find($combo_id); if (empty($comboInfo)) { return responseMessage(2002, '该产品可能已删除,请重试!'); } if ($comboInfo['status'] == 2) { return responseMessage(2003, '对不起,该产品已下架,不能购买!'); } // $preferential_type = 1; // 会员卡 $totalPrice = $comboInfo['price']; //所有的商品总金额 $totalPreferentialPrice = 0; $order_amount_total = $totalPrice - $totalPreferentialPrice; //实际付款金额 $order_status = 1; //1 未支付 2 已支付 $order_no = 'CO' . createNewOrderNo(); $info = [ 'user_id' => $this->userId, 'order_no' => $order_no, 'order_status' => $order_status, //1 未支付 'product_amount_total' => $totalPrice, //所有购买商品总价 'order_amount_total' => $order_amount_total, //实际付款金额 'pay_amount_total' => 0, 'preferential_price' => $totalPreferentialPrice, //订单优惠金额(优惠券等) 'preferential_type' => $preferential_type, // //优惠类型 1优惠券 2会员卡 'pay_channel' => '', 'product_ids' => $comboInfo['product_ids'], // 服务商品,便于搜索 ]; $isSuccess = ES::table('order_combo')->toRefresh()->insertGetId($info); if ($isSuccess) { return responseMessage(1001, '订单创建成功!', $order_no); } else { return responseMessage(2008, '订单创建失败,请重试!'); } } public function getOrderInfo($orderNo, $where = []): array { $find = ES::table('order_combo')->where('order_no', $orderNo); if ($where) { $find->where($where); } return $find->first(); } }