2023-07-18 15:00:00 +08:00
|
|
|
|
<?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\controller\contract;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
|
|
|
use app\adminapi\lists\contract\ContractLists;
|
2023-08-07 15:13:34 +08:00
|
|
|
|
use app\common\logic\contract\ContractLogic;
|
2023-07-18 15:00:00 +08:00
|
|
|
|
use app\adminapi\validate\contract\ContractValidate;
|
2023-08-01 11:01:26 +08:00
|
|
|
|
use app\common\model\contract\Contract;
|
|
|
|
|
use think\facade\Request;
|
2023-08-01 13:41:36 +08:00
|
|
|
|
use think\facade\Db;
|
|
|
|
|
use app\api\logic\SmsLogic;
|
|
|
|
|
use app\api\controller\JunziqianController;
|
2023-08-15 15:03:42 +08:00
|
|
|
|
use app\common\model\Company;
|
2023-07-18 15:00:00 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-01 11:01:26 +08:00
|
|
|
|
* 合同控制器
|
2023-07-18 15:00:00 +08:00
|
|
|
|
* Class ContractController
|
|
|
|
|
* @package app\adminapi\controller\contract
|
|
|
|
|
*/
|
|
|
|
|
class ContractController extends BaseAdminController
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 获取列表
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/07/18 14:28
|
|
|
|
|
*/
|
|
|
|
|
public function lists()
|
|
|
|
|
{
|
|
|
|
|
return $this->dataLists(new ContractLists());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 添加
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/07/18 14:28
|
|
|
|
|
*/
|
|
|
|
|
public function add()
|
|
|
|
|
{
|
|
|
|
|
$params = (new ContractValidate())->post()->goCheck('add');
|
|
|
|
|
$result = ContractLogic::add($params);
|
|
|
|
|
if (true === $result) {
|
|
|
|
|
return $this->success('添加成功', [], 1, 1);
|
|
|
|
|
}
|
|
|
|
|
return $this->fail(ContractLogic::getError());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 编辑
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/07/18 14:28
|
|
|
|
|
*/
|
|
|
|
|
public function edit()
|
|
|
|
|
{
|
|
|
|
|
$params = (new ContractValidate())->post()->goCheck('edit');
|
|
|
|
|
$result = ContractLogic::edit($params);
|
|
|
|
|
if (true === $result) {
|
|
|
|
|
return $this->success('编辑成功', [], 1, 1);
|
|
|
|
|
}
|
|
|
|
|
return $this->fail(ContractLogic::getError());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 删除
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/07/18 14:28
|
|
|
|
|
*/
|
|
|
|
|
public function delete()
|
|
|
|
|
{
|
|
|
|
|
$params = (new ContractValidate())->post()->goCheck('delete');
|
|
|
|
|
ContractLogic::delete($params);
|
|
|
|
|
return $this->success('删除成功', [], 1, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 获取详情
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/07/18 14:28
|
|
|
|
|
*/
|
|
|
|
|
public function detail()
|
|
|
|
|
{
|
|
|
|
|
$params = (new ContractValidate())->goCheck('detail');
|
|
|
|
|
$result = ContractLogic::detail($params);
|
|
|
|
|
return $this->data($result);
|
|
|
|
|
}
|
2023-08-01 11:01:26 +08:00
|
|
|
|
//风控部上传合同
|
|
|
|
|
public function wind_control()
|
|
|
|
|
{
|
|
|
|
|
$params = Request::param();
|
|
|
|
|
$file = $params['file'];
|
2023-08-02 10:50:50 +08:00
|
|
|
|
$res = Contract::where('id', $params['id'])->update(['file' => $file,'check_status'=>2]);
|
2023-08-01 11:01:26 +08:00
|
|
|
|
if ($res) {
|
2023-08-16 18:56:29 +08:00
|
|
|
|
$find=Contract::where('id', $params['id'])->with(['party_a_info'])->field('type,party_b,party_a')
|
|
|
|
|
->find()->toArray();
|
|
|
|
|
if($find['type']==1){
|
|
|
|
|
$find['party_b_info'] =Company::where('id', $find['party_b'])->field('company_name name,master_phone phone')->find()->toArray();
|
|
|
|
|
}else{
|
|
|
|
|
$find['party_b_info'] =Db::name('user')->where('id', $find['party_b'])->field('nickname name,mobile phone')->find()->toArray();
|
|
|
|
|
}
|
2023-08-15 15:03:42 +08:00
|
|
|
|
$a = [
|
2023-08-16 18:56:29 +08:00
|
|
|
|
'mobile' => $find['party_a_info']['master_phone'],
|
2023-08-15 15:03:42 +08:00
|
|
|
|
'name' => $find['party_a_info']['company_name'],
|
|
|
|
|
'scene' => 'WQTZ'
|
|
|
|
|
];
|
|
|
|
|
SmsLogic::contractUrl($a);
|
|
|
|
|
$b = [
|
|
|
|
|
'mobile' => $find['party_b_info']['phone'],
|
|
|
|
|
'name' => $find['party_b_info']['name'],
|
|
|
|
|
'scene' => 'WQTZ'
|
|
|
|
|
];
|
|
|
|
|
SmsLogic::contractUrl($b);
|
2023-08-01 11:01:26 +08:00
|
|
|
|
return $this->success('上传成功', [], 1, 1);
|
|
|
|
|
} else {
|
2023-08-01 14:10:06 +08:00
|
|
|
|
if($res==0){
|
|
|
|
|
return $this->success('没有更新', [], 1, 1);
|
|
|
|
|
}
|
2023-08-01 11:01:26 +08:00
|
|
|
|
return $this->fail('上传失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-01 13:41:36 +08:00
|
|
|
|
|
|
|
|
|
//**发送短信 */ 接口可能要做调整
|
|
|
|
|
|
|
|
|
|
public function postsms()
|
|
|
|
|
{
|
|
|
|
|
$params = Request::param();
|
|
|
|
|
$find = Db::name('contract')->where('id', $params['id'])
|
|
|
|
|
->withAttr('contract_type_name', function ($value, $data) {
|
|
|
|
|
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
|
|
|
|
|
})
|
|
|
|
|
->withAttr('user_info', function ($value, $data) {
|
|
|
|
|
if($data['type']==1){
|
|
|
|
|
return Db::name('admin')->where('id', $data['party_b'])->field('name,phone')->find();
|
|
|
|
|
}else{
|
|
|
|
|
return Db::name('user')->where('id', $data['party_b'])->field('nickname name,mobile phone')->find();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
->find();
|
|
|
|
|
if ($find && $find['url'] != '') {
|
|
|
|
|
//发送短信
|
|
|
|
|
$sms = [
|
|
|
|
|
'mobile' => $find['user_info']['phone'],
|
|
|
|
|
'name' => $find['user_info']['name'],
|
|
|
|
|
'type' => '《' . $find['contract_type_name'] . '》',
|
|
|
|
|
'code' => 'api/Hetong/url?id=' . $find['id'],
|
|
|
|
|
'scene' => 'WQ'
|
|
|
|
|
];
|
|
|
|
|
$result = SmsLogic::contractUrl($sms);
|
|
|
|
|
if (true === $result) {
|
|
|
|
|
return $this->success('发送成功');
|
|
|
|
|
} else {
|
|
|
|
|
return $this->fail(SmsLogic::getError());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-01 11:01:26 +08:00
|
|
|
|
}
|