|
|
@@ -216,21 +216,24 @@ class CustomClass extends BaseClass
|
|
|
$shopId = $shop->id ?? 0;
|
|
|
$sjId = $shop->sjId ?? 0;
|
|
|
|
|
|
- $newGhsBalance = bcsub($ghs->balance, $amount, 2);
|
|
|
+ $amount = bcadd((string)$amount, '0', 2);
|
|
|
+ if (bccomp($amount, '0', 2) <= 0) {
|
|
|
+ util::fail('销账扣款金额须大于0');
|
|
|
+ }
|
|
|
+
|
|
|
+ $newGhsBalance = bcsub((string)($ghs->balance ?? '0'), $amount, 2);
|
|
|
+ $newCustomBalance = bcsub((string)($custom->balance ?? '0'), $amount, 2);
|
|
|
+
|
|
|
+ // 合并后净余额可为负(待结),勿再因扣款后 <0 报错;金额由 CustomPaymentAllocateService 按来款池控制
|
|
|
+ if (bccomp($newGhsBalance, $newCustomBalance, 2) !== 0) {
|
|
|
+ util::fail('客户与供货商余额不一致,无法结账,请联系管理员');
|
|
|
+ }
|
|
|
+
|
|
|
$ghs->balance = $newGhsBalance;
|
|
|
$ghs->save();
|
|
|
-
|
|
|
- $newCustomBalance = bcsub($custom->balance, $amount, 2);
|
|
|
$custom->balance = $newCustomBalance;
|
|
|
$custom->save();
|
|
|
|
|
|
- if ($newGhsBalance < 0) {
|
|
|
- util::fail('余额有问题哦..');
|
|
|
- }
|
|
|
- if (floatval($newGhsBalance) != floatval($newCustomBalance)) {
|
|
|
- util::fail('余额有问题...');
|
|
|
- }
|
|
|
-
|
|
|
$capitalType = dict::getDict('capitalType', 'ghsHelpCustomUseBalanceClear', 'id');
|
|
|
$fromType = dict::getDict('fromType', 'shop');
|
|
|
$cbData = [
|