|
|
@@ -162,41 +162,18 @@ class RechargeClass extends BaseClass
|
|
|
|
|
|
//如果客户有欠款、结账充值、售后充值、售后付款充值,不参与优惠
|
|
|
if ($custom->balance >= 0 && $recharge->settleId == 0 && $recharge->shOrderId == 0 && $recharge->refundOrderId == 0) {
|
|
|
- if ($rechargeWeal == 1 || $rechargeWeal == 2) {
|
|
|
- $weal = MemberWealClass::getAllByCondition(['shopId' => $shopId], null, '*');
|
|
|
+ if ($rechargeWeal == 1) {
|
|
|
+ $weal = MemberWealClass::getAllByCondition(['shopId' => $shopId], 'recharge DESC', '*');
|
|
|
if (!empty($weal)) {
|
|
|
- $weal = arrayUtil::arraySort($weal, 'level', SORT_ASC);
|
|
|
- if ($rechargeWeal == 1) {
|
|
|
- //优惠方式1:充值升级会员
|
|
|
- $newLevel = 0;
|
|
|
- foreach ($weal as $k => $v) {
|
|
|
- $thisRecharge = $v['recharge'] ?? 0;
|
|
|
- $thisLevel = $v['level'] ?? 0;
|
|
|
- if ($amount >= $thisRecharge) {
|
|
|
- $newLevel = $thisLevel;
|
|
|
- }
|
|
|
- }
|
|
|
- $params = [
|
|
|
- 'style' => 0,
|
|
|
- 'rechargeAmount' => floatval($amount),
|
|
|
- 'onlinePay' => $onlinePay,
|
|
|
- 'staffId' => $staffId,
|
|
|
- 'staffName' => $staffName,
|
|
|
- ];
|
|
|
- if ($newLevel > $oldLevel) {
|
|
|
- CustomClass::levelChange($oldLevel, $newLevel, $shop, $custom, $hd, $params);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //优惠方式2:充多少送多少
|
|
|
- foreach ($weal as $k => $v) {
|
|
|
- $thisRecharge = $v['recharge'] ?? 0;
|
|
|
- $thisGive = $v['give'] ?? 0;
|
|
|
- if ($amount >= $thisRecharge) {
|
|
|
- $recharge->giveAmount = $thisGive;
|
|
|
- $recharge->save();
|
|
|
- //增加赠送的金额
|
|
|
- $balanceGive = $thisGive;
|
|
|
- }
|
|
|
+ //优惠方式2:充多少送多少
|
|
|
+ foreach ($weal as $k => $v) {
|
|
|
+ $thisRecharge = $v['recharge'] ?? 0;
|
|
|
+ $thisGive = $v['give'] ?? 0;
|
|
|
+ if ($amount >= $thisRecharge) {
|
|
|
+ $recharge->giveAmount = $thisGive;
|
|
|
+ $recharge->save();
|
|
|
+ //增加赠送的金额
|
|
|
+ $balanceGive = $thisGive;
|
|
|
}
|
|
|
}
|
|
|
}
|