Procházet zdrojové kódy

feat(admin): 添加自提点管理功能

- 在路由文件中新增自提点管理相关路由配置
- 创建自提点控制器类实现增删改查接口
- 扩展自提点DAO层添加搜索查询方法
- 完善自提点仓库层实现业务逻辑处理
- 添加自提点列表分页查询功能
- 实现自提点添加、获取、更新操作接口
shichen před 4 měsíci
rodič
revize
5afbcf44b9

+ 20 - 0
app/common/dao/store/order/PickUpDao.php

@@ -13,4 +13,24 @@ class PickUpDao extends BaseDao
13 13
     {
14 14
         return PickUp::class;
15 15
     }
16
+
17
+    public function search(array $where)
18
+    {
19
+        return PickUp::getDB()
20
+            ->when(isset($where['name']) && $where['name'] !== '', function ($query) use ($where) {
21
+                $query->where('name', 'like', '%' . $where['name'] . '%');
22
+            })
23
+            ->when(isset($where['address']) && $where['address'] !== '', function ($query) use ($where) {
24
+                $query->where('address', 'like', '%' . $where['address'] . '%');
25
+            })
26
+            ->when(isset($where['user_name']) && $where['user_name'] !== '', function ($query) use ($where) {
27
+                $query->where('user_name', 'like', '%' . $where['user_name'] . '%');
28
+            })
29
+            ->when(isset($where['mobile']) && $where['mobile'] !== '', function ($query) use ($where) {
30
+                $query->where('mobile', 'like', '%' . $where['mobile'] . '%');
31
+            })
32
+            ->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
33
+                $query->where('status', $where['status']);
34
+            });
35
+    }
16 36
 }

+ 41 - 1
app/common/repositories/store/order/PickUpRepository.php

@@ -19,6 +19,46 @@ class PickUpRepository extends BaseRepository
19 19
 
20 20
     public function getlist()
21 21
     {
22
-        return $this->dao->selectWhere(['status'=>1]);
22
+        return $this->dao->selectWhere(['status' => 1]);
23
+    }
24
+
25
+    /**
26
+     * @param array $where
27
+     * @param $page
28
+     * @param $limit
29
+     * @return array
30
+     * @throws \think\db\exception\DataNotFoundException
31
+     * @throws \think\db\exception\DbException
32
+     * @throws \think\db\exception\ModelNotFoundException
33
+     * @author 史晨
34
+     * @date 2026/3/20 10:13
35
+     * 自提点地址列表
36
+     */
37
+    public function adminList(array $params): array
38
+    {
39
+        $page = $params['page'] ?? 1;
40
+        $limit = $params['limit'] ?? 10;
41
+        unset($params['page'], $params['limit']);
42
+        $query = $this->dao->search($params);
43
+        $list = $query->page($page, $limit)
44
+            ->order('id', 'desc')
45
+            ->select()
46
+            ->toArray();
47
+        return $list;
48
+    }
49
+
50
+    public function add($params)
51
+    {
52
+        return $this->dao->create($params);
53
+    }
54
+
55
+    public function get($id)
56
+    {
57
+        return $this->dao->get($id);
58
+    }
59
+
60
+    public function update($id,$params)
61
+    {
62
+        return $this->dao->update($id,$params);
23 63
     }
24 64
 }

+ 84 - 0
app/controller/admin/system/pickUp/PickUp.php

@@ -0,0 +1,84 @@
1
+<?php
2
+
3
+namespace app\controller\admin\system\pickUp;
4
+
5
+use app\common\repositories\store\order\PickUpRepository;
6
+
7
+class PickUp
8
+{
9
+
10
+    protected $repository;
11
+
12
+    /**
13
+     * @param PickUpRepository $repository
14
+     */
15
+    public function __construct(PickUpRepository $repository)
16
+    {
17
+        $this->repository = $repository;
18
+    }
19
+
20
+    /**
21
+     * @return mixed
22
+     * @throws \think\db\exception\DataNotFoundException
23
+     * @throws \think\db\exception\DbException
24
+     * @throws \think\db\exception\ModelNotFoundException
25
+     * @author 史晨
26
+     * @date 2026/3/20 10:13
27
+     * 自提点地址列表
28
+     */
29
+    public function getList()
30
+    {
31
+        $params = request()->get();
32
+        $list = $this->repository->adminList($params);
33
+        return app('json')->success($list);
34
+    }
35
+
36
+    /**
37
+     * @return mixed
38
+     * @author 史晨
39
+     * @date 2026/3/20 10:32
40
+     * 添加自提点
41
+     */
42
+    public function add()
43
+    {
44
+        $params = request()->post();
45
+        $res = $this->repository->add($params);
46
+        if (!$res) {
47
+            return app('json')->fail('添加失败');
48
+        }
49
+        return app('json')->success('添加成功');
50
+    }
51
+
52
+    /**
53
+     * @param $id
54
+     * @return mixed
55
+     * @author 史晨
56
+     * @date 2026/3/20 10:32
57
+     * 获取自提点信息
58
+     */
59
+    public function get($id)
60
+    {
61
+        $data = $this->repository->get($id);
62
+        if (!$data) {
63
+            return app('json')->fail('获取失败');
64
+        }
65
+        return app('json')->success($data);
66
+    }
67
+
68
+    /**
69
+     * @param $id
70
+     * @return mixed
71
+     * @author 史晨
72
+     * @date 2026/3/20 10:33
73
+     * 更新自提点信息
74
+     */
75
+    public function update($id)
76
+    {
77
+        $params = request()->post();
78
+        $res = $this->repository->update($id, $params);
79
+        if (!$res) {
80
+            return app('json')->fail('添加失败');
81
+        }
82
+        return app('json')->success('添加成功');
83
+    }
84
+}

+ 11 - 3
route/admin.php

@@ -100,7 +100,7 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
100 100
             Route::get('lst', '/lst')->name('configAwardLst');
101 101
             Route::post('update/:key', '/update')->name('configAwardUpdate');
102 102
             Route::get('update/table', '/updateTable')->name('configAwardUpdateForm');
103
-        })->prefix('admin.system.config.award');    
103
+        })->prefix('admin.system.config.award');
104 104
 
105 105
         Route::group('config/others', function () {
106 106
             Route::get('lst', 'ConfigOthers/lst')->name('configOthersSettingLst');
@@ -155,7 +155,7 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
155 155
 
156 156
         //上传图片
157 157
         Route::post('upload/image/:id/:field', 'admin.system.attachment.Attachment/image')->name('uploadImage');
158
-        
158
+
159 159
         //上传视频
160 160
         Route::post('upload/video/:id/:field', 'admin.system.attachment.Attachment/video')->name('merchantUploadVideo');
161 161
 
@@ -317,6 +317,14 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
317 317
             Route::get('category/form/:id', '/updateForm')->name('systemMerchantCategoryUpdateForm');
318 318
         })->prefix('admin.system.merchant.MerchantCategory');
319 319
 
320
+        // 自提点管理
321
+        Route::group('system/pickUp', function () {
322
+            Route::get('list', '/getList')->name('systemPickUpList');
323
+            Route::post('add', '/add')->name('systemPickUpAdd');
324
+            Route::get('get/:id', '/get')->name('systemPickUpGet');
325
+            Route::post('update/:id', '/update')->name('systemPickUpUpdate');
326
+        })->prefix('admin.system.pickUp.PickUp');
327
+
320 328
 
321 329
         //用户标签
322 330
         Route::group('user/label', function () {
@@ -577,7 +585,7 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
577 585
             Route::post('upload/image', '/uploadImage')->name('wechatUploadImage');
578 586
             Route::post('upload/voice', '/uploadVoice')->name('wechatUploadVoice');
579 587
         })->prefix('admin.wechat.WechatReply');
580
-	
588
+
581 589
 	// 商家管理
582 590
         Route::group('merchant/contribute', function () {
583 591
             Route::post("list","admin.merchant.MerchantContribute/list");//图片列表