签名更新

This commit is contained in:
mkm 2023-07-18 18:05:58 +08:00
parent 86bba7997e
commit 00968bcb86
4 changed files with 82 additions and 28 deletions

View File

@ -20,7 +20,11 @@ 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 think\App;
use think\facade\Db;
use think\view\driver\Think;
/**
* Company控制器
@ -52,8 +56,8 @@ class CompanyController extends BaseAdminController
public function add()
{
$params = (new CompanyValidate())->post()->goCheck('add');
$params['other_contacts']=json_encode($params['other_contacts']);
$params['qualification']=json_encode($params['qualification']);
$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);
@ -71,8 +75,8 @@ class CompanyController extends BaseAdminController
public function edit()
{
$params = (new CompanyValidate())->post()->goCheck('edit');
$params['other_contacts']=json_encode($params['other_contacts']);
$params['qualification']=json_encode($params['qualification']);
$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);
@ -108,5 +112,49 @@ class CompanyController extends BaseAdminController
return $this->data($result);
}
public function Draftingcontracts()
{
}
$params = (new CompanyValidate())->goCheck('detail');
$result = CompanyLogic::detail($params);
if ($result && $result['contract'] && $result['contract']['contract_type_two_url'] != '') {
$data = [
'name' => $result['company_name'],
'signatories' => [['fullName' => $result['master_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']
];
$res = app(JunziqianController::class)->Signing($data);
if ($res->success == true) {
Db::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data]);
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'])->find();
if ($find) {
$data = array(
"applyNo" => $find['contract_no'], //TODO *
"fullName" => $company['master_name'], //TODO *
"identityCard" => $company['organization_code'], //TODO *
"identityType" => 12, //TODO *
);
$res = app(JunziqianController::class)->SigningLink($data);
if ($res->success == true) {
return $this->success('发生成功', [], 1, 1);
} else {
return $this->fail($res->msg);
}
}
}
}
}

View File

@ -75,8 +75,10 @@ class CompanyLogic extends BaseLogic
'update_time'=>time(),
'party_a'=>$contract['party_a'],
'party_b'=>$data['id'],
'type'=>1
];
Db::name('contract')->insert($datas);
$ids=Db::name('contract')->insertGetId($datas);
Company::where('id',$data['id'])->update(['contract_id'=>$ids]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -171,10 +173,13 @@ class CompanyLogic extends BaseLogic
if($data){
$data['other_contacts']=json_decode($data['other_contacts'],true);
$data['qualification']=json_decode($data['qualification'],true);
$data['contract']=Db::name('contract')->where('company_id',$data['id'])
$data['contract']=Db::name('contract')->where('id',$data['contract_id'])
->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');
})
->find();
}
return $data;

View File

@ -63,6 +63,7 @@ class AdminLogic extends BaseLogic
'update_time'=>time(),
'party_a'=>$params['party_a'],
'party_b'=>$admin_id,
'type'=>2
];
Db::name('contract')->insert($datas);
// 角色

View File

@ -29,7 +29,12 @@ class JunziqianController extends BaseApiController
public function index()
{
halt($this->SigningLink());
$data=[
'name'=>'我的合同',
'signatories'=>[ ['fullName' => '小米', 'identityType' => 1, 'identityCard' => '5002401XXXXXXXXX', 'mobile' => 18982406440,'noNeedVerify'=>1,'signLevel'=>1] ],
'url'=>"https://dev.lihaink.cn/storage/202307/acbba88e77392348d3a8a4a1fdf210f1.pdf"
];
halt($this->Signing($data));
}
/**
* 填充签名数据
@ -113,37 +118,32 @@ class JunziqianController extends BaseApiController
return $this->success('', (array)$response);
}
//签约
public function Signing()
public function Signing($data)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//CURLFile 可以传url或filePath但必须保证文件存在且有效否则php不会报错只会导致http请求返回null并没有调到服务端
//初始化合同参数
//[ ['fullName' => '小米', 'identityType' => 1, 'identityCard' => '5002401XXXXXXXXX', 'mobile' => 18982406440,'noNeedVerify'=>1,'signLevel'=>1] ]
$request = new ApplySignReq();
$request->contractName = "合同名称";
$request->signatories = json_encode([
['fullName' => '小米', 'identityType' => 1, 'identityCard' => '5002401XXXXXXXXX', 'mobile' => 18982406440,'noNeedVerify'=>1,'signLevel'=>1]
]);
$request->serverCa = 1; //自动签
$request->fileType = 1;
$request->url = "https://dev.lihaink.cn/storage/202307/acbba88e77392348d3a8a4a1fdf210f1.pdf";
$request->contractName = $data['name'];
$request->signatories = json_encode($data['signatories']);//签约方
$request->serverCa = 1; //是否需要服务端云证书
$request->fileType = 1;//合同上传方式 url
$request->url = $data['url'];
//发起PING请求
$response = $requestUtils->doPost("/v2/sign/applySign", $request);
return $this->success('', (array)$response);
return $response;
// return $this->success('', (array)$response);
}
public function SigningLink()
public function SigningLink($data)
{
//构建请求工具
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//初始化合同参数
$request = array(
"applyNo" => "APL1680880011001217024", //TODO *
"fullName" => "小米", //TODO *
"identityCard" => "5002401XXXXXXXXX", //TODO *
"identityType" => 1, //TODO *
);
$response = $requestUtils->doPost("/v2/sign/link", $request);
return $this->success('', (array)$response);
$response = $requestUtils->doPost("/v2/sign/link", $data);
return $response;
// return $this->success('', (array)$response);
}
}