礼物墙
This commit is contained in:
@@ -82,6 +82,16 @@ class User extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//礼物墙用户列表
|
||||
public function gift_wall_user_list()
|
||||
{
|
||||
$uid = input('user_id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$reslut = model('User')->gift_wall_user_list($uid,$gift_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//相册列表
|
||||
public function get_album_list()
|
||||
{
|
||||
|
||||
@@ -421,19 +421,47 @@ class GiveGift extends Model
|
||||
|
||||
//使用收礼用户 和礼物ID 查询礼物墙
|
||||
$gift_wall = db::name('user_gift_wall')->where(['user_id'=>$to_id,'gift_id'=>$gid])->find();
|
||||
if($gift_wall){
|
||||
db::name('user_gift_wall')->where(['id'=>$gift_wall['id']])->inc('count',$num)->update();
|
||||
$userIds = explode(',',$gift_wall['give_user_ids']);
|
||||
if(!in_array($uid,$userIds)){
|
||||
$userIds[] = $uid;
|
||||
db::name('user_gift_wall')->where(['id'=>$gift_wall['id']])->update(['give_user_ids'=>implode(',',$userIds)]);
|
||||
if($gift_wall){//更新
|
||||
//往期送礼用户
|
||||
$users = json_decode($gift_wall['give_user_ids'], true);
|
||||
if($users){
|
||||
$ture = false;
|
||||
foreach ($users as $user_id){
|
||||
if($user_id['user_id'] == $uid){
|
||||
$user_id['count'] += $num;
|
||||
$ture = true;
|
||||
}
|
||||
}
|
||||
if(!$ture){
|
||||
$users[] = [
|
||||
'user_id' => $uid,
|
||||
'count' => $num
|
||||
];
|
||||
}
|
||||
$users_list = json_encode($users);
|
||||
db::name('user_gift_wall')->where(['id'=>$gift_wall['id']])
|
||||
->update(['give_user_ids'=>$users_list,'updatetime' => time(),'count' => $gift_wall['count'] + $num]);
|
||||
}else{
|
||||
$users[] = [
|
||||
'user_id' => $uid,
|
||||
'count' => $num
|
||||
];
|
||||
$users_list = json_encode($users);
|
||||
db::name('user_gift_wall')->where(['id'=>$gift_wall['id']])
|
||||
->update(['give_user_ids'=>$users_list,'updatetime' => time(),'count' => $num]);
|
||||
}
|
||||
}else{
|
||||
|
||||
}else{//新增
|
||||
$users[] = [
|
||||
'user_id' => $uid,
|
||||
'count' => $num
|
||||
];
|
||||
$users_list = json_encode($users);
|
||||
db::name('user_gift_wall')->insert([
|
||||
'user_id' => $to_id,
|
||||
'gift_id' => $gid,
|
||||
'count' => $num,
|
||||
'give_user_ids' => $uid,
|
||||
'give_user_ids' => $users_list,
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -518,6 +518,26 @@ class User extends Model
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $redata];
|
||||
}
|
||||
|
||||
|
||||
//礼物墙用户列表
|
||||
public function gift_wall_user_list($uid, $gift_id){
|
||||
$result = db::name('user_gift_wall')
|
||||
->where(['user_id' => $uid,'gift_id' => $gift_id])
|
||||
->value('give_user_ids');
|
||||
$user = [];
|
||||
$count = 0;
|
||||
if($result){
|
||||
$user_list = json_decode($result, true);
|
||||
foreach ($user_list as $user_id){
|
||||
$user[] = db::name('user')->where(['id' => $user_id['user_id']])->field('id user_id,nickname,avatar')->find();
|
||||
$user[]['count'] = $user_id['count'];
|
||||
$count += $user_id['count'];
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['count' => $count, 'users' =>$user]];
|
||||
}
|
||||
|
||||
|
||||
//添加用户访问记录
|
||||
/*
|
||||
* @param $to_id 被访问对象id
|
||||
|
||||
@@ -297,7 +297,7 @@ class PerformPerSecond
|
||||
->where('end_time', '<', $now)
|
||||
->where('left_count', '>', 0)
|
||||
->select();
|
||||
|
||||
$processedCounts = 0;
|
||||
foreach ($expiredRedpackets as $redpacket) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
@@ -320,28 +320,29 @@ class PerformPerSecond
|
||||
}
|
||||
}
|
||||
|
||||
// 更新红包状态为已结束
|
||||
// 更新红包状态为已退款
|
||||
Db::name('redpacket')
|
||||
->where('id', $redpacket['id'])
|
||||
->update([
|
||||
'status' => Redpacket::STATUS_FINISHED,
|
||||
'status' => Redpacket::STATUS_REFUNDED,
|
||||
'updatetime' => $now
|
||||
]);
|
||||
|
||||
// 更新Redis缓存
|
||||
// 清理Redis缓存
|
||||
$redis = Cache::store('redis')->handler();
|
||||
$redisKey = "redpacket:{$redpacket['id']}";
|
||||
$redis->hSet($redisKey, 'status', Redpacket::STATUS_FINISHED);
|
||||
$redis->del($redisKey);
|
||||
|
||||
Db::commit();
|
||||
$processedCount++;
|
||||
$processedCounts++;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
// 记录日志
|
||||
\think\Log::error("红包退款失败: {$redpacket['id']}, 错误: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
echo "处理过期红包-共". $processedCount . "条数据\n";
|
||||
echo "处理过期红包-共". $processedCounts . "条数据\n";
|
||||
echo "处理未开始红包-共". $processedCount . "条数据\n";
|
||||
}
|
||||
|
||||
//签约房时间结束处理和签约到期处理
|
||||
|
||||
Reference in New Issue
Block a user