diff --git a/app/common/dao/common/ContractDao.php b/app/common/dao/common/ContractDao.php index 009963b..d46967b 100644 --- a/app/common/dao/common/ContractDao.php +++ b/app/common/dao/common/ContractDao.php @@ -9,6 +9,8 @@ use FddCloud\client\Client; use FddCloud\client\ServiceClient; use think\exception\ValidateException; use think\facade\Cache; +use think\facade\Route; +use think\facade\Route as Url; class ContractDao extends BaseDao{ @@ -194,6 +196,20 @@ class ContractDao extends BaseDao{ 'autoFillFinalize' => true, // 参与方列表 参与方信息 'actors' => [ + [ + 'actor' => [ + // 参与方标识。在同一个签署任务中,参与方标识唯一,不允许重复;例如:甲方、乙方、丙方 + 'actorId' => '甲方', + // 参与方主体类型: corp: 企业;person: 个人 + 'actorType' => 'corp', + // 参与方具体名称。长度最大128个字符。 + 'actorName' => '万马奔鸿数易科技有限公司', + // 参与方权限 fill:填写;sign:签署;cc:抄送 + 'permissions' => ['fill','sign'], + // 参与方主体在应用上的OpenId;openCorpId/openUserId + 'actorOpenId' => $config['open_corp_id'], + ], + ], [ 'actor' => [ // 参与方标识。在同一个签署任务中,参与方标识唯一,不允许重复;例如:甲方、乙方、丙方 @@ -250,6 +266,39 @@ class ContractDao extends BaseDao{ throw new ValidateException($result['msg']); } } + /** + * Common: 法大大 - 接口请求 - 获取企业签署链接 + * Author: wu-hui + * Time: 2024/07/05 17:52 + * @param array $authInfo + * @return array|mixed + */ + public function enterpriseActorGetUrl(array $authInfo){ + $link = get_file_link('/admin/marketing/contract/list'); + $config = app()->make(ContractRepository::class)->getConfig(); + + $bizContent = [ + // 签署任务ID + 'signTaskId' => $authInfo['sign_task_id'], + // 参与方标识。在同一个签署任务中,参与方标识唯一,不允许重复;例如:甲方、乙方、丙方 + 'actorId' => '甲方', + // 应用系统中唯一确定登录用户身份的标识 + 'actorOpenId' => $config['open_corp_id'], + // 重定向地址,系统判断在非小程序环境下会跳转至该地址。 + 'redirectUrl' => $link, + // 小程序的重定向地址(微信和支付宝) + // 'redirectMiniAppUrl' => '', + ]; + $result = $this->requestApi($bizContent, '/sign-task/actor/get-url'); + if($result['code'] == 100000){ + + return $result['data'] ?? []; + }else{ + throw new ValidateException($result['msg']); + } + } + + /** * Common: 法大大 - 接口请求 - 获取签署文档下载地址 * Author: wu-hui diff --git a/app/common/repositories/common/ContractRepository.php b/app/common/repositories/common/ContractRepository.php index a7935fc..fcadd53 100644 --- a/app/common/repositories/common/ContractRepository.php +++ b/app/common/repositories/common/ContractRepository.php @@ -110,8 +110,8 @@ class ContractRepository extends BaseRepository{ foreach($templateList as $tempKey => $tempItem){ $currentInfo = $config['template_list'][$tempKey] ?? []; - if($currentInfo) $config['template_list'][$tempKey] = $currentInfo; - else $config['template_list'][$tempKey] = $tempItem; + if($currentInfo) $config['template_list'][$tempKey] = (array)$currentInfo; + else $config['template_list'][$tempKey] = (array)$tempItem; } return $config; @@ -183,6 +183,20 @@ class ContractRepository extends BaseRepository{ $authInfo = $this->getSearchModel(['id' => $id])->findOrEmpty()->toArray(); return $this->dao->ownerGetDownloadUrl((array)$authInfo); } + /** + * Common: 获取企业签署链接 + * Author: wu-hui + * Time: 2024/07/05 17:52 + * @param $id + * @return array|mixed + */ + public function enterpriseSignInfo($id){ + $authInfo = $this->getSearchModel(['id' => $id])->findOrEmpty()->toArray(); + + return $this->dao->enterpriseActorGetUrl((array)$authInfo); + } + + /** @@ -214,6 +228,12 @@ class ContractRepository extends BaseRepository{ 'rejected_reason' => $bizContent['fillRejectReason'] ],['sign_task_id' => $bizContent['signTaskId']]); } + if($bizContent['actorId'] == '甲方'){ + (new Contract())->update([ + 'enterprise_status' => 2, + 'enterprise_rejected_reason' => $bizContent['fillRejectReason'] + ],['sign_task_id' => $bizContent['signTaskId']]); + } } /** * Common: 异步通知 - 合同签署成功 @@ -227,6 +247,11 @@ class ContractRepository extends BaseRepository{ 'sign_status' => 1, ],['sign_task_id' => $bizContent['signTaskId']]); } + if($bizContent['actorId'] == '甲方'){ + (new Contract())->update([ + 'enterprise_status' => 1, + ],['sign_task_id' => $bizContent['signTaskId']]); + } } diff --git a/app/controller/admin/common/Contract.php b/app/controller/admin/common/Contract.php index f8f2730..fd925ff 100644 --- a/app/controller/admin/common/Contract.php +++ b/app/controller/admin/common/Contract.php @@ -73,6 +73,18 @@ class Contract extends BaseController{ return app('json')->success($result); } + /** + * Common: 获取企业签署链接 + * Author: wu-hui + * Time: 2024/07/05 17:53 + * @param $id + * @return mixed + */ + public function signInfo($id){ + $result = $this->repository->enterpriseSignInfo($id); + + return app('json')->success($result); + } } diff --git a/app/controller/api/Common.php b/app/controller/api/Common.php index 960af4e..e9b02cc 100644 --- a/app/controller/api/Common.php +++ b/app/controller/api/Common.php @@ -669,7 +669,7 @@ class Common extends BaseController $bizContent = $params['bizContent'] ?? []; $bizContent = json_decode($bizContent, true) ?? []; $notifyEvent = (string)request()->header('X-FASC-Event'); - // Log::info('法大大 - 异步通知:'.var_export(['header'=>$notifyEvent,'bizContent'=>$bizContent],TRUE)); + Log::info('法大大 - 异步通知:'.var_export(['header'=>$notifyEvent,'bizContent'=>$bizContent],TRUE)); // 根据类型和结果进行对应的操作 switch($notifyEvent){ // 个人授权异步通知 diff --git a/app/controller/api/common/Contract.php b/app/controller/api/common/Contract.php index 27a6f4f..c1c1a1a 100644 --- a/app/controller/api/common/Contract.php +++ b/app/controller/api/common/Contract.php @@ -51,5 +51,27 @@ class Contract extends BaseController{ return app('json')->success($info); } + /** + * Common: 法大大 - 重新发起合同签署 + * Author: wu-hui + * Time: 2024/07/05 16:55 + * @return mixed + */ + public function againSign(){ + $id = $this->request->param('id', 0); + // 清除信息 + (new \app\common\model\common\Contract())->update([ + 'sign_status' => 0, + 'sign_task_id' => null, + 'sign_task_subject' => null, + 'sign_template_id' => null, + 'rejected_reason' => null, + ],['id' => $id]); + $info = $this->repository->getSignInfo((int)$id); + + return app('json')->success($info); + } + + } diff --git a/route/admin/marketing.php b/route/admin/marketing.php index 5622428..8c67eea 100644 --- a/route/admin/marketing.php +++ b/route/admin/marketing.php @@ -565,6 +565,7 @@ Route::group(function () { Route::get('get_config','getConfig')->name('systemMarketingContractConfigGet'); Route::post('set_config','setConfig')->name('systemMarketingContractConfigSet'); Route::get('download/:id','downloadInfo')->name('systemMarketingContractDownloadInfo'); + Route::get('sign_info/:id','signInfo')->name('systemMarketingContractSignInfo'); })->prefix('admin.common.Contract/'); diff --git a/route/api.php b/route/api.php index 8a8abf6..5f2566f 100644 --- a/route/api.php +++ b/route/api.php @@ -496,10 +496,7 @@ Route::group('api/', function () { Route::group('contract', function () { Route::get('auth_info', 'authInfo');// 获取个人授权信息 Route::get('get_sign_info', 'getSignInfo');// 获取合同签署信息 - - - - + Route::get('again_sign', 'againSign');// 重新发起合同签署 })->prefix('api.common.Contract/');