From 8d78ef853e61c600a465637154017d966e58d373 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Wed, 13 Sep 2023 18:17:08 +0800 Subject: [PATCH] =?UTF-8?q?update:=E5=95=86=E6=88=B7=E5=90=88=E5=90=8C?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/logic/ShopContractLogic.php | 111 ++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/app/adminapi/logic/ShopContractLogic.php b/app/adminapi/logic/ShopContractLogic.php index d89516aad..706f15199 100644 --- a/app/adminapi/logic/ShopContractLogic.php +++ b/app/adminapi/logic/ShopContractLogic.php @@ -16,7 +16,10 @@ namespace app\adminapi\logic; use app\api\controller\JunziqianController; +use app\api\logic\SmsLogic; +use app\common\logic\CompanyLogic; use app\common\logic\contract\ContractLogic; +use app\common\logic\UserLogic; use app\common\model\ShopContract; use app\common\logic\BaseLogic; use app\common\model\ShopMerchant; @@ -130,7 +133,6 @@ class ShopContractLogic extends BaseLogic return $data['status'] == 1 ? '已签约' : '未签约'; }) ->find(); - dd($data); $data['signed_contract_url'] = self::getSignedContract($data); return $data; } @@ -150,4 +152,111 @@ class ShopContractLogic extends BaseLogic } return $signedContractUrl; } + + + // /**发送合同 */ + public static function Draftingcontracts($params,$type=1) + { + $result = ShopMerchantLogic::detail($params); + if ($result && isset($result['contract']) && isset($result['contract']['file']) && $result['contract']['file'] != '') { + if ($result['contract']['check_status'] == 3) { + return self::setError('你已经生成过合同,请勿重复生成'); + } + + $name=$result['company_name']; + $data = [ + 'name' => $name . '的合同', + 'signatories' => [ + ['fullName' => $name, 'identityType' => 12, 'identityCard' => $result['organization_code'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1], // 'authLevel'=>[11], 签约时验证人脸识别 + ['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('shop_contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data, 'check_status' => 3]); + self::postsms(['id'=>$result['contract']['id']]); + return true; + } else { + return self::setError($res->msg); + } + } else { + return self::setError('生成合同成功失败,联系管理员'); + } + } + + //**发送短信 */ + public static function postsms($params) + { + $result = self::detail($params); + if ($result && $result['file'] != '') { + //发送短信 + $data = [ + [ + "applyNo" => $result['contract_no'], //TODO * + "fullName" => $result['party_a_info']['company_name'], //TODO * + "identityCard" => $result['party_a_info']['organization_code'], //TODO * + "identityType" => 12, //TODO * + "master_phone" => $result['party_a_info']['master_phone'], + "type"=>"party_a" + ], + ]; + if($result['type']==1){ + $data[]= [ + "applyNo" => $result['contract_no'], //TODO * + "fullName" => $result['party_b_info']['company_name'], //TODO * + "identityCard" => $result['party_b_info']['organization_code'], //TODO * + "identityType" => 12, //TODO * + "master_phone" => $result['party_b_info']['master_phone'], + "type"=>"party_b" + + ]; + }else{ + $data[]= [ + "applyNo" => $result['contract_no'], //TODO * + "fullName" => $result['party_b_info']['nickname'], //TODO * + "identityCard" => $result['party_b_info']['id_card'], //TODO * + "identityType" => 1, //TODO * + "master_phone" => $result['party_b_info']['mobile'], + "type"=>"party_b" + + ]; + } + $find = Db::name('shop_contract')->where('id', $params['id']) + ->withAttr('contract_type_name', function ($value, $data) { + return Db::name('dict_data')->where('id', $data['contract_type'])->value('name'); + })->find(); + + $url = []; + foreach ($data as $k => $v) { + $res = app(JunziqianController::class)->SigningLink($v); + if ($res->success == true) { + if ($v['type'] == 'party_a') { + $url['party_a'] =$res->data; + } else { + $url['party_b'] =$res->data; + } + //发送短信 + $sms = [ + 'mobile' => $v['master_phone'], + 'name' => $v['fullName'], + 'type' => '《' . $find['contract_type_name'] . '》', + 'code' => 'api/Hetong/url?id=' . $find['id'].'&type='.$v['type'], + 'scene' => 'WQ' + ]; + $result = SmsLogic::contractUrl($sms); + if ($result != true) { + return self::setError(SmsLogic::getError()); + } + } else { + return self::setError($res->msg); + } + } + Db::name('contract')->where('id', $find['id'])->update(['url' => json_encode($url)]); + return true; + }else{ + return self::setError('没找到合同,联系管理员'); + } + } } \ No newline at end of file