海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
866 B

  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Order;
  5. use App\Models\User;
  6. use App\Service\OrderStatus;
  7. class VerificationController extends Controller
  8. {
  9. //核销订单
  10. public function verify()
  11. {
  12. $id = (int)request()->input('id'); //订单ID
  13. $user = User::firstWhere(['id' => $this->user_id, 'status' => 1]);
  14. if (!$user || $user->verifier != 1) {
  15. return $this->error('对不起,你没有核销权限,请联系管理员');
  16. }
  17. $order = Order::query()->where('agent_id', $this->agent_id)->find($id);
  18. if (!$order) {
  19. return $this->error('订单不存在或无权限');
  20. }
  21. if (!in_array($order->status, [OrderStatus::PAID, OrderStatus::PAY_RETAINAGE])) {
  22. return $this->error('当前订单状态不允许核销');
  23. }
  24. $order->status = 16;
  25. $order->save();
  26. return $this->success();
  27. }
  28. }