Ver código fonte

Merge branch 'dev'

gorden 3 meses atrás
pai
commit
678fb4ade0

+ 24 - 14
app/admin/controller/content/SubjectController.php

@@ -63,9 +63,9 @@ class SubjectController extends Curd
                     ->get()
                     ->toArray();
                 $formGoods = [];
-                foreach ($goodsList as $key => $goods){
-                    foreach ($contentConfigJson['goods'] as $cateGoods){
-                        if($cateGoods['goods_id'] == $goods['goods_id']){
+                foreach ($goodsList as $key => $goods) {
+                    foreach ($contentConfigJson['goods'] as $cateGoods) {
+                        if ($cateGoods['goods_id'] == $goods['goods_id']) {
                             $goodsList[$key]['cate'] = $cateGoods['cate'];
                             $formGoods[] = [
                                 'cate' => $cateGoods['cate'],
@@ -73,7 +73,7 @@ class SubjectController extends Curd
                             ];
                         }
                     }
-                    $goodsList[$key]['goods_cover'] = getenv('STORAGE_DOMAIN').$goods['goods_cover'];
+                    $goodsList[$key]['goods_cover'] = getenv('STORAGE_DOMAIN') . $goods['goods_cover'];
                 }
                 $item->goods = $formGoods;
                 $item->goodsList = $goodsList;
@@ -82,8 +82,13 @@ class SubjectController extends Curd
                 $sliders = [];
                 $originSliders = [];
                 foreach ($contentConfigJson['slider'] as $slider) {
-                    $sliders[] = getenv('STORAGE_DOMAIN') . $slider['url'];
-                    $originSliders[] = getenv('STORAGE_DOMAIN').str_replace('/thumb','',$slider['url']);
+                    if (!empty($slider['url'])) {
+                        $sliders[] = [
+                            'url' => getenv('STORAGE_DOMAIN') . $slider['url'],
+                            'href' => $slider['href'] ?? ''
+                        ];
+                        $originSliders[] = getenv('STORAGE_DOMAIN') . str_replace('/thumb', '', $slider['url']);
+                    }
                 }
                 $item->sliders = $sliders;
                 $item->originSliders = $originSliders;
@@ -99,9 +104,12 @@ class SubjectController extends Curd
         $data = $this->inputFilter($request->post());
         $contentConfigJson = [];
         if (!empty($params['sliders'])) {
-            $sliders = explode(',', $params['sliders']);
-            foreach ($sliders as $slider) {
-                $contentConfigJson['slider'][] = ['url' => str_replace(getenv('STORAGE_DOMAIN'), '', $slider)];
+            $contentConfigJson['slider'] = [];
+            foreach ($params['sliders'] as $slider) {
+                $contentConfigJson['slider'][] = [
+                    'url' => str_replace(getenv('STORAGE_DOMAIN'), '', $slider['url']),
+                    'href' => $slider['href']
+                ];
             }
         }
         if (!empty($params['cate'])) {
@@ -128,14 +136,16 @@ class SubjectController extends Curd
             throw new BusinessException('记录不存在', 2);
         }
         $contentConfigJson = [];
-        if (!empty($model->content_config_json)){
-            $contentConfigJson = json_decode($model->content_config_json,true);
+        if (!empty($model->content_config_json)) {
+            $contentConfigJson = json_decode($model->content_config_json, true);
         }
         if (!empty($params['sliders'])) {
             $contentConfigJson['slider'] = [];
-            $sliders = explode(',', $params['sliders']);
-            foreach ($sliders as $slider) {
-                $contentConfigJson['slider'][] = ['url' => str_replace(getenv('STORAGE_DOMAIN'), '', $slider)];
+            foreach ($params['sliders'] as $slider) {
+                $contentConfigJson['slider'][] = [
+                    'url' => str_replace(getenv('STORAGE_DOMAIN'), '', $slider['url']),
+                    'href' => $slider['href']
+                ];
             }
         }
         if (!empty($params['cate'])) {

+ 7 - 2
app/admin/controller/coupon/CardController.php

@@ -53,9 +53,11 @@ class CardController extends Curd
         if (!empty($cardMainName)) {
             $cardMainIds = CardMain::where('card_main_name', 'like', '%' . $cardMainName . '%')->pluck('card_main_id')->toArray();
         }
-        if (!empty($cardMainAmount)) {
+        if (!empty($cardMainAmount) && !empty($cardMainName)) {
             $mainIds = CardMain::where('card_main_amount', $cardMainAmount)->pluck('card_main_id')->toArray();
             $cardMainIds = array_intersect($cardMainIds, $mainIds);
+        } else if (!empty($cardMainAmount)) {
+            $cardMainIds = CardMain::where('card_main_amount', $cardMainAmount)->pluck('card_main_id')->toArray();
         }
         if (!empty($cardMainName) || !empty($cardMainAmount)) {
             $where['join_card_main_id'] = ['in', $cardMainIds];
@@ -64,6 +66,9 @@ class CardController extends Curd
             $cardIssueIds = CardIssue::where('card_issue_name', 'like', '%' . $cardIssueName . '%')->pluck('card_issue_id')->toArray();
             $where['join_card_issue_id'] = ['in', $cardIssueIds];
         }
+        if (!empty($where['card_id'])) {
+            $where['card_id'] = ['like', $where['card_id']];
+        }
 
         $query = $this->doSelect($where, $field, $order);
         return $this->doFormat($query, $format, $limit);
@@ -203,7 +208,7 @@ class CardController extends Curd
                 $query->select('card_issue_id', 'card_issue_name');
             }
         ])->when(!empty($cardId), function ($query) use ($cardId) {
-            $query->where('card_id', $cardId);
+            $query->where('card_id', 'like', '%' . $cardId . '%');
         })->when(!empty($deptId), function ($query) use ($deptId) {
             $query->where('join_card_dept_id', $deptId);
         })->when(!empty($memberId), function ($query) use ($memberId) {

+ 4 - 1
app/admin/controller/coupon/CardMainController.php

@@ -104,6 +104,9 @@ class CardMainController extends Curd
             } elseif ($item['card_main_valid_mode'] == 'DATE') {
                 $item['valid_term'] = date('Y/m/d', strtotime($item['card_main_valid_begin'])) . '-' . date('Y/m/d', strtotime($item['card_main_valid_end']));
             }
+
+            $item['total'] = Card::where('join_card_main_id', $item['card_main_id'])->count();
+            $item['amount'] = sprintf('%.2f', $item['total'] * $item['card_main_amount']);
         }
 
         return $items;
@@ -368,7 +371,7 @@ class CardMainController extends Curd
         })->when(!empty($name), function ($query) use ($name) {
             $query->where('card_main_name', 'like', '%' . $name . '%');
         })->when(!empty($amount), function ($query) use ($amount) {
-            $query->where('card_main_amount',  $amount);
+            $query->where('card_main_amount', $amount);
         })->when(!empty($addtimes), function ($query) use ($addtimes) {
             $addtimes[0] = strtotime($addtimes[0]);
             $addtimes[1] = strtotime($addtimes[1]);

+ 39 - 34
app/admin/controller/finance/CardController.php

@@ -19,8 +19,11 @@ class CardController
         $times[0] = strtotime($times[0]);
         $times[1] = strtotime(date('Y-m-d 23:59:59', strtotime($times[1])));
         $name = $request->get('card_main_name');
+        $searchMainAmount = $request->get('card_main_amount');
         $cardMain = CardMain::when(!empty($name), function ($query) use ($name) {
             $query->where('card_main_name', 'like', '%' . $name . '%');
+        })->when(!empty($searchMainAmount), function ($query) use ($searchMainAmount) {
+            $query->where('card_main_amount', $searchMainAmount);
         })->get()
             ->toArray();
         $cardIds = array_column($cardMain, 'card_main_id');
@@ -39,40 +42,39 @@ class CardController
         ];
         $data = [];
         foreach ($cardStatus as $key => $status) {
-            $cards = Card::when(!empty($cardIds), function ($query) use ($cardIds) {
-                $query->whereIn('join_card_main_id', $cardIds);
-            })->when($status == 'ISSUE', function ($query) use ($times) {
-                $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.issue_datetime'))) as SIGNED) >= {$times[0]}")
-                    ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.issue_datetime'))) as SIGNED) <= {$times[1]}")
-                    ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.issue_datetime' )))),'%Y-%m-%d') AS group_by_time");
-            })->when($status == 'ADD', function ($query) use ($times) {
-                $query->whereBetween('card_addtimes', $times)
-                    ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(card_addtimes),'%Y-%m-%d') AS group_by_time");
-            })->when($status == 'WAITING', function ($query) use ($times) {
-                $query->whereRaw("CAST(UNIX_TIMESTAMP(card_assign_datetime) as SIGNED) >= {$times[0]}")
-                    ->whereRaw("CAST(UNIX_TIMESTAMP(card_assign_datetime) as SIGNED) <= {$times[1]}")
-                    ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(card_assign_datetime)),'%Y-%m-%d') AS group_by_time");
-            })->when($status == 'PENDING', function ($query) use ($times) {
-                $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.buy_datetime'))) as SIGNED) >= {$times[0]}")
-                    ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.buy_datetime'))) as SIGNED) <= {$times[1]}")
-                    ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.buy_datetime' )))),'%Y-%m-%d') AS group_by_time");
-            })->when($status == 'USED', function ($query) use ($times) {
-                $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.used_datetime'))) as SIGNED) >= {$times[0]}")
-                    ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.used_datetime'))) as SIGNED) <= {$times[1]}")
-                    ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.used_datetime' )))),'%Y-%m-%d') AS group_by_time");
-            })->when($status == 'DONE', function ($query) use ($times) {
-                $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.done_time'))) as SIGNED) >= {$times[0]}")
-                    ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.done_time'))) as SIGNED) <= {$times[1]}")
-                    ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.done_time' )))),'%Y-%m-%d') AS group_by_time");
-            })->when($status == 'EXPIRED', function ($query) use ($times) {
-                $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.expired_datetime'))) as SIGNED) >= {$times[0]}")
-                    ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.expired_datetime'))) as SIGNED) <= {$times[1]}")
-                    ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.expired_datetime' )))),'%Y-%m-%d') AS group_by_time");
-            })->when($status == 'PAUSED', function ($query) use ($times) {
-                $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.paused_datetime'))) as SIGNED) >= {$times[0]}")
-                    ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.paused_datetime'))) as SIGNED) <= {$times[1]}")
-                    ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.paused_datetime' )))),'%Y-%m-%d') AS group_by_time");
-            })->selectRaw('count(card_id) as total,join_card_main_id')
+            $cards = Card::whereIn('join_card_main_id', $cardIds)
+                ->when($status == 'ISSUE', function ($query) use ($times) {
+                    $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.issue_datetime'))) as SIGNED) >= {$times[0]}")
+                        ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.issue_datetime'))) as SIGNED) <= {$times[1]}")
+                        ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.issue_datetime' )))),'%Y-%m-%d') AS group_by_time");
+                })->when($status == 'ADD', function ($query) use ($times) {
+                    $query->whereBetween('card_addtimes', $times)
+                        ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(card_addtimes),'%Y-%m-%d') AS group_by_time");
+                })->when($status == 'WAITING', function ($query) use ($times) {
+                    $query->whereRaw("CAST(UNIX_TIMESTAMP(card_assign_datetime) as SIGNED) >= {$times[0]}")
+                        ->whereRaw("CAST(UNIX_TIMESTAMP(card_assign_datetime) as SIGNED) <= {$times[1]}")
+                        ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(card_assign_datetime)),'%Y-%m-%d') AS group_by_time");
+                })->when($status == 'PENDING', function ($query) use ($times) {
+                    $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.buy_datetime'))) as SIGNED) >= {$times[0]}")
+                        ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.buy_datetime'))) as SIGNED) <= {$times[1]}")
+                        ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.buy_datetime' )))),'%Y-%m-%d') AS group_by_time");
+                })->when($status == 'USED', function ($query) use ($times) {
+                    $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.used_datetime'))) as SIGNED) >= {$times[0]}")
+                        ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.used_datetime'))) as SIGNED) <= {$times[1]}")
+                        ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.used_datetime' )))),'%Y-%m-%d') AS group_by_time");
+                })->when($status == 'DONE', function ($query) use ($times) {
+                    $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.done_time'))) as SIGNED) >= {$times[0]}")
+                        ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.done_time'))) as SIGNED) <= {$times[1]}")
+                        ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.done_time' )))),'%Y-%m-%d') AS group_by_time");
+                })->when($status == 'EXPIRED', function ($query) use ($times) {
+                    $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.expired_datetime'))) as SIGNED) >= {$times[0]}")
+                        ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.expired_datetime'))) as SIGNED) <= {$times[1]}")
+                        ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.expired_datetime' )))),'%Y-%m-%d') AS group_by_time");
+                })->when($status == 'PAUSED', function ($query) use ($times) {
+                    $query->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.paused_datetime'))) as SIGNED) >= {$times[0]}")
+                        ->whereRaw("CAST(UNIX_TIMESTAMP(JSON_UNQUOTE(JSON_EXTRACT(card_extend_json,'$.paused_datetime'))) as SIGNED) <= {$times[1]}")
+                        ->selectRaw("DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP( JSON_UNQUOTE( JSON_EXTRACT( card_extend_json, '$.paused_datetime' )))),'%Y-%m-%d') AS group_by_time");
+                })->selectRaw('count(card_id) as total,join_card_main_id')
                 ->groupBy('join_card_main_id', 'group_by_time')
                 ->get()
                 ->toArray();
@@ -148,8 +150,11 @@ class CardController
         $times[1] = strtotime(date('Y-m-d 23:59:59', strtotime($times[1])));
         $name = $request->get('card_main_name');
         $keys = $request->get('keys', []);
+        $searchMainAmount = $request->get('card_main_amount');
         $cardMain = CardMain::when(!empty($name), function ($query) use ($name) {
             $query->where('card_main_name', 'like', '%' . $name . '%');
+        })->when(!empty($searchMainAmount), function ($query) use ($searchMainAmount) {
+            $query->where('card_main_amount', $searchMainAmount);
         })->get()
             ->toArray();
         $cardIds = array_column($cardMain, 'card_main_id');

+ 17 - 0
app/admin/controller/member/MemberController.php

@@ -448,6 +448,23 @@ class MemberController
         return MemberService::vipInfo($request);
     }
 
+    /**
+     * @Desc 储值卡账户列表
+     * @Author Gorden
+     * @Date 2024/11/19 11:46
+     *
+     * @param Request $request
+     * @return \support\Response
+     */
+    public function cardList(Request $request)
+    {
+        $memberId = $request->get('member_id', '');
+        if (!$memberId) {
+            return json_fail("参数错误");
+        }
+
+        return MemberService::cardList($request);
+    }
     /**
      * @Desc 储值卡账户明细
      * @Author Gorden

+ 96 - 24
app/admin/controller/member/WellnessRecordController.php

@@ -36,7 +36,7 @@ class WellnessRecordController extends Curd
         }
 
         $data = $this->model->where($primaryKey, $request->get('id'))->first();
-        if ($data['wellness_record_category'] == 'Examine'){
+        if ($data['wellness_record_category'] == 'Examine') {
             $data->wellness_record_status = 'ACTIVED';
             $data->save();
         }
@@ -63,7 +63,7 @@ class WellnessRecordController extends Curd
                     $data['wellness_record_file_json'] = json_encode($file);
                     $this->doInsert($data);
                 }
-            }else{
+            } else {
                 $this->doInsert($data);
             }
 
@@ -134,8 +134,9 @@ class WellnessRecordController extends Curd
      * @param $memberId
      * @return Response
      */
-    public function advice($memberId)
+    public function advice(Request $request)
     {
+        $memberId = $request->get('member_id');
         $query = $this->model->where('wellness_record_category', 'Advice')
             ->where('join_wellness_record_member_id', $memberId)
             ->orderBy('wellness_record_addtimes', 'desc');
@@ -150,27 +151,20 @@ class WellnessRecordController extends Curd
                 'wellness_record_status' => $item->wellness_record_status,
                 'wellness_record_name' => $item->wellness_record_name,
                 'wellness_record_datetime' => $item->wellness_record_datetime,
-                'wellness_record_json' => $item->wellness_record_json,
                 'wellness_record_content' => $item->wellness_record_content,
                 'wellness_record_remark' => $item->wellness_record_remark,
                 'wellness_record_extend_json' => $item->wellness_record_extend_json,
                 'wellness_record_addtimes' => $item->wellness_record_addtimes,
+                'wellness_record_file_json' => json_decode($item->wellness_record_file_json),
+                'wellness_record_json' => json_decode($item->wellness_record_json,true),
             ];
-            if (!empty($item->wellness_record_file_json)) {
-                $item->wellness_record_file_json = json_decode($item->wellness_record_file_json, true);
-                foreach ($item->wellness_record_file_json as $value) {
-                    $itemNew['wellness_record_file_json'][] = [
-                        'url' => isset($value['url']) ? getenv('STORAGE_DOMAIN') . $value['url'] : '',
-                        'name' => isset($value['name']) ? $value['name'] : ''
-                    ];
+            if (!empty($itemNew['wellness_record_json'])) {
+                foreach ($itemNew['wellness_record_json'] as $key => $item) {
+                    if (empty($item['entry'])) {
+                        $itemNew['wellness_record_json'][$key]['entry'] = 'none';
+                    }
                 }
             }
-            if (!empty($item->wellness_record_json)) {
-                $itemNew['wellness_record_json'] = json_decode($item->wellness_record_json);
-            }
-            if (!empty($item->wellness_record_extend_json)) {
-                $itemNew['wellness_record_extend_json'] = json_decode($item->wellness_record_extend_json);
-            }
 
             $itemsNew[] = $itemNew;
         }
@@ -182,6 +176,82 @@ class WellnessRecordController extends Curd
         return json(['code' => 200, 'msg' => 'success', 'data' => $data]);
     }
 
+    /**
+     * @Desc 添加医嘱
+     * @Author Gorden
+     * @Date 2024/11/29 11:27
+     *
+     * @param Request $request
+     * @return Response
+     */
+    public function insertAdvice(Request $request): Response
+    {
+        try {
+            $params = $request->post();
+            $params['wellness_record_file_json'] = json_encode($params['wellness_record_file_json']);
+            $params['wellness_record_json'] = json_encode($params['wellness_record_json']);
+            $data = $this->inputFilter($params);
+            $data['wellness_record_datetime'] = date('Y-m-d H:i:s', strtotime($data['wellness_record_datetime']));
+            $this->doInsert($data);
+        } catch (BusinessException $customException) {
+            return json_fail($customException->getMessage());
+        } catch (\Exception $e) {
+            return json_fail('数据写入失败11');
+        }
+        return json_success('success');
+    }
+
+    /**
+     * @Desc 编辑医嘱
+     * @Author Gorden
+     * @Date 2024/11/29 11:27
+     *
+     * @param Request $request
+     * @return Response
+     */
+    public function updateAdvice(Request $request): Response
+    {
+        try {
+            [$id, $data] = $this->updateAdviceInput($request);
+            $this->doUpdate($id, $data);
+        } catch (BusinessException $e) {
+            return json_fail($e->getMessage());
+        } catch (\Exception $e) {
+            dump($e->getMessage());
+            return json_fail('数据更新失败');
+        }
+
+        return json_success('success');
+    }
+
+    /**
+     * @Desc 编辑医嘱预处理
+     * @Author Gorden
+     * @Date 2024/11/29 13:07
+     *
+     * @param Request $request
+     * @return array
+     * @throws BusinessException
+     */
+    protected function updateAdviceInput(Request $request): array
+    {
+        $primary_key = $this->model->getKeyName();
+        $id = $request->post($primary_key);
+        $model = $this->model->find($id);
+        if (!$model) {
+            throw new BusinessException('记录不存在', 2);
+        }
+        $params = $request->post();
+        $params['wellness_record_file_json'] = json_encode($params['wellness_record_file_json']);
+        $params['wellness_record_json'] = json_encode($params['wellness_record_json']);
+
+        $data = $this->inputFilter($params);
+        $data['wellness_record_datetime'] = date('Y-m-d H:i:s', strtotime($data['wellness_record_datetime']));
+
+        unset($data[$primary_key]);
+        return [$id, $data];
+    }
+
     /**
      * @Desc 我的档案
      * @Author Gorden
@@ -190,8 +260,9 @@ class WellnessRecordController extends Curd
      * @param $memberId
      * @return Response
      */
-    public function archives($memberId)
+    public function archives(Request $request)
     {
+        $memberId = $request->get('member_id');
         $archives = $this->model->where('wellness_record_category', 'Archives')
             ->where('join_wellness_record_member_id', $memberId)
             ->first();
@@ -260,8 +331,9 @@ class WellnessRecordController extends Curd
         return json_success('', $archives);
     }
 
-    public function checkup($memberId)
+    public function checkup(Request $request)
     {
+        $memberId = $request->get('member_id');
         $query = $this->model->where('wellness_record_category', 'Examine')
             ->where('join_wellness_record_member_id', $memberId)
             ->orderBy('wellness_record_addtimes', 'desc');
@@ -286,7 +358,7 @@ class WellnessRecordController extends Curd
                 $item->wellness_record_file_json = json_decode($item->wellness_record_file_json, true);
                 if (isset($item->wellness_record_file_json['file_filename']) && isset($item->wellness_record_file_json['file_savepath'])) {
                     $itemNew['wellness_record_file_json'][] = [
-                        'url' => getenv('APP_IMAGE_DOMAIN') .$item->wellness_record_file_json['file_savepath'].$item->wellness_record_file_json['file_savename'],
+                        'url' => getenv('APP_IMAGE_DOMAIN') . $item->wellness_record_file_json['file_savepath'] . $item->wellness_record_file_json['file_savename'],
                         'name' => $item->wellness_record_file_json['file_filename']
                     ];
                 } else if (isset($item->wellness_record_file_json['url']) && isset($item->wellness_record_file_json['name'])) {
@@ -493,6 +565,10 @@ class WellnessRecordController extends Curd
     {
         $primary_key = $this->model->getKeyName();
         $id = $request->post($primary_key);
+        $model = $this->model->find($id);
+        if (!$model) {
+            throw new BusinessException('记录不存在', 2);
+        }
         $data = $this->inputFilter($request->post());
         $data['wellness_record_datetime'] = date('Y-m-d H:i:s', strtotime($data['wellness_record_datetime']));
         if (!empty($data['wellness_record_file_json'])) {
@@ -512,10 +588,6 @@ class WellnessRecordController extends Curd
         if (!empty($request->post('records'))) {
             $data['wellness_record_json'] = json_encode($request->post('records'));
         }
-        $model = $this->model->find($id);
-        if (!$model) {
-            throw new BusinessException('记录不存在', 2);
-        }
         unset($data[$primary_key]);
         return [$id, $data];
     }

+ 6 - 1
app/admin/controller/order/CardController.php

@@ -219,6 +219,7 @@ class CardController extends Curd
     public function getCardList(Request $request)
     {
         $orderId = $request->get('order_id');
+        $deptId = $request->get('dept_id', '');
         $goodsId = OrderSheet::where('join_sheet_order_id', $orderId)->value('join_sheet_goods_id');
         $goods = Goods::where('goods_id', $goodsId)->select('goods_attribute_json')->first();
         $cards = [];
@@ -227,8 +228,12 @@ class CardController extends Curd
             if (!empty($goodsAttributeJson['card_main_id'])) {
                 $cards = Card::where('join_card_main_id', $goodsAttributeJson['card_main_id'])
                     ->where('card_status', 'WAITING')
+                    ->when(!empty($deptId), function ($query) use ($deptId) {
+                        $query->where('join_card_dept_id', $deptId);
+                    })
                     ->where('is_issue', 'Y')
-                    ->pluck('card_id')
+                    ->select('card_id', 'join_card_dept_id')
+                    ->get()
                     ->toArray();
             }
         }

+ 17 - 12
app/admin/controller/sys_manage/CategoryController.php

@@ -41,25 +41,30 @@ class CategoryController extends Curd
         $format = 'tree';
         $order = $request->get('order', 'desc');
         $field = $field ?? 'category_sort';
-        $where['category_status'] = ['in',['ACTIVED','UNSHOW']];
+        $where['category_status'] = ['in', ['ACTIVED', 'UNSHOW']];
+//        dump($where);
         $query = $this->doSelect($where, $field, $order);
         return $this->doFormat($query, $format, 1000);
     }
 
-    public function afterQuery($items){
+    public function afterQuery($items)
+    {
+        $categoryType = \request()->get('category_type', '');
         $categoryDatas = [];
-        foreach($items as &$item){
-            if (empty($item->category_super_path)){
-                $item->category_super_path = '#'.$item['category_id'].'#';
+        foreach ($items as &$item) {
+            if (empty($item->category_super_path)) {
+                $item->category_super_path = '#' . $item['category_id'] . '#';
             }
-            $categorys = SysCategory::where('category_super_path','like',$item->category_super_path.'%')
-                ->where('category_status','ACTIVED')
+            $categorys = SysCategory::where('category_super_path', 'like', $item->category_super_path . '%')
+                ->when(!empty($categoryType), function ($query) use ($categoryType) {
+                    $query->where('category_type', $categoryType);
+                })->whereIn('category_status', ['ACTIVED', 'UNSHOW'])
                 ->paginate(1000)
                 ->items();
-            $categoryDatas = array_merge($categorys,$categoryDatas);
+            $categoryDatas = array_merge($categorys, $categoryDatas);
         }
 
-        $items = array_merge($items,$categoryDatas);
+        $items = array_merge($items, $categoryDatas);
 
         return $items;
     }
@@ -101,7 +106,7 @@ class CategoryController extends Curd
         $order = $request->get('order', 'desc');
         $field = $field ?? 'category_sort';
         $where['category_status'] = 'ACTIVED';
-        $where['category_super_id'] = ['in','31,154,5,181,30,70,42'];
+        $where['category_super_id'] = ['in', '31,154,5,181,30,70,42'];
         $query = $this->doSelect($where, $field, $order);
         return $this->doFormatForGoods($query, $format, 1000);
         // $model->orWhereIn('category_id', ['31','154','5','181','30','70','42']);
@@ -128,12 +133,12 @@ class CategoryController extends Curd
         if (method_exists($this, "afterQuery")) {
             $items = call_user_func([$this, "afterQuery"], $items);
         }
-        $super = SysCategory::whereIn('category_id', ['31','154','5','181','30','70','42']);
+        $super = SysCategory::whereIn('category_id', ['31', '154', '5', '181', '30', '70', '42']);
         $superPaginator = $super->paginate($limit);
         $superTotal = $superPaginator->total();
         $superItems = $superPaginator->items();
 
-        $items = array_merge($items,$superItems);
+        $items = array_merge($items, $superItems);
         $total = $total + $superTotal;
 
         $format_function = $methods[$format] ?? 'formatNormal';

+ 19 - 8
app/admin/controller/sys_manage/FieldController.php

@@ -39,6 +39,17 @@ class FieldController extends Curd
         return $this->doFormat($query, $format, 1000);
     }
 
+    public function afterQuery($items)
+    {
+        foreach ($items as &$item) {
+            if (!empty($item->field_refer_json)) {
+                $fieldReferJson = json_decode($item->field_refer_json, true);
+                $item->field_refer_json_default = $fieldReferJson['default'] ?? '';
+            }
+        }
+        return $items;
+    }
+
     /**
      * @Desc 字段详情
      * @Author Gorden
@@ -62,10 +73,10 @@ class FieldController extends Curd
      */
     public function addField(Request $request)
     {
-        $validate = new FieldValidate();
-        if (!$validate->scene('add')->check($request->post())) {
-            return json_fail($validate->getError());
-        }
+//        $validate = new FieldValidate();
+//        if (!$validate->scene('add')->check($request->post())) {
+//            return json_fail($validate->getError());
+//        }
 
         // 验证数据表是否存在
         if (!FieldService::checkTableExist($request->post('field_table'))) {
@@ -90,10 +101,10 @@ class FieldController extends Curd
      */
     public function updateFields($id, Request $request)
     {
-        $validate = new FieldValidate();
-        if (!$validate->scene('update')->check($request->post())) {
-            return json_fail($validate->getError());
-        }
+//        $validate = new FieldValidate();
+//        if (!$validate->scene('update')->check($request->post())) {
+//            return json_fail($validate->getError());
+//        }
         // 验证数据表是否存在
         if (!FieldService::checkTableExist($request->post('field_table'))) {
             return json_fail('数据表不存在');

+ 27 - 1
app/admin/controller/sys_manage/ProtocolController.php

@@ -9,6 +9,7 @@ use app\controller\Curd;
 use app\model\Adv;
 use app\model\Article;
 use app\model\Content;
+use app\model\SysCategory;
 use support\exception\BusinessException;
 use support\Request;
 use support\Response;
@@ -79,12 +80,37 @@ class ProtocolController extends Curd
         return $model;
     }
 
+    /**
+     * @Desc 查询服务协议列表
+     * @Author Gorden
+     * @Date 2024/12/2 13:51
+     *
+     * @param Request $request
+     * @return Response
+     */
+    public function selectList(Request $request)
+    {
+        $category_type = $request->get('category_type');
+        $categoryIds = [];
+        if (!empty($category_type)) {
+            $categoryIds = SysCategory::where('category_type', $category_type)->pluck('category_id')->toArray();
+        }
+
+        $protocol = Content::whereIn('join_content_category_id',$categoryIds)
+            ->where('content_status','ACTIVED')
+            ->select('content_id','content_title')
+            ->get()
+            ->toArray();
+
+        return json_success('success',$protocol);
+    }
+
     public function insert(Request $request): Response
     {
         if ($this->validate && !$this->validateClass->scene('add')->check($request->post())) {
             return json_fail($this->validateClass->getError());
         }
-        if (Content::where('join_content_category_id',$request->post('join_content_category_id'))->exists()){
+        if (Content::where('join_content_category_id', $request->post('join_content_category_id'))->exists()) {
             return json_fail("当前分类已存在,请不要重复添加");
         }
 

+ 66 - 49
app/admin/controller/sys_manage/QuestionController.php

@@ -2,13 +2,11 @@
 
 namespace app\admin\controller\sys_manage;
 
-use app\admin\validate\sys_manage\AdvValidate;
-use app\admin\validate\sys_manage\ArticleValidate;
+use app\admin\service\sys_manage\FieldService;
 use app\admin\validate\sys_manage\ContentValidate;
 use app\controller\Curd;
-use app\model\Adv;
-use app\model\Article;
 use app\model\Content;
+use app\model\SysField;
 use support\exception\BusinessException;
 use support\Request;
 use support\Response;
@@ -36,7 +34,7 @@ class QuestionController extends Curd
         [$where, $format, $limit, $field, $order] = $this->selectInput($request);
         $where['content_category'] = 'WELLNESSQUESTION';
         $order = $request->get('order', 'desc');
-        $field = $field ?? 'content_addtimes';
+        $field = $field ?? 'content_sort';
         $query = $this->doSelect($where, $field, $order);
         return $this->doFormat($query, $format, $limit);
     }
@@ -78,7 +76,7 @@ class QuestionController extends Curd
             }
         }
         if ($field) {
-            $model = $model->orderBy($field, $order);
+            $model = $model->orderBy($field, $order)->orderBy('content_addtimes','DESC');
         }
         return $model;
     }
@@ -88,20 +86,20 @@ class QuestionController extends Curd
         foreach ($items as &$item) {
             if (!empty($item->content_config_json)) {
                 $contentConfigJson = json_decode($item->content_config_json, true);
-                $questionArray = [];
-                foreach ($contentConfigJson as $question) {
-                    $questionArray[] = [
-                        [
-                            'label' => '选项',
-                            'value' => $question['field'],
-                        ],
-                        [
-                            'label' => '题目',
-                            'value' => $question['question'],
-                        ]
-                    ];
-                }
-                $item->content_config_json = $questionArray;
+//                $questionArray = [];
+//                foreach ($contentConfigJson as $question) {
+//                    $questionArray[] = [
+//                        [
+//                            'label' => '选项',
+//                            'value' => $question['field'],
+//                        ],
+//                        [
+//                            'label' => '题目',
+//                            'value' => $question['question'],
+//                        ]
+//                    ];
+//                }
+                $item->content_config_json = array_values($contentConfigJson);
             } else {
                 $item->content_config_json = [];
             }
@@ -111,7 +109,43 @@ class QuestionController extends Curd
     }
 
     /**
-     * @Desc
+     * @Desc 问卷详情
+     * @Author Gorden
+     * @Date 2024/12/2 10:09
+     *
+     * @param Request $request
+     * @return Response
+     */
+    public function info(Request $request): Response
+    {
+        $contentId = $request->get('content_id');
+
+        $question = Content::where('content_id', $contentId)->first();
+        $questionContent = [];
+        if (!empty($question->content_config_json)) {
+            $contentConfigJson = json_decode($question->content_config_json, true);
+            foreach ($contentConfigJson as $item) {
+                $fields = SysField::whereIn('field_id', $item['field'])->select('field_name', 'field_form_type')->get()->toArray();
+                $fieldName = '';
+                foreach ($fields as $field) {
+                    $formType = FieldService::$formType[$field['field_form_type']] ?? '';
+                    $fieldName .= $field['field_name'] . '(' . $formType . ');';
+                }
+                $questionContent[] = [
+                    'question' => $item['question'],
+                    'fieldStr' => rtrim($fieldName, ';')
+                ];
+            }
+            $question->content_question_content = $questionContent;
+        }
+
+        dump($question);
+
+        return json_success('success', $question);
+    }
+
+    /**
+     * @Desc insert 处理
      * @Author Gorden
      * @Date 2024/3/27 10:24
      *
@@ -123,25 +157,20 @@ class QuestionController extends Curd
     {
         $data = $this->inputFilter($request->post());
         $data['content_category'] = 'WELLNESSQUESTION';
-        $contentConfigJson = [];
-        if (!empty($request->post('question'))) {
-            $questions = $request->post('question');
-            foreach ($questions as $question) {
-                if (!empty($question[1]['value'])) {
-                    $contentConfigJson[] = [
-                        'field' => $question[0]['value'],
-                        'question' => $question[1]['value'],
-                    ];
-                }
-            }
-            $contentConfigJson = new \ArrayObject($contentConfigJson);
-
-            $data['content_config_json'] = json_encode($contentConfigJson);
-        }
+        $data['content_config_json'] = json_encode($request->post('question'));
 
         return $data;
     }
 
+    /**
+     * @Desc update 处理
+     * @Author Gorden
+     * @Date 2024/12/2 9:22
+     *
+     * @param Request $request
+     * @return array
+     * @throws BusinessException
+     */
     protected function updateInput(Request $request): array
     {
         $primary_key = $this->model->getKeyName();
@@ -151,19 +180,7 @@ class QuestionController extends Curd
         if (!$model) {
             throw new BusinessException('记录不存在', 2);
         }
-        $contentConfigJson = [];
-        if (!empty($request->post('question'))) {
-            $questions = $request->post('question');
-            foreach ($questions as $question) {
-                $contentConfigJson[] = [
-                    'question' => $question[1]['value'],
-                    'field' => $question[0]['value'],
-                ];
-            }
-            $contentConfigJson = new \ArrayObject($contentConfigJson);
-
-            $data['content_config_json'] = json_encode($contentConfigJson);
-        }
+        $data['content_config_json'] = json_encode($request->post('question'));
         unset($data[$primary_key]);
         return [$id, $data];
     }

+ 30 - 63
app/admin/service/goods/CardService.php

@@ -826,14 +826,14 @@ class CardService
                 }
                 $data['goods_detail_slider_json'] = rtrim($slider, ',');
             }
-            $extendJson = [];
+            $goodsAttributeJson = [];
             if (!empty($data['goods_attribute_json'])) {
-                $extendJson = json_decode($data['goods_attribute_json'], true);
-                $data['goods_attribute_json'] = $extendJson;
+                $goodsAttributeJson = json_decode($data['goods_attribute_json'], true);
+                $data['goods_attribute_json'] = $goodsAttributeJson;
             }
-            if (!empty($extendJson['card_main_id'])) {
-                $data['card_main_id'] = $extendJson['card_main_id'];
-                $cardMain = CardMain::with('category')->where('card_main_id', $extendJson['card_main_id'])->first();
+            if (!empty($goodsAttributeJson['card_main_id'])) {
+                $data['card_main_id'] = $goodsAttributeJson['card_main_id'];
+                $cardMain = CardMain::with('category')->where('card_main_id', $goodsAttributeJson['card_main_id'])->first();
                 if (!empty($cardMain) && !empty($cardMain->card_main_valid_mode)) {
                     $validTerm = '';
                     if ($cardMain->card_main_valid_mode == 'LONG') {
@@ -855,6 +855,8 @@ class CardService
                     ];
                 }
             }
+            $data['protocol'] = $goodsAttributeJson['protocol'] ?? '';
+            $data['protocol_name'] = $goodsAttributeJson['protocol_name'] ?? '';
 
             $data['express_json'] = [];
             if (!empty($data['goods_express_json'])) {
@@ -1271,82 +1273,37 @@ class CardService
 
             $model->goods_json = '[]';
 
+            $attributeJson = [];
+            if (!empty($model->goods_attribute_json)) {
+                $attributeJson = json_decode($model->goods_attribute_json, true);
+            }
             if (!empty($params['goods_premisses'])) {
-                $attributeJson = [];
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
                 $attributeJson['premisses'] = $params['goods_premisses'];
-                $model->goods_attribute_json = json_encode($attributeJson);
-            }
-
-            if (!empty($params['goods_theme_color']) && !empty($params['goods_theme_icon'])) {
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
-                $attributeJson['bg'] = $params['goods_theme_color'];
-                $attributeJson['icon'] = str_replace(getenv('STORAGE_DOMAIN'), '', $params['goods_theme_icon']);
-                $model->goods_attribute_json = json_encode($attributeJson);
             }
             if (!empty($params['address'])) {
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
                 $attributeJson['address'] = $params['address'];
-                $model->goods_attribute_json = json_encode($attributeJson);
             }
             if (!empty($params['position'])) {
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
                 $attributeJson['position'] = $params['position'];
-                $model->goods_attribute_json = json_encode($attributeJson);
             }
             if (isset($params['goods_service_premises'])) {
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
                 $attributeJson['service_premises_id'] = $params['goods_service_premises'];
-                $model->goods_attribute_json = json_encode($attributeJson);
             }
             if (isset($params['min_count'])) {
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
                 $attributeJson['min-count'] = $params['min_count'];
-                $model->goods_attribute_json = json_encode($attributeJson);
-            }
-            if (isset($params['teachers'])) {
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
-                $attributeJson['teachers'] = $params['teachers'];
-                $model->goods_attribute_json = json_encode($attributeJson);
             }
             if (!empty($params['card_main_id'])) {
-                if (!empty($model->goods_attribute_json) && !is_array($model->goods_attribute_json)) {
-                    $attributeJson = json_decode($model->goods_attribute_json, true);
-                } elseif (empty($model->goods_attribute_json)) {
-                    $attributeJson = [];
-                }
                 $attributeJson['payment'] = 'Wx+Ali';
                 $attributeJson['card_main_id'] = $params['card_main_id'];
-                $model->goods_attribute_json = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
             }
+            if (!empty($params['protocol'])){
+                $attributeJson['protocol'] = $params['protocol'];
+            }
+            if (!empty($params['protocol_name'])){
+                $attributeJson['protocol_name'] = $params['protocol_name'];
+            }
+            $model->goods_attribute_json = json_encode($attributeJson);
+
             if ($model->save()) {
                 return $model->goods_id;
             }
@@ -1598,6 +1555,16 @@ class CardService
             if (!empty($params['card_main_id'])) {
                 $attributeJson['card_main_id'] = $params['card_main_id'];
             }
+            if (!empty($params['protocol'])){
+                $attributeJson['protocol'] = $params['protocol'];
+            }else{
+                unset($attributeJson['protocol']);
+            }
+            if (!empty($params['protocol_name'])){
+                $attributeJson['protocol_name'] = $params['protocol_name'];
+            }else{
+                unset($attributeJson['protocol_name']);
+            }
 
             $data['goods_attribute_json'] = json_encode($attributeJson, JSON_UNESCAPED_UNICODE);
 

+ 64 - 34
app/admin/service/member/MemberService.php

@@ -57,9 +57,7 @@ class MemberService
         }
 
         $rows = Member::with([
-            'account' => function ($query) {
-                $query->where('member_account_status', 'ACTIVED');
-            }
+            'account'
         ])->where('member_is_owner', 'N')
             ->where('member_mobile', '<>', '0000')
             ->leftJoin('member_info', 'member_info.join_info_member_id', 'member.member_id')
@@ -196,13 +194,19 @@ class MemberService
                             'member_account_added' => $item['member_account_added'],
                         ];
                     } else if ($item['member_account_classify'] == 'CARD') {
-                        $account['card'] = [
-                            'member_account_name' => $item['member_account_name'],
-                            'member_account_income' => $item['member_account_income'],
-                            'member_account_expend' => $item['member_account_expend'],
-                            'member_account_surplus' => $item['member_account_surplus'],
-                            'member_account_added' => $item['member_account_added'],
-                        ];
+                        if (isset($account['card'])) {
+                            $account['card']['member_account_income'] += $item['member_account_income'];
+                            $account['card']['member_account_expend'] += $item['member_account_expend'];
+                            $account['card']['member_account_surplus'] += $item['member_account_surplus'];
+                            $account['card']['member_account_added'] += $item['member_account_added'];
+                        } else {
+                            $account['card'] = [
+                                'member_account_income' => $item['member_account_income'],
+                                'member_account_expend' => $item['member_account_expend'],
+                                'member_account_surplus' => $item['member_account_surplus'],
+                                'member_account_added' => $item['member_account_added'],
+                            ];
+                        }
                     } else if ($item['member_account_classify'] == 'VIP') {
                         $account['vip'] = [
                             'member_account_name' => $item['member_account_name'],
@@ -743,6 +747,32 @@ class MemberService
         return json_success('', compact('rows', 'page', 'pageSize', 'total'));
     }
 
+    /**
+     * @Desc 我的储值卡列表
+     * @Author Gorden
+     * @Date 2024/12/2 17:12
+     *
+     * @param Request $request
+     * @return Response
+     */
+    public static function cardList(Request $request)
+    {
+        $page = $request->get('page', 1);
+        $pageSize = $request->get('pageSize', 20);
+        $memberId = $request->get('member_id');
+        $accounts = MemberAccount::where('join_account_member_id', $memberId)->where('member_account_classify','CARD');
+        $total = $accounts->count();
+        $rows = $accounts->orderByDesc('member_account_addtimes')
+            ->forPage($page, $pageSize)
+            ->get()
+            ->toArray();
+        foreach ($rows as &$row){
+            $row['member_account_surplus'] += $row['member_account_added'];
+        }
+
+        return json_success('success', compact('total', 'rows', 'page', 'pageSize'));
+    }
+
     /**
      * @Desc 储值卡账户明细
      * @Author Gorden
@@ -795,7 +825,7 @@ class MemberService
                 }
             }
             $item['goods_category'] = implode(',', array_unique($categoryName));
-            if (in_array($item['pay_category'], ['RECHARGE','REFUND'])) {
+            if (in_array($item['pay_category'], ['RECHARGE', 'REFUND'])) {
                 $item['balance_type'] = 'add';
             } else {
                 $item['balance_type'] = 'cut';
@@ -806,12 +836,12 @@ class MemberService
         }
 
         // 绑定记录
-        $memberAccountLists = MemberAccountList::where('join_list_member_account_nbr',$accountNbr)
-            ->where('member_account_list_attr','IN')
-            ->select('member_account_list_amount','member_account_list_datetime','member_account_list_attr','join_list_member_account_nbr','member_account_list_addtimes')
+        $memberAccountLists = MemberAccountList::where('join_list_member_account_nbr', $accountNbr)
+            ->where('member_account_list_attr', 'IN')
+            ->select('member_account_list_amount', 'member_account_list_datetime', 'member_account_list_attr', 'join_list_member_account_nbr', 'member_account_list_addtimes')
             ->get()
             ->toArray();
-        foreach ($memberAccountLists as $item){
+        foreach ($memberAccountLists as $item) {
             $data[] = [
                 'goods_category' => '',
                 'balance' => $item['member_account_list_amount'],
@@ -2220,28 +2250,28 @@ class MemberService
     /**
      * 卡用完了
      */
-    public static function accountToDone($accountId,$surplus,$added)
+    public static function accountToDone($accountId, $surplus, $added)
     {
-        try{
-            $account = MemberAccount::where('member_account_id',$accountId)
-                ->where('member_account_classify','CARD')
+        try {
+            $account = MemberAccount::where('member_account_id', $accountId)
+                ->where('member_account_classify', 'CARD')
                 ->first();
-                if (!empty($account) && $surplus <= 0 && $added <= 0){
-                    // 卡已完成
-                    $card = Card::where('join_card_member_account_id', $accountId)->first();
-                    $cardExtendJson = [];
-                    if (!empty($card->card_extend_json)){
-                        $cardExtendJson = json_decode($card->card_extend_json,true);
-                    }
-                    $cardExtendJson['done_time'] = date('Y-m-d H:i:s');
-                    $card->card_status = 'DONE';
-                    $card->card_extend_json = json_encode($cardExtendJson);
-                    $card->save();
-                    // 卡账户已完成
-                    $account->member_account_status = 'DONE';
-                    $account->save();
+            if (!empty($account) && $surplus <= 0 && $added <= 0) {
+                // 卡已完成
+                $card = Card::where('join_card_member_account_id', $accountId)->first();
+                $cardExtendJson = [];
+                if (!empty($card->card_extend_json)) {
+                    $cardExtendJson = json_decode($card->card_extend_json, true);
                 }
-        }catch (\Exception $e){
+                $cardExtendJson['done_time'] = date('Y-m-d H:i:s');
+                $card->card_status = 'DONE';
+                $card->card_extend_json = json_encode($cardExtendJson);
+                $card->save();
+                // 卡账户已完成
+                $account->member_account_status = 'DONE';
+                $account->save();
+            }
+        } catch (\Exception $e) {
             Log::error("卡完成状态处理失败");
         }
     }

+ 8 - 2
app/admin/service/sys_manage/CategoryService.php

@@ -88,8 +88,14 @@ class CategoryService
             // 不是顶级分类,有path
             if ($params['category_super_id'] != 0) {
                 // 回填path
-                $categoryPath = self::getCategoryPath($params['category_super_id']);
-                SysCategory::where('category_id', $categoryId)->update(['category_super_path' => $categoryPath . '#' . $params['category_super_id'] . '#']);
+                $parentSuperPath = self::getCategoryPath($params['category_super_id']);
+                $superPath = '#' . $params['category_super_id'] . '#';
+                if ($parentSuperPath == $superPath) {
+                    $categorySuperPath = $superPath;
+                } else {
+                    $categorySuperPath = $parentSuperPath . $superPath;
+                }
+                SysCategory::where('category_id', $categoryId)->update(['category_super_path' => $categorySuperPath]);
             }
             // 提交事务
             DB::commit();

+ 82 - 56
app/admin/service/sys_manage/FieldService.php

@@ -27,15 +27,16 @@ class FieldService
         $pageSize = $request->get('pageSize', 10);
         $fieldName = $request->get('field_name', '');
         $tableName = $request->get('table_name', '');
+        $fieldCategory = $request->get('field_category', '');
 
         $rows = SysField::select('*')
             ->when($fieldName != '', function ($query) use ($fieldName) {
                 $query->where('field_name', 'like', '%' . $fieldName . '%');
-            })
-            ->when($tableName != '', function ($query) use ($tableName) {
+            })->when($tableName != '', function ($query) use ($tableName) {
                 $query->where('field_table', 'like', '%' . $tableName . '%');
-            })
-            ->orderBy('field_addtimes', 'DESC')
+            })->when($fieldCategory != '', function ($query) use ($fieldCategory) {
+                $query->where('field_category', $fieldCategory);
+            })->orderBy('field_addtimes', 'DESC')
             ->forPage($page, $pageSize)
             ->get()
             ->toArray();
@@ -45,7 +46,7 @@ class FieldService
             $query->where('field_table', 'like', '%' . $tableName . '%');
         })->count();
 
-        foreach ($rows as &$row){
+        foreach ($rows as &$row) {
             $row['field_refer_json'] = json_decode($row['field_refer_json']);
         }
 
@@ -80,7 +81,7 @@ class FieldService
      */
     public static function addField($params)
     {
-        if (!empty($params['field_refer_json']['key'])){
+        if (!empty($params['field_refer_json']['key'])) {
             $params['field_refer_json']['val'] = $params['field_refer_json']['key'];
         }
         Db::beginTransaction();
@@ -104,24 +105,26 @@ class FieldService
             // 入库
             SysField::insert($data);
 
-            // 字段设置
-            $column = [
-                'type' => $params['field_column_datatype'],
-                'field' => $params['field_column_key'],
-                'primary_key' => false,
-                'nullable' => true,
-                'default' => $params['field_column_default'],
-                'auto_increment' => false,
-                'comment' => $params['field_name']
-            ];
-            $defaultLength = Util::fieldDefaultLength();
-            if (isset($defaultLength[$column['type']])) {
-                $column['length'] = $defaultLength[$column['type']];
+            if (!empty($params['field_table'])) {
+                // 字段设置
+                $column = [
+                    'type' => self::$column[$params['field_column_datatype']],
+                    'field' => $params['field_column_key'],
+                    'primary_key' => false,
+                    'nullable' => true,
+                    'default' => $params['field_column_default'],
+                    'auto_increment' => false,
+                    'comment' => $params['field_name']
+                ];
+                $defaultLength = Util::fieldDefaultLength();
+                if (isset($defaultLength[$column['type']])) {
+                    $column['length'] = $defaultLength[$column['type']];
+                }
+                // 写入字段
+                Util::schema()->table($params['field_table'], function (Blueprint $table) use ($column) {
+                    self::createColumn($table, $column);
+                });
             }
-            // 写入字段
-            Util::schema()->table($params['field_table'], function (Blueprint $table) use ($column) {
-                self::createColumn($table, $column);
-            });
             Db::commit();
         } catch (\Exception $e) {
             Db::rollBack();
@@ -155,47 +158,48 @@ class FieldService
                 'field_form_key' => $params['field_form_key'],
                 'field_form_type' => $params['field_form_type'],
                 'field_form_default' => $params['field_form_default'],
-                'field_refer_json' => !empty($params['field_refer_json']) ? $params['field_refer_json'] : [],
+                'field_refer_json' => !empty($params['field_refer_json']) ? json_encode($params['field_refer_json']) : '[]',
                 'field_remark' => $params['field_remark'],
-                'field_extend_json' => !empty($params['field_extend_json']) ? $params['field_extend_json'] : []
+//                'field_extend_json' => !empty($params['field_extend_json']) ? $params['field_extend_json'] : '[]'
             ];
             // 更新
             SysField::where('field_id', $id)->update($data);
-
-            // 字段设置
-            $column = [
-                'type' => $params['field_column_datatype'],
-                'field' => $params['field_column_key'],
-                'old_field' => $field->field_column_key,
-                'primary_key' => false,
-                'nullable' => true,
-                'default' => $params['field_column_default'],
-                'auto_increment' => false,
-                'comment' => $params['field_name']
-            ];
-            // 设置字段长度
-            $defaultLength = Util::fieldDefaultLength();
-            if (isset($defaultLength[$column['type']])) {
-                $column['length'] = $defaultLength[$column['type']];
-            }
-            // 表变动
-            if ($field->field_table != $params['field_table']) {
-                if (!empty($field->field_table)){
-                    // 删原表字段
-                    Util::db()->statement("ALTER TABLE " . getenv('DB_PREFIX') . $field->field_table . " DROP COLUMN `$field->field_column_key`");
+            if (!empty($params['field_table'])) {
+                // 字段设置
+                $column = [
+                    'type' => self::$column[$params['field_column_datatype']],
+                    'field' => $params['field_column_key'],
+                    'old_field' => $field->field_column_key,
+                    'primary_key' => false,
+                    'nullable' => true,
+                    'default' => $params['field_column_default'],
+                    'auto_increment' => false,
+                    'comment' => $params['field_name']
+                ];
+                // 设置字段长度
+                $defaultLength = Util::fieldDefaultLength();
+                if (isset($defaultLength[$column['type']])) {
+                    $column['length'] = $defaultLength[$column['type']];
+                }
+                // 表变动
+                if ($field->field_table != $params['field_table']) {
+                    if (!empty($field->field_table)) {
+                        // 删原表字段
+                        Util::db()->statement("ALTER TABLE " . getenv('DB_PREFIX') . $field->field_table . " DROP COLUMN `$field->field_column_key`");
+                    }
+                    // 在新表创建
+                    Util::schema()->table($params['field_table'], function (Blueprint $table) use ($column) {
+                        self::createColumn($table, $column);
+                    });
+                } else {
+                    // 表没变,改就行
+                    self::modifyColumn($params['field_table'], $column);
                 }
-                // 在新表创建
-                Util::schema()->table($params['field_table'], function (Blueprint $table) use ($column) {
-                    self::createColumn($table, $column);
-                });
-            } else {
-                // 表没变,改就行
-                self::modifyColumn(getenv('DB_PREFIX') . $params['field_table'], $column);
             }
             Db::commit();
         } catch (\Exception $e) {
             Db::rollBack();
-//            dump($e->getTrace());
+            dump($e->getMessage());
             return json_fail('修改字段失败');
         }
 
@@ -258,8 +262,12 @@ class FieldService
 
     public static function checkTableExist($table)
     {
+        if (empty($table)) {
+            return true;
+        }
+
         try {
-            $table = getenv('DB_PREFIX') . $table;
+//            $table = $table;
             $desc = (new SysField)->getConnection()->select("desc `$table`");
             if ($desc) {
                 return true;
@@ -280,6 +288,9 @@ class FieldService
      */
     public static function checkFieldExist($table, $field)
     {
+        if (empty($table)) {
+            return true;
+        }
         return SysField::where('field_table', $table)
             ->where('field_column_key', $field)
             ->exists();
@@ -440,4 +451,19 @@ class FieldService
         Util::db()->statement($sql);
     }
 
+    public static $column = [
+        'VARCHAR' => 'string',
+        'DATETIME' => 'dateTime',
+        'INT' => 'integer',
+        'DECIMAL' => 'decimal'
+    ];
+
+    public static $formType = [
+        'TEXT' => '单行文本',
+        'TEXTAREA' => '多行文本',
+        'RADIO' => '单选',
+        'CHECKBOX' => '多选',
+        'SELECT' => '下拉选择',
+        'DATE' => '日期'
+    ];
 }

+ 4 - 4
app/admin/validate/sys_manage/FieldValidate.php

@@ -8,14 +8,14 @@ class FieldValidate extends Validate
 {
     protected $rule = [
         'field_status|状态' => 'require|in:ACTIVED,DISABLED',
-        'field_category|分类' => 'in:NORMAL,PAGE,OTHER',
+//        'field_category|分类' => 'in:NORMAL,PAGE,OTHER',
         'field_name|名称' => 'require',
         'field_table|所属表' => 'require|alphaDash',
         'field_column_key|字段列名' => 'alphaDash',
-        'field_column_datatype|数据类型' => 'in:string,decimal,text,dateTime',
-        'field_column_default|列默认值' => 'checkDefault',
+//        'field_column_datatype|数据类型' => 'in:string,decimal,text,dateTime',
+//        'field_column_default|列默认值' => 'checkDefault',
 //        'field_form_key' => 'in:id,name',
-        'field_form_type|DOM表单类型' => 'alphaDash',
+//        'field_form_type|DOM表单类型' => 'alphaDash',
 //        'field_form_default' => 'chsDash',
 //        'field_refer_json' => 'isJson',
 //        'field_remark' => 'chsDash',

+ 8 - 3
route/admin.php

@@ -384,6 +384,7 @@ Route::group('/admin', function () {
         ]);
         Route::group('/protocol', function () {
             Route::get('/list', [\app\admin\controller\sys_manage\ProtocolController::class, 'select']);
+            Route::get('/selectList', [\app\admin\controller\sys_manage\ProtocolController::class, 'selectList']);
             Route::post('/add', [\app\admin\controller\sys_manage\ProtocolController::class, 'insert']);
             Route::post('/update', [\app\admin\controller\sys_manage\ProtocolController::class, 'update']);
             Route::delete('/delete', [\app\admin\controller\sys_manage\ProtocolController::class, 'delete']);
@@ -432,6 +433,7 @@ Route::group('/admin', function () {
         ]);
         Route::group('/question', function () {
             Route::get('/list', [\app\admin\controller\sys_manage\QuestionController::class, 'select']);
+            Route::get('/info', [\app\admin\controller\sys_manage\QuestionController::class, 'info']);
             Route::post('/add', [\app\admin\controller\sys_manage\QuestionController::class, 'insert']);
             Route::post('/update', [\app\admin\controller\sys_manage\QuestionController::class, 'update']);
             Route::delete('/delete', [\app\admin\controller\sys_manage\QuestionController::class, 'delete']);
@@ -820,6 +822,7 @@ Route::group('/admin', function () {
             Route::get('/couponCount', [\app\admin\controller\member\MemberController::class, 'couponCount']);
             Route::get('/couponDetail', [\app\admin\controller\member\MemberController::class, 'couponDetail']);
             Route::get('/balanceInfo', [\app\admin\controller\member\MemberController::class, 'balanceInfo']);
+            Route::get('/cardList', [\app\admin\controller\member\MemberController::class, 'cardList']);
             Route::get('/pointInfo', [\app\admin\controller\member\MemberController::class, 'pointInfo']);
             Route::get('/list', [\app\admin\controller\member\MemberController::class, 'list']);
             Route::get('/info', [\app\admin\controller\member\MemberController::class, 'info']);
@@ -884,9 +887,11 @@ Route::group('/admin', function () {
         /* 档案管理 */
         Route::group('/wellnessRecord', function () {
             Route::get('/my/{id:[0-9a-zA-Z]+}', [\app\admin\controller\member\WellnessRecordController::class, 'my']);
-            Route::get('/advice/{id:[0-9a-zA-Z]+}', [\app\admin\controller\member\WellnessRecordController::class, 'advice']);
-            Route::get('/archives/{id:[0-9a-zA-Z]+}', [\app\admin\controller\member\WellnessRecordController::class, 'archives']);
-            Route::get('/checkup/{id:[0-9a-zA-Z]+}', [\app\admin\controller\member\WellnessRecordController::class, 'checkup']);
+            Route::get('/advice', [\app\admin\controller\member\WellnessRecordController::class, 'advice']);
+            Route::post('/advice/add', [\app\admin\controller\member\WellnessRecordController::class, 'insertAdvice']);
+            Route::post('/advice/update', [\app\admin\controller\member\WellnessRecordController::class, 'updateAdvice']);
+            Route::get('/archives', [\app\admin\controller\member\WellnessRecordController::class, 'archives']);
+            Route::get('/checkup', [\app\admin\controller\member\WellnessRecordController::class, 'checkup']);
             Route::get('/visit/{id:[0-9a-zA-Z]+}', [\app\admin\controller\member\WellnessRecordController::class, 'visit']);
             Route::get('/list', [\app\admin\controller\member\WellnessRecordController::class, 'select']);
             Route::get('/info', [\app\admin\controller\member\WellnessRecordController::class, 'info']);