diff --git a/app/adminapi/controller/auth/AdminController.php b/app/adminapi/controller/auth/AdminController.php index 47f66499c..dce6e0ca3 100755 --- a/app/adminapi/controller/auth/AdminController.php +++ b/app/adminapi/controller/auth/AdminController.php @@ -158,83 +158,4 @@ class AdminController extends BaseAdminController $result = AdminLogic::editSelf($params); return $this->success('操作成功', [], 1, 1); } - // /**生成合同 */ - public function Draftingcontracts() - { - $params = Request::param(); - $result = AdminLogic::detail($params); - if ($result && $result['contract'] && $result['contract']['file'] != '') { - $data = [ - 'name' => $result['name'] . '合同', - 'signatories' => [ - ['fullName' => $result['name'], 'identityType' => 1, 'identityCard' => $result['id_card'], 'mobile' => $result['account'], 'noNeedVerify' => 1, 'signLevel' => 1], - ['fullName' => $result['contract']['party_a_info']['company_name'], 'identityType' => 12, 'identityCard' => $result['contract']['party_a_info']['organization_code'], 'email' => $result['contract']['party_a_info']['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1] - ], - 'url' => $result['contract']['file'] - ]; - $res = app(JunziqianController::class)->Signing($data,$result['contract']['id']); - if ($res->success == true) { - Db::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data]); - $data = array( - "applyNo" => $res->data, //TODO * - "fullName" => $result['name'], //TODO * - "identityCard" => $result['id_card'], //TODO * - "identityType" => 1, //TODO * - ); - $res = app(JunziqianController::class)->SigningLink($data); - if ($res->success == true) { - Db::name('contract')->where('id', $result['contract']['id'])->update(['url' => $res->data]); - //发送短信 - $sms = [ - 'mobile' => $result['phone'], - 'name' => $result['name'], - 'type' => '《' . $result['contract']['contract_type_name'] . '》', - 'code' => 'api/Hetong/url?id=' . $result['contract']['id'], - 'scene' => 'WQ' - ]; - $result = SmsLogic::contractUrl($sms); - if (true === $result) { - return $this->success('发送成功'); - } else { - return $this->fail(SmsLogic::getError()); - } - } else { - return $this->fail($res->msg); - } - return $this->success('生成合同成功', [], 1, 1); - } else { - return $this->fail($res->msg); - } - } else { - return $this->fail('生成合同成功失败,联系管理员'); - } - } - - //**发送短信 */ - public function postsms() - { - $params = Request::param(); - $admin=Db::name('admin')->where('id',$params['id'])->find(); - $find = Db::name('contract')->where('party_b', $params['id']) - ->withAttr('contract_type_name', function ($value, $data) { - return Db::name('dict_data')->where('id', $data['contract_type'])->value('name'); - }) - ->find(); - if ($find && $find['url'] != '') { - //发送短信 - $sms = [ - 'mobile' => $admin['phone'], - 'name' => $admin['name'], - 'type' => '《' . $find['contract_type_name'] . '》', - 'code' => 'api/Hetong/url?id=' . $find['id'], - 'scene' => 'WQ' - ]; - $result = SmsLogic::contractUrl($sms); - if (true === $result) { - return $this->success('发送成功'); - } else { - return $this->fail(SmsLogic::getError()); - } - } - } } diff --git a/app/adminapi/controller/task_scheduling/TaskSchedulingController.php b/app/adminapi/controller/task_scheduling/TaskSchedulingController.php new file mode 100644 index 000000000..5b4cf0f67 --- /dev/null +++ b/app/adminapi/controller/task_scheduling/TaskSchedulingController.php @@ -0,0 +1,109 @@ +dataLists(new TaskSchedulingLists()); + } + + + /** + * @notes 添加任务公司排期 + * @return \think\response\Json + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function add() + { + $params = (new TaskSchedulingValidate())->post()->goCheck('add'); + $params['create_user_id']=$this->adminId; + $result = TaskSchedulingLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(TaskSchedulingLogic::getError()); + } + + + /** + * @notes 编辑任务公司排期 + * @return \think\response\Json + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function edit() + { + $params = (new TaskSchedulingValidate())->post()->goCheck('edit'); + $result = TaskSchedulingLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(TaskSchedulingLogic::getError()); + } + + + /** + * @notes 删除任务公司排期 + * @return \think\response\Json + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function delete() + { + $params = (new TaskSchedulingValidate())->post()->goCheck('delete'); + TaskSchedulingLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取任务公司排期详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function detail() + { + $params = (new TaskSchedulingValidate())->goCheck('detail'); + $result = TaskSchedulingLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/task_scheduling_plan/TaskSchedulingPlanController.php b/app/adminapi/controller/task_scheduling_plan/TaskSchedulingPlanController.php new file mode 100644 index 000000000..1ab3a4a68 --- /dev/null +++ b/app/adminapi/controller/task_scheduling_plan/TaskSchedulingPlanController.php @@ -0,0 +1,112 @@ +dataLists(new TaskSchedulingPlanLists()); + } + + + /** + * @notes 添加任务排期日历 + * @return \think\response\Json + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function add() + { + $params = (new TaskSchedulingPlanValidate())->post()->goCheck('add'); + $params['create_user_id']=$this->adminId; + $time=strtotime($params['time']); + $params['start_time']=$time; + $params['end_time']=$time+86399; + $result = TaskSchedulingPlanLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(TaskSchedulingPlanLogic::getError()); + } + + + /** + * @notes 编辑任务排期日历 + * @return \think\response\Json + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function edit() + { + $params = (new TaskSchedulingPlanValidate())->post()->goCheck('edit'); + $result = TaskSchedulingPlanLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(TaskSchedulingPlanLogic::getError()); + } + + + /** + * @notes 删除任务排期日历 + * @return \think\response\Json + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function delete() + { + $params = (new TaskSchedulingPlanValidate())->post()->goCheck('delete'); + TaskSchedulingPlanLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取任务排期日历详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function detail() + { + $params = (new TaskSchedulingPlanValidate())->goCheck('detail'); + $result = TaskSchedulingPlanLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/task_scheduling/TaskSchedulingLists.php b/app/adminapi/lists/task_scheduling/TaskSchedulingLists.php new file mode 100644 index 000000000..e70808e8f --- /dev/null +++ b/app/adminapi/lists/task_scheduling/TaskSchedulingLists.php @@ -0,0 +1,78 @@ + ['create_user_id', 'template_id', 'company_id', 'type', 'status'], + ]; + } + + + /** + * @notes 获取任务公司排期列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function lists(): array + { + return TaskScheduling::where($this->searchWhere) + ->with(['admin','data_type','template','company']) + ->field(['id', 'create_user_id', 'template_id', 'company_id', 'type', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取任务公司排期数量 + * @return int + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function count(): int + { + return TaskScheduling::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/task_scheduling_plan/TaskSchedulingPlanLists.php b/app/adminapi/lists/task_scheduling_plan/TaskSchedulingPlanLists.php new file mode 100644 index 000000000..582888d98 --- /dev/null +++ b/app/adminapi/lists/task_scheduling_plan/TaskSchedulingPlanLists.php @@ -0,0 +1,85 @@ + ['create_user_id', 'template_id', 'scheduling_id', 'status'], + 'between_time'=> 'start_time' + ]; + } + + + /** + * @notes 获取任务排期日历列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function lists(): array + { + $where = []; + + if($this->adminInfo['root']!=1){ + $where[] = ['create_user_id','=',$this->adminId]; + } + return TaskSchedulingPlan::where($this->searchWhere) + ->where($where) + ->with(['template']) + ->field(['id', 'create_user_id', 'template_id', 'scheduling_id', 'start_time', 'end_time', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取任务排期日历数量 + * @return int + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function count(): int + { + return TaskSchedulingPlan::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/task_template/TaskTemplateLists.php b/app/adminapi/lists/task_template/TaskTemplateLists.php index 6fff08a9a..11b838a70 100644 --- a/app/adminapi/lists/task_template/TaskTemplateLists.php +++ b/app/adminapi/lists/task_template/TaskTemplateLists.php @@ -56,6 +56,7 @@ class TaskTemplateLists extends BaseAdminDataLists implements ListsSearchInterfa { return TaskTemplate::where($this->searchWhere) ->field(['id', 'title', 'admin_id', 'moeny', 'type', 'status', 'content']) + ->with(['admin','data_type']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() diff --git a/app/adminapi/validate/task_scheduling/TaskSchedulingValidate.php b/app/adminapi/validate/task_scheduling/TaskSchedulingValidate.php new file mode 100644 index 000000000..f22450a09 --- /dev/null +++ b/app/adminapi/validate/task_scheduling/TaskSchedulingValidate.php @@ -0,0 +1,94 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return TaskSchedulingValidate + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return TaskSchedulingValidate + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return TaskSchedulingValidate + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return TaskSchedulingValidate + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/task_scheduling_plan/TaskSchedulingPlanValidate.php b/app/adminapi/validate/task_scheduling_plan/TaskSchedulingPlanValidate.php new file mode 100644 index 000000000..fef9f01b6 --- /dev/null +++ b/app/adminapi/validate/task_scheduling_plan/TaskSchedulingPlanValidate.php @@ -0,0 +1,94 @@ + 'id', + ]; + + + /** + * @notes 添加场景 + * @return TaskSchedulingPlanValidate + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function sceneAdd() + { + return $this->only([]); + } + + + /** + * @notes 编辑场景 + * @return TaskSchedulingPlanValidate + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return TaskSchedulingPlanValidate + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return TaskSchedulingPlanValidate + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/api/controller/CompanyController.php b/app/api/controller/CompanyController.php index a2361bc95..be8d4fc60 100644 --- a/app/api/controller/CompanyController.php +++ b/app/api/controller/CompanyController.php @@ -39,7 +39,7 @@ class CompanyController extends BaseApiController public function unsigned() { $myCompany = Company::findOrEmpty($this->userInfo['company_id'])->toArray(); - $query = Company::where(['street' => $myCompany['street'], 'company_type' => [17, 18], 'is_contract' => 0]); + $query = Company::where(['street' => $myCompany['street'], 'company_type' => [17, 18], 'is_contract' => 0])->where('id','<>',$this->userInfo['company_id']); $count = $query->count(); $companies = $query->field('*,street street_name,area area_name,city city_name,province province_name')->select()->toArray(); return $this->success('', ['count' => $count, 'data' => $companies]); diff --git a/app/common/logic/contract/ContractLogic.php b/app/common/logic/contract/ContractLogic.php index fa9c6c774..2b854e099 100644 --- a/app/common/logic/contract/ContractLogic.php +++ b/app/common/logic/contract/ContractLogic.php @@ -170,6 +170,11 @@ class ContractLogic extends BaseLogic $model->contract_no = time(); $model->create_time = time(); } + if($data['type']==1){ + if($data['party_a'] == $data['party_b']){ + return self::setError('甲方和乙方不能是同一个公司'); + } + } $model->check_status = 1; $model->update_time = time(); $model->setAttrs($data); diff --git a/app/common/logic/task_scheduling/TaskSchedulingLogic.php b/app/common/logic/task_scheduling/TaskSchedulingLogic.php new file mode 100644 index 000000000..197401cb9 --- /dev/null +++ b/app/common/logic/task_scheduling/TaskSchedulingLogic.php @@ -0,0 +1,114 @@ + $params['create_user_id'], + 'template_id' => $params['template_id'], + 'company_id' => $params['company_id'], + 'type' => $params['type'], + 'status' => $params['status'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑任务公司排期 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + TaskScheduling::where('id', $params['id'])->update([ + 'create_user_id' => $params['create_user_id'], + 'template_id' => $params['template_id'], + 'company_id' => $params['company_id'], + 'type' => $params['type'], + 'status' => $params['status'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除任务公司排期 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public static function delete(array $params): bool + { + return TaskScheduling::destroy($params['id']); + } + + + /** + * @notes 获取任务公司排期详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/08/08 10:08 + */ + public static function detail($params): array + { + return TaskScheduling::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/common/logic/task_scheduling_plan/TaskSchedulingPlanLogic.php b/app/common/logic/task_scheduling_plan/TaskSchedulingPlanLogic.php new file mode 100644 index 000000000..acee3333a --- /dev/null +++ b/app/common/logic/task_scheduling_plan/TaskSchedulingPlanLogic.php @@ -0,0 +1,119 @@ + $params['create_user_id'], + 'template_id' => $params['template_id'], + 'scheduling_id' => $params['scheduling_id'], + 'start_time' => $params['start_time'], + 'end_time' => $params['end_time'], + 'status' => 1 + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑任务排期日历 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + TaskSchedulingPlan::where('id', $params['id'])->update([ + 'create_user_id' => $params['create_user_id'], + 'template_id' => $params['template_id'], + 'scheduling_id' => $params['scheduling_id'], + 'start_time' => $params['start_time'], + 'end_time' => $params['end_time'], + 'status' => $params['status'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除任务排期日历 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public static function delete(array $params): bool + { + return TaskSchedulingPlan::destroy($params['id']); + } + + + /** + * @notes 获取任务排期日历详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/08/08 10:34 + */ + public static function detail($params): array + { + $data=TaskSchedulingPlan::findOrEmpty($params['id'])->toArray(); + $data['task_info']=TaskTemplate::where('id',$data['template_id'])->with('dataType')->find(); + return $data; + } +} \ No newline at end of file diff --git a/app/common/model/task_scheduling/TaskScheduling.php b/app/common/model/task_scheduling/TaskScheduling.php new file mode 100644 index 000000000..f9cdc13d1 --- /dev/null +++ b/app/common/model/task_scheduling/TaskScheduling.php @@ -0,0 +1,52 @@ +hasOne(Admin::class, 'id', 'create_user_id')->bind(['admin_name'=>'name']); + } + public function dataType() + { + return $this->hasOne(DictData::class, 'id', 'type')->bind(['type_name'=>'name']); + } + public function template() + { + return $this->hasOne(TaskTemplate::class, 'id', 'template_id')->bind(['template_name'=>'title']); + } + public function company() + { + return $this->hasOne(Company::class, 'id', 'company_id')->bind(['company_name']); + } +} \ No newline at end of file diff --git a/app/common/model/task_scheduling_plan/TaskSchedulingPlan.php b/app/common/model/task_scheduling_plan/TaskSchedulingPlan.php new file mode 100644 index 000000000..2d01388f4 --- /dev/null +++ b/app/common/model/task_scheduling_plan/TaskSchedulingPlan.php @@ -0,0 +1,46 @@ +hasOne(TaskTemplate::class, 'id', 'template_id')->bind(['template_name'=>'title']); + } +} \ No newline at end of file diff --git a/app/common/model/task_template/TaskTemplate.php b/app/common/model/task_template/TaskTemplate.php index bf077dbe0..e3b145672 100644 --- a/app/common/model/task_template/TaskTemplate.php +++ b/app/common/model/task_template/TaskTemplate.php @@ -14,8 +14,9 @@ namespace app\common\model\task_template; - +use app\common\model\auth\Admin; use app\common\model\BaseModel; +use app\common\model\dict\DictData; use think\model\concern\SoftDelete; @@ -30,5 +31,13 @@ class TaskTemplate extends BaseModel protected $name = 'task_template'; protected $deleteTime = 'delete_time'; + public function admin() + { + return $this->hasOne(Admin::class, 'id', 'admin_id')->bind(['admin_name'=>'name']); + } + public function dataType() + { + return $this->hasOne(DictData::class, 'id', 'type')->bind(['type_name'=>'name']); + } } \ No newline at end of file diff --git a/vendor/ebaoquan/junziqian_sdk b/vendor/ebaoquan/junziqian_sdk index 1294ea49f..9acc82cd2 160000 --- a/vendor/ebaoquan/junziqian_sdk +++ b/vendor/ebaoquan/junziqian_sdk @@ -1 +1 @@ -Subproject commit 1294ea49ff9ecc4532821f8798304816cbf8dd74 +Subproject commit 9acc82cd23d807280ddd29df2117e7890094d049