quanwei
2 days ago 73b874c72ad55eb9eef21c36160ac0de58f0189e
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
<?php
 
namespace app\api\controller\user;
 
use app\api\model\user\UserAuth;
use app\api\controller\Controller;
 
/**
 * 收货地址控制器
 */
class Auth extends Controller
{
    /**
     * 详情
     */
    public function detail()
    {
        $user = $this->getUser();
        $data = UserAuth::detail($user['user_id']);
        return $this->renderSuccess('', compact('data'));
    }
 
    /**
     * 保存
     */
    public function save()
    {
        $data = $this->request->post();
        if ($data['account'] == '') {
            return $this->renderError('账户名称不能为空');
        }
        if ($data['residence_address'] == '') {
            return $this->renderError('户籍地址不能为空');
        }
        if ($data['legal_person_name'] == '') {
            return $this->renderError('法人姓名不能为空');
        }
        $user = $this->getUser();
        $model = UserAuth::detail($user['user_id']);
 
        if (!empty($model)) {
            //修改记录
            $data['auth_id'] = $model['auth_id'];
            if ($model->edit($data)) {
                return $this->renderSuccess('提交成功');
            }
        }else{
            $model = new UserAuth;
            $data['user_id'] = $user['user_id'];
            //创建记录
            if ($model->add($data,$user['app_id'])) {
                return $this->renderSuccess('提交成功');
            }
        }
 
        return $this->renderError('提交失败');
    }
}