...
|
...
|
@@ -10,6 +10,7 @@ namespace api\index\controller; |
|
|
|
|
|
|
|
|
use api\common\model\ActivityNews;
|
|
|
use api\common\model\AddressModel;
|
|
|
use api\common\model\ClassModel;
|
|
|
use api\common\model\ClassQuestionModel;
|
|
|
use api\common\model\GoodsModel;
|
...
|
...
|
@@ -560,5 +561,161 @@ class SecondController extends RestBaseController |
|
|
$this->success('',$goodInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 地址列表
|
|
|
* @description 地址列表
|
|
|
* @author sgj
|
|
|
* @url /index/second/addressList
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return data:地址列表@
|
|
|
* @data name:姓名 province:省 city:市 district:区 address:地址 tel:电话 is_default:是否默认地址
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function addressList(){
|
|
|
$userId=$this->getUserId();
|
|
|
$Address=new AddressModel();
|
|
|
$map['user_id']=$userId;
|
|
|
$list=$Address->where($map)->select();
|
|
|
$this->success('',$list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 添加地址
|
|
|
* @description 添加地址
|
|
|
* @author sgj
|
|
|
* @url /index/second/addAddress
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@param name:name type:int require:1 other: desc:姓名
|
|
|
*@param name:province type:int require:1 other: desc:省
|
|
|
*@param name:city type:int require:1 other: desc:市
|
|
|
*@param name:district type:int require:1 other: desc:区
|
|
|
*@param name:address type:int require:1 other: desc:地址
|
|
|
*@param name:is_default type:int require:1 other: desc:是否为默认地址1,是0,否
|
|
|
*@param name:tel type:int require:1 other: desc:电话
|
|
|
*@param name:wx_id type:int require:1 other: desc:微信号
|
|
|
*@param name:mail type:int require:1 other: desc:邮箱
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function addAddress(){
|
|
|
$userId=$this->getUserId();
|
|
|
$param = $this->request->param();
|
|
|
$validate = new Validate([
|
|
|
'name' => 'require',
|
|
|
'tel' => 'require',
|
|
|
'province' => 'require',
|
|
|
'city' => 'require',
|
|
|
'district' => 'require',
|
|
|
'address' => 'require',
|
|
|
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'name' => '姓名不能为空',
|
|
|
'tel' => '电话不能为空',
|
|
|
'province' => '省市区不能为空',
|
|
|
'city' => '省市区不能为空',
|
|
|
'district' => '省市区不能为空',
|
|
|
'address' => '省市区不能为空',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$Address=new AddressModel();
|
|
|
if ($param['is_default']==1){
|
|
|
$Address->setDefaultBefore($userId);
|
|
|
}
|
|
|
$param['user_id']=$userId;
|
|
|
$result=$Address->insert($param);
|
|
|
if ($result>0){
|
|
|
$this->success('添加成功');
|
|
|
}else{
|
|
|
$this->error('添加失败');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 删除地址
|
|
|
* @description 删除地址
|
|
|
* @author sgj
|
|
|
* @url /index/second/deleteAddress
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@param name:address_id type:int require:1 other: desc:地址id
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function deleteAddress(){
|
|
|
$userId=$this->getUserId();
|
|
|
$id=input('address_id');
|
|
|
$AddressModel=new AddressModel();
|
|
|
$info=$AddressModel->where('id',$id)->where('user_id',$userId)->delete();
|
|
|
$this->success('操作成功');
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 设置默认地址
|
|
|
* @description 设置默认地址
|
|
|
* @author sgj
|
|
|
* @url /index/second/defaultAddress
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@param name:address_id type:int require:1 other: desc:地址id
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function setDefault(){
|
|
|
$id=input('id');
|
|
|
$Address=new AddressModel();
|
|
|
$update['is_default']=1;
|
|
|
$result=$Address->where('id',$id)->update($update);
|
|
|
if ($result==1){
|
|
|
$this->success('操作成功');
|
|
|
}else{
|
|
|
$this->error('操作失败');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 获取单一地址
|
|
|
* @description 获取单一地址
|
|
|
* @author sgj
|
|
|
* @url /index/second/getAddress
|
|
|
* @method POST
|
|
|
*
|
|
|
*
|
|
|
*@header name:XX-Token require:1 default: desc:token
|
|
|
*@param name:address_id type:int require:1 other: desc:地址id
|
|
|
*
|
|
|
* @return data:地址列表@
|
|
|
* @data name:姓名 province:省 city:市 district:区 address:地址 tel:电话 is_default:是否默认地址
|
|
|
*
|
|
|
* @throws
|
|
|
*/
|
|
|
public function getAddress(){
|
|
|
$id=input('id');
|
|
|
$Address=new AddressModel();
|
|
|
$return=$Address->where('id',$id)->find();
|
|
|
$this->success('',$return);
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|