|
|
@@ -87,7 +87,94 @@ class CustomClass extends BaseClass
|
|
|
'mainId' => $mainId,
|
|
|
'remark' => '',
|
|
|
];
|
|
|
- return BalanceChangeClass::add($change, true);
|
|
|
+ BalanceChangeClass::add($change, true);
|
|
|
+
|
|
|
+ // 多处需要同步修改 balance_pay_give
|
|
|
+ if ($hd->balancePay >= $actPrice) {
|
|
|
+ $payAmount = $actPrice;
|
|
|
+ $mustUseGiveAmount = 0;
|
|
|
+ } else {
|
|
|
+ $payAmount = $hd->balancePay;
|
|
|
+ $mustUseGiveAmount = bcsub($actPrice, $payAmount, 2);
|
|
|
+ if ($mustUseGiveAmount > $hd->balanceGive) {
|
|
|
+ util::fail('赠送余额异常,不够扣');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /************************* 充值余额 *****************************/
|
|
|
+ $customBalancePay = bcsub($custom->balancePay, $payAmount, 2);
|
|
|
+ $custom->balancePay = $customBalancePay;
|
|
|
+ $custom->save();
|
|
|
+ $hdBalancePay = bcsub($hd->balancePay, $payAmount, 2);
|
|
|
+ $hd->balancePay = $hdBalancePay;
|
|
|
+ $hd->save();
|
|
|
+ $payChange = [
|
|
|
+ 'hdId' => $hdId,
|
|
|
+ 'hdName' => $hdName,
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'customName' => $customName,
|
|
|
+ 'relateId' => $relateId,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $payAmount,
|
|
|
+ 'balance' => $customBalancePay,
|
|
|
+ 'io' => 0,
|
|
|
+ 'side' => $side,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'event' => $event,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ BalancePayChangeClass::add($payChange, true);
|
|
|
+
|
|
|
+ /***************************** 赠送余额 ******************************/
|
|
|
+ //应用掉的赠送金额
|
|
|
+ if ($mustUseGiveAmount > 0) {
|
|
|
+ $customBalanceGive = bcsub($custom->balanceGive, $mustUseGiveAmount, 2);
|
|
|
+ if ($customBalanceGive < 0) {
|
|
|
+ util::fail('余额异常哈!请联系管理员,编号' . $hdId . ' ' . $custom->balanceGive);
|
|
|
+ }
|
|
|
+ $custom->balanceGive = $customBalanceGive;
|
|
|
+ $custom->save();
|
|
|
+ $hdBalanceGive = bcsub($hd->balanceGive, $mustUseGiveAmount, 2);
|
|
|
+ $hd->balanceGive = $hdBalanceGive;
|
|
|
+ $hd->save();
|
|
|
+ if (floatval($customBalanceGive) != floatval($hdBalanceGive)) {
|
|
|
+ util::fail('余额有问题呢!请联系管理员,编号' . $hdId);
|
|
|
+ }
|
|
|
+ $giveChange = [
|
|
|
+ 'hdId' => $hdId,
|
|
|
+ 'hdName' => $hdName,
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'customName' => $customName,
|
|
|
+ 'relateId' => $relateId,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $mustUseGiveAmount,
|
|
|
+ 'balance' => $customBalanceGive,
|
|
|
+ 'io' => 0,
|
|
|
+ 'side' => $side,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'event' => $event,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ BalanceGiveChangeClass::add($giveChange, true);
|
|
|
+ $order->giveBalance = $mustUseGiveAmount;
|
|
|
+ $order->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ $addBalance = bcadd($hd->balancePay, $hd->balanceGive, 2);
|
|
|
+ if (floatval($addBalance) != floatval($custom->balance)) {
|
|
|
+ util::fail('账户余额有问题!请检查,编号' . $customId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//会员等级变化,包括手动修改、自动降会员和充值升会员等 ssh 20250324
|
|
|
@@ -241,13 +328,11 @@ class CustomClass extends BaseClass
|
|
|
BalanceChangeClass::add($change, true);
|
|
|
|
|
|
$mustUseGiveAmount = 0;
|
|
|
+ // 多处需要同步修改 balance_pay_give
|
|
|
if ($hd->balancePay >= $amount) {
|
|
|
- // todo 如果【充值金额】大于等于订单欠款金额,则用【全部充值金额】消单,还是正数,不需要用【赠送金额】
|
|
|
- // todo 错了,应该提醒客户使用余额支付,因为余额够付
|
|
|
util::fail('请用余额支付哈');
|
|
|
} else {
|
|
|
// todo 如果【充值金额】小于订单欠款金额,则用全部【充值金额】消单,同时必须用上【赠送金额】,够抵,则【充值金额】还是正数,不够抵,则是负数
|
|
|
-
|
|
|
if ($hd->balanceGive <= 0) {
|
|
|
//没有【赠送金额】,则用【充值金额】来消全部的欠款金额,不够则变成负数
|
|
|
$payAmount = $amount;
|
|
|
@@ -255,7 +340,6 @@ class CustomClass extends BaseClass
|
|
|
//这个是【总余额】,包括【充值金额】和【赠送金额】
|
|
|
$currentAdd = bcadd($hd->balancePay, $hd->balanceGive, 2);
|
|
|
if ($currentAdd >= $amount) {
|
|
|
- //【总余额】够抵欠款金额,用掉全部的【充值金额】,剩下的用【赠送金额】扣掉
|
|
|
util::fail('请使用余额支付哦');
|
|
|
} else {
|
|
|
//【总余额】不够抵欠款金额,先用掉全部的【赠送金额】,其他的全部算在【充值金额】名下,因为充值金额也不够扣,会出现负数
|