浏览代码

ç身份配置相关

hefei 1 年之前
父节点
当前提交
4f0afd844e

+ 48 - 0
app/common/dao/user/UserIdentityDao.php

@@ -0,0 +1,48 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-05-07
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\dao\user;
12
+
13
+
14
+use app\common\dao\BaseDao;
15
+use app\common\model\BaseModel;
16
+use app\common\model\user\UserIdentity;
17
+use think\db\BaseQuery;
18
+
19
+/**
20
+ * Class UserIdentityDao
21
+ * @package app\common\dao\user
22
+ */
23
+class UserIdentityDao extends BaseDao
24
+{
25
+
26
+    /**
27
+     * @return BaseModel
28
+     * @author xaboy
29
+     * @day 2020-03-30
30
+     */
31
+    protected function getModel(): string
32
+    {
33
+        return UserIdentity::class;
34
+    }
35
+
36
+
37
+    /**
38
+     * @param array $where
39
+     * @return BaseQuery
40
+     * @author xaboy
41
+     * @day 2020-05-06
42
+     */
43
+    public function search(array $where = [])
44
+    {
45
+        return UserIdentity::getDB();
46
+    }
47
+
48
+}

+ 38 - 0
app/common/model/user/UserIdentity.php

@@ -0,0 +1,38 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-05-07
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\model\user;
12
+
13
+
14
+use app\common\model\BaseModel;
15
+
16
+class UserIdentity extends BaseModel
17
+{
18
+
19
+    /**
20
+     * @return string
21
+     * @author xaboy
22
+     * @day 2020-03-30
23
+     */
24
+    public static function tablePk(): string
25
+    {
26
+        return 'user_group_id';
27
+    }
28
+
29
+    /**
30
+     * @return string
31
+     * @author xaboy
32
+     * @day 2020-03-30
33
+     */
34
+    public static function tableName(): string
35
+    {
36
+        return 'user_identity';
37
+    }
38
+}

+ 97 - 0
app/common/repositories/user/UserIdentityRepository.php

@@ -0,0 +1,97 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-05-07
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\repositories\user;
12
+
13
+
14
+use app\common\dao\user\UserIdentityDao;
15
+use app\common\repositories\BaseRepository;
16
+use FormBuilder\Exception\FormBuilderException;
17
+use FormBuilder\Factory\Elm;
18
+use FormBuilder\Form;
19
+use think\db\exception\DataNotFoundException;
20
+use think\db\exception\DbException;
21
+use think\db\exception\ModelNotFoundException;
22
+use think\facade\Route;
23
+
24
+/**
25
+ * Class UserIdentityRepository
26
+ * @package app\common\repositories\user
27
+ * @author xaboy
28
+ * @day 2020-05-07
29
+ * @mixin UserIdentityDao
30
+ */
31
+class UserIdentityRepository extends BaseRepository
32
+{
33
+    /**
34
+     * @var UserIdentityDao
35
+     */
36
+    protected $dao;
37
+
38
+    /**
39
+     * UserGroupRepository constructor.
40
+     * @param UserIdentityDao $dao
41
+     */
42
+    public function __construct(UserIdentityDao $dao)
43
+    {
44
+        $this->dao = $dao;
45
+    }
46
+
47
+    /**
48
+     * @param array $where
49
+     * @param $page
50
+     * @param $limit
51
+     * @return array
52
+     * @throws DataNotFoundException
53
+     * @throws DbException
54
+     * @throws ModelNotFoundException
55
+     * @author xaboy
56
+     * @day 2020-05-07
57
+     */
58
+    public function getList(array $where, $page, $limit)
59
+    {
60
+        $query = $this->dao->search($where);
61
+        $count = $query->count($this->dao->getPk());
62
+        $list = $query->page($page, $limit)->select();
63
+        return compact('count', 'list');
64
+    }
65
+
66
+    /**
67
+     * @param null $id
68
+     * @param array $formData
69
+     * @return Form
70
+     * @throws FormBuilderException
71
+     * @author xaboy
72
+     * @day 2020-05-07
73
+     */
74
+    public function form($id = null, array $formData = [])
75
+    {
76
+        $isCreate = is_null($id);
77
+        $action = Route::buildUrl($isCreate ? 'systemUserGroupCreate' : 'systemUserGroupUpdate', $isCreate ? [] : compact('id'))->build();
78
+        return Elm::createForm($action, [
79
+            Elm::input('group_name', '用户分组名称')->required()
80
+        ])->setTitle($isCreate ? '添加用户分组' : '编辑用户分组')->formData($formData);
81
+    }
82
+
83
+    /**
84
+     * @param $id
85
+     * @return Form
86
+     * @throws FormBuilderException
87
+     * @throws DataNotFoundException
88
+     * @throws DbException
89
+     * @throws ModelNotFoundException
90
+     * @author xaboy
91
+     * @day 2020-05-07
92
+     */
93
+    public function updateForm($id)
94
+    {
95
+        return $this->form($id, $this->dao->get($id)->toArray());
96
+    }
97
+}

+ 94 - 0
app/controller/admin/system/config/Identity.php

@@ -0,0 +1,94 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-03-24
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\controller\admin\system\config;
12
+
13
+
14
+use crmeb\basic\BaseController;
15
+use app\common\repositories\user\UserIdentityRepository;
16
+use FormBuilder\Exception\FormBuilderException;
17
+use think\App;
18
+use think\db\exception\DataNotFoundException;
19
+use think\db\exception\DbException;
20
+use think\db\exception\ModelNotFoundException;
21
+
22
+/**
23
+ * Class Config
24
+ * @package app\controller\admin\system\config
25
+ * @author xaboy
26
+ * @day 2020-03-27
27
+ */
28
+class Identity extends BaseController
29
+{
30
+    /**
31
+     * @var UserIdentityRepository
32
+     */
33
+    protected $repository;
34
+
35
+    /**
36
+     * Config constructor.
37
+     * @param App $app
38
+     * @param UserIdentityRepository $repository
39
+     */
40
+    public function __construct(App $app, UserIdentityRepository $repository)
41
+    {
42
+        parent::__construct($app);
43
+        $this->repository = $repository;
44
+    }
45
+
46
+    /**
47
+     * @return mixed
48
+     * @throws DataNotFoundException
49
+     * @throws DbException
50
+     * @throws ModelNotFoundException
51
+     * @author xaboy
52
+     * @day 2020-03-31
53
+     */
54
+    public function lst()
55
+    {
56
+        $where = $this->request->params(['keyword']);
57
+        [$page, $limit] = $this->getPage();
58
+        $lst = $this->repository->getList($where, $page, $limit);
59
+
60
+        return app('json')->success($lst);
61
+    }
62
+
63
+    /**
64
+     * @param int $id
65
+     * @return mixed
66
+     * @throws DataNotFoundException
67
+     * @throws DbException
68
+     * @throws ModelNotFoundException
69
+     * @throws FormBuilderException
70
+     * @author xaboy
71
+     * @day 2020-03-31
72
+     */
73
+    public function updateTable($id)
74
+    {
75
+        if (!$this->repository->exists($id)) app('json')->fail('数据不存在');
76
+        $form = $this->repository->updateForm($id);
77
+        return app('json')->success(formToData($form));
78
+    }
79
+
80
+    /**
81
+     * @param int $id
82
+     * @return mixed
83
+     * @throws DbException
84
+     * @author xaboy
85
+     * @day 2020-03-27
86
+     */
87
+    public function update($id)
88
+    {
89
+        $data = $this->request->params(['arrive_num_own', 'arrive_num_team']);
90
+        $this->repository->update($id, $data);
91
+        return app('json')->success('修改成功');
92
+    }
93
+
94
+}

+ 3 - 1
app/controller/merchant/store/shipping/ShippingTemplate.php

@@ -47,7 +47,9 @@ class ShippingTemplate extends BaseController
47 47
      */
48 48
     public function getList()
49 49
     {
50
-        return app('json')->success($this->repository->getList($this->request->merId()));
50
+//        return app('json')->success($this->repository->getList($this->request->merId()));
51
+        // 目前只包邮
52
+        return app('json')->success($this->repository->getList(0));
51 53
     }
52 54
 
53 55
     /**

+ 6 - 0
route/admin.php

@@ -86,6 +86,12 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
86 86
             Route::delete('delete/:id', '/delete')->name('configSettingDelete');
87 87
             Route::post('upload_file/:field', '/upload')->name('configUpload');
88 88
         })->prefix('admin.system.config.Config');
89
+        //用户身份升级配置
90
+        Route::group('config/identity', function () {
91
+            Route::post('update/:id', '/update')->name('configIdentityUpdate');
92
+            Route::get('update/table/:id', '/updateTable')->name('configIdentityUpdateForm');
93
+            Route::get('lst', '/lst')->name('configIdentityLst');
94
+        })->prefix('admin.system.config.Identity');
89 95
 
90 96
         Route::group('config/others', function () {
91 97
             Route::get('lst', 'ConfigOthers/lst')->name('configOthersSettingLst');