gorden преди 2 месеца
родител
ревизия
b5d87853ff

+ 43 - 15
app/admin/controller/member/AccountController.php

@@ -17,7 +17,7 @@ class AccountController extends Curd
 
     public function my($id)
     {
-        $account = MemberAccount::where('join_account_member_id', $id)->where('member_account_status','ACTIVED')->get()->toArray();
+        $account = MemberAccount::where('join_account_member_id', $id)->get()->toArray();
         if (!$account) {
             // 账户表
             $accountData = [
@@ -39,13 +39,13 @@ class AccountController extends Curd
 
             $account = MemberAccount::where('join_account_member_id', $id)->get()->toArray();
         }
-        if ($account[0]['member_account_classify'] == 'POINTS'){
+        if ($account[0]['member_account_classify'] == 'POINTS') {
             $account = array_reverse($account);
         }
 
-        foreach ($account as &$item){
-            $item['member_account_duedate'] = !empty($item['member_account_duedate']) ? date('Y-m-d H:i:s',$item['member_account_duedate']) : '长期有效';
-            $item['member_account_surplus'] = round($item['member_account_surplus'] + $item['member_account_added'],2);
+        foreach ($account as &$item) {
+            $item['member_account_duedate'] = !empty($item['member_account_duedate']) ? date('Y-m-d H:i:s', $item['member_account_duedate']) : '长期有效';
+            $item['member_account_surplus'] = round($item['member_account_surplus'] + $item['member_account_added'], 2);
         }
 
         return json_success('', $account);
@@ -81,30 +81,58 @@ class AccountController extends Curd
     /**
      * 用户的账户
      */
-    public function selectMemberAccount(Request $request) 
+    public function selectMemberAccount(Request $request)
     {
-        $memberId = $request->get('member_id','');
-        if (!$memberId){
+        $memberId = $request->get('member_id', '');
+        if (!$memberId) {
             return json_fail('参数异常');
         }
-        
+
         $account = MemberAccount::where('join_account_member_id', $memberId)->get()->toArray();
 
         $data = [];
-        foreach ($account as $item){
-            $item['member_account_duedate'] = !empty($item['member_account_duedate']) ? date('Y-m-d H:i:s',$item['member_account_duedate']) : '长期有效';
+        foreach ($account as $item) {
+            $item['member_account_duedate'] = !empty($item['member_account_duedate']) ? date('Y-m-d H:i:s', $item['member_account_duedate']) : '长期有效';
 
-            if ($item['member_account_classify'] == 'POINTS'){
+            if ($item['member_account_classify'] == 'POINTS') {
                 $data['points'] = $item;
-            }elseif ($item['member_account_classify'] == 'CASH'){
+            } elseif ($item['member_account_classify'] == 'CASH') {
                 $data['cash'] = $item;
-            }elseif ($item['member_account_classify'] == 'CARD'){
+            } elseif ($item['member_account_classify'] == 'CARD') {
                 $data['card'][] = $item;
-            }elseif ($item['member_account_classify'] == 'WELFARE'){
+            } elseif ($item['member_account_classify'] == 'WELFARE') {
                 $data['welfare'] = $item;
             }
         }
 
         return json_success('', $data);
     }
+
+    /**
+     * @Desc 修改账户状态
+     * @Author Gorden
+     * @Date 2024/9/12 16:28
+     *
+     * @param Request $request
+     * @return \support\Response
+     */
+    public function updateStatus(Request $request)
+    {
+        $accountId = $request->post('account_id');
+        $status = $request->post('status');
+        if (!$accountId || !$status || !in_array($status,['DISABLED','ACTIVED','EXPIRED'])){
+            return json_fail('参数异常');
+        }
+        try {
+            $account = MemberAccount::where('member_account_id',$accountId)->first();
+            $account->member_account_status = $status;
+            $account->save();
+
+            _syslog("修改账户状态",'修改账户状态成功');
+            return json_success('账户状态修改成功');
+        }catch (\Exception $e){
+            _syslog("修改账户状态",'账户状态修改失败');
+            return json_fail('账户状态修改失败');
+        }
+    }
 }

+ 25 - 6
app/admin/controller/order/PayDetailController.php

@@ -53,11 +53,11 @@ class PayDetailController extends Curd
         //     $where['pay_category'] = 'RECHARGE';
         //     $where['pay_prepayid'] = ['in','WXPAY,ALIPAY'];
         // }
-        $query = $this->doSelect($where, $field, $order);
+        $query = $this->doSelect($where, $field, $order,$request->get());
         return $this->doFormat($query, $format, $limit);
     }
 
-    protected function doSelect(array $where, string $field = null, string $order = 'desc')
+    protected function doSelect(array $where, string $field = null, string $order = 'desc',$params=[])
     {
         $model = $this->model->with(['member', 'cert', 'memberAccount']);
         foreach ($where as $column => $value) {
@@ -89,10 +89,25 @@ class PayDetailController extends Curd
                 $model = $model->where($column, $value);
             }
         }
-        $model = $model->where(function ($query) {
-            $query->whereIn('pay_prepayid', ['ALIPAY', 'WXPAY','OFFLINE_WXPAY','OFFLINE_ALIPAY','MONEY'])
-                ->orWhere('pay_prepayid', 'like', '%CASH%');
-        });
+        if (empty($params['type'])){
+            $model = $model->where(function ($query) {
+                $query->whereIn('pay_prepayid', ['ALIPAY', 'WXPAY','OFFLINE_WXPAY','OFFLINE_ALIPAY','MONEY'])
+                    ->orWhere('pay_prepayid', 'like', '%CASH%')
+                    ->orWhere('pay_prepayid', 'like', '%WELFARE%');
+            });
+        }else{
+            if ($params['type'] == 'NORMAL'){
+                $model = $model->where(function ($query) {
+                    $query->whereIn('pay_prepayid', ['ALIPAY', 'WXPAY','OFFLINE_WXPAY','OFFLINE_ALIPAY','MONEY'])
+                        ->orWhere('pay_prepayid', 'like', '%CASH%');
+                });
+            }else{
+                $model = $model->where(function ($query) {
+                    $query->orWhere('pay_prepayid', 'like', '%WELFARE%');
+                });
+            }
+        }
+
 
         if ($field) {
             $model = $model->orderBy($field, $order);
@@ -168,6 +183,10 @@ class PayDetailController extends Curd
             if (count($prepayId) > 1) {
                 $item->pay_prepayid = $prepayId[1];
             }
+            $item->type = 'NORMAL';
+            if (isset($prepayId[1]) && $prepayId[1] == 'WELFARE'){
+                $item->type = 'WELFARE';
+            }
             $memberAccount = [];
             if (!empty($item->memberAccount)) {
                 foreach ($item->memberAccount as $account) {

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

@@ -1015,18 +1015,18 @@ class MemberService
                 MemberInfo::where('join_info_member_id', $params['member_id'])->update($infoData);
             }
             // 福利账户
-//            if (!empty($params['member_classify']) && $params['member_classify'] == 'EMPLOY' && !MemberAccount::where('member_account_nbr',$memberId.'-WELFARE')->exists()){
-//                $welfareData = [
-//                    'join_account_member_id'=>$memberId,
-//                    'member_account_classify'=>'WELFARE',
-//                    'member_account_status'=>'ACTIVED',
-//                    'member_account_category'=>'NORMAL',
-//                    'member_account_nbr'=>$memberId.'-WELFARE',
-//                    'member_account_name'=>'福利账户',
-//                    'member_account_addtimes'=>time()
-//                ];
-//                MemberAccount::insert($welfareData);
-//            }
+            if (!empty($params['member_classify']) && $params['member_classify'] == 'EMPLOY' && !MemberAccount::where('member_account_nbr',$memberId.'-WELFARE')->exists()){
+                $welfareData = [
+                    'join_account_member_id'=>$memberId,
+                    'member_account_classify'=>'WELFARE',
+                    'member_account_status'=>'ACTIVED',
+                    'member_account_category'=>'NORMAL',
+                    'member_account_nbr'=>$memberId.'-WELFARE',
+                    'member_account_name'=>'福利账户',
+                    'member_account_addtimes'=>time()
+                ];
+                MemberAccount::insert($welfareData);
+            }
 
             Db::commit();
         } catch (\Exception $e) {

+ 1 - 0
route/admin.php

@@ -666,6 +666,7 @@ Route::group('/admin', function () {
         Route::group('/account', function () {
             Route::get('/my/{id:\w+}', [\app\admin\controller\member\AccountController::class, 'my']);
             Route::post('/incomeExpend', [\app\admin\controller\member\AccountController::class, 'incomeExpend']);
+            Route::post('/updateStatus', [\app\admin\controller\member\AccountController::class, 'updateStatus']);
             Route::get('/selectMemberAccount', [\app\admin\controller\member\AccountController::class, 'selectMemberAccount']);
         })->middleware([
             \app\middleware\AdminAuthCheck::class