dev #21

Merged
weiz merged 11 commits from dev into master 2023-11-07 16:57:39 +08:00
30 changed files with 1 additions and 2995 deletions
Showing only changes of commit 6f4650e147 - Show all commits

View File

@ -1,101 +0,0 @@
<?php
namespace app\adminapi\controller\contract;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\contract\ContractLists;
use app\api\logic\SmsLogic;
use app\common\logic\contract\ContractLogic;
use app\common\model\company\Company;
use app\common\model\contract\Contract;
use app\common\model\user\WorkerUser;
use think\facade\Db;
use think\response\Json;
/**
* 合同控制器
* Class ContractController
* @package app\adminapi\controller\contract
*/
class ContractController extends BaseAdminController
{
public function lists(): Json
{
return $this->dataLists(new ContractLists());
}
public function detail(): Json
{
$params = $this->request->get(['id']);
$result = ContractLogic::detail($params);
return $this->data($result);
}
public function wind_control(): Json
{
$params = $this->request->param();
$file = $params['file'];
$res = Contract::where('id', $params['id'])->update(['file' => $file, 'check_status' => 2]);
if ($res) {
$find = Contract::where('id', $params['id'])->with(['party_a_info'])->field('type,party_b,party_a')
->find()->toArray();
if ($find['type'] == 1) {
$find['party_b_info'] = Company::where('id', $find['party_b'])->field('company_name name,master_phone phone')->find()->toArray();
} else {
$find['party_b_info'] = WorkerUser::where('id', $find['party_b'])->field('nickname name,mobile phone')->find()->toArray();
}
$a = [
'mobile' => $find['party_a_info']['master_phone'],
'name' => $find['party_a_info']['company_name'],
'scene' => 'WQTZ'
];
SmsLogic::contractUrl($a);
$b = [
'mobile' => $find['party_b_info']['phone'],
'name' => $find['party_b_info']['name'],
'scene' => 'WQTZ'
];
SmsLogic::contractUrl($b);
return $this->success('上传成功', [], 1, 1);
} else {
if ($res == 0) {
return $this->success('没有更新', [], 1, 1);
}
return $this->fail('上传失败');
}
}
public function postsms()
{
$params = $this->request->param();
$find = Db::connect('mysql2')->name('la_contract')->where('id', $params['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::connect('mysql2')->name('la_dict_data')->where('id', $data['contract_type'])->value('name');
})
->withAttr('user_info', function ($value, $data) {
if ($data['type'] == 1) {
return Db::connect('mysql2')->name('la_admin')->where('id', $data['party_b'])->field('name,phone')->find();
} else {
return Db::connect('mysql2')->name('la_user')->where('id', $data['party_b'])->field('nickname name,mobile phone')->find();
}
})
->find();
if ($find && $find['url'] != '') {
//发送短信
$sms = [
'mobile' => $find['user_info']['phone'],
'name' => $find['user_info']['name'],
'type' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $find['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return $this->success('发送成功');
} else {
return $this->fail(SmsLogic::getError());
}
}
}
}

View File

@ -1,300 +0,0 @@
<?php
namespace app\adminapi\controller\contract;
use app\adminapi\controller\BaseAdminController;
use app\common\controller\JunziqianController;
use app\common\enum\notice\NoticeEnum;
use app\common\model\contract\VehicleContract;
use app\common\model\vehicle\VehicleRent;
use think\response\Json;
class VehicleContractController extends BaseAdminController
{
//风控中心上传合同
public function uploadContract(): Json
{
//获取参数
$params = $this->request->post(['id','file','cars']);
if(empty($params['id']) || empty($params['file'])){
return $this->fail('缺少必要参数');
}
//获取合同信息
$vehicle_contract = VehicleContract::where('id',$params['id'])->findOrEmpty();
if($vehicle_contract->isEmpty()){
return $this->fail('合同信息错误');
}
if($vehicle_contract['type']==0 && $vehicle_contract['contract_logistic_id'] != 0){
if(empty($params['cars'])){
return $this->fail('缺少必要参数cars');
}
$cars = json_decode($params['cars'],true);
if(empty($cars)){
return $this->fail('参数cars无效');
}
}
if($vehicle_contract['status'] != 0){
return $this->fail('合同状态错误');
}
//更新本地
try {
$data = [
'id' => $vehicle_contract['contract_logistic_id'],
'file' => $params['file'],
'status' => 1,
];
//判断合同类型
if($vehicle_contract['type'] == 0 && $vehicle_contract['contract_logistic_id'] != 0){
$data['cars_info'] = $params['cars'];
}
if(!empty($vehicle_contract['contract_logistic_id'])){
//更新物流系统
curl_post(env('project.logistic_domain').'/api/contractUpdate',$data);
}
unset($data['id']);
VehicleContract::where('id', $params['id'])->update($data);
}catch (\Exception $e){
return $this->fail($e->getMessage());
}
return $this->success('上传成功', [], 1, 1);
}
//风控中心发起合同
public function initiatingRentCarContract(): Json
{
//获取参数
$params = $this->request->post(['id']);
if(empty($params['id'])){
return $this->fail('缺少必要参数');
}
//获取数据
$contract = VehicleContract::where('id',$params['id'])->findOrEmpty();
if($contract->isEmpty()){
return $this->fail('数据不存在');
}
if(!($contract['status'] == 1 || ($contract['status'] == 2 && $contract['signing_timer'] != 2))){
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']
];
$notify_url = '';
if($contract['type'] == 0){
$smsTitle = '《租赁合同》';
if(empty($contract['contract_logistic_id'])){
$notify_url = env('project.web_domain').'/api/notify/systemCarRent';
}else{
$notify_url = env('project.web_domain').'/api/notify/townCarRent';
}
}elseif($contract['type'] == 1){
$smsTitle = '《自有车辆上传合同》';
$notify_url = env('project.web_domain').'/api/notify/selfCarRent';
}elseif($contract['type'] == 2){
$smsTitle = '《解约合同》';
$notify_url = env('project.web_domain').'/api/notify/cancelRent';
}elseif($contract['type'] == 3){
$smsTitle = '《购买合同》';
$notify_url = env('project.web_domain').'/api/notify/buyCar';
}
$signRes = app(JunziqianController::class)->VehicleRentSigning($signData, $params['id'],$notify_url);
if ($signRes->success) {
$contract->save([
'id' => $contract['id'],
'contract_no' => $signRes->data,
'status' => 2,
'signing_timer' => 0
]);
if(!empty($contract['contract_logistic_id'])){
curl_post(env('project.logistic_domain').'/api/contractUpdate',[
'id' => $contract['contract_logistic_id'],
'contract_no' => $signRes->data,
'status' => 2,
'signing_timer' => 0
]);
}
$this->sendSms($params['id'],$smsTitle);
return $this->success('合同发送成功');
} else {
return $this->fail($signRes->msg);
}
}
public function sendSmsAgain(): Json
{
//获取参数
$id = $this->request->post('id');
if(empty($id)){
return $this->fail('参数错误');
}
//获取数据
$contract = VehicleContract::where('id',$id)->find();
if(empty($contract)){
return $this->fail('数据错误');
}
if($contract['type'] == 0){
$smsTitle = '《租赁合同》';
}elseif($contract['type'] == 1){
$smsTitle = '《自有车辆上传合同》';
}elseif($contract['type'] == 2){
$smsTitle = '《解约合同》';
}else{
$smsTitle = '《购买合同》';
}
$this->sendSms($id,$smsTitle);
return $this->success('发送成功');
}
public function sendSms($id,$title): bool{
//获取合同数据
$contract = VehicleContract::where('id',$id)->findOrEmpty();
if (!$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' => $title,
'code' => 'api/Hetong/info?id='.$id.'&type='.$v['type'],
'scene' => 'WQ'
];
$scene = NoticeEnum::getSceneByTag($sms['scene']);
if (empty($scene)) {
throw new \Exception('场景值异常');
}
//发送短信
event('Notice', [
'scene_id' => $scene,
'params' => $sms
]);
}
VehicleContract::where('id', $id)->update(['url' => json_encode($url)]);
return true;
}else{
return false;
}
}
public function lists(): Json
{
$param = $this->request->get();
$where = [];
if(isset($param['company_name'])){
$where[] = ['company_b_name','like','%'.$param['company_name'].'%'];
}
if(isset($param['contract_no'])){
$where[] = ['contract_no','like','%'.$param['contract_no'].'%'];
}
if(isset($param['status']) && in_array($param['status'],[0,1])){
if($param['status'] == 1){
$where[] = ['status','in', '1,2,3'];
}else{
$where[] = ['status','=', $param['status']];
}
}else{
$where[] = ['status','in', '0,1,2,3'];
}
$pageNo = !empty($param['page_no']) ? $param['page_no'] : 1;
$pageSize = !empty($param['page_size']) ? $param['page_size'] : 15;
$data = VehicleContract::where($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(): Json
{
$id = $this->request->get('id');
if(empty($id)){
$this->fail('参数错误');
}
$data = VehicleContract::where('id',$id)->findOrEmpty();
if($data->isEmpty()){
return $this->fail('未查找到数据');
}
$cars = json_decode($data['cars_info'],true);
//判断合同类型
if(!empty($data['contract_logistic_id']) && $data['type'] == 0){
$carList = curl_get(env('project.logistic_domain').'/api/getAvailableVehicles');
$data['car_list'] = $carList&&$carList['code']==1 ? $carList['data'] : [];
}
if(!empty($cars)){
foreach ($cars as $k=>$v) {
if($data['type'] == 0){
$cars[$k]['type'] = 0;
}
if($data['type'] == 1){
if(empty($v['id'])){
$cars[$k]['type'] = 1;
}else{
$rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
if($rentInfo->isEmpty()){
$cars[$k]['type'] = 0;
}else{
$cars[$k]['type'] = $rentInfo['type'];
}
}
}
if($data['type'] == 2){
$rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
if($rentInfo->isEmpty()){
$cars[$k]['type'] = 0;
}else{
$cars[$k]['type'] = $rentInfo['type'];
}
}
if($data['type'] == 3){
$rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
if($rentInfo->isEmpty()){
$cars[$k]['type'] = 2;
}else{
$cars[$k]['type'] = $rentInfo['type'];
}
}
$cars[$k]['rent_time'] = $data['update_time'];
}
}
$data['cars_info'] = $cars;
return $this->success('success',$data->toArray());
}
}

View File

@ -1,96 +0,0 @@
<?php
namespace app\adminapi\lists\contract;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\contract\Contract;
use app\common\lists\ListsSearchInterface;
use app\common\model\company\Company;
use app\common\model\WorkerAdmin\WorkerAdmin;
use think\facade\Db;
/**
* Contract列表
* Class ContractLists
* @package app\adminapi\listscontract
*/
class ContractLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/07/18 14:28
*/
public function setSearch(): array
{
return [
'=' => ['contract_type', 'contract_no', 'status'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/07/18 14:28
*/
public function lists(): array
{
$params=$this->request->param();
$where=[];
if(isset($params['company_id']) && $params['company_id']!=''){
$arr= Company::where('company_name','like','%'.$params['company_id'].'%')->column('id');
if($arr){
$where[]=['party_a|party_b','in',$arr];
}
}
if(isset($params['area_manager']) && $params['area_manager']!=''){
$arr= WorkerAdmin::where('name','like','%'.$params['area_manager'].'%')->column('id');
if($arr){
$where[]=['area_manager','in',$arr];
}
}
return Contract::where($this->searchWhere)->where($where)->with(['companyName','party_a_info','contractType'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item, $key) {
if($item->type==1){
$item->party_b_name=Db::connect('mysql2')->name('la_company')->where('id',$item->party_b)->value('company_name');
}else{
$item->party_b_name=Db::connect('mysql2')->name('la_user')->where('id',$item->party_b)->value('nickname');
}
if(!empty($item->party_a_info)){
$area_manager_name=Db::connect('mysql2')->name('la_admin')->where('id',$item->party_a_info->area_manager)->value('name');
if($area_manager_name){
$item->area_manager_name=$area_manager_name;
}else{
$item->area_manager_name='暂无片区经理';
}
}else{
$item->area_manager_name='暂无片区经理';
}
$item->contract_type_name=Db::connect('mysql2')->name('la_dict_data')->where('id',$item->contract_type)->value('name');
$item->status_name=$item->status==1?'已签约':'未签约';
})
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/07/18 14:28
*/
public function count(): int
{
return Contract::where($this->searchWhere)->count();
}
}

View File

@ -1,92 +0,0 @@
<?php
namespace app\api\controller;
use app\common\model\company\Company;
use app\common\model\contract\VehicleContract;
use think\facade\Db;
use think\facade\Log;
class HetongController extends BaseApiController
{
public array $notNeedLogin = ['url','info', 'toFaceCreate', 'notifyOrganizationFaceCreate'];
public function url(): string|\think\response\Redirect
{
$id = Request()->get('id');
$type = Request()->get('type');
$params = Request()->param();
$msg='合同不存在';
if(empty($type)){
$msg='参数错误';
}
if (isset($params['t']) && $params['t'] == 1) {
$find = Db::name('shop_contract')->where('id', $id)->find();
if ($find && $find['url']) {
$url = json_decode($find['url'], true);
if(isset($url[$type])){
return redirect($url[$type]);
}
}
}
if ($id && $type) {
$find = Db::name('contract')->where('id', $id)->find();
if ($find && $find['url']) {
$url = json_decode($find['url'], true);
if(isset($url[$type])){
return redirect($url[$type]);
}
}
}
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p>'.$msg.'</p> </div>';
}
public function info(): \think\response\Json|string|\think\response\Redirect
{
$params = $this->request->get(['id','type']);
if(empty($params['id']) || empty($params['type'])){
return $this->fail('缺少必要参数');
}
$find = VehicleContract::where('id', $params['id'])->find();
if (!empty($find) && $find['url']) {
$url = json_decode($find['url'], true);
if(isset($url[$params['type']])){
return redirect($url[$params['type']]);
}
}
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p></p> </div>';
}
// 用户做人脸识别时,作跳板的短信链接
public function toFaceCreate(): string|\think\response\Redirect
{
$id = Request()->get('id');
$msg='地址不存在';
if ($id) {
$find = Db::name('company')->where('id', $id)->find();
if ($find && $find['face_create_url']) {
return redirect($find['face_create_url']);
} else {
$msg='参数错误';
}
}
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p>'.$msg.'</p> </div>';
}
public function notifyOrganizationFaceCreate(): string
{
$parmas = Request()->param();
Log::info(['人脸识别采集校验回调:',$parmas]);
$result = json_decode($parmas['data'], true);
$msg = '人脸采集成功';
if (isset($result['status']) && $result['status'] == 1) {
// 修改人脸采集状态
Company::where(['organization_code'=>$result['organizationRegNo']])->update(['face_create_status'=>1]);
} else {
$msg = '采集失败,原因:'.$result['msg'];
// 记录错误日志
Db::name('company_authentication_fail_log')->insert(['company_id'=>$result['orderNo'], 'log_type'=>2,'fail_reason'=>$msg, 'create_time'=>time()]);
}
return '<style type="text/css"> * { padding: 0; margin: 0; } div { padding: 4px 48px; } a { color: #2E5CD5; cursor: pointer; text-decoration: none } a:hover { text-decoration: underline; } body { background: #fff; font-family: "Century Gothic", "Microsoft yahei"; color: #333; font-size: 18px; } h1 { font-size: 100px; font-weight: normal; margin-bottom: 12px; } p { line-height: 1.6em; font-size: 42px } </style> <div style="padding: 24px 48px;"> <h1>:) </h1> <p>'.$msg.'</p> </div>';
}
}

View File

@ -1,516 +0,0 @@
<?php
namespace app\api\controller;
use app\common\controller\JunziqianController;
use app\common\model\company\Company;
use app\common\model\contract\Contract;
use app\common\model\contract\VehicleContract;
use app\common\model\vehicle\VehicleBuyRecord;
use app\common\model\vehicle\VehicleRent;
use think\response\Json;
class NotifyController extends BaseApiController
{
public array $notNeedLogin = ['townCarRent','systemCarRent', 'selfCarRent', 'cancelRent', 'buyCar'];
//镇街车辆租赁回调
public function townCarRent(): Json
{
$id = Request()->get('id');
if(empty($id)){
return json(['success' => false, 'msg' => '缺少参数']);
}
//获取合同数据
$contract = VehicleContract::where('id', $id)->find();
if (empty($contract)) {
return json(['success' => false, 'msg' => '获取数据失败']);
}
if($contract['status'] != 2){
return json(['success' => false, 'msg' => '合同状态错误']);
}
if ($contract['signing_timer'] == 0) {
//更新本地合同状态
$updateLocalRes = VehicleContract::where('id',$contract['id'])->update(['signing_timer'=>1]);
//更新远程
$updateSverRes =curl_post(env('project.logistic_domain').'/api/contractUpdate',[
'id' => $contract['contract_logistic_id'],
'signing_timer' => 1,
]);
if(!$updateLocalRes || $updateSverRes['code']==0){
return json(['success' => false, 'msg' => '更新失败11']);
}
return json(['success' => true, 'msg' => '成功']);
}else if($contract['signing_timer'] == 1){
//获取签约后的合同
$signContractFile = app(JunziqianController::class)->downloadVehicleContractFile($contract['contract_no']);
$signContractFile = $signContractFile ?? '';
//获取签约后的证据
$signContractEvidenceToPartyA = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_a_name'],$contract['company_a_code']);
$signContractEvidenceToPartyA = $signContractEvidenceToPartyA ?? '';
$signContractEvidenceToPartyB = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_b_name'],$contract['company_b_code']);
$signContractEvidenceToPartyB = $signContractEvidenceToPartyB ?? '';
$contractEvidence = json_encode([
'party_a' => $signContractEvidenceToPartyA,
'party_b' => $signContractEvidenceToPartyB
]);
//更新本地合同状态
$updateLocalRes = VehicleContract::where('id',$contract['id'])->update(['signing_timer'=>2,'status' => 3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
//将车辆加入到本地租赁列表
$cars = json_decode($contract['cars_info'], true);
$data = [];
foreach ($cars as $k => $v) {
$hasCar = VehicleRent::where('car_id',$v['id'])->findOrEmpty();
if($hasCar->isEmpty()){
$data[$k]['contract_id'] = $contract['id'];
$data[$k]['company_id'] = $contract['company_b_id'];
$data[$k]['car_id'] = $v['id'];
$data[$k]['car_license'] = $v['license'];
$data[$k]['type'] = 0;
$data[$k]['status'] = 0;
$data[$k]['rent_contract_id'] = 0;
$data[$k]['rent_company_id'] = 0;
$data[$k]['rent_time'] = 0;
$data[$k]['create_time'] = strtotime($contract['create_time']);
}
}
$vehicleRent = new VehicleRent();
$vehicleRent->saveAll($data);
//更新远程
$updateSverRes = curl_post(env('project.logistic_domain').'/api/contractUpdate',[
'id' => $contract['contract_logistic_id'],
'signing_timer' => 2,
'status' => 3,
'contract_url'=>$signContractFile,
'contract_evidence'=>$contractEvidence
]);
if(!$updateLocalRes || $updateSverRes['code']==0){
return json(['success' => false, 'msg' => '更新失败22']);
}else{
return json(['success' => true, 'msg' => '更新成功']);
}
}
return json(['success' => true, 'msg' => '更新成功@']);
}
//系统车辆租赁回来
public function systemCarRent(): Json
{
//获取参数
$id = $this->request->get('id');
if (empty($id)) {
return json(['success' => false, 'msg' => '失败1.1']);
}
//获取合同数据
$contract = VehicleContract::where('id', $id)->find();
if (empty($contract)) {
return json(['success' => false, 'msg' => '失败1.2']);
}
if ($contract['type'] != 0) {
return json(['success' => false, 'msg' => '失败1.3']);
}
if ($contract['status'] != 2) {
return json(['success' => false, 'msg' => '失败1.4']);
}
//判断签约方
if ($contract['signing_timer'] == 0) {
//更新合同的签约次数
$res = VehicleContract::where('id', $id)->update(['signing_timer' => 1]);
if (!$res) {
return json(['success' => false, 'msg' => '失败1.5']);
}
return json(['success' => true, 'msg' => '成功']);
} else if ($contract['signing_timer'] == 1) {
//获取签约后的合同
$signContractFile = app(JunziqianController::class)->downloadVehicleContractFile($contract['contract_no']);
$signContractFile = $signContractFile ?? '';
//获取签约后的证据
$signContractEvidenceToPartyA = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_a_name'],$contract['company_a_code']);
$signContractEvidenceToPartyA = $signContractEvidenceToPartyA ?? '';
$signContractEvidenceToPartyB = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_b_name'],$contract['company_b_code']);
$signContractEvidenceToPartyB = $signContractEvidenceToPartyB ?? '';
$contractEvidence = json_encode([
'party_a' => $signContractEvidenceToPartyA,
'party_b' => $signContractEvidenceToPartyB
]);
//更改合同状态
VehicleContract::where('id', $id)->update(['signing_timer' => 2, 'status' => 3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
//添加车辆到租赁列表
$vehicle = json_decode($contract['cars_info'], true);
VehicleRent::where('car_id', $vehicle[0]['id'])->update([
'status' => 2,
'rent_contract_id' => $contract['id'],
'rent_company_id' => $contract['company_b_id'],
'rent_time' => time(),
]);
$party_b = Company::where('id', $contract['company_b_id'])->find();
//通知物流系统跟新
curl_post(env('project.logistic_domain').'/api/updateVehicleRent', [
'car_id' => $vehicle[0]['id'],
'use_user_id' => $party_b['user_id'],
'use_user_name' => $party_b['master_name'],
'use_user_phone' => $party_b['master_phone']
]);
return json(['success' => true, 'msg' => '成功']);
} else {
return json(['success' => true, 'msg' => '成功']);
}
}
//自有车辆租赁回答
public function selfCarRent(): Json
{
//获取参数
$id = $this->request->get('id');
if (empty($id)) {
return json(['success' => false, 'msg' => '失败2.1']);
}
//获取合同数据
$contract = VehicleContract::where('id', $id)->find();
if (empty($contract)) {
return json(['success' => false, 'msg' => '失败2.2']);
}
if ($contract['type'] != 1) {
return json(['success' => false, 'msg' => '失败2.3']);
}
if ($contract['status'] != 2) {
return json(['success' => false, 'msg' => '失败2.4']);
}
//判断签约方
if ($contract['signing_timer'] == 0) {
$res = VehicleContract::where('id', $id)->update(['signing_timer' => 1]);
if (!$res) {
return json(['success' => false, 'msg' => '失败2.5']);
}
return json(['success' => true, 'msg' => '成功']);
} else if ($contract['signing_timer'] == 1) {
//添加车辆到物流系统
$vehicle = json_decode($contract['cars_info'], true);
$curl_res = curl_post(env('project.logistic_domain').'/api/addSelfCar', [
'license' => $vehicle[0]['license'],
'pic' => $vehicle[0]['pic'],
'company_id' => $contract['company_a_id'],
'company_name' => $contract['company_a_name'],
'company_user' => $contract['company_a_user'],
'company_phone' => $contract['company_a_phone'],
]);
if (!$curl_res || $curl_res['code'] == 0) {
return json(['success' => false, 'msg' => '失败2.6']);
}
$cars_info = json_encode([['id' => $curl_res['data']['car_id'], 'license' => $vehicle[0]['license']]]);
//获取签约后的合同
$signContractFile = app(JunziqianController::class)->downloadVehicleContractFile($contract['contract_no']);
$signContractFile = $signContractFile ?? '';
//获取签约后的证据
$signContractEvidenceToPartyA = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_a_name'],$contract['company_a_code']);
$signContractEvidenceToPartyA = $signContractEvidenceToPartyA ?? '';
$signContractEvidenceToPartyB = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_b_name'],$contract['company_b_code']);
$signContractEvidenceToPartyB = $signContractEvidenceToPartyB ?? '';
$contractEvidence = json_encode([
'party_a' => $signContractEvidenceToPartyA,
'party_b' => $signContractEvidenceToPartyB
]);
VehicleContract::where('id', $id)->update(['cars_info'=>$cars_info,'update_time'=>time(),'signing_timer'=>2,'status'=>3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
VehicleRent::create([
'car_id' => $curl_res['data']['car_id'],
'contract_id' => $contract['id'],
'company_id' => $contract['company_a_id'],
'car_license' => $vehicle[0]['license'],
'status' => 2,
'rent_time' => time(),
'rent_contract_id' => $contract['id'],
'rent_company_id' => $contract['company_b_id'],
'create_time' => time(),
'type' => 1
]);
$car_id = $curl_res['data']['car_id'];
$party_b = Company::where('id', $contract['company_b_id'])->find();
//通知物流系统跟新
curl_post(env('project.logistic_domain').'/api/updateVehicleRent', [
'car_id' => $car_id,
'use_user_id' => $party_b['user_id'],
'use_user_name' => $party_b['master_name'],
'use_user_phone' => $party_b['master_phone']
]);
return json(['success' => true, 'msg' => '成功']);
} else {
return json(['success' => true, 'msg' => '成功']);
}
}
//解除合同回调
public function cancelRent()
{
//获取参数
$id = $this->request->get('id');
if (empty($id)) {
return json(['success' => false, 'msg' => '失败3.1']);
}
//获取合同数据
$contract = VehicleContract::where('id', $id)->find();
if (empty($contract)) {
return json(['success' => false, 'msg' => '失败3.2']);
}
if ($contract['type'] != 2) {
return json(['success' => false, 'msg' => '失败3.3']);
}
if ($contract['status'] != 2) {
return json(['success' => false, 'msg' => '失败3.4']);
}
if ($contract['signing_timer'] == 0) {
$res = VehicleContract::where('id', $id)->update(['signing_timer' => 1]);
if (!$res) {
return json(['success' => false, 'msg' => '失败3.5']);
}
return json(['success' => true, 'msg' => '成功']);
} else if ($contract['signing_timer'] == 1) {
//获取签约后的合同
$signContractFile = app(JunziqianController::class)->downloadVehicleContractFile($contract['contract_no']);
$signContractFile = $signContractFile ?? '';
//获取签约后的证据
$signContractEvidenceToPartyA = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_a_name'],$contract['company_a_code']);
$signContractEvidenceToPartyA = $signContractEvidenceToPartyA ?? '';
$signContractEvidenceToPartyB = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_b_name'],$contract['company_b_code']);
$signContractEvidenceToPartyB = $signContractEvidenceToPartyB ?? '';
$contractEvidence = json_encode([
'party_a' => $signContractEvidenceToPartyA,
'party_b' => $signContractEvidenceToPartyB
]);
$cars = json_decode($contract['cars_info'],true);
$cars_ids = array_column($cars,'id');
//更改合同状态
VehicleContract::where('id', $id)->update(['signing_timer'=>2,'status'=>3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
if(!empty($contract['contract_logistic_id'])){
curl_post(env('project.logistic_domain').'/api/contractUpdate',[
'id' => $contract['contract_logistic_id'],
'signing_timer' => 2,
'status' => 3,
'contract_url'=>$signContractFile,
'contract_evidence'=>$contractEvidence,
]);
}
//判断合同是否存在购买记录表中
$vehicleBuyRecord = VehicleBuyRecord::where('contract_id',$contract['id'])->findOrEmpty();
if(!$vehicleBuyRecord->isEmpty()){
//小组公司与镇街公司解约
if($vehicleBuyRecord['status'] == 1){
//获取租赁车辆信息
$rentCarsInfo = VehicleRent::where('car_id',$cars_ids[0])->findOrEmpty();
if($rentCarsInfo['type'] == 0){
//修改租赁车俩状态
VehicleRent::where('id',$rentCarsInfo['id'])->update(['status'=>0,'rent_company_id'=>0,'rent_contract_id'=>0,'rent_time'=>0]);
}
if($rentCarsInfo['type'] == 1){
//修改租赁车俩状态
VehicleRent::where('id',$rentCarsInfo['id'])->delete();
}
//删除原合同
VehicleContract::where('id',$rentCarsInfo['rent_contract_id'])->delete();
//修改物流系统车辆租赁信息
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [
'car_id' => $cars_ids[0]
]);
//发送购买合同给物流系统
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[
'num' => $vehicleBuyRecord['num'],
'company_id' => $vehicleBuyRecord['company_id'],
'company_name' => $vehicleBuyRecord['company_name'],
'company_code' => $vehicleBuyRecord['company_code'],
'company_user' => $vehicleBuyRecord['company_user'],
'company_phone' => $vehicleBuyRecord['company_phone'],
'company_email' => $vehicleBuyRecord['company_email'],
'cars_info' => $vehicleBuyRecord['cars_info'],
'type' => 3
]);
if(empty($curl_result)){
return $this->fail('null return from logistic');
}
if($curl_result['code'] == 0){
return $this->fail($curl_result['msg'].' from logistic');
}
//生成本地合同
VehicleContract::create($curl_result['data']);
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>4]);
return json(['success' => true, 'msg' => '成功']);
}
//小组公司与镇街公司解约,然后镇街公司与平台公司解约
if($vehicleBuyRecord['status'] == 2){
//获取租赁车辆信息
$rentCarsInfo = VehicleRent::where('car_id',$cars_ids[0])->findOrEmpty();
if($rentCarsInfo['type'] == 0){
//修改租赁车俩状态
VehicleRent::where('id',$rentCarsInfo['id'])->update(['status'=>0,'rent_company_id'=>0,'rent_contract_id'=>0,'rent_time'=>0]);
}
if($rentCarsInfo['type'] == 1){
//修改租赁车俩状态
VehicleRent::where('id',$rentCarsInfo['id'])->delete();
}
//删除原合同
VehicleContract::where('id',$rentCarsInfo['rent_contract_id'])->delete();
//修改物流系统车辆租赁信息
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [
'car_id' => $cars_ids[0]
]);
//获取镇街公司信息
$zjCompany = Company::where('id',$rentCarsInfo['company_id'])->findOrEmpty();
//判断购买车辆中是否包含镇街公司租赁的车辆
$car_ids = array_column(json_decode($vehicleBuyRecord['cars_info'],true),'id');
$zjRentCars = VehicleRent::field('car_id as id,car_license as license')->where('company_id',$zjCompany['id'])->where('car_id','in',$car_ids)->where('status',0)->where('type',0)->select();
//发送镇公司与平台公司的解约合同
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[
'num' => count($zjRentCars),
'company_id' => $zjCompany['id'],
'company_name' => $zjCompany['company_name'],
'company_code' => $zjCompany['organization_code'],
'company_user' => $zjCompany['master_name'],
'company_phone' => $zjCompany['master_phone'],
'company_email' => $zjCompany['master_email'],
'cars_info' => json_encode($zjRentCars),
'type' => 2
]);
if(empty($curl_result)){
return $this->fail('null return from logistic');
}
if($curl_result['code'] == 0){
return $this->fail($curl_result['msg'].' from logistic');
}
//生成本地合同
$res = VehicleContract::create($curl_result['data']);
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>3,'contract_id'=>$res->id]);
return json(['success' => true, 'msg' => '成功']);
}
//镇街公司与平台公司解约
if($vehicleBuyRecord['status'] == 3){
//删除本地租赁信息
VehicleRent::where('car_id','in',$cars_ids)->delete();
//删除物流系统租赁信息
curl_post(env('project.logistic_domain').'/api/cancelRent', [
'car_ids' => implode(',',$cars_ids)
]);
//发送购买合同给物流系统
$curl_result = curl_post(env('project.logistic_domain').'/api/signContract',[
'num' => $vehicleBuyRecord['num'],
'company_id' => $vehicleBuyRecord['company_id'],
'company_name' => $vehicleBuyRecord['company_name'],
'company_code' => $vehicleBuyRecord['company_code'],
'company_user' => $vehicleBuyRecord['company_user'],
'company_phone' => $vehicleBuyRecord['company_phone'],
'company_email' => $vehicleBuyRecord['company_email'],
'cars_info' => $vehicleBuyRecord['cars_info'],
'type' => 3
]);
if(empty($curl_result)){
return $this->fail('null return from logistic');
}
if($curl_result['code'] == 0){
return $this->fail($curl_result['msg'].' from logistic');
}
//生成本地合同
VehicleContract::create($curl_result['data']);
VehicleBuyRecord::where('id',$vehicleBuyRecord['id'])->update(['status'=>4]);
return json(['success' => true, 'msg' => '成功']);
}
}else{
//更改租赁列表车辆状态
$vehicle = json_decode($contract['cars_info'], true);
//获取租赁车辆信息
$vehicleRentInfo = VehicleRent::where('car_id', $vehicle[0]['id'])->find();
//更新原始合同类型
VehicleContract::where('id', $vehicleRentInfo['rent_contract_id'])->delete();
VehicleRent::where('car_id', $vehicle[0]['id'])->delete();
//通知物流系统跟新
curl_post(env('project.logistic_domain').'/api/Vehicle/delRentUseInfo', [
'car_id' => $vehicle[0]['id']
]);
return json(['success' => true, 'msg' => '成功']);
}
} else {
return json(['success' => true, 'msg' => '成功']);
}
}
//购买合同回调
public function buyCar(): Json
{
//获取参数
$id = $this->request->get('id');
if (empty($id)) {
return json(['success' => false, 'msg' => '失败4.1']);
}
//获取合同数据
$contract = VehicleContract::where('id', $id)->find();
if (empty($contract)) {
return json(['success' => false, 'msg' => '失败4.2']);
}
if ($contract['type'] != 3) {
return json(['success' => false, 'msg' => '失败4.3']);
}
if ($contract['status'] != 2) {
return json(['success' => false, 'msg' => '失败4.4']);
}
if ($contract['signing_timer'] == 0) {
$res = VehicleContract::where('id', $id)->update(['signing_timer' => 1]);
if (!$res) {
return json(['success' => false, 'msg' => '失败4.5']);
}
return json(['success' => true, 'msg' => '成功']);
}else if ($contract['signing_timer'] == 1) {
//获取签约后的合同
$signContractFile = app(JunziqianController::class)->downloadVehicleContractFile($contract['contract_no']);
$signContractFile = $signContractFile ?? '';
//获取签约后的证据
$signContractEvidenceToPartyA = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_a_name'],$contract['company_a_code']);
$signContractEvidenceToPartyA = $signContractEvidenceToPartyA ?? '';
$signContractEvidenceToPartyB = app(JunziqianController::class)->downloadVehicleContractEvidence($contract['contract_no'],$contract['company_b_name'],$contract['company_b_code']);
$signContractEvidenceToPartyB = $signContractEvidenceToPartyB ?? '';
$contractEvidence = json_encode([
'party_a' => $signContractEvidenceToPartyA,
'party_b' => $signContractEvidenceToPartyB
]);
//更新本地合同状态
$updateLocalRes = VehicleContract::where('id',$contract['id'])->update(['signing_timer'=>2,'status' => 3,'contract_url'=>$signContractFile,'contract_evidence'=>$contractEvidence]);
//判断是否有监管车辆
$jgCars = VehicleRent::where('rent_company_id',$contract['company_b_id'])->where('status',2)->where('type',2)->findOrEmpty();
if($jgCars->isEmpty()){
//获取镇街公司信息
$zjCompany = Contract::field('party_a')->where('party_b',$contract['company_b_id'])->where('signing_timer',2)->findOrEmpty();
//将车辆加入到本地租赁列表
$cars = json_decode($contract['cars_info'], true);
//写入数据
$data = [
'car_id' => $cars[0]['id'],
'car_license' => $cars[0]['license'],
'type' => 2,
'status' => 2,
'company_id' => $zjCompany['party_a'],
'rent_time' => time(),
'rent_company_id' => $contract['company_b_id'],
'contract_id' => $contract['id'],
'create_time' => time()
];
$vehicleRent = new VehicleRent();
$vehicleRent->save($data);
}
//获取签约公司信息
$compay = Company::where('id',$contract['company_b_id'])->findOrEmpty();
//更新远程
$updateSverRes = curl_post(env('project.logistic_domain').'/api/contractUpdate',[
'id' => $contract['contract_logistic_id'],
'signing_timer' => 2,
'status' => 3,
'contract_url'=>$signContractFile,
'contract_evidence'=>$contractEvidence,
'use_user_id' =>$compay['user_id'],
'use_user_name' =>$compay['master_name'],
'use_user_phone' =>$compay['master_phone'],
]);
if(!$updateLocalRes || $updateSverRes['code']==0){
return json(['success' => false, 'msg' => '更新失败']);
}else{
return json(['success' => true, 'msg' => '更新成功']);
}
}else{
return json(['success' => true, 'msg' => '成功']);
}
}
}

View File

@ -1,21 +1,9 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\logic;
use app\common\enum\notice\NoticeEnum;
use app\common\logic\BaseLogic;
use think\facade\Log;
/**
@ -56,31 +44,5 @@ class SmsLogic extends BaseLogic
return false;
}
}
public static function contractUrl($params)
{
try {
$scene = NoticeEnum::getSceneByTag($params['scene']);
if (empty($scene)) {
throw new \Exception('场景值异常');
}
$result = event('Notice', [
'scene_id' => $scene,
'params' => [
'mobile' => $params['mobile'],
'name' => $params['name'],
'type' => $params['type'],
'code' => $params['code']
]
]);
return $result[0];
} catch (\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
}

View File

@ -1,491 +0,0 @@
<?php
namespace app\common\controller;
use app\common\model\contract\VehicleContract;
use junziqian\sdk\bean\req\sign\ApplySignReq;
use junziqian\sdk\bean\req\user\OrganizationCreateReq;
use junziqian\sdk\bean\req\user\OrganizationFaceCreateReq;
use junziqian\sdk\util\exception\ResultInfoException;
use junziqian\sdk\util\RequestUtils;
use junziqian\sdk\util\ShaUtils;
use CURLFile;
use think\facade\Db;
use think\facade\Log;
class JunziqianController extends BaseLikeAdminController
{
public array $notNeedLogin = ['download_file'];
/**请求地址*/
private $serviceUrl;
/**appkey*/
private $appkey;
/**secret*/
private $appSecret;
public function initialize()
{
$this->serviceUrl=env('junzi.url_prefix');
$this->appkey=env('junzi.app_key');
$this->appSecret=env('junzi.app_secret');
parent::initialize();
}
/**请求地址*/
// private $serviceUrl = 'https://api.junziqian.com';
// /**appkey*/
// private $appkey = '62dc4ab579153712';
// /**secret*/
// private $appSecret = 'b7f65acc62dc4ab579153712fc9ebfc5';
/**默认加密方式:不输入使用sha256,其它可选择项md5,sha1,sha3-256*/
private $encryMethod;
/**默认ts单位:1毫秒,2秒*/
private $tsType;
/**
* 填充签名数据
* @param $req array
*/
public function fillSign($req)
{
/**默认加密方式:不输入使用sha256,其它可选择项md5,sha1,sha3-256*/
$ts = time();
if ($this->tsType == 1) {
$ts = $ts * 1000;
}
$sign = null;
$nonce = md5($ts . "");
$signSrc = "nonce" . $nonce . "ts" . $ts . "app_key" . $this->appkey . "app_secret" . $this->appSecret;
if ($this->encryMethod == null || $this->encryMethod == "sha256") {
$sign = ShaUtils::getSha256($signSrc);
} else if ($this->encryMethod == "sha1") {
$sign = ShaUtils::getSha1($signSrc);
} else if ($this->encryMethod == "md5") {
$sign = md5($signSrc);
} else {
throw new ResultInfoException($this->encryMethod . ",必须为md5,sha1,sha256之一", "PARAM_ERROR");
}
$req['ts'] = $ts;
$req['app_key'] = $this->appkey;
$req['sign'] = $sign;
$req['nonce'] = $nonce; //这只是为了生成一个随机值
if ($this->encryMethod != null) {
$req['encry_method'] = $this->encryMethod; //为''也不能传
}
return $req;
}
//企业实名认证上传
public function EnterpriseCertification($data)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$request = new OrganizationCreateReq();
$request->name = $data['name'];
$request->identificationType = 1; //证件类型0多证,1多证合一
$request->organizationType = 0; //组织类型 0企业,1事业单位
$request->organizationRegNo = $data['organization_code'];
$request->organizationRegImg = $data['business_license']; //new CURLFile('D:/tmp/test.png',null,"test.png");
$request->legalName = $data["master_name"]; //法人
// $request->legalIdentityCard = $data["master_id_card"]; // 法人身份证 签约时人脸识别需要
// $request->legalMobile = $data["master_phone"]; // 法人手机号 预留 签约时短信验证需要
if (isset($data['master_email'])) {
$request->emailOrMobile = $data['master_email']; //邮箱
}
// $request->notifyUrl = env('url.url_prefix').'/notifyAuthentication?ids=22222';
$request->notifyUrl = env('url.url_prefix') . '/notifyAuthentication?id=' . $data['id'];
// halt($request);
//发起创建企业请求
$response = $requestUtils->doPost("/v2/user/organizationCreate", $request);
return $response;
}
/**
* @param $data
* @return object
* 商城商户入驻,实名认证
*/
public function ShopMerchantCertification($data)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$request = new OrganizationCreateReq();
$request->name = $data['name'];
$request->identificationType = 1; //证件类型0多证,1多证合一
$request->organizationType = 0; //组织类型 0企业,1事业单位
$request->organizationRegNo = $data['organization_code'];
$request->organizationRegImg = $data['business_license'];
$request->legalName = $data["master_name"]; //法人
if (isset($data['master_email'])) {
$request->emailOrMobile = $data['master_email']; //邮箱
}
$request->notifyUrl = env('url.url_prefix') . '/notifyAuthentication?id=' . $data['id'].'&type=shop_merchant'; // 回调增加type参数用于回调是辨别是商户认证会带
//发起创建企业请求
$response = $requestUtils->doPost("/v2/user/organizationCreate", $request);
return $response;
}
//重新提交企业实名认证
public function organizationReapply($data)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$request = new OrganizationCreateReq();
$request->name = $data['name'];
$request->identificationType = 1; //证件类型0多证,1多证合一
$request->organizationType = 0; //组织类型 0企业,1事业单位
$request->organizationRegNo = $data['organization_code'];
$request->organizationRegImg = $data['business_license']; //new CURLFile('D:/tmp/test.png',null,"test.png");
$request->legalName = $data["master_name"]; //法人
// $request->legalIdentityCard = $data["master_id_card"]; // 法人身份证 签约时人脸识别需要
// $request->legalMobile = $data["master_phone"]; // 法人手机号 预留 短信验证需要
$request->emailOrMobile = $data['master_email']; //邮箱
//发起创建企业请求
$response = $requestUtils->doPost("/v2/user/organizationReapply", $request);
return $response;
// return $this->success('', (array)$response);
}
//企业实名认证状态查询
public function StatusQuery()
{
$param = Request()->param();
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//初始化合同参数
$request = array(
"emailOrMobile" => $param['master_email'], //TODO *
);
//发起请求
$response = $requestUtils->doPost("/v2/user/organizationAuditStatus", $request);
return $response;
}
public function shopMerchantStatusQuery($email)
{
$param = Request()->param();
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//初始化合同参数
$request = array(
"emailOrMobile" => $email, //TODO *
);
//发起请求
$response = $requestUtils->doPost("/v2/user/organizationAuditStatus", $request);
return $response;
}
//企业自定义公章
public function Custom_seal()
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//初始化合同参数
$request = array(
"signName" => "500XXXXXXXXXXXX", //TODO *
"email" => "500XXXXXXXXXXXX", //TODO 不传则保存在商户下,传入注册的邮箱则上传到指定邮箱企业名下
"signImgFile" => new CURLFile('D:/tmp/test.png', null, "test.png"),
);
$response = $requestUtils->doPost("/v2/user/uploadEntSign", $request);
return $this->success('', (array)$response);
}
//签约
public function Signing($data, $id, $notify = '')
{
if ($notify == '') {
$notify = env('url.url_prefix') . '/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 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)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$request = new OrganizationFaceCreateReq();
$request->orderNo = $data['id'];
$request->email = $data['master_email'];
$request->enterpriseName = $data['company_name'];
$request->identityNo = $data['organization_code'];
// $request-> facePerType = 0;
$request->legalPersonName = $data['master_name'];
$request->legalIdentityCard = $data['master_id_card']; //法人证件号
$request->legalMobile = $data['master_phone'];
$request->faceAgantIdenName = $data['master_name'];
$request->faceAgantIdenCard = $data['master_id_card'];
$request->backUrl = env('url.url_prefix') . '/api/Hetong/notifyOrganizationFaceCreate';
$response = $requestUtils->doPost("/v2/user/organizationFaceCreate", $request);
return $response;
}
public function VehicleRentSigning($data, $id, $notify)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$request = new ApplySignReq();
$request->contractName = $data['name'];
$request->signatories = $data['signatories']; //签约方
$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);
Log::write('三轮车签约:'.json_encode(['result'=>$response,'notify'=>$notify]),'notice');
return $response;
}
public function downloadVehicleContractFile($applyNo)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$contract_url = VehicleContract::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) {
$this->getDownload($response->data, root_path() . 'public/uploads/vehicle_contract/' . $applyNo . '.pdf');
return env('project.website_domain') . '/uploads/vehicle_contract/' . $applyNo . '.pdf';
} else {
return false;
}
}
public function downloadVehicleContractEvidence($applyNo, $companyName, $companyCode)
{
//构建请求工具
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//初始化合同参数
$request = array(
"applyNo" => $applyNo,
"fullName" => $companyName, //签约人名称(合同发起接口中传入的签署人姓名)
"identityCard" => $companyCode, //统一社会信用代码
"identityType" => 12, //证件类型 1身份证, 2护照, 3台胞证, 4港澳居民来往内地通行证, 11营业执照, 12统一社会信用代码, 20子账号, 99其他
"dealType" => 1
);
$response = $requestUtils->doPost("/v2/sign/presLinkFile", $request);
if ($response->success) {
$this->getDownload($response->data, root_path().'public/uploads/vehicle_contract_evidence/'.$applyNo.'_'.$companyCode.'.zip');
return env('project.website_domain').'/uploads/vehicle_contract_evidence/'.$applyNo.'_'.$companyCode.'.zip';;
} else {
return false;
}
}
public function SigningLink($data)
{
//构建请求工具
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//初始化合同参数
$response = $requestUtils->doPost("/v2/sign/link", $data);
return $response;
}
public function sms($data)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//初始化请求参数
$request = array(
"applyNo" => $data['applyNo'], //TODO +
//"businessNo" => "0000XXXXXXXXX", //TODO +
"fullName" => $data['fullName'], //TODO *
"identityCard" => $data['identityCard'], //TODO *
"identityType" => 12, //TODO *
"signNotifyType" => 1 //默认为1
);
$response = $requestUtils->doPost("/v2/sign/notify", $request);
return $response;
}
//html模板
public function html_contract($data, $id)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
//CURLFile 可以传url或filePath但必须保证文件存在且有效否则php不会报错只会导致http请求返回null并没有调到服务端
//初始化合同参数
$request = new ApplySignReq();
$request->contractName = $data['name'];
$request->signatories = $data['signatories']; //签约方
$request->serverCa = 1; //是否需要服务端云证书
$request->fileType = 3;
$request->htmlContent = $data['content'];
$request->notifyUrl = env('url.url_prefix') . '/notify_url?id=' . $id;
$request->needQifengSign = 1;
//发起PING请求
$response = $requestUtils->doPost("/v2/sign/applySign", $request);
return $response;
}
/**
* 下载合同
*/
public function download_file($applyNo)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$find = Db::connect('mysql2')->name('la_contract')->where('contract_no', $applyNo)->value('contract_url');
if ($find) {
return $this->success('获取成功', ['url' => env('url.url_prefix') . $find]);
}
//初始化请求参数
$request = array(
"applyNo" => $applyNo, //TODO +
);
$response = $requestUtils->doPost("/v2/sign/linkFile", $request);
if ($response->success == true) {
$this->getDownload($response->data, root_path() . 'public/uploads/contract/' . $applyNo . '.pdf');
Db::connect('mysql2')->name('la_contract')->where('contract_no', $applyNo)->update(['contract_url' => '/uploads/contract/' . $applyNo . '.pdf']);
return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/contract/' . $applyNo . '.pdf']);
} else {
return $this->fail('获取失败');
}
}
public function download_shop_file($applyNo)
{
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$find = Db::connect('mysql2')->name('la_contract')->where('contract_no', $applyNo)->value('contract_url');
if ($find) {
return $this->success('获取成功', ['url' => env('url.url_prefix') . $find]);
}
//初始化请求参数
$request = array(
"applyNo" => $applyNo, //TODO +
);
$response = $requestUtils->doPost("/v2/sign/linkFile", $request);
if ($response->success == true) {
$this->getDownload($response->data, root_path() . 'public/uploads/contract/' . $applyNo . '.pdf');
Db::connect('mysql2')->name('la_shop_contract')->where('contract_no', $applyNo)->update(['contract_url' => '/uploads/contract/' . $applyNo . '.pdf']);
return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/contract/' . $applyNo . '.pdf']);
} else {
return $this->fail('获取失败');
}
}
/**
* 保全后合同文件及证据包下载
*/
public function EvidenceDownload($param)
{
//初始化请求参数
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$request = array(
"applyNo" => $param['applyNo'],
"fullName" => $param['fullName'],
"identityCard" => $param['identityCard'],
"identityType" => 12,
"dealType" => 1,
);
$response = $requestUtils->doPost("/v2/sign/presLinkFile", $request);
if ($response->success == true) {
$this->getDownload($response->data, root_path() . 'public/uploads/evidence/' . $param['applyNo'] . '.zip');
Db::connect('mysql2')->name('la_contract')->where('contract_no', $param['applyNo'])->update(['evidence_url' => '/uploads/evidence/' . $param['applyNo'] . '.zip']);
return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/evidence/' . $param['applyNo'] . '.zip']);
} else {
return $this->fail('获取失败');
}
}
/**
* 保全后合同文件及证据包下载
*/
public function EvidenceShopDownload($param)
{
//初始化请求参数
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
$request = array(
"applyNo" => $param['applyNo'],
"fullName" => $param['fullName'],
"identityCard" => $param['identityCard'],
"identityType" => 12,
"dealType" => 1,
);
$response = $requestUtils->doPost("/v2/sign/presLinkFile", $request);
if ($response->success == true) {
$this->getDownload($response->data, root_path() . 'public/uploads/evidence_shop_contract/' . $param['applyNo'] . '.zip');
Db::connect('mysql2')->name('la_shop_contract')->where('contract_no', $param['applyNo'])->update(['evidence_url' => '/uploads/evidence_shop_contract/' . $param['applyNo'] . '.zip']);
return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/evidence_shop_contract/' . $param['applyNo'] . '.zip']);
} else {
return $this->fail('获取失败');
}
}
public function getDownload($url, $publicDir = '', $fileName = '', $type = 0)
{
//获取文件路径
$newOneDir = substr($publicDir, 0, strrpos($publicDir, "/"));
if (trim($url) == '') {
return false;
}
//检验访问url是否有效
$array = get_headers($url, 1);
if (!preg_match('/200/', $array[0])) {
return false;
}
if (trim($publicDir) == '') {
return false;
}
//创建保存目录
if (!file_exists($newOneDir) && !mkdir($newOneDir, 0777, true)) {
return false;
}
//获取远程文件所采用的方法
if ($type) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = curl_exec($ch);
curl_close($ch);
} else {
ob_start();
readfile($url);
$content = ob_get_contents();
ob_end_clean();
}
$size = strlen($content);
//文件大小
$fp2 = @fopen($publicDir, 'a');
fwrite($fp2, $content);
fclose($fp2);
unset($content, $url);
}
}

View File

@ -1,8 +0,0 @@
<?php
namespace app\common\logic\company;
class CompanyLogic
{
}

View File

@ -1,371 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\logic\contract;
use app\common\controller\JunziqianController;
use app\common\model\contract\Contract;
use app\common\logic\BaseLogic;
use app\common\model\company\Company;
use app\common\model\user\WorkerUser;
use think\facade\Db;
use app\api\logic\SmsLogic;
use app\common\logic\company\CompanyLogic;
use app\common\logic\user\WorkerUserLogic;
use think\facade\Log;
/**
* Contract逻辑
* Class ContractLogic
* @package app\adminapi\logic\contract
*/
class ContractLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/07/18 14:28
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
Contract::create([
'company_id' => $params['company_id'],
'contract_type' => $params['contract_type'],
'contract_no' => $params['contract_no'],
'file' => $params['file'],
'status' => $params['status'],
'party_a' => $params['party_a'],
'party_b' => $params['party_b'],
'area_manager' => $params['area_manager']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/07/18 14:28
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
Contract::where('id', $params['id'])->update([
'company_id' => $params['company_id'],
'contract_type' => $params['contract_type'],
'contract_no' => $params['contract_no'],
'file' => $params['file'],
'status' => $params['status'],
'party_a' => $params['party_a'],
'party_b' => $params['party_b'],
'area_manager' => $params['area_manager']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/07/18 14:28
*/
public static function delete(array $params): bool
{
return Contract::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/07/18 14:28
*/
public static function detail($params)
{
$data = Db::connect('mysql2')->name('la_contract')->where('id', $params['id'])
->withAttr('party_b_info', function ($value, $data) {
if ($data['type'] == 1) {
$field = ['id,company_name,company_type,company_type company_type_name,organization_code,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,master_name,
qualification'];
$company = Company::where(['id' => $data['party_b']])->field($field)->find();
if(empty($company)){
return [];
}else{
$company=$company->toArray();
}
$company['qualification'] = json_decode($company['qualification'], true);
if($company['qualification'] && isset($company['qualification']['other_qualifications'])){
$company['qualification']['other_qualifications']=json_decode($company['qualification']['other_qualifications'],true);
}
return $company;
} else {
$filed = ['id,id_card,avatar,nickname,sex,mobile,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,nickname master_name,
qualification'];
$user = WorkerUser::where('id', $data['party_b'])->field($filed)->find();
if(empty($user)){
return [];
}else{
$user=$user->toArray();
}
$user['qualification'] = json_decode($user['qualification'], true);
if($user['qualification'] && isset($user['qualification']['other_qualifications'])){
$user['qualification']['other_qualifications']=json_decode($user['qualification']['other_qualifications'],true);
}
return $user;
}
})
->withAttr('party_a_info', function ($value, $data) {
$field = ['id,company_name,company_type,company_type company_type_name,organization_code,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,master_name,
qualification'];
$company = Company::where(['id' => $data['party_a']])->field($field)->find()->toArray();
$company['qualification'] = json_decode($company['qualification'], true);
if($company['qualification'] && isset($company['qualification']['other_qualifications'])){
$company['qualification']['other_qualifications']=json_decode($company['qualification']['other_qualifications'],true);
}
return $company;
})
->withAttr('area_manager_name', function ($value, $data) {
return Db::connect('mysql2')->name('la_admin')->where('id', $data['area_manager'])->value('name');
})
->withAttr('contract_type_name', function ($value, $data) {
return Db::connect('mysql2')->name('la_dict_data')->where('id', $data['contract_type'])->value('name');
})
->withAttr('type_name', function ($value, $data) {
return $data['type'] == 1 ? '公司' : '个人';
})
->withAttr('status_name', function ($value, $data) {
return $data['status'] == 1 ? '已签约' : '未签约';
})
->find();
$data['signed_contract_url'] = self::getSignedContract($data);
return $data;
}
/**
* 获取已签约盖章的合同
*/
public static function getSignedContract($contract)
{
$signedContractUrl = '';
if($contract['status'] == 1){
if ($contract['contract_url'] == '') {
$res = app(JunziqianController::class)->download_file($contract['contract_no'])->getData();
if ($res['code'] == 1) {
$signedContractUrl = $res['data']['url'];
}
}else {
$signedContractUrl = env('url.url_prefix').$contract['contract_url'];
}
}
return $signedContractUrl;
}
//生成合同
public static function Initiate_contract($data)
{
// 平台公司可以直接签合同,其他类型的公司需要做过合同乙方才能签合同
$partyACompamyInfo = Company::where(['id'=>$data['party_a']])->find();
if ($partyACompamyInfo['company_type'] != 30) {
$partyAModel = Contract::where(['party_b' => $data['party_a']])->find();
if (empty($partyAModel)) {
return self::setError('当前甲方暂无和平台或上级公司签约,请先进行签约');
}
}
$model = Contract::where(['party_b' => $data['party_b'],'contract_type'=>$data['contract_type']])->find();
if (empty($model)) {
$model = new Contract();
$model->contract_no = time();
$model->create_time = time();
}
if($data['party_a']<=0){
return self::setError('甲方不能为空');
}
if($data['party_b']<=0){
return self::setError('乙方不能为空');
}
if($data['type']==1){
if($data['party_a'] == $data['party_b']){
return self::setError('甲方和乙方不能是同一个公司');
}
}
try {
$model->check_status = 1;
$model->update_time = time();
$model->setAttrs($data);
$res = $model->save($data);
if($res){
return ['code'=>1,'msg'=>'发起成功,等待平台风控部上传合同','data'=>['id'=>$model->id]];
}else{
return ['code'=>0,'msg'=>'发起失败,请稍后重试',];
}
}catch(\Exception $e){
return ['code'=>0,'msg'=>$e->getMessage()];
}
}
/**发送合同
* @type 1公司 2个人
*/
public static function Draftingcontracts($params,$type=1)
{
if($type==1){
$result = CompanyLogic::detail($params);
}else{
$result = WorkerUserLogic::detail($params['id']);
}
$result['contract']= Contract::where('id',$params['contract_id'])->with(['party_a_info', 'contractType'])->find();
if ($result && isset($result['contract']) && isset($result['contract']['file']) && $result['contract']['file'] != '') {
if ($result['contract']['check_status'] == 3) {
return self::setError('你已经生成过合同,请勿重复生成');
}
if($type==1){
$name=$result['company_name'];
$data = [
'name' => $name . '的合同',
'signatories' => [
['fullName' => $name, 'identityType' => 12, 'identityCard' => $result['organization_code'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1], // 'authLevel'=>[11], 签约时验证人脸识别
['fullName' => $result['contract']['party_a_info']['company_name'], 'identityType' => 12, 'identityCard' => $result['contract']['party_a_info']['organization_code'], 'email' => $result['contract']['party_a_info']['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]
],
'url' => $result['contract']['file'],
];
}else{
$name=$result['nickname'];
$data = [
'name' => $name . '的合同',
'signatories' => [
['fullName' => $name, 'identityType' => 1, 'identityCard' => $result['id_card'], 'mobile' => $result['mobile'], 'noNeedVerify' => 1, 'signLevel' => 1],
['fullName' => $result['contract']['party_a_info']['company_name'], 'identityType' => 12, 'identityCard' => $result['contract']['party_a_info']['organization_code'], 'email' => $result['contract']['party_a_info']['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]
],
'url' => $result['contract']['file']
];
}
$res = app(JunziqianController::class)->Signing($data, $result['contract']['id']);
if ($res->success == true) {
Db::connect('mysql2')->name('la_contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data, 'check_status' => 3]);
self::postsms(['id'=>$result['contract']['id']]);
return true;
} else {
return self::setError($res->msg);
}
} else {
return self::setError('生成合同成功失败,联系管理员');
}
}
//**发送短信 */
public static function postsms($params)
{
$result = self::detail($params);
Log::info(['发送合同短信', $result]);
if ($result && $result['file'] != '') {
//发送短信
$data = [
[
"applyNo" => $result['contract_no'], //TODO *
"fullName" => $result['party_a_info']['company_name'], //TODO *
"identityCard" => $result['party_a_info']['organization_code'], //TODO *
"identityType" => 12, //TODO *
"master_phone" => $result['party_a_info']['master_phone'],
"type"=>"party_a"
],
];
if($result['type']==1){
$data[]= [
"applyNo" => $result['contract_no'], //TODO *
"fullName" => $result['party_b_info']['company_name'], //TODO *
"identityCard" => $result['party_b_info']['organization_code'], //TODO *
"identityType" => 12, //TODO *
"master_phone" => $result['party_b_info']['master_phone'],
"type"=>"party_b"
];
}else{
$data[]= [
"applyNo" => $result['contract_no'], //TODO *
"fullName" => $result['party_b_info']['nickname'], //TODO *
"identityCard" => $result['party_b_info']['id_card'], //TODO *
"identityType" => 1, //TODO *
"master_phone" => $result['party_b_info']['mobile'],
"type"=>"party_b"
];
}
$find = Db::connect('mysql2')->name('la_contract')->where('id', $params['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::connect('mysql2')->name('la_dict_data')->where('id', $data['contract_type'])->value('name');
})->find();
$url = [];
foreach ($data as $k => $v) {
$res = app(JunziqianController::class)->SigningLink($v);
if ($res->success == true) {
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' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $find['id'].'&type='.$v['type'],
'scene' => 'WQ'
];
Log::info(['发送合同短信-消息体', $sms]);
$result = SmsLogic::contractUrl($sms);
if ($result != true) {
return self::setError(SmsLogic::getError());
}
} else {
return self::setError($res->msg);
}
}
Db::connect('mysql2')->name('la_contract')->where('id', $find['id'])->update(['url' => json_encode($url)]);
return true;
}else{
return self::setError('没找到合同,联系管理员');
}
}
}

View File

@ -1,8 +0,0 @@
<?php
namespace app\common\logic\user;
class WorkerUserLogic
{
}

View File

@ -1,11 +0,0 @@
<?php
namespace app\common\model\WorkerAdmin;
use app\common\model\BaseModel;
class WorkerAdmin extends BaseModel
{
protected $connection = 'mysql2';
protected $name = 'la_admin';
}

View File

@ -1,68 +0,0 @@
<?php
namespace app\common\model\company;
use app\common\model\BaseModel;
use app\common\model\contract\Contract;
use app\common\model\dict\DictData;
use think\facade\Db;
use think\model\concern\SoftDelete;
class Company extends BaseModel
{
use SoftDelete;
protected $connection = 'mysql2';
protected $name = 'la_company';
protected $deleteTime = 'delete_time';
public function getCompanyTypeNameAttr($value)
{
return DictData::where('id', $value)->value('name');
}
public function getProvinceNameAttr($value)
{
return Db::name('geo_province')->where(['province_code' => $this->province])->value('province_name');
}
public function getCityNameAttr($value)
{
return Db::name('geo_city')->where(['city_code' => $this->city])->value('city_name');
}
public function getAreaNameAttr($value)
{
return Db::name('geo_area')->where(['area_code' => $this->area])->value('area_name');
}
public function getStreetNameAttr($value)
{
return Db::name('geo_street')->where(['street_code' => $this->street])->value('street_name');
}
public function getVillageNameAttr($value)
{
return Db::name('geo_village')->where(['village_code' => $this->village])->value('village_name');
}
public function getBrigadeNameAttr($value)
{
return Db::name('geo_brigade')->where(['id' => $this->brigade])->value('brigade_name');
}
public function getAreaManagerNameAttr($value)
{
return Db::name('admin')->where(['id' => $this->area_manager])->value('name');
}
public function getContractAttr()
{
$find=Contract::where('party_a|party_b', $this->id)->field('check_status,status')->find();
if($find){
return $find->toArray();
}else{
return [];
}
}
}

View File

@ -1,47 +0,0 @@
<?php
namespace app\common\model\contract;
use app\common\model\BaseModel;
use app\common\model\company\Company;
use app\common\model\dict\WorkerDictData;
class Contract extends BaseModel
{
protected $connection = 'mysql2';
protected $name = 'la_contract';
public function companyName(): \think\model\relation\HasOne
{
return $this->hasOne(Company::class, 'id', 'company_id')->bind(['company_name']);
}
public function company(): \think\model\relation\HasOne
{
return $this->hasOne(Company::class, 'id', 'company_id');
}
public function partyAInfo(): \think\model\relation\HasOne
{
return $this->hasOne(Company::class, 'id', 'party_a')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager');
}
public function partyBInfo(): \think\model\relation\HasOne
{
return $this->hasOne(Company::class, 'id', 'party_b')->field('id,company_name,organization_code,master_name,master_phone,master_email,area_manager');
}
public function partyA(): \think\model\relation\HasOne
{
return $this->hasOne(Company::class, 'id', 'party_a')->bind(['party_a_name' => 'company_name']);
}
public function partyB(): \think\model\relation\HasOne
{
return $this->hasOne(Company::class, 'id', 'party_b')->bind(['party_b_name' => 'company_name']);
}
public function contractType(): \think\model\relation\HasOne
{
return $this->hasOne(WorkerDictData::class, 'id', 'contract_type')->bind(['contract_type_name' => 'name']);
}
public function getContractTypeNameAttr($value)
{
return WorkerDictData::where(['id' => $this->contract_type])->value('name');
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace app\common\model\contract;
use app\common\model\BaseModel;
class VehicleContract extends BaseModel
{
protected $connection = 'mysql2';
protected $name = 'la_vehicle_contract';
}

View File

@ -1,24 +0,0 @@
<?php
namespace app\common\model\dict;
use app\common\model\BaseModel;
class WorkerDictData extends BaseModel
{
protected $connection = 'mysql2';
protected $name = 'la_dict_data';
public function getStatusDescAttr($value, $data): string
{
return $data['status'] ? '正常' : '停用';
}
// 根据镇农科公司任务类型获取code
public function getTownTaskType($typeId){
$townTaskTypeList = WorkerDictData::where(['type_value' => 'town_task_type', 'status' => 1])->column('value', 'id');
if(isset($townTaskTypeList[$typeId])) {
return $townTaskTypeList[$typeId];
}
return '';
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace app\common\model\user;
use app\common\model\BaseModel;
class WorkerUser extends BaseModel
{
protected $connection = 'mysql2';
protected $name = 'la_user';
}

View File

@ -1,11 +0,0 @@
<?php
namespace app\common\model\vehicle;
use app\common\model\BaseModel;
class VehicleBuyRecord extends BaseModel
{
protected $connection = 'mysql2';
protected $name = 'la_vehicle_buy_record';
}

View File

@ -1,11 +0,0 @@
<?php
namespace app\common\model\vehicle;
use app\common\model\BaseModel;
class VehicleRent extends BaseModel
{
protected $connection = 'mysql2';
protected $name = 'la_vehicle_rent';
}

View File

@ -1,52 +0,0 @@
<?php
namespace junziqian\sdk\bean;
use junziqian\sdk\util\CommonUtil;
/**
* Interface Req2MapInterface
* @package com\junziqian\sdk\bean
* @edit yfx 2019-10-29
*/
abstract class Req2MapInterface{
/**
* @return mixed object转array(第二层要看情况转,所以无法通用)
*/
public function build(){
$arr= self::getObject2Array($this);
return $arr;
}
/**
* 对象转为数组,如果已经是数组,则会清空数组
* @param $obj
* @param $immPramas array 直转不做处理的属性
* @return array
*/
static function getObject2Array($obj,$ignoreParams=null){
$_array = is_object($obj) ? get_object_vars($obj) : $obj;
$array=array();
foreach ($_array as $key => $value) {
if(is_null($value)){
continue;
}else if($ignoreParams!=null&&in_array($key, $ignoreParams)){
continue;
}else if(is_a($value,'CURLFile')){
$array[$key] = $value;//文件直接处理
}else if(is_array($value)){
$array[$key] = CommonUtil::json_encode($value);//文件直接处理
}else if(is_a($value,"com\junziqian\sdk\bean\Req2MapInterface")){
$array[$key] = CommonUtil::json_encode($value);//
}else if(is_object($value)){
//is_object 对数字、数组等都是返回false
$array[$key] = CommonUtil::json_encode($value);//
}else{
if(is_string($value)&&""==$value){
continue;
}
$array[$key] = $value;//文件直接处理
}
}
return $array;
}
}

View File

@ -1,110 +0,0 @@
<?php
namespace junziqian\sdk\bean\req\sign;
use junziqian\sdk\bean\Req2MapInterface;
use junziqian\sdk\util\CommonUtil;
/**
* Class ApplySignReq 签约发起-合同
* @package com\junziqian\sdk\bean\req\sign
* @edit yfx 2019-10-29
*/
class ApplySignReq extends Req2MapInterface {
//@ApiModelProperty(value = "合同名称",required = true)
public $contractName;
//@ApiModelProperty(value = "签收方",required = true)
public $signatories;
//@ApiModelProperty(value = "是否需要服务端证书云证书非1不需要默认;1需要")
public $serverCa;
/**处理方式*/
//@ApiModelProperty(value = "处理方式:为空或0时默认为手签合同;1自动签约;2只保全;5部份自动签;6HASH只保全;7收集批量签")
public $dealType;
//@ApiModelProperty(value = "dealType=6时必须传入,文件的sha512HexString值")
public $hashValue;
/**-----------合同文件相关----------**/
//@ApiModelProperty(value = "合同上传方式:0或null直接上传PDF;1url地址下载;2tmpl模版生成;3html文件上传")
public $fileType;
//@ApiModelProperty(value = "dealType!=6,fileType=0或null,时必须传入,合同文件;请使用form表单上传文件")
public $file;
//@ApiModelProperty(value = "dealType!=6,fileType=1,时必须传入,合同PDF文件的url地址")
public $url;
//@ApiModelProperty(value = "dealType!=6,fileType=2,时必须传入,合同模版编号")
public $templateNo;
//@ApiModelProperty(value = "dealType!=6,fileType=2,时必须传入,合同模版参数JSON字符串")
public $templateParams;
//@ApiModelProperty(value = "dealType!=6,fileType=3,时必须传入,合同html文件")
public $htmlContent;
/**-----------合同文件相关 end----------**/
//@ApiModelProperty(value = "指定公章位置类型:0或null使用签字座标位置或不指定签字位置;1表单域定位(表单域如果上传为pdf时,需pdf自行定义好表单域,html及url及tmpl等需定义好input标签);2关键字定义")
public $positionType;
//@ApiModelProperty(value = "验证方式为人脸时必传,人脸识别等级:默认等级(1-100之间整数),建议范围(60-79)")
public $faceThreshold;
//@ApiModelProperty(value = "是否按顺序签字非1为不按1为按")
public $orderFlag;
//@ApiModelProperty(value = "合同查看二维码0默认不1显示")
public $qrCode;
//@ApiModelProperty(value = "不显示ebq的保全章:1 不显示但会签名,2不显示也不签名;0或其它-显示")
public $noEbqSign;
//@ApiModelProperty(value = "合同金额")
public $contractAmount;
//@ApiModelProperty(value = "备注")
public $remark;
//@ApiModelProperty(value = " 前置记录此记录会计录到签约日志中并保全到日志保全和最终的证据保全中最大字符不能超过2000字符串")
public $preRecored;
//@ApiModelProperty(value = "多合同顺序签约Info")
public $sequenceInfo;
//@ApiModelProperty(value = "合同附件,虽不限个数,但包括合同原文件,不能超过20MB")
public $attachFiles;
//@ApiModelProperty(value = "是否使用视频签约:0或null不使用;1使用(使用时必须购买相应套餐)")
public $ifWebRtc;
//@ApiModelProperty(value = "是否使用骑缝章:1使用;其它不使用")
public $needQifengSign;
//@ApiModelProperty(value = "是否归档:0不归档;1归档(默认)")
public $isArchive;
//@ApiModelProperty(value = "是否可以拒签:0或null不能拒签(默认);1可拒签")
public $canRefuse;
//@ApiModelProperty(value = "是否不显示个人标准章边框:1不显示,其它显示边框(默认)")
public $noBorderSign;
//回调地址
public $notifyUrl;
//@Override
public function build() {
$arr= self::getObject2Array($this,array("attachFiles"));
if($this->attachFiles!=null&&sizeof($this->attachFiles)>0){
$i=0;
foreach($this->attachFiles as $value){
$arr["attachFiles[".$i."]"]=$value;
$i = $i+1;
}
}
return $arr;
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace junziqian\sdk\bean\req\sign\ext;
/**
* Class SequenceInfo 合同顺序信息
* @package com\junziqian\sdk\bean\req\sign\ext
* @edit yfx 2019-10-29
*/
class SequenceInfo{
//@ApiModelProperty(value = "客户方合同的唯一编号",required = true)
public $businessNo;
//@ApiModelProperty(value = "签约顺序号",required = true)
public $sequenceOrder;
//@ApiModelProperty(value = "总份数",required = true)
public $totalNum;
/**
* SequenceInfo constructor.
* @param $businessNo
* @param $sequenceOrder
* @param $totalNum
*/
public function __construct($businessNo, $sequenceOrder, $totalNum){
$this->businessNo = $businessNo;
$this->sequenceOrder = $sequenceOrder;
$this->totalNum = $totalNum;
}
}

View File

@ -1,88 +0,0 @@
<?php
namespace junziqian\sdk\bean\req\sign\ext;
/**
* Class SignatoryReq 签约方信息
* @package com\junziqian\sdk\bean\req\sign\ext
* @edit yfx 2019-10-29
*/
class SignatoryReq{
//@ApiModelProperty(value = "签约方名称,不超过50个字符",required = true)
public $fullName;
//@ApiModelProperty(value = "身份类型:1身份证,2护照,3台胞证,4港澳居民来往内地通行证,11营业执照,12统一社会信用代码",required = true)
public $identityType;
//@ApiModelProperty(value = "证件号不超过50个字符",required = true)
public $identityCard;
//@ApiModelProperty(value = "手机号码个人必传11个字符")
public $mobile;
//@ApiModelProperty(value = "邮箱,企业必传")
public $email;
//@ApiModelProperty(value = "签字顺序:连续签orderNum只是针对于当前合同,顺序签时需指定")
public $orderNum;
//@ApiModelProperty(value = "签字位置座标信息:positionType=0时可以传入chapteJson")
public $chapteJson;
//@ApiModelProperty(value = "签字位置-表单域名ID:positionType=1时必须传入")
public $chapteName;
//@ApiModelProperty(value = "签字位置-按关键字签署positionType=2时必须传入关键字支持多个;以英文;分隔")
public $searchKey;
//@ApiModelProperty(value = "签字位置-按关键字查询-扩展positionType=2时可以传入,支持指定查询页数/关键字颜色/透明度.可参考相关说明")
public $searchExtend;
//@ApiModelProperty(value = "签字位置-按关键字查询-结果转换的配置positionType=2时可以传入,可配置查询结果的位置偏移.可参考后面说明")
public $searchConvertExtend;
//@ApiModelProperty(value = "签约方需要手签时是否不先行验证手机或邮箱:1不验证其它验证(默认)")
public $noNeedVerify;
//@ApiModelProperty(value = " 是否使用自动签0或null不使用1自动(当且只当合同处理方式为部份自动或收集批量签时有效);有些场景必须serverCaAuto=1")
public $serverCaAuto;
//@ApiModelProperty(value = "验证等级(传数组字符串):[2,3];2银行卡认证,10三要素认证,11人脸识别,12验证码验证")
public $authLevel;
//@ApiModelProperty(value = "最小验证种类:默认为authLevel数组长度;必须小于authLevel长度且大于0(等于0时按authLevel数组长度计录);如authLevel=[2,3,10],authLevelRange=2表过只需要验证其中的两项即可")
public $authLevelRange;
//@ApiModelProperty(value = "签字类型,标准图形章或公章:0标准图形章,1公章或手写,2公章手写或手写")
public $signLevel;
//@ApiModelProperty(value = "强制添加现场:0或null不强制添加现场,1强制添加现场")
public $forceEvidence;
//@ApiModelProperty(value = "买保险年数:1-3购买年限,基它不买;注需要有相应的套餐")
public $insureYear;
//@ApiModelProperty(value = "强制阅读多少秒单位1-300秒")
public $readTime;
//@ApiModelProperty(value = "企业用户指定签章ID:此值需为商户上传的自定义公章ID或商户创建的企业的自定义公章ID。自定义公章可通过sass或api上传")
public $signId;
//@ApiModelProperty(value = "标准章时是否对个人或企业章图片打码0不打1打码")
public $nameHideStatus;
//@ApiModelProperty(value = "h5人脸订单号,如使用过君子签提供的人脸认证服务可以上传其订单号")
public $h5FaceOrderNo;
//@ApiModelProperty(value = "现场存证只能上传视频:1是其它不是(默认)")
public $onlyVideoEvidence;
//@ApiModelProperty(value = "现场存证自定义标题")
public $evidenceTitle;
//@ApiModelProperty(value = "是否使用电子保管函1使用0或其它不使用;使用时需有相应套餐")
public $safeKeepLetterFlag;
//@ApiModelProperty(value = "api发起显示确认签字")
public $apiAffirm;
}

View File

@ -1,75 +0,0 @@
<?php
namespace junziqian\sdk\bean\req\user;
use junziqian\sdk\bean\Req2MapInterface;
/**
* Class OrganizationCreateReq 组织创建及重传
* @package com\junziqian\sdk\bean\req\user
* @edit yfx 2019-10-29
*/
class OrganizationCreateReq extends Req2MapInterface{
//@ApiModelProperty(value = " 邮箱或手机号",required = true)
public $emailOrMobile;
//@ApiModelProperty(value = " 名称",required = true)
public $name;
//@ApiModelProperty(value = "组织类型 0企业,1事业单位",required = true,allowableValues = "0,1")
public $organizationType;
//@ApiModelProperty(value = "证明类型0多证,1多证合一",required = true,allowableValues = "0,1")
public $identificationType;
//@ApiModelProperty(value = "组织注册编号,营业执照号或事业单位事证号或统一社会信用代码",required = true)
public $organizationRegNo;
//@ApiModelProperty(value = "组织注册证件扫描件,营业执照或事业单位法人证书",required = true)
public $organizationRegImg;
//@ApiModelProperty(value = "法人姓名",required = false)
public $legalName;
//@ApiModelProperty(value = "法人身份证号",required = false)
public $legalIdentityCard;
//@ApiModelProperty(value = "法人电话号码",required = false)
public $legalMobile;
//@ApiModelProperty(value = "法人身份证正面",required = false)
public $legalIdentityFrontImg;
//@ApiModelProperty(value = "法人身份证反面",required = false)
public $legalIdentityBackImg;
//@ApiModelProperty(value = "公章签章图片",required = false)
public $signImg;
//@ApiModelProperty(value = "法人住址",required = false)
public $address;
//@ApiModelProperty(value = "企业授权人姓名",required = false)
public $authorizeName;
//@ApiModelProperty(value = "企业授权人身份证号",required = false)
public $authorizeCard;
//@ApiModelProperty(value = "企业授权人手机号",required = false)
public $authorizeMobilePhone;
//@ApiModelProperty(value = "组织结构代码",required = false)
public $organizationCode;
//@ApiModelProperty(value = "组织结构代码扫描件",required = false)
public $organizationCodeImg;
//@ApiModelProperty(value = "税务登记扫描件,事业单位选填,普通企业必选",required = false)
public $taxCertificateImg;
//@ApiModelProperty(value = "签约申请书扫描图",required = false)
public $signApplication;
//回调地址
public $notifyUrl;
}

View File

@ -1,42 +0,0 @@
<?php
namespace junziqian\sdk\bean\req\user;
use junziqian\sdk\bean\Req2MapInterface;
class OrganizationFaceCreateReq extends Req2MapInterface
{
//@ApiModelProperty(value = "唯一流水号,自定义",required = true)
public $orderNo;
//@ApiModelProperty(value = "唯一邮箱,自定义",required = true)
public $email;
//@ApiModelProperty(value = "企业证件名称",required = true)
public $enterpriseName;
//@ApiModelProperty(value = "统一社会信用号",required = true)
public $identityNo;
//@ApiModelProperty(value = "法人名称",required = true)
public $legalPersonName;
//@ApiModelProperty(value = "法人证件号",required = true)
public $legalIdentityCard;
//@ApiModelProperty(value = "法人手机号",required = true)
public $legalMobile;
//@ApiModelProperty(value = "验证人类型1代理人不传则是法人")
public $facePerType;
//@ApiModelProperty(value = "人脸验证代理人-名称",required = true)
public $faceAgantIdenName;
//@ApiModelProperty(value = "人脸验证代理人-证件号",required = true)
public $faceAgantIdenCard;
//@ApiModelProperty(value = "同步回调地址",required = true)
public $backUrl;
}

View File

@ -1,55 +0,0 @@
<?php
namespace junziqian\sdk\util;
use junziqian\sdk\util\exception\ResultInfoException;
/**
* Class Assert 断言工具,方便抛出异常,由统一异常处理工具类捕获异常直接返回
* @package com\junziqian\sdk\util
*/
class Assert{
/**
* 判断为真
* @param $flag bool 判断结果
* @param $msg string 为空时异常信息
*/
static function isTrue($flag,$msg="值不为True"){
if(!$flag){
throw new ResultInfoException($msg,"PARAM_ERROR");
}
}
/**
* 断言为NULL
* @param $flag
* @param string $msg
*/
static function isNull($flag,$msg="值不为NULL"){
if(!is_null($flag)){
throw new ResultInfoException($msg,"PARAM_ERROR");
}
}
/**
* 断言不为空
* @param $flag
* @param string $msg
*/
static function notNull($flag,$msg="值为NULL"){
if(is_null($flag)){
throw new ResultInfoException($msg,"PARAM_ERROR");
}
}
/**
* 断方不为BLANK
* @param $flag
* @param string $msg
*/
static function notBlank($flag,$msg="值为BLANK"){
if(is_null($flag)||trim($flag)==''||$flag=='null'){
throw new ResultInfoException($msg,"PARAM_ERROR");
}
}
}

View File

@ -1,45 +0,0 @@
<?php
namespace junziqian\sdk\util;
/**
* Class CommonUtil 通用工具类
* @package com\junziqian\sdk
*/
class CommonUtil{
/**
* 使json_encode支持5.4.0以下
* @param $value object|array 传入为对象
* @return mixed|string
*/
static function json_encode($value){
if (version_compare(PHP_VERSION,'5.4.0','<')){
$str = json_encode($value);
$str = preg_replace_callback("#\\\u([0-9a-f]{4})#i",
function($matchs){
return iconv('UCS-2BE', 'UTF-8', pack('H4', $matchs[1]));
},
$str
);
return $str;
}else{
return json_encode($value, JSON_UNESCAPED_UNICODE);
}
}
/**
* 处理无效params转数字null或0为'0'
* @param null $str
* @return string
*/
static function trim($str=null){
if(is_null($str)){
if(is_numeric($str)){
return '0';
}
return '';
}else{
return trim($str.'');
}
}
}

View File

@ -1,106 +0,0 @@
<?php
namespace junziqian\sdk\util;
use junziqian\sdk\util\exception\ResultInfoException;
use junziqian\sdk\util\http\HttpClientUtils;
use think\facade\Log;
/**
* Class RequestUtils http请求
* @package com\junziqian\sdk\bean
* @edit yfx 2019-10-29
*/
class RequestUtils{
/**请求地址*/
private $serviceUrl;
/**appkey*/
private $appkey;
/**secret*/
private $appSecret;
/**默认加密方式:不输入使用sha256,其它可选择项md5,sha1,sha3-256*/
private $encryMethod;
/**默认ts单位:1毫秒,2秒*/
private $tsType;
/**
* RequestUtils constructor.
* @param $serviceUrl
* @param $appkey
* @param $appSecret
*/
public function __construct($serviceUrl, $appkey, $appSecret,$encryMethod=null,$tsType=2){
Assert::notBlank($serviceUrl,"serviceUrl不能为空");
Assert::notBlank($appkey,"appkey不能为空");
Assert::notBlank($appSecret,"appSecret不能为空");
$this->serviceUrl = $serviceUrl;
$this->appkey = $appkey;
$this->appSecret = $appSecret;
$this->encryMethod = $encryMethod;
$this->tsType = $tsType;
if(!is_null($this->encryMethod)){
$this->encryMethod=strtolower($this->encryMethod);
}
}
/**
* @param $path
* @return object
*/
public function doPost($path,$req=null){
Assert::notBlank($path,"path不能为空");
$url=$this->serviceUrl.$path;
if($req==null){
$req=Array();
}else if(is_array($req)){
//
}else if(is_a($req,"junziqian\sdk\bean\Req2MapInterface")){
$req=$req->build();
}else{
throw new ResultInfoException("不支持的请求req");
}
$req=$this->fillSign($req);
// Log::error([$url,json_encode($req)]);
//请求服务端sass
// halt($url,$req);
//print_r(CommonUtil::json_encode($req));
$response= HttpClientUtils::getPost($url,$req);
$res=json_decode($response);
Assert::notNull($res,"不能转换为JSON:".$response);
return $res;
}
/**
* 填充签名数据
* @param $req array
*/
public function fillSign($req){
/**默认加密方式:不输入使用sha256,其它可选择项md5,sha1,sha3-256*/
$ts=time();
if($this->tsType==1){
$ts=$ts*1000;
}
$sign=null;
$nonce= md5($ts."");
$signSrc="nonce".$nonce."ts".$ts."app_key".$this->appkey."app_secret".$this->appSecret;
if($this->encryMethod==null||$this->encryMethod=="sha256"){
$sign=ShaUtils::getSha256($signSrc);
}else if($this->encryMethod=="sha1"){
$sign=ShaUtils::getSha1($signSrc);
}else if($this->encryMethod=="md5"){
$sign=md5($signSrc);
}else{
throw new ResultInfoException($this->encryMethod.",必须为md5,sha1,sha256之一","PARAM_ERROR");
}
$req['ts']=$ts;
$req['app_key']=$this->appkey;
$req['sign']=$sign;
$req['nonce']=$nonce;//这只是为了生成一个随机值
if($this->encryMethod!=null){
$req['encry_method']=$this->encryMethod;//为''也不能传
}
return $req;
}
}

View File

@ -1,56 +0,0 @@
<?php
namespace junziqian\sdk\util;
/**
* 以下只针对utf-8字符串进行sha加密
* Class ShaUtils
* @package org\ebq\api\tool
* @edit yfx 2019-10-29
*/
class ShaUtils {
/*
* 加密字符串sha1
* $str 字符串
*/
static function getSha1($str) {
return sha1 ( $str );
}
/*
* 加密字符串sha256
* $str 字符串
*/
static function getSha256($str) {
return hash ( 'sha256', $str );
}
/*
* 加密字符串sha512
* $str 字符串
*/
static function getSha512($str) {
return hash ( 'sha512', $str );
}
/*
* 加密文件sha1
* $filePath 文件路径
*/
static function getFileSha1($filePath) {
return sha1_file ( $filePath );
}
/*
* 加密文件sha256
* $filePath 文件路径
*/
static function getFileSha256($filePath) {
$str = file_get_contents ( $filePath );
return self::getSha256 ( $str );
}
/*
* 加密文件sha512
* $filePath 文件路径
*/
static function getFileSha512($filePath) {
$str = file_get_contents ( $filePath );
return self::getSha512 ( $str );
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace junziqian\sdk\util\exception;
/**
* 异常信息类
* Class ResultInfoException
* @package com\junziqian\sdk\util\exception
* @edit yfx 2019-10-29
*/
class ResultInfoException extends \RuntimeException {
/**
* @var string 异常码
*/
private $resultCode;
/**
* ResultInfoException constructor.
* @param string $message 异常信息
* @param string $resultCode 异常码
*/
public function __construct($message = "",$resultCode="PARAM_ERROR"){
parent::__construct($message, null, null);
}
/**
* @return string 异常吗
*/
public function getResultCode(){
return $this->resultCode;
}
}

View File

@ -1,89 +0,0 @@
<?php
namespace junziqian\sdk\util\http;
use junziqian\sdk\util\exception\ResultInfoException;
/**
* Class HttpClientUtils
* @package com\junziqian\sdk\util\http
* @edit yfx 2019-10-29
*/
class HttpClientUtils{
/**
* post请求
* @param $url string
* @param $req array
* @return string
*/
public static function getPost($url,$req){
//ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)');
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //验证curl对等证书(一般只要此项)
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //检查服务器SSL证书中是否存在一个公用名
curl_setopt($ch, CURLOPT_SSLVERSION, 0); //传递一个包含SSL版本的长参数。
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_POST, true);
if(version_compare(PHP_VERSION, '5.6')&&!version_compare(PHP_VERSION, '7.0')){
curl_setopt ( $ch, CURLOPT_SAFE_UPLOAD, false);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
$response = curl_exec($ch);
if(!curl_error($ch)) {
return $response;
} else {
throw new ResultInfoException(curl_error($ch),"POST_ERROR");
}
}
/**
* http文件下载
* @param $url 原文件地址
* @param string $file 文件路径
* @param int $timeout 超时设置,默认60秒
* @return bool|mixed|string
*/
public static function httpcopy($url, $file="", $timeout=60) {
$file = empty($file) ? pathinfo($url,PATHINFO_BASENAME) : $file;
$dir = pathinfo($file,PATHINFO_DIRNAME);
!is_dir($dir) && @mkdir($dir,0755,true);
$url = str_replace(" ","%20",$url);
if(function_exists('curl_init')) {
$headers['User-Agent'] = 'windows';
$headerArr = array();
foreach( $headers as $n => $v ) {
$headerArr[] = $n .':' . $v;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$temp = curl_exec($ch);
if(@file_put_contents($file, $temp) && !curl_error($ch)) {
return $file;
} else {
throw new ResultInfoException(curl_error($ch),"POST_ERROR");
}
} else {
$params = array(
"http"=>array(
"method"=>"GET",
"header"=>"User-Agent:windows",
"timeout"=>$timeout)
);
$context = stream_context_create($params);
if(@copy($url, $file, $context)) {
//$http_response_header
return $file;
} else {
return false;
}
}
}
}