shish 2 سال پیش
والد
کامیت
829eb994fe

+ 16 - 0
biz-ghs/custom/classes/CustomBalanceClass.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace bizGhs\custom\classes;
+
+use common\components\dict;
+use common\components\imgUtil;
+use common\components\noticeUtil;
+use common\components\util;
+use bizHd\base\classes\BaseClass;
+
+class CustomBalanceClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\custom\models\CustomBalance';
+
+}

+ 125 - 0
biz-ghs/custom/classes/CustomClass.php

@@ -7,11 +7,15 @@ use biz\sj\classes\MerchantClass;
 use bizGhs\custom\models\Custom;
 use bizGhs\shop\classes\MainClass;
 use bizGhs\shop\classes\TotalDebtChangeClass;
+use bizGhs\ghs\classes\GhsBalanceClass;
+use bizGhs\ghs\classes\GhsRechargeClass;
+use bizGhs\shop\classes\ShopClass;
 use common\components\business;
 use common\components\dict;
 use common\components\imgUtil;
 use common\components\noticeUtil;
 use common\components\util;
+use common\components\orderSn;
 use bizHd\base\classes\BaseClass;
 
 class CustomClass extends BaseClass
@@ -58,6 +62,127 @@ class CustomClass extends BaseClass
         self::LEVEL_ZS => 'zsAddPrice',
     ];
 
+    //充值金额 ssh 20240310
+    public static function rechargeAmount($custom, $amount, $shop, $staff)
+    {
+        $ghsId = $custom->ghsId ?? 0;
+        $ghsInfo = GhsClass::getById($ghsId, true);
+        if (empty($ghsInfo)) {
+            util::fail('没有找到供货商');
+        }
+        $ghsShopId = $ghsInfo->shopId ?? 0;
+        $ghsName = $ghsInfo->name ?? '';
+        $customId = $custom->id ?? 0;
+        $customShopId = $custom->shopId ?? 0;
+        $customName = $custom->name ?? '';
+        $customShop = ShopClass::getById($customShopId, true);
+        if (empty($customShop)) {
+            util::fail('没有找到客户门店');
+        }
+        $customShopSjId = $customShop->sjId ?? 0;
+        $customShopMainId = $customShop->mainId ?? 0;
+
+        $custom->balance = bcadd($custom->balance, $amount, 2);
+        $custom->save();
+        $orderSn = orderSn::getGhsCustomRechargeSn();
+        $shopId = $shop->id ?? 0;
+        $sjId = $shop->sjId ?? 0;
+        $mainId = $shop->mainId ?? 0;
+        $staffId = $staff->id ?? 0;
+        $staffName = $staff->name ?? '';
+        $cData = [
+            'orderSn' => $orderSn,
+            'onlinePay' => 1,
+            'payWay' => 0,
+            'shopId' => $shopId,
+            'mainId' => $mainId,
+            'amount' => $amount,
+            'balance' => $custom->balance,
+            'side' => 0,
+            'staffId' => $staffId,
+            'staffName' => $staffName,
+            'payStatus' => 1,
+            'status' => 1,
+            'remark' => '',
+            'ghsId' => $ghsId,
+            'ghsShopId' => $ghsShopId,
+            'ghsName' => $ghsName,
+            'customId' => $customId,
+            'customShopId' => $customShopId,
+            'customName' => $customName,
+        ];
+        $cRecharge = CustomRechargeClass::add($cData, true);
+        $cRechargeId = $cRecharge->id ?? 0;
+
+        $capitalType = dict::getDict('capitalType', 'ghsHelpCustomRecharge', 'id');
+        $fromType = dict::getDict('fromType', 'shop');
+        $cbData = [
+            'customId' => $customId,
+            'relateId' => $cRechargeId,
+            'onlinePay' => 1,
+            'ptStyle' => 2,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $custom->balance,
+            'io' => 1,
+            'payWay' => 0,
+            'fromType' => $fromType,
+            'event' => '充值',
+            'mainId' => $mainId,
+            'shopId' => $shopId,
+            'sjId' => $sjId,
+            'remark' => '',
+        ];
+        CustomBalanceClass::add($cbData, true);
+
+        $ghsInfo->balance = bcadd($ghsInfo->balance, $amount, 2);
+        $ghsInfo->save();
+        $orderSn = orderSn::getGhsRechargeSn();
+        $customMainId = $custom->mainId ?? 0;
+        $gData = [
+            'orderSn' => $orderSn,
+            'onlinePay' => 1,
+            'payWay' => 0,
+            'shopId' => $customShopId,
+            'mainId' => $customMainId,
+            'amount' => $amount,
+            'balance' => $ghsInfo->balance,
+            'side' => 0,
+            'staffId' => 0,
+            'staffName' => '',
+            'payStatus' => 1,
+            'status' => 1,
+            'remark' => '',
+            'ghsId' => $ghsId,
+            'ghsShopId' => $ghsShopId,
+            'ghsName' => $ghsName,
+            'customId' => $customId,
+            'customShopId' => $customShopId,
+            'customName' => $customName,
+        ];
+        $gRecharge = GhsRechargeClass::add($gData, true);
+        $gRechargeId = $gRecharge->id ?? 0;
+        $capitalType = dict::getDict('capitalType', 'ghsCustomRecharge', 'id');
+        $gbData = [
+            'ghsId' => $ghsId,
+            'relateId' => $gRechargeId,
+            'ptStyle' => 2,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $ghsInfo->balance,
+            'io' => 1,
+            'onlinePay' => 1,
+            'payWay' => 0,
+            'fromType' => $fromType,
+            'event' => '充值',
+            'sjId' => $customShopSjId,
+            'mainId' => $customShopMainId,
+            'shopId' => $customShopId,
+            'remark' => '',
+        ];
+        GhsBalanceClass::add($gbData, true);
+    }
+
     public static function createSeatSn($mainId)
     {
         $max = Custom::find(['mainId' => $mainId])->max('seatSn');

+ 13 - 0
biz-ghs/custom/models/CustomBalance.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizGhs\custom\models;
+use bizHd\base\models\Base;
+
+class CustomBalance extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhCustomBalance';
+    }
+
+}

+ 19 - 0
biz-ghs/custom/services/CustomBalanceService.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace bizGhs\custom\services;
+
+use biz\ghs\classes\GhsClass;
+use biz\sj\classes\SjClass;
+use bizGhs\custom\classes\CustomRechargeClass;
+use bizGhs\ghs\classes\GhsRechargeClass;
+use bizHd\base\services\BaseService;
+use bizGhs\custom\classes\CustomClass;
+use common\components\orderSn;
+use common\components\util;
+
+class CustomBalanceService extends BaseService
+{
+
+    public static $baseFile = '\bizGhs\custom\classes\CustomBalanceClass';
+
+}

+ 3 - 71
biz-ghs/custom/services/CustomService.php

@@ -4,12 +4,9 @@ namespace bizGhs\custom\services;
 
 use biz\ghs\classes\GhsClass;
 use biz\sj\classes\SjClass;
-use bizGhs\custom\classes\CustomRechargeClass;
-use bizGhs\ghs\classes\GhsRechargeClass;
+use bizGhs\order\classes\OrderClearClass;
 use bizHd\base\services\BaseService;
 use bizGhs\custom\classes\CustomClass;
-use common\components\orderSn;
-use common\components\util;
 
 class CustomService extends BaseService
 {
@@ -19,73 +16,8 @@ class CustomService extends BaseService
     //充值和结账 ssh 20240309
     public static function rechargeClear($custom, $amount, $shop, $staff)
     {
-        $ghsId = $custom->ghsId ?? 0;
-        $ghsInfo = GhsClass::getById($ghsId, true);
-        if (empty($ghsInfo)) {
-            util::fail('没有找到供货商');
-        }
-        $ghsShopId = $ghsInfo->shopId ?? 0;
-        $ghsName = $ghsInfo->name ?? '';
-        $customId = $custom->id ?? 0;
-        $customShopId = $custom->shopId ?? 0;
-        $customName = $custom->name ?? '';
-
-        $custom->balance = bcadd($custom->balance, $amount, 2);
-        $custom->save();
-        $orderSn = orderSn::getGhsCustomRechargeSn();
-        $shopId = $shop->id ?? 0;
-        $mainId = $shop->mainId ?? 0;
-        $staffId = $staff->id ?? 0;
-        $staffName = $staff->name ?? '';
-        $cData = [
-            'orderSn' => $orderSn,
-            'onlinePay' => 1,
-            'payWay' => 0,
-            'shopId' => $shopId,
-            'mainId' => $mainId,
-            'amount' => $amount,
-            'balance' => $custom->balance,
-            'side' => 0,
-            'staffId' => $staffId,
-            'staffName' => $staffName,
-            'payStatus' => 1,
-            'status' => 1,
-            'remark' => '',
-            'ghsId' => $ghsId,
-            'ghsShopId' => $ghsShopId,
-            'ghsName' => $ghsName,
-            'customId' => $customId,
-            'customShopId' => $customShopId,
-            'customName' => $customName,
-        ];
-        $cRecharge = CustomRechargeClass::add($cData, true);
-
-        $ghsInfo->balance = bcadd($ghsInfo->balance, $amount, 2);
-        $ghsInfo->save();
-        $orderSn = orderSn::getGhsRechargeSn();
-        $customMainId = $custom->mainId ?? 0;
-        $gData = [
-            'orderSn' => $orderSn,
-            'onlinePay' => 1,
-            'payWay' => 0,
-            'shopId' => $customShopId,
-            'mainId' => $customMainId,
-            'amount' => $amount,
-            'balance' => $ghsInfo->balance,
-            'side' => 0,
-            'staffId' => 0,
-            'staffName' => '',
-            'payStatus' => 1,
-            'status' => 1,
-            'remark' => '',
-            'ghsId' => $ghsId,
-            'ghsShopId' => $ghsShopId,
-            'ghsName' => $ghsName,
-            'customId' => $customId,
-            'customShopId' => $customShopId,
-            'customName' => $customName,
-        ];
-        $gRecharge = GhsRechargeClass::add($gData, true);
+        CustomClass::rechargeAmount($custom, $amount, $shop, $staff);
+        OrderClearClass::useBalanceClear($custom);
     }
 
     //分享建立客户和供货商关系 ssh 2021.2.28

+ 15 - 0
biz-ghs/ghs/classes/GhsBalanceClass.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizGhs\ghs\classes;
+
+use bizGhs\base\classes\BaseClass;
+use bizGhs\order\classes\PurchaseOrderClass;
+use bizGhs\shop\classes\ShopClass;
+use common\components\imgUtil;
+
+class GhsBalanceClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\ghs\models\GhsBalance';
+
+}

+ 15 - 0
biz-ghs/ghs/models/GhsBalance.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizGhs\ghs\models;
+
+use bizGhs\base\models\Base;
+
+class GhsBalance extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhGhsBalance';
+    }
+
+}

+ 13 - 0
biz-ghs/ghs/services/GhsBalanceService.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizGhs\ghs\services;
+
+use bizGhs\base\services\BaseService;
+use Yii;
+
+class GhsBalanceService extends BaseService
+{
+
+    public static $baseFile = '\bizGhs\ghs\classes\GhsBalanceClass';
+
+}

+ 6 - 0
biz-ghs/order/classes/OrderClearClass.php

@@ -20,6 +20,12 @@ class OrderClearClass extends BaseClass
 
     public static $baseFile = '\bizGhs\order\models\OrderClear';
 
+    //使用余额自助结欠款 ssh 20240310
+    public static function useBalanceClear($custom)
+    {
+        return true;
+    }
+
     //订单结算 ssh 2021.3.14
     public static function clear($post, $idText, $sjId, $shopId)
     {

+ 6 - 0
common/components/dict.php

@@ -339,6 +339,10 @@ class dict
             'ljhApply' => ['id' => 60, 'name' => 'ljhApply'],
             //供货商结账支出
             'ghsClearExpend' => ['id' => 61, 'name' => 'ghsClearExpend'],
+            //供货商帮客户充值
+            'ghsHelpCustomRecharge' => ['id' => 62, 'name' => 'ghsHelpCustomRecharge'],
+            //供货商的客户自行充值
+            'ghsCustomRecharge' => ['id' => 63, 'name' => 'ghsCustomRecharge'],
         ],
         "capitalTypeList" => [//流水类型的对应链接,后台收支明细查看时跳转的链接
             0 => ['link' => '/capital/order-detail', 'name' => '网店', 'orderLink' => '/order/detail', 'id' => 0,],
@@ -373,6 +377,8 @@ class dict
             59 => ['link' => '', 'name' => '退货退款', 'id' => 59,],
             60 => ['link' => '', 'name' => '零交会报名', 'id' => 60,],
             61 => ['link' => '', 'name' => '结账支出', 'id' => 61,],
+            62 => ['link' => '', 'name' => '充值', 'id' => 62,],
+            63 => ['link' => '', 'name' => '充值', 'id' => 63,],
         ],
 
         //用户来源