shish 3 år sedan
förälder
incheckning
6efd7492e0
2 ändrade filer med 60 tillägg och 2 borttagningar
  1. 15 2
      app-ghs/controllers/OrderClearController.php
  2. 45 0
      biz-hd/notice/classes/NoticeClass.php

+ 15 - 2
app-ghs/controllers/OrderClearController.php

@@ -5,6 +5,7 @@ namespace ghs\controllers;
 use biz\ghs\classes\GhsClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\order\classes\OrderClearClass;
+use bizGhs\shop\classes\ShopClass;
 use bizHd\purchase\classes\PurchaseClearClass;
 use common\components\dateUtil;
 use common\components\dict;
@@ -84,9 +85,21 @@ class OrderClearController extends BaseController
             'complete' => $complete,
         ];
         try {
-            $respond = OrderClearClass::clear($data, $id, $this->sjId, $this->shopId);
+            $clearInfo = OrderClearClass::clear($data, $id, $this->sjId, $this->shopId);
             $transaction->commit();
-            util::success($respond);
+            if (!empty($clearInfo)) {
+                //结账单通知客户
+                $customShopId = $custom->shopId ?? 0;
+                $customShop = ShopClass::getById($customShopId, true);
+                if (!empty($customShop)) {
+                    $noticeRespond = \bizHd\notice\classes\NoticeClass::newClearNotice($customShop, $clearInfo);
+                    if (isset($noticeRespond['hasNotice']) && $noticeRespond['hasNotice'] == 1) {
+                        $clearInfo->hasNoticeCustom = 1;
+                        $clearInfo->save();
+                    }
+                }
+            }
+            util::success($clearInfo);
         } catch (\Exception $exception) {
             $transaction->rollBack();
             Yii::info("批量收款失败:" . $exception->getMessage());

+ 45 - 0
biz-hd/notice/classes/NoticeClass.php

@@ -13,6 +13,51 @@ use Yii;
 class NoticeClass extends BaseClass
 {
 
+    //有新的结账单 ssh 20230514
+    public static function newClearNotice($shop, $clear)
+    {
+        $result = [];
+        $mainId = $shop->mainId ?? 0;
+        $staffList = StaffClass::getAllByCondition(['mainId' => $mainId], null, 'adminId');
+        $merchant = WxOpenClass::getWxInfo();
+        $ptStyle = dict::getDict('ptStyle', 'hd');
+        if (getenv('YII_ENV') == 'production') {
+            $msgList = dict::getDict('hdMiniMessage');
+        } else {
+            $msgList = dict::getDict('hdMiniMessageDev');
+        }
+        $msgId = $msgList['remindHdClear']['msgId'] ?? '';
+        if (empty($msgId)) {
+            return $result;
+        }
+        $num = $clear->num ?? 0;
+        $actPrice = $clear->actPrice ?? 0;
+        if (!empty($staffList)) {
+            $ids = array_column($staffList, 'adminId');
+            if (!empty($ids)) {
+                $adminList = AdminClass::getByIds($ids);
+                if (!empty($adminList)) {
+                    foreach ($adminList as $admin) {
+                        $miniOpenId = $admin['miniOpenId'] ?? '';
+                        if (!empty($miniOpenId)) {
+                            $msg = [
+                                "amount3" => ["value" => $actPrice],
+                                "short_thing2" => ["value" => $num . "笔"],
+                                "time1" => ["value" => "2023年新年"],
+                            ];
+                            $page = 'admin/clear/info?id=' . $clear->id;
+                            $respond = miniUtil::commonSendSubscribeMessage($merchant, $ptStyle, $msgId, $miniOpenId, $page, $msg);
+                            if (isset($respond['errcode']) && $respond['errcode'] === 0) {
+                                $result['hasNotice'] = 1;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return $result;
+    }
+
     //采购成功之后小程序通知
     public static function cgSuccessMiniNotice($cgShop, $cg)
     {