1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?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;
 
/**
 * 商户申请
 */
class Apply extends Controller
{
    protected $user;
     /**
     * 构造方法
     */
    public function initialize()
    {   
        $this->user = $this->getUser();
    }
    //店铺分类
    public function category()
    {
        $list = CategoryModel::getALL();
        //是否需要短信验证
        $sms_open = Setting::getItem('store')['sms_open'];
        return $this->renderSuccess('', compact('list', 'sms_open'));
    }
    //店铺区域
    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() ?:'发送失败');
    }
 
   
}