request->post(['id']); if(empty($params['id'])){ return $this->fail('缺少必要参数'); } //获取数据 $contract = Contract::where('id',$params['id'])->find(); if(!$contract || $contract->isEmpty()){ return $this->fail('数据不存在'); } if($contract['status'] == 3 || $contract['status'] == 4){ return $this->fail('合同已发送'); } //获取平台公司 $platform = Platform::find(1); $signData = [ 'name' => $platform['company_name'] . '的合同', 'signatories' => [ ['fullName' => $platform['company_name'], 'identityType' => 12, 'identityCard' => $platform['company_organization_code'], 'email' => $platform['company_email'], 'noNeedVerify' => 1, 'signLevel' => 1], ['fullName' => $contract['company_b_name'], 'identityType' => 12, 'identityCard' => $contract['company_b_code'], 'email' => $contract['company_b_email'], 'noNeedVerify' => 1, 'signLevel' => 1] ], 'url' => $contract['file'] ]; $signRes = app(JunziqianController::class)->Signing($signData, $params['id']); if ($signRes->success) { $a = $contract->save([ 'id' => $contract['id'], 'contract_no' => $signRes->data, 'status' => 3 ]); $this->sendSms($params['id']); $newData = Contract::where('id', $params['id'])->find(); curl_post('https://worker-task.lihaink.cn/api/index/notifyVehicleContractUpdate',[],[ 'id' => $contract['id'], 'contract_no' => $signRes->data, 'url' => $newData['url'], 'status' => 3 ]); return $this->success('合同发送成功'); } else { return $this->fail($signRes->msg); } } public function sendSms($id) { //获取合同数据 $contract = Contract::where('id',$id)->find(); if ($contract && !$contract->isEmpty() && $contract['file'] != '') { //发送短信 $data = [ //甲方 [ "applyNo" => $contract['contract_no'], "fullName" => $contract['company_a_name'], "identityCard" => $contract['company_a_code'], "identityType" => 12, "master_phone" => $contract['company_a_phone'], "type"=>"party_a" ], //乙方 [ "applyNo" => $contract['contract_no'], "fullName" => $contract['company_b_name'], "identityCard" => $contract['company_b_code'], "identityType" => 12, "master_phone" => $contract['company_b_phone'], "type"=>"party_b" ], ]; $url = []; foreach ($data as $v) { $res = app(JunziqianController::class)->SigningLink($v); if (!$res->success) { return false; } 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' => '《租赁合同》', 'code' => 'api/Hetong/url?id='.$id.'&type='.$v['type'], 'scene' => 'CLZL' ]; $scene = NoticeEnum::getSceneByTag($sms['scene']); if (empty($scene)) { throw new \Exception('场景值异常'); } event('Notice', [ 'scene_id' => $scene, 'params' => $sms ]); } Contract::where('id', $id)->update(['url' => json_encode($url)]); return true; }else{ return false; } } }