shish 3 anni fa
parent
commit
4709c065b3
1 ha cambiato i file con 23 aggiunte e 2 eliminazioni
  1. 23 2
      app-mall/controllers/OrderController.php

+ 23 - 2
app-mall/controllers/OrderController.php

@@ -3,6 +3,7 @@
 namespace mall\controllers;
 
 use bizHd\wx\classes\WxOpenClass;
+use bizMall\custom\classes\CustomClass;
 use bizMall\goods\classes\GoodsClass;
 use bizMall\goods\services\GoodsService;
 use bizMall\merchant\services\ExpressService;
@@ -33,6 +34,17 @@ class OrderController extends BaseController
         $post['payWay'] = $this->isWx == true ? 0 : 1;
         $post['mainId'] = $this->mainId ?? 0;
         $post['userId'] = $this->userId ?? 0;
+
+
+        $custom = CustomClass::getByCondition(['shopId' => $this->shopId, 'userId' => $this->userId], true);
+        $customId = $custom->id ?? 0;
+        if (!empty($custom)) {
+            $post['customId'] = $customId;
+            $customName = $custom->name ?? '';
+            $post['customName'] = $customName;
+            $post['customNamePy'] = stringUtil::py($customName);
+        }
+
         $now = time();
         //订单30分钟后过期
         $expireTime = $now + 1800;
@@ -93,8 +105,16 @@ class OrderController extends BaseController
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            $post['customId'] = $this->customId;
-            $post['customName'] = $this->custom['name'] ?? '';
+
+            $custom = CustomClass::getByCondition(['shopId' => $this->shopId, 'userId' => $this->userId], true);
+            $customId = $custom->id ?? 0;
+            if (!empty($custom)) {
+                $post['customId'] = $customId;
+                $customName = $custom->name ?? '';
+                $post['customName'] = $customName;
+                $post['customNamePy'] = stringUtil::py($customName);
+            }
+
             $user = isset($this->user->attributes) ? $this->user->attributes : [];
             $post['bookName'] = isset($user['userName']) ? $user['userName'] : '';
             $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
@@ -117,6 +137,7 @@ class OrderController extends BaseController
             $post['shopId'] = $this->shopId;
             $mainId = $this->mainId;
             $post['mainId'] = $mainId;
+            $post['userId'] = $this->userId;
             //计算总金额
             $unitPrice = $goodsInfo['price'];
             $goodsStyleList = isset($goodsInfo['goodsStyleList']) ? $goodsInfo['goodsStyleList'] : [];