Przeglądaj źródła

Merge branch 'master' into zhongqi-IntraCityExpress

shish 11 miesięcy temu
rodzic
commit
3d84f195f9

+ 1 - 1
app-ghs/controllers/OrderController.php

@@ -1133,7 +1133,7 @@ class OrderController extends BaseController
 
         $shop = $this->shop;
 
-        //到期超过5天不支持开单
+        //过期不支持开单
         $deadline = $shop->deadline;
         $deadTime = strtotime($deadline);
         $myCurrentTime = time();

+ 36 - 8
app-hd/controllers/OrderController.php

@@ -581,14 +581,8 @@ class OrderController extends BaseController
         try {
             $post['product'] = $productList;
 
-            //3秒内不允许重复开单
-            $staffId = $this->shopAdminId ?? 0;
-            $cacheKey = 'hd_create_order_' . $staffId . '_' . $customId;
-            $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
-            if (!empty($has)) {
-                util::fail('稍等5秒再开单');
-            }
-            Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 3, 'has']);
+            //解决重复提交
+            util::checkRepeatCommit($this->adminId, 3);
 
             $reduceStock = $post['reduceStock'] ?? 0;
             if ($reduceStock == 1) {
@@ -598,6 +592,40 @@ class OrderController extends BaseController
                 util::success($return);
             }
 
+            //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
+            $version = $post['version'] ?? 0;
+            if ($version == 2) {
+                $dealPrice = $post['dealPrice'] ?? 0;
+                if ($dealPrice == 0) {
+                    $ids = array_unique(array_filter(array_column($productList, 'productId')));
+                    $itemInfo = ProductClass::getByIds($ids, null, 'id');
+                    if (empty($itemInfo)) {
+                        util::fail('要选择花材哦');
+                    }
+                    $diff = [];
+                    $priceMap = \bizGhs\custom\classes\CustomClass::$levelPriceKeyMap;
+                    $addPriceMap = \bizGhs\custom\classes\CustomClass::$levelAddPriceKeyMap;
+                    $level = 0;
+                    foreach ($productList as $currentProduct) {
+                        $currentPrice = $currentProduct['unitPrice'] ?? 0;
+                        $currentId = $currentProduct['productId'] ?? 0;
+                        $systemInfo = $itemInfo[$currentId] ?? [];
+                        $name = $systemInfo['name'] ?? '';
+                        $systemPrice = \bizGhs\product\classes\ProductClass::getFinalPrice($systemInfo, $level, $priceMap, $addPriceMap);
+                        if (floatval($currentPrice) != floatval($systemPrice)) {
+                            $diff[] = [
+                                'name' => $name,
+                                'price' => $systemPrice,
+                                'kdPrice' => $currentPrice,
+                            ];
+                        }
+                    }
+                    if (!empty($diff)) {
+                        util::success(['diff' => $diff, 'respondType' => 'priceError']);
+                    }
+                }
+            }
+
             //多处调用这个方法,注意同步修改,搜索关键词 createHdNewOrder
             $return = OrderService::createHdOrder($post, $custom, $hasPay);
             $shop = $this->shop;

+ 7 - 0
app-hd/controllers/ShopExtController.php

@@ -287,6 +287,13 @@ class ShopExtController extends BaseController
         util::complete('设置成功');
     }
 
+    public function actionInfo()
+    {
+        $shopId = $this->shopId;
+        $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        util::success(['ext' => $ext]);
+    }
+
     public function actionModifyGatherRepeat()
     {
         $staff = $this->shopAdmin;

+ 10 - 0
biz-ghs/apply/services/ApplyService.php

@@ -4,6 +4,7 @@ namespace bizGhs\apply\services;
 
 use biz\cp\services\PtCpService;
 use biz\shop\classes\ShopClass;
+use biz\shop\classes\ShopExtClass;
 use bizGhs\apply\classes\ApplyClass;
 use bizGhs\item\classes\ItemClassClass;
 use bizGhs\merchant\services\MerchantService;
@@ -45,6 +46,15 @@ class ApplyService extends BaseService
                 util::fail('没有main信息21');
             }
         }
+
+        //收款码要做成不算收入
+        $lsShopId = $lsShop->id;
+        $lsExt = ShopExtClass::getByCondition(['shopId' => $lsShopId], true);
+        if (!empty($lsExt)) {
+            $lsExt->gatherRepeat = 1;
+            $lsExt->save();
+        }
+
         ApplyClass::updateById($applyId, ['status' => ApplyClass::STATUS_PASS, 'remark' => $remark]);
         $apply['name'] = isset($apply['name']) ? $apply['name'] : '';
         //初始化或更新花材

+ 3 - 0
biz-hd/order/classes/OrderClass.php

@@ -1098,6 +1098,9 @@ class OrderClass extends BaseClass
         if ($order->tkPrice > 0) {
             util::fail('已经发生退款,无法操作');
         }
+        if ($order->customId != $customId) {
+            util::fail('订单对应客户有问题,无法扣库存,编号:' . $customId . ' ' . $order->customId);
+        }
         $orderSn = $order->orderSn ?? '';
         $product = $data['product'] ?? [];
         if (empty($product)) {