dataLists(new CompanyLists()); } /** * @notes 添加 * @return \think\response\Json * @author likeadmin * @date 2023/07/15 14:43 */ public function add() { $params = (new CompanyValidate())->post()->goCheck('add'); $params['other_contacts'] = json_encode($params['other_contacts']); $params['qualification'] = json_encode($params['qualification']); $result = CompanyLogic::add($params); if (true === $result) { return $this->success('添加成功', [], 1, 1); } return $this->fail(CompanyLogic::getError()); } /** * @notes 编辑 * @return \think\response\Json * @author likeadmin * @date 2023/07/15 14:43 */ public function edit() { $params = (new CompanyValidate())->post()->goCheck('edit'); $params['other_contacts'] = json_encode($params['other_contacts']); $params['qualification'] = json_encode($params['qualification']); $result = CompanyLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(CompanyLogic::getError()); } /** * @notes 删除 * @return \think\response\Json * @author likeadmin * @date 2023/07/15 14:43 */ public function delete() { $params = (new CompanyValidate())->post()->goCheck('delete'); CompanyLogic::delete($params); return $this->success('删除成功', [], 1, 1); } /** * @notes 获取详情 * @return \think\response\Json * @author likeadmin * @date 2023/07/15 14:43 */ public function detail() { $params = (new CompanyValidate())->goCheck('detail'); $result = CompanyLogic::detail($params); return $this->data($result); } // /**生成合同 */ public function Draftingcontracts() { $params = (new CompanyValidate())->goCheck('detail'); $result = CompanyLogic::detail($params); if ($result && $result['contract'] && $result['contract']['file'] != '') { $data = [ 'name' => $result['company_name'] . '合同', 'signatories' => [['fullName' => $result['company_name'], 'identityType' => 12, 'identityCard' => $result['organization_code'], 'mobile' => $result['master_phone'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]], 'url' => $result['contract']['file'] ]; $res = app(JunziqianController::class)->Signing($data); if ($res->success == true) { Db::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data]); $company = Db::name('company')->where('id', $params['id'])->find(); if ($company && $company['contract_id']) { $find = Db::name('contract')->where('id', $company['contract_id']) ->withAttr('contract_type_name', function ($value, $data) { return Db::name('dict_data')->where('id', $data['contract_type'])->value('name'); })->find(); if ($find) { $data = array( "applyNo" => $find['contract_no'], //TODO * "fullName" => $company['company_name'], //TODO * "identityCard" => $company['organization_code'], //TODO * "identityType" => 12, //TODO * ); $res = app(JunziqianController::class)->SigningLink($data); if ($res->success == true) { Db::name('contract')->where('id', $company['contract_id'])->update(['url' => $res->data]); //发送短信 $sms = [ 'mobile' => $company['master_phone'], 'name' => $company['company_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()); } } 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 = (new CompanyValidate())->goCheck('detail'); $company = Db::name('company')->where('id', $params['id'])->find(); if ($company && $company['contract_id']) { $find = Db::name('contract')->where('id', $company['contract_id']) ->withAttr('contract_type_name', function ($value, $data) { return Db::name('dict_data')->where('id', $data['contract_type'])->value('name'); }) ->find(); if ($find) { //发送短信 $sms = [ 'mobile' => $company['master_phone'], 'name' => $company['company_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()); } } } } //企业认证 public function authentication() { $params = (new CompanyValidate())->goCheck('detail'); $company = Db::name('company')->where('id', $params['id'])->find(); $qualification = json_decode($company['qualification'], true); if ($company && $qualification['business_license']) { $data = [ 'name' => $company['company_name'], 'organization_code' => $company['organization_code'], 'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png', //$qualification['business_license'], 'master_name' => $company['master_name'], 'master_email' => $company['master_email'], ]; $res = app(JunziqianController::class)->EnterpriseCertification($data); if ($res->success == true) { Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data]); return $this->success('认证成功', ['email' => $res->data], 1, 1); } else { return $this->fail($res->msg); } } } //重新认证 public function organizationReapply() { $params = (new CompanyValidate())->goCheck('detail'); $company = Db::name('company')->where('id', $params['id'])->find(); $qualification = json_decode($company['qualification'], true); if ($company && $qualification['business_license']) { $data = [ 'name' => $company['company_name'], 'organization_code' => $company['organization_code'], 'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png', //$qualification['business_license'], 'master_name' => $company['master_name'], 'master_email' => $company['master_email'], ]; $res = app(JunziqianController::class)->organizationReapply($data); if ($res->success == true) { Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data]); return $this->success('重新认证成功', ['em'], 1, 1); } else { return $this->fail($res->msg); } } } }