add:商户合同发起签约

This commit is contained in:
chenbo 2023-09-13 19:16:10 +08:00
parent a156b5fed1
commit 75a92c381e
6 changed files with 112 additions and 5 deletions

View File

@ -173,7 +173,7 @@ class ShopContractLogic extends BaseLogic
'url' => $result['contract']['file'],
];
$res = app(JunziqianController::class)->Signing($data, $result['contract']['id']);
$res = app(JunziqianController::class)->shopContractSigning($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']]);
@ -241,8 +241,8 @@ class ShopContractLogic extends BaseLogic
$sms = [
'mobile' => $v['master_phone'],
'name' => $v['fullName'],
'type' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $find['id'].'&type='.$v['type'],
'type' => '《商户入驻合同》',
'code' => 'api/Hetong/url?id=' . $find['id'].'&type='.$v['type'].'&sign_type=shop_contract',
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);

View File

@ -15,6 +15,10 @@
namespace app\adminapi\logic;
use app\common\model\auth\Admin;
use app\common\model\Company;
use app\common\model\contract\Contract;
use app\common\model\contract\ShopContract;
use app\common\model\ShopMerchant;
use app\common\logic\BaseLogic;
use think\facade\Db;
@ -101,6 +105,16 @@ class ShopMerchantLogic extends BaseLogic
*/
public static function detail($params): array
{
return ShopMerchant::findOrEmpty($params['id'])->toArray();
$data = ShopMerchant::findOrEmpty($params['id'])->toArray();
if ($data) {
$where[]=['party_b','=', $data['id']];
if(isset($params['contract_type'])){
$where[]=['contract_type','=',$params['contract_type']];
}
$data['contract'] = ShopContract::where($where)->with(['party_a_info', 'contractType'])->find();
}
return $data;
// return ShopMerchant::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -122,6 +122,31 @@ class IndexController extends BaseApiController
}
return json(['success' => true, 'msg' => '成功']);
}
/**商户合同签约回调 */
public function shopContractNotifyUrl()
{
$a = Request()->get();
Log::info(['商户合同签约回调', $a]);
// 获取合同详情
if ($a) {
$find = Db::name('contract')->where('id', $a['id'])->find();
if ($find) {
// 合同一方已签约
if ($find['signing_timer'] == 0) {
Db::name('shop_contract')->where('id', $a['id'])->update(['signing_timer' => 1]);
return true;
} else if ($find['signing_timer'] == 1) {
// 合同另一方已签约,修改合同状态,修改公司状态
Db::name('shop_contract')->where('id', $a['id'])->update(['status' => 1, 'signing_timer' => 2]);
Db::name('shop_merchant')->where('id', $find['party_a'])->update(['status' => 1, 'is_contract' => 1]);
Db::name('shop_merchant')->where('id', $find['party_b'])->update(['status' => 1, 'is_contract' => 1]);
// todo 通知商城,商户签约完成
}
}
}
return json(['success' => true, 'msg' => '成功']);
}
//镇街车辆租赁回调
public function townCarRent() {

View File

@ -184,6 +184,26 @@ class JunziqianController extends BaseApiController
$response = $requestUtils->doPost("/v2/sign/applySign", $request);
return $response;
}
public function shopContractSigning($data, $id, $notify = '')
{
if ($notify == '') {
$notify = env('url.url_prefix') . '/shop_contract_notify_url';
}
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$request = new ApplySignReq();
$request->contractName = $data['name'];
$request->signatories = $data['signatories']; //签约方
// $request->faceThreshold = 79; // 人脸识别阀值:默认等级(1-100之间整数),建议范围(60-79)
$request->serverCa = 1; //是否需要服务端云证书
$request->fileType = 1; //合同上传方式 url
$request->url = $data['url'];
$request->notifyUrl = $notify . '?id=' . $id;
$request->needQifengSign = 1;
//发起PING请求
// halt($request);
$response = $requestUtils->doPost("/v2/sign/applySign", $request);
return $response;
}
// 企业人脸校验上传
public function OrganizationFaceCreate($data)

View File

@ -3,8 +3,55 @@
namespace app\common\model\contract;
use app\common\model\BaseModel;
use app\common\model\Company;
use app\common\model\dict\DictData;
use app\common\model\ShopMerchant;
class ShopContract extends BaseModel
{
protected $name = 'shop_contract';
/**
* @notes 关联company_name
* @return \think\model\relation\HasOne
* @author likeadmin
* @date 2023/07/18 14:28
*/
public function companyName()
{
return $this->hasOne(ShopMerchant::class, 'id', 'company_id')->bind(['company_name']);
}
public function company()
{
return $this->hasOne(ShopMerchant::class, 'id', 'company_id');
}
public function partyAInfo()
{
return $this->hasOne(ShopMerchant::class, 'id', 'party_a')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager');
}
public function partyBInfo()
{
// halt($this->type);
// if($this->type==1){
return $this->hasOne(ShopMerchant::class, 'id', 'party_b')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager');
// }else{
// return $this->hasOne(User::class, 'id', 'party_b')->field('id,nickname company_name');
// }
}
public function partyA()
{
return $this->hasOne(ShopMerchant::class, 'id', 'party_a')->bind(['party_a_name' => 'company_name']);
}
public function partyB()
{
return $this->hasOne(ShopMerchant::class, 'id', 'party_b')->bind(['party_b_name' => 'company_name']);
}
public function contractType()
{
return $this->hasOne(DictData::class, 'id', 'contract_type')->bind(['contract_type_name' => 'name']);
}
public function getContractTypeNameAttr($value)
{
return DictData::where(['id' => $this->contract_type])->value('name');
}
}

View File

@ -36,4 +36,5 @@ Route::rule('crontab', function () {
Route::post('/notify_url', IndexController::class . '@notifyUrl');
Route::post('/notifyAuthentication',IndexController::class . '@notifyAuthentication');
Route::get('/api/junziqian/download_file',JunziqianController::class . '@download_file');
Route::get('/api/junziqian/download_file',JunziqianController::class . '@download_file');
Route::post('/shop_contract_notify_url', IndexController::class . '@shopContractNotifyUrl');