shish 9 hónapja
szülő
commit
b4de63d562
2 módosított fájl, 56 hozzáadás és 113 törlés
  1. 17 2
      app-mall/controllers/NoticeController.php
  2. 39 111
      biz/shop/classes/ShopExtClass.php

+ 17 - 2
app-mall/controllers/NoticeController.php

@@ -8,6 +8,8 @@ use bizHd\order\classes\OrderClass;
 use bizHd\order\classes\ScanPayClass;
 use bizHd\recharge\classes\RechargeClass;
 use bizHd\refund\classes\HdRefundClass;
+use bizHd\shop\classes\MainClass;
+use bizHd\work\classes\WorkClass;
 use bizHd\wx\classes\WxOpenClass;
 use common\components\noticeUtil;
 use common\components\payUtil;
@@ -168,11 +170,24 @@ class NoticeController extends PublicController
 
                     $shopId = $order->shopId ?? 0;
                     $shop = ShopClass::getById($shopId, true);
+                    //制作任务
+                    $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+                    if ($shopExt->needWork == 1 && $order->hasWork != 1) {
+                        $mainId = $shop->mainId ?? 0;
+                        $main = MainClass::getById($mainId, true);
+                        $orderId = $order->id ?? 0;
+                        WorkClass::needWork($order, $main);
+                        $has = WorkClass::getByCondition(['orderId' => $orderId], true);
+                        if (!empty($has)) {
+                            $order->hasWork = 1;
+                            $order->save();
+                        }
+                        ShopExtClass::newWorkRemind($shopExt, $order);
+                    }
+
                     //来自商城的新订单微信通知
                     WxMessageClass::hdNewOrderInform($shop, $order);
 
-                    $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
-                    ShopExtClass::newWorkRemind($shopExt, $order);
                 }
             }
 

+ 39 - 111
biz/shop/classes/ShopExtClass.php

@@ -104,126 +104,54 @@ class ShopExtClass extends BaseClass
         }
     }
 
-    //新制作单提示
+    //新制作单提示
     public static function newWorkRemind($shopExt, $order)
     {
-        $id = $order->id ?? 0;
-        $list = WorkClass::getAllByCondition(['orderId' => $id], null, '*', null, true);
-        if (empty($list)) {
-            //提示有订单,但没有生成制作单
-            if (isset($order->shopAdminId) == false || empty($order->shopAdminId)) {
-                //$lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
-                //$lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
-                if (!empty($lbSn)) {
-                    //$sound = "您有新订单,编号{$order->sendNum},因还有库存,没有生成制作单";
-                    //$url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
-                    //$curl = new curl\Curl();
-                    //$curl->get($url);
+        $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
+        $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
+        if (empty($lbSn)) {
+            return false;
+        }
+        $sound = "您有新的制作单";
+        $reachDate = $order->reachDate ?? '';
+        if ($order->sendType == 1) {
+            if (!empty($reachDate) && $reachDate != '0000-00-00') {
+                $readPeriod = $order->reachPeriod ?? 0;
+                $period = explode(':', $readPeriod);
+                $periodName = implode($period, '点');
+                if ($reachDate == date("Y-m-d")) {
+                    $sound .= ',今天' . $periodName . "分到店自取";
+                } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
+                    $sound .= ',明天' . $periodName . "分到店自取";
+                } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
+                    $sound .= ',后天' . $periodName . "分到店自取";
+                } else {
+                    $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分到店自取";
                 }
-                //noticeUtil::push("订单id:{$id} 因还有库存,没有生成制作单,请跟进", '15280215347');
+            } else {
+                $sound .= ",客户到店自取";
             }
         } else {
-            //散花
-            $sh = 0;
-            //花束
-            $hs = 0;
-            foreach ($list as $work) {
-                if ($work->sh == 1) {
-                    $sh = 1;
+            if (!empty($reachDate) && $reachDate != '0000-00-00') {
+                $readPeriod = $order->reachPeriod ?? 0;
+                $period = explode(':', $readPeriod);
+                $periodName = implode($period, '点');
+                if ($reachDate == date("Y-m-d")) {
+                    $sound .= ',今天' . $periodName . "分前配送";
+                } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
+                    $sound .= ',明天' . $periodName . "分前配送";
+                } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
+                    $sound .= ',后天' . $periodName . "分前配送";
                 } else {
-                    $hs = 1;
-                }
-            }
-            if ($sh == 1) {
-                $lbSn = $shopExt->lbSn ?? '';
-                $lbVersion = $shopExt->lbVersion ?? '';
-                if (!empty($lbSn)) {
-                    $sound = "您有新的散花订单";
-                    $reachDate = $order->reachDate ?? '';
-                    if ($order->sendType == 1) {
-                        if (!empty($reachDate) && $reachDate != '0000-00-00') {
-                            $readPeriod = $order->reachPeriod ?? 0;
-                            $period = explode(':', $readPeriod);
-                            $periodName = implode($period, '点');
-                            if ($reachDate == date("Y-m-d")) {
-                                $sound .= ',今天' . $periodName . "分到店自取";
-                            } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
-                                $sound .= ',明天' . $periodName . "分到店自取";
-                            } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
-                                $sound .= ',后天' . $periodName . "分到店自取";
-                            } else {
-                                $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分到店自取";
-                            }
-                        } else {
-                            $sound .= ",客户到店自取";
-                        }
-                    } else {
-                        if (!empty($reachDate) && $reachDate != '0000-00-00') {
-                            $readPeriod = $order->reachPeriod ?? 0;
-                            $period = explode(':', $readPeriod);
-                            $periodName = implode($period, '点');
-                            if ($reachDate == date("Y-m-d")) {
-                                $sound .= ',今天' . $periodName . "分前配送";
-                            } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
-                                $sound .= ',明天' . $periodName . "分前配送";
-                            } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
-                                $sound .= ',后天' . $periodName . "分前配送";
-                            } else {
-                                $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前配送";
-                            }
-                        }
-                    }
-                    $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
-                    $curl = new curl\Curl();
-                    $curl->get($url);
-                }
-            }
-            if ($hs == 1) {
-                $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
-                $lbVersion = $order->fromType == 4 ? $shopExt->mtLbVersion : $shopExt->makeLbVersion;
-                if (!empty($lbSn)) {
-                    $sound = "您有新的制作单";
-                    $reachDate = $order->reachDate ?? '';
-                    if ($order->sendType == 1) {
-                        if (!empty($reachDate) && $reachDate != '0000-00-00') {
-                            $readPeriod = $order->reachPeriod ?? 0;
-                            $period = explode(':', $readPeriod);
-                            $periodName = implode($period, '点');
-                            if ($reachDate == date("Y-m-d")) {
-                                $sound .= ',今天' . $periodName . "分到店自取";
-                            } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
-                                $sound .= ',明天' . $periodName . "分到店自取";
-                            } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
-                                $sound .= ',后天' . $periodName . "分到店自取";
-                            } else {
-                                $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分到店自取";
-                            }
-                        } else {
-                            $sound .= ",客户到店自取";
-                        }
-                    } else {
-                        if (!empty($reachDate) && $reachDate != '0000-00-00') {
-                            $readPeriod = $order->reachPeriod ?? 0;
-                            $period = explode(':', $readPeriod);
-                            $periodName = implode($period, '点');
-                            if ($reachDate == date("Y-m-d")) {
-                                $sound .= ',今天' . $periodName . "分前配送";
-                            } elseif ($reachDate == date("Y-m-d", strtotime("+1 day"))) {
-                                $sound .= ',明天' . $periodName . "分前配送";
-                            } elseif ($reachDate == date("Y-m-d", strtotime("+2 day"))) {
-                                $sound .= ',后天' . $periodName . "分前配送";
-                            } else {
-                                $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前配送";
-                            }
-                        }
-                    }
-                    $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
-                    $curl = new curl\Curl();
-                    $curl->get($url);
-                    $curl->get($url);
+                    $sound .= date("d", strtotime($reachDate)) . '号' . $periodName . "分前配送";
                 }
             }
         }
+        $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version={$lbVersion}&message=" . $sound;
+        $curl = new curl\Curl();
+        $curl->get($url);
+        $curl->get($url);
+        return true;
     }
 
     //花店采购供货商端播放声音