shish 11 달 전
부모
커밋
14bc215dbf

+ 42 - 0
app-hd/controllers/BalanceGiveChangeController.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace hd\controllers;
+
+use bizHd\balance\classes\BalanceGiveChangeClass;
+use bizHd\custom\classes\CustomClass;
+use common\components\dateUtil;
+use common\components\util;
+use Yii;
+
+class BalanceGiveChangeController extends BaseController
+{
+
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        $customId = $get['customId'] ?? 0;
+        if (!empty($customId)) {
+            $custom = CustomClass::getById($customId, true);
+            if (empty($custom)) {
+                util::fail('没有找到客户');
+            }
+            $shopId = $this->shopId;
+            if ($custom->shopId != $shopId) {
+                util::fail('没有找到客户信息');
+            }
+            $where['customId'] = $customId;
+        }
+        $searchTime = $get['searchTime'] ?? '';
+        if (!empty($searchTime)) {
+            $startTime = $get['startTime'] ?? '';
+            $endTime = $get['endTime'] ?? '';
+            $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
+            $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
+        }
+        $respond = BalanceGiveChangeClass::getChangeList($where);
+        util::success($respond);
+    }
+
+}

+ 42 - 0
app-hd/controllers/BalancePayChangeController.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace hd\controllers;
+
+use bizHd\balance\classes\BalancePayChangeClass;
+use bizHd\custom\classes\CustomClass;
+use common\components\dateUtil;
+use common\components\util;
+use Yii;
+
+class BalancePayChangeController extends BaseController
+{
+
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        $customId = $get['customId'] ?? 0;
+        if (!empty($customId)) {
+            $custom = CustomClass::getById($customId, true);
+            if (empty($custom)) {
+                util::fail('没有找到客户');
+            }
+            $shopId = $this->shopId;
+            if ($custom->shopId != $shopId) {
+                util::fail('没有找到客户信息');
+            }
+            $where['customId'] = $customId;
+        }
+        $searchTime = $get['searchTime'] ?? '';
+        if (!empty($searchTime)) {
+            $startTime = $get['startTime'] ?? '';
+            $endTime = $get['endTime'] ?? '';
+            $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
+            $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
+        }
+        $respond = BalancePayChangeClass::getChangeList($where);
+        util::success($respond);
+    }
+
+}

+ 0 - 3
app-hd/controllers/OrderController.php

@@ -584,9 +584,6 @@ class OrderController extends BaseController
         try {
             $post['product'] = $productList;
 
-            //阿东开5支老是会出现5扎情况跟踪
-            ProductClass::adStockCheck($this->shop, $productList);
-
             //3秒内不允许重复开单
             $staffId = $this->shopAdminId ?? 0;
             $cacheKey = 'hd_create_order_' . $staffId . '_' . $customId;

+ 6 - 0
biz-hd/balance/classes/BalanceGiveChangeClass.php

@@ -10,4 +10,10 @@ class BalanceGiveChangeClass extends BaseClass
 
     public static $baseFile = '\bizHd\balance\models\BalanceGiveChange';
 
+    public static function getChangeList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC,id DESC');
+        return $data;
+    }
+
 }

+ 19 - 0
biz-hd/balance/classes/BalancePayChangeClass.php

@@ -10,4 +10,23 @@ class BalancePayChangeClass extends BaseClass
 
     public static $baseFile = '\bizHd\balance\models\BalancePayChange';
 
+    public static function getChangeList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC,id DESC');
+        if (!empty($data['list'])) {
+            foreach ($data['list'] as $k => $v) {
+                $settleAmount = $v['settleAmount'] ?? 0;
+                $amount = $v['amount'] ?? 0;
+                $io = $v['io'] ?? 0;
+                $becomeBalance = 0;
+                if ($io == 1) {
+                    $becomeBalance = bcsub($amount, $settleAmount, 2);
+                    $becomeBalance = floatval($becomeBalance);
+                }
+                $data['list'][$k]['becomeBalance'] = $becomeBalance;
+            }
+        }
+        return $data;
+    }
+
 }

+ 103 - 3
biz-hd/custom/classes/CustomClass.php

@@ -5,6 +5,7 @@ namespace bizHd\custom\classes;
 use biz\wx\classes\WxMessageClass;
 use bizGhs\shop\classes\TotalDebtChangeClass;
 use bizHd\balance\classes\BalanceChangeClass;
+use bizHd\balance\classes\BalancePayChangeClass;
 use bizHd\member\classes\MemberChangeClass;
 use bizHd\member\classes\MemberWealClass;
 use bizHd\order\classes\SettleClass;
@@ -188,24 +189,22 @@ class CustomClass extends BaseClass
             $settleId = $set->id;
         }
 
+        /************************ 总余额 *********************************/
         $customBalance = bcsub($custom->balance, $amount, 2);
         $custom->balance = $customBalance;
         if ($custom->balance < 0) {
             $custom->isDebt = 1;
         }
         $custom->save();
-
         $hdBalance = bcsub($hd->balance, $amount, 2);
         $hd->balance = $hdBalance;
         if ($hd->balance < 0) {
             $hd->debt = 2;
         }
         $hd->save();
-
         if (floatval($customBalance) != floatval($hdBalance)) {
             util::fail('余额有错,请联系管理员,编号' . $hdId);
         }
-
         $relateId = $order->id ?? 0;
         $customId = $custom->id ?? 0;
         $orderSn = $order->orderSn ?? '';
@@ -239,6 +238,107 @@ class CustomClass extends BaseClass
             'remark' => '',
         ];
         BalanceChangeClass::add($change, true);
+
+
+        /************************* 充值余额 *****************************/
+        if ($hd->balancePay > $amount) {
+
+        } else {
+
+        }
+        $customBalancePay = bcsub($custom->balancePay, $amount, 2);
+        $custom->balancePay = $customBalancePay;
+        $custom->save();
+        $hdBalancePay = bcsub($hd->balancePay, $amount, 2);
+        $hd->balance = $hdBalancePay;
+        $hd->save();
+        if (floatval($customBalancePay) != floatval($hdBalancePay)) {
+            util::fail('余额有错,请联系管理员,编号' . $hdId);
+        }
+        $relateId = $order->id ?? 0;
+        $customId = $custom->id ?? 0;
+        $orderSn = $order->orderSn ?? '';
+        $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
+        $event = '购买花材,单号:' . $orderSn;
+        $customName = $custom->name ?? '';
+        $onlinePay = 1;
+        $side = 0;
+        $payWay = 0;
+        $payChange = [
+            'hdId' => $hdId,
+            'hdName' => $hdName,
+            'customId' => $customId,
+            'customName' => $customName,
+            'relateId' => $relateId,
+            'onlinePay' => $onlinePay,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $customBalance,
+            'io' => 0,
+            'side' => $side,
+            'payWay' => $payWay,
+            'event' => $event,
+            'staffId' => $staffId,
+            'staffName' => $staffName,
+            'shopId' => $shopId,
+            'mainId' => $order->mainId,
+            'settleId' => $settleId,
+            'settleNo' => $settleNo,
+            'settleAmount' => $settleAmount,
+            'remark' => '',
+        ];
+        BalancePayChangeClass::add($payChange, true);
+
+        /***************************** 赠送余额 ******************************/
+        $giveAmount = bcsub($amount, $hd->balancePay, 2);
+        if ($giveAmount > 0) {
+            $customBalancePay = bcsub($custom->balancePay, $amount, 2);
+            $custom->balancePay = $customBalancePay;
+            $custom->save();
+            $hdBalancePay = bcsub($hd->balancePay, $amount, 2);
+            $hd->balance = $hdBalancePay;
+            $hd->save();
+            if (floatval($customBalancePay) != floatval($hdBalancePay)) {
+                util::fail('余额有错,请联系管理员,编号' . $hdId);
+            }
+            $relateId = $order->id ?? 0;
+            $customId = $custom->id ?? 0;
+            $orderSn = $order->orderSn ?? '';
+            $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
+            $event = '购买花材,单号:' . $orderSn;
+            $customName = $custom->name ?? '';
+            $onlinePay = 1;
+            $side = 0;
+            $payWay = 0;
+            $payChange = [
+                'hdId' => $hdId,
+                'hdName' => $hdName,
+                'customId' => $customId,
+                'customName' => $customName,
+                'relateId' => $relateId,
+                'onlinePay' => $onlinePay,
+                'capitalType' => $capitalType,
+                'amount' => $amount,
+                'balance' => $customBalance,
+                'io' => 0,
+                'side' => $side,
+                'payWay' => $payWay,
+                'event' => $event,
+                'staffId' => $staffId,
+                'staffName' => $staffName,
+                'shopId' => $shopId,
+                'mainId' => $order->mainId,
+                'settleId' => $settleId,
+                'settleNo' => $settleNo,
+                'settleAmount' => $settleAmount,
+                'remark' => '',
+            ];
+            BalancePayChangeClass::add($payChange, true);
+        }
+        $addBalance = bcadd($hd->balancePay, $hd->balanceGive, 2);
+        if (floatval($addBalance) != floatval($hd->balance)) {
+            util::fail('账户余额有问题,请检查,编号' . $customId);
+        }
     }
 
     //欠款和余额支付的售后 ssh 20250803

+ 5 - 1
biz-hd/recharge/classes/RechargeClass.php

@@ -216,7 +216,7 @@ class RechargeClass extends BaseClass
         if ($balanceGive > 0) {
             $event .= "(送" . floatval($balanceGive) . ")";
             $custom->balanceGive = bcadd($custom->balanceGive, $balanceGive, 2);
-            $hd->balanceGive = bcadd($hd->balancePay, $balancePay, 2);
+            $hd->balanceGive = bcadd($hd->balanceGive, $balanceGive, 2);
         }
         //本金
         if ($balancePay > 0) {
@@ -245,6 +245,10 @@ class RechargeClass extends BaseClass
             Yii::info($msg);
             util::fail($msg);
         }
+        $addBalance = bcadd($hd->balanceGive, $hd->balancePay, 2);
+        if (floatval($hd->balance) != floatval($addBalance)) {
+            util::fail('充值金额有问题哦,编号:' . $customId);
+        }
 
         $settleId = $recharge->settleId;
         $settleAmount = 0;