| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace App\Http\Controllers\admin;
- 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]
- * @apiParam {int=0,1,2} type 类型 0全部 1=代收,2=代付
- * @apiParam {String} order_no 订单号
- * @apiPaaram {String} member_id 会员ID
- * @apiParam {int=0,1,2,3} [status] 状态:0待处理 1处理中 2成功 3失败
- *
- */
- public function index()
- {
- try {
- $params = request()->validate([
- 'page' => ['nullable', 'integer', 'min:1'],
- 'limit' => ['nullable', 'integer', 'min:1'],
- 'type' => ['required', 'integer', 'in:0,1,2'],
- 'order_no' => ['nullable', 'string'],
- 'status' => ['nullable', 'integer', 'in:0,1,2,3'],
- ]);
- $result = PaymentOrderService::paginate($params);
- } 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($result);
- }
- /**
- * @description: 查询订单的支付情况
- * @return {*}
- */
- public function check()
- {
- $id = request()->input('id');
- if (empty($id)) {
- return $this->error(HttpStatus::CUSTOM_ERROR, '参数错误');
- }
- try {
- $result = PaymentOrderService::singlePayOrder($id);
- $this->success([], $result['msg'] ?? '操作成功');
- } catch (Exception $e) {
- return $this->error(intval($e->getCode()));
- }
- return $this->success([], $result['msg'] ?? '操作成功');
- }
- }
|