Преглед изворни кода

Merge branch 'master' into zhongqi-delivery

shish пре 7 месеци
родитељ
комит
375258ebbf

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

@@ -641,7 +641,7 @@ class ProductController extends BaseController
         }
 
         $shopAdmin = $this->shopAdmin;
-        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+        if (!isset($shopAdmin->super) || $shopAdmin->super != 1) {
             util::fail('超管才能修改');
         }
 

+ 11 - 3
app-ghs/controllers/TestController.php

@@ -43,11 +43,19 @@ class TestController extends BaseController
 
     public $guestAccess = ['rabbit', 'recharge', 'fx', 'on', 'in', 'clear-query', 'ip', 'html', 'debt', 'apply', 'clear', 'ls-trade-query', 'ls-trade-refund', 'refund-query', 'inform', 'notice', 'order-query', 'add-order', 'index', 'get', 'trade-query', 'query', 'balance-query', 'refund', 'recharge-query', 'sim', 'push', 'code'];
 
+    // ./yii test/rabbit 0
     public function actionRabbit()
     {
-        $producer = Yii::$app->rabbitmq->getProducer('stockProducer');
-        $msg = serialize(['type' => 'add', 'name' => 'shish']);
-        $producer->publish($msg, 'stockExchange', 'stockRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $event = '跑腿已经取消了' . rand(1, 999);
+        if ($id == 0) {
+            $orderId = 5231;
+            GhsNotifyClass::ptErrorNotify($orderId, $event);
+        } else {
+            $orderId = 525111;
+            HdNotifyClass::ptErrorNotify($orderId, $event);
+        }
     }
 
     public function actionFx()

+ 24 - 27
biz-ghs/order/classes/StockInOrderClass.php

@@ -191,6 +191,13 @@ class StockInOrderClass extends BaseClass
             util::fail("订单异常");
         }
 
+        $chainShopList = [];
+        $default = $shop->default ?? 0;
+        $sjId = $shop->sjId ?? 0;
+        if ($default == 1) {
+            $chainShopList = \bizGhs\merchant\classes\ShopClass::getAllByCondition(['sjId' => $sjId, 'join' => 0], null, '*', null, true);
+        }
+
         $totalCost = $orderData['price'] ?? 0;
         foreach ($itemInfo as $k => $v) {
             $currentItemId = $v['productId'] ?? 0;
@@ -203,15 +210,6 @@ class StockInOrderClass extends BaseClass
             $currentInfo = ProductClass::getById($currentItemId, true);
             if (isset($currentInfo->stock) && floatval($currentInfo->stock) == 0) {
                 $upData = ['cost' => $currentCost];
-                if ($currentHdPrice > 0) {
-                    $upData['price'] = $currentHdPrice;
-                }
-                if ($currentSkPrice > 0) {
-                    $upData['skPrice'] = $currentSkPrice;
-                }
-                if ($currentHjPrice > 0) {
-                    $upData['hjPrice'] = $currentHjPrice;
-                }
                 ProductClass::updateById($currentItemId, $upData);
                 //成本变动记录
                 $changeData = [
@@ -231,24 +229,23 @@ class StockInOrderClass extends BaseClass
                 ];
                 CostChangeClass::addData($changeData);
                 if ($currentHdPrice > 0) {
-                    $changeData = [
-                        'ptStyle' => 2,
-                        'sjId' => $currentInfo->sjId ?? 0,
-                        'mainId' => $mainId,
-                        'itemId' => $currentInfo->id ?? 0,
-                        'ptItemId' => $currentInfo->itemId ?? 0,
-                        'price' => $currentHdPrice,
-                        'skPrice' => $currentSkPrice,
-                        'hjPrice' => $currentHjPrice,
-                        'staffId' => $staffId,
-                        'staffName' => $staffName,
-                        'name' => $currentInfo->name ?? '',
-                        'cover' => $currentInfo->cover ?? '',
-                        'event' => $event,
-                        'targetId' => $orderId,
-                        'type' => 2,
-                    ];
-                    PriceChangeClass::addData($changeData);
+                    $ptItemId = $currentInfo->itemId ?? 0;
+                    $changeParams = ['staffId' => $staffId, 'staffName' => $staffName, 'event' => '调拨入库改价', 'targetId' => $orderId];
+                    ProductClass::changeSinglePrice($shop, $ptItemId, $currentHdPrice, $currentSkPrice, $currentHjPrice, $changeParams);
+                    //在首店修改需要同步到所有直营店
+                    if ($default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
+                        foreach ($chainShopList as $chain) {
+                            if ($chain->id == $shop->id) {
+                                continue;
+                            }
+                            $chainMainId = $chain->mainId ?? 0;
+                            $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
+                            $staffId = $staff->id ?? 0;
+                            $staffName = $staff->name ?? '';
+                            $changeParams2 = ['staffId' => $staffId, 'staffName' => $staffName, 'event' => '调拨入库改价,同步给分店'];
+                            ProductClass::changeSinglePrice($chain, $ptItemId, $currentHdPrice, $currentSkPrice, $currentHjPrice, $changeParams2);
+                        }
+                    }
                 }
             }
 

+ 2 - 1
biz-ghs/product/classes/ProductClass.php

@@ -1317,7 +1317,7 @@ class ProductClass extends BaseClass
         $staffName = $params['staffName'] ?? '';
         $changeType = $params['changeType'] ?? 'normal';
         $targetId = $params['targetId'] ?? 0;
-        $event = '修改';
+        $event = $params['event'] ?? '修改';
         $type = 0;
         if ($changeType == 'cg') {
             $event = '采购后修改';
@@ -1341,6 +1341,7 @@ class ProductClass extends BaseClass
             'targetId' => $targetId,
         ];
         PriceChangeClass::addData($changeData);
+        return true;
     }
 
     //下单时计算商品的价格  lqh 2021.1.28

+ 5 - 1
biz/wx/classes/WxMessageClass.php

@@ -125,7 +125,11 @@ class WxMessageClass extends BaseClass
                 ]
             ];
             $data['miniprogram']['appid'] = $wx['miniAppId'];
-            $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
+            if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+                $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
+            } else {
+                $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
+            }
             wxUtil::sendTaskInform($data, $wx, $ptStyle);
         }
     }

+ 19 - 0
common/components/rabbitmq/notifyConsumer.php

@@ -61,6 +61,7 @@ class notifyConsumer implements ConsumerInterface
                     break;
                 case 'hd_pt_error':
                     //花店跑腿异常通知
+                    $result = $this->hdPtErrorAction($data);
                     break;
                 default:
                     noticeUtil::push("通知的消费者提示:Unknown notify type: {$type}", '15280215347');
@@ -96,6 +97,24 @@ class notifyConsumer implements ConsumerInterface
         return true;
     }
 
+    private function hdPtErrorAction($data)
+    {
+        $orderId = $data['orderId'] ?? 0;
+        $event = $data['event'] ?? '';
+        $order = \bizHd\order\classes\OrderClass::getById($orderId, true);
+        if (!empty($order)) {
+            $sendNum = $order->sendNum ?? '';
+            $result = $event . ',取货号:' . $sendNum;
+            $customName = $order->customName ?? '';
+            $shopId = $order->shopId ?? '';
+            $shop = ShopClass::getById($shopId, true);
+            if (!empty($shop)) {
+                WxMessageClass::expressErrorInform($shop, $customName, $orderId, $result);
+            }
+        }
+        return true;
+    }
+
     private function ghsNewOrderNotify($data)
     {
         $orderId = $data['orderId'] ?? 0;

+ 1 - 0
common/components/wxUtil.php

@@ -537,6 +537,7 @@ class wxUtil
         $curl = new curl\Curl();
         $response = $curl->setOption(CURLOPT_POSTFIELDS, $data)->post($url);
         Yii::info('发送模板消息返回:' . $response);
+        //noticeUtil::push('发送模板消息返回:' . $response, '15280215347');
         $arr = json_decode($response);
         return $arr;
     }