工会流水计算
This commit is contained in:
@@ -113,13 +113,21 @@ class Guild extends Model
|
||||
}
|
||||
|
||||
//获取所有工会房间ID
|
||||
$room_ids = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id')->select();
|
||||
$room_ids = array_column($room_ids, 'room_id');
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$room_ids)
|
||||
->where(['from'=>['in',[2,3,6]]])
|
||||
->where($where)
|
||||
->sum('total_price');
|
||||
$guild_user_data = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id,createtime,quit_time')->select();
|
||||
$transaction = 0;
|
||||
foreach ($guild_user_data as $k => $v) {
|
||||
if($v['createtime'] && $stoday < $v['createtime']){
|
||||
$stoday = $v['createtime'];
|
||||
}
|
||||
if($v['quit_time'] && ($etoday > $v['quit_time'])){
|
||||
$etoday = $v['quit_time'];
|
||||
}
|
||||
$transaction_one = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$stoday, $etoday]]])
|
||||
->sum('total_price');
|
||||
$transaction += $transaction_one;
|
||||
}
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user