<?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('提交失败');
|
}
|
}
|