request->post(['id']); if(empty($params['id'])){ return $this->fail('缺少必要参数'); } //获取数据 $contract = Contract::where('id',$params['id'])->find(); if(empty($contract)){ return $this->fail('数据不存在'); } if($contract['status'] != 1){ return $this->fail('合同状态错误'); } $signData = [ 'name' => $contract['company_a_name'] . '的合同', 'signatories' => [ ['fullName' => $contract['company_a_name'], 'identityType' => 12, 'identityCard' => $contract['company_a_code'], 'email' => $contract['company_a_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) { $contract->save([ 'id' => $contract['id'], 'contract_no' => $signRes->data, 'status' => 2 ]); $this->sendSms($params['id']); $newData = Contract::where('id', $params['id'])->find(); curl_post($this->domain.'/api/index/notifyVehicleContractUpdate',[],[ 'contract_logistic_id' => $contract['id'], 'contract_no' => $signRes->data, 'url' => $newData['url'], 'status' => 2 ]); return $this->success('合同发送成功'); } else { return $this->fail($signRes->msg); } } public function sendSmsAgain() { //获取参数 $id = $this->request->post('id'); if(empty($id)){ return $this->fail('参数错误'); } //获取数据 $contract = Contract::where('id',$id)->find(); if(empty($contract)){ return $this->fail('数据错误'); } $this->sendSms($id); return $this->success('发送成功'); } public function sendSms($id) { //获取合同数据 $contract = Contract::where('id',$id)->find(); if (!empty($contract) && $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; } } public function lists() { $param = $this->request->get(); $where = []; if(isset($param['company_user'])){ $where[] = ['company_b_user','like','%'.$param['company_user'].'%']; } if(isset($param['company_phone'])){ $where[] = ['company_b_phone','like','%'.$param['company_phone'].'%']; } $pageNo = !empty($param['page_no']) ? $param['page_no'] : 1; $pageSize = !empty($param['page_size']) ? $param['page_size'] : 15; $data = Contract::whereor($where) ->page($pageNo, $pageSize) ->order('create_time desc') ->select()->each(function($item){ $item['cars_info'] = json_decode($item['cars_info'],true); }); return $this->success('success',['lists'=>$data->toArray(),'page_no'=>$pageNo,'page_size'=>$pageSize,'count'=>$data->count()]); } public function detail() { //获取参数 $id = $this->request->get('id'); if(empty($id)) { return $this->fail('参数错误'); } $data = Contract::where('id',$id)->find(); if(empty($data)){ return $this->fail('没找到数据'); } $data['cars_info'] = json_decode($data['cars_info'],true); return $this->success('success',$data->toArray()); } }