交友换麦优化

This commit is contained in:
2025-09-15 16:11:38 +08:00
parent 952350c4ea
commit d997efe73a
2 changed files with 113 additions and 99 deletions

View File

@@ -2619,11 +2619,13 @@ class Room extends Model
if($room_id == '' || $user_id == ''){
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
}
$clear_time = db::name('vs_room_user_charm')->where(['room_id' => $room_id, 'user_id' => $user_id])->order('id', 'desc')->value('clear_time') ?? 0;
$clear_time = db::name('vs_room_user_charm')->where(['room_id' => $room_id, 'user_id' => $user_id])
->order('id', 'desc')->value('clear_time') ?? 0;
$list = db::name('vs_give_gift')->alias('a')
->join('user b', 'a.user_id=b.id')
->field('a.user_id,sum(a.total_price) as total_price,b.nickname,b.avatar,b.user_code')
->where(['a.from_id' => $room_id, 'a.gift_user' => $user_id, 'a.createtime' => ['>',$clear_time],'a.from' => 2])->group('a.user_id')->select();
->where(['a.from_id' => $room_id, 'a.gift_user' => $user_id, 'a.createtime' => ['>',$clear_time],'a.from' => 2])
->group('a.user_id')->select();
if($list){
foreach ($list as &$v){
$v['charm'] = $v['total_price'] * get_system_config_value('coin_charm_exp');