Browse Source

充值销账

shish 2 years ago
parent
commit
1cdf4f57d6

+ 5 - 1
app-ghs/controllers/CustomController.php

@@ -6,6 +6,7 @@ use biz\admin\classes\AdminRoleClass;
 use biz\ghs\classes\GhsClass;
 use biz\shop\classes\ShopAdminClass;
 use biz\sj\classes\SjClass;
+use biz\wx\classes\WxMessageClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\custom\services\CustomService;
 use bizGhs\merchant\classes\WlClass;
@@ -109,8 +110,11 @@ class CustomController extends BaseController
         try {
             $staff = $this->shopAdmin;
             $params = ['remark' => $remark];
-            CustomService::rechargeClear($custom, $amount, $this->shop, $staff, $payWay, $params);
+            $recharge = CustomService::rechargeClear($custom, $amount, $this->shop, $staff, $payWay, $params);
             $transaction->commit();
+
+            WxMessageClass::customRechargeClearInform($shop, $recharge);
+
             util::complete('充值成功');
         } catch (\Exception $e) {
             Yii::info("充值失败原因:" . $e->getMessage());

+ 1 - 1
biz-ghs/custom/classes/CustomClass.php

@@ -278,7 +278,7 @@ class CustomClass extends BaseClass
             'remark' => $remark,
         ];
         GhsBalanceChangeClass::add($gbData, true);
-        return ['custom' => $custom, 'ghs' => $ghsInfo];
+        return ['custom' => $custom, 'ghs' => $ghsInfo, 'customRecharge' => $cRecharge, 'ghsRecharge' => $gRecharge];
     }
 
     public static function createSeatSn($mainId)

+ 2 - 0
biz-ghs/custom/services/CustomService.php

@@ -20,6 +20,7 @@ class CustomService extends BaseService
         $respond = CustomClass::rechargeBalance($custom, $amount, $shop, $staff, $payWay, $params);
         $custom = $respond['custom'] ?? [];
         $ghs = $respond['ghs'] ?? [];
+        $customRecharge = $respond['customRecharge'] ?? [];
         if (empty($custom)) {
             util::fail('没有客户信息');
         }
@@ -27,6 +28,7 @@ class CustomService extends BaseService
             util::fail('没有供货商信息');
         }
         OrderClearClass::useBalanceClear($custom, $ghs, $shop, $staff);
+        return $customRecharge;
     }
 
     //分享建立客户和供货商关系 ssh 2021.2.28

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

@@ -224,6 +224,61 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //客户充值清账通知 ssh 20240511
+    public static function customRechargeClearInform($shop, $recharge)
+    {
+        //充值金额 商品名称 姓名 操作人 充值时间
+        $orderSn = $recharge->orderSn ?? '';
+        $ptStyle = $shop->ptStyle;
+        $amount = $recharge->actPrice ?? 0;
+        $staffName = $recharge->staffName ?? '';
+        $onlinePay = $recharge->onlinePay ?? 1;
+        $onlineName = $onlinePay == 1 ? '线下' : '线上';
+        $payWay = $recharge->payWay ?? 0;
+        $nameMap = dict::getDict('payWayName');
+        $payWayName = $nameMap[$payWay] ?? '微信';
+        $payName = $onlineName . $payWayName;
+        $title = $payName . '-充值销账';
+        $customName = $recharge->customName ?? '';
+        $payTime = $recharge->payTime ?? '';
+
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'ZHH202405111704';
+        $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" => [
+                        "amount1" => ["value" => $amount],
+                        "thing9" => ["value" => $title],
+                        "thing7" => ["value" => $customName],
+                        "thing11" => ["value" => $staffName],
+                        "time3" => ["value" => $payTime],
+                    ]
+                ];
+                $data['miniprogram']['appid'] = $wx['miniAppId'];
+                $data['miniprogram']['pagepath'] = 'pagesPurchase/info?orderSn=' . $orderSn;
+                wxUtil::sendTaskInform($data, $wx, $ptStyle);
+            }
+        }
+    }
+
     //供货商重复打印通知 ssh 20240511
     public static function ghsCgRepeatPrintInform($cg)
     {