...
|
...
|
@@ -39,7 +39,13 @@ class User extends Api |
|
|
{
|
|
|
// 当前用户信息
|
|
|
$user = $this->auth->getUser();
|
|
|
return $this->success('成功',compact('user'));
|
|
|
$coupon_count = \app\common\model\UserCoupon::alias('uc')
|
|
|
->join('coupon c','c.id = uc.coupon_id')
|
|
|
->where('uc.user_id',$user['id'])
|
|
|
->where('uc.status','1')
|
|
|
->where('c.expiretime','>',time())
|
|
|
->count();
|
|
|
return $this->success('成功',compact('user','coupon_count'));
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -193,6 +199,7 @@ class User extends Api |
|
|
* @ApiParams (name="phone", type="string", required=true, description="手机号码")
|
|
|
* @ApiParams (name="area", type="string", required=true, description="所在地区", sample="广东省,广州市,海珠区")
|
|
|
* @ApiParams (name="detail", type="string", description="详细地址")
|
|
|
* @ApiParams (name="isdefault", type="string", description="是否默认:0=否,1=是")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -205,7 +212,11 @@ class User extends Api |
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$post = $this->request->request();
|
|
|
if (UserAddress::add($user, $post)) {
|
|
|
empty($post['name']) && $this->error(__('请填写收货人'));
|
|
|
empty($post['phone']) && $this->error(__('请填写手机号码'));
|
|
|
empty($post['area']) && $this->error(__('请选择所在地区'));
|
|
|
empty($post['detail']) && $this->error(__('请填写详细地址'));
|
|
|
if ((new UserAddress)->add($user, $post)) {
|
|
|
$this->success(__('添加成功'));
|
|
|
}
|
|
|
$this->error(__('添加失败'));
|
...
|
...
|
@@ -215,7 +226,7 @@ class User extends Api |
|
|
* 我的地址-详情
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="address_id", type="integer", required=true, description="地址ID")
|
|
|
* @ApiParams (name="user_address_id", type="integer", required=true, description="地址ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -227,8 +238,8 @@ class User extends Api |
|
|
public function addressDetail()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$address_id = $this->request->request('address_id');
|
|
|
$detail = UserAddress::detail($user['id'],$address_id);
|
|
|
$user_address_id = $this->request->request('user_address_id');
|
|
|
$detail = UserAddress::detail($user['id'],$user_address_id);
|
|
|
$area = array_values($detail['area']);
|
|
|
$this->success(__('成功'),compact('detail', 'area'));
|
|
|
}
|
...
|
...
|
@@ -237,11 +248,12 @@ class User extends Api |
|
|
* 我的地址-编辑
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="address_id", type="integer", required=true, description="地址ID")
|
|
|
* @ApiParams (name="user_address_id", type="integer", required=true, description="地址ID")
|
|
|
* @ApiParams (name="name", type="string", required=true, description="收货人")
|
|
|
* @ApiParams (name="phone", type="string", required=true, description="手机号码")
|
|
|
* @ApiParams (name="area", type="object", required=true, description="所在地区", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}")
|
|
|
* @ApiParams (name="detail", type="string", description="详细地址")
|
|
|
* @ApiParams (name="isdefault", type="string", description="是否默认:0=否,1=是")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -253,12 +265,15 @@ class User extends Api |
|
|
public function addressEdit()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$post['address_id'] = $this->request->post('address_id');
|
|
|
$post['name'] = $this->request->post('name');
|
|
|
$post['phone'] = $this->request->post('phone');
|
|
|
$post['area'] = $this->request->post('area');
|
|
|
$post['detail'] = $this->request->post('detail');
|
|
|
$model = UserAddress::detail($user['id'], $post['address_id']);
|
|
|
$post = $this->request->request();
|
|
|
$model = UserAddress::detail($user['id'], $post['user_address_id']);
|
|
|
if(empty($model)){
|
|
|
$this->error(__('地址不存在'));
|
|
|
}
|
|
|
empty($post['name']) && $this->error(__('请填写收货人'));
|
|
|
empty($post['phone']) && $this->error(__('请填写手机号码'));
|
|
|
empty($post['area']) && $this->error(__('请选择所在地区'));
|
|
|
empty($post['detail']) && $this->error(__('请填写详细地址'));
|
|
|
if ($model->edit($post)) {
|
|
|
$this->success(__('更新成功'));
|
|
|
}
|
...
|
...
|
@@ -269,7 +284,7 @@ class User extends Api |
|
|
* 我的地址-删除
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="address_id", type="integer", required=true, description="地址ID")
|
|
|
* @ApiParams (name="user_address_id", type="integer", required=true, description="地址ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -281,8 +296,8 @@ class User extends Api |
|
|
public function addressDelete()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$address_id = $this->request->request('address_id');
|
|
|
$model = UserAddress::detail($user['id'], $address_id);
|
|
|
$user_address_id = $this->request->request('user_address_id');
|
|
|
$model = UserAddress::detail($user['id'], $user_address_id);
|
|
|
if ($model->remove($user)) {
|
|
|
$this->success(__('删除成功'));
|
|
|
}
|
...
|
...
|
@@ -290,6 +305,30 @@ class User extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的地址-设为默认
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="user_address_id", type="integer", required=true, description="尺寸ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function addressDefault()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$user_size_id = $this->request->request('user_size_id');
|
|
|
$model = UserAddress::detail($user['id'], $user_size_id);
|
|
|
if ($model->setDefault()) {
|
|
|
$this->success(__('设置成功'));
|
|
|
}
|
|
|
$this->error(__('设置失败'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的尺寸-列表
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
...
|
...
|
@@ -309,6 +348,59 @@ class User extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的尺寸-身体信息
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiParams (name="gender", type="string", required=true, description="性别:1=男,2=女")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function bodyInfo()
|
|
|
{
|
|
|
$gender = $this->request->request('gender','1');
|
|
|
$list = \app\common\model\Style::styleList($gender);
|
|
|
$this->success(__('成功'),compact('list'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的尺寸-身材特征
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function bodyFeatures()
|
|
|
{
|
|
|
$list = \app\common\model\Style::styleList(3);
|
|
|
$this->success(__('成功'),compact('list'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的尺寸-全身照或半身照
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function bodyImage()
|
|
|
{
|
|
|
$list = \app\common\model\Style::styleList(4);
|
|
|
$this->success(__('成功'),compact('list'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (我的尺寸-添加)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
...
|
...
|
@@ -322,7 +414,7 @@ class User extends Api |
|
|
* @ApiParams (name="shoulder_width", type="integer", description="肩宽(厘米)")
|
|
|
* @ApiParams (name="gender", type="string", required=true, description="性别:1=男,2=女")
|
|
|
* @ApiParams (name="body_info", type="object", required=true, description="身体信息")
|
|
|
* @ApiParams (name="body_features", type="set", description="身体特征:1=脖子粗,2=手臂特别长,3=肩膀特别宽,多个值用英文逗号分隔")
|
|
|
* @ApiParams (name="body_features", type="string", description="身体特征,多个值用英文逗号分隔")
|
|
|
* @ApiParams (name="remark", type="string", description="备注")
|
|
|
* @ApiParams (name="body_images", type="file", description="身材照片,多文件")
|
|
|
* @ApiParams (name="isdefault", type="string", description="是否默认:0=否,1=是")
|
...
|
...
|
@@ -338,12 +430,12 @@ class User extends Api |
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$post = $this->request->request();
|
|
|
!empty($post['name']) && $this->error(__('请填写尺寸名称'));
|
|
|
!empty($post['height']) && $this->error(__('请填写身高'));
|
|
|
!empty($post['weight']) && $this->error(__('请填写体重'));
|
|
|
!empty($post['gender']) && $this->error(__('请选择性别'));
|
|
|
!empty($post['body_info']) && $this->error(__('请选择身体信息'));
|
|
|
if (UserSize::add($user, $post)) {
|
|
|
empty($post['name']) && $this->error(__('请填写尺寸名称'));
|
|
|
empty($post['height']) && $this->error(__('请填写身高'));
|
|
|
empty($post['weight']) && $this->error(__('请填写体重'));
|
|
|
empty($post['gender']) && $this->error(__('请选择性别'));
|
|
|
empty($post['body_info']) && $this->error(__('请选择身体信息'));
|
|
|
if ((new UserSize)->add($user, $post)) {
|
|
|
$this->success(__('添加成功'));
|
|
|
}
|
|
|
$this->error(__('添加失败'));
|
...
|
...
|
@@ -353,7 +445,7 @@ class User extends Api |
|
|
* 我的尺寸-详情
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="size_id", type="integer", required=true, description="尺寸ID")
|
|
|
* @ApiParams (name="user_size_id", type="integer", required=true, description="尺寸ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -365,8 +457,8 @@ class User extends Api |
|
|
public function sizeDetail()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$size_id = $this->request->request('size_id');
|
|
|
$detail = UserSize::detail($user['id'],$size_id);
|
|
|
$user_size_id = $this->request->request('user_size_id');
|
|
|
$detail = UserSize::detail($user['id'],$user_size_id);
|
|
|
$this->success(__('成功'),compact('detail'));
|
|
|
}
|
|
|
|
...
|
...
|
@@ -374,7 +466,7 @@ class User extends Api |
|
|
* 我的尺寸-编辑
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="size_id", type="integer", required=true, description="尺寸ID")
|
|
|
* @ApiParams (name="user_size_id", type="integer", required=true, description="尺寸ID")
|
|
|
* @ApiParams (name="name", type="string", required=true, description="尺寸名称")
|
|
|
* @ApiParams (name="height", type="integer", required=true, description="身高(厘米)")
|
|
|
* @ApiParams (name="weight", type="integer", required=true, description="体重(公斤)")
|
...
|
...
|
@@ -385,7 +477,7 @@ class User extends Api |
|
|
* @ApiParams (name="shoulder_width", type="integer", description="肩宽(厘米)")
|
|
|
* @ApiParams (name="gender", type="string", required=true, description="性别:1=男,2=女")
|
|
|
* @ApiParams (name="body_info", type="object", required=true, description="身体信息")
|
|
|
* @ApiParams (name="body_features", type="set", description="身体特征:1=脖子粗,2=手臂特别长,3=肩膀特别宽,多个值用英文逗号分隔")
|
|
|
* @ApiParams (name="body_features", type="string", description="身体特征,多个值用英文逗号分隔")
|
|
|
* @ApiParams (name="remark", type="string", description="备注")
|
|
|
* @ApiParams (name="body_images", type="file", description="身材照片,多文件")
|
|
|
* @ApiParams (name="isdefault", type="string", description="是否默认:0=否,1=是")
|
...
|
...
|
@@ -401,15 +493,15 @@ class User extends Api |
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$post = $this->request->request();
|
|
|
$model = UserSize::detail($user['id'], $post['size_id']);
|
|
|
$model = UserSize::detail($user['id'], $post['user_size_id']);
|
|
|
if(empty($model)){
|
|
|
$this->error(__('尺寸信息不存在'));
|
|
|
}
|
|
|
!empty($post['name']) && $this->error(__('请填写尺寸名称'));
|
|
|
!empty($post['height']) && $this->error(__('请填写身高'));
|
|
|
!empty($post['weight']) && $this->error(__('请填写体重'));
|
|
|
!empty($post['gender']) && $this->error(__('请选择性别'));
|
|
|
!empty($post['body_info']) && $this->error(__('请选择身体信息'));
|
|
|
empty($post['name']) && $this->error(__('请填写尺寸名称'));
|
|
|
empty($post['height']) && $this->error(__('请填写身高'));
|
|
|
empty($post['weight']) && $this->error(__('请填写体重'));
|
|
|
empty($post['gender']) && $this->error(__('请选择性别'));
|
|
|
empty($post['body_info']) && $this->error(__('请选择身体信息'));
|
|
|
if ($model->edit($post)) {
|
|
|
$this->success(__('更新成功'));
|
|
|
}
|
...
|
...
|
@@ -420,7 +512,7 @@ class User extends Api |
|
|
* 我的尺寸-删除
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="size_id", type="integer", required=true, description="尺寸ID")
|
|
|
* @ApiParams (name="user_size_id", type="integer", required=true, description="尺寸ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -432,8 +524,8 @@ class User extends Api |
|
|
public function sizeDelete()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$size_id = $this->request->request('size_id');
|
|
|
$model = UserSize::detail($user['id'], $size_id);
|
|
|
$user_size_id = $this->request->request('user_size_id');
|
|
|
$model = UserSize::detail($user['id'], $user_size_id);
|
|
|
if ($model->remove($user)) {
|
|
|
$this->success(__('删除成功'));
|
|
|
}
|
...
|
...
|
@@ -441,8 +533,10 @@ class User extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的尺寸-量体教程
|
|
|
* 我的尺寸-设为默认
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="user_size_id", type="integer", required=true, description="尺寸ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -451,16 +545,20 @@ class User extends Api |
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function measure()
|
|
|
public function sizeDefault()
|
|
|
{
|
|
|
$measure = config('site.measure');
|
|
|
$this->success(__('成功'),compact('measure'));
|
|
|
$user = $this->auth->getUser();
|
|
|
$user_size_id = $this->request->request('user_size_id');
|
|
|
$model = UserSize::detail($user['id'], $user_size_id);
|
|
|
if ($model->setDefault()) {
|
|
|
$this->success(__('设置成功'));
|
|
|
}
|
|
|
$this->error(__('设置失败'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 身体信息
|
|
|
* 我的尺寸-量体教程
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiParams (name="gender", type="string", required=true, description="性别:1=男,2=女")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -469,10 +567,9 @@ class User extends Api |
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function bodyInfo()
|
|
|
public function measure()
|
|
|
{
|
|
|
$gender = $this->request->request('gender','1');
|
|
|
$list = \app\common\model\Spec::bodyInfo($gender);
|
|
|
$this->success(__('成功'),compact('list'));
|
|
|
$measure = str_replace('src="/uploads/', 'src="'.config('upload.cdnurl').'/uploads/', config('site.measure'));
|
|
|
$this->success(__('成功'),compact('measure'));
|
|
|
}
|
|
|
} |
...
|
...
|
|