shish 3 years ago
parent
commit
483d152e8f
1 changed files with 67 additions and 37 deletions
  1. 67 37
      biz/shop/classes/ShopExtClass.php

+ 67 - 37
biz/shop/classes/ShopExtClass.php

@@ -34,49 +34,79 @@ class ShopExtClass extends BaseClass
     public static function newWorkRemind($shopExt, $order)
     {
         $id = $order->id ?? 0;
-        $work = WorkClass::getByCondition(['orderId' => $id], true);
-        if (empty($work)) {
-            return false;
-        }
-        $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
-        $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 . "分客户到店自取";
+        $list = WorkClass::getAllByCondition(['orderId' => $id], null, '*', null, true);
+        if (empty($list)) {
+            //提示有订单,但没有生成制作单
+            $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
+            $sound = "您有新的订单,但没有生成制作单,请确认是否还有库存";
+            $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version=3&message=" . $sound;
+            $curl = new curl\Curl();
+            $curl->get($url);
+        } else {
+            //散花
+            $sh = 0;
+            //花束
+            $hs = 0;
+            foreach ($list as $work) {
+                if ($work->sh == 1) {
+                    $sh = 1;
                 } else {
-                    $sound .= ',' . date("d", strtotime($reachDate)) . '号' . $periodName . "分客户到店自取";
+                    $hs = 1;
                 }
-            } 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 . "分前送达";
+            if ($sh == 1) {
+                $lbSn = $shopExt->lbSn;
+                $sound = "您有新的散花订单";
+                if (!empty($lbSn)) {
+                    $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version=3&message=" . $sound;
+                    $curl = new curl\Curl();
+                    $curl->get($url);
+                }
+            }
+            if ($hs == 1) {
+                $lbSn = $order->fromType == 4 ? $shopExt->mtLbSn : $shopExt->makeLbSn;
+                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=3&message=" . $sound;
+                    $curl = new curl\Curl();
+                    $curl->get($url);
                 }
             }
         }
-        $url = "https://speaker.17laimai.cn/notify.php?id={$lbSn}&token=HK1626595800&version=3&message=" . $sound;
-        $curl = new curl\Curl();
-        $curl->get($url);
     }
 
     //花店采购供货商端播放声音