dataLists(new TaskTemplateLists()); } /** * @notes 添加任务模板 * @return \think\response\Json * @author likeadmin * @date 2023/08/06 17:30 */ public function add() { $params = (new TaskTemplateValidate())->post()->goCheck('add'); $params['admin_id'] = $this->adminId; $company = Company::find($params['company_id']); if ($company->company_type == 16) { // 创建 镇合伙人公司 任务模板 $result = TaskTemplateLogic::addTownTaskTemplate($params); } else if ($company->company_type == 17) { $result = TaskTemplateLogic::addVillageTaskTemplate($params); } else { $result = TaskTemplateLogic::add($params); } if (true === $result) { /** * 如果是公司第一次创建安排任务,则初始化公司的提现周期截止时间 */ TaskTemplateLogic::initCompanyWithdrawDeadline($params['company_id']); return $this->success('添加成功', [], 1, 1); } return $this->fail(TaskTemplateLogic::getError()); } /** * @notes 编辑任务模板 * @return \think\response\Json * @author likeadmin * @date 2023/08/06 17:30 */ public function edit() { $params = (new TaskTemplateValidate())->post()->goCheck('edit'); $result = TaskTemplateLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(TaskTemplateLogic::getError()); } /** * @notes 删除任务模板 * @return \think\response\Json * @author likeadmin * @date 2023/08/06 17:30 */ public function delete() { $params = (new TaskTemplateValidate())->post()->goCheck('delete'); $task = Task::where(['template_id' =>$params['id']])->whereDay('start_time', 'today')->find(); if(!empty($task)) { return $this->fail('该任务今天已在进行中,无法删除'); } TaskTemplateLogic::delete($params); return $this->success('删除成功', [], 1, 1); } /** * @notes 获取任务模板详情 * @return \think\response\Json * @author likeadmin * @date 2023/08/06 17:30 */ public function detail() { $params = (new TaskTemplateValidate())->goCheck('detail'); $result = TaskTemplateLogic::detail($params); return $this->data($result); } public function getProductList() { $param = $this->request->param(); // page keyword $p['page'] = $param['page_no'] ?? 1; $p['keyword'] = $param['keyword'] ??''; $result = ShopRequestLogic::getProductList($p);; // $result['data']['count'] = 1000; $data = [ 'lists' => $result['data']['data'], 'count' => $result['data']['count'], 'page_no' => $result['data']['page'], 'page_size' => 10, ]; return $this->data($data); } public function checkRole() { $params = $this->request->param(); if ($params['task_role'] == 1) { $serviceManagerUser = (new User())->searchMaster($params['company_id']); if (empty($serviceManagerUser)) { return $this->fail('公司还没有负责人,无法指派任务'); } } if ($params['task_role'] == 2) { $serviceManagerUser = (new User())->searchMarketingManager($params['company_id']); if (empty($serviceManagerUser)) { return $this->fail('公司还没有市场部长,无法指派任务'); } } if ($params['task_role'] == 3) { $serviceManagerUser = (new User())->searchServiceManager($params['company_id']); if (empty($serviceManagerUser)) { return $this->fail('公司还没有服务部长,无法指派任务'); } } return $this->success('成功'); } }