|
|
|
@ -161,25 +161,21 @@ class Order extends BaseService |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @notes:生成订单 |
|
|
|
|
* @param int $serverId |
|
|
|
|
* @param array $params |
|
|
|
|
* @param int $couponId |
|
|
|
|
* @param string $server_address |
|
|
|
|
* @param string $server_time |
|
|
|
|
* @param string $buyer_remark |
|
|
|
|
* @return array |
|
|
|
|
* @throws BaseException |
|
|
|
|
* @throws DbException |
|
|
|
|
* @author: wanghousheng |
|
|
|
|
*/ |
|
|
|
|
public function createOrder(int $serverId, int $couponId, string $server_address, string $server_time, string $buyer_remark = ''): array |
|
|
|
|
public function createOrder(array $params, int $couponId): array |
|
|
|
|
{ |
|
|
|
|
$userId = UserService::getCurrentLoginUserId(); |
|
|
|
|
$data = $this->onCheck($serverId, $couponId); |
|
|
|
|
$data = $this->onCheck($params['server_id'], $couponId); |
|
|
|
|
// 设置优惠券使用状态 |
|
|
|
|
$couponId > 0 && UserCoupon::setIsUse($couponId); |
|
|
|
|
//封装数据 |
|
|
|
|
$order_data = [ |
|
|
|
|
'server_id' => $this->serverInfo['server_id'], |
|
|
|
|
'order_no' => $this->orderNo(), |
|
|
|
|
'server_name' => $this->serverInfo['server_name'], |
|
|
|
|
'server_image_id' => $this->serverInfo['image_id'], |
|
|
|
@ -189,12 +185,10 @@ class Order extends BaseService |
|
|
|
|
'coupon_id' => $data['coupon_id'], |
|
|
|
|
'coupon_money' => $data['coupon_money'], |
|
|
|
|
'pay_price' => $data['pay_price'], |
|
|
|
|
'buyer_remark' => $buyer_remark, |
|
|
|
|
'create_time' => time(), |
|
|
|
|
'update_time' => time(), |
|
|
|
|
'server_time' => $server_time, |
|
|
|
|
'server_address' => $server_address, |
|
|
|
|
]; |
|
|
|
|
$order_data = array_merge($order_data, $params); |
|
|
|
|
$model = new ServerOrder(); |
|
|
|
|
$order_id = $model->insertGetId($order_data); |
|
|
|
|
if ($order_id) { |
|
|
|
|