TaskSystem/app/adminapi/controller/CompanyController.php

161 lines
5.3 KiB
PHP
Raw Normal View History

2023-07-15 14:46:25 +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;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\CompanyLists;
use app\adminapi\logic\CompanyLogic;
use app\adminapi\validate\CompanyValidate;
2023-07-18 18:05:58 +08:00
use think\facade\Request;
use app\api\controller\JunziqianController;
use think\App;
use think\facade\Db;
use think\view\driver\Think;
2023-07-15 14:46:25 +08:00
/**
* Company控制器
* Class CompanyController
* @package app\adminapi\controller
*/
class CompanyController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/07/15 14:43
*/
public function lists()
{
return $this->dataLists(new CompanyLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/07/15 14:43
*/
public function add()
{
$params = (new CompanyValidate())->post()->goCheck('add');
2023-07-18 18:05:58 +08:00
$params['other_contacts'] = json_encode($params['other_contacts']);
$params['qualification'] = json_encode($params['qualification']);
2023-07-15 14:46:25 +08:00
$result = CompanyLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(CompanyLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/07/15 14:43
*/
public function edit()
{
$params = (new CompanyValidate())->post()->goCheck('edit');
2023-07-18 18:05:58 +08:00
$params['other_contacts'] = json_encode($params['other_contacts']);
$params['qualification'] = json_encode($params['qualification']);
2023-07-15 14:46:25 +08:00
$result = CompanyLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(CompanyLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/07/15 14:43
*/
public function delete()
{
$params = (new CompanyValidate())->post()->goCheck('delete');
CompanyLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/07/15 14:43
*/
public function detail()
{
$params = (new CompanyValidate())->goCheck('detail');
$result = CompanyLogic::detail($params);
return $this->data($result);
}
2023-07-18 18:05:58 +08:00
public function Draftingcontracts()
{
2023-07-15 14:46:25 +08:00
2023-07-18 18:05:58 +08:00
$params = (new CompanyValidate())->goCheck('detail');
$result = CompanyLogic::detail($params);
if ($result && $result['contract'] && $result['contract']['contract_type_two_url'] != '') {
$data = [
'name' => $result['company_name'],
'signatories' => [['fullName' => $result['master_name'], 'identityType' => 12, 'identityCard' => $result['organization_code'], 'mobile' => $result['master_phone'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]],
'url' => $result['contract']['contract_type_two_url']
];
$res = app(JunziqianController::class)->Signing($data);
if ($res->success == true) {
Db::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data]);
return $this->success('起草合同成功', [], 1, 1);
} else {
return $this->fail($res->msg);
}
} else {
return $this->fail('起草合同失败,联系管理员');
}
}
public function postsms()
{
$params = (new CompanyValidate())->goCheck('detail');
$company = Db::name('company')->where('id', $params['id'])->find();
if ($company && $company['contract_id']) {
$find = Db::name('contract')->where('id',$company['contract_id'])->find();
if ($find) {
$data = array(
"applyNo" => $find['contract_no'], //TODO *
"fullName" => $company['master_name'], //TODO *
"identityCard" => $company['organization_code'], //TODO *
"identityType" => 12, //TODO *
);
$res = app(JunziqianController::class)->SigningLink($data);
if ($res->success == true) {
return $this->success('发生成功', [], 1, 1);
} else {
return $this->fail($res->msg);
}
}
}
}
}