102 lines
4.8 KiB
PHP
102 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace app\controller\api;
|
|
|
|
|
|
use app\services\supplier\SystemSupplierApplyServices;
|
|
use app\services\supplier\SystemSupplierServices;
|
|
use crmeb\basic\BaseController;
|
|
use think\App;
|
|
use think\exception\ValidateException;
|
|
|
|
class Supplier extends BaseController{
|
|
|
|
protected $services;
|
|
|
|
public function __construct(App $app, SystemSupplierServices $services){
|
|
parent::__construct($app);
|
|
$this->services = $services;
|
|
}
|
|
|
|
/**
|
|
* Common: 申请入驻
|
|
* Author: wu-hui
|
|
* Time: 2024/01/30 14:28
|
|
* @return mixed
|
|
*/
|
|
public function applyJoin(){
|
|
// 参数获取
|
|
$data = $this->checkParam();
|
|
if((int)$data['supplierApplyId'] > 0){
|
|
// 编辑账号信息
|
|
app()->make(SystemSupplierApplyServices::class)->editInfo((array)$data);
|
|
}else{
|
|
// 添加账号
|
|
app()->make(SystemSupplierApplyServices::class)->createApplyInfo((array)$data);
|
|
}
|
|
|
|
return app('json')->success('操作成功');
|
|
}
|
|
/**
|
|
* Common: 申请信息接收
|
|
* Author: wu-hui
|
|
* Time: 2024/01/30 14:18
|
|
* @return array
|
|
*/
|
|
private function checkParam():array{
|
|
// 接收表单参数
|
|
$supplierApplyId = (int)$this->request->param('id');
|
|
$applyInfo = $this->request->params([
|
|
'invite_agent_id',
|
|
'winery_name',
|
|
'scale',
|
|
'cellar_size',
|
|
'corporation_name',
|
|
'corporation_phone',
|
|
['corporation_id_card',[]],
|
|
'chairman_name',
|
|
'chairman_phone',
|
|
['chairman_id_card',[]],
|
|
'contacts_name',
|
|
'contacts_phone',
|
|
'business_license',
|
|
'production_icense',
|
|
'circulative_license',
|
|
]);
|
|
// 数据校验
|
|
if (empty($applyInfo['invite_agent_id'])) throw new ValidateException('非法请求,无有效邀请人!');
|
|
if (empty($applyInfo['winery_name'])) throw new ValidateException('请输入酒厂名称!');
|
|
if (empty($applyInfo['scale'])) throw new ValidateException('请输入年产量多少吨!');
|
|
if (empty($applyInfo['cellar_size'])) throw new ValidateException('请输入窖池大小!');
|
|
if (empty($applyInfo['corporation_name'])) throw new ValidateException('请输入法人姓名!');
|
|
if (empty($applyInfo['corporation_phone'])) throw new ValidateException('请输入法人电话!');
|
|
if (isPhone($applyInfo['corporation_phone'])) throw new ValidateException('请输入正确的法人电话!');
|
|
if (empty($applyInfo['corporation_id_card'])) throw new ValidateException('请上传法人身份证正反面图片!');
|
|
if (empty($applyInfo['chairman_name'])) throw new ValidateException('请输入董事长姓名!');
|
|
if (empty($applyInfo['chairman_phone'])) throw new ValidateException('请输入董事长电话!');
|
|
if (isPhone($applyInfo['chairman_phone'])) throw new ValidateException('请输入正确的董事长电话!');
|
|
if (empty($applyInfo['chairman_id_card'])) throw new ValidateException('请上传董事长身份证正反面图片!');
|
|
if (empty($applyInfo['contacts_name'])) throw new ValidateException('请输入联系人姓名!');
|
|
if (empty($applyInfo['contacts_phone'])) throw new ValidateException('请输入联系人电话!');
|
|
if (isPhone($applyInfo['contacts_phone'])) throw new ValidateException('请输入正确的联系人电话!');
|
|
if (empty($applyInfo['business_license'])) throw new ValidateException('请上传营业执照!');
|
|
if (empty($applyInfo['production_icense'])) throw new ValidateException('请上传生产许可证!');
|
|
if (empty($applyInfo['circulative_license'])) throw new ValidateException('请上传流通许可证!');
|
|
// 联系人及联系人手机号
|
|
$isHas = app()->make(SystemSupplierApplyServices::class)->searchModel(['contacts_phone'=>$applyInfo['contacts_phone']])->count();
|
|
if($isHas >= 1) throw new ValidateException('联系人已经存在,请勿重复申请!');
|
|
// 酒厂是否已经存在
|
|
$isHas = app()->make(SystemSupplierApplyServices::class)->searchModel(['winery_name'=>$applyInfo['winery_name']])->count();
|
|
if($isHas >= 1) throw new ValidateException('酒厂已经存在,请勿重复申请!');
|
|
$isHas = app()->make(SystemSupplierApplyServices::class)->searchModel(['winery_name'=>$applyInfo['winery_name']])->count();
|
|
if($isHas >= 1) throw new ValidateException('酒厂已经存在,请勿重复申请!');
|
|
$nameIsHave = $this->services->isHave('supplier_name',$applyInfo['winery_name']);
|
|
if($nameIsHave) throw new ValidateException('该酒厂已经入驻,请勿重复申请!');
|
|
|
|
|
|
return compact('supplierApplyId','applyInfo');
|
|
}
|
|
|
|
|
|
}
|