Browse Source

充值升级

gorden 7 months ago
parent
commit
c1202801ef

+ 2 - 2
app/admin/controller/order/PayDetailController.php

@@ -90,7 +90,7 @@ class PayDetailController extends Curd
             }
         }
         $model = $model->where(function ($query) {
-            $query->whereIn('pay_prepayid', ['ALIPAY', 'WXPAY'])
+            $query->whereIn('pay_prepayid', ['ALIPAY', 'WXPAY','OFFLINE_WXPAY','OFFLINE_ALIPAY'])
                 ->orWhere('pay_prepayid', 'like', '%CASH%');
         });
 
@@ -238,7 +238,7 @@ class PayDetailController extends Curd
         Db::beginTransaction();
         try {
             $data = $this->insertRechargeInput($request);
-            $data['pay_prepayid'] = $data['join_pay_member_id'] . '-CASH';
+            $data['pay_prepayid'] = $request->post('pay_prepayid', '');
 
             $payDetailId = $this->doInsert($data);
             (new RechargeController)->disposePaySuccess($payDetailId);

+ 3 - 3
app/admin/service/member/MemberService.php

@@ -743,7 +743,7 @@ class MemberService
                 }
             }
 
-            if (in_array($point['client_points_category'], ["评价", "消费", "活动", "赠送"])) {
+            if (in_array($point['client_points_category'], ["评价", "消费", "活动", "赠送",'登录活动积分'])) {
                 $point['balance_type'] = 'add';
             } else {
                 $point['balance_type'] = 'cut';
@@ -751,7 +751,7 @@ class MemberService
 
             if ($key == 0) {
                 $point['balance'] = number_format($balance, 2, '.', '');
-                if (in_array($point['client_points_category'], ["评价", "消费", "活动", "赠送"])) {
+                if (in_array($point['client_points_category'], ["评价", "消费", "活动", "赠送",'登录活动积分'])) {
                     $balance = $balance - $point['client_points_nbr'];
                 } else {
                     $balance = $balance + $point['client_points_nbr'];
@@ -759,7 +759,7 @@ class MemberService
 
                 continue;
             }
-            if (in_array($point['client_points_category'], ["评价", "消费", "活动", "赠送"])) {
+            if (in_array($point['client_points_category'], ["评价", "消费", "活动", "赠送",'登录活动积分'])) {
                 $point['balance'] = number_format($balance, 2, '.', '');
                 $balance = $balance - $point['client_points_nbr'];
 //                $point['balance'] = $balance = $nowPoint = number_format($balance - $point['client_points_nbr'], 2, '.', '');

+ 17 - 3
app/admin/service/notify/RechargeService.php

@@ -8,6 +8,7 @@ use app\model\MemberQuota;
 use app\model\MemberRole;
 use app\model\Order;
 use app\model\OrderSheet;
+use app\model\PayDetail;
 use app\model\RuleAdded;
 use app\model\RuleAddedComponent;
 use Monolog\Handler\IFTTTHandler;
@@ -64,9 +65,22 @@ class RechargeService
         if (!$memberAccount) {
             throw new BusinessException('账户异常');
         }
-        $income = floatval($memberAccount->member_account_income);
-        $expend = floatval($memberAccount->member_account_expend);
-        $money = max($income, $expend);
+//        $income = floatval($memberAccount->member_account_income);
+//        $expend = floatval($memberAccount->member_account_expend);
+//        $money = max($income, $expend);
+
+        $recharge = PayDetail::where('join_pay_member_id',$memberId)
+            ->where('pay_category','RECHARGE')
+            ->where('pay_status','SUCCESS')
+            ->whereIn('pay_prepayid', ['ALIPAY', 'WXPAY','OFFLINE_WXPAY','OFFLINE_ALIPAY','MONEY'])
+            ->orWhere('pay_prepayid', 'like', '%CASH%')
+            ->sum('pay_amount');
+        $expend = PayDetail::where('join_pay_member_id',$memberId)
+            ->whereIn('pay_category',['GOODS','SERVICE','CHNMED','CHNNCD','PACKAGE','MEALS'])
+            ->where('pay_status','SUCCESS')
+            ->whereIn('pay_prepayid', ['ALIPAY', 'WXPAY','OFFLINE_WXPAY','OFFLINE_ALIPAY','MONEY'])
+            ->sum('pay_amount');
+        $money = max($recharge, $expend);
 
         $memberRoles = MemberRole::where('member_role_status', 'ACTIVED')->get()->toArray();
         foreach ($memberRoles as $role) {