shish vor 2 Jahren
Ursprung
Commit
e1fa77c4e9
1 geänderte Dateien mit 111 neuen und 0 gelöschten Zeilen
  1. 111 0
      app-hd/controllers/NoticeController.php

+ 111 - 0
app-hd/controllers/NoticeController.php

@@ -107,6 +107,117 @@ class NoticeController extends PublicController
             }
             //请不要修改
             echo "SUCCESS";
+
+            //解决重复通知
+            $cacheKey = 'pay_success_notice_' . $orderSn;
+            $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+            if (!empty($has)) {
+                Yii::$app->end();
+            }
+            Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 864000, 'has']);
+
+            //零售采购结账通知
+            if ($capitalType == dict::getDict('capitalType', 'xhPurchase', 'id')) {
+                $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
+                $saleId = $cg->saleId ?? 0;
+                $order = OrderClass::getById($saleId, true);
+
+                //不是预订单,并且采购人没有开批发店,供货商不是源花汇和小明鲜花,则订单直接完成掉,有三个地方要修改,请搜索关键词zjFinish
+                if (!empty($cg) && !empty($order)) {
+                    if (isset($cg->book) && $cg->book == 0) {
+                        $ghsShopId = $order->shopId ?? 0;
+                        if (getenv('YII_ENV') == 'production') {
+                            $specialList = [3, 10649, 8042];
+                        } else {
+                            $specialList = [36523];
+                        }
+                        if (!in_array($ghsShopId, $specialList)) {
+                            $cgShopId = $cg->shopId ?? 0;
+                            $cgShop = ShopClass::getById($cgShopId, true);
+                            if (!empty($cgShop)) {
+                                if (isset($cgShop->pfShopId) && $cgShop->pfShopId == 0) {
+                                    PurchaseClass::confirmTake($cg);
+                                }
+                            }
+                        }
+                    }
+                }
+
+                if (isset($cg->localOrder) && $cg->localOrder == 1) {
+                    if ($cg->transType != 5 && $cg->transType != 4) {
+                        //昆明发货,客户算了一次打包费和运费,第二次就不再算了
+                        $customId = $cg->customId ?? 0;
+                        $current = date("Y_m_d");
+                        $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
+                        Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
+                    }
+                } else {
+                    if (isset($cg->sendType) && $cg->sendType == 4) {
+                        //标记当天发快递方式已收一次包装费,岭南批发市场用的功能
+                        $customId = $cg->customId ?? 0;
+                        $current = date("Y_m_d");
+                        $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
+                        Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
+                    }
+                }
+
+                if (!empty($cg) && $cg->payStatus == 1) {
+                    //微信通知
+                    if (!empty($order)) {
+                        //订单生成时唤起在线打印
+                        if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
+                            //有几个地方要同步去修改
+                            if (getenv('YII_ENV') == 'production') {
+                                //源花汇不自动打开小票
+                                $mallOrderNoPrint = [10536];
+                            } else {
+                                $mallOrderNoPrint = [];
+                            }
+                            if (in_array($order->mainId, $mallOrderNoPrint)) {
+
+                            } else {
+                                OrderClass::onlinePrint($order);
+                                $order->printNum += 1;
+                                $order->save();
+
+                                if (getenv('YII_ENV') == 'production') {
+                                    //福州我要花要打二次小票
+                                    $needTwoPrint = [7538];
+                                } else {
+                                    $needTwoPrint = [];
+                                }
+                                if (in_array($order->mainId, $needTwoPrint)) {
+                                    OrderClass::onlinePrint($order);
+                                    $order->printNum += 1;
+                                    $order->save();
+                                }
+
+                            }
+                        }
+                        $cgShopId = $cg->shopId ?? 0;
+                        $cgShop = ShopClass::getById($cgShopId, true);
+                        if (!empty($cgShop)) {
+                            \bizHd\notice\classes\NoticeClass::cgSuccessMiniNotice($cgShop, $cg);
+                        }
+                        //如果是门店用手机开单,让客户扫码付款的,则也要语音提示
+                        if (isset($order->shopAdminId) && $order->shopAdminId > 0) {
+                            ShopExtClass::ghsGatheringReport($order);
+                        }
+                        $shopId = $order->shopId ?? 0;
+                        $shop = ShopClass::getById($shopId, true);
+                        if (!empty($shop)) {
+                            //花店采购供货商端微信收到通知
+                            //WxMessageClass::ghsHasNewOrderInform($shop, $order);
+                            $noticeText = json_encode(['orderId' => $saleId]);
+                            $noticeKey = "hdCgNoticeGhs";
+                            Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
+                        }
+                        //花店采购供货商端APP收到通知
+                        //NoticeClass::ghsNewOrderNotice($order);
+                    }
+                }
+            }
+
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::error("失败原因:" . $e->getMessage());