作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

个人中心-我的活动

... ... @@ -284,7 +284,6 @@ class House extends Api
*/
public function house_list()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->auth->id;
$area = $this->request->param('area');
$keyword = $this->request->param('keyword');
... ...
... ... @@ -259,7 +259,6 @@ class HouseBoard extends Api
"msg": "成功",
"time": "1571492001",
"data": {
"id"://id
"user_id"://用户id
"avatar"://管理员头像
"nickname"://昵称
... ... @@ -279,7 +278,7 @@ class HouseBoard extends Api
->alias('a')
->join('user b','a.user_id = b.id')
->where('a.house_id',$house_id)
->field('a.id,a.user_id,b.avatar,b.nickname')
->field('a.user_id,b.avatar,b.nickname')
->order('a.is_direct')
->select();
foreach ($data as &$v){
... ... @@ -330,7 +329,6 @@ class HouseBoard extends Api
*/
public function chat_record()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->auth->id; //当前登录用户id
$house_id = $this->request->param('house_id'); //社区id
$wuye_user_id = $this->request->param('user_id'); //物业用户id
... ... @@ -352,7 +350,7 @@ class HouseBoard extends Api
foreach ($data as &$v){
$v['is_right'] = 1;
if($v['type'] == 2){
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
}
}
$arr = Db::name('message')
... ... @@ -364,7 +362,7 @@ class HouseBoard extends Api
foreach ($arr as &$v){
$v['is_right'] = 2;
if($v['type'] == 2){
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
}
}
... ... @@ -395,7 +393,7 @@ class HouseBoard extends Api
{
"id": // 活动id
"title": // 活动标题
"spec_type": // 活动规格:0=无规格(免费),1=单规格,2=多规格
"spec_type": // 活动规格:0=无规格,免费,1=单规格,2=多规格
"content": // 活动描述
"activity_time": 活动日期
"price": // 报名费用
... ... @@ -431,7 +429,7 @@ class HouseBoard extends Api
"data": {
"id": // 活动id
"title": // 活动标题
"spec_type": // 活动规格:0=无规格(免费),1=单规格,2=多规格
"spec_type": // 活动规格:0=无规格,免费,1=单规格,2=多规格
"content": // 活动描述
"activity_time": 活动日期
"price": // 报名费用
... ...
... ... @@ -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();
}
... ...
<?php
namespace app\api\model;
class HouseJoin extends Base
{
}
\ No newline at end of file
... ...
<?php
namespace app\api\model;
class Message extends Base
{
}
\ No newline at end of file
... ...