diff --git a/app/adminapi/controller/contract/ContractController.php b/app/adminapi/controller/contract/ContractController.php index 20025a38..951e17a0 100644 --- a/app/adminapi/controller/contract/ContractController.php +++ b/app/adminapi/controller/contract/ContractController.php @@ -10,8 +10,6 @@ use app\common\model\platform\Platform; class ContractController extends BaseAdminController { - private $domain = 'https://worker-task.lihaink.cn'; - public function initiatingContract() { //获取参数 $params = $this->request->post(['id']); @@ -43,7 +41,7 @@ class ContractController extends BaseAdminController ]); $this->sendSms($params['id']); $newData = Contract::where('id', $params['id'])->find(); - curl_post($this->domain.'/api/index/notifyVehicleContractUpdate',[],[ + curl_post(env('project.notify_domain').'/api/index/notifyVehicleContractUpdate',[],[ 'contract_logistic_id' => $contract['id'], 'contract_no' => $signRes->data, 'url' => $newData['url'], diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 98549c90..b7889139 100755 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -120,10 +120,14 @@ class IndexController extends BaseApiController if(empty($vehicle)){ return json(['success' => false, 'msg' => '更新失败']); } + //获取签约后的合同 + $signContractFile = app(JunziqianController::class)->download_file($contract['contract_no']); + $signContractFile = $signContractFile ?? ''; //更新本地合同状态 - Contract::where('id',$params['id'])->update(['signing_timer'=>2,'status'=>3]); + Contract::where('id',$params['id'])->update(['signing_timer'=>2,'status'=>3,'contract_url'=>$signContractFile]); //更新本地车辆状态 Vehicle::where('id','in',array_column($vehicle,'id'))->update(['status'=>2]); + //添加车辆到租赁列表 $data = []; foreach($vehicle as $v){ $data[] = [ @@ -146,7 +150,8 @@ class IndexController extends BaseApiController curl_post(env('project.notify_domain').'/api/index/notifyVehicleContractUpdate',[],[ 'contract_logistic_id' => $contract['id'], 'signing_timer' => 2, - 'status' => 3 + 'status' => 3, + 'contract_url'=>$signContractFile ]); } return json(['success' => true, 'msg' => '成功']); diff --git a/app/api/controller/JunziqianController.php b/app/api/controller/JunziqianController.php index e8c9e8e9..4b98ca5f 100644 --- a/app/api/controller/JunziqianController.php +++ b/app/api/controller/JunziqianController.php @@ -2,6 +2,7 @@ namespace app\api\controller; +use app\common\model\contract\Contract; use app\Request; use junziqian\sdk\bean\req\sign\ApplySignReq; use junziqian\sdk\bean\req\user\OrganizationCreateReq; @@ -183,7 +184,6 @@ class JunziqianController extends BaseApiController $request->htmlContent = $data['content']; $request->notifyUrl = env('project.website_domain').'/api/index/notifyUrl?id='.$id; $request->needQifengSign = 1; - //发起PING请求 $response = $requestUtils->doPost("/v2/sign/applySign", $request); return $response; @@ -192,27 +192,25 @@ class JunziqianController extends BaseApiController public function download_file($applyNo) { $requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret); - $find = Db::name('contract')->where('contract_no', $applyNo)->value('contract_url'); - if ($find) { - return $this->success('获取成功', ['url' => env('project.notify_domain').$find]); + $contract_url = Contract::where('contract_no', $applyNo)->value('contract_url'); + if ($contract_url && !empty($contract_url)) { + return $contract_url; } //初始化请求参数 $request = array( "applyNo" => $applyNo, //TODO + ); $response = $requestUtils->doPost("/v2/sign/linkFile", $request); - if ($response->success == true) { + if ($response->success) { $this->getDownload($response->data, root_path() . 'public/uploads/contract/' . $applyNo . '.pdf'); - Db::name('contract')->where('contract_no', $applyNo)->update(['contract_url' => '/uploads/contract/' . $applyNo . '.pdf']); - return $this->success('获取成功', ['url' => env('project.notify_domain').$applyNo . '.pdf']); + return env('project.website_domain').'/uploads/contract/' . $applyNo . '.pdf'; } else { - return $this->fail('获取失败'); + return false; } } public function getDownload($url, $publicDir = '', $fileName = '', $type = 0) { - //获取文件路径 $newOneDir = substr($publicDir, 0, strrpos($publicDir, "/")); if (trim($url) == '') {