Explorar el Código

采购单打印

shish hace 2 años
padre
commit
03262ed589

+ 1 - 2
app-ghs/controllers/PurchaseOrderController.php

@@ -151,10 +151,9 @@ class PurchaseOrderController extends BaseController
         if (getenv('YII_ENV') == 'production') {
             //小向的采购单要打印二张
             if ($this->mainId == 23390) {
-                PurchaseOrderClass::printTicket($cg, false, $order);
+                //PurchaseOrderClass::printTicket($cg, false, $order);
             }
         }
-
         PurchaseOrderClass::printTicket($cg, false, $order);
         util::complete();
     }

+ 18 - 4
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -11,6 +11,7 @@ use biz\sj\classes\SjClass;
 use biz\stat\classes\StatCgClass;
 use biz\stat\classes\StatCgGhsClass;
 use biz\stat\classes\StatOutClass;
+use biz\wx\classes\WxMessageClass;
 use bizGhs\base\classes\BaseClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\item\classes\CostChangeClass;
@@ -130,11 +131,24 @@ class PurchaseOrderClass extends BaseClass
         return $content;
     }
 
-    public static function addPrintNum($orderInfo, $num = 1)
+    public static function addPrintNum($cg, $num = 1)
     {
-        $orderInfo->printNum += $num;
-        $orderInfo->save();
-        return $orderInfo;
+        $cg->printNum += $num;
+        $cg->save();
+        if ($cg->printNum > 1) {
+            $mainId = $cg->mainId ?? 0;
+            if (getenv('YII_ENV') == 'production') {
+                //小向花卉采购单第二次打通要通知老板
+                if ($mainId == 23390) {
+                    WxMessageClass::ghsCgRepeatPrintInform($cg);
+                }
+            } else {
+                if ($mainId == 644) {
+                    WxMessageClass::ghsCgRepeatPrintInform($cg);
+                }
+            }
+        }
+        return $cg;
     }
 
     //打印小票 ssh 20230608

+ 49 - 0
biz/wx/classes/WxMessageClass.php

@@ -223,6 +223,55 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //供货商重复打印通知 ssh 20240511
+    public static function ghsCgRepeatPrintInform($cg)
+    {
+        $shopId = $cg->shopId ?? 0;
+        $shop = ShopClass::getById($shopId, true);
+        if (empty($shop)) {
+            return false;
+        }
+        $orderSn = $cg->orderSn ?? '';
+        $num = $cg->printNum ?? 0;
+        $ptStyle = $shop->ptStyle;
+        $ghsName = $cg->ghsName ?? '';
+        $staffName = $cg->shopAdminName ?? '';
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'ZHH202405111701';
+        $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $adminList = ShopAdminClass::getRemainAdmin($shop);
+        if (empty($adminList)) {
+            return false;
+        }
+        foreach ($adminList as $admin) {
+            $openId = isset($admin['openId']) ? $admin['openId'] : '';
+            if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+                $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
+            }
+            if (!empty($openId)) {
+                $data = [
+                    "touser" => $openId,
+                    "template_id" => $tempId,
+                    "url" => Yii::$app->params['ghsDomain'],
+                    "data" => [
+                        "character_string20" => ["value" => $orderSn],
+                        "thing10" => ["value" => $ghsName],
+                        "thing17" => ["value" => "采购单打印了{$num}次"],
+                        "thing23" => ["value" => $staffName],
+                    ]
+                ];
+                $data['miniprogram']['appid'] = $wx['miniAppId'];
+                $data['miniprogram']['pagepath'] = 'pagesPurchase/info?orderSn=' . $orderSn;
+                wxUtil::sendTaskInform($data, $wx, $ptStyle);
+            }
+        }
+    }
+
     //供货商新订单通知 ssh 20210529
     public static function ghsHasNewOrderInform($shop, $order)
     {