<?php
|
|
namespace app\api\controller\supplier;
|
|
use app\api\controller\Controller;
|
use app\api\model\supplier\Apply as ApplyModel;
|
use app\common\model\settings\Setting;
|
use app\api\model\supplier\Category as CategoryModel;
|
use app\common\model\user\Sms as SmsModel;
|
use app\common\model\supplier\Area as AreaModel;
|
use app\common\enum\supplier\SupplierType;
|
|
/**
|
* 商户申请
|
*/
|
class Apply extends Controller
|
{
|
protected $user;
|
/**
|
* 构造方法
|
*/
|
public function initialize()
|
{
|
$this->user = $this->getUser();
|
}
|
//店铺分类
|
public function category()
|
{
|
//供应商类型列表
|
$typeList = SupplierType::getTypeName();
|
//是否需要短信验证
|
$sms_open = Setting::getItem('store')['sms_open'];
|
$list=[];
|
foreach ($typeList as $key => $value) {
|
$list[$key] = CategoryModel::getALL(['category_type'=>$key]);
|
}
|
return $this->renderSuccess('', compact('list', 'sms_open','typeList'));
|
}
|
//店铺区域
|
public function area()
|
{
|
$list = AreaModel::getALL();
|
return $this->renderSuccess('', compact('list'));
|
}
|
/**
|
* 申请开店
|
*/
|
public function index()
|
{
|
$data = $this->request->post();
|
$model = new ApplyModel;
|
// 新增记录
|
if ($model->add($data,$this->user)) {
|
return $this->renderSuccess('申请成功,请等待平台审核', []);
|
}
|
return $this->renderError($model->getError() ?: '申请失败');
|
}
|
//获取申请状态
|
public function detail()
|
{
|
$detail = ApplyModel::getLastDetail($this->user['user_id']);
|
return $this->renderSuccess('', compact('detail'));
|
}
|
/**
|
* 发送短信
|
*/
|
public function sendCode($mobile)
|
{
|
$model = new SmsModel();
|
if($model->send($mobile, 'apply')){
|
return $this->renderSuccess();
|
}
|
return $this->renderError($model->getError() ?:'发送失败');
|
}
|
|
|
}
|