Browse Source

售后通知

shish 3 years ago
parent
commit
fec8f7f9eb
2 changed files with 40 additions and 0 deletions
  1. 9 0
      app-hd/controllers/CgRefundController.php
  2. 31 0
      biz-ghs/notify/classes/NotifyClass.php

+ 9 - 0
app-hd/controllers/CgRefundController.php

@@ -2,6 +2,8 @@
 
 namespace hd\controllers;
 
+use bizGhs\notify\classes\NotifyClass;
+use bizGhs\order\classes\RefundOrderClass;
 use bizHd\cg\classes\CgRefundClass;
 use bizHd\cg\classes\CgRefundItemClass;
 use bizHd\cg\services\CgRefundService;
@@ -94,6 +96,13 @@ class CgRefundController extends BaseController
             $post['shopAdminName'] = $adminName;
             $respond = CgRefundService::createOrder($post, $cg);
             $transaction->commit();
+
+            $saleRefundId = $respond->saleRefundId ?? 0;
+            $saleRefund = RefundOrderClass::getById($saleRefundId, true);
+            if (!empty($order) && !empty($saleRefund)) {
+                NotifyClass::addRefundApplyNotify($saleRefund);
+            }
+
             util::success($respond);
         } catch (\Exception $exception) {
             $transaction->rollBack();

+ 31 - 0
biz-ghs/notify/classes/NotifyClass.php

@@ -3,6 +3,8 @@
 namespace bizGhs\notify\classes;
 
 use bizGhs\base\classes\BaseClass;
+use bizGhs\custom\classes\CustomClass;
+use bizGhs\shop\classes\ShopAdminClass;
 use Yii;
 
 class NotifyClass extends BaseClass
@@ -16,4 +18,33 @@ class NotifyClass extends BaseClass
         return $data;
     }
 
+    //新增售后申请通过 ssh 20230814
+    public static function addRefundApplyNotify($refund)
+    {
+        $mainId = $refund->mainId ?? 0;
+        $shopId = $refund->shopId ?? 0;
+        $title = '有新的售后申请';
+        $id = $refund->id;
+        $customId = $refund->customId;
+        $custom = CustomClass::getById($customId, true);
+        $customName = $custom->name ?? '';
+        $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
+        if (!empty($staffList)) {
+            foreach ($staffList as $staff) {
+                $staffId = $staff->id;
+                $data = [
+                    'mainId' => $mainId,
+                    'shopId' => $shopId,
+                    'staffId' => $staffId,
+                    'title' => $title,
+                    'type' => 0,
+                    'read' => 0,
+                    'content' => $customName . ' 申请售后',
+                    'page' => '/pagesOrder/refundDetail?id=' . $id,
+                ];
+                self::add($data);
+            }
+        }
+    }
+
 }