post(); $bidding_order = BiddingOrder::where(['id' => $requestData['bidding_order_id']])->findOrEmpty(); if ($bidding_order->isEmpty()) { throw new Exception('未找到出价订单'); } if ($bidding_order->bind_status != 1) { throw new Exception('该出价订单未中标,支付失败'); } if ($bidding_order->pay_final_status != 0) { throw new Exception('订单状态异常,支付失败'); } $requirement = Requirement::where(['id' => $bidding_order->requirement_id])->findOrEmpty(); //@todo:判断是否需要支付定金 if(1){ } $trade_no = generate_order_no('B'); //创建订单 DepositOrder::create([ 'user_id' => $bidding_order->user_id, 'photographer_id' => $bidding_order->photographer_id, 'detail' => json_encode($requirement->toArray()), 'order_type' => 'requirement', 'deposit_amount' => $requirement->deposit_amount, 'trade_no' => $trade_no, 'pay_status' => 0, ]); $pay_data = [ 'trade_no' => $trade_no, 'total_amount' => $bidding_order->bidding_price, 'desc' => $requirement->requirement_trade_no . '-定金', 'notify_url' => getenv('SERVER_DOMAIN') . self::NOTIFY_URL,//回调地址 'openid' => $request->user->openid, ]; $result = (new PayService())->payment($pay_data); if(isset($result['code'])){ throw new Exception($result['msg']); } return [ 'code' => ResponseCode::SUCCESS, 'data' => $result, ]; } catch (Exception $e) { return [ 'code' => ResponseCode::FAIL, 'msg' => $e->getMessage() ]; } } }