|
|
@@ -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
|