Ver código fonte

Merge remote-tracking branch 'origin/master'

whitefang 1 ano atrás
pai
commit
3247943334
25 arquivos alterados com 1366 adições e 4 exclusões
  1. 108 0
      app/adminapi/controller/master_worker_register/MasterWorkerRegisterController.php
  2. 1 1
      app/adminapi/lists/home_service/HomeServiceLists.php
  3. 79 0
      app/adminapi/lists/master_worker_register/MasterWorkerRegisterLists.php
  4. 1 1
      app/adminapi/lists/top_ranking/TopRankingLists.php
  5. 148 0
      app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php
  6. 106 0
      app/adminapi/validate/master_worker_register/MasterWorkerRegisterValidate.php
  7. 2 0
      app/api/logic/GoodsLogic.php
  8. 80 0
      app/common/cache/MasterWokerAccountSafeCache.php
  9. 107 0
      app/common/cache/MasterWokerTokenCache.php
  10. 7 0
      app/common/enum/notice/NoticeEnum.php
  11. 34 0
      app/common/model/MasterWorkerRegister.php
  12. 4 1
      app/common/model/dict/DictType.php
  13. 7 1
      app/common/model/goods/Goods.php
  14. 31 0
      app/common/model/master_worker/MasterWorker.php
  15. 28 0
      app/common/model/master_worker/MasterWorkerSession.php
  16. 34 0
      app/common/model/master_worker_register/MasterWorkerRegister.php
  17. 31 0
      app/workerapi/controller/BaseApiController.php
  18. 101 0
      app/workerapi/controller/LoginController.php
  19. 18 0
      app/workerapi/controller/SettingController.php
  20. 21 0
      app/workerapi/logic/DictLogic.php
  21. 102 0
      app/workerapi/logic/LoginLogic.php
  22. 120 0
      app/workerapi/service/MasterWokerTokenService.php
  23. 20 0
      app/workerapi/validate/DictValidate.php
  24. 138 0
      app/workerapi/validate/LoginAccountValidate.php
  25. 38 0
      app/workerapi/validate/RegisterValidate.php

+ 108 - 0
app/adminapi/controller/master_worker_register/MasterWorkerRegisterController.php

@@ -0,0 +1,108 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\master_worker_register;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\master_worker_register\MasterWorkerRegisterLists;
+use app\adminapi\logic\master_worker_register\MasterWorkerRegisterLogic;
+use app\adminapi\validate\master_worker_register\MasterWorkerRegisterValidate;
+
+
+/**
+ * MasterWorkerRegister控制器
+ * Class MasterWorkerRegisterController
+ * @package app\adminapi\controller\master_worker_register
+ */
+class MasterWorkerRegisterController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerRegisterLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerRegisterValidate())->post()->goCheck('add');
+        $result = MasterWorkerRegisterLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerRegisterLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerRegisterValidate())->post()->goCheck('edit');
+        $result = MasterWorkerRegisterLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerRegisterLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerRegisterValidate())->post()->goCheck('delete');
+        MasterWorkerRegisterLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerRegisterValidate())->goCheck('detail');
+        $result = MasterWorkerRegisterLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 1 - 1
app/adminapi/lists/home_service/HomeServiceLists.php

@@ -81,7 +81,7 @@ class HomeServiceLists extends BaseAdminDataLists implements ListsSearchInterfac
      */
      */
     public function count(): int
     public function count(): int
     {
     {
-        return HomeService::where($this->searchWhere)->count();
+        return HomeService::where($this->searchWhere)->where($this->queryWhere())->count();
     }
     }
 
 
 }
 }

+ 79 - 0
app/adminapi/lists/master_worker_register/MasterWorkerRegisterLists.php

@@ -0,0 +1,79 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\master_worker_register;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorkerRegister列表
+ * Class MasterWorkerRegisterLists
+ * @package app\adminapi\listsmaster_worker_register
+ */
+class MasterWorkerRegisterLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['maintain_exp_type', 'other_exp_type', 'city', 'vehicle_type', 'status'],
+            '%like%' => ['name', 'mobile'],
+            'between' => ['age'],

+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function lists(): array
+    {
+        return MasterWorkerRegister::where($this->searchWhere)
+            ->field(['id', 'maintain_exp_type', 'other_exp_type', 'city', 'vehicle_type', 'name', 'age', 'mobile', 'status'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function count(): int
+    {
+        return MasterWorkerRegister::where($this->searchWhere)->count();
+    }
+
+}

+ 1 - 1
app/adminapi/lists/top_ranking/TopRankingLists.php

@@ -81,7 +81,7 @@ class TopRankingLists extends BaseAdminDataLists implements ListsSearchInterface
      */
      */
     public function count(): int
     public function count(): int
     {
     {
-        return TopRanking::where($this->searchWhere)->count();
+        return TopRanking::where($this->searchWhere)->where($this->queryWhere())->count();
     }
     }
 
 
 }
 }

+ 148 - 0
app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php

@@ -0,0 +1,148 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\master_worker_register;
+
+
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+use think\facade\Config;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerRegister逻辑
+ * Class MasterWorkerRegisterLogic
+ * @package app\adminapi\logic\master_worker_register
+ */
+class MasterWorkerRegisterLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerRegister::create([
+                'maintain_exp_type' => $params['maintain_exp_type'],
+                'other_exp_type' => $params['other_exp_type'],
+                'city' => $params['city'],
+                'vehicle_type' => $params['vehicle_type'],
+                'name' => $params['name'],
+                'age' => $params['age'],
+                'mobile' => $params['mobile'],
+                'status' => $params['status'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $updata = [
+                'maintain_exp_type' => $params['maintain_exp_type'],
+                'other_exp_type' => $params['other_exp_type'],
+                'city' => $params['city'],
+                'vehicle_type' => $params['vehicle_type'],
+                'name' => $params['name'],
+                'age' => $params['age'],
+                'mobile' => $params['mobile'],
+                'status' => $params['status'],
+            ];
+
+            //审批通过逻辑处理
+            if($params['status'] == 1){
+                $updata['master_worker_id'] = self::createMasterWorker($params);
+            }
+            MasterWorkerRegister::where('id', $params['id'])->update($updata);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+    public static function createMasterWorker(array $params)
+    {
+        $where = ['mobile' => $params['mobile']];
+        $masterWorker = MasterWorker::where($where)->findOrEmpty();
+        if ($masterWorker->isEmpty()) {
+            $userSn = MasterWorker::createUserSn();
+            $passwordSalt = Config::get('project.unique_identification');
+            $password = create_password($params['mobile'], $passwordSalt);
+            $avatar = ConfigService::get('default_image', 'user_avatar');
+            $masterWorker = MasterWorker::create([
+                'sn' => $userSn,
+                'avatar' => $avatar,
+                'nickname' => '用户' . $userSn,
+                'account' => $params['mobile'],
+                'mobile' => $params['mobile'],
+                'password' => $password,
+                'channel' => 1,
+            ]);
+        }
+        return $masterWorker;
+    }
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerRegister::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerRegister::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 106 - 0
app/adminapi/validate/master_worker_register/MasterWorkerRegisterValidate.php

@@ -0,0 +1,106 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\master_worker_register;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerRegister验证器
+ * Class MasterWorkerRegisterValidate
+ * @package app\adminapi\validate\master_worker_register
+ */
+class MasterWorkerRegisterValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'maintain_exp_type' => 'require',
+        'other_exp_type' => 'require',
+        'city' => 'require',
+        'vehicle_type' => 'require',
+        'name' => 'require',
+        'mobile' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'maintain_exp_type' => '维修经验',
+        'other_exp_type' => '其他经验',
+        'city' => '城市',
+        'vehicle_type' => '交通工具',
+        'name' => '姓名',
+        'mobile' => '电话',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['maintain_exp_type','other_exp_type','city','vehicle_type','name','mobile']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','maintain_exp_type','other_exp_type','city','vehicle_type','name','mobile']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerRegisterValidate
+     * @author likeadmin
+     * @date 2024/07/09 19:45
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 2 - 0
app/api/logic/GoodsLogic.php

@@ -33,6 +33,8 @@ class GoodsLogic extends BaseLogic
     public static function getHotData()
     public static function getHotData()
     {
     {
         return Goods::where('is_hot', '=', 1)
         return Goods::where('is_hot', '=', 1)
+            ->with('goodsCategory')
+            ->visible(['id','goods_name','goods_category_id','goods_image','goods_video','goodsCategory'])
             ->order(['top_weight' => 'desc', 'id' => 'desc'])
             ->order(['top_weight' => 'desc', 'id' => 'desc'])
             ->select()->toArray();
             ->select()->toArray();
     }
     }

+ 80 - 0
app/common/cache/MasterWokerAccountSafeCache.php

@@ -0,0 +1,80 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\common\cache;
+
+
+/**
+ * //后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
+ * Class AdminAccountSafeCache
+ * @package app\common\cache
+ */
+class MasterWokerAccountSafeCache extends BaseCache
+{
+
+    private $key;//缓存次数名称
+    public $minute = 15;//缓存设置为15分钟,即密码错误次数达到,锁定15分钟
+    public $count = 15;  //设置连续输错次数,即15分钟内连续输错误15次后,锁定
+
+    public function __construct()
+    {
+        parent::__construct();
+        $ip = \request()->ip();
+        $this->key = $this->tagName . $ip;
+    }
+
+    /**
+     * @notes 记录登录错误次数
+     * @author 令狐冲
+     * @date 2021/6/30 01:51
+     */
+    public function record()
+    {
+        if ($this->get($this->key)) {
+            //缓存存在,记录错误次数
+            $this->inc($this->key, 1);
+        } else {
+            //缓存不存在,第一次设置缓存
+            $this->set($this->key, 1, $this->minute * 60);
+        }
+    }
+
+    /**
+     * @notes 判断是否安全
+     * @return bool
+     * @author 令狐冲
+     * @date 2021/6/30 01:53
+     */
+    public function isSafe()
+    {
+        $count = $this->get($this->key);
+        if ($count >= $this->count) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * @notes 删除该ip记录错误次数
+     * @author 令狐冲
+     * @date 2021/6/30 01:55
+     */
+    public function relieve()
+    {
+        $this->delete($this->key);
+    }
+
+
+}

+ 107 - 0
app/common/cache/MasterWokerTokenCache.php

@@ -0,0 +1,107 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\common\cache;
+
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerSession;
+use app\common\model\user\User;
+use app\common\model\user\UserSession;
+
+class MasterWokerTokenCache extends BaseCache
+{
+
+    private $prefix = 'token_master_woker_user';
+
+
+    /**
+     * @notes 通过token获取缓存用户信息
+     * @param $token
+     * @return array|false|mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/16 10:11
+     */
+    public function getUserInfo($token)
+    {
+        //直接从缓存获取
+        $userInfo = $this->get($this->prefix . $token);
+        if ($userInfo) {
+            return $userInfo;
+        }
+
+        //从数据获取信息被设置缓存(可能后台清除缓存)
+        $userInfo = $this->setUserInfo($token);
+        if ($userInfo) {
+            return $userInfo;
+        }
+
+        return false;
+    }
+
+
+    /**
+     * @notes 通过有效token设置用户信息缓存
+     * @param $token
+     * @return array|false|mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/16 10:11
+     */
+    public function setUserInfo($token)
+    {
+        $userSession = MasterWorkerSession::where([['token', '=', $token], ['expire_time', '>', time()]])->find();
+        if (empty($userSession)) {
+            return [];
+        }
+
+        $user = MasterWorker::where('id', '=', $userSession->user_id)
+            ->find();
+
+        $userInfo = [
+            'user_id' => $user->id,
+            'nickname' => $user->nickname,
+            'token' => $token,
+            'sn' => $user->sn,
+            'mobile' => $user->mobile,
+            'avatar' => $user->avatar,
+            'terminal' => $userSession->terminal,
+            'expire_time' => $userSession->expire_time,
+        ];
+
+        $ttl = new \DateTime(Date('Y-m-d H:i:s', $userSession->expire_time));
+        $this->set($this->prefix . $token, $userInfo, $ttl);
+        return $this->getUserInfo($token);
+    }
+
+
+    /**
+     * @notes 删除缓存
+     * @param $token
+     * @return bool
+     * @author 段誉
+     * @date 2022/9/16 10:13
+     */
+    public function deleteUserInfo($token)
+    {
+        return $this->delete($this->prefix . $token);
+    }
+
+
+}

+ 7 - 0
app/common/enum/notice/NoticeEnum.php

@@ -36,6 +36,7 @@ class NoticeEnum
     const BIND_MOBILE_CAPTCHA = 102;
     const BIND_MOBILE_CAPTCHA = 102;
     const CHANGE_MOBILE_CAPTCHA = 103;
     const CHANGE_MOBILE_CAPTCHA = 103;
     const FIND_LOGIN_PASSWORD_CAPTCHA = 104;
     const FIND_LOGIN_PASSWORD_CAPTCHA = 104;
+    const OTHER_CAPTCHA = 105;
 
 
 
 
     /**
     /**
@@ -46,6 +47,7 @@ class NoticeEnum
         self::BIND_MOBILE_CAPTCHA,
         self::BIND_MOBILE_CAPTCHA,
         self::CHANGE_MOBILE_CAPTCHA,
         self::CHANGE_MOBILE_CAPTCHA,
         self::FIND_LOGIN_PASSWORD_CAPTCHA,
         self::FIND_LOGIN_PASSWORD_CAPTCHA,
+        self::OTHER_CAPTCHA,
     ];
     ];
 
 
 
 
@@ -89,6 +91,7 @@ class NoticeEnum
             self::BIND_MOBILE_CAPTCHA => '绑定手机验证码',
             self::BIND_MOBILE_CAPTCHA => '绑定手机验证码',
             self::CHANGE_MOBILE_CAPTCHA => '变更手机验证码',
             self::CHANGE_MOBILE_CAPTCHA => '变更手机验证码',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '找回登录密码验证码',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '找回登录密码验证码',
+            self::OTHER_CAPTCHA => '其它',
         ];
         ];
 
 
         if ($flag) {
         if ($flag) {
@@ -117,6 +120,8 @@ class NoticeEnum
             'BGSJHM' => self::CHANGE_MOBILE_CAPTCHA,
             'BGSJHM' => self::CHANGE_MOBILE_CAPTCHA,
             // 找回登录密码
             // 找回登录密码
             'ZHDLMM' => self::FIND_LOGIN_PASSWORD_CAPTCHA,
             'ZHDLMM' => self::FIND_LOGIN_PASSWORD_CAPTCHA,
+            //其它
+            'OTHER' => self::OTHER_CAPTCHA,
         ];
         ];
         return $scene[$tag] ?? '';
         return $scene[$tag] ?? '';
     }
     }
@@ -137,6 +142,7 @@ class NoticeEnum
             self::BIND_MOBILE_CAPTCHA => '验证码:code',
             self::BIND_MOBILE_CAPTCHA => '验证码:code',
             self::CHANGE_MOBILE_CAPTCHA => '验证码:code',
             self::CHANGE_MOBILE_CAPTCHA => '验证码:code',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '验证码:code',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '验证码:code',
+            self::OTHER_CAPTCHA => '验证码:code',
         ];
         ];
 
 
         if ($flag) {
         if ($flag) {
@@ -182,6 +188,7 @@ class NoticeEnum
             self::BIND_MOBILE_CAPTCHA => '您正在绑定手机号,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
             self::BIND_MOBILE_CAPTCHA => '您正在绑定手机号,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
             self::CHANGE_MOBILE_CAPTCHA => '您正在变更手机号,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
             self::CHANGE_MOBILE_CAPTCHA => '您正在变更手机号,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '您正在找回登录密码,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
             self::FIND_LOGIN_PASSWORD_CAPTCHA => '您正在找回登录密码,验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
+            self::OTHER_CAPTCHA => '您的验证码${code},切勿将验证码泄露于他人,本条验证码有效期5分钟。',
         ];
         ];
 
 
         if ($flag) {
         if ($flag) {

+ 34 - 0
app/common/model/MasterWorkerRegister.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * MasterWorkerRegister模型
+ * Class MasterWorkerRegister
+ * @package app\common\model
+ */
+class MasterWorkerRegister extends BaseModel
+{
+    
+    protected $name = 'master_worker_register';
+    
+
+    
+}

+ 4 - 1
app/common/model/dict/DictType.php

@@ -43,5 +43,8 @@ class DictType extends BaseModel
     {
     {
         return $data['status'] ? '正常' : '停用';
         return $data['status'] ? '正常' : '停用';
     }
     }
-
+    public function dictData()
+    {
+        return $this->hasMany(DictData::class,'type_id','id')->where('status',1)->order('sort','desc')->field('id,type_id,name');
+    }
 }
 }

+ 7 - 1
app/common/model/goods/Goods.php

@@ -16,7 +16,7 @@ namespace app\common\model\goods;
 
 
 
 
 use app\common\model\BaseModel;
 use app\common\model\BaseModel;
-
+use app\common\model\goods_category\GoodsCategory;
 
 
 
 
 /**
 /**
@@ -33,4 +33,10 @@ class Goods extends BaseModel
     protected $type = [
     protected $type = [
         'goods_category_ids' =>  'array',
         'goods_category_ids' =>  'array',
     ];
     ];
+
+    public function goodsCategory()
+    {
+        return $this->hasOne(GoodsCategory::class, 'id', 'goods_category_id')
+            ->field('id,name,picture');
+    }
 }
 }

+ 31 - 0
app/common/model/master_worker/MasterWorker.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+
+namespace app\common\model\master_worker;
+
+use app\common\model\BaseModel;
+
+/**
+ * 师傅表
+ * Class MasterWorker
+ * @package app\common\model
+ */
+class MasterWorker extends BaseModel
+{
+    protected $name = 'master_worker';
+    public static function createUserSn($prefix = '', $length = 8)
+    {
+        $rand_str = '';
+        for ($i = 0; $i < $length; $i++) {
+            $rand_str .= mt_rand(1, 9);
+        }
+        $sn = $prefix . $rand_str;
+        if (MasterWorker::where(['sn' => $sn])->find()) {
+            return self::createUserSn($prefix, $length);
+        }
+        return $sn;
+    }
+}

+ 28 - 0
app/common/model/master_worker/MasterWorkerSession.php

@@ -0,0 +1,28 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\common\model\master_worker;
+
+use app\common\model\BaseModel;
+
+/**
+ * 师傅登录登录token信息
+ * Class UserSession
+ * @package app\common\model\master_worker
+ */
+class MasterWorkerSession extends BaseModel
+{
+    protected $name = 'master_worker_session';
+}

+ 34 - 0
app/common/model/master_worker_register/MasterWorkerRegister.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\master_worker_register;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * MasterWorkerRegister模型
+ * Class MasterWorkerRegister
+ * @package app\common\model\master_worker_register
+ */
+class MasterWorkerRegister extends BaseModel
+{
+    
+    protected $name = 'master_worker_register';
+    
+
+    
+}

+ 31 - 0
app/workerapi/controller/BaseApiController.php

@@ -0,0 +1,31 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\workerapi\controller;
+
+use app\common\controller\BaseLikeAdminController;
+
+class BaseApiController extends BaseLikeAdminController
+{
+    protected int $userId = 0;
+    protected array $userInfo = [];
+
+    public function initialize()
+    {
+        if (isset($this->request->userInfo) && $this->request->userInfo) {
+            $this->userInfo = $this->request->userInfo;
+            $this->userId = $this->request->userInfo['user_id'];
+        }
+    }
+}

+ 101 - 0
app/workerapi/controller/LoginController.php

@@ -0,0 +1,101 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\workerapi\controller;
+
+use app\workerapi\controller\BaseApiController;
+use app\workerapi\logic\LoginLogic;
+use app\workerapi\validate\LoginAccountValidate;
+use app\workerapi\validate\RegisterValidate;
+
+
+/**
+ * 登录注册
+ * Class LoginController
+ * @package app\api\controller
+ */
+class LoginController extends BaseApiController
+{
+
+    public array $notNeedLogin = ['register', 'account', 'logout'];
+
+
+    /**
+     * @notes 注册账号
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/7 15:38
+     */
+    public function register()
+    {
+        $params = (new RegisterValidate())->post()->goCheck('register');
+        $res = LoginLogic::confirmMobile($params);
+        if(!$res){
+            return $this->fail(LoginLogic::getError());
+        }
+        $result = LoginLogic::register($params);
+        if (true === $result) {
+            return $this->success('注册成功', [], 1, 1);
+        }
+        return $this->fail(LoginLogic::getError());
+    }
+
+
+    /**
+     * @notes 账号密码/手机号密码/手机号验证码登录
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/16 10:42
+     */
+    public function account()
+    {
+        $params = (new LoginAccountValidate())->post()->goCheck();
+        $result = LoginLogic::login($params);
+        if (false === $result) {
+            return $this->fail(LoginLogic::getError());
+        }
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 退出登录
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/16 10:42
+     */
+    public function logout()
+    {
+        LoginLogic::logout($this->userInfo);
+        return $this->success();
+    }
+
+    /**
+     * @notes 更新用户头像昵称
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/2/22 11:15
+     */
+    public function updateUser()
+    {
+        $params = (new WechatLoginValidate())->post()->goCheck("updateUser");
+        LoginLogic::updateUser($params, $this->userId);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+}

+ 18 - 0
app/workerapi/controller/SettingController.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace app\workerapi\controller;
+
+use app\workerapi\logic\DictLogic;
+use app\workerapi\validate\DictValidate;
+
+class SettingController extends BaseApiController
+{
+    public array $notNeedLogin = ['dictData'];
+
+    public function dictData()
+    {
+       $params = (new DictValidate())->post()->goCheck('dictData');
+       $res = DictLogic::groupData($params);
+       return $this->success('', $res);
+   }
+}

+ 21 - 0
app/workerapi/logic/DictLogic.php

@@ -0,0 +1,21 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\logic\BaseLogic;
+use app\common\model\dict\DictType;
+
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+class DictLogic extends BaseLogic
+{
+    public static function groupData($params): array
+    {
+        $typeArr = $params['type'];
+        return DictType::with('dictData')->whereIn('type',$typeArr)
+            ->field('id,type,name')
+            ->where('status',1)
+            ->select()
+            ->toArray();
+    }
+}

+ 102 - 0
app/workerapi/logic/LoginLogic.php

@@ -0,0 +1,102 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\enum\LoginEnum;
+use app\common\enum\notice\NoticeEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\service\FileService;
+use app\common\service\sms\SmsDriver;
+ use think\facade\Config;
+use app\workerapi\service\MasterWokerTokenService;
+
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+class LoginLogic extends BaseLogic
+{
+
+    /**
+     * @notes 确认手机号
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/9/21 17:28
+     */
+    public static function confirmMobile(array $params)
+    {
+        try {
+            // 变更手机号场景
+            $sceneId = NoticeEnum::OTHER_CAPTCHA;
+            // 校验短信
+//            $checkSmsCode = (new SmsDriver())->verify($params['mobile'], $params['code'], $sceneId);
+//            if (!$checkSmsCode) {
+//                throw new \Exception('验证码错误');
+//            }
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function register(array $params)
+    {
+        try {
+            MasterWorkerRegister::create([
+                'maintain_exp_type' => $params['maintain_exp_type'],
+                'other_exp_type' => $params['other_exp_type'],
+                'city' => $params['city'],
+                'vehicle_type' => $params['vehicle_type'],
+                'name' => $params['name'],
+                'age' => $params['age'],
+                'mobile' => $params['mobile'],
+            ]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function login($params)
+    {
+        try {
+            // 账号/手机号 密码登录
+            $where = ['account' => $params['account']];
+            if ($params['scene'] == LoginEnum::MOBILE_CAPTCHA) {
+                //手机验证码登录
+                $where = ['mobile' => $params['account']];
+            }
+
+            $user = MasterWorker::where($where)->findOrEmpty();
+            if ($user->isEmpty()) {
+                throw new \Exception('用户不存在');
+            }
+
+            //更新登录信息
+            $user->login_time = time();
+            $user->login_ip = request()->ip();
+            $user->save();
+
+            //设置token
+            $userInfo = MasterWokerTokenService::setToken($user->id, 1);
+
+            //返回登录信息
+            $avatar = $user->avatar ?: Config::get('project.default_image.user_avatar');
+            $avatar = FileService::getFileUrl($avatar);
+
+            return [
+                'nickname' => $userInfo['nickname'],
+                'sn' => $userInfo['sn'],
+                'mobile' => $userInfo['mobile'],
+                'avatar' => $avatar,
+                'token' => $userInfo['token'],
+            ];
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

+ 120 - 0
app/workerapi/service/MasterWokerTokenService.php

@@ -0,0 +1,120 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\workerapi\service;
+
+use app\common\cache\MasterWokerTokenCache;
+use app\common\model\master_worker\MasterWorkerSession;
+use think\facade\Config;
+
+class MasterWokerTokenService
+{
+
+    /**
+     * @notes 设置或更新用户token
+     * @param $userId
+     * @param $terminal
+     * @return array|false|mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/16 10:10
+     */
+    public static function setToken($userId, $terminal)
+    {
+        $time = time();
+        $userSession = MasterWorkerSession::where([['user_id', '=', $userId], ['terminal', '=', $terminal]])->find();
+
+        //获取token延长过期的时间
+        $expireTime = $time + Config::get('project.user_token.expire_duration');
+        $MasterWokerTokenCache = new MasterWokerTokenCache();
+
+        //token处理
+        if ($userSession) {
+            //清空缓存
+            $MasterWokerTokenCache->deleteUserInfo($userSession->token);
+            //重新获取token
+            $userSession->token = create_token($userId);
+            $userSession->expire_time = $expireTime;
+            $userSession->update_time = $time;
+            $userSession->save();
+        } else {
+            //找不到在该终端的token记录,创建token记录
+            $userSession = MasterWorkerSession::create([
+                'user_id' => $userId,
+                'terminal' => $terminal,
+                'token' => create_token($userId),
+                'expire_time' => $expireTime
+            ]);
+        }
+
+        return $MasterWokerTokenCache->setUserInfo($userSession->token);
+    }
+
+
+    /**
+     * @notes 延长token过期时间
+     * @param $token
+     * @return array|false|mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/16 10:10
+     */
+    public static function overtimeToken($token)
+    {
+        $time = time();
+        $userSession = MasterWorkerSession::where('token', '=', $token)->find();
+        if ($userSession->isEmpty()) {
+            return false;
+        }
+        //延长token过期时间
+        $userSession->expire_time = $time + Config::get('project.user_token.expire_duration');
+        $userSession->update_time = $time;
+        $userSession->save();
+
+        return (new MasterWokerTokenCache())->setUserInfo($userSession->token);
+    }
+
+
+    /**
+     * @notes 设置token为过期
+     * @param $token
+     * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/16 10:10
+     */
+    public static function expireToken($token)
+    {
+        $userSession = MasterWorkerSession::where('token', '=', $token)
+            ->find();
+        if (empty($userSession)) {
+            return false;
+        }
+
+        $time = time();
+        $userSession->expire_time = $time;
+        $userSession->update_time = $time;
+        $userSession->save();
+
+        return (new  MasterWokerTokenCache())->deleteUserInfo($token);
+    }
+
+}

+ 20 - 0
app/workerapi/validate/DictValidate.php

@@ -0,0 +1,20 @@
+<?php
+namespace app\workerapi\validate;
+use app\common\validate\BaseValidate;
+
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+
+class DictValidate extends BaseValidate
+{
+    protected $rule = [
+        'type' => 'require|array',
+    ];
+
+    protected $message = [
+        'type.require' => '字典类型名称必填',
+        'type.array' => '字典类型名称值必须是数组',
+    ];
+}

+ 138 - 0
app/workerapi/validate/LoginAccountValidate.php

@@ -0,0 +1,138 @@
+<?php
+namespace app\workerapi\validate;
+use app\common\cache\MasterWokerAccountSafeCache;
+use app\common\enum\LoginEnum;
+use app\common\enum\notice\NoticeEnum;
+use app\common\enum\user\UserTerminalEnum;
+use app\common\enum\YesNoEnum;
+use app\common\service\sms\SmsDriver;
+use think\facade\Config;
+use app\common\model\master_worker\MasterWorker;
+use app\common\validate\BaseValidate;
+
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+Class LoginAccountValidate  extends BaseValidate
+{
+    protected $rule = [
+        'account' => 'require',
+        'password' => 'require',
+        'terminal' => 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ','
+            . UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS .
+            ',' . UserTerminalEnum::ANDROID,
+        'scene' => 'require|in:' . LoginEnum::ACCOUNT_PASSWORD . ',' . LoginEnum::MOBILE_CAPTCHA . '|checkConfig',
+    ];
+
+    protected $message = [
+        'account.require' => '请输入手机号或账号',
+        'password.require' => '请输入密码',
+        'terminal.require' => '终端参数缺失',
+        'terminal.in' => '终端参数状态值不正确',
+        'scene.require' => '场景不能为空',
+        'scene.in' => '场景值错误',
+    ];
+    /**
+     * @notes 登录场景相关校验
+     * @param $scene
+     * @param $rule
+     * @param $data
+     * @return bool|string
+     * @author 段誉
+     * @date 2022/9/15 14:37
+     */
+    public function checkConfig($scene, $rule, $data)
+    {
+
+        // 账号密码登录
+        if (LoginEnum::ACCOUNT_PASSWORD == $scene) {
+            if (!isset($data['password'])) {
+                return '请输入密码';
+            }
+            return $this->checkPassword($data['password'], [], $data);
+        }
+
+        // 手机验证码登录
+        if (LoginEnum::MOBILE_CAPTCHA == $scene) {
+            if (!isset($data['code'])) {
+                return '请输入手机验证码';
+            }
+            return $this->checkCode($data['code'], [], $data);
+        }
+
+        return true;
+    }
+
+
+    /**
+     * @notes 登录密码校验
+     * @param $password
+     * @param $other
+     * @param $data
+     * @return bool|string
+     * @author 段誉
+     * @date 2022/9/15 14:39
+     */
+    public function checkPassword($password, $other, $data)
+    {
+        //账号安全机制,连续输错后锁定,防止账号密码暴力破解
+        $userAccountSafeCache = new MasterWokerAccountSafeCache();
+        if (!$userAccountSafeCache->isSafe()) {
+            return '密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试';
+        }
+
+        $where = [];
+        if ($data['scene'] == LoginEnum::ACCOUNT_PASSWORD) {
+            // 手机号密码登录
+            $where = ['account|mobile' => $data['account']];
+        }
+
+        $userInfo = MasterWorker::where($where)
+            ->field(['password,is_disable'])
+            ->findOrEmpty();
+
+        if ($userInfo->isEmpty()) {
+            return '用户不存在';
+        }
+
+        if ($userInfo['is_disable'] === YesNoEnum::YES) {
+            return '用户已禁用';
+        }
+        if (empty($userInfo['password'])) {
+            $userAccountSafeCache->record();
+            return '用户不存在';
+        }
+
+        $passwordSalt = Config::get('project.unique_identification');
+
+        if ($userInfo['password'] !== create_password($password, $passwordSalt)) {
+            $userAccountSafeCache->record();
+            return '密码错误';
+        }
+
+        $userAccountSafeCache->relieve();
+
+        return true;
+    }
+
+
+    /**
+     * @notes 校验验证码
+     * @param $code
+     * @param $rule
+     * @param $data
+     * @return bool|string
+     * @author Tab
+     * @date 2021/8/25 15:43
+     */
+    public function checkCode($code, $rule, $data)
+    {
+        $smsDriver = new SmsDriver();
+        $result = $smsDriver->verify($data['account'], $code, NoticeEnum::LOGIN_CAPTCHA);
+        if ($result) {
+            return true;
+        }
+        return '验证码错误';
+    }
+}

+ 38 - 0
app/workerapi/validate/RegisterValidate.php

@@ -0,0 +1,38 @@
+<?php
+/**
+ * @author 林海涛
+ * @date ${DATA}
+ */
+namespace app\workerapi\validate;
+
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\validate\BaseValidate;
+
+/**
+ * 注册验证器
+ * Class RegisterValidate
+ * @package app\api\validate
+ */
+class RegisterValidate extends BaseValidate
+{
+    protected $rule = [
+        'other_exp_type' => 'require',
+        'vehicle_type' => 'require',
+        'name' => 'require',
+        'age' => 'require|number|between:18,55',
+        'mobile' => 'require|mobile|unique:' . MasterWorkerRegister::class,
+        'code' => 'require'
+    ];
+
+    protected $message = [
+        'other_exp_type.require' => '其他经验必填',
+        'vehicle_type.require' => '交通工具必填',
+        'name.require' => '账号必填',
+        'age.require' => '年龄必填',
+        'age.number' => '年龄必须为数字',
+        'age.between' => '年龄只能在18-55之间',
+        'mobile.unique' => '手机号重复',
+        'mobile.mobile' => '请输入正确手机号',
+        'code.require' => '请输入验证码',
+    ];
+}