input('verify_code'); //订单ID $code_arr = explode('-', $input_verify_code); if (count($code_arr) != 2) { return $this->error('参数错误'); } list($id, $verify_code) = $code_arr; $order = Order::with('agentProduct:id,verifier') ->where(['agent_id' => $this->agent_id, 'verify_code' => $verify_code]) ->whereIn('status', [OrderStatus::PAID, OrderStatus::PAID_RETAINAGE, OrderStatus::OFFLINE_PAID]) ->find($id); if (!$order) { return $this->error('订单不存在或订单状态不允许核销'); } $mobile = User::where('id', $this->user_id)->value('mobile'); $checkMobile = Product::query()->whereIn('id', explode(',', $order->product_ids))->where('verify_mobile', $mobile)->doesntExist(); if ($checkMobile) { return $this->error('对不起,你没有核销权限,请联系管理员'); } $order->status = OrderStatus::SUCCESS; $order->save(); return $this->success(); } }