diff --git a/app/middleapi/controller/TaskTemplateController.php b/app/middleapi/controller/TaskTemplateController.php new file mode 100644 index 000000000..afe6c1741 --- /dev/null +++ b/app/middleapi/controller/TaskTemplateController.php @@ -0,0 +1,155 @@ +request->isPost()){ + return $this->fail('请求方式错误'); + } + $params=$this->request->post(['page_no','page_size','title', 'type', 'status', 'company_id']); + $where = []; + if (isset($params['title']) && $params['title'] != '') { + $where[] = ['title', 'like', '%' . $params['title'] . '%']; + } + if (isset($params['type']) && $params['type'] != '') { + $where[] = ['type', '=', $params['type']]; + } + if (isset($params['status']) && $params['status'] != '') { + $where[] = ['status', '=', $params['status']]; + } + if (isset($params['company_id']) && $params['company_id'] != '') { + $where[] = ['company_id', '=', $params['company_id']]; + } + $pageNo = !empty($params['page_no']) ? $params['page_no'] : 1; + $pageSize = !empty($params['page_size']) ? $params['page_size'] : 20; + $data = TaskTemplate::where($where) + ->with(['admin','data_type']) + ->page($pageNo, $pageSize) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + $count = TaskTemplate::where($where)->count(); + $result = [ + 'lists' => $data, + 'count' => $count, + 'page_no' => $pageNo, + 'page_size' => $pageSize + ]; + return $this->success('请求成功',$result); + } + + + /** + * @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 == 41) { + // 创建 镇农科公司 任务模板 + $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'); + 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); + } +} \ No newline at end of file