2023-11-10 17:04:24 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\adminapi\controller\company;
|
|
|
|
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
|
|
use think\response\Json;
|
|
|
|
|
|
|
|
class CompanyController extends BaseAdminController
|
|
|
|
{
|
2023-11-11 09:34:43 +08:00
|
|
|
protected array $reqHeader = [];
|
|
|
|
public function initialize()
|
2023-11-10 17:04:24 +08:00
|
|
|
{
|
2023-11-11 09:34:43 +08:00
|
|
|
parent::initialize();
|
|
|
|
$this->reqHeader = [
|
2023-11-10 17:04:24 +08:00
|
|
|
"appid:".env('app.app_id'),
|
|
|
|
"timestamp:".time(),
|
|
|
|
"sign:".makeSign(['appid'=>env('app.app_id'),'timestamp'=>time()],env('app.app_secret'))
|
2023-11-11 09:34:43 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
//公司列表
|
|
|
|
public function lists(): Json
|
|
|
|
{
|
|
|
|
$params=$this->request->get(['page_no','page_size','company_name','area_name','street_name','area_manager','company_type','is_contract']);
|
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/lists',$params,$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//公司详情
|
|
|
|
public function detail(): Json
|
|
|
|
{
|
|
|
|
$params=$this->request->get(['id']);
|
|
|
|
if(empty($params['id'])){
|
|
|
|
return $this->fail('id不能为空');
|
|
|
|
}
|
2023-11-11 09:34:43 +08:00
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/detail',$params,$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除公司
|
|
|
|
public function delete(): Json
|
|
|
|
{
|
|
|
|
$params=$this->request->post(['id']);
|
|
|
|
if(empty($params['id'])){
|
|
|
|
return $this->fail('缺少必要参数');
|
|
|
|
}
|
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/delete',$params,[
|
|
|
|
"appid:".env('app.app_id'),
|
|
|
|
"timestamp:".time(),
|
|
|
|
"sign:".makeSign(['appid'=>env('app.app_id'),'timestamp'=>time()],env('app.app_secret'))
|
|
|
|
]);
|
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//添加公司
|
|
|
|
public function create(): Json
|
|
|
|
{
|
|
|
|
$params=$this->request->post();
|
|
|
|
if(empty($params['company_name']) || empty($params['organization_code']) || empty($params['company_type']) || empty($params['master_name']) || empty($params['master_phone'])){
|
|
|
|
return $this->fail('缺少必要参数');
|
|
|
|
}
|
2023-11-11 09:34:43 +08:00
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/create',http_build_query($params),$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//修改公司
|
|
|
|
public function edit(): Json
|
|
|
|
{
|
|
|
|
$params=$this->request->post();
|
|
|
|
if(empty($params['id']) || empty($params['company_name']) || empty($params['organization_code']) || empty($params['company_type']) || empty($params['master_name']) || empty($params['master_phone'])){
|
|
|
|
return $this->fail('缺少必要参数');
|
|
|
|
}
|
2023-11-11 09:34:43 +08:00
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/edit',http_build_query($params),$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//公司认证
|
|
|
|
public function enterpriseCertification(): Json
|
|
|
|
{
|
|
|
|
$params=$this->request->post(['id']);
|
|
|
|
if(empty($params['id'])){
|
|
|
|
return $this->fail('id不能为空');
|
|
|
|
}
|
2023-11-11 09:34:43 +08:00
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/enterpriseCertification',$params,$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//生成合同
|
|
|
|
public function generateContract(): Json
|
|
|
|
{
|
|
|
|
$params=$this->request->post(['id','party_a','contract_type']);
|
|
|
|
if(empty($params['id']) || empty($params['party_a']) || empty($params['contract_type'])){
|
|
|
|
return $this->fail('缺少必要参数');
|
|
|
|
}
|
2023-11-11 09:34:43 +08:00
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/generateContract',$params,$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//下属公司
|
|
|
|
public function subsidiaryCompany(): Json
|
|
|
|
{
|
|
|
|
$params=$this->request->get(['id','page_no','page_size']);
|
|
|
|
if(empty($params['id'])){
|
|
|
|
return $this->fail('缺少必要参数');
|
|
|
|
}
|
2023-11-11 09:34:43 +08:00
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/subsidiaryCompany',$params,$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//公司类型
|
|
|
|
public function companyType(): Json
|
|
|
|
{
|
2023-11-11 09:34:43 +08:00
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/companyType',[],$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//合同类型
|
|
|
|
public function contractType(): Json
|
|
|
|
{
|
2023-11-11 09:34:43 +08:00
|
|
|
$result = curl_post(env('project.worker_domain').'/middleapi/company/contractType',[],$this->reqHeader);
|
2023-11-10 17:04:24 +08:00
|
|
|
if($result['code'] == 0){
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
}
|
|
|
|
return json($result);
|
|
|
|
}
|
|
|
|
}
|