124 lines
4.5 KiB
PHP
124 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace app\middleapi\controller;
|
|
|
|
use app\common\controller\BaseLikeAdminController;
|
|
use app\common\model\Approve;
|
|
use app\common\model\auth\Admin;
|
|
use app\common\model\Company;
|
|
use app\common\model\CompanyForm;
|
|
use app\common\model\ShopMerchant;
|
|
use app\common\model\task\Task;
|
|
use think\facade\Db;
|
|
use think\response\Json;
|
|
|
|
class MerchantController extends BaseLikeAdminController
|
|
{
|
|
//商户档案列表
|
|
public function merchantRecordLists(): Json
|
|
{
|
|
if(!$this->request->isPost()){
|
|
return $this->fail('请求方式错误');
|
|
}
|
|
$params = $this->request->post(['page_no','page_size','merchant_name','master_name','master_phone']);
|
|
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
|
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
|
$where = [];
|
|
if(!empty($params['merchant_name'])){
|
|
$where[] = ['company_name','like','%'.$params['merchant_name'].'%'];
|
|
}
|
|
if(!empty($params['master_name'])){
|
|
$where[] = ['master_name','like','%'.$params['master_name'].'%'];
|
|
}
|
|
if(!empty($params['master_phone'])){
|
|
$where[] = ['master_phone','like','%'.$params['master_phone'].'%'];
|
|
}
|
|
$data = ShopMerchant::where($where)
|
|
->field(['id', 'company_name', 'organization_code', 'master_name', 'master_phone'])
|
|
->page($pageNo, $pageSize)
|
|
->order(['id' => 'desc'])
|
|
->append(['notes'], true)
|
|
->withAttr('notes',function($value,$data){
|
|
return Db::name('company_authentication_fail_log')->where('company_id',$data['id'])->where('log_type', 3)->order(['id'=>'desc'])->limit(1)->value('fail_reason');
|
|
})->select()->toArray();
|
|
$count = ShopMerchant::where($where)->count();
|
|
$result = [
|
|
'lists' => $data,
|
|
'count' => $count,
|
|
'page_no' => $pageNo,
|
|
'page_size' => $pageSize
|
|
];
|
|
return $this->success('请求成功',$result);
|
|
}
|
|
|
|
//商户认证表格列表
|
|
public function merchantAuthLists(): Json
|
|
{
|
|
if(!$this->request->isPost()){
|
|
return $this->fail('请求方式错误');
|
|
}
|
|
$params = $this->request->post(['page_no','page_size','merchant_name','organization_code','master_name']);
|
|
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
|
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
|
$where = [];
|
|
if(!empty($params['merchant_name'])){
|
|
$where[] = ['company_name','like','%'.$params['merchant_name'].'%'];
|
|
}
|
|
if(!empty($params['organization_code'])){
|
|
$where[] = ['organization_code','like','%'.$params['organization_code'].'%'];
|
|
}
|
|
if(!empty($params['master_name'])){
|
|
$where[] = ['master_name','like','%'.$params['master_name'].'%'];
|
|
}
|
|
$data = CompanyForm::where($where)
|
|
->field(['id', 'company_name', 'organization_code', 'address', 'master_name', 'type', 'master_email', 'notes'])
|
|
->page($pageNo, $pageSize)->order(['id' => 'desc'])->select()->toArray();
|
|
$count = CompanyForm::where($where)->count();
|
|
$result = [
|
|
'lists' => $data,
|
|
'count' => $count,
|
|
'page_no' => $pageNo,
|
|
'page_size' => $pageSize
|
|
];
|
|
return $this->success('请求成功',$result);
|
|
}
|
|
|
|
//商户申请列表
|
|
public function merchantApplyLists(): Json
|
|
{
|
|
if(!$this->request->isPost()){
|
|
return $this->fail('请求方式错误');
|
|
}
|
|
$params = $this->request->post(['page_no','page_size','check_status','type']);
|
|
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
|
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
|
$where = [];
|
|
if(!empty($params['check_status']) && in_array($params['check_status'],[1,2,3])){
|
|
$where[] = ['check_status','=', $params['check_status']];
|
|
}
|
|
if(!empty($params['type']) && in_array($params['type'],[2,3])){
|
|
$where[] = ['type','=',$params['type']];
|
|
}else{
|
|
$where[] = ['type','in','2,3'];
|
|
}
|
|
$data = Approve::where($where)->with('task')->append(['area_manager', 'company_name'], true)
|
|
->page($pageNo, $pageSize)->order(['id' => 'desc'])->select()
|
|
->withAttr('area_manager',function($value,$data){
|
|
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
|
})
|
|
->withAttr('company_name',function($value,$data){
|
|
$task = Task::where('id', $data['task_id'])->find();
|
|
if(!empty($task)){
|
|
return Company::where(['id' => $task['company_id']])->value('company_name');
|
|
}
|
|
})->toArray();
|
|
$count = Approve::where($where)->count();
|
|
$result = [
|
|
'lists' => $data,
|
|
'count' => $count,
|
|
'page_no' => $pageNo,
|
|
'page_size' => $pageSize
|
|
];
|
|
return $this->success('请求成功',$result);
|
|
}
|
|
} |