shish há 11 meses atrás
pai
commit
679307f9b1

+ 20 - 0
app-hd/controllers/MemberWealController.php

@@ -14,6 +14,26 @@ class MemberWealController extends BaseController
 
     public $guestAccess = [];
 
+    //获取充值和会员的优惠政策 ssh 20250226
+    public function actionGetWeal()
+    {
+        $shop = $this->shop;
+        $shopId = $shop->id;
+        $weal = MemberWealClass::getAllByCondition(['shopId' => $shopId], null, '*', null);
+        if (!empty($weal)) {
+            foreach ($weal as $key => $value) {
+                $recharge = $value['recharge'] ?? 0;
+                $recharge = floatval($recharge);
+                $give = $value['give'] ?? 0;
+                $give = floatval($give);
+                $weal[$key]['recharge'] = $recharge;
+                $weal[$key]['give'] = $give;
+            }
+        }
+        $rechargeWeal = $shop->rechargeWeal ?? 0;
+        util::success(['weal' => $weal, 'rechargeWeal' => $rechargeWeal]);
+    }
+
     public function actionGetRechargeData()
     {
         $shopId = $this->shopId;

+ 5 - 6
app-mall/controllers/MemberWealController.php

@@ -19,15 +19,14 @@ class MemberWealController extends BaseController
         $shop = $this->shop;
         $shopId = $shop->id;
         $weal = MemberWealClass::getAllByCondition(['shopId' => $shopId], null, '*', null);
-        $weal = arrayUtil::arraySort($weal, 'level', SORT_ASC);
         if (!empty($weal)) {
-            foreach ($weal as $key => $val) {
-                $recharge = $val['recharge'] ?? 0;
+            foreach ($weal as $key => $value) {
+                $recharge = $value['recharge'] ?? 0;
                 $recharge = floatval($recharge);
-                $giv = $val['give'] ?? 0;
-                $giv = floatval($giv);
+                $give = $value['give'] ?? 0;
+                $give = floatval($give);
                 $weal[$key]['recharge'] = $recharge;
-                $weal[$key]['give'] = $giv;
+                $weal[$key]['give'] = $give;
             }
         }
         $rechargeWeal = $shop->rechargeWeal ?? 0;

+ 11 - 34
biz-hd/recharge/classes/RechargeClass.php

@@ -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;
                         }
                     }
                 }