完善提现功能:商城商户入驻审批流
This commit is contained in:
parent
62fbc3b995
commit
6883c63dc1
@ -22,11 +22,9 @@ use app\common\logic\CompanyLogic;
|
||||
use app\adminapi\validate\CompanyValidate;
|
||||
use app\api\controller\JunziqianController;
|
||||
use app\common\logic\RedisLogic;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\ShopContract;
|
||||
use app\common\model\ShopMerchant;
|
||||
use think\cache\driver\Redis;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
use app\common\logic\contract\ContractLogic;
|
||||
@ -363,24 +361,30 @@ class CompanyController extends BaseAdminController
|
||||
{
|
||||
try {
|
||||
$params = $this->request->param();
|
||||
Log::info(['商户入驻请求', $params]);
|
||||
if (empty($params['company_name'])) {
|
||||
throw new Exception('商户名称不能为空');
|
||||
}
|
||||
if (empty($params['organization_code'])) {
|
||||
throw new Exception('社会统一信用代码不能为空');
|
||||
}
|
||||
if (empty($params['master_name'])) {
|
||||
throw new Exception('商户法人名称不能为空');
|
||||
}
|
||||
$master_email=Db::name('company_form')->where('organization_code',$params['organization_code'])->value('master_email');
|
||||
dd($master_email);
|
||||
$isQueryStatus = false; // 需要进一步查询是否已做过企业认证
|
||||
// $master_email为空表示没有做过认证
|
||||
if($master_email){
|
||||
$isQueryStatus = true;
|
||||
}else{
|
||||
$master_email=substr(md5(uniqid()),rand(0, 22),10)."@lihai.com";
|
||||
Log::info(['商户入驻申请-请求参数', $params]);
|
||||
// if (empty($params['company_name'])) {
|
||||
// throw new Exception('商户名称不能为空');
|
||||
// }
|
||||
// if (empty($params['organization_code'])) {
|
||||
// throw new Exception('社会统一信用代码不能为空');
|
||||
// }
|
||||
// if (empty($params['master_name'])) {
|
||||
// throw new Exception('商户法人名称不能为空');
|
||||
// }
|
||||
// $master_email=Db::name('company_form')->where('organization_code',$params['organization_code'])->value('master_email');
|
||||
//
|
||||
// $isQueryStatus = false; // 需要进一步查询是否已做过企业认证
|
||||
// // $master_email为空表示没有做过认证
|
||||
// if($master_email){
|
||||
// $isQueryStatus = true;
|
||||
// }else{
|
||||
// $master_email=substr(md5(uniqid()),rand(0, 22),10)."@lihai.com";
|
||||
// }
|
||||
|
||||
// 根据street码查询所属镇管理公司
|
||||
$company = Company::where(['street' => $params['street'], 'company_type' => 41])->find();
|
||||
if(empty($company)) {
|
||||
throw new Exception('未找到所属镇管理公司');
|
||||
}
|
||||
$data = [
|
||||
'mer_intention_id' => $params['mer_intention_id']??'', // 商城商户入驻申请id,签约完成后回调使用
|
||||
@ -393,60 +397,75 @@ class CompanyController extends BaseAdminController
|
||||
'master_name' => $params['master_name']??'',
|
||||
'master_phone' => $params['master_phone']??'',
|
||||
'master_email' => $master_email??'',
|
||||
'type_name' => $params['type_name'] ?? '', //店铺类型
|
||||
'category_name' => $params['category_name'] ?? '', //商户分类
|
||||
'face_create_status' => 1,
|
||||
'qualification' => !empty($params['images'])?$params['images']:json_encode([])
|
||||
];
|
||||
$approveModel = new Approve();
|
||||
// 插入审批流
|
||||
$approveModel->type = 2;
|
||||
$approveModel->flow_id = 2;
|
||||
$approveModel->name = '商户入驻审批';
|
||||
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
|
||||
$approveModel->department_id = '0';
|
||||
$approveModel->check_admin_ids = $company['area_manager']; // 当前审批人ID 片区经理的admin_id
|
||||
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
|
||||
$approveModel->other_type = 6;
|
||||
$approveModel->extend = json_encode($data);
|
||||
$approveModel->create_time = time();
|
||||
$approveModel->update_time = time();
|
||||
$approveModel->save();
|
||||
|
||||
$shopMerchantModel = ShopMerchant::create($data);
|
||||
// $shopMerchantModel = ShopMerchant::create($data);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
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('商户创建失败');
|
||||
}
|
||||
return $this->success('商户创建成功', [], 1, 1);
|
||||
// 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('商户创建失败');
|
||||
// }
|
||||
return $this->success('审批创建成功', [], 1, 1);
|
||||
} catch (Exception $exception) {
|
||||
Log::error(['商户入驻请求失败', $exception->getMessage()]);
|
||||
Log::error(['商户入驻审批失败', $exception->getMessage()]);
|
||||
return $this->fail($exception->getMessage());
|
||||
}
|
||||
|
||||
|
43
app/api/controller/ApproveController.php
Normal file
43
app/api/controller/ApproveController.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\lists\approve\ApproveLists;
|
||||
use app\common\model\Approve;
|
||||
use think\facade\Db;
|
||||
|
||||
class ApproveController extends BaseApiController
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ApproveLists());
|
||||
}
|
||||
|
||||
public function audit()
|
||||
{
|
||||
$params = $this->request->param(); // id check_status remark
|
||||
$approve = Approve::find($params['id']);
|
||||
if (!$approve) {
|
||||
$this->fail('数据不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
// 拒绝通过
|
||||
if ($params['check_status'] == 3) {
|
||||
$this->refuse($approve);
|
||||
}
|
||||
// 修改任务完成状态
|
||||
if ($params['check_status'] == 2) {
|
||||
$this->pass($approve);
|
||||
}
|
||||
}
|
||||
|
||||
private static function pass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static function refuse()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
52
app/api/lists/approve/ApproveLists.php
Normal file
52
app/api/lists/approve/ApproveLists.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\lists\approve;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\Approve;
|
||||
use app\common\model\user\User;
|
||||
|
||||
class ApproveLists extends BaseApiDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/08/31 11:08
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' =>['type']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function queryWhere()
|
||||
{
|
||||
$where = [];
|
||||
$param = $this->request->param();
|
||||
if (isset($param['type']) && $param['type'] == 2) {
|
||||
$adminId = User::where(['id' => $this->userId])->with('company')->value('admin_id');
|
||||
$where[] = ['check_admin_ids', '=', $adminId]; // 只有片区经理才能查看
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
return Approve::where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return Approve::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user