|
|
@@ -145,9 +145,44 @@ class ShopClass extends BaseClass
|
|
|
return $gatheringCode;
|
|
|
}
|
|
|
|
|
|
- //门店增加余额 ssh 2021.2.21
|
|
|
+ //客户下单引起的余额增加 shish 20210520
|
|
|
+ public static function customCreateOrderAddBalance($shop, $amount, $order, $capitalType)
|
|
|
+ {
|
|
|
+ //门店余额增加
|
|
|
+ $currentBalance = bcadd($shop->balance, $amount, 2);
|
|
|
+ $shop->balance = $currentBalance;
|
|
|
+ $shop->totalRecharge += $amount;
|
|
|
+ //可提现余额同步增加
|
|
|
+ $currentTx = bcadd($shop->txBalance, $amount, 2);
|
|
|
+ $shop->txBalance = $currentTx;
|
|
|
+ $shop->save();
|
|
|
+
|
|
|
+ //增加余额变动记录
|
|
|
+ $id = $order->id;
|
|
|
+ $event = "客户下单 {$amount}元";
|
|
|
+ $tx = dict::getDict('yeTx', 'can');
|
|
|
+ $change = [
|
|
|
+ 'relateId' => $id,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $currentBalance,
|
|
|
+ 'txBalance' => $currentTx,
|
|
|
+ 'io' => 1,
|
|
|
+ 'payWay' => $order->payWay,
|
|
|
+ 'event' => $event,
|
|
|
+ 'sjId' => $order->sjId,
|
|
|
+ 'shopId' => $order->shopId,
|
|
|
+ 'tx' => $tx,
|
|
|
+ ];
|
|
|
+ ShopYeChangeClass::addChange($change, true);
|
|
|
+
|
|
|
+ //平台余额增加
|
|
|
+ PtAssetClass::customCreateOrderAddBalance($shop, $amount, $order, $capitalType, $tx);
|
|
|
+ }
|
|
|
+
|
|
|
+ //门店充值增加余额 ssh 2021.2.21
|
|
|
//$fix = true 余额只能在指定门店使用
|
|
|
- public static function addBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)
|
|
|
+ public static function rechargeAddBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)
|
|
|
{
|
|
|
//门店余额增加
|
|
|
$currentBalance = bcadd($shop->balance, $amount, 2);
|
|
|
@@ -188,8 +223,7 @@ class ShopClass extends BaseClass
|
|
|
ShopYeChangeClass::addChange($change, true);
|
|
|
|
|
|
//平台余额增加
|
|
|
- PtAssetClass::addBalance($shop, $amount, $order, $capitalType, $tx);
|
|
|
-
|
|
|
+ PtAssetClass::rechargeAddBalance($shop, $amount, $order, $capitalType, $tx);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -211,18 +245,18 @@ class ShopClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//找出推荐人
|
|
|
- $ghsSjId = $ghs->sjId;
|
|
|
+ $ghsShopId = $ghs->shopId;
|
|
|
$parentShopId = SjClass::getParentShopId($sjId);
|
|
|
|
|
|
//指定消费判断
|
|
|
- if ($ghsSjId != $parentShopId) {
|
|
|
+ if ($ghsShopId != $parentShopId) {
|
|
|
//如果不是在自己推荐人那边采购,需确认扣掉定向消费余额后还够不够扣
|
|
|
$notFixBalance = bcsub($shop->balance, $currentFixBalance, 2);
|
|
|
if (bccomp($amount, $notFixBalance, 2) == 1) {
|
|
|
util::fail('充值余额只能在介绍您的门店消费');
|
|
|
}
|
|
|
} else {
|
|
|
- //需要扣掉的定向消费余额,不够本次扣时全部扣掉
|
|
|
+ //需要定向消费余额不够本次扣时全部扣掉
|
|
|
if ($currentFixBalance > 0) {
|
|
|
$reduceFix = $currentFixBalance > $amount ? $amount : $currentFixBalance;
|
|
|
$shop->fixBalance = bcsub($currentFixBalance, $reduceFix, 2);
|
|
|
@@ -252,7 +286,7 @@ class ShopClass extends BaseClass
|
|
|
'amount' => $amount,
|
|
|
'balance' => $currentBalance,
|
|
|
'txBalance' => $currentTxBalance,
|
|
|
- 'io' => 1,
|
|
|
+ 'io' => 0,
|
|
|
'payWay' => $order->payWay,
|
|
|
'event' => "余额支付{$amount}元",
|
|
|
'sjId' => $sjId,
|