|
|
@@ -7,11 +7,42 @@ use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Services\PaymentOrderService;
|
|
|
use Exception;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
|
|
class PaymentOrder extends Controller
|
|
|
{
|
|
|
|
|
|
+
|
|
|
+ public function audit()
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $validate = [
|
|
|
+ 'id' => ['required', 'integer', 'min:1'],
|
|
|
+ 'status' => ['required', 'integer', 'in:1,3'],
|
|
|
+ ];
|
|
|
+ $status = request()->input('status', null);
|
|
|
+ if ($status == 3) {
|
|
|
+ $validate['remark'] = ['required', 'string', 'min:1', 'max:120'];
|
|
|
+ }
|
|
|
+ $params = request()->validate($validate);
|
|
|
+ $remark = request()->input('remark', '');
|
|
|
+ if ($params['status'] == 1) {
|
|
|
+ $ret = PaymentOrderService::createPayout($params['id']);
|
|
|
+ if ($ret['code'] !== 0) throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
|
|
|
+ } else {
|
|
|
+ $ret = PaymentOrderService::withdrawalFailed($params['id'], $remark);
|
|
|
+ if ($ret['code'] !== 0) throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
|
|
|
+ }
|
|
|
+ } catch (ValidationException $e) {
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
|
|
|
+ }
|
|
|
+ return $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @apiParam {int} [page]
|
|
|
* @apiParam {int} [limit]
|
|
|
@@ -37,7 +68,7 @@ class PaymentOrder extends Controller
|
|
|
} catch (ValidationException $e) {
|
|
|
return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
|
} catch (Exception $e) {
|
|
|
- return $this->error(intval($e->getCode()));
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
|
|
|
}
|
|
|
return $this->success($result);
|
|
|
}
|
|
|
@@ -45,20 +76,20 @@ class PaymentOrder extends Controller
|
|
|
/**
|
|
|
* @description: 查询订单的支付情况
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public function check()
|
|
|
{
|
|
|
$id = request()->input('id');
|
|
|
- if(empty($id)){
|
|
|
- return $this->error(HttpStatus::CUSTOM_ERROR,'参数错误');
|
|
|
+ if (empty($id)) {
|
|
|
+ return $this->error(HttpStatus::CUSTOM_ERROR, '参数错误');
|
|
|
|
|
|
}
|
|
|
try {
|
|
|
$result = PaymentOrderService::singlePayOrder($id);
|
|
|
- $this->success([],$result['msg'] ?? '操作成功');
|
|
|
+ $this->success([], $result['msg'] ?? '操作成功');
|
|
|
} catch (Exception $e) {
|
|
|
return $this->error(intval($e->getCode()));
|
|
|
}
|
|
|
- return $this->success([],$result['msg'] ?? '操作成功');
|
|
|
+ return $this->success([], $result['msg'] ?? '操作成功');
|
|
|
}
|
|
|
}
|