|
|
@@ -345,6 +345,12 @@ class PurchaseService extends BaseService
|
|
|
Yii::$app->params['noNeedWxNotice'] = 1;
|
|
|
}
|
|
|
|
|
|
+ // 成对账户预检:两个 payAfter 顺序不变,先确认 xhGhsCustom/xhGhs 净余额一致再动单
|
|
|
+ $customId = intval($order->customId ?? 0);
|
|
|
+ if ($customId > 0) {
|
|
|
+ GhsRechargeSettleService::lockAccountPair(['id' => $customId]);
|
|
|
+ }
|
|
|
+
|
|
|
self::payAfter($info, $payWay);
|
|
|
|
|
|
OrderService::payAfter($order, $payWay, true);
|
|
|
@@ -657,8 +663,12 @@ class PurchaseService extends BaseService
|
|
|
if (empty($ghs)) {
|
|
|
util::fail('没有找到供货商');
|
|
|
}
|
|
|
+ // 挂账净余额:有联动销售单时由 OrderService::payAfter 成对扣,hd 侧不再扣 xhGhs.balance(同余额支付)
|
|
|
if ($payWay == dict::getDict('payWay', 'debtPay')) {
|
|
|
- \bizHd\ghs\classes\GhsClass::cgDebtAmountAdd($ghs, $info);
|
|
|
+ $saleId = intval($info->saleId ?? 0);
|
|
|
+ if ($saleId <= 0) {
|
|
|
+ \bizHd\ghs\classes\GhsClass::cgDebtAmountAdd($ghs, $info);
|
|
|
+ }
|
|
|
}
|
|
|
$ghs->expendAmount = bcadd($ghs->expendAmount, $actPrice, 2);
|
|
|
$ghs->expendNum += 1;
|