Kaynağa Gözat

重启福利账户

gorden 2 ay önce
ebeveyn
işleme
6cca5cb74a

+ 2 - 0
app/admin/controller/member/AccountController.php

@@ -102,6 +102,8 @@ class AccountController extends Curd
                 $data['card'][] = $item;
             } elseif ($item['member_account_classify'] == 'WELFARE') {
                 $data['welfare'] = $item;
+            } elseif ($item['member_account_classify'] == 'VIP') {
+                $data['vip'] = $item;
             }
         }
 

+ 63 - 1
app/admin/controller/order/WholeController.php

@@ -275,6 +275,8 @@ class WholeController extends Curd
                     $item['payWay'] = '账户余额';
                 } else if (!empty($payWay[1]) && $payWay[1] == 'WELFARE') {
                     $item['payWay'] = '福利账户';
+                } else if (!empty($payWay[1]) && $payWay[1] == 'VIP') {
+                    $item['payWay'] = 'VIP账户';
                 } else if (!empty($payWay[1]) && $payWay[1] == 'QRCODE') {
                     $item['payWay'] = '付款码';
                 } else if (!empty($payWay[0]) && $payWay[0] == 'OFFLINE') {
@@ -883,6 +885,35 @@ class WholeController extends Curd
                     $order->order_status_system = $systemStatus;
                     $order->order_status_payment = 'SUCCESS';
                 }
+            }  else if ($params['pay_category'] == 'VIP') {    // 余额支付
+                $account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
+                    ->where('member_account_classify', 'VIP')
+                    ->where('member_account_status', 'ACTIVED')
+                    ->first();
+                if (!$account) {
+                    throw new BusinessException('账户异常');
+                }
+                $amount = $account->member_account_surplus + $account->member_account_added;
+                if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
+                    throw new BusinessException('账户余额不足');
+                }
+                if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
+                    $qrcodePayAmount = $params['order_amount_pay'] - $amount;
+                    $params['order_amount_pay'] = $amount;
+                }
+                if ($params['order_amount_pay'] > $account->member_account_surplus) {
+                    $cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
+                    $account->member_account_surplus = 0;
+                    $account->member_account_added = $cut;
+                } else {
+                    $account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
+                }
+                $account->member_account_expend = $account->member_account_expend + $params['order_amount_pay'];
+                $account->save();
+                if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] <= $amount)) {
+                    $order->order_status_system = $systemStatus;
+                    $order->order_status_payment = 'SUCCESS';
+                }
             } else if ($params['pay_category'] == 'WELFARE') {  // 福利账户
                 $account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
                     ->where('member_account_classify', 'WELFARE')
@@ -1117,6 +1148,8 @@ class WholeController extends Curd
                 $payData['pay_prepayid'] = $params['join_order_member_id'] . '-CASH';
             } else if ($params['pay_category'] == 'WELFARE') {
                 $payData['pay_prepayid'] = $params['join_order_member_id'] . '-WELFARE';
+            }  else if ($params['pay_category'] == 'VIP') {
+                $payData['pay_prepayid'] = $params['join_order_member_id'] . '-VIP';
             } else if ($params['pay_category'] == 'CARD') {
                 $payData['pay_prepayid'] = $params['card_nbr'];
             } else if ($params['pay_category'] == 'OFFLINE') {
@@ -1913,7 +1946,7 @@ class WholeController extends Curd
                 }
             }
             // 余额、福利、储值卡 验证短信
-            if ($params['settlement_now'] == 'Y' && $params['pay_constitute'] == 'N' && in_array($params['pay_category'], ['CASH', 'CARD', 'WELFARE'])) {
+            if ($params['settlement_now'] == 'Y' && $params['pay_constitute'] == 'N' && in_array($params['pay_category'], ['CASH', 'CARD', 'WELFARE','VIP'])) {
                 $code = $params['sms_code'];
                 if (!$code) {
                     throw new BusinessException('验证码错误,请重新输入');
@@ -2000,6 +2033,35 @@ class WholeController extends Curd
                     $params['order_status_system'] = $systemStatus;
                     $params['order_status_payment'] = 'SUCCESS';
                 }
+            } else if ($params['settlement_now'] == 'Y' && $params['pay_category'] == 'VIP') {    // 余额支付
+                $account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
+                    ->where('member_account_classify', 'VIP')
+                    ->where('member_account_status', 'ACTIVED')
+                    ->first();
+                if (!$account) {
+                    throw new BusinessException('账户异常');
+                }
+                $amount = $account->member_account_surplus + $account->member_account_added;
+                if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
+                    throw new BusinessException('账户余额不足');
+                }
+                if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
+                    $qrcodePayAmount = $params['order_amount_pay'] - $amount;
+                    $params['order_amount_pay'] = $amount;
+                }
+                if ($params['order_amount_pay'] > $account->member_account_surplus) {
+                    $cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
+                    $account->member_account_surplus = 0;
+                    $account->member_account_added = $cut;
+                } else {
+                    $account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
+                }
+                $account->member_account_expend = $account->member_account_expend + $params['order_amount_pay'];
+                $account->save();
+                if ($params['pay_constitute'] == 'N') {
+                    $params['order_status_system'] = $systemStatus;
+                    $params['order_status_payment'] = 'SUCCESS';
+                }
             } else if ($params['settlement_now'] == 'Y' && $params['pay_category'] == 'WELFARE') {  // 福利账户
                 $account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
                     ->where('member_account_classify', 'WELFARE')