修复bug
This commit is contained in:
parent
e0faf898b1
commit
28c6f0dd2b
@ -125,10 +125,10 @@ class CompanyController extends BaseAdminController
|
||||
if ($result && $result['contract'] && $result['contract']['file'] != '') {
|
||||
$data = [
|
||||
'name' => $result['company_name'] . '合同',
|
||||
'signatories' => [['fullName' => $result['company_name'], 'identityType' => 12, 'identityCard' => $result['organization_code'], 'mobile' => $result['master_phone'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]],
|
||||
'signatories' => [['fullName' => $result['company_name'], 'identityType' => 12, 'identityCard' => $result['organization_code'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]],
|
||||
'url' => $result['contract']['file']
|
||||
];
|
||||
$res = app(JunziqianController::class)->Signing($data);
|
||||
$res = app(JunziqianController::class)->Signing($data,$result['contract']['id']);
|
||||
if ($res->success == true) {
|
||||
Db::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data]);
|
||||
$company = Db::name('company')->where('id', $params['id'])->find();
|
||||
@ -221,7 +221,7 @@ class CompanyController extends BaseAdminController
|
||||
];
|
||||
$res = app(JunziqianController::class)->EnterpriseCertification($data);
|
||||
if ($res->success == true) {
|
||||
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data]);
|
||||
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data,'is_authentication'=>1]);
|
||||
return $this->success('认证成功', ['email' => $res->data], 1, 1);
|
||||
} else {
|
||||
return $this->fail($res->msg);
|
||||
@ -271,8 +271,9 @@ class CompanyController extends BaseAdminController
|
||||
public function subordinate($company_id)
|
||||
{
|
||||
$company = Company::findOrEmpty($company_id);
|
||||
$result = loopGetChild(Company::class, $company->id, 'level_one');
|
||||
return $this->success('success', $result);
|
||||
$result = loopGetChild(Company::class, $company->id, 'level_one','company_name,id,company_type,area,area area_name,street,street street_name,is_contract,area_manager,area_manager area_manager_name,master_name,master_phone');
|
||||
$data['lists']=$result;
|
||||
return $this->success('success', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,17 +54,15 @@ class AdminController extends BaseAdminController
|
||||
public function add()
|
||||
{
|
||||
$params = Request::param();
|
||||
|
||||
if (empty($params['party_a'])) {
|
||||
return $this->fail('签约方不能为空');
|
||||
}
|
||||
// if (empty($params['party_a'])) {
|
||||
// return $this->fail('签约方不能为空');
|
||||
// }
|
||||
try {
|
||||
$params['phone'] = $params['account'];
|
||||
$params['password'] = 'm' . $params['account'];
|
||||
$params['password_confirm'] = 'm' . $params['account'];
|
||||
$params['root'] = 0;
|
||||
$params['qualification'] = json_encode($params['qualification']);
|
||||
$params['disable'] = 1;
|
||||
validate(AdminValidate::class)
|
||||
->scene('add')->check($params);
|
||||
} catch (ValidateException $e) {
|
||||
@ -89,11 +87,13 @@ class AdminController extends BaseAdminController
|
||||
public function edit()
|
||||
{
|
||||
$params = (new AdminValidate())->post()->goCheck('edit');
|
||||
if (empty($params['party_a'])) {
|
||||
return $this->fail('签约方不能为空');
|
||||
}
|
||||
// if (empty($params['party_a'])) {
|
||||
// return $this->fail('签约方不能为空');
|
||||
// }
|
||||
$params['disable'] = $params['disable'] ?? 0;
|
||||
$params['qualification'] = json_encode($params['qualification']);
|
||||
if(isset($params['qualification'])){
|
||||
$params['qualification'] = json_encode($params['qualification']);
|
||||
}
|
||||
$result = AdminLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
@ -169,7 +169,7 @@ class AdminController extends BaseAdminController
|
||||
'signatories' => [['fullName' => $result['name'], 'identityType' => 1, 'identityCard' => $result['id_card'], 'mobile' => $result['account'], 'noNeedVerify' => 1, 'signLevel' => 1]],
|
||||
'url' => $result['contract']['file']
|
||||
];
|
||||
$res = app(JunziqianController::class)->Signing($data);
|
||||
$res = app(JunziqianController::class)->Signing($data,$result['contract']['id']);
|
||||
if ($res->success == true) {
|
||||
Db::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data]);
|
||||
$data = array(
|
||||
|
@ -56,7 +56,7 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function lists(): array
|
||||
{
|
||||
return Company::where($this->searchWhere)
|
||||
->field(['id', 'level_two', 'level_one', 'company_name', 'organization_code', 'city', 'area', 'street', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'other_contacts', 'area_manager', 'is_contract', 'account', 'password', 'deposit', 'deposit_time', 'qualification', 'status'])
|
||||
->field(['is_authentication','id', 'level_two', 'level_one', 'company_name', 'organization_code', 'city', 'area', 'street', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'other_contacts', 'area_manager', 'is_contract', 'account', 'password', 'deposit', 'deposit_time', 'qualification', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->withAttr('company_type',function($value,$data){
|
||||
@ -71,13 +71,6 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
->withAttr('area_manager',function($value,$data){
|
||||
return Db::name('admin')->where('id',$value)->value('name');
|
||||
})
|
||||
->withAttr('is_contract',function($value,$data){
|
||||
if($value==1){
|
||||
return '已签约';
|
||||
}else{
|
||||
return '未签约';
|
||||
}
|
||||
})
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
@ -120,6 +120,9 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis
|
||||
$where[] = ['id', 'in', $adminIds];
|
||||
}
|
||||
}
|
||||
if(isset($this->params['company_id']) && $this->params['company_id'] != ''){
|
||||
$where[] = ['company_id', '=', $this->params['company_id']];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
@ -137,7 +140,7 @@ class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, Lis
|
||||
{
|
||||
$field = [
|
||||
'id', 'name', 'account', 'create_time', 'disable', 'root', 'province', 'city', 'area', 'street',
|
||||
'login_time', 'login_ip', 'multipoint_login', 'avatar', 'company_id', 'contract_id', 'create_time'
|
||||
'login_time', 'login_ip', 'multipoint_login', 'avatar', 'company_id', 'is_contract', 'create_time'
|
||||
];
|
||||
|
||||
$adminLists = Admin::field($field)
|
||||
|
@ -65,6 +65,15 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
}else{
|
||||
$item->party_b_name=Db::name('admin')->where('id',$item->party_b)->value('name');
|
||||
}
|
||||
$item->party_a_name=Db::name('company')->where('id',$item->party_a)->value('company_name');
|
||||
$area_manager_name=Db::name('admin')->where('id',$item->area_manager)->value('name');
|
||||
if($area_manager_name){
|
||||
$item->area_manager_name=$area_manager_name;
|
||||
}else{
|
||||
$item->area_manager_name='暂无片区经理';
|
||||
}
|
||||
$item->contract_type_name=Db::name('dict_data')->where('id',$item->contract_type)->value('name');
|
||||
$item->status_name=$item->status==1?'已签约':'未签约';
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ class CompanyLogic extends BaseLogic
|
||||
// if (!empty($exist)) {
|
||||
// throw new ValidateException('该账号已经注册过企业');
|
||||
// }
|
||||
$data=Company::create([
|
||||
$level_one = $params['contract']['party_a'] ?? 0;
|
||||
$data = Company::create([
|
||||
// 'level_two' => $params['level_two'],
|
||||
// 'level_one' => $params['level_one'],
|
||||
'company_name' => $params['company_name'],
|
||||
@ -62,7 +63,7 @@ class CompanyLogic extends BaseLogic
|
||||
'master_phone' => $params['master_phone'],
|
||||
'master_email' => $params['master_email'],
|
||||
'other_contacts' => $params['other_contacts'],
|
||||
'area_manager' => $params['area_manager']??0,
|
||||
'area_manager' => $params['area_manager'] ?? 0,
|
||||
// 'is_contract' => $params['is_contract'],
|
||||
// 'account' => $params['account'],
|
||||
// 'password' => $params['password'],
|
||||
@ -70,11 +71,12 @@ class CompanyLogic extends BaseLogic
|
||||
// 'deposit_time' => $params['deposit_time'],
|
||||
'qualification' => $params['qualification'],
|
||||
'admin_id' => $params['admin_id'] ?? 0,
|
||||
'level_one' => $params['contract']['party_a'] ?? 0,
|
||||
'level_one' => $level_one,
|
||||
// 'status' => $params['status']
|
||||
]);
|
||||
$contractId = self::contract($data['id'], $params);
|
||||
Company::update(['contract_id' => $contractId], ['id' => $data['id']]);
|
||||
if ($level_one > 0) {
|
||||
$contractId = self::contract($data['id'], $params);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -112,7 +114,7 @@ class CompanyLogic extends BaseLogic
|
||||
'master_phone' => $params['master_phone'],
|
||||
'master_email' => $params['master_email'],
|
||||
'other_contacts' => $params['other_contacts'],
|
||||
'area_manager' => $params['area_manager']??0,
|
||||
'area_manager' => $params['area_manager'] ?? 0,
|
||||
// 'is_contract' => $params['is_contract'],
|
||||
// 'account' => $params['account'],
|
||||
// 'password' => $params['password'],
|
||||
@ -123,7 +125,7 @@ class CompanyLogic extends BaseLogic
|
||||
'level_one' => $params['contract']['party_a'] ?? 0,
|
||||
// 'status' => $params['status']
|
||||
]);
|
||||
if($params['contract']){
|
||||
if ($params['contract']) {
|
||||
$contractId = self::contract($params['id'], $params);
|
||||
Company::update(['contract_id' => $contractId], ['id' => $params['id']]);
|
||||
}
|
||||
@ -159,25 +161,24 @@ class CompanyLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
|
||||
$data=Company::findOrEmpty($params['id'])->toArray();
|
||||
if($data){
|
||||
$data['other_contacts']=json_decode($data['other_contacts'],true);
|
||||
$data['qualification']=json_decode($data['qualification'],true);
|
||||
$data['admin_name']=Db::name('admin')->where('id',$data['admin_id'])->value('name');
|
||||
$data['area_manager_name']=Db::name('admin')->where('id',$data['area_manager'])->value('name');
|
||||
$data['contract']=Db::name('contract')->where('party_b',$data['id'])
|
||||
->withAttr('party_a_name',function($value,$data){
|
||||
return Db::name('company')->where('id',$data['party_a'])->value('company_name');
|
||||
})
|
||||
->find();
|
||||
$data = Company::findOrEmpty($params['id'])->toArray();
|
||||
if ($data) {
|
||||
$data['other_contacts'] = json_decode($data['other_contacts'], true);
|
||||
$data['qualification'] = json_decode($data['qualification'], true);
|
||||
$data['admin_name'] = Db::name('admin')->where('id', $data['admin_id'])->value('name');
|
||||
$data['area_manager_name'] = Db::name('admin')->where('id', $data['area_manager'])->value('name');
|
||||
$data['contract'] = Db::name('contract')->where('party_b', $data['id'])
|
||||
->withAttr('party_a_name', function ($value, $data) {
|
||||
return Db::name('company')->where('id', $data['party_a'])->value('company_name');
|
||||
})
|
||||
->find();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function contract($companyId, $params)
|
||||
{
|
||||
$model = Contract::where(['party_b'=>$companyId])->find();
|
||||
$model = Contract::where(['party_b' => $companyId])->find();
|
||||
if (empty($model)) {
|
||||
$model = new Contract();
|
||||
$model->contract_no = time();
|
||||
@ -203,5 +204,4 @@ class CompanyLogic extends BaseLogic
|
||||
}
|
||||
return array_filter($companyIds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,9 @@ class AdminLogic extends BaseLogic
|
||||
// 岗位
|
||||
// self::insertJobs($admin_id, $params['jobs_id'] ?? []);
|
||||
self::createUser($params, $password, $admin_id);
|
||||
self::contract($admin_id, $params);
|
||||
if($params['party_a']>0){
|
||||
self::contract($admin_id, $params);//生成合同
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -89,11 +91,14 @@ class AdminLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 基础信息
|
||||
$role_id_arr=explode(',',$params['role_id']) ?? [];
|
||||
if(is_array($params['role_id'])){
|
||||
$role_id_arr=$params['role_id'];
|
||||
}else{
|
||||
$role_id_arr=explode(',',$params['role_id']) ?? [];
|
||||
}
|
||||
$data=$params;
|
||||
// 头像
|
||||
$data['avatar'] = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : '';
|
||||
|
||||
// 密码
|
||||
if (!empty($params['password'])) {
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
@ -113,6 +118,11 @@ class AdminLogic extends BaseLogic
|
||||
self::expireToken($token['token']);
|
||||
}
|
||||
}
|
||||
$is_contract=false;
|
||||
if(isset($params['party_a']) && $params['party_a']!=''){
|
||||
$data['company_id'] = $params['party_a'] ?? 0;
|
||||
$is_contract=true;
|
||||
}
|
||||
Admin::strict(false)->update($data);
|
||||
(new AdminAuthCache($params['id']))->clearAuthCache();
|
||||
|
||||
@ -122,7 +132,17 @@ class AdminLogic extends BaseLogic
|
||||
AdminJobs::delByUserId($params['id']);
|
||||
// 角色
|
||||
self::insertRole($params['id'], $role_id_arr);
|
||||
self::contract($params['id'], $params);
|
||||
if($is_contract){
|
||||
$datas=[
|
||||
'party_a' => $params['party_a'],
|
||||
'party_b' => $params['id'],
|
||||
'contract_type' => $params['contract_type'],
|
||||
'type' => 2,
|
||||
'file' => $params['file'],
|
||||
];
|
||||
self::contract($params['id'], $datas);//生成合同
|
||||
}
|
||||
//修改用户同步信息
|
||||
self::createUser($params, $data['password'] ?? '', $data['id']);
|
||||
// 部门
|
||||
// self::insertDept($params['id'], $params['dept_id'] ?? []);
|
||||
@ -167,7 +187,8 @@ class AdminLogic extends BaseLogic
|
||||
AdminRole::delByUserId($params['id']);
|
||||
AdminDept::delByUserId($params['id']);
|
||||
AdminJobs::delByUserId($params['id']);
|
||||
|
||||
//修改用户同步信息
|
||||
Db::name('user')->where(['admin_id'=>$params['id']])->update(['is_disable'=>1]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -229,7 +250,7 @@ class AdminLogic extends BaseLogic
|
||||
})
|
||||
->find();
|
||||
if (empty($admin['contract']['party_a'])) {
|
||||
$admin['contract']['party_a_name'] = '平台';
|
||||
$admin['contract']['party_a_name'] = '';
|
||||
} else {
|
||||
$admin['contract']['party_a_name'] = Company::where(['id' => $admin['contract']['party_a']])->value('company_name');
|
||||
}
|
||||
@ -356,8 +377,16 @@ class AdminLogic extends BaseLogic
|
||||
'admin_id' => $adminId,
|
||||
]);
|
||||
} else {
|
||||
$user->avatar = $admin['avatar'];
|
||||
$user->nickname = $admin['name'];
|
||||
if(isset($admin['avatar']) && $admin['avatar']!=''){
|
||||
$user->avatar = $admin['avatar'];
|
||||
}
|
||||
if(isset($admin['name']) && $admin['name']!=''){
|
||||
$user->nickname = $admin['name'];
|
||||
}
|
||||
if(isset($admin['disable']) && $admin['disable']!=''){
|
||||
$user->is_disable = $admin['disable'];
|
||||
}
|
||||
$user->admin_id=$adminId;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,31 @@ class ContractLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return Contract::with(['companyName','partyA','partyB','contractType'])->findOrEmpty($params['id'])->toArray();
|
||||
$data = Db::name('contract')->where('id', $params['id'])
|
||||
->withAttr('party_b_name', function ($value, $data) {
|
||||
if ($data['type'] == 1) {
|
||||
return Db::name('company')->where('id', $data['party_b'])->value('company_name');
|
||||
} else {
|
||||
return Db::name('admin')->where('id', $data['party_b'])->value('name');
|
||||
}
|
||||
})
|
||||
->withAttr('party_a_name', function ($value, $data) {
|
||||
return Db::name('company')->where('id', $data['party_a'])->value('company_name');
|
||||
|
||||
})
|
||||
->withAttr('area_manager_name', function ($value, $data) {
|
||||
return Db::name('admin')->where('id', $data['area_manager'])->value('name');
|
||||
})
|
||||
->withAttr('contract_type_name', function ($value, $data) {
|
||||
return Db::name('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();
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class CompanyValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['company_name','organization_code','master_name','master_position','master_phone','master_email']);
|
||||
return $this->only(['company_name','organization_code','master_name','master_position','master_phone']);
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ class CompanyValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','company_name','organization_code','master_name','master_position','master_phone','master_email']);
|
||||
return $this->only(['id','company_name','organization_code','master_name','master_position','master_phone']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,9 +28,21 @@ class ContractController extends BaseApiController
|
||||
$query = Contract::where('party_b', $admin['id']);
|
||||
}
|
||||
$count = $query->count();
|
||||
$contract = $query->with(['company' => function ($query) {
|
||||
$query->field('id,company_name');
|
||||
}])->page($page)->limit($limit)->select();
|
||||
$contract = $query->page($page)->limit($limit)->select()->each(function ($item, $key) {
|
||||
$company_name= Db::name('company')->where('id', $item['party_a'])->value('company_name');
|
||||
$contract_type_name= Db::name('dict_data')->where('id', $item['contract_type'])->value('name');
|
||||
$datas=[
|
||||
'id'=>$item['id'],
|
||||
'company_name'=>$company_name,
|
||||
'contract_type_name'=>$contract_type_name,
|
||||
];
|
||||
$item->company=$datas;
|
||||
// if ($item->type == 2) {
|
||||
// $item['party_b_name'] = Admin::where('id', $item['party_b'])->value('name');
|
||||
// } else {
|
||||
// $item['party_b_name'] = Db::name('company')->where('id', $item['party_b'])->value('company_name');
|
||||
// }
|
||||
});
|
||||
return $this->success('success', ['count' => $count, 'data' => $contract]);
|
||||
}
|
||||
|
||||
@ -40,25 +52,30 @@ class ContractController extends BaseApiController
|
||||
if (empty($contract)) {
|
||||
return $this->fail('合同不存在');
|
||||
}
|
||||
if($contract['admin_id']!=0){
|
||||
$contract['party_b_name'] = Admin::where('id', $contract['admin_id'])->value('name');
|
||||
}else{
|
||||
if ($contract['type'] == 2) {
|
||||
$contract['party_b_name'] = Admin::where('id', $contract['party_b'])->value('name');
|
||||
} else {
|
||||
$contract['party_b_name'] = Db::name('company')->where('id', $contract['party_b'])->value('company_name');
|
||||
}
|
||||
$contract['party_a_name'] = Db::name('company')->where('id', $contract['party_a'])->value('company_name');
|
||||
|
||||
$contract['contract_type_name'] = Db::name('dict_data')->where('id', $contract['contract_type'])->value('name');
|
||||
$company = Company::where('id', $contract['company_id'])->find();
|
||||
$company = Company::where('id', $contract['party_a'])->find();
|
||||
$province_name= Db::name('geo_province')->where(['province_code' => $company['province']])->value('province_name');
|
||||
$city_name= Db::name('geo_city')->where(['city_code' => $company['city']])->value('city_name');
|
||||
$area_name= Db::name('geo_area')->where(['area_code' => $company['area']])->value('area_name');
|
||||
$street_name= Db::name('geo_street')->where(['street_code' => $company['street']])->value('street_name');
|
||||
$company['address']= $province_name.$city_name.$area_name.$street_name.$company['address'];
|
||||
|
||||
$company['company_type_name'] = Db::name('dict_data')->where('id', $company['company_type'])->value('name');
|
||||
$company['other_contacts'] = json_decode($company['other_contacts'], true);
|
||||
$company['qualification'] = $company['qualification']!=null?json_decode($company['qualification'], true):'';
|
||||
$users = Admin::where('company_id', $company['id'])->field('id,name,account,phone,qualification')->select()->toArray();
|
||||
$company['qualification'] = $company['qualification'] != null ? json_decode($company['qualification'], true) : '';
|
||||
$users = Admin::where('company_id', $company['party_a'])->field('id,name,account,phone,qualification')->select()->toArray();
|
||||
foreach ($users as &$user) {
|
||||
$user['is_main'] = $user['id'] == $company['admin_id'] ? 1 : 0;
|
||||
$user['qualification'] =$user['qualification']!=null?json_decode($user['qualification'], true):[];
|
||||
$user['qualification'] = $user['qualification'] != null ? json_decode($user['qualification'], true) : [];
|
||||
unset($user['role_id'], $user['dept_id'], $user['jobs_id'], $user['id']);
|
||||
}
|
||||
return $this->success('success', ['contract' => $contract, 'company' => $company, 'users' => $users]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\IndexLogic;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
use think\response\Json;
|
||||
|
||||
@ -29,7 +30,7 @@ class IndexController extends BaseApiController
|
||||
{
|
||||
|
||||
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate'];
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate','notifyUrl'];
|
||||
|
||||
|
||||
/**
|
||||
@ -92,10 +93,22 @@ class IndexController extends BaseApiController
|
||||
}
|
||||
|
||||
public function notifyUrl(){
|
||||
$a= Request()->port();
|
||||
Log::error("asdasd");
|
||||
Log::error($a);
|
||||
halt(111);
|
||||
$a= Request()->get();
|
||||
if($a){
|
||||
$find=Db::name('contract')->where('id',$a['id'])->find();
|
||||
if($find){
|
||||
Db::name('contract')->where('id',$a['id'])->update(['status'=>1]);
|
||||
if($find['type']==1){
|
||||
Db::name('company')->where('id',$find['party_a'])->update(['status'=>1,'is_contract'=>1]);
|
||||
Db::name('company')->where('id',$find['party_b'])->update(['status'=>1,'is_contract'=>1]);
|
||||
}else{
|
||||
Db::name('company')->where('id',$find['party_a'])->update(['status'=>1,'is_contract'=>1]);
|
||||
Db::name('admin')->where('id',$find['party_b'])->update(['is_contract'=>1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json(['success'=>true,'msg'=>'成功']);
|
||||
}
|
||||
|
||||
}
|
@ -9,10 +9,11 @@ use com\junziqian\sdk\util\exception\ResultInfoException;
|
||||
use com\junziqian\sdk\util\RequestUtils;
|
||||
use com\junziqian\sdk\util\ShaUtils;
|
||||
use CURLFile;
|
||||
use think\facade\Db;
|
||||
|
||||
class JunziqianController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['index', 'config', 'policy', 'decorate'];
|
||||
public array $notNeedLogin = ['index', 'download_file'];
|
||||
|
||||
/**请求地址*/
|
||||
private $serviceUrl = 'https://api.sandbox.junziqian.com';
|
||||
@ -34,7 +35,6 @@ class JunziqianController extends BaseApiController
|
||||
'signatories' => [['fullName' => '小米', 'identityType' => 1, 'identityCard' => '5002401XXXXXXXXX', 'mobile' => 18982406440, 'noNeedVerify' => 1, 'signLevel' => 1]],
|
||||
'url' => "https://dev.lihaink.cn/storage/202307/acbba88e77392348d3a8a4a1fdf210f1.pdf"
|
||||
];
|
||||
halt($this->Signing($data));
|
||||
}
|
||||
/**
|
||||
* 填充签名数据
|
||||
@ -141,7 +141,7 @@ class JunziqianController extends BaseApiController
|
||||
return $this->success('', (array)$response);
|
||||
}
|
||||
//签约
|
||||
public function Signing($data)
|
||||
public function Signing($data,$id)
|
||||
{
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
//CURLFile 可以传url或filePath,但必须保证文件存在且有效,否则php不会报错,只会导致http请求返回null(并没有调到服务端)。
|
||||
@ -153,8 +153,7 @@ class JunziqianController extends BaseApiController
|
||||
$request->serverCa = 1; //是否需要服务端云证书
|
||||
$request->fileType = 1; //合同上传方式 url
|
||||
$request->url = $data['url'];
|
||||
$request->notifyUrl='https://worker-task.lihaink.cn/notify_url';
|
||||
|
||||
$request->notifyUrl='https://worker-task.lihaink.cn/notify_url?id='.$id;
|
||||
//发起PING请求
|
||||
// halt($request);
|
||||
$response = $requestUtils->doPost("/v2/sign/applySign", $request);
|
||||
@ -188,4 +187,62 @@ class JunziqianController extends BaseApiController
|
||||
$response=$requestUtils->doPost("/v2/sign/notify",$request);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function download_file($applyNo){
|
||||
$requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret);
|
||||
//初始化请求参数
|
||||
$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::name('contract')->where('contract_no',$applyNo)->update(['contract_url'=>'/uploads/contract/'.$applyNo.'.pdf']);
|
||||
return $this->success('获取成功', ['url' => 'https://worker-task.lihaink.cn/uploads/contract/'.$applyNo.'.pdf']);
|
||||
}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);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ use app\common\{enum\notice\NoticeEnum,
|
||||
model\user\UserAuth,
|
||||
service\sms\SmsDriver,
|
||||
service\wechat\WeChatMnpService};
|
||||
use app\Request;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
@ -76,6 +77,7 @@ class UserLogic extends BaseLogic
|
||||
]])
|
||||
->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,create_time,user_money,income,admin_id')
|
||||
->findOrEmpty();
|
||||
// $user['avatar'] = $user['avatar'] ? Request()->host() . $user['avatar'] : $user['avatar'];
|
||||
$user['has_password'] = !empty($user['password']);
|
||||
$user['has_auth'] = self::hasWechatAuth($userId);
|
||||
$user['version'] = config('project.version');
|
||||
|
@ -27,10 +27,10 @@ class Company extends BaseModel
|
||||
|
||||
protected $name = 'company';
|
||||
|
||||
public function getCompanyTypeAttr($value)
|
||||
{
|
||||
return DictData::where('id', $value)->value('name');
|
||||
}
|
||||
// public function getCompanyTypeAttr($value)
|
||||
// {
|
||||
// return DictData::where('id', $value)->value('name');
|
||||
// }
|
||||
|
||||
public function getProvinceNameAttr($value)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use app\api\controller\IndexController;
|
||||
use app\api\controller\JunziqianController;
|
||||
use think\facade\Console;
|
||||
use think\facade\Route;
|
||||
|
||||
@ -33,4 +34,5 @@ Route::rule('crontab', function () {
|
||||
Console::call('crontab');
|
||||
});
|
||||
|
||||
Route::post('/notify_url', IndexController::class . '@notifyUrl');
|
||||
Route::post('/notify_url', IndexController::class . '@notifyUrl');
|
||||
Route::get('/api/junziqian/download_file',JunziqianController::class . '@download_file');
|
2
vendor/ebaoquan/junziqian_sdk
vendored
2
vendor/ebaoquan/junziqian_sdk
vendored
@ -1 +1 @@
|
||||
Subproject commit 9acc82cd23d807280ddd29df2117e7890094d049
|
||||
Subproject commit 1294ea49ff9ecc4532821f8798304816cbf8dd74
|
Loading…
x
Reference in New Issue
Block a user