Преглед изворни кода

长期合作工程师不显示收益金额

dongxiaoqin пре 10 месеци
родитељ
комит
1f0199023b

+ 10 - 0
app/adminapi/controller/master_worker/MasterWorkerController.php

@@ -23,6 +23,7 @@ use app\adminapi\lists\master_worker\MasterWorkerOnlineLists;
 use app\adminapi\lists\master_worker\MasterWorkerStopLists;
 use app\adminapi\logic\master_worker\MasterWorkerLogic;
 use app\adminapi\validate\master_worker\MasterWorkerValidate;
+use app\adminapi\lists\master_worker\MasterWorkerScheduleLists;
 
 
 /**
@@ -166,4 +167,13 @@ class MasterWorkerController extends BaseAdminController
     {
         return $this->dataLists(new MasterWorkerStopLists());
     }
+
+    /**
+     * @notes 长期合作工程师排班列表
+     * @return \think\response\Json
+     */
+    public function scheduleLists()
+    {
+        return $this->dataLists(new MasterWorkerScheduleLists());
+    }
 }

+ 87 - 0
app/adminapi/lists/master_worker/MasterWorkerScheduleLists.php

@@ -0,0 +1,87 @@
+<?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;
+/**
+ * MasterWorkerSchedule列表
+ * Class MasterWorkerScheduleLists
+ * @package app\adminapi\listsmaster_worker
+ */
+class MasterWorkerScheduleLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+    public $count = 0;
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['mobile'],
+            '%like%' => ['real_name']
+        ];
+    }
+
+    public function queryWhere(){
+        $where[] = ['type','=',2];
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function lists(): array
+    {
+        $list = MasterWorker::with(['stopList'])->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->field(['id','real_name','mobile','avatar'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order("id","desc")
+            ->select()
+            ->toArray();
+        $stopList = [];
+        foreach ($list as &$item) {
+            foreach( $item['stopList'] as $v ) {
+                $stopList[] = (int)date("d",strtotime($v['start_time']));
+                $stopList[] = (int)date("d",strtotime($v['end_time']));
+            }
+            $item['stopList'] = array_values(array_unique($stopList));
+        }
+        return $list;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function count(): int
+    {
+        return MasterWorker::where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->count();
+    }
+}

+ 3 - 1
app/adminapi/logic/master_worker/MasterWorkerLogic.php

@@ -331,7 +331,9 @@ class MasterWorkerLogic extends BaseLogic
                 self::setError('该日期已存在停单记录');
                 return false;
             }
-
+            if ($params['start_time'] == date('Y-m-d')) {
+                $worker->accept_order_status = 0;
+            }
             $worker->save();
 
             MasterWorkerStop::create([

+ 8 - 2
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -718,8 +718,12 @@ class ServiceWorkLogic extends BaseLogic
                                         ->toArray();
 
         //查收工程师提成金额
-        $change_amount = MasterWorkerAccountLog::where(['work_sn'=>$result['work_sn'],'action'=>1])->value('change_amount');
-        $result['change_amount'] = !empty($change_amount)?$change_amount:0;
+        if (!empty($params['user_id']) && $result['type'] == 2) {
+            $result['change_amount'] = "-";
+        } else {
+            $change_amount = MasterWorkerAccountLog::where(['work_sn'=>$result['work_sn'],'action'=>1])->value('change_amount');
+            $result['change_amount'] = !empty($change_amount)?$change_amount:0;
+        }
 
         //质保金相关金额
         $result['retention'] = MasterWorkerRetentionMoneyLog::where('work_id',$result['id'])->visible(['action','amount'])->select()
@@ -1154,6 +1158,8 @@ class ServiceWorkLogic extends BaseLogic
                 $work->first_contact_time = time();
                 $work->save();
             }
+            
+            return ['middleNumber' => $work->mobile];
             if ($middleNumber = Cache::get('WORKER_MIDDLE_NUMBER_'.$work->id)) {
                 return ['middleNumber' => $middleNumber];
             }

+ 11 - 12
app/common/command/AutomaticDispatch.php

@@ -65,10 +65,7 @@ class AutomaticDispatch extends Command
 
         if (!Cache::get("automatic_dispatch_acceptOrderStatus_".date("Y-m-d"))) {
             //长期合作工程师:停单/开启接单
-            $this->acceptOrderStatus(0);
-            
-            //长期合作工程师:停单/开启接单
-            $this->acceptOrderStatus(1);
+            $this->acceptOrderStatus();
 
             Cache::set("automatic_dispatch_acceptOrderStatus_".date("Y-m-d"), 1, 24*60*60);//秒数
         }        
@@ -77,24 +74,26 @@ class AutomaticDispatch extends Command
     /**
      * 长期合作工程师停单/启单
      */
-    public function acceptOrderStatus($accept_order_status)
+    public function acceptOrderStatus()
     {
         $startTime = strtotime(date('Y-m-d 00:00:00'));
         $endTime = strtotime(date('Y-m-d 23:59:59', strtotime("-1 days")));
-        if ($accept_order_status == 0) { // 停单
-            $where[] = ['start_time', '=', $startTime];
-        } else {
-            $where[] = ['end_time', '=', $endTime];
-        }
-        $list = MasterWorkerStop::where($where)
-                    ->field("id,worker_id")
+        
+        $list = MasterWorkerStop::where(function ($query) use ($startTime, $endTime) {
+                        $query->where('start_time', $startTime)
+                              ->whereOr('end_time', $endTime);
+                    })
+                    ->field("id,worker_id,start_time,end_time")
+                    ->order("start_time", "ASC")
                     ->select()
                     ->toArray();
+                    
         if (!$list) {
             return ;
         }
         foreach($list as $item) {
             try {
+                $accept_order_status = strtotime($item['start_time']) == $startTime ? 0 : 1;
                 MasterWorker::where('id', $item['worker_id'])->update(['accept_order_status' => $accept_order_status]);
             } catch (\Exception $e) {
                 Log::write('长期合作工程师停单/启单异常:'.$e->getMessage());

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

@@ -118,4 +118,11 @@ class MasterWorker extends BaseModel
     {
         return $this->hasMany(ServiceWork::class,'master_worker_id','id')->field('id,master_worker_id,title,address,appointment_time,dispatch_time,estimated_finish_time,finished_time,goods_category_id,mobile,real_name,city,work_sn,work_status','in',[0,1])->order('appointment_time','asc');
     }
+    //当月停单记录
+    public function stopList()
+    {
+        return $this->hasMany(MasterWorkerStop::class,'worker_id','id')
+                ->where('start_time', 'between',[strtotime(date('Y-m-01 00:00:00')),strtotime(date('Y-m-t 23:59:59'))])
+                ->order('start_time','asc');
+    }
 }

+ 6 - 2
app/workerapi/logic/AccountLogic.php

@@ -27,14 +27,18 @@ class AccountLogic extends BaseLogic
             $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['worker_id'])->value('user_money') ?? 0;
+            $masterWorker = MasterWorker::where('id',$params['worker_id'])->field('user_money,type')->findOrEmpty();
+            if ($masterWorker->type == 2) {
+                return ['user_money' =>"-",'account_yesterday' => "-",'case_out_money' => "-"];
+            }
+            $data['user_money'] = $masterWorker && $masterWorker->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');
+            ->sum('change_amount');
             $data['case_out_money']= MasterWorkerCaseOutLog::where([
                 'worker_id'=>$params['worker_id'],
                 'review_status' => 1,

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

@@ -136,7 +136,7 @@ class MasterWorkerLogic extends  BaseLogic
 
      public static function detail($userId): array
     {
-        $worker = MasterWorker::field('id,team_id,team_role,sn,avatar,real_avatar,real_name,nickname,account,mobile,sex,estimate_money,user_money,earnest_money,exp,worker_number,work_status,accept_order_status,identity_source')
+        $worker = MasterWorker::field('id,team_id,team_role,sn,avatar,real_avatar,real_name,nickname,account,mobile,sex,estimate_money,user_money,earnest_money,exp,worker_number,work_status,accept_order_status,identity_source,type')
             ->findOrEmpty($userId)
             ->toArray();
 
@@ -156,7 +156,13 @@ class MasterWorkerLogic extends  BaseLogic
         //今日退款
         $worker['refund_account_today'] = MasterWorkerAccountLog::where(['worker_id'=> $worker['id'],'action'=>2,'change_type'=>WorkerAccountLogEnum::UM_DEC_ADMIN])->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['refund_account_today'];
+        if ($worker['type'] == 2) {
+            //长期合作工程师不返回
+            $worker['user_money'] = "-";
+            $worker['account_today'] = "-";
+        } else {
+            $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['refund_account_today'];
+        }
         //本月成功订单
         $worker['success_work'] = ServiceWork::where(['master_worker_id'=>$worker['id'],'service_status'=>3])->whereTime('create_time', 'month')->count();
         //本月失败单