Răsfoiți Sursa

师傅端增加我的客服,及后台处理

林海涛 1 an în urmă
părinte
comite
24656a549d

+ 108 - 0
app/adminapi/controller/master_worker/MasterWorkerController.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;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\master_worker\MasterWorkerLists;
+use app\adminapi\logic\master_worker\MasterWorkerLogic;
+use app\adminapi\validate\master_worker\MasterWorkerValidate;
+
+
+/**
+ * MasterWorker控制器
+ * Class MasterWorkerController
+ * @package app\adminapi\controller\master_worker
+ */
+class MasterWorkerController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerValidate())->post()->goCheck('add');
+        $result = MasterWorkerLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerValidate())->post()->goCheck('edit');
+        $result = MasterWorkerLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerValidate())->post()->goCheck('delete');
+        MasterWorkerLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerValidate())->goCheck('detail');
+        $result = MasterWorkerLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 109 - 0
app/adminapi/controller/master_worker_customer/MasterWorkerCustomerController.php

@@ -0,0 +1,109 @@
+<?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_customer;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\master_worker_customer\MasterWorkerCustomerLists;
+use app\adminapi\logic\master_worker_customer\MasterWorkerCustomerLogic;
+use app\adminapi\validate\master_worker_customer\MasterWorkerCustomerValidate;
+
+
+/**
+ * MasterWorkerCustomer控制器
+ * Class MasterWorkerCustomerController
+ * @package app\adminapi\controller\master_worker_customer
+ */
+class MasterWorkerCustomerController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerCustomerLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerCustomerValidate())->post()->goCheck('add');
+        $result = MasterWorkerCustomerLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerCustomerLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerCustomerValidate())->post()->goCheck('edit');
+        $params['deal_user_id'] = $this->adminId;
+        $result = MasterWorkerCustomerLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerCustomerLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerCustomerValidate())->post()->goCheck('delete');
+        MasterWorkerCustomerLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerCustomerValidate())->goCheck('detail');
+        $result = MasterWorkerCustomerLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

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

@@ -38,7 +38,7 @@ class HomeServiceLists extends BaseAdminDataLists implements ListsSearchInterfac
     public function setSearch(): array
     {
         return [
-            '=' => ['name',],
+            '=' => ['name'],
         ];
     }
 

+ 77 - 0
app/adminapi/lists/master_worker/MasterWorkerLists.php

@@ -0,0 +1,77 @@
+<?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;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\MasterWorker;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorker列表
+ * Class MasterWorkerLists
+ * @package app\adminapi\listsmaster_worker
+ */
+class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['sn', 'real_name', 'nickname', 'account', 'password', 'mobile', 'sex', 'channel', 'is_disable', 'is_new_user', 'create_time', 'update_time'],

+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function lists(): array
+    {
+        return MasterWorker::where($this->searchWhere)
+            ->field(['id', 'sn', 'avatar', 'real_avatar', 'real_name', 'nickname', 'account', 'password', 'mobile', 'sex', 'channel', 'is_disable', 'login_ip', 'login_time', 'is_new_user', 'estimate_money', 'user_money', 'earnest_money', 'exp'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function count(): int
+    {
+        return MasterWorker::where($this->searchWhere)->count();
+    }
+
+}

+ 90 - 0
app/adminapi/lists/master_worker_customer/MasterWorkerCustomerLists.php

@@ -0,0 +1,90 @@
+<?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_customer;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker_customer\MasterWorkerCustomer;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorkerCustomer列表
+ * Class MasterWorkerCustomerLists
+ * @package app\adminapi\listsmaster_worker_customer
+ */
+class MasterWorkerCustomerLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['user_id',  'deal_user_id', 'status', 'create_time', 'update_time'],
+            '%like%' => ['name', 'mobile'],
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function lists(): array
+    {
+        return MasterWorkerCustomer::with(['admin','masterWorker'])
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->field(['id','user_id','deal_user_id','name', 'mobile', 'problem', 'status', 'remark'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+    public function queryWhere(){
+        $where = [];
+        // 用户
+        if (isset($this->params['user_id']) && is_array($this->params['user_id'])) {
+            $where[] = ['user_id', 'in',$this->params['user_id']];
+        }
+        if (isset($this->params['deal_user_id']) && is_array($this->params['deal_user_id'])) {
+            $where[] = ['deal_user_id', 'in',$this->params['deal_user_id']];
+        }
+        return $where;
+    }
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function count(): int
+    {
+        return MasterWorkerCustomer::where($this->searchWhere)->where($this->queryWhere())->count();
+    }
+}

+ 140 - 0
app/adminapi/logic/master_worker/MasterWorkerLogic.php

@@ -0,0 +1,140 @@
+<?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;
+
+
+use app\common\model\master_worker\MasterWorker;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorker逻辑
+ * Class MasterWorkerLogic
+ * @package app\adminapi\logic\master_worker
+ */
+class MasterWorkerLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorker::create([
+                'sn' => $params['sn'],
+                'avatar' => $params['avatar'],
+                'real_avatar' => $params['real_avatar'],
+                'real_name' => $params['real_name'],
+                'nickname' => $params['nickname'],
+                'account' => $params['account'],
+                'password' => $params['password'],
+                'mobile' => $params['mobile'],
+                'sex' => $params['sex'],
+                'channel' => $params['channel'],
+                'is_disable' => $params['is_disable'],
+                'login_ip' => $params['login_ip'],
+                'login_time' => $params['login_time'],
+                'is_new_user' => $params['is_new_user'],
+                'estimate_money' => $params['estimate_money'],
+                'user_money' => $params['user_money'],
+                'earnest_money' => $params['earnest_money'],
+                'exp' => $params['exp'],
+            ]);
+
+            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/10 18:17
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorker::where('id', $params['id'])->update([
+                'sn' => $params['sn'],
+                'avatar' => $params['avatar'],
+                'real_avatar' => $params['real_avatar'],
+                'real_name' => $params['real_name'],
+                'nickname' => $params['nickname'],
+                'account' => $params['account'],
+                'password' => $params['password'],
+                'mobile' => $params['mobile'],
+                'sex' => $params['sex'],
+                'channel' => $params['channel'],
+                'is_disable' => $params['is_disable'],
+                'login_ip' => $params['login_ip'],
+                'login_time' => $params['login_time'],
+                'is_new_user' => $params['is_new_user'],
+                'estimate_money' => $params['estimate_money'],
+                'user_money' => $params['user_money'],
+                'earnest_money' => $params['earnest_money'],
+                'exp' => $params['exp'],
+            ]);
+
+            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/10 18:17
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorker::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public static function detail($params): array
+    {
+        return MasterWorker::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 118 - 0
app/adminapi/logic/master_worker_customer/MasterWorkerCustomerLogic.php

@@ -0,0 +1,118 @@
+<?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_customer;
+
+
+use app\common\model\master_worker_customer\MasterWorkerCustomer;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerCustomer逻辑
+ * Class MasterWorkerCustomerLogic
+ * @package app\adminapi\logic\master_worker_customer
+ */
+class MasterWorkerCustomerLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerCustomer::create([
+                'user_id' => $params['user_id'],
+                'name' => $params['name'],
+                'mobile' => $params['mobile'],
+                'problem' => $params['problem'],
+                'deal_user_id' => $params['deal_user_id'],
+                'status' => $params['status'],
+                'remark' => $params['remark'],
+            ]);
+
+            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/10 17:34
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerCustomer::where('id', $params['id'])->update([
+                'user_id' => $params['user_id'],
+                'name' => $params['name'],
+                'mobile' => $params['mobile'],
+                'problem' => $params['problem'],
+                'deal_user_id' => $params['deal_user_id'],
+                'status' => $params['status'],
+                'remark' => $params['remark'],
+            ]);
+
+            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/10 17:34
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerCustomer::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerCustomer::with(['masterWorker'])->findOrEmpty($params['id'])->toArray();
+    }
+}

+ 124 - 0
app/adminapi/validate/master_worker/MasterWorkerValidate.php

@@ -0,0 +1,124 @@
+<?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;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorker验证器
+ * Class MasterWorkerValidate
+ * @package app\adminapi\validate\master_worker
+ */
+class MasterWorkerValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'sn' => 'require',
+        'avatar' => 'require',
+        'real_avatar' => 'require',
+        'real_name' => 'require',
+        'nickname' => 'require',
+        'account' => 'require',
+        'password' => 'require',
+        'mobile' => 'require',
+        'sex' => 'require',
+        'channel' => 'require',
+        'is_disable' => 'require',
+        'login_ip' => 'require',
+        'login_time' => 'require',
+        'is_new_user' => 'require',
+        'exp' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'sn' => '编号',
+        'avatar' => '头像',
+        'real_avatar' => '真实头像',
+        'real_name' => '真实姓名',
+        'nickname' => '用户昵称',
+        'account' => '师傅账号',
+        'password' => '师傅密码',
+        'mobile' => '师傅电话',
+        'sex' => '师傅性别',
+        'channel' => '注册渠道',
+        'is_disable' => '是否禁用',
+        'login_ip' => '最后登录IP',
+        'login_time' => '最后登录时间',
+        'is_new_user' => '是否是新注册用户: [1-是, 0-否]',
+        'exp' => '经验值',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['sn','avatar','real_avatar','real_name','nickname','account','password','mobile','sex','channel','is_disable','login_ip','login_time','is_new_user','exp']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','sn','avatar','real_avatar','real_name','nickname','account','password','mobile','sex','channel','is_disable','login_ip','login_time','is_new_user','exp']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 100 - 0
app/adminapi/validate/master_worker_customer/MasterWorkerCustomerValidate.php

@@ -0,0 +1,100 @@
+<?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_customer;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerCustomer验证器
+ * Class MasterWorkerCustomerValidate
+ * @package app\adminapi\validate\master_worker_customer
+ */
+class MasterWorkerCustomerValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'user_id' => 'require',
+        'name' => 'require',
+        'mobile' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'user_id' => '用户id',
+        'name' => '姓名',
+        'mobile' => '手机号',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerCustomerValidate
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['user_id','name','mobile']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerCustomerValidate
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','user_id','name','mobile']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerCustomerValidate
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerCustomerValidate
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 1 - 0
app/common/enum/FileEnum.php

@@ -26,6 +26,7 @@ class FileEnum
     // 图片来源
     const SOURCE_ADMIN = 0;  // 后台
     const SOURCE_USER = 1;   // 用户
+    const SOURCE_WORKER=2;   //师傅
 
 
 }

+ 12 - 0
app/common/model/master_worker/MasterWorkerInfo.php

@@ -0,0 +1,12 @@
+<?php
+namespace app\common\model\master_worker;
+use app\common\model\BaseModel;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/10 下午4:33
+ */
+class MasterWorkerInfo extends BaseModel
+{
+    protected $name = 'master_worker_info';
+}

+ 43 - 0
app/common/model/master_worker_customer/MasterWorkerCustomer.php

@@ -0,0 +1,43 @@
+<?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_customer;
+
+
+use app\common\model\auth\Admin;
+use app\common\model\BaseModel;
+use app\common\model\master_worker\MasterWorker;
+
+
+/**
+ * MasterWorkerCustomer模型
+ * Class MasterWorkerCustomer
+ * @package app\common\model\master_worker_customer
+ */
+class MasterWorkerCustomer extends BaseModel
+{
+    
+    protected $name = 'master_worker_customer';
+    
+
+    public function admin()
+    {
+        return $this->hasOne(Admin::class,'id','deal_user_id')->field('id,name');
+    }
+
+    public function masterWorker()
+    {
+        return $this->hasOne(MasterWorker::class,'id','user_id')->field('id,nickname');
+    }
+}

+ 40 - 5
app/workerapi/controller/MasterWokerController.php

@@ -2,7 +2,10 @@
 
 namespace app\workerapi\controller;
 
-use app\workerapi\logic\MasterWokerLogic;
+use app\workerapi\logic\LoginLogic;
+use app\workerapi\logic\MasterWorkerInfoLogic;
+use app\workerapi\logic\MasterWorkerLogic;
+use app\workerapi\validate\MasterWokerInfoValidate;
 use app\workerapi\validate\MasterWokerValidate;
 
 class MasterWokerController extends BaseApiController
@@ -17,11 +20,11 @@ class MasterWokerController extends BaseApiController
     public function changePassword()
     {
         $params = (new MasterWokerValidate())->post()->goCheck('changePassword');
-        $result = MasterWokerLogic::changePassword($params, $this->userId);
+        $result = MasterWorkerLogic::changePassword($params, $this->userId);
         if (true === $result) {
             return $this->success('操作成功', [], 1, 1);
         }
-        return $this->fail(MasterWokerLogic::getError());
+        return $this->fail(MasterWorkerLogic::getError());
     }
 
     /**
@@ -33,11 +36,43 @@ class MasterWokerController extends BaseApiController
     public function changeMobile()
     {
         $params = (new MasterWokerValidate())->post()->goCheck('changeMobile');
-        $result = MasterWokerLogic::changeMobile($params, $this->userId);
+        $result = MasterWorkerLogic::changeMobile($params, $this->userId);
         if (true === $result) {
             return $this->success('操作成功', [], 1, 1);
         }
-        return $this->fail(MasterWokerLogic::getError());
+        return $this->fail(MasterWorkerLogic::getError());
     }
 
+    /**
+     * 更改身份证信息
+     * @return \think\response\Json
+     * @author 林海涛
+     * @date 2024/7/10 下午4:46
+     */
+    public function changeIdCard()
+    {
+        $params =  (new MasterWokerInfoValidate())->post()->goCheck('changeIdCard');
+        $result = MasterWorkerInfoLogic::changeIdCard($params, $this->userId);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerInfoLogic::getError());
+    }
+
+
+    /**
+     * 注销账号
+     * @return \think\response\Json
+     * @author 林海涛
+     * @date 2024/7/10 下午4:46
+     */
+    public function logOff()
+    {
+        $result = MasterWorkerLogic::logOff($this->userId);
+        if (true === $result) {
+            LoginLogic::logout($this->userInfo);
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerInfoLogic::getError());
+    }
 }

+ 19 - 0
app/workerapi/controller/MasterWorkerCustomerController.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace app\workerapi\controller;
+
+use app\workerapi\logic\MasterWorkerCustomerLogic;
+use app\workerapi\validate\MasterWorkerCustomerValidate;
+
+class MasterWorkerCustomerController extends BaseApiController
+{
+    public function submitCustomerProblem()
+    {
+        $params =  (new MasterWorkerCustomerValidate())->post()->goCheck('changeIdCard');
+        $result = MasterWorkerCustomerLogic::submitCustomerProblem($params, $this->userId);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerCustomerLogic::getError());
+    }
+}

+ 21 - 0
app/workerapi/controller/UploadController.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace app\workerapi\controller;
+
+use app\workerapi\controller\BaseApiController;
+use app\common\enum\FileEnum;
+use Exception;
+use app\common\service\UploadService;
+
+class UploadController  extends BaseApiController
+{
+    public function image()
+    {
+        try {
+            $result = UploadService::image(2, $this->userId,FileEnum::SOURCE_WORKER);
+            return $this->success('上传成功', $result);
+        } catch (Exception $e) {
+            return $this->fail($e->getMessage());
+        }
+    }
+}

+ 27 - 0
app/workerapi/logic/MasterWorkerCustomerLogic.php

@@ -0,0 +1,27 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker_customer\MasterWorkerCustomer;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/10 下午5:46
+ */
+class MasterWorkerCustomerLogic extends BaseLogic
+{
+    public static function submitCustomerProblem($params, $userId)
+    {
+        try {
+            MasterWorkerCustomer::create([
+                'user_id' => $userId,
+                'name' => $params['name'],
+                'mobile' => $params['mobile'],
+                'problem' => $params['problem'],
+            ]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

+ 34 - 0
app/workerapi/logic/MasterWorkerInfoLogic.php

@@ -0,0 +1,34 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker\MasterWorkerInfo;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/10 下午4:29
+ */
+
+class MasterWorkerInfoLogic extends BaseLogic
+{
+
+    public static function changeIdCard($params,$userId)
+    {
+        try{
+            $where = [['user_id', '=', $userId]];
+            $userInfo = MasterWorkerInfo::where($where)->findOrEmpty();
+            if (!$userInfo->isEmpty()) {
+                $userInfo = new MasterWorkerInfo();
+                $userInfo->user_id = $userId;
+            }
+            $userInfo->real_name = $params['real_name'];
+            $userInfo->id_card = $params['id_card'];
+            $userInfo->id_card_front_img = $params['id_card_front_img'];
+            $userInfo->id_card_opposite_img = $params['id_card_opposite_img'];
+            $userInfo->save();
+            return true;
+        } catch(\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

+ 20 - 4
app/workerapi/logic/MasterWokerLogic.php → app/workerapi/logic/MasterWorkerLogic.php

@@ -1,5 +1,6 @@
 <?php
 namespace app\workerapi\logic;
+use app\common\enum\YesNoEnum;
 use app\common\logic\BaseLogic;
 use app\common\model\master_worker\MasterWorker;
 use think\facade\Config;
@@ -8,7 +9,7 @@ use think\facade\Config;
  * @author 林海涛
  * @date 2024/7/10 下午1:45
  */
-class MasterWokerLogic extends  BaseLogic
+class MasterWorkerLogic extends  BaseLogic
 {
     public static function changePassword(array $params, int $userId)
     {
@@ -43,7 +44,6 @@ class MasterWokerLogic extends  BaseLogic
     public static function changeMobile(array $params, int $userId)
     {
         try {
-
             $user = MasterWorker::findOrEmpty($userId);
             if ($user->isEmpty()) {
                 throw new \Exception('用户不存在');
@@ -52,8 +52,8 @@ class MasterWokerLogic extends  BaseLogic
                 throw new \Exception('输入的手机号相同');
             }
             $where = [['mobile', '=', $params['mobile']]];
-            $exitUser = MasterWorker::where($where)->findOrEmpty();
-            if (!$exitUser->isEmpty()) {
+            $existUser = MasterWorker::where($where)->findOrEmpty();
+            if (!$existUser->isEmpty()) {
                 throw new \Exception('该手机号已被使用');
             }
             $user->password = $params['mobile'];
@@ -64,4 +64,20 @@ class MasterWokerLogic extends  BaseLogic
             return false;
         }
     }
+
+    public static function logOff(int $userId)
+    {
+        try {
+            $user = MasterWorker::findOrEmpty($userId);
+            if ($user->isEmpty()) {
+                throw new \Exception('用户不存在');
+            }
+            $user->is_disable = YesNoEnum::YES;
+            $user->save();
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
 }

+ 79 - 0
app/workerapi/validate/MasterWokerInfoValidate.php

@@ -0,0 +1,79 @@
+<?php
+namespace app\workerapi\validate;
+use app\common\validate\BaseValidate;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/10 下午3:41
+ */
+class MasterWokerInfoValidate  extends BaseValidate
+{
+    protected $rule = [
+        'real_name' => 'require',
+        'id_card' => 'require|checkIdCard',
+        'id_card_front_img' => 'require',
+        'id_card_opposite_img' => 'require',
+    ];
+
+    protected $message = [
+        'real_name.require' => '请输入真实姓名',
+        'id_card.require' => '请输入身份证号',
+        'id_card.checkIdCard' => '身份证格式有误',
+        'id_card_front_img.require' => '请上传身份证正面照',
+        'id_card_opposite_img.require' => '请上传身份证反面照',
+
+    ];
+
+    public function checkIdCard($idcard)
+    {
+        if(empty($idcard)){
+            return false;
+        }else{
+            $idcard = strtoupper($idcard); # 如果是小写x,转化为大写X
+            if(strlen($idcard) != 18 && strlen($idcard) != 15){
+                return false;
+            }
+            # 如果是15位身份证,则转化为18位
+            if(strlen($idcard) == 15){
+                # 如果身份证顺序码是996 997 998 999,这些是为百岁以上老人的特殊编码
+                if (array_search(substr($idcard, 12, 3), array('996', '997', '998', '999')) !== false) {
+                    $idcard = substr($idcard, 0, 6) . '18' . substr($idcard, 6, 9);
+                } else {
+                    $idcard = substr($idcard, 0, 6) . '19' . substr($idcard, 6, 9);
+                }
+                # 加权因子
+                $factor = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
+                # 校验码对应值
+                $code = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
+                $checksum = 0;
+                for ($i = 0; $i < strlen($idcard); $i++) {
+                    $checksum += substr($idcard, $i, 1) * $factor[$i];
+                }
+                $idcard = $idcard . $code[$checksum % 11];
+            }
+            # 验证身份证开始
+            $IDCardBody = substr($idcard, 0, 17); # 身份证主体
+            $IDCardCode = strtoupper(substr($idcard, 17, 1)); # 身份证最后一位的验证码
+
+            # 加权因子
+            $factor = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
+            # 校验码对应值
+            $code = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
+            $checksum = 0;
+            for ($i = 0; $i < strlen($IDCardBody); $i++) {
+                $checksum += substr($IDCardBody, $i, 1) * $factor[$i];
+            }
+            $validateIdcard = $code[$checksum % 11];    # 判断身份证是否合理
+            if($validateIdcard != $IDCardCode){
+                return false;
+            }else{
+                return true;
+            }
+        }
+    }
+
+    public function sceneChangeIdCard()
+    {
+         return $this->only(['real_name', 'id_card','id_card_front_img','id_card_opposite_img']);
+    }
+}

+ 23 - 0
app/workerapi/validate/MasterWorkerCustomerValidate.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ * @author 林海涛
+ * @date 2024/7/10 下午5:20
+ */
+
+namespace app\workerapi\validate;
+use app\common\validate\BaseValidate;
+class MasterWorkerCustomerValidate extends BaseValidate
+{
+    protected $rule = [
+        'name' => 'require',
+        'mobile' => 'require|mobile',
+        'problem' => 'require',
+    ];
+
+    protected $message = [
+        'name.require' => '请输入真实姓名',
+        'mobile.require' => '请输入手机号',
+        'mobile.mobile' => '手机号格式有误',
+        'problem.require' => '请输入要咨询的问题',
+    ];
+}