liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
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
<?php
 
namespace app\api\controller\plus\agent;
 
use app\api\controller\Controller;
use app\api\model\plus\agent\Apply as AgentApplyModel;
use  app\common\model\plus\agent\Setting;
use app\common\exception\BaseException;
 
/**
 * 分销商申请
 */
class Apply extends Controller
{
    // 当前用户
    private $user;
 
    /**
     * 构造方法
     */
    public function initialize()
    {
        $this->user = $this->getUser();   // 用户信息
    }
 
    /**
     * 提交分销商申请
     */
    public function submit()
    {
        $data = $this->postData();
        if (empty($data['name']) || empty($data['mobile'])) {
            throw new BaseException(['msg' => '用户名或者手机号为空']);
        }
        $model = new AgentApplyModel;
        if ($model->submit($this->user, $data)) {
            return $this->renderSuccess('成功');
        }
        return $this->renderError($model->getError() ?: '提交失败');
    }
 
    /*
     *获取分销商协议
     */
    public function getAgreement()
    {
        $model = new Setting();
        $data = $model->getItem('license');
        return $this->renderSuccess('', compact('data'));
    }
 
}