|
|
@@ -457,6 +457,31 @@ class PurchaseService extends BaseService
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 采购单余额付是否扣减花店 main.balance。
|
|
|
+ * main.balance 已废弃、后续会删,批发余额以 xhGhsCustom 净余额为准(OrderService::payToChangeBalance)。
|
|
|
+ * 仅「花店自助采购、先付采购单」等遗留路径仍可能走 purchaseReduceBalance,待 main.balance 下线后一并改。
|
|
|
+ */
|
|
|
+ protected static function shouldReduceMainBalanceOnBalancePay($info)
|
|
|
+ {
|
|
|
+ if (intval($info->cgStyle ?? 0) !== intval(dict::getDict('cgStyle', 'ghs'))) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ $saleId = intval($info->saleId ?? 0);
|
|
|
+ if ($saleId <= 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ $saleOrder = OrderClass::getById($saleId, true);
|
|
|
+ if (empty($saleOrder) || intval($saleOrder->payStatus ?? 0) !== 1) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 批发开单先完成销售单 payAfter:客户余额已扣,勿再动 main.balance
|
|
|
+ if (intval($saleOrder->payWay ?? -1) === intval(dict::getDict('payWay', 'balancePay'))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
//第三方支付、余额支付和欠款支付后调用的流程 ssh 2021.4.27
|
|
|
public static function payAfter($info, $payWay)
|
|
|
{
|
|
|
@@ -538,8 +563,8 @@ class PurchaseService extends BaseService
|
|
|
}
|
|
|
$realPrice = $info->realPrice;
|
|
|
$actPrice = $info->actPrice;
|
|
|
- //余额支付引起余额减少
|
|
|
- if ($payWay == dict::getDict('payWay', 'balancePay')) {
|
|
|
+ // 余额支付:批发开单只扣 xhGhsCustom;main.balance 已废弃,见 shouldReduceMainBalanceOnBalancePay
|
|
|
+ if ($payWay == dict::getDict('payWay', 'balancePay') && self::shouldReduceMainBalanceOnBalancePay($info)) {
|
|
|
ShopClass::purchaseReduceBalance($main, $shop, $realPrice, $info);
|
|
|
}
|
|
|
$main->totalPurchase = bcadd($main->totalPurchase, $actPrice, 2);
|