diff --git a/app/adminapi/controller/CompanyController.php b/app/adminapi/controller/CompanyController.php index a2564674e..f8d90ac6d 100644 --- a/app/adminapi/controller/CompanyController.php +++ b/app/adminapi/controller/CompanyController.php @@ -20,15 +20,9 @@ use app\adminapi\controller\BaseAdminController; use app\adminapi\lists\CompanyLists; use app\adminapi\logic\CompanyLogic; use app\adminapi\validate\CompanyValidate; -use think\facade\Request; use app\api\controller\JunziqianController; use app\api\logic\SmsLogic; -use Cls\Log; -use com\junziqian\sdk\util\RequestUtils; -use think\App; use think\facade\Db; -use think\facade\Log as FacadeLog; -use think\Log as ThinkLog; use think\view\driver\Think; /** @@ -117,16 +111,16 @@ class CompanyController extends BaseAdminController return $this->data($result); } - // /**生成合同 */iHMb7rVj@service.ebaoquan.org + // /**生成合同 */ public function Draftingcontracts() { $params = (new CompanyValidate())->goCheck('detail'); $result = CompanyLogic::detail($params); - if ($result && $result['contract'] && $result['contract']['contract_type_two_url'] != '') { + 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']['contract_type_two_url'] + 'url' => $result['contract']['file'] ]; $res = app(JunziqianController::class)->Signing($data); if ($res->success == true) { @@ -134,8 +128,8 @@ class CompanyController extends BaseAdminController $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_two_name', function ($value, $data) { - return Db::name('dict_data')->where('id', $data['contract_type_two'])->value('name'); + ->withAttr('contract_type_name', function ($value, $data) { + return Db::name('dict_data')->where('id', $data['contract_type'])->value('name'); })->find(); if ($find) { $data = array( @@ -151,7 +145,7 @@ class CompanyController extends BaseAdminController $sms = [ 'mobile' => $company['master_phone'], 'name' => $company['company_name'], - 'type' => '《' . $find['contract_type_two_name'] . '》', + 'type' => '《' . $find['contract_type_name'] . '》', 'code' => 'api/Hetong/url?id='.$find['id'], 'scene' => 'WQ' ]; @@ -182,8 +176,8 @@ class CompanyController extends BaseAdminController $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_two_name', function ($value, $data) { - return Db::name('dict_data')->where('id', $data['contract_type_two'])->value('name'); + ->withAttr('contract_type_name', function ($value, $data) { + return Db::name('dict_data')->where('id', $data['contract_type'])->value('name'); }) ->find(); if ($find) { @@ -191,7 +185,7 @@ class CompanyController extends BaseAdminController $sms = [ 'mobile' => $company['master_phone'], 'name' => $company['company_name'], - 'type' => '《' . $find['contract_type_two_name'] . '》', + 'type' => '《' . $find['contract_type_name'] . '》', 'code' => 'api/Hetong/url?id='.$find['id'], 'scene' => 'WQ' ]; diff --git a/app/adminapi/controller/auth/AdminController.php b/app/adminapi/controller/auth/AdminController.php index d7833e405..03eb537e2 100755 --- a/app/adminapi/controller/auth/AdminController.php +++ b/app/adminapi/controller/auth/AdminController.php @@ -20,7 +20,9 @@ use app\adminapi\validate\auth\AdminValidate; use app\adminapi\logic\auth\AdminLogic; use app\adminapi\validate\auth\editSelfValidate; use think\exception\ValidateException; +use think\facade\Db; use think\facade\Request; +use app\api\logic\SmsLogic; /** * 管理员控制器 @@ -50,17 +52,17 @@ class AdminController extends BaseAdminController */ public function add() { - $params=Request::param(); + $params = Request::param(); try { - $params['account']=$params['phone']; - $params['password']='m'.$params['phone']; - $params['password_confirm']='m'.$params['phone']; - $params['root']=0; - $params['qualification']=json_encode($params['qualification']); - $params['disable']=1; + $params['phone'] = $params['account']; + $params['password'] = 'm' . $params['account']; + $params['password_confirm'] = 'm' . $params['account']; + $params['root'] = 0; + $params['qualification'] = json_encode($params['qualification']); + $params['disable'] = 1; validate(AdminValidate::class) - ->scene('add')->check($params); + ->scene('add')->check($params); } catch (ValidateException $e) { // 验证失败 输出错误信息 return $this->fail($e->getError()); @@ -147,5 +149,80 @@ 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['company_name'] . '合同', + 'signatories' => [['fullName' => $result['company_name'], 'identityType' => 1, 'identityCard' => $result['id_card'], 'mobile' => $result['account'], 'noNeedVerify' => 1, 'signLevel' => 1]], + 'url' => $result['contract']['file'] + ]; + $res = app(JunziqianController::class)->Signing($data); + if ($res->success == true) { + Db::name('contract')->where('admin_id', $params['id'])->update(['contract_no' => $res->data]); + $data = array( + "applyNo" => $res->data, //TODO * + "fullName" => $result['company_name'], //TODO * + "identityCard" => $result['id_card'], //TODO * + "identityType" => 1, //TODO * + ); + $res = app(JunziqianController::class)->SigningLink($data); + if ($res->success == true) { + Db::name('contract')->where('admin_id', $params['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('生成合同成功失败,联系管理员'); + } + } -} \ No newline at end of file + //**发送短信 */ + public function postsms() + { + $params = Request::param(); + $admin=Db::name('admin')->where('id',$params['id'])->find(); + $find = Db::name('contract')->where('admin_id', $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/logic/CompanyLogic.php b/app/adminapi/logic/CompanyLogic.php index 38ccdb8e5..9fc5b472f 100644 --- a/app/adminapi/logic/CompanyLogic.php +++ b/app/adminapi/logic/CompanyLogic.php @@ -177,9 +177,9 @@ class CompanyLogic extends BaseLogic ->withAttr('party_a_name',function($value,$data){ return Db::name('company')->where('id',$data['party_a'])->value('company_name'); }) - ->withAttr('contract_type_two_url',function($value,$data){ - return Db::name('dict_data')->where('id',$data['contract_type_two'])->value('value'); - }) + // ->withAttr('contract_file_url',function($value,$data){ + // return Db::name('dict_data')->where('id',$data['contract_type_two'])->value('value'); + // }) ->find(); } return $data; diff --git a/app/adminapi/logic/auth/AdminLogic.php b/app/adminapi/logic/auth/AdminLogic.php index e59217d79..e2e93a2fc 100755 --- a/app/adminapi/logic/auth/AdminLogic.php +++ b/app/adminapi/logic/auth/AdminLogic.php @@ -225,6 +225,11 @@ class AdminLogic extends BaseLogic 'multipoint_login', 'avatar', 'sex', 'province', 'city', 'area', 'street', 'address', 'qualification', 'is_contract', 'id_card' ])->findOrEmpty($params['id'])->toArray(); $admin['qualification'] = json_decode($admin['qualification'], true); + $admin['contract']=Db::name('contract')->where('admin_id',$params['id']) + ->withAttr('contract_type_name',function($value,$data){ + return Db::name('dict_data')->where('id',$data['contract_type'])->value('name'); + }) + ->find(); if ($action == 'detail') { return $admin; }