前端合同生成
This commit is contained in:
parent
772d76477a
commit
d8bc3150f2
@ -15,9 +15,12 @@ namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\UserLogic;
|
||||
use app\common\logic\UserLogic as CommonUserLogic;
|
||||
use app\api\validate\PasswordValidate;
|
||||
use app\api\validate\SetUserInfoValidate;
|
||||
use app\api\validate\UserValidate;
|
||||
use Common;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 用户控制器
|
||||
@ -138,7 +141,7 @@ class UserController extends BaseApiController
|
||||
$params = (new UserValidate())->post()->goCheck('bindMobile');
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = UserLogic::bindMobile($params);
|
||||
if($result) {
|
||||
if ($result) {
|
||||
return $this->success('绑定成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
@ -149,7 +152,7 @@ class UserController extends BaseApiController
|
||||
$params = $this->request->param();
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = UserLogic::withdraw($params);
|
||||
if($result) {
|
||||
if ($result) {
|
||||
return $this->success('提现申请已提交', [], 1, 1);
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
@ -162,4 +165,25 @@ class UserController extends BaseApiController
|
||||
return $this->success('success', ['count' => $count, 'data' => $list]);
|
||||
}
|
||||
|
||||
}
|
||||
//**发起合同 */
|
||||
public function initiate_contract()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$admin_id=Db::name('user')->where('id',$this->userId)->value('admin_id');
|
||||
$result = CommonUserLogic::initiate_contract($params,$admin_id);
|
||||
if($result==true){
|
||||
return $this->success('发起成功,等待平台风控部上传合同');
|
||||
}
|
||||
return $this->fail(CommonUserLogic::getError());
|
||||
}
|
||||
// /**生成合同 */
|
||||
public function Draftingcontracts()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$result = CommonUserLogic::Draftingcontracts($params);
|
||||
if($result==true){
|
||||
return $this->success('生成合同成功');
|
||||
}
|
||||
return $this->fail(CommonUserLogic::getError());
|
||||
}
|
||||
}
|
||||
|
187
app/common/logic/UserLogic.php
Executable file
187
app/common/logic/UserLogic.php
Executable file
@ -0,0 +1,187 @@
|
||||
<?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;
|
||||
|
||||
use app\api\controller\JunziqianController;
|
||||
use app\api\logic\SmsLogic;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 用户逻辑层
|
||||
* Class UserLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 用户详情
|
||||
* @param int $userId
|
||||
* @return array
|
||||
* @author 段誉
|
||||
* @date 2022/9/22 16:32
|
||||
*/
|
||||
public static function detail(int $userId): array
|
||||
{
|
||||
// $field = [
|
||||
// 'id', 'sn', 'account', 'nickname', 'avatar', 'real_name',
|
||||
// 'sex', 'mobile', 'create_time', 'login_time', 'channel',
|
||||
// 'user_money',
|
||||
// ];
|
||||
|
||||
$user = User::where(['id' => $userId])
|
||||
->findOrEmpty();
|
||||
|
||||
$user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']);
|
||||
// $user->sex = $user->getData('sex');
|
||||
$user['qualification'] = json_decode($user->qualification, true);
|
||||
if ($user->is_contract == 1) {
|
||||
$user['contract'] = Contract::where(['type' => 2, 'party_b' => $userId])->with(['partyA', 'contractType'])->find();
|
||||
}
|
||||
return $user->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新用户信息
|
||||
* @param array $params
|
||||
* @return User
|
||||
* @author 段誉
|
||||
* @date 2022/9/22 16:38
|
||||
*/
|
||||
public static function setUserInfo(array $params)
|
||||
{
|
||||
return User::update([
|
||||
'id' => $params['id'],
|
||||
$params['field'] => $params['value']
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 调整用户余额
|
||||
* @param array $params
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2023/2/23 14:25
|
||||
*/
|
||||
public static function adjustUserMoney(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$user = User::find($params['user_id']);
|
||||
if (AccountLogEnum::INC == $params['action']) {
|
||||
//调整可用余额
|
||||
$user->user_money += $params['num'];
|
||||
$user->save();
|
||||
//记录日志
|
||||
AccountLogLogic::add(
|
||||
$user->id,
|
||||
AccountLogEnum::UM_INC_ADMIN,
|
||||
AccountLogEnum::INC,
|
||||
$params['num'],
|
||||
'',
|
||||
$params['remark'] ?? ''
|
||||
);
|
||||
} else {
|
||||
$user->user_money -= $params['num'];
|
||||
$user->save();
|
||||
//记录日志
|
||||
AccountLogLogic::add(
|
||||
$user->id,
|
||||
AccountLogEnum::UM_DEC_ADMIN,
|
||||
AccountLogEnum::DEC,
|
||||
$params['num'],
|
||||
'',
|
||||
$params['remark'] ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
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'] != '') {
|
||||
$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 true;
|
||||
} else {
|
||||
return self::setError(SmsLogic::getError());
|
||||
}
|
||||
} else {
|
||||
return self::setError($res->msg);
|
||||
}
|
||||
} else {
|
||||
return self::setError($res->msg);
|
||||
}
|
||||
} else {
|
||||
return self::setError('生成合同成功失败,联系管理员');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user