|
|
@@ -317,28 +317,23 @@ class ShopClass extends BaseClass
|
|
|
|
|
|
//定向消费余额
|
|
|
$currentFixBalance = $shop->fixBalance;
|
|
|
- $ghsId = $order->ghsId;
|
|
|
- $ghs = GhsClass::getById($ghsId, true);
|
|
|
- if (empty($ghs)) {
|
|
|
- util::fail('没有找到供货商');
|
|
|
- }
|
|
|
-
|
|
|
- //找出推荐人
|
|
|
- $ghsShopId = $ghs->shopId;
|
|
|
- $parentShopId = SjClass::getParentShopId($sjId);
|
|
|
-
|
|
|
- //指定消费判断
|
|
|
- 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);
|
|
|
+ $ghsId = $order->ghsId ?? 0;
|
|
|
+ $fixGhsId = $shop->fixGhsId ?? 0;
|
|
|
+
|
|
|
+ //定向消费判断
|
|
|
+ if (!empty($fixGhsId)) {
|
|
|
+ if ($ghsId != $fixGhsId) {
|
|
|
+ //如果不是在自己推荐人那边采购,需确认扣掉定向消费余额后还够不够扣
|
|
|
+ $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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$currentBalance = bcsub($shop->balance, $amount, 2);
|