فهرست منبع

Merge branch 'master' of e.coding.net:zdap/weixiu/weixiu_api into new_settlement-m

liugc 11 ماه پیش
والد
کامیت
60eb968b89

+ 16 - 2
app/adminapi/lists/master_worker/MasterWorkerServiceOrderLists.php

@@ -93,7 +93,17 @@ class MasterWorkerServiceOrderLists extends BaseAdminDataLists implements ListsS
         $where[] = ['a.audit_state','=' ,1];
         return $where;
     }
-
+    public function queryWhereLog()
+    {
+        $where = [];
+        if (!empty($this->params['start_time'])) {
+            $where[0] = $this->params['start_time'];
+        }
+        if (!empty($this->params['end_time'])) {
+            $where[1] = strtotime($this->params['end_time'])+86400;
+        }
+        return $where;
+    }
     /**
      * 获取数据权限
      * $this->adminInfo['data_rules']
@@ -125,6 +135,7 @@ class MasterWorkerServiceOrderLists extends BaseAdminDataLists implements ListsS
     public function lists(): array
     {
         $queryWhere = $this->queryWhere();
+        $queryWhereLog = $this->queryWhereLog();
         $lists = Db::name('master_worker')->alias('a')->field([
                 'a.id','a.real_name','a.nickname','a.area_name','a.worker_number','a.recruiting_behalf','a.mobile','a.cooperation','a.category_ids','a.labels','a.remark',
                 Db::raw("COUNT(b.id) AS all_count"),
@@ -146,7 +157,10 @@ class MasterWorkerServiceOrderLists extends BaseAdminDataLists implements ListsS
         foreach ($lists as &$item) {
             $item['labels'] = $item['labels']?array_map(function ($item) { return intval($item); },explode(',',$item['labels'])):'';
             $item['category_name'] = $item['category_ids']?implode('、',array_column(get_parent_info($categoryData,explode(',',$item['category_ids'])),'name')):'';
-            $item['allocate_num'] = ServiceWorkAllocateWorkerLog::where(['master_worker_id'=>$item['id']])->count();
+            $item['allocate_num'] = ServiceWorkAllocateWorkerLog::where(['master_worker_id'=>$item['id']])
+                                    ->where('type',0)
+                                    ->whereBetweenTime('create_time',$queryWhereLog[0],$queryWhereLog[1])
+                                    ->count();
             $item['register_info'] = $masterWorkerRegisters[$item['id']]??[];
         }
         return $lists;

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

@@ -1133,6 +1133,7 @@ class ServiceWorkLogic extends BaseLogic
                 $serviceWork->user_confirm_status = 5;
                 $serviceWork->service_status = 3;
                 $serviceWork->work_pay_status = 1;
+                $serviceWork->finished_time = time();
                 $serviceWork->remark = ($serviceWork->remark?:'')." | 终止结束服务:常规流程";
                 $serviceWork->save();
             }else{
@@ -1146,6 +1147,7 @@ class ServiceWorkLogic extends BaseLogic
                     'work_status' => 7,
                     'user_confirm_status' => 5,
                     'service_status' => 3,
+                    'finished_time' => time(),
                     'work_pay_status' => 2, // 已结算则不执行 onAfterUpdate
                     'settlement_amount' => $paid_amount??0,
                     'worker_price' => $paid_amount??0,

+ 18 - 1
app/workerapi/controller/WorksController.php

@@ -367,5 +367,22 @@ class WorksController extends BaseApiController
         return $this->success('操作成功,工程师已上门,请用户扫码确认', $result, 1, 1);
     }
 
-
+    /**
+     * 工程师取消自己的分配
+     * @return \think\response\Json
+     * @author liugc <466014217@qq.com>
+     * @date 2025/4/28 15:08
+     */
+    public function cancelMasterWorker()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('cancel', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = ServiceWorkLogic::cancelAllocation(['id'=>$params['id'],'master_worker_id'=>$this->userId],['admin_id'=>$this->userId,'name'=>'工程师-'.$this->userInfo['mobile']]);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->success('成功', [], 1, 1);
+    }
 }

+ 4 - 1
app/workerapi/logic/MasterWorkerRegisterLogic.php

@@ -11,6 +11,7 @@ use app\common\model\service_area\ServiceArea;
 use app\common\logic\BaseLogic;
 use app\common\model\sale\Sale;
 use app\common\service\ConfigService;
+use app\workerapi\lists\MasterWorkerRegisterLists;
 use think\facade\Config;
 use think\facade\Db;
 use think\facade\Log;
@@ -28,7 +29,9 @@ class MasterWorkerRegisterLogic extends BaseLogic
      */
     public static function detail($params): array
     {
-        return MasterWorkerRegister::findOrEmpty($params['id'])->append(['credential_images','credential_name','city_text','maintain_exp_type_text','other_exp_type_text','vehicle_type_text'])->toArray();
+        $item = MasterWorkerRegister::findOrEmpty($params['id'])->append(['credential_images','credential_name','city_text','maintain_exp_type_text','other_exp_type_text','vehicle_type_text'])->toArray();
+        $item['status'] = (new MasterWorkerRegisterLists)->requiredMasterWorker($item['worker_id'])?1:2;
+        return $item;
     }
 
     public static function createMasterWorker(array $params)

+ 4 - 0
app/workerapi/validate/ServiceWorkValidate.php

@@ -138,4 +138,8 @@ class ServiceWorkValidate extends BaseValidate
     {
         return $this->only(['work_sn']);
     }
+    public function sceneCancel()
+    {
+        return $this->only(['id']);
+    }
 }