更新合同
This commit is contained in:
parent
1f89a88631
commit
947da31f27
@ -20,10 +20,12 @@ use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\contract\ContractLists;
|
||||
use app\adminapi\logic\contract\ContractLogic;
|
||||
use app\adminapi\validate\contract\ContractValidate;
|
||||
use app\common\model\contract\Contract;
|
||||
use think\facade\Request;
|
||||
|
||||
|
||||
/**
|
||||
* Contract控制器
|
||||
* 合同控制器
|
||||
* Class ContractController
|
||||
* @package app\adminapi\controller\contract
|
||||
*/
|
||||
@ -103,6 +105,16 @@ class ContractController extends BaseAdminController
|
||||
$result = ContractLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//风控部上传合同
|
||||
public function wind_control()
|
||||
{
|
||||
$params = Request::param();
|
||||
$file = $params['file'];
|
||||
$res = Contract::where('id', $params['id'])->update(['file' => $file]);
|
||||
if ($res) {
|
||||
return $this->success('上传成功', [], 1, 1);
|
||||
} else {
|
||||
return $this->fail('上传失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,11 @@ use app\adminapi\lists\user\UserLists;
|
||||
use app\adminapi\logic\user\UserLogic;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 用户控制器
|
||||
@ -82,5 +87,131 @@ class UserController extends BaseAdminController
|
||||
}
|
||||
return $this->fail($res);
|
||||
}
|
||||
|
||||
//**发起合同 */
|
||||
public function initiate_contract(){
|
||||
$params = Request::param();
|
||||
$params['party_a']=Db::name('company')->where('admin_id',$this->adminId)->value('id');
|
||||
if($params['party_a']<=0){
|
||||
return $this->fail('甲方不存在,请联系平台绑定公司');
|
||||
}
|
||||
$res=Contract::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'] != '') {
|
||||
$data = [
|
||||
'name' => $result['nickname'] . '的合同',
|
||||
'signatories' => [['fullName' => $result['nickname'], 'identityType' => 1, 'identityCard' => $result['id_card'], 'mobile' => $result['mobile'], '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]);
|
||||
$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);
|
||||
}
|
||||
} else {
|
||||
return $this->fail('生成合同成功失败,联系管理员');
|
||||
}
|
||||
}
|
||||
|
||||
//**发送短信 */ 接口可能要做调整
|
||||
|
||||
public function postsms()
|
||||
{
|
||||
$params = Request::param();
|
||||
$admin=Db::name('admin')->where('id',$params['id'])->find();
|
||||
$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();
|
||||
if ($find && $find['url'] != '') {
|
||||
//发送短信
|
||||
$sms = [
|
||||
'mobile' => $admin['phone'],
|
||||
'name' => $admin['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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//**废除合同 */ 接口可能要做调整
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -49,6 +51,7 @@ class UserLogic extends BaseLogic
|
||||
$user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']);
|
||||
$user->sex = $user->getData('sex');
|
||||
$user['qualification']=json_decode($user->qualification,true);
|
||||
$user['contract']=Contract::where(['party_b'=>$userId])->with('contractType')->find();
|
||||
return $user->toArray();
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class IndexController extends BaseApiController
|
||||
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]);
|
||||
Db::name('user')->where('id',$find['party_b'])->update(['is_contract'=>1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use app\common\model\Company;
|
||||
use app\common\model\dict\DictData;
|
||||
|
||||
/**
|
||||
* Contract模型
|
||||
* 合同模型
|
||||
* Class Contract
|
||||
* @package app\common\model\contract
|
||||
*/
|
||||
@ -62,4 +62,18 @@ 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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user