|
|
@@ -15,6 +15,8 @@ use common\components\util;
|
|
|
|
|
|
class OrderController extends BaseController
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//商城下单操作 shish 2019.12.3
|
|
|
public function actionCreateOrder()
|
|
|
@@ -22,6 +24,7 @@ class OrderController extends BaseController
|
|
|
//给出省市区的接口 todo
|
|
|
//给出商家门店地址接口 todo
|
|
|
//给出腾讯的接口 todo
|
|
|
+ //运费 计算方式 todo
|
|
|
|
|
|
$post = Yii::$app->request->post();
|
|
|
$goodsId = isset($post['goodsId']) ? $post['goodsId'] : 0;
|
|
|
@@ -34,16 +37,15 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
//确认是否要配送的商品
|
|
|
$needSend = isset($goodsInfo['needSend']) && $goodsInfo['needSend'] == 1 ? 1 : 0;
|
|
|
-
|
|
|
- $userId = $this->userId;
|
|
|
- $post['userId'] = $userId;
|
|
|
+dd($goodsInfo);
|
|
|
+ $post['userId'] = $this->userId;
|
|
|
$post['payWay'] = $this->isWeixin == true ? 0 : 1;
|
|
|
$defaultShopId = MerchantService::getDefaultShopId($this->merchant);
|
|
|
if (empty($defaultShopId)) {
|
|
|
util::fail('没有找到门店');
|
|
|
}
|
|
|
$shopInfo = ShopService::getById($defaultShopId);
|
|
|
-
|
|
|
+
|
|
|
//计算运费
|
|
|
$post['sendDistance'] = isset($post['sendDistance']) ? $post['sendDistance'] : 0;
|
|
|
$post['sendCost'] = 0;
|
|
|
@@ -54,20 +56,19 @@ class OrderController extends BaseController
|
|
|
$sendCost = ShopService::getSendCost($lat, $lng, $jsStatDistance, $shopInfo);
|
|
|
$post['sendCost'] = $sendCost;
|
|
|
}
|
|
|
- //付款成功才保存优惠券id
|
|
|
- unset($post['couponId']);
|
|
|
$post['merchantId'] = $this->merchantId;
|
|
|
$post['shopId'] = $defaultShopId;
|
|
|
+
|
|
|
$order = OrderService::add($post);
|
|
|
$orderId = $order['id'];
|
|
|
|
|
|
$data = [
|
|
|
'orderId' => $orderId,
|
|
|
'goodsId' => $goodsId,
|
|
|
- 'userId' => $userId,
|
|
|
+ 'userId' => $this->userId,
|
|
|
'merchantId' => $this->merchantId,
|
|
|
- 'title' => $goods['goodsName'],
|
|
|
- 'cover' => $goods['cover'],
|
|
|
+ 'title' => $goodsInfo['goodsName'],
|
|
|
+ 'cover' => $goodsInfo['cover'],
|
|
|
'unitPrice' => $price,
|
|
|
'num' => $num,
|
|
|
'multiPriceId' => $multiPriceId,
|
|
|
@@ -75,6 +76,9 @@ class OrderController extends BaseController
|
|
|
];
|
|
|
xhOrderGoodsService::add($data);//创建订单商品列表
|
|
|
|
|
|
+ //付款成功才保存优惠券id
|
|
|
+ unset($post['couponId']);
|
|
|
+
|
|
|
util::success(['orderId' => $orderId, 'couponId' => $couponId]);
|
|
|
}
|
|
|
|