|
|
@@ -193,11 +193,16 @@ class ShopClass extends BaseClass
|
|
|
//客户结帐增加余额 shish 20210729
|
|
|
public static function customClearAddBalance($shop, $order)
|
|
|
{
|
|
|
- $balance = bcadd($shop->balance, $order->actPrice, 2);
|
|
|
- $txBalance = bcadd($shop->txBalance, $order->actPrice, 2);
|
|
|
- $shop->balance = $balance;
|
|
|
- $shop->txBalance = $txBalance;
|
|
|
- $shop->save();
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ util::fail('没有找到资产信息');
|
|
|
+ }
|
|
|
+ $balance = bcadd($main->balance, $order->actPrice, 2);
|
|
|
+ $txBalance = bcadd($main->txBalance, $order->actPrice, 2);
|
|
|
+ $main->balance = $balance;
|
|
|
+ $main->txBalance = $txBalance;
|
|
|
+ $main->save();
|
|
|
$clearId = $order->id ?? 0;
|
|
|
$tx = dict::getDict('yeTx', 'can');
|
|
|
$capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
|
|
|
@@ -220,6 +225,7 @@ class ShopClass extends BaseClass
|
|
|
'shopId' => $shop->id,
|
|
|
'tx' => $tx,
|
|
|
'ptStyle' => $shop->ptStyle,
|
|
|
+ 'mainId' => $mainId,
|
|
|
];
|
|
|
ShopYeChangeClass::addChange($change, true);
|
|
|
|
|
|
@@ -268,14 +274,18 @@ class ShopClass extends BaseClass
|
|
|
//客户下单引起的余额增加 shish 20210520
|
|
|
public static function customKdAddBalance($shop, $amount, $order, $capitalType)
|
|
|
{
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ util::fail('没有找到资产信息');
|
|
|
+ }
|
|
|
//门店余额增加
|
|
|
- $currentBalance = bcadd($shop->balance, $amount, 2);
|
|
|
- $shop->balance = $currentBalance;
|
|
|
- $shop->totalRecharge = bcadd($shop->totalRecharge, $amount, 2);
|
|
|
+ $currentBalance = bcadd($main->balance, $amount, 2);
|
|
|
+ $main->balance = $currentBalance;
|
|
|
//可提现余额同步增加
|
|
|
- $currentTx = bcadd($shop->txBalance, $amount, 2);
|
|
|
- $shop->txBalance = $currentTx;
|
|
|
- $shop->save();
|
|
|
+ $currentTx = bcadd($main->txBalance, $amount, 2);
|
|
|
+ $main->txBalance = $currentTx;
|
|
|
+ $main->save();
|
|
|
|
|
|
$ptStyle = $shop->ptStyle ?? dict::getDict('ptStyle', 'hd');
|
|
|
$customName = '客户';
|
|
|
@@ -291,7 +301,6 @@ class ShopClass extends BaseClass
|
|
|
$id = $order->id;
|
|
|
$event = $customName . "下单{$amount}元";
|
|
|
$tx = dict::getDict('yeTx', 'can');
|
|
|
- $mainId = $shop->mainId ?? 0;
|
|
|
$change = [
|
|
|
'relateId' => $id,
|
|
|
'capitalType' => $capitalType,
|
|
|
@@ -315,23 +324,29 @@ class ShopClass extends BaseClass
|
|
|
//$fix = true 余额只能在指定门店使用
|
|
|
public static function rechargeAddBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)
|
|
|
{
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ util::fail('没有找到资产信息');
|
|
|
+ }
|
|
|
//门店余额增加
|
|
|
- $currentBalance = bcadd($shop->balance, $amount, 2);
|
|
|
- $shop->balance = $currentBalance;
|
|
|
+ $currentBalance = bcadd($main->balance, $amount, 2);
|
|
|
+ $main->balance = $currentBalance;
|
|
|
$currentTotalRecharge = bcadd($shop->totalRecharge, $amount, 2);
|
|
|
- $shop->totalRecharge = $currentTotalRecharge;
|
|
|
+ $main->totalRecharge = $currentTotalRecharge;
|
|
|
//定向消费余额
|
|
|
if ($fix) {
|
|
|
- $currentFix = bcadd($shop->fixBalance, $amount, 2);
|
|
|
- $shop->fixBalance = $currentFix;
|
|
|
+ $currentFix = bcadd($main->fixBalance, $amount, 2);
|
|
|
+ $main->fixBalance = $currentFix;
|
|
|
}
|
|
|
- $currentTx = $shop->txBalance;
|
|
|
+ $currentTx = $main->txBalance;
|
|
|
//提现余额
|
|
|
if ($tx == dict::getDict('yeTx', 'can')) {
|
|
|
- $currentTx = bcadd($shop->txBalance, $amount, 2);
|
|
|
- $shop->txBalance = $currentTx;
|
|
|
+ $currentTx = bcadd($main->txBalance, $amount, 2);
|
|
|
+ $main->txBalance = $currentTx;
|
|
|
}
|
|
|
- $shop->save();
|
|
|
+ $main->save();
|
|
|
+
|
|
|
$order->totalRecharge = $currentTotalRecharge;
|
|
|
$order->save();
|
|
|
|
|
|
@@ -352,6 +367,7 @@ class ShopClass extends BaseClass
|
|
|
'event' => $event,
|
|
|
'sjId' => $order->sjId,
|
|
|
'shopId' => $order->shopId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
'tx' => $tx,
|
|
|
'ptStyle' => $shop->ptStyle,
|
|
|
];
|