admin page update

This commit is contained in:
unknown 2023-09-05 15:05:14 +08:00
parent fc7c4cd8c5
commit 6c074f18b0
3 changed files with 15 additions and 14 deletions

View File

@ -10,8 +10,6 @@ use app\common\model\platform\Platform;
class ContractController extends BaseAdminController class ContractController extends BaseAdminController
{ {
private $domain = 'https://worker-task.lihaink.cn';
public function initiatingContract() { public function initiatingContract() {
//获取参数 //获取参数
$params = $this->request->post(['id']); $params = $this->request->post(['id']);
@ -43,7 +41,7 @@ class ContractController extends BaseAdminController
]); ]);
$this->sendSms($params['id']); $this->sendSms($params['id']);
$newData = Contract::where('id', $params['id'])->find(); $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_logistic_id' => $contract['id'],
'contract_no' => $signRes->data, 'contract_no' => $signRes->data,
'url' => $newData['url'], 'url' => $newData['url'],

View File

@ -120,10 +120,14 @@ class IndexController extends BaseApiController
if(empty($vehicle)){ if(empty($vehicle)){
return json(['success' => false, 'msg' => '更新失败']); 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]); Vehicle::where('id','in',array_column($vehicle,'id'))->update(['status'=>2]);
//添加车辆到租赁列表
$data = []; $data = [];
foreach($vehicle as $v){ foreach($vehicle as $v){
$data[] = [ $data[] = [
@ -146,7 +150,8 @@ class IndexController extends BaseApiController
curl_post(env('project.notify_domain').'/api/index/notifyVehicleContractUpdate',[],[ curl_post(env('project.notify_domain').'/api/index/notifyVehicleContractUpdate',[],[
'contract_logistic_id' => $contract['id'], 'contract_logistic_id' => $contract['id'],
'signing_timer' => 2, 'signing_timer' => 2,
'status' => 3 'status' => 3,
'contract_url'=>$signContractFile
]); ]);
} }
return json(['success' => true, 'msg' => '成功']); return json(['success' => true, 'msg' => '成功']);

View File

@ -2,6 +2,7 @@
namespace app\api\controller; namespace app\api\controller;
use app\common\model\contract\Contract;
use app\Request; use app\Request;
use junziqian\sdk\bean\req\sign\ApplySignReq; use junziqian\sdk\bean\req\sign\ApplySignReq;
use junziqian\sdk\bean\req\user\OrganizationCreateReq; use junziqian\sdk\bean\req\user\OrganizationCreateReq;
@ -183,7 +184,6 @@ class JunziqianController extends BaseApiController
$request->htmlContent = $data['content']; $request->htmlContent = $data['content'];
$request->notifyUrl = env('project.website_domain').'/api/index/notifyUrl?id='.$id; $request->notifyUrl = env('project.website_domain').'/api/index/notifyUrl?id='.$id;
$request->needQifengSign = 1; $request->needQifengSign = 1;
//发起PING请求 //发起PING请求
$response = $requestUtils->doPost("/v2/sign/applySign", $request); $response = $requestUtils->doPost("/v2/sign/applySign", $request);
return $response; return $response;
@ -192,27 +192,25 @@ class JunziqianController extends BaseApiController
public function download_file($applyNo) public function download_file($applyNo)
{ {
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret); $requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$find = Db::name('contract')->where('contract_no', $applyNo)->value('contract_url'); $contract_url = Contract::where('contract_no', $applyNo)->value('contract_url');
if ($find) { if ($contract_url && !empty($contract_url)) {
return $this->success('获取成功', ['url' => env('project.notify_domain').$find]); return $contract_url;
} }
//初始化请求参数 //初始化请求参数
$request = array( $request = array(
"applyNo" => $applyNo, //TODO + "applyNo" => $applyNo, //TODO +
); );
$response = $requestUtils->doPost("/v2/sign/linkFile", $request); $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'); $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 env('project.website_domain').'/uploads/contract/' . $applyNo . '.pdf';
return $this->success('获取成功', ['url' => env('project.notify_domain').$applyNo . '.pdf']);
} else { } else {
return $this->fail('获取失败'); return false;
} }
} }
public function getDownload($url, $publicDir = '', $fileName = '', $type = 0) public function getDownload($url, $publicDir = '', $fileName = '', $type = 0)
{ {
//获取文件路径 //获取文件路径
$newOneDir = substr($publicDir, 0, strrpos($publicDir, "/")); $newOneDir = substr($publicDir, 0, strrpos($publicDir, "/"));
if (trim($url) == '') { if (trim($url) == '') {