|
|
@@ -15,9 +15,12 @@ class PaymentOrder extends Controller
|
|
|
|
|
|
public function audit()
|
|
|
{
|
|
|
+ DB::beginTransaction();
|
|
|
try {
|
|
|
$validate = [
|
|
|
- 'id' => ['required', 'integer', 'min:1'],
|
|
|
+// 'id' => ['required', 'integer', 'min:1'],
|
|
|
+ 'ids' => ['required', 'array', 'min:1','max:20'],
|
|
|
+ 'ids.*' => ['required', 'integer', 'min:1'],
|
|
|
'status' => ['required', 'integer', 'in:1,3'],
|
|
|
];
|
|
|
$status = request()->input('status', null);
|
|
|
@@ -26,16 +29,27 @@ class PaymentOrder extends Controller
|
|
|
}
|
|
|
$params = request()->validate($validate);
|
|
|
$remark = request()->input('remark', '');
|
|
|
+
|
|
|
+ $count = 0;
|
|
|
if ($params['status'] == 1) {
|
|
|
$ret = PaymentOrderService::createPayout($params['id']);
|
|
|
+ if ($ret['code'] === 0)$count++;
|
|
|
if ($ret['code'] !== 0) throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
|
|
|
} else {
|
|
|
$ret = PaymentOrderService::withdrawalFailed($params['id'], $remark);
|
|
|
+ if ($ret['code'] === 0)$count++;
|
|
|
if ($ret['code'] !== 0) throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
|
|
|
}
|
|
|
+
|
|
|
+ if ($count < 1) {
|
|
|
+ throw new Exception('操作失败', HttpStatus::CUSTOM_ERROR);
|
|
|
+ }
|
|
|
+ DB::commit();
|
|
|
} catch (ValidationException $e) {
|
|
|
+ DB::rollBack();
|
|
|
return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
|
} catch (Exception $e) {
|
|
|
+ DB::rollBack();
|
|
|
return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
|
|
|
}
|
|
|
return $this->success();
|