Просмотр исходного кода

增加师傅余额明细,及修改师傅相关的user_id为worker_id

林海涛 1 год назад
Родитель
Сommit
cb48c03aef
26 измененных файлов с 828 добавлено и 126 удалено
  1. 108 0
      app/adminapi/controller/finance/MasterWorkerCaseOutLogController.php
  2. 1 1
      app/adminapi/controller/master_worker_customer/MasterWorkerCustomerController.php
  3. 93 0
      app/adminapi/lists/finance/MasterWorkerCaseOutLogLists.php
  4. 2 2
      app/adminapi/lists/master_worker/MasterWorkerLists.php
  5. 5 5
      app/adminapi/lists/master_worker_customer/MasterWorkerCustomerLists.php
  6. 113 0
      app/adminapi/logic/finance/MasterWorkerCaseOutLogLogic.php
  7. 4 4
      app/adminapi/logic/master_worker_customer/MasterWorkerCustomerLogic.php
  8. 1 1
      app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php
  9. 4 4
      app/adminapi/validate/LoginValidate.php
  10. 105 0
      app/adminapi/validate/finance/MasterWorkerCaseOutLogValidate.php
  11. 101 99
      app/adminapi/validate/master_worker_customer/MasterWorkerCustomerValidate.php
  12. 44 0
      app/common/model/finance/MasterWorkerCaseOutLog.php
  13. 1 1
      app/common/model/master_worker/MasterWorker.php
  14. 5 0
      app/common/model/master_worker/MasterWorkerAccountLog.php
  15. 2 2
      app/common/model/master_worker_customer/MasterWorkerCustomer.php
  16. 1 1
      app/common/model/master_worker_message/MasterWorkerMessage.php
  17. 40 0
      app/workerapi/controller/AccountController.php
  18. 45 0
      app/workerapi/lists/MasterWorkerAccountLogLists.php
  19. 40 0
      app/workerapi/lists/MasterWorkerCaseOutLogLists.php
  20. 84 0
      app/workerapi/logic/AccountLogic.php
  21. 1 1
      app/workerapi/logic/MasterWorkerCustomerLogic.php
  22. 1 1
      app/workerapi/logic/MasterWorkerInfoLogic.php
  23. 2 1
      app/workerapi/logic/MasterWorkerLogic.php
  24. 2 2
      app/workerapi/logic/MasterWorkerMessageLogic.php
  25. 22 0
      app/workerapi/validate/AccountLogValidate.php
  26. 1 1
      app/workerapi/validate/BankAccountValidate.php

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

+ 1 - 1
app/adminapi/controller/master_worker_customer/MasterWorkerCustomerController.php

@@ -69,7 +69,7 @@ class MasterWorkerCustomerController extends BaseAdminController
     public function edit()
     {
         $params = (new MasterWorkerCustomerValidate())->post()->goCheck('edit');
-        $params['deal_user_id'] = $this->adminId;
+        $params['admin_id'] = $this->adminId;
         $result = MasterWorkerCustomerLogic::edit($params);
         if (true === $result) {
             return $this->success('编辑成功', [], 1, 1);

+ 93 - 0
app/adminapi/lists/finance/MasterWorkerCaseOutLogLists.php

@@ -0,0 +1,93 @@
+<?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\finance;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\finance\MasterWorkerCaseOutLog;
+use app\common\lists\ListsSearchInterface;
+use think\db\Query;
+
+
+/**
+ * MasterWorkerCaseOutLog列表
+ * Class MasterWorkerCaseOutLogLists
+ * @package app\adminapi\listsfinance
+ */
+class MasterWorkerCaseOutLogLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['sn', 'worker_id', 'review_status'],
+            '%like%' => ['sn'],
+        ];
+    }
+    public function querySearch():array
+    {
+        $data = [];
+        if(isset($this->params['min_change_amount']) && is_numeric($this->params['min_change_amount'])){
+            $where[] =['change_amount','>=',$this->params['min_change_amount']];
+        }
+        if(isset($this->params['max_change_amount']) && is_numeric($this->params['max_change_amount'])){
+            $where[] =['change_amount','<=',$this->params['max_change_amount']];
+        }
+        return $data;
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function lists(): array
+    {
+        return MasterWorkerCaseOutLog::where($this->searchWhere)
+            ->with(['masterWorker'=>function(Query $query){
+                $query->field('id,nickname,worker_number');
+            }])
+            ->where($this->querySearch())
+            ->field(['id', 'sn', 'worker_id', 'change_amount', 'review_status', 'remark'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function count(): int
+    {
+        return MasterWorkerCaseOutLog::where($this->searchWhere)->where($this->querySearch())->count();
+    }
+
+}

+ 2 - 2
app/adminapi/lists/master_worker/MasterWorkerLists.php

@@ -81,7 +81,7 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function lists(): array
     {
          return MasterWorker::alias('mw')
-            ->join('master_worker_register mwr', 'mwr.master_worker_id = mw.id')
+            ->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
              ->leftJoin('service_work sw','sw.master_worker_id = mw.id and sw.service_status !=4')
             ->where($this->searchWhere)
             ->where($this->queryWhere())
@@ -109,7 +109,7 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function count(): int
     {
         return MasterWorker::alias('mw')
-            ->join('master_worker_register mwr', 'mwr.master_worker_id = mw.id')
+            ->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
             ->leftJoin('service_work sw','sw.master_worker_id = mw.id and sw.service_status !=4')
             ->field([
                 'mw.*',

+ 5 - 5
app/adminapi/lists/master_worker_customer/MasterWorkerCustomerLists.php

@@ -38,7 +38,7 @@ class MasterWorkerCustomerLists extends BaseAdminDataLists implements ListsSearc
     public function setSearch(): array
     {
         return [
-            '=' => ['user_id',  'deal_user_id', 'status', 'create_time', 'update_time'],
+            '=' => ['worker_id',  'admin_id', 'status', 'create_time', 'update_time'],
             '%like%' => ['name', 'mobile'],
         ];
     }
@@ -58,7 +58,7 @@ class MasterWorkerCustomerLists extends BaseAdminDataLists implements ListsSearc
         return MasterWorkerCustomer::with(['admin','masterWorker'])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
-            ->field(['id','user_id','deal_user_id','name', 'mobile', 'problem', 'status', 'remark'])
+            ->field(['id','worker_id','admin_id','name', 'mobile', 'problem', 'status', 'remark'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()
@@ -68,11 +68,11 @@ class MasterWorkerCustomerLists extends BaseAdminDataLists implements ListsSearc
     public function queryWhere(){
         $where = [];
         // 用户
-        if (isset($this->params['user_id']) && is_array($this->params['user_id'])) {
+        if (isset($this->params['worker_id']) && is_array($this->params['worker_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']];
+        if (isset($this->params['admin_id']) && is_array($this->params['admin_id'])) {
+            $where[] = ['admin_id', 'in',$this->params['admin_id']];
         }
         return $where;
     }

+ 113 - 0
app/adminapi/logic/finance/MasterWorkerCaseOutLogLogic.php

@@ -0,0 +1,113 @@
+<?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\finance;
+
+
+use app\common\model\finance\MasterWorkerCaseOutLog;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerCaseOutLog逻辑
+ * Class MasterWorkerCaseOutLogLogic
+ * @package app\adminapi\logic\finance
+ */
+class MasterWorkerCaseOutLogLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerCaseOutLog::create([
+                'sn' => generate_sn(MasterWorkerCaseOutLog::class,'sn'),
+                'worker_id' => $params['worker_id'],
+                'action' => $params['action'],
+                'change_amount' => $params['change_amount'],
+                'review_status' => $params['review_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/23 09:30
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerCaseOutLog::where('sn', $params['sn'])->update([
+                'review_status' => $params['review_status'],
+                'remark' => $params['remark'],
+                'admin_id' => $params['admin_id'],
+            ]);
+
+            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/23 09:30
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerCaseOutLog::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerCaseOutLog::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 4 - 4
app/adminapi/logic/master_worker_customer/MasterWorkerCustomerLogic.php

@@ -41,11 +41,11 @@ class MasterWorkerCustomerLogic extends BaseLogic
         Db::startTrans();
         try {
             MasterWorkerCustomer::create([
-                'user_id' => $params['user_id'],
+                'worker_id' => $params['worker_id'],
                 'name' => $params['name'],
                 'mobile' => $params['mobile'],
                 'problem' => $params['problem'],
-                'deal_user_id' => $params['deal_user_id'],
+                'admin_id' => $params['admin_id'],
                 'status' => $params['status'],
                 'remark' => $params['remark'],
             ]);
@@ -72,11 +72,11 @@ class MasterWorkerCustomerLogic extends BaseLogic
         Db::startTrans();
         try {
             MasterWorkerCustomer::where('id', $params['id'])->update([
-                'user_id' => $params['user_id'],
+                'worker_id' => $params['worker_id'],
                 'name' => $params['name'],
                 'mobile' => $params['mobile'],
                 'problem' => $params['problem'],
-                'deal_user_id' => $params['deal_user_id'],
+                'admin_id' => $params['admin_id'],
                 'status' => $params['status'],
                 'remark' => $params['remark'],
             ]);

+ 1 - 1
app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php

@@ -88,7 +88,7 @@ class MasterWorkerRegisterLogic extends BaseLogic
 
             //审批通过逻辑处理
             if($params['status'] == 1){
-                $updata['master_worker_id'] = self::createMasterWorker($params);
+                $updata['worker_id'] = self::createMasterWorker($params);
             }
             MasterWorkerRegister::where('id', $params['id'])->update($updata);
 

+ 4 - 4
app/adminapi/validate/LoginValidate.php

@@ -91,10 +91,10 @@ class LoginValidate extends BaseValidate
         }
 
         $passwordSalt = Config::get('project.unique_identification');
-//        if ($adminInfo['password'] !== create_password($password, $passwordSalt)) {
-//            $adminAccountSafeCache->record();
-//            return '密码错误';
-//        }
+        if ($adminInfo['password'] !== create_password($password, $passwordSalt)) {
+            $adminAccountSafeCache->record();
+            return '密码错误';
+        }
 
         $adminAccountSafeCache->relieve();
         return true;

+ 105 - 0
app/adminapi/validate/finance/MasterWorkerCaseOutLogValidate.php

@@ -0,0 +1,105 @@
+<?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\finance;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerCaseOutLog验证器
+ * Class MasterWorkerCaseOutLogValidate
+ * @package app\adminapi\validate\finance
+ */
+class MasterWorkerCaseOutLogValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'sn' => 'require',
+        'worker_id' => 'require',
+        'action' => 'require',
+        'change_amount' => 'require',
+        'review_status' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'sn' => 'sn',
+        'worker_id' => '用户id',
+        'change_amount' => '变动数量',
+        'review_status' => '审批状态',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerCaseOutLogValidate
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['worker_id','change_amount']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerCaseOutLogValidate
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['sn','review_status']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerCaseOutLogValidate
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerCaseOutLogValidate
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 101 - 99
app/adminapi/validate/master_worker_customer/MasterWorkerCustomerValidate.php

@@ -1,100 +1,102 @@
-<?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']);
-    }
-
+<?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',
+        'worker_id' => 'require',
+        'name' => 'require',
+        'mobile' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'worker_id' => '师傅id',
+        'name' => '姓名',
+        'mobile' => '手机号',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerCustomerValidate
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['worker_id','name','mobile']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerCustomerValidate
+     * @author likeadmin
+     * @date 2024/07/10 17:34
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','worker_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']);
+    }
+
 }

+ 44 - 0
app/common/model/finance/MasterWorkerCaseOutLog.php

@@ -0,0 +1,44 @@
+<?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\finance;
+
+
+use app\common\model\BaseModel;
+use app\common\model\master_worker\MasterWorker;
+use think\model\concern\SoftDelete;
+
+
+/**
+ * MasterWorkerCaseOutLog模型
+ * Class MasterWorkerCaseOutLog
+ * @package app\common\model\finance
+ */
+class MasterWorkerCaseOutLog extends BaseModel
+{
+    use SoftDelete;
+    protected $name = 'master_worker_case_out_log';
+    protected $deleteTime = 'delete_time';
+
+    public function masterWorker()
+    {
+        return $this->hasOne(MasterWorker::class,'id','worker_id');
+    }
+
+    public function getReviewStatusTextAttr($value,$data)
+    {
+        $status = [0=>'审批中',1=>'审批通过',2=>'审批驳回'];
+        return $status[$data['review_status']];
+    }
+}

+ 1 - 1
app/common/model/master_worker/MasterWorker.php

@@ -32,7 +32,7 @@ class MasterWorker extends BaseModel
 
     public function workerRegister()
     {
-        return $this->hasOne(MasterWorkerRegister::class, 'master_worker_id', 'id');
+        return $this->hasOne(MasterWorkerRegister::class, 'worker_id', 'id');
     }
 
 }

+ 5 - 0
app/common/model/master_worker/MasterWorkerAccountLog.php

@@ -16,4 +16,9 @@ class MasterWorkerAccountLog extends BaseModel
     use SoftDelete;
 
     protected $deleteTime = 'delete_time';
+    public function getActionTextAttr($value,$data)
+    {
+        $status = [1=>'+',2=>'-'];
+        return $status[$data['action']];
+    }
 }

+ 2 - 2
app/common/model/master_worker_customer/MasterWorkerCustomer.php

@@ -33,11 +33,11 @@ class MasterWorkerCustomer extends BaseModel
 
     public function admin()
     {
-        return $this->hasOne(Admin::class,'id','deal_user_id')->field('id,name');
+        return $this->hasOne(Admin::class,'id','admin_id')->field('id,name');
     }
 
     public function masterWorker()
     {
-        return $this->hasOne(MasterWorker::class,'id','user_id')->field('id,nickname');
+        return $this->hasOne(MasterWorker::class,'id','worker_id')->field('id,nickname');
     }
 }

+ 1 - 1
app/common/model/master_worker_message/MasterWorkerMessage.php

@@ -13,6 +13,6 @@ class MasterWorkerMessage extends BaseModel
 
     public function masterWorker()
     {
-        return $this->hasOne(MasterWorker::class,'id','user_id')->field('id,nickname');
+        return $this->hasOne(MasterWorker::class,'id','worker_id')->field('id,nickname');
     }
 }

+ 40 - 0
app/workerapi/controller/AccountController.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\workerapi\controller;
+
+use app\workerapi\lists\MasterWorkerAccountLogLists;
+use app\workerapi\lists\MasterWorkerCaseOutLogLists;
+use app\workerapi\logic\AccountLogic;
+use app\workerapi\validate\AccountLogValidate;
+
+class AccountController extends BaseApiController
+{
+    public function totalAssets()
+    {
+        $result = AccountLogic::totalAssets(['worker_id' => $this->userId]);
+        if (false === $result) {
+            return $this->fail(AccountLogic::getError());
+        }
+        return $this->success('操作成功',$result, 1, 1);
+    }
+
+    public function accountLogLists()
+    {
+        return $this->dataLists(new MasterWorkerAccountLogLists());
+    }
+
+    public function caseOutLists()
+    {
+        return $this->dataLists(new MasterWorkerCaseOutLogLists());
+    }
+
+    public function monthAccountWithCaseOutTotal()
+    {
+        $params = (new AccountLogValidate())->get()->goCheck('monthAccountWithCaseOutTotal',['worker_id'=>$this->userId]);
+        $result = AccountLogic::monthAccountWithCaseOutTotal($params);
+        if (false === $result) {
+            return $this->fail(AccountLogic::getError());
+        }
+        return $this->success('操作成功',$result, 1, 1);
+    }
+}

+ 45 - 0
app/workerapi/lists/MasterWorkerAccountLogLists.php

@@ -0,0 +1,45 @@
+<?php
+namespace app\workerapi\lists;
+
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/23 下午2:16
+ */
+class MasterWorkerAccountLogLists extends BaseWorkerDataLists
+{
+    public function queryWhere()
+    {
+        $where = [];
+        if(isset($this->params['month'])){
+            $firstDay =date("Y-m-d 00:00:00", strtotime("first day of {$this->params['month']}"));
+            $lastDay = date("Y-m-d 23:59:59", strtotime("{$this->params['month']} +1 month -1 day"));
+            $firstTime = strtotime($firstDay);
+            $lastTime = strtotime($lastDay);
+            $where[] = ['create_time','between',[$firstTime,$lastTime]];
+        }
+        $where[] = ['worker_id', '=', $this->userId];
+        if(isset($this->params['change_types']) && is_array($this->params['change_types'])){
+            $where[] = ['change_type','in',$this->params['change_types']];
+        }
+
+        return $where;
+    }
+    public function lists():array
+    {
+        return MasterWorkerAccountLog::where($this->queryWhere())
+            ->field('sn,change_type,action,work_sn,change_amount,create_time')
+            ->order(['id' => 'dasc'])
+            ->append(['action_text'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()
+            ->toArray();
+
+    }
+    public function count(): int
+    {
+        return MasterWorkerAccountLog::where($this->queryWhere())->count();
+    }
+}

+ 40 - 0
app/workerapi/lists/MasterWorkerCaseOutLogLists.php

@@ -0,0 +1,40 @@
+<?php
+namespace app\workerapi\lists;
+use app\common\model\finance\MasterWorkerCaseOutLog;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/23 下午2:17
+ */
+class MasterWorkerCaseOutLogLists extends BaseWorkerDataLists
+{
+    public function queryWhere()
+    {
+        $where = [];
+        if(isset($this->params['month'])){
+            $firstDay = date("Y-m-d 00:00:00", strtotime("first day of {$this->params['month']}"));
+            $lastDay = date("Y-m-d 23:59:59", strtotime("{$this->params['month']} +1 month -1 day"));
+            $firstTime = strtotime($firstDay);
+            $lastTime = strtotime($lastDay);
+            $where[] = ['create_time','between',[$firstTime,$lastTime]];
+        }
+        $where[] = ['worker_id', '=', $this->userId];
+        return $where;
+    }
+
+    public function lists():array
+    {
+        return MasterWorkerCaseOutLog::where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->field('sn,change_amount,review_status,create_time')
+            ->append(['review_status_text'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+    public function count(): int
+    {
+        return MasterWorkerCaseOutLog::where($this->queryWhere())->count();
+    }
+}

+ 84 - 0
app/workerapi/logic/AccountLogic.php

@@ -0,0 +1,84 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\finance\MasterWorkerCaseOutLog;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+
+/**
+ * @author 林海涛
+ * @date 2024/7/22 下午4:31
+ */
+class AccountLogic extends BaseLogic
+{
+
+    /**
+     * 我的账户总资产
+     * @param $params
+     * @return false|int[]
+     * @author 林海涛
+     * @date 2024/7/22 下午5:39
+     */
+    public static function totalAssets($params)
+    {
+        try{
+            $yDay = date("Y-m-d",strtotime("-1 day"));
+            $ytime = strtotime("$yDay 00:00:00");//昨天开始时间戳
+            $yetime = strtotime("$yDay 23:59:59");//昨天开始时间戳
+            $data= ['user_money' =>0,'account_yesterday' => 0,'case_out_money' => 0];
+            $data['user_money'] = MasterWorker::where('id',$params['user_id'])->value('user_money') ?? 0;
+            $where = [];
+            $where[] = ['worker_id','=',$params['worker_id']] ;
+            $where[] = ['change_type', '=', WorkerAccountLogEnum::UM_INC_ADMIN];
+            $where[] = ['action', '=',WorkerAccountLogEnum::INC];
+            $where[] = ['create_time','between',[$ytime,$yetime]];
+            $data['account_yesterday']= MasterWorkerAccountLog::where($where)
+                ->sum('change_amount');
+            $data['case_out_money']= MasterWorkerCaseOutLog::where([
+                'worker_id'=>$params['user_id'],
+                'review_status' => 1,
+            ])->sum('change_amount');
+            return $data;
+        } catch(\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function monthAccountWithCaseOutTotal($params)
+    {
+        try{
+            $month = $params['month'];
+            $firstDay = date("Y-m-d 00:00:00", strtotime("first day of {$month}"));
+            $lastDay = date("Y-m-d 23:59:59", strtotime("{$month} +1 month -1 day"));
+            $firstTime = strtotime($firstDay);
+            $lastTime = strtotime($lastDay);
+            $where = [];
+            $where[] = ['worker_id','=',$params['worker_id']] ;
+            $where[] = ['create_time','between',[$firstTime,$lastTime]];
+            $data= [];
+            $incAccountWhere[] = $where+[
+                ['change_type', '=', WorkerAccountLogEnum::UM_INC_ADMIN],
+                ['action', '=',WorkerAccountLogEnum::INC],
+                ];
+            $data['account_amount_inc_total'] = MasterWorkerAccountLog::where($incAccountWhere)
+                ->sum('change_amount');
+            $decAccountWhere[] = $where+[
+                    ['change_type', '=', WorkerAccountLogEnum::UM_DEC_ADMIN],
+                    ['action', '=',WorkerAccountLogEnum::DEC],
+                ];
+            $data['account_amount_dec_total'] = MasterWorkerAccountLog::where($decAccountWhere)
+                ->sum('change_amount');
+            $data['account_amount_total'] =  $data['account_amount_inc_total'] - $data['account_amount_dec_total'];
+            $caseOutWhere = $where+[
+                    ['review_status','=',1]
+                ];
+            $data['case_out_total'] = MasterWorkerCaseOutLog::where($caseOutWhere)->sum('change_amount');
+            return $data;
+        }catch(\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

+ 1 - 1
app/workerapi/logic/MasterWorkerCustomerLogic.php

@@ -13,7 +13,7 @@ class MasterWorkerCustomerLogic extends BaseLogic
     {
         try {
             MasterWorkerCustomer::create([
-                'user_id' => $userId,
+                'worker_id' => $userId,
                 'name' => $params['name'],
                 'mobile' => $params['mobile'],
                 'problem' => $params['problem'],

+ 1 - 1
app/workerapi/logic/MasterWorkerInfoLogic.php

@@ -15,7 +15,7 @@ class MasterWorkerInfoLogic extends BaseLogic
     public static function changeIdCard($params,$userId)
     {
         try{
-            $where = [['user_id', '=', $userId]];
+            $where = [['worker_id', '=', $userId]];
             $userInfo = MasterWorkerInfo::where($where)->findOrEmpty();
             if ($userInfo->isEmpty()) {
                 $userInfo = new MasterWorkerInfo();

+ 2 - 1
app/workerapi/logic/MasterWorkerLogic.php

@@ -1,5 +1,6 @@
 <?php
 namespace app\workerapi\logic;
+use app\common\enum\worker\WorkerAccountLogEnum;
 use app\common\enum\YesNoEnum;
 use app\common\logic\BaseLogic;
 use app\common\model\master_worker\MasterWorker;
@@ -90,7 +91,7 @@ class MasterWorkerLogic extends  BaseLogic
             ->toArray();
 
         //今日收益
-        $worker['account_today'] = MasterWorkerAccountLog::where(['worker_id'=> $worker['id'],'action'=>1])->whereTime('create_time', 'today')->sum('change_amount');
+        $worker['account_today'] = MasterWorkerAccountLog::where(['worker_id'=> $worker['id'],'action'=>1,'change_type'=>WorkerAccountLogEnum::UM_INC_ADMIN])->whereTime('create_time', 'today')->sum('change_amount');
         //本月成功订单
         $worker['success_work'] = ServiceWork::where(['master_worker_id'=>$worker['id'],'service_status'=>3])->whereTime('create_time', 'month')->count();
         //本月失败单

+ 2 - 2
app/workerapi/logic/MasterWorkerMessageLogic.php

@@ -34,7 +34,7 @@ class MasterWorkerMessageLogic extends  BaseLogic
         $msgStatisTicsObj = MasterWorkerMessage::field('msg_type,count(*) as count')
             ->where('show_type',YesNoEnum::NO)
             ->whereIn('msg_type',$msgTypeArr)
-            ->where('user_id',$userId)
+            ->where('worker_id',$userId)
             ->group('msg_type')
             ->select();
        foreach($dictData as $k => $v){
@@ -48,7 +48,7 @@ class MasterWorkerMessageLogic extends  BaseLogic
     public static function showMsg($params,$userId)
     {
         return MasterWorkerMessage::whereIn('id',$params['ids'])
-            ->where('user_id',$userId)
+            ->where('worker_id',$userId)
             ->update(['show_type'=>YesNoEnum::YES]);
     }
 }

+ 22 - 0
app/workerapi/validate/AccountLogValidate.php

@@ -0,0 +1,22 @@
+<?php
+/**
+ * @author 林海涛
+ * @date 2024/7/23 上午11:47
+ */
+namespace app\workerapi\validate;
+use app\common\validate\BaseValidate;
+class AccountLogValidate extends \app\common\validate\BaseValidate
+{
+    protected $rule = [
+        'month' => 'require',
+    ];
+
+    protected $message = [
+        'month.require' => '请输入年月',
+    ];
+
+    public function sceneMonthAccountWithCaseOutTotal()
+    {
+        return $this->only(['month']);
+    }
+}

+ 1 - 1
app/workerapi/validate/BankAccountValidate.php

@@ -6,7 +6,7 @@ use app\common\validate\BaseValidate;
  * @author 林海涛
  * @date 2024/7/11 下午4:30
  */
-class BankAccountValidate extends \app\common\validate\BaseValidate
+class BankAccountValidate extends BaseValidate
 {
     protected $rule = [
         'account_holder' => 'require',