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\lists\CompanyLists;
|
2023-08-18 12:03:56 +08:00
|
|
|
|
use app\adminapi\logic\auth\AdminLogic;
|
2023-08-07 15:13:34 +08:00
|
|
|
|
use app\common\logic\CompanyLogic;
|
2023-07-15 14:46:25 +08:00
|
|
|
|
use app\adminapi\validate\CompanyValidate;
|
2023-07-18 18:05:58 +08:00
|
|
|
|
use app\api\controller\JunziqianController;
|
2023-09-08 12:03:19 +08:00
|
|
|
|
use app\common\logic\RedisLogic;
|
2023-07-20 17:56:39 +08:00
|
|
|
|
use app\common\model\auth\Admin;
|
|
|
|
|
use app\common\model\Company;
|
2023-09-15 17:45:46 +08:00
|
|
|
|
use app\common\model\contract\ShopContract;
|
2023-09-13 15:54:15 +08:00
|
|
|
|
use app\common\model\ShopMerchant;
|
2023-09-08 11:29:18 +08:00
|
|
|
|
use think\cache\driver\Redis;
|
2023-09-13 15:54:15 +08:00
|
|
|
|
use think\Exception;
|
2023-07-18 18:05:58 +08:00
|
|
|
|
use think\facade\Db;
|
2023-08-07 15:13:34 +08:00
|
|
|
|
use app\common\logic\contract\ContractLogic;
|
2023-08-07 16:38:56 +08:00
|
|
|
|
use app\common\model\contract\Contract;
|
2023-08-18 12:03:56 +08:00
|
|
|
|
use app\common\model\task_scheduling\TaskScheduling;
|
2023-08-18 11:01:11 +08:00
|
|
|
|
use app\common\model\user\User;
|
2023-09-08 18:27:27 +08:00
|
|
|
|
use think\facade\Log;
|
2023-07-15 14:46:25 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Company控制器
|
|
|
|
|
* Class CompanyController
|
|
|
|
|
* @package app\adminapi\controller
|
|
|
|
|
*/
|
|
|
|
|
class CompanyController extends BaseAdminController
|
|
|
|
|
{
|
2023-09-13 15:54:15 +08:00
|
|
|
|
public array $notNeedLogin = ['createShopMerchant'];
|
2023-07-15 14:46:25 +08:00
|
|
|
|
/**
|
|
|
|
|
* @notes 获取列表
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/07/15 14:43
|
|
|
|
|
*/
|
|
|
|
|
public function lists()
|
|
|
|
|
{
|
|
|
|
|
return $this->dataLists(new CompanyLists());
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-17 10:39:05 +08:00
|
|
|
|
public function list_two()
|
|
|
|
|
{
|
2023-08-08 17:09:45 +08:00
|
|
|
|
return $this->success('ok', (new CompanyLists())->list_two());
|
|
|
|
|
}
|
2023-07-15 14:46:25 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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-08-17 10:39:05 +08:00
|
|
|
|
$params['area_manager'] = $this->adminId;
|
|
|
|
|
if (isset($params['responsible_area'])) {
|
|
|
|
|
$params['responsible_area'] = implode(',', $params['responsible_area']);
|
2023-08-14 09:12:55 +08:00
|
|
|
|
}
|
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-08-17 10:39:05 +08:00
|
|
|
|
if (isset($params['responsible_area'])) {
|
|
|
|
|
$params['responsible_area'] = implode(',', $params['responsible_area']);
|
2023-08-14 09:12:55 +08:00
|
|
|
|
}
|
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');
|
2023-08-21 17:26:31 +08:00
|
|
|
|
$admin_id = Company::where('id', $params['id'])->value('admin_id');
|
|
|
|
|
User::where('company_id', $params['id'])->update(['delete_time' => time()]);
|
|
|
|
|
TaskScheduling::where('company_id', $params['id'])->update(['delete_time' => time()]);
|
|
|
|
|
AdminLogic::delete(['id' => $admin_id]);
|
2023-07-15 14:46:25 +08:00
|
|
|
|
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-08-03 12:47:20 +08:00
|
|
|
|
//**发起合同 */
|
|
|
|
|
public function initiate_contract()
|
|
|
|
|
{
|
|
|
|
|
$params = $this->request->param();
|
2023-08-17 10:39:05 +08:00
|
|
|
|
if (isset($params['party_a']) && $params['party_a'] > 0) {
|
2023-08-08 17:14:36 +08:00
|
|
|
|
$params['party_a'] = $params['party_a'];
|
2023-08-17 10:39:05 +08:00
|
|
|
|
} else {
|
2023-08-08 17:14:36 +08:00
|
|
|
|
$params['party_a'] = $this->adminInfo['company_id'];
|
|
|
|
|
}
|
2023-08-24 15:26:37 +08:00
|
|
|
|
//判断是否是租赁合同
|
2023-08-24 16:32:54 +08:00
|
|
|
|
//如果是租赁合同则必须传递租赁数量参数
|
2023-08-26 09:35:53 +08:00
|
|
|
|
// if($params['contract_type'] == 29) {
|
|
|
|
|
// if(empty($params['num'])){
|
|
|
|
|
// return $this->fail('缺少必要参数');
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
$area_manager = Company::where('id', $params['party_a'])->value('area_manager');
|
|
|
|
|
$params['area_manager'] = $area_manager;
|
2023-08-03 12:47:20 +08:00
|
|
|
|
$params['type'] = 1;
|
2023-08-17 10:39:05 +08:00
|
|
|
|
$params['party_b'] = $params['id'];
|
2023-08-07 18:01:24 +08:00
|
|
|
|
unset($params['id']);
|
2023-08-07 15:13:34 +08:00
|
|
|
|
$result = ContractLogic::initiate_contract($params);
|
2023-09-06 11:01:26 +08:00
|
|
|
|
if (!empty($result) && $result['code'] == 1) {
|
2023-09-11 10:20:46 +08:00
|
|
|
|
return $this->success($result['msg'], $result['data'], 1, 1);
|
2023-08-03 12:47:20 +08:00
|
|
|
|
}
|
2023-08-07 15:13:34 +08:00
|
|
|
|
return $this->fail(ContractLogic::getError());
|
2023-08-03 12:47:20 +08:00
|
|
|
|
}
|
2023-07-20 16:30:00 +08:00
|
|
|
|
// /**生成合同 */
|
2023-07-18 18:05:58 +08:00
|
|
|
|
public function Draftingcontracts()
|
|
|
|
|
{
|
2023-08-03 12:47:20 +08:00
|
|
|
|
$params = $this->request->param();
|
2023-08-07 15:13:34 +08:00
|
|
|
|
$result = ContractLogic::Draftingcontracts($params);
|
2023-08-03 12:47:20 +08:00
|
|
|
|
if ($result == true) {
|
2023-08-08 22:59:28 +08:00
|
|
|
|
return $this->success('生成合同成功', [], 1, 1);
|
2023-07-18 18:05:58 +08:00
|
|
|
|
}
|
2023-08-07 15:13:34 +08:00
|
|
|
|
return $this->fail(ContractLogic::getError());
|
2023-07-18 18:05:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-19 12:42:57 +08:00
|
|
|
|
//**发送短信 */
|
2023-07-18 18:05:58 +08:00
|
|
|
|
public function postsms()
|
|
|
|
|
{
|
|
|
|
|
$params = (new CompanyValidate())->goCheck('detail');
|
2023-08-17 10:39:05 +08:00
|
|
|
|
$id = Contract::where('party_b', $params['id'])->value('id');
|
|
|
|
|
$res = ContractLogic::postsms(['id' => $id]);
|
2023-08-03 12:47:20 +08:00
|
|
|
|
if ($res == true) {
|
|
|
|
|
return $this->success('发送成功', [], 1, 1);
|
|
|
|
|
} else {
|
2023-08-07 15:13:34 +08:00
|
|
|
|
return $this->fail(ContractLogic::getError());
|
2023-07-18 18:05:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-19 12:42:57 +08:00
|
|
|
|
|
|
|
|
|
//企业认证
|
2023-07-19 17:42:15 +08:00
|
|
|
|
public function authentication()
|
|
|
|
|
{
|
2023-07-19 12:42:57 +08:00
|
|
|
|
$params = (new CompanyValidate())->goCheck('detail');
|
|
|
|
|
$company = Db::name('company')->where('id', $params['id'])->find();
|
2023-07-19 17:42:15 +08:00
|
|
|
|
$qualification = json_decode($company['qualification'], true);
|
2023-07-19 12:42:57 +08:00
|
|
|
|
if ($company && $qualification['business_license']) {
|
2023-07-19 17:42:15 +08:00
|
|
|
|
$data = [
|
2023-07-19 12:42:57 +08:00
|
|
|
|
'name' => $company['company_name'],
|
|
|
|
|
'organization_code' => $company['organization_code'],
|
2023-07-19 17:42:15 +08:00
|
|
|
|
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png', //$qualification['business_license'],
|
|
|
|
|
'master_name' => $company['master_name'],
|
|
|
|
|
'master_email' => $company['master_email'],
|
2023-09-07 15:18:57 +08:00
|
|
|
|
'master_phone' => $company['master_phone'],
|
|
|
|
|
'master_id_card' => $company['master_id_card'],
|
2023-08-26 09:35:53 +08:00
|
|
|
|
'id' => $company['id'],
|
2023-07-19 12:42:57 +08:00
|
|
|
|
];
|
|
|
|
|
$res = app(JunziqianController::class)->EnterpriseCertification($data);
|
2023-09-08 18:27:27 +08:00
|
|
|
|
Log::info(['企业认证同步结果',$res]);
|
2023-07-19 12:42:57 +08:00
|
|
|
|
if ($res->success == true) {
|
2023-09-07 16:20:26 +08:00
|
|
|
|
// 企业人脸上传
|
2023-09-07 19:06:35 +08:00
|
|
|
|
// $company['master_email'] = $email; // 法人邮箱
|
|
|
|
|
// $faceCreateRe = CompanyLogic::originationFaceCreate($company);
|
|
|
|
|
// if ($faceCreateRe !== true) {
|
|
|
|
|
// return $this->fail($faceCreateRe);
|
|
|
|
|
// }
|
2023-09-11 13:52:29 +08:00
|
|
|
|
//
|
2023-09-11 14:41:57 +08:00
|
|
|
|
if ($company['company_type'] == 30) {
|
2023-09-11 13:52:29 +08:00
|
|
|
|
// 平台公司不用初始化生成合同 合同签约暂不用人脸识别,预留人脸采集状态为已采集
|
|
|
|
|
Db::name('company')->where('id', $params['id'])->update([ 'is_contract'=>1,'face_create_status'=>1]);
|
|
|
|
|
} else {
|
|
|
|
|
Db::name('company')->where('id', $params['id'])->update([ 'face_create_status'=>1]);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-08 11:13:27 +08:00
|
|
|
|
// 加入缓存中,is_callback用于判断是否获取到异步通知
|
2023-09-08 12:03:19 +08:00
|
|
|
|
RedisLogic::getInstance()->set('authentication_company_id_'.$company['id'], json_encode(['company_id'=>$company['id'],'is_callback'=>0, 'timing'=>time()]));
|
2023-09-07 19:06:35 +08:00
|
|
|
|
// return $this->success('认证成功',[],1, 1);
|
|
|
|
|
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
|
2023-07-19 12:42:57 +08:00
|
|
|
|
} else {
|
|
|
|
|
return $this->fail($res->msg);
|
|
|
|
|
}
|
2023-09-04 17:48:08 +08:00
|
|
|
|
} else {
|
|
|
|
|
return $this->fail("公司不存在");
|
2023-07-19 12:42:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//重新认证
|
2023-07-19 17:42:15 +08:00
|
|
|
|
public function organizationReapply()
|
|
|
|
|
{
|
2023-07-19 12:42:57 +08:00
|
|
|
|
$params = (new CompanyValidate())->goCheck('detail');
|
|
|
|
|
$company = Db::name('company')->where('id', $params['id'])->find();
|
2023-07-19 17:42:15 +08:00
|
|
|
|
$qualification = json_decode($company['qualification'], true);
|
2023-07-19 12:42:57 +08:00
|
|
|
|
if ($company && $qualification['business_license']) {
|
2023-07-19 17:42:15 +08:00
|
|
|
|
$data = [
|
2023-07-19 12:42:57 +08:00
|
|
|
|
'name' => $company['company_name'],
|
|
|
|
|
'organization_code' => $company['organization_code'],
|
2023-07-19 17:42:15 +08:00
|
|
|
|
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png', //$qualification['business_license'],
|
|
|
|
|
'master_name' => $company['master_name'],
|
|
|
|
|
'master_email' => $company['master_email'],
|
2023-09-07 15:18:57 +08:00
|
|
|
|
'master_phone' => $company['master_phone'],
|
|
|
|
|
'master_id_card' => $company['master_id_card'],
|
2023-07-19 12:42:57 +08:00
|
|
|
|
];
|
|
|
|
|
$res = app(JunziqianController::class)->organizationReapply($data);
|
|
|
|
|
if ($res->success == true) {
|
2023-09-08 21:20:13 +08:00
|
|
|
|
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data, 'face_create_status'=>1]); //todo 上人脸采集功能时
|
2023-08-25 16:56:15 +08:00
|
|
|
|
return $this->success('系统认证中,请稍后刷新页面查看', ['email' => $res->data], 1, 1);
|
2023-07-19 12:42:57 +08:00
|
|
|
|
} else {
|
|
|
|
|
return $this->fail($res->msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-20 17:56:39 +08:00
|
|
|
|
|
2023-09-04 17:48:08 +08:00
|
|
|
|
// 企业人脸校验上传
|
|
|
|
|
public function organizationFaceCreate()
|
|
|
|
|
{
|
|
|
|
|
$params = (new CompanyValidate())->goCheck('detail');
|
|
|
|
|
$company = Db::name('company')->where('id', $params['id'])->find();
|
2023-09-07 19:06:35 +08:00
|
|
|
|
$re = CompanyLogic::originationFaceCreate($company);
|
|
|
|
|
if ($re === true) {
|
2023-09-08 15:33:27 +08:00
|
|
|
|
return $this->success('人脸采集中,请稍后刷新页面查看',[],1, 1);
|
2023-09-04 17:48:08 +08:00
|
|
|
|
} else {
|
2023-09-07 19:06:35 +08:00
|
|
|
|
return $this->fail($re);
|
2023-09-04 17:48:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private function companyCheck($company) {
|
|
|
|
|
if (empty($company)) {
|
|
|
|
|
return $this->fail("公司不存在");
|
|
|
|
|
}
|
|
|
|
|
if(empty($company['master_id_card'])) {
|
|
|
|
|
return $this->fail("主联系人证件号为空,无法上传企业人脸");
|
|
|
|
|
}
|
|
|
|
|
if(empty($company['master_email'])) {
|
|
|
|
|
return $this->fail("主联系人邮箱为空,无法上传企业人脸");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-07-20 17:56:39 +08:00
|
|
|
|
public function userList()
|
|
|
|
|
{
|
|
|
|
|
$existUsers = Company::where('status', '<>', -1)->column('admin_id');
|
|
|
|
|
$existUsers = array_unique($existUsers);
|
|
|
|
|
$users = Admin::whereNotIn('id', $existUsers)->field('id,name,avatar')->select()->toArray();
|
2023-07-21 11:23:39 +08:00
|
|
|
|
return $this->success('success', $users);
|
2023-07-20 17:56:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-21 09:58:46 +08:00
|
|
|
|
/**
|
|
|
|
|
* 所有成员公司
|
|
|
|
|
* @param $id
|
|
|
|
|
* @return \think\response\Json
|
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
*/
|
2023-07-21 11:05:12 +08:00
|
|
|
|
public function subordinate($company_id)
|
2023-07-21 09:58:46 +08:00
|
|
|
|
{
|
2023-08-21 17:26:31 +08:00
|
|
|
|
$ids = Contract::where('party_a', $company_id)->where('status', 1)->where('type', 1)->column('party_b');
|
|
|
|
|
if ($ids) {
|
|
|
|
|
$result = Company::where('id', 'in', $ids)->field('company_name,id,company_type,company_type company_type_name,area,area area_name,street,street street_name,is_contract,area_manager,area_manager area_manager_name,master_name,master_phone,is_authentication')->select();
|
|
|
|
|
} else {
|
|
|
|
|
$result = [];
|
2023-08-18 11:01:11 +08:00
|
|
|
|
}
|
2023-08-03 12:47:20 +08:00
|
|
|
|
$data['lists'] = $result;
|
2023-07-23 23:17:29 +08:00
|
|
|
|
return $this->success('success', $data);
|
2023-07-21 09:58:46 +08:00
|
|
|
|
}
|
2023-08-17 10:39:05 +08:00
|
|
|
|
|
|
|
|
|
public function responsible_area()
|
|
|
|
|
{
|
|
|
|
|
$parmas = $this->request->param();
|
|
|
|
|
if (!isset($parmas['key']) && isset($parmas['key']) == '' || !isset($parmas['value']) && isset($parmas['value']) == '') {
|
|
|
|
|
return $this->fail('参数错误');
|
|
|
|
|
}
|
|
|
|
|
if ($parmas['key'] == 'city') {
|
|
|
|
|
$where[] = ['area', '=', 0];
|
|
|
|
|
}
|
2023-08-21 17:26:31 +08:00
|
|
|
|
if ($parmas['value'] == '') {
|
2023-08-17 15:30:58 +08:00
|
|
|
|
return $this->fail('参数不能为空');
|
|
|
|
|
}
|
2023-08-17 10:39:05 +08:00
|
|
|
|
$where[] = [$parmas['key'], '=', $parmas['value']];
|
|
|
|
|
switch ($parmas['key']) {
|
|
|
|
|
case 'city':
|
2023-08-21 17:26:31 +08:00
|
|
|
|
// $geo_area=Db::name('geo_area')->where('city_code', '=', $parmas['value'])->column('area_code');
|
|
|
|
|
// $where[] = ['area', 'in', $geo_area];
|
2023-08-17 10:39:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 'area':
|
2023-08-21 17:26:31 +08:00
|
|
|
|
$street_code = Db::name('geo_street')->where('area_code', '=', $parmas['value'])->column('street_code');
|
|
|
|
|
$where[] = ['street', 'in', $street_code];
|
|
|
|
|
$where[] = ['village', '=', 0];
|
2023-08-17 10:39:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case 'street':
|
2023-08-21 17:26:31 +08:00
|
|
|
|
$street_code = Db::name('geo_village')->where('street_code', '=', $parmas['value'])->column('village_code');
|
|
|
|
|
$where[] = ['village', 'in', $street_code];
|
|
|
|
|
$where[] = ['brigade', '=', 0];
|
|
|
|
|
break;
|
|
|
|
|
case 'village':
|
|
|
|
|
// $street_code = Db::name('geo_brigade')->where('street_code', '=', $parmas['value'])->column('village_code');
|
|
|
|
|
$where[] = ['village', '=', $parmas['value']];
|
|
|
|
|
// $where[] = ['brigade', '=', 0];
|
2023-08-17 10:39:05 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-08-17 16:58:20 +08:00
|
|
|
|
|
2023-08-17 10:39:05 +08:00
|
|
|
|
$res = Company::where($where)->column('responsible_area');
|
2023-08-21 17:26:31 +08:00
|
|
|
|
|
|
|
|
|
foreach ($res as $k => $v) {
|
|
|
|
|
$res[$k] = explode(',', $v);
|
2023-08-17 10:39:05 +08:00
|
|
|
|
}
|
2023-08-21 17:26:31 +08:00
|
|
|
|
$data = [];
|
|
|
|
|
foreach ($res as $k => $v) {
|
|
|
|
|
foreach ($v as $kk => $vv) {
|
|
|
|
|
if ($vv != '') {
|
2023-08-17 10:39:05 +08:00
|
|
|
|
$data[] = $vv;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-21 17:26:31 +08:00
|
|
|
|
return $this->success('success', array_unique($data));
|
2023-08-17 10:39:05 +08:00
|
|
|
|
}
|
2023-09-13 15:54:15 +08:00
|
|
|
|
public function createShopMerchant()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$params = $this->request->param();
|
2023-09-15 14:55:41 +08:00
|
|
|
|
Log::info(['商户入驻请求', $params]);
|
2023-09-13 15:54:15 +08:00
|
|
|
|
if (empty($params['company_name'])) {
|
|
|
|
|
throw new Exception('商户名称不能为空');
|
|
|
|
|
}
|
|
|
|
|
if (empty($params['organization_code'])) {
|
|
|
|
|
throw new Exception('社会统一信用代码不能为空');
|
|
|
|
|
}
|
|
|
|
|
if (empty($params['master_name'])) {
|
|
|
|
|
throw new Exception('商户法人名称不能为空');
|
|
|
|
|
}
|
2023-09-15 13:37:21 +08:00
|
|
|
|
$master_email=Db::name('company_form')->where('organization_code',$params['organization_code'])->value('master_email');
|
2023-09-15 18:01:25 +08:00
|
|
|
|
dd($master_email);
|
2023-09-15 17:45:46 +08:00
|
|
|
|
$isQueryStatus = false; // 需要进一步查询是否已做过企业认证
|
|
|
|
|
// $master_email为空表示没有做过认证
|
2023-09-15 13:37:21 +08:00
|
|
|
|
if($master_email){
|
2023-09-15 17:45:46 +08:00
|
|
|
|
$isQueryStatus = true;
|
2023-09-15 13:37:21 +08:00
|
|
|
|
}else{
|
|
|
|
|
$master_email=substr(md5(uniqid()),rand(0, 22),10)."@lihai.com";
|
|
|
|
|
}
|
2023-09-13 15:54:15 +08:00
|
|
|
|
$data = [
|
2023-09-15 13:37:21 +08:00
|
|
|
|
'mer_intention_id' => $params['mer_intention_id']??'', // 商城商户入驻申请id,签约完成后回调使用
|
|
|
|
|
'company_name' => $params['company_name']??'',
|
|
|
|
|
'organization_code' => $params['organization_code']??'',
|
|
|
|
|
'city' => $params['city']??'',
|
|
|
|
|
'area' => $params['area']??'',
|
|
|
|
|
'street' => $params['street']??'',
|
|
|
|
|
'address' => $params['address']??'',
|
|
|
|
|
'master_name' => $params['master_name']??'',
|
|
|
|
|
'master_phone' => $params['master_phone']??'',
|
|
|
|
|
'master_email' => $master_email??'',
|
2023-09-15 15:22:27 +08:00
|
|
|
|
'face_create_status' => 1,
|
2023-09-15 13:37:21 +08:00
|
|
|
|
'qualification' => !empty($params['images'])?$params['images']:json_encode([])
|
2023-09-13 15:54:15 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$shopMerchantModel = ShopMerchant::create($data);
|
|
|
|
|
|
2023-09-15 17:45:46 +08:00
|
|
|
|
Log::info(['商户入驻请求-通滩镇商户', $params['street'], $isQueryStatus]);
|
|
|
|
|
// 如果是通滩镇的商户,查询一下企业认证状态,通过的情况,则直接发起生成合同
|
|
|
|
|
if ($params['street'] == '510502106' && $isQueryStatus) {
|
|
|
|
|
$statusRe = app(JunziqianController::class)->shopMerchantStatusQuery($master_email);
|
|
|
|
|
Log::info(['商户入驻请求-通滩镇商户-认证状态查询结果', $statusRe]);
|
|
|
|
|
if($statusRe->success == true) {
|
|
|
|
|
$statusData = json_decode($statusRe->data, true);
|
|
|
|
|
if ($statusData['status'] == 1) {
|
|
|
|
|
// 生成合同
|
|
|
|
|
$createContractData = [
|
|
|
|
|
'id' => $shopMerchantModel->id,
|
|
|
|
|
'party_a' => 1,
|
|
|
|
|
'party_a_name' => '泸州市海之农科技有限公司',
|
|
|
|
|
'party_b' => $shopMerchantModel->id,
|
|
|
|
|
'party_b_name' => $params['company_name'],
|
|
|
|
|
'contract_type' => 22,
|
|
|
|
|
];
|
|
|
|
|
$shopContractModel = new ShopContract();
|
|
|
|
|
$shopContractModel->contract_no = time();
|
|
|
|
|
$shopContractModel->create_time = time();
|
|
|
|
|
$shopContractModel->check_status = 1;
|
|
|
|
|
$shopContractModel->update_time = time();
|
|
|
|
|
$shopContractModel->setAttrs($createContractData);
|
|
|
|
|
$shopContractModel->save($createContractData);
|
|
|
|
|
return $this->success('已做过企业认证,直接生成合同成功', [], 1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 15:54:15 +08:00
|
|
|
|
if (!$shopMerchantModel->isEmpty()) {
|
|
|
|
|
// 自动发起企业认证
|
|
|
|
|
$shopMerchantCertificationData = [
|
|
|
|
|
'name' => $shopMerchantModel->company_name,
|
|
|
|
|
'organization_code' => $shopMerchantModel->organization_code,
|
|
|
|
|
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png',
|
|
|
|
|
'master_name' => $shopMerchantModel->master_name,
|
|
|
|
|
'master_email' => $shopMerchantModel->master_email,
|
|
|
|
|
'master_phone' => $shopMerchantModel->master_phone,
|
|
|
|
|
'id' => $shopMerchantModel->id,
|
|
|
|
|
];
|
|
|
|
|
app(JunziqianController::class)->ShopMerchantCertification($shopMerchantCertificationData);
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception('商户创建失败');
|
|
|
|
|
}
|
2023-09-15 17:45:46 +08:00
|
|
|
|
return $this->success('商户创建成功', [], 1, 1);
|
2023-09-13 15:54:15 +08:00
|
|
|
|
} catch (Exception $exception) {
|
2023-09-15 14:55:41 +08:00
|
|
|
|
Log::error(['商户入驻请求失败', $exception->getMessage()]);
|
2023-09-13 15:54:15 +08:00
|
|
|
|
return $this->fail($exception->getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2023-07-18 18:05:58 +08:00
|
|
|
|
}
|