...
|
...
|
@@ -7,6 +7,8 @@ use app\common\library\Ems; |
|
|
use app\common\library\Sms;
|
|
|
use fast\Random;
|
|
|
use think\Validate;
|
|
|
use think\Cache;
|
|
|
use app\api\model\HouseJoin;
|
|
|
|
|
|
/**
|
|
|
* 会员接口
|
...
|
...
|
@@ -83,24 +85,22 @@ class User extends Api |
|
|
* @ApiReturn ({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1598664523",
|
|
|
"time": "1598667600",
|
|
|
"data": {
|
|
|
"user": {
|
|
|
"id": 2, //用户ID
|
|
|
"username": "何先生", //用户名
|
|
|
"nickname": "何先生", //昵称
|
|
|
"avatar": "http://cloud.caiyunpan.brotop.cn/assets/img/avatar.png", //头像
|
|
|
"money": "0.00", //钱包余额
|
|
|
"house_id": 17, //当前小区ID
|
|
|
"id_num": "100001", //ID
|
|
|
"url": "/u/2",
|
|
|
"today_money": 10, //今日收益
|
|
|
"total_money": 10 //总收益
|
|
|
},
|
|
|
"house": { //当前小区信息
|
|
|
"id": 2, //用户ID
|
|
|
"username": "何先生", //用户名
|
|
|
"nickname": "何先生", //昵称
|
|
|
"avatar": "http://cloud.caiyunpan.brotop.cn/assets/img/avatar.png", //头像
|
|
|
"money": "0.00", //余额
|
|
|
"id_num": "100001", //ID
|
|
|
"url": "/u/2",
|
|
|
"house": { //小区信息
|
|
|
"id": 17, //小区ID
|
|
|
"name": "碧海花园小区" //小区名称
|
|
|
}
|
|
|
},
|
|
|
"today_money": 10, //今日收益
|
|
|
"total_money": 10, //总收益
|
|
|
"message_num": 0 //未读消息数量
|
|
|
}
|
|
|
})
|
|
|
*/
|
...
|
...
|
@@ -108,29 +108,98 @@ class User extends Api |
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$store_inform_log = new \app\api\model\StoreInformLog;
|
|
|
// 今日收益
|
|
|
$user['today_money'] = $store_inform_log
|
|
|
->where('user_id',$this->auth->id)
|
|
|
->whereTime('createtime', 'today')
|
|
|
->sum('money');
|
|
|
// 总收益
|
|
|
$user['total_money'] = $store_inform_log
|
|
|
->where('user_id',$this->auth->id)
|
|
|
->sum('money');
|
|
|
$data = [
|
|
|
// 当前小区信息
|
|
|
'house' => \app\api\model\House::get($user['house_id'])
|
|
|
->visible(['id','name'])->toArray(),
|
|
|
// 今日收益
|
|
|
'today_money' => $store_inform_log
|
|
|
->where('user_id',$this->auth->id)
|
|
|
->whereTime('createtime', 'today')
|
|
|
->sum('money'),
|
|
|
// 总收益
|
|
|
'total_money' => $store_inform_log
|
|
|
->where('user_id',$this->auth->id)
|
|
|
->sum('money'),
|
|
|
// 未读消息数量
|
|
|
'message_num' => \app\api\model\Message::where('to_user_id',$user['id'])
|
|
|
->where('is_read',2)
|
|
|
->count()
|
|
|
];
|
|
|
$user = $user->visible([
|
|
|
'id',
|
|
|
'username',
|
|
|
'nickname',
|
|
|
'avatar',
|
|
|
'id_num',
|
|
|
'house_id',
|
|
|
'money'
|
|
|
])->append([
|
|
|
'today_money',
|
|
|
'total_money'
|
|
|
]);
|
|
|
$house = \app\api\model\House::get($user['house_id'])->visible(['id','name']);
|
|
|
$this->success('成功', compact('user','house'));
|
|
|
])->toArray();
|
|
|
$this->success('成功', array_merge($user,$data));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (个人中心-我的活动)
|
|
|
* @ApiSummary (个人中心-我的活动)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/user/activity)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiReturn ({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1598673648",
|
|
|
"data": [{
|
|
|
"id": 20, //活动报名ID
|
|
|
"title": "澳大利亚政府这人品:我只要不承认,就不是针对中国", //活动标题
|
|
|
"content": "", //活动内容
|
|
|
"activity_time": "2020-08-28-2020-08-28" //活动时间
|
|
|
}]
|
|
|
})
|
|
|
*/
|
|
|
public function activity()
|
|
|
{
|
|
|
$list = HouseJoin::where('user_id',$this->auth->id)
|
|
|
->where('join_status','1')
|
|
|
->field('id,title,content,start_time,end_time')
|
|
|
->select();
|
|
|
foreach ($list as &$v) {
|
|
|
// 活动日期
|
|
|
$v['activity_time'] = date('Y-m-d',$v['start_time']).'-'.date('Y-m-d',$v['end_time']);
|
|
|
unset($v['start_time'],$v['end_time']);
|
|
|
}
|
|
|
$this->success('成功', $list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (个人中心-我的活动-详情)
|
|
|
* @ApiSummary (个人中心-我的活动-详情)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/user/activityInfo)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="house_join_id", type="string", required=true, description="报名ID")
|
|
|
|
|
|
* @ApiReturn ({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1598673648",
|
|
|
"data": [{
|
|
|
"id": 20, //报名ID
|
|
|
"title": "澳大利亚政府这人品:我只要不承认,就不是针对中国", //活动标题
|
|
|
"content": "", //活动内容
|
|
|
"activity_time": "2020-08-28-2020-08-28" //活动时间
|
|
|
}]
|
|
|
})
|
|
|
*/
|
|
|
public function activityInfo()
|
|
|
{
|
|
|
$house_join_id = $this->request->param('house_join_id');
|
|
|
empty($house_join_id) && $this->error('请传入必填参数');
|
|
|
$info = HouseJoin::get(['user_id'=>$this->auth->id,'id'=>$house_join_id]);
|
|
|
empty($info) && $this->error('活动信息不存在');
|
|
|
$info['activity_time'] = date('Y-m-d',$info['start_time']).'-'.date('Y-m-d',$info['end_time']);
|
|
|
$info = $info->visible([
|
|
|
'title',
|
|
|
]);
|
|
|
$this->success('成功', $info);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -246,14 +315,12 @@ class User extends Api |
|
|
* @param string $avatar 头像地址
|
|
|
* @param string $username 用户名
|
|
|
* @param string $nickname 昵称
|
|
|
* @param string $bio 个人简介
|
|
|
*/
|
|
|
public function profile()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
$username = $this->request->request('username');
|
|
|
$nickname = $this->request->request('nickname');
|
|
|
$bio = $this->request->request('bio');
|
|
|
$avatar = $this->request->request('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
if ($username) {
|
|
|
$exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find();
|
...
|
...
|
@@ -263,7 +330,6 @@ class User extends Api |
|
|
$user->username = $username;
|
|
|
}
|
|
|
$user->nickname = $nickname;
|
|
|
$user->bio = $bio;
|
|
|
$user->avatar = $avatar;
|
|
|
$user->save();
|
|
|
$this->success();
|
...
|
...
|
@@ -323,8 +389,8 @@ class User extends Api |
|
|
if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
|
|
|
$this->error(__('Mobile already exists'));
|
|
|
}
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
|
$code = Cache::get($mobile);
|
|
|
if ($code != $captcha) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
|
$verification = $user->verification;
|
...
|
...
|
@@ -333,7 +399,7 @@ class User extends Api |
|
|
$user->mobile = $mobile;
|
|
|
$user->save();
|
|
|
|
|
|
Sms::flush($mobile, 'changemobile');
|
|
|
Cache::rm($mobile);
|
|
|
$this->success();
|
|
|
}
|
|
|
|
...
|
...
|
|