|
|
@@ -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\BalanceGiveChangeClass;
|
|
|
use bizHd\balance\classes\BalancePayChangeClass;
|
|
|
use bizHd\member\classes\MemberChangeClass;
|
|
|
use bizHd\member\classes\MemberWealClass;
|
|
|
@@ -239,21 +240,22 @@ class CustomClass extends BaseClass
|
|
|
];
|
|
|
BalanceChangeClass::add($change, true);
|
|
|
|
|
|
-
|
|
|
- /************************* 充值余额 *****************************/
|
|
|
+ $giveAmount = bcsub($amount, $hd->balancePay, 2);//这个方法不能移到下面
|
|
|
if ($hd->balancePay > $amount) {
|
|
|
-
|
|
|
+ $payAmount = $amount;
|
|
|
} else {
|
|
|
-
|
|
|
+ $payAmount = $hd->balancePay;
|
|
|
}
|
|
|
- $customBalancePay = bcsub($custom->balancePay, $amount, 2);
|
|
|
+
|
|
|
+ /************************* 充值余额 *****************************/
|
|
|
+ $customBalancePay = bcsub($custom->balancePay, $payAmount, 2);
|
|
|
$custom->balancePay = $customBalancePay;
|
|
|
$custom->save();
|
|
|
- $hdBalancePay = bcsub($hd->balancePay, $amount, 2);
|
|
|
- $hd->balance = $hdBalancePay;
|
|
|
+ $hdBalancePay = bcsub($hd->balancePay, $payAmount, 2);
|
|
|
+ $hd->balancePay = $hdBalancePay;
|
|
|
$hd->save();
|
|
|
if (floatval($customBalancePay) != floatval($hdBalancePay)) {
|
|
|
- util::fail('余额有错,请联系管理员,编号' . $hdId);
|
|
|
+ util::fail('余额有错呢,请联系管理员,编号' . $hdId);
|
|
|
}
|
|
|
$relateId = $order->id ?? 0;
|
|
|
$customId = $custom->id ?? 0;
|
|
|
@@ -272,8 +274,8 @@ class CustomClass extends BaseClass
|
|
|
'relateId' => $relateId,
|
|
|
'onlinePay' => $onlinePay,
|
|
|
'capitalType' => $capitalType,
|
|
|
- 'amount' => $amount,
|
|
|
- 'balance' => $customBalance,
|
|
|
+ 'amount' => $payAmount,
|
|
|
+ 'balance' => $customBalancePay,
|
|
|
'io' => 0,
|
|
|
'side' => $side,
|
|
|
'payWay' => $payWay,
|
|
|
@@ -290,16 +292,18 @@ class CustomClass extends BaseClass
|
|
|
BalancePayChangeClass::add($payChange, true);
|
|
|
|
|
|
/***************************** 赠送余额 ******************************/
|
|
|
- $giveAmount = bcsub($amount, $hd->balancePay, 2);
|
|
|
if ($giveAmount > 0) {
|
|
|
- $customBalancePay = bcsub($custom->balancePay, $amount, 2);
|
|
|
- $custom->balancePay = $customBalancePay;
|
|
|
+ $customBalanceGive = bcsub($custom->balanceGive, $giveAmount, 2);
|
|
|
+ if ($customBalanceGive < 0) {
|
|
|
+ util::fail('余额异常哈,请联系管理员,编号' . $hdId);
|
|
|
+ }
|
|
|
+ $custom->balanceGive = $customBalanceGive;
|
|
|
$custom->save();
|
|
|
- $hdBalancePay = bcsub($hd->balancePay, $amount, 2);
|
|
|
- $hd->balance = $hdBalancePay;
|
|
|
+ $hdBalanceGive = bcsub($hd->balanceGive, $giveAmount, 2);
|
|
|
+ $hd->balanceGive = $hdBalanceGive;
|
|
|
$hd->save();
|
|
|
- if (floatval($customBalancePay) != floatval($hdBalancePay)) {
|
|
|
- util::fail('余额有错,请联系管理员,编号' . $hdId);
|
|
|
+ if (floatval($customBalanceGive) != floatval($hdBalanceGive)) {
|
|
|
+ util::fail('余额有问题呢,请联系管理员,编号' . $hdId);
|
|
|
}
|
|
|
$relateId = $order->id ?? 0;
|
|
|
$customId = $custom->id ?? 0;
|
|
|
@@ -310,7 +314,7 @@ class CustomClass extends BaseClass
|
|
|
$onlinePay = 1;
|
|
|
$side = 0;
|
|
|
$payWay = 0;
|
|
|
- $payChange = [
|
|
|
+ $giveChange = [
|
|
|
'hdId' => $hdId,
|
|
|
'hdName' => $hdName,
|
|
|
'customId' => $customId,
|
|
|
@@ -318,8 +322,8 @@ class CustomClass extends BaseClass
|
|
|
'relateId' => $relateId,
|
|
|
'onlinePay' => $onlinePay,
|
|
|
'capitalType' => $capitalType,
|
|
|
- 'amount' => $amount,
|
|
|
- 'balance' => $customBalance,
|
|
|
+ 'amount' => $giveAmount,
|
|
|
+ 'balance' => $customBalanceGive,
|
|
|
'io' => 0,
|
|
|
'side' => $side,
|
|
|
'payWay' => $payWay,
|
|
|
@@ -333,10 +337,10 @@ class CustomClass extends BaseClass
|
|
|
'settleAmount' => $settleAmount,
|
|
|
'remark' => '',
|
|
|
];
|
|
|
- BalancePayChangeClass::add($payChange, true);
|
|
|
+ BalanceGiveChangeClass::add($giveChange, true);
|
|
|
}
|
|
|
$addBalance = bcadd($hd->balancePay, $hd->balanceGive, 2);
|
|
|
- if (floatval($addBalance) != floatval($hd->balance)) {
|
|
|
+ if (floatval($addBalance) != floatval($custom->balance)) {
|
|
|
util::fail('账户余额有问题,请检查,编号' . $customId);
|
|
|
}
|
|
|
}
|