This commit is contained in:
mkm 2023-08-07 15:13:34 +08:00
parent 62d68b853e
commit e07a1e0436
19 changed files with 373 additions and 848 deletions

View File

@ -17,14 +17,13 @@ namespace app\adminapi\controller;
use app\adminapi\lists\CompanyLists;
use app\adminapi\logic\CompanyLogic;
use app\common\logic\CompanyLogic;
use app\adminapi\validate\CompanyValidate;
use app\api\controller\JunziqianController;
use app\api\logic\SmsLogic;
use app\common\model\auth\Admin;
use app\common\model\Company;
use think\facade\Db;
use app\common\logic\CompanyLogic as CommonCompanyLogic;
use app\common\logic\contract\ContractLogic;
/**
* Company控制器
@ -118,32 +117,32 @@ class CompanyController extends BaseAdminController
$params = $this->request->param();
$params['party_a'] = $this->adminInfo['company_id'];
$params['type'] = 1;
$result = CommonCompanyLogic::initiate_contract($params);
$result = ContractLogic::initiate_contract($params);
if ($result == true) {
return $this->success('发起成功,等待平台风控部上传合同');
}
return $this->fail(CommonCompanyLogic::getError());
return $this->fail(ContractLogic::getError());
}
// /**生成合同 */
public function Draftingcontracts()
{
$params = $this->request->param();
$result = CommonCompanyLogic::Draftingcontracts($params);
$result = ContractLogic::Draftingcontracts($params);
if ($result == true) {
return $this->success('生成合同成功');
}
return $this->fail(CommonCompanyLogic::getError());
return $this->fail(ContractLogic::getError());
}
//**发送短信 */
public function postsms()
{
$params = (new CompanyValidate())->goCheck('detail');
$res = CommonCompanyLogic::postsms($params);
$res = ContractLogic::postsms($params);
if ($res == true) {
return $this->success('发送成功', [], 1, 1);
} else {
return $this->fail(CommonCompanyLogic::getError());
return $this->fail(ContractLogic::getError());
}
}

View File

@ -237,41 +237,4 @@ class AdminController extends BaseAdminController
}
}
}
//**废除合同 */
public function abolition()
{
$params = Request::param();
$result = AdminLogic::detail($params);
$find=Db::name('article')->where('id',2)->value('content');
$data = [
'name' => $result['name'] . '合同',
'signatories' => [['fullName' => $result['name'], 'identityType' => 1, 'identityCard' => $result['id_card'], 'mobile' => $result['account'], 'noNeedVerify' => 1, 'signLevel' => 1]],
'url' => $result['contract']['file'],
'content'=>'<meta charset="utf-8">'.$find,
];
$res = app(JunziqianController::class)->html_contract($data,$result['contract']['id']);
$data = array(
"applyNo" => $res->data, //TODO *
"fullName" => $result['name'], //TODO *
"identityCard" => $result['id_card'], //TODO *
"identityType" => 1, //TODO *
);
$res = app(JunziqianController::class)->SigningLink($data);
$sms = [
'mobile' => $result['phone'],
'name' => $result['name'],
'type' => '《' . $result['contract']['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $result['contract']['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return $this->success('发送成功');
} else {
return $this->fail(SmsLogic::getError());
}
halt($res);
}
}

View File

@ -18,7 +18,7 @@ namespace app\adminapi\controller\category_business;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\category_business\CategoryBusinessLists;
use app\adminapi\logic\category_business\CategoryBusinessLogic;
use app\common\logic\category_business\CategoryBusinessLogic;
use app\adminapi\validate\category_business\CategoryBusinessValidate;

View File

@ -18,7 +18,7 @@ namespace app\adminapi\controller\contract;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\contract\ContractLists;
use app\adminapi\logic\contract\ContractLogic;
use app\common\logic\contract\ContractLogic;
use app\adminapi\validate\contract\ContractValidate;
use app\common\model\contract\Contract;
use think\facade\Request;
@ -157,41 +157,4 @@ class ContractController extends BaseAdminController
}
}
}
//**废除合同 */
public function abolition()
{
// $params = Request::param();
// $result = UserLogic::detail($params);
// $find=Db::name('article')->where('id',2)->value('content');
// $data = [
// 'name' => $result['name'] . '合同',
// 'signatories' => [['fullName' => $result['name'], 'identityType' => 1, 'identityCard' => $result['id_card'], 'mobile' => $result['account'], 'noNeedVerify' => 1, 'signLevel' => 1]],
// 'url' => $result['contract']['file'],
// 'content'=>'<meta charset="utf-8">'.$find,
// ];
// $res = app(JunziqianController::class)->html_contract($data,$result['contract']['id']);
// $data = array(
// "applyNo" => $res->data, //TODO *
// "fullName" => $result['name'], //TODO *
// "identityCard" => $result['id_card'], //TODO *
// "identityType" => 1, //TODO *
// );
// $res = app(JunziqianController::class)->SigningLink($data);
// $sms = [
// 'mobile' => $result['phone'],
// 'name' => $result['name'],
// 'type' => '《' . $result['contract']['contract_type_name'] . '》',
// 'code' => 'api/Hetong/url?id=' . $result['contract']['id'],
// 'scene' => 'WQ'
// ];
// $result = SmsLogic::contractUrl($sms);
// if (true === $result) {
// return $this->success('发送成功');
// } else {
// return $this->fail(SmsLogic::getError());
// }
// halt($res);
}
}

View File

@ -20,9 +20,7 @@ use app\adminapi\validate\user\AdjustUserMoney;
use app\adminapi\validate\user\UserValidate;
use think\facade\Db;
use think\facade\Request;
use app\api\logic\SmsLogic;
use app\api\controller\JunziqianController;
use app\common\model\contract\Contract;
use app\common\logic\contract\ContractLogic;
/**
* 用户控制器
@ -95,64 +93,21 @@ class UserController extends BaseAdminController
return $this->fail('甲方不存在,请联系平台绑定公司');
}
$params['check_status']=1;
$res=Contract::Initiate_contract($params);
$res=ContractLogic::Initiate_contract($params);
if (true === $res) {
return $this->success('发起成功,等待平台风控部上传合同');
}
return $this->fail('发起失败');
}
// /**生成合同 */
// /**发送合同 */
public function Draftingcontracts()
{
$params = Request::param();
$result = UserLogic::detail($params['id']);
if ($result && $result['contract'] && $result['contract']['file'] != '') {
if($result['contract']['check_status']==3){
return $this->fail('你已经生成过合同,请问重复生成');
}
$data = [
'name' => $result['nickname'] . '的合同',
'signatories' => [
['fullName' => $result['nickname'], '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::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data,'check_status'=>3]);
$data = array(
"applyNo" => $res->data, //TODO *
"fullName" => $result['nickname'], //TODO *
"identityCard" => $result['id_card'], //TODO *
"identityType" => 1, //TODO *
);
$res = app(JunziqianController::class)->SigningLink($data);
if ($res->success == true) {
Db::name('contract')->where('id', $result['contract']['id'])->update(['url' => $res->data]);
//发送短信
$sms = [
'mobile' => $result['mobile'],
'name' => $result['nickname'],
'type' => '《' . $result['contract']['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $result['contract']['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return $this->success('发送成功');
} else {
return $this->fail(SmsLogic::getError());
}
} else {
return $this->fail($res->msg);
}
return $this->success('生成合同成功', [], 1, 1);
} else {
return $this->fail($res->msg);
}
$result = ContractLogic::Draftingcontracts($params);
if ($result === true) {
return $this->success('发送合同成功');
} else {
return $this->fail('生成合同成功失败,联系管理员');
return $this->fail(ContractLogic::getError());
}
}
}

View File

@ -15,7 +15,7 @@
namespace app\adminapi\lists\article;
use app\adminapi\lists\BaseAdminDataLists;
use app\adminapi\logic\CompanyLogic;
use app\common\logic\CompanyLogic;
use app\common\lists\ListsSearchInterface;
use app\common\lists\ListsSortInterface;
use app\common\model\article\Article;

View File

@ -55,7 +55,7 @@ class UserInformationgLists extends BaseAdminDataLists implements ListsSearchInt
public function lists(): array
{
$lists = UserInformationg::where($this->searchWhere)
->field(['id','create_user_id','company_id','area_id','area_id area_name','street_id','street_id street_name','village_id','village_id village_name', 'brigade_id','brigade_id brigade_name', 'address', 'name', 'phone', 'sex', 'age','update_time','status'])
->field(['id','create_user_id','company_id','area_id','area_id area_name','street_id','street_id street_name','village_id','village_id village_name', 'brigade_id','brigade_id brigade_name', 'address', 'name', 'phone', 'sex', 'age','update_time','create_time','status'])
->append(['extend'])
->order(['id' => 'desc'])
->select()

View File

@ -15,7 +15,7 @@
namespace app\adminapi\lists\recharge;
use app\adminapi\lists\BaseAdminDataLists;
use app\adminapi\logic\CompanyLogic;
use app\common\logic\CompanyLogic;
use app\common\lists\ListsExcelInterface;
use app\common\lists\ListsSearchInterface;
use app\common\model\recharge\RechargeOrder;

View File

@ -1,237 +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\adminapi\logic;
use app\common\model\Company;
use app\common\logic\BaseLogic;
use app\common\model\auth\Admin;
use app\common\model\contract\Contract;
use app\common\model\user\User;
use think\exception\ValidateException;
use think\facade\Config;
use think\facade\Db;
use app\common\service\FileService;
/**
* Company逻辑
* Class CompanyLogic
* @package app\adminapi\logic
*/
class CompanyLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/07/15 14:43
*/
public static function add(array $params): bool
{
unset($params['id']);
Db::startTrans();
try {
// $exist = Company::where('admin_id', $params['admin_id'])->find();
// if (!empty($exist)) {
// throw new ValidateException('该账号已经注册过企业');
// }
$level_one = $params['contract']['party_a'] ?? 0;
$arr=[
'company_name' => $params['company_name'],
'organization_code' => $params['organization_code'],
'province' => $params['province'],
'city' => $params['city'],
'area' => $params['area'],
'street' => $params['street'],
'address' => $params['address'],
'company_type' => $params['company_type'],
'master_name' => $params['master_name'],
'master_position' => $params['master_position'],
'master_phone' => $params['master_phone'],
'master_email' => $params['master_email'],
'other_contacts' => $params['other_contacts'],
'area_manager' => $params['area_manager'] ?? 0,
'qualification' => $params['qualification'],
'admin_id' => $params['admin_id'] ?? 0,
'level_one' => $level_one,
];
$data = Company::create($arr);
$passwordSalt = Config::get('project.unique_identification');
$defaultAvatar = config('project.default_image.admin_avatar');
$admin=$arr;
$admin['id_card']=$params['id_card'];
$admin['area_manager']=$params['area_manager'];
$admin['sex']=$params['sex'];
$admin['name']=$params['master_name'];
$admin['account']=$params['master_phone'];
$admin['avatar'] = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar;
$admin['phone']=$params['master_phone'];
$admin['password'] = create_password(123456, $passwordSalt);
$admin_id=Admin::strict(false)->insertGetId($admin);
$userSn = User::createUserSn();
$admin['admin_id']=$admin_id;
$admin['sn']=$userSn;
$admin['sechannel']=4;
$admin['company_id']=$data['id'];
$admin['real_name']=$params['master_name'];
$admin['nickname']=$params['master_name'];
$admin['mobile']=$params['master_phone'];
$admin['phone']=$params['master_phone'];
User::strict(false)->insert($admin);
// if ($level_one > 0) {
// $contractId = self::contract($data['id'], $params);
// }
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/15 14:43
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
Company::where('id', $params['id'])->update([
// 'level_two' => $params['level_two'],
// 'level_one' => $params['level_one'],
'company_name' => $params['company_name'],
'organization_code' => $params['organization_code'],
'province' => $params['province'],
'city' => $params['city'],
'area' => $params['area'],
'street' => $params['street'],
'address' => $params['address'],
'company_type' => $params['company_type'],
'master_name' => $params['master_name'],
'master_position' => $params['master_position'],
'master_phone' => $params['master_phone'],
'master_email' => $params['master_email'],
'other_contacts' => $params['other_contacts'],
'area_manager' => $params['area_manager'] ?? 0,
// 'is_contract' => $params['is_contract'],
// 'account' => $params['account'],
// 'password' => $params['password'],
// 'deposit' => $params['deposit'],
// 'deposit_time' => $params['deposit_time'],
'qualification' => $params['qualification'],
'admin_id' => $params['admin_id'] ?? 0,
'level_one' => $params['contract']['party_a'] ?? 0,
// 'status' => $params['status']
]);
if ($params['contract']) {
$contractId = self::contract($params['id'], $params);
Company::update(['contract_id' => $contractId], ['id' => $params['id']]);
}
if($params['admin_id']){
$admin=Admin::where('company_id', $params['id'])->find();
Admin::where('id' , $params['admin_id'])->update(['company_id' => $params['id']]);
User::where('admin_id',$params['admin_id'])->update(['company_id' => $params['id'],'qualification'=>$params['qualification'],'province'=>$params['province'],'city'=>$params['city'],'area'=>$params['area'],'street'=>$params['street'],'address'=>$params['address'],'is_contract'=>$admin['is_contract'],'mobile'=>$admin['phone']]);
if($admin['id']!=$params['admin_id']){
Admin::where('id',$admin['id'])->update(['company_id' =>0]);
User::where('admin_id' , $admin['id'])->update(['company_id' => 0]);
}
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage(), $e->getFile());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/07/15 14:43
*/
public static function delete(array $params): bool
{
return Company::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/07/15 14:43
*/
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();
}
return $data;
}
public static function contract($companyId, $params)
{
$model = Contract::where(['party_b' => $companyId])->find();
if (empty($model)) {
$model = new Contract();
$model->contract_no = time();
$model->create_time = time();
$model->type = 1;
}
$model->update_time = time();
$model->party_a = $params['contract']['party_a'] ?? 0;
$model->contract_type = $params['contract']['contract_type'] ?? 0;
$model->file = $params['contract']['file'] ?? '';
$model->party_b = $companyId;
$model->save();
return $model->id;
}
public static function getAllCompanyIds()
{
$companyId = request()->adminInfo['company_id'] ?? 0;
$companyIds[] = $companyId;
$companies = loopGetChild(Company::class, $companyId, 'level_one', 'id,level_one');
if (!empty($companies)) {
$companyIds = array_merge(array_column($companies, 'id'), $companyIds);
}
return array_filter($companyIds);
}
}

View File

@ -1,163 +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\adminapi\logic\contract;
use app\common\model\contract\Contract;
use app\common\logic\BaseLogic;
use app\common\model\Company;
use app\common\model\user\User;
use think\facade\Db;
/**
* 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): array
{
$data = Db::name('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,
qualification'];
$company=Company::where(['id'=> $data['party_b']])->field($field)->find();
$company['qualification']=json_decode($company['qualification'],true);
return $company;
} else {
$filed=['id,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,
qualification'];
$user= User::where('id', $data['party_b'])->field($filed)->find();
$user['qualification']=json_decode($user['qualification'],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,
qualification'];
$company=Company::where(['id'=> $data['party_a']])->field($field)->find();
$company['qualification']=json_decode($company['qualification'],true);
return $company;
})
->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;
}
}

View File

@ -2,17 +2,14 @@
namespace app\api\controller;
use app\common\logic\contract\ContractLogic;
use app\common\model\auth\Admin;
use app\common\model\auth\AdminRole;
use app\common\model\auth\SystemRole;
use app\common\model\Company;
use app\common\model\contract\Contract;
use app\common\model\user\User;
use app\common\model\user\UserAccountLog;
use think\facade\Db;
use app\common\logic\CompanyLogic as CommonCompanyLogic;
use app\common\model\informationg\UserInformationg;
/**
* Class CompanyController
* @package app\api\controller
@ -147,32 +144,32 @@ class CompanyController extends BaseApiController
$params = $this->request->param();
$params['party_a'] = $this->userInfo['company_id'];
$params['type'] = 1;
$result = CommonCompanyLogic::initiate_contract($params);
$result = ContractLogic::initiate_contract($params);
if ($result == true) {
return $this->success('发起成功,等待平台风控部上传合同');
}
return $this->fail(CommonCompanyLogic::getError());
return $this->fail(ContractLogic::getError());
}
// /**生成合同 */
// /**发送合同 */
public function Draftingcontracts()
{
$params = $this->request->param();
$result = CommonCompanyLogic::Draftingcontracts($params);
$result = ContractLogic::Draftingcontracts($params,1);
if ($result == true) {
return $this->success('生成合同成功');
}
return $this->fail(CommonCompanyLogic::getError());
return $this->fail(ContractLogic::getError());
}
//**发送短信 */
public function postsms()
{
$params = $this->request->param();
$res = CommonCompanyLogic::postsms($params);
$res = ContractLogic::postsms($params);
if ($res == true) {
return $this->success('发送成功', [], 1, 1);
} else {
return $this->fail(CommonCompanyLogic::getError());
return $this->fail(ContractLogic::getError());
}
}
}

View File

@ -22,14 +22,21 @@ class HetongController extends BaseApiController
public function url()
{
$id=Request()->get('id');
if($id){
$url=Db::name('contract')->where('id',$id)->value('url');
if($url){
return redirect($url);
$id = Request()->get('id');
$type = Request()->get('tyep');
$msg='合同不存在';
if(empty($type)){
$msg='参数错误';
}
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>合同不存在</p> </div>';
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

@ -19,6 +19,7 @@ use app\common\logic\UserLogic as CommonUserLogic;
use app\api\validate\PasswordValidate;
use app\api\validate\SetUserInfoValidate;
use app\api\validate\UserValidate;
use app\common\logic\contract\ContractLogic;
use Common;
use think\facade\Db;
@ -176,32 +177,33 @@ class UserController extends BaseApiController
{
$params = $this->request->param();
$admin_id = Db::name('user')->where('id', $this->userId)->value('admin_id');
$result = CommonUserLogic::initiate_contract($params, $admin_id);
$params['check_status'] = 1;
$result = ContractLogic::initiate_contract($params, $admin_id);
if ($result == true) {
return $this->success('发起成功,等待平台风控部上传合同');
}
return $this->fail(CommonUserLogic::getError());
return $this->fail(ContractLogic::getError());
}
// /**生成合同 */
public function Draftingcontracts()
{
$params = $this->request->param();
$result = CommonUserLogic::Draftingcontracts($params);
$result = ContractLogic::Draftingcontracts($params,2);
if ($result == true) {
return $this->success('生成合同成功');
}
return $this->fail(CommonUserLogic::getError());
return $this->fail(ContractLogic::getError());
}
//**发送短信 */
public function postsms()
{
$params = $this->request->param();
$res = CommonUserLogic::postsms($params);
$res = ContractLogic::postsms($params);
if ($res == true) {
return $this->success('发送成功', [], 1, 1);
} else {
return $this->fail(CommonUserLogic::getError());
return $this->fail(ContractLogic::getError());
}
}
}

View File

@ -35,7 +35,7 @@ class CompanyLogic extends BaseLogic
{
/**
/**
* @notes 添加
* @param array $params
* @return bool
@ -44,6 +44,7 @@ class CompanyLogic extends BaseLogic
*/
public static function add(array $params): bool
{
unset($params['id']);
Db::startTrans();
try {
// $exist = Company::where('admin_id', $params['admin_id'])->find();
@ -51,9 +52,7 @@ class CompanyLogic extends BaseLogic
// throw new ValidateException('该账号已经注册过企业');
// }
$level_one = $params['contract']['party_a'] ?? 0;
$data = Company::create([
// 'level_two' => $params['level_two'],
// 'level_one' => $params['level_one'],
$arr=[
'company_name' => $params['company_name'],
'organization_code' => $params['organization_code'],
'province' => $params['province'],
@ -68,19 +67,37 @@ class CompanyLogic extends BaseLogic
'master_email' => $params['master_email'],
'other_contacts' => $params['other_contacts'],
'area_manager' => $params['area_manager'] ?? 0,
// 'is_contract' => $params['is_contract'],
// 'account' => $params['account'],
// 'password' => $params['password'],
// 'deposit' => $params['deposit'],
// 'deposit_time' => $params['deposit_time'],
'qualification' => $params['qualification'],
'admin_id' => $params['admin_id'] ?? 0,
'level_one' => $level_one,
// 'status' => $params['status']
]);
if ($level_one > 0) {
$contractId = self::contract($data['id'], $params);
}
];
$data = Company::create($arr);
$passwordSalt = Config::get('project.unique_identification');
$defaultAvatar = config('project.default_image.admin_avatar');
$admin=$arr;
$admin['id_card']=$params['id_card'];
$admin['area_manager']=$params['area_manager'];
$admin['sex']=$params['sex'];
$admin['name']=$params['master_name'];
$admin['account']=$params['master_phone'];
$admin['avatar'] = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar;
$admin['phone']=$params['master_phone'];
$admin['password'] = create_password(123456, $passwordSalt);
$admin_id=Admin::strict(false)->insertGetId($admin);
$userSn = User::createUserSn();
$admin['admin_id']=$admin_id;
$admin['sn']=$userSn;
$admin['sechannel']=4;
$admin['company_id']=$data['id'];
$admin['real_name']=$params['master_name'];
$admin['nickname']=$params['master_name'];
$admin['mobile']=$params['master_phone'];
$admin['phone']=$params['master_phone'];
User::strict(false)->insert($admin);
// if ($level_one > 0) {
// $contractId = self::contract($data['id'], $params);
// }
Db::commit();
return true;
} catch (\Exception $e) {
@ -133,13 +150,13 @@ class CompanyLogic extends BaseLogic
$contractId = self::contract($params['id'], $params);
Company::update(['contract_id' => $contractId], ['id' => $params['id']]);
}
if ($params['admin_id']) {
$admin = Admin::where('company_id', $params['id'])->find();
Admin::where('id', $params['admin_id'])->update(['company_id' => $params['id']]);
User::where('admin_id', $params['admin_id'])->update(['company_id' => $params['id'], 'qualification' => $params['qualification'], 'province' => $params['province'], 'city' => $params['city'], 'area' => $params['area'], 'street' => $params['street'], 'address' => $params['address'], 'is_contract' => $admin['is_contract'], 'mobile' => $admin['phone']]);
if ($admin['id'] != $params['admin_id']) {
Admin::where('id', $admin['id'])->update(['company_id' => 0]);
User::where('admin_id', $admin['id'])->update(['company_id' => 0]);
if($params['admin_id']){
$admin=Admin::where('company_id', $params['id'])->find();
Admin::where('id' , $params['admin_id'])->update(['company_id' => $params['id']]);
User::where('admin_id',$params['admin_id'])->update(['company_id' => $params['id'],'qualification'=>$params['qualification'],'province'=>$params['province'],'city'=>$params['city'],'area'=>$params['area'],'street'=>$params['street'],'address'=>$params['address'],'is_contract'=>$admin['is_contract'],'mobile'=>$admin['phone']]);
if($admin['id']!=$params['admin_id']){
Admin::where('id',$admin['id'])->update(['company_id' =>0]);
User::where('admin_id' , $admin['id'])->update(['company_id' => 0]);
}
}
Db::commit();
@ -178,13 +195,12 @@ class CompanyLogic extends BaseLogic
if ($data) {
$data['other_contacts'] = json_decode($data['other_contacts'], true);
$data['qualification'] = json_decode($data['qualification'], true);
if($data['qualification'] && isset($data['qualification']['other_qualifications'])){
$data['qualification']['other_qualifications']=json_decode($data['qualification']['other_qualifications'],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_info', function ($value, $data) {
return Db::name('company')->where('id', $data['party_a'])->field('id,company_name,organization_code,master_name,master_email,master_phone')->find();
})
->find();
$data['contract'] = Contract::where(['party_b' => $data['id']])->with(['partyAInfo', 'contractType'])->find();
}
return $data;
}
@ -217,143 +233,4 @@ class CompanyLogic extends BaseLogic
}
return array_filter($companyIds);
}
//**发起合同 */
public static function initiate_contract($params)
{
$find = Db::name('company')->where('id', $params['party_b'])->value('is_contract');
if ($find == 1) {
return self::setError('该公司已签约无法发起合同');
}
$params['check_status'] = 1;
$res = Contract::Initiate_contract($params);
if (true === $res) {
return true;
}
return self::setError('发起失败');
}
// /**生成合同 */
public static function Draftingcontracts($params)
{
$result = self::detail($params);
halt($result);
if ($result && $result['contract'] && $result['contract']['file'] != '') {
$data = [
'name' => $result['company_name'] . '合同',
'signatories' => [
['fullName' => $result['company_name'], 'identityType' => 12, 'identityCard' => $result['organization_code'], 'email' => $result['master_email'], '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::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data, 'check_status' => 3]);
$company = Db::name('company')->where('id', $params['id'])->find();
if ($company) {
$find = Db::name('contract')->where('party_b', $company['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
})->find();
if ($find) {
$data = [
[
"applyNo" => $find['contract_no'], //TODO *
"fullName" => $result['contract']['party_a_info']['company_name'], //TODO *
"identityCard" => $result['contract']['party_a_info']['organization_code'], //TODO *
"identityType" => 12, //TODO *
"master_phone"=>$result['contract']['party_a_info']['master_phone']
],
[
"applyNo" => $find['contract_no'], //TODO *
"fullName" => $result['company_name'], //TODO *
"identityCard" => $result['organization_code'], //TODO *
"identityType" => 12, //TODO *
"master_phone"=>$result['master_phone']
]
];
foreach($data as $k=>$v){
$res = app(JunziqianController::class)->SigningLink($data);
if ($res->success == true ) {
Db::name('contract')->where('id', $find['id'])->update(['url' => $res->data]);
//发送短信
$sms = [
'mobile' => $v['master_phone'],
'name' => $v['company_name'],
'type' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $find['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return true;
} else {
return self::setError(SmsLogic::getError());
}
} else {
return self::setError($res->msg);
}
}
}
}
return true;
} else {
return self::setError($res->msg);
}
} else {
return self::setError('生成合同成功失败,联系管理员');
}
}
//**发送短信 */
public static function postsms($params)
{
$result = self::detail($params);
if ($result && $result['contract'] && $result['contract']['file'] != '') {
//发送短信
$data = [
[
"applyNo" => $result['contract_no'], //TODO *
"fullName" => $result['contract']['party_a_info']['company_name'], //TODO *
"identityCard" => $result['contract']['party_a_info']['organization_code'], //TODO *
"identityType" => 12, //TODO *
"master_phone"=>$result['contract']['party_a_info']['master_phone']
],
[
"applyNo" => $result['contract_no'], //TODO *
"fullName" => $result['company_name'], //TODO *
"identityCard" => $result['organization_code'], //TODO *
"identityType" => 12, //TODO *
"master_phone"=>$result['master_phone']
]
];
$find = Db::name('contract')->where('party_b', $params['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
})->find();
foreach($data as $k=>$v){
$res = app(JunziqianController::class)->SigningLink($data);
if ($res->success == true ) {
Db::name('contract')->where('id', $find['id'])->update(['url' => $res->data]);
//发送短信
$sms = [
'mobile' => $v['master_phone'],
'name' => $v['company_name'],
'type' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $find['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return true;
} else {
return self::setError(SmsLogic::getError());
}
} else {
return self::setError($res->msg);
}
}
}
}
}

View File

@ -122,99 +122,5 @@ class UserLogic extends BaseLogic
return $e->getMessage();
}
}
//**发起合同 */
public static function initiate_contract($params, $adminId)
{
$params['party_a'] = Db::name('company')->where('admin_id', $adminId)->value('id');
if ($params['party_a'] <= 0) {
return self::setError('甲方不存在,请联系平台绑定公司');
}
$params['check_status'] = 1;
$res = Contract::Initiate_contract($params);
if (true === $res) {
return true;
}
return self::setError('发起失败');
}
// /**生成合同 */
public static function Draftingcontracts($params)
{
$result = self::detail($params['id']);
if ($result && $result['contract'] && $result['contract']['file'] != '') {
if ($result['contract']['check_status'] == 3) {
return self::setError('你已经生成过合同,请问重复生成');
}
$data = [
'name' => $result['nickname'] . '的合同',
'signatories' => [
['fullName' => $result['nickname'], '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::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data, 'check_status' => 3]);
$data = array(
"applyNo" => $res->data, //TODO *
"fullName" => $result['nickname'], //TODO *
"identityCard" => $result['id_card'], //TODO *
"identityType" => 1, //TODO *
);
$res = app(JunziqianController::class)->SigningLink($data);
if ($res->success == true) {
Db::name('contract')->where('id', $result['contract']['id'])->update(['url' => $res->data]);
//发送短信
$sms = [
'mobile' => $result['mobile'],
'name' => $result['nickname'],
'type' => '《' . $result['contract']['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $result['contract']['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return true;
} else {
return self::setError(SmsLogic::getError());
}
} else {
return self::setError($res->msg);
}
} else {
return self::setError($res->msg);
}
} else {
return self::setError('生成合同成功失败,联系管理员');
}
}
//**发送短信 */
public static function postsms($params)
{
$find = Db::name('contract')->where('party_b', $params['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
})
->find();
$user = User::where('id', $params['id'])->find();
if ($find) {
//发送短信
$sms = [
'mobile' => $user['mobile'],
'name' => $user['nickname'],
'type' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id=' . $find['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return true;
} else {
return self::setError(SmsLogic::getError());
}
}
}
}

View File

@ -12,7 +12,7 @@
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\category_business;
namespace app\common\logic\category_business;
use app\common\model\category_business\CategoryBusiness;

View File

@ -0,0 +1,269 @@
<?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\model\contract\Contract;
use app\common\logic\BaseLogic;
use app\common\model\Company;
use app\common\model\user\User;
use think\facade\Db;
use app\api\logic\SmsLogic;
use app\common\logic\CompanyLogic;
use app\common\logic\UserLogic;
/**
* 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): array
{
$data = Db::name('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,
qualification'];
$company = Company::where(['id' => $data['party_b']])->field($field)->find();
$company['qualification'] = json_decode($company['qualification'], true);
return $company;
} else {
$filed = ['id,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,
qualification'];
$user = User::where('id', $data['party_b'])->field($filed)->find();
$user['qualification'] = json_decode($user['qualification'], 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,
qualification'];
$company = Company::where(['id' => $data['party_a']])->field($field)->find();
$company['qualification'] = json_decode($company['qualification'], true);
return $company;
})
->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;
}
//生成合同
public static function Initiate_contract($data)
{
$model = Contract::where(['party_b' => $data['party_b']])->find();
if (empty($model)) {
$model = new Contract();
$model->party_b = $data['party_b'];
$model->contract_no = time();
$model->create_time = time();
}
$model->update_time = time();
$model->setAttrs($data);
return $model->save($data);
}
// /**发送合同 */
public static function Draftingcontracts($params,$type=1)
{
if($type==1){
$result = CompanyLogic::detail($params);
}else{
$result = UserLogic::detail($params['id']);
}
if ($result && isset($result['contract']) && isset($result['contract']['file']) && $result['contract']['file'] != '') {
if ($result['contract']['check_status'] == 3) {
return self::setError('你已经生成过合同,请问重复生成');
}
$data = [
'name' => $result['nickname'] . '的合同',
'signatories' => [
['fullName' => $result['nickname'], '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::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data, 'check_status' => 3]);
self::postsms($params);
return true;
} else {
return self::setError($res->msg);
}
} else {
return self::setError('生成合同成功失败,联系管理员');
}
}
//**发送短信 */
public static function postsms($params)
{
$result = self::detail($params);
if ($result && $result['contract'] && $result['contract']['file'] != '') {
//发送短信
$data = [
[
"applyNo" => $result['contract_no'], //TODO *
"fullName" => $result['contract']['party_a_info']['company_name'], //TODO *
"identityCard" => $result['contract']['party_a_info']['organization_code'], //TODO *
"identityType" => 12, //TODO *
"master_phone" => $result['contract']['party_a_info']['master_phone']
],
[
"applyNo" => $result['contract_no'], //TODO *
"fullName" => $result['company_name'], //TODO *
"identityCard" => $result['organization_code'], //TODO *
"identityType" => 12, //TODO *
"master_phone" => $result['master_phone']
]
];
$find = Db::name('contract')->where('party_b', $params['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
})->find();
foreach ($data as $k => $v) {
$res = app(JunziqianController::class)->SigningLink($data);
$url = [];
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'
];
$result = SmsLogic::contractUrl($sms);
if ($result != true) {
return self::setError(SmsLogic::getError());
}
} else {
return self::setError($res->msg);
}
Db::name('contract')->where('id', $find['id'])->update(['url' => json_encode($url)]);
}
}else{
return self::setError('没找到合同,联系管理员');
}
}
}

View File

@ -25,11 +25,11 @@ use app\common\model\dict\DictData;
*/
class Contract extends BaseModel
{
protected $name = 'contract';
protected $name = 'contract';
/**
* @notes 关联company_name
* @return \think\model\relation\HasOne
@ -46,19 +46,19 @@ class Contract extends BaseModel
}
public function partyAInfo()
{
return $this->hasOne(Company::class, 'id', 'party_a')->filed('id,company_name,organization_code,master_name,master_phone,master_email');
return $this->hasOne(Company::class, 'id', 'party_a')->field('id,company_name,organization_code,master_name,master_phone,master_email');
}
public function partyA()
{
return $this->hasOne(Company::class, 'id', 'party_a')->bind(['party_a_name'=>'company_name']);
return $this->hasOne(Company::class, 'id', 'party_a')->bind(['party_a_name' => 'company_name']);
}
public function partyB()
{
return $this->hasOne(Company::class, 'id', 'party_b')->bind(['party_b_name'=>'company_name']);
return $this->hasOne(Company::class, 'id', 'party_b')->bind(['party_b_name' => 'company_name']);
}
public function contractType()
{
return $this->hasOne(DictData::class, 'id', 'contract_type')->bind(['contract_type_name'=>'name']);
return $this->hasOne(DictData::class, 'id', 'contract_type')->bind(['contract_type_name' => 'name']);
}
public function getContractTypeNameAttr($value)
@ -66,18 +66,4 @@ class Contract extends BaseModel
return DictData::where(['id' => $this->contract_type])->value('name');
}
//生成合同
public static function Initiate_contract($data)
{
$model = self::where(['party_b'=>$data['party_b']])->find();
if (empty($model)) {
$model = new Contract();
$model->party_b = $data['party_b'];
$model->contract_no = time();
$model->create_time = time();
}
$model->update_time = time();
$model->setAttrs($data);
return $model->save($data);
}
}
}

View File

@ -48,6 +48,7 @@ class UserInformationg extends BaseModel
// 插入数据
$data = [
'create_user_id' => $param['admin_id'],
'company_id' => $param['company_id'],
'name' => $param['name'],
'phone' => $param['phone'],
'age' => $param['age'],