工会流水计算
This commit is contained in:
@@ -95,36 +95,26 @@ class Guild extends Model
|
||||
*工会当日流水
|
||||
*/
|
||||
public function getTodayMoney($guild_id,$stoday="",$etoday=""){
|
||||
$where = [];
|
||||
if(empty($stoday) && empty($etoday)){
|
||||
$stoday = strtotime(date('Y-m-d 00:00:00'));
|
||||
$etoday = strtotime(date('Y-m-d 23:59:59'));
|
||||
$where['createtime'] = ['between', [$stoday, $etoday]];
|
||||
}else{
|
||||
if(!empty($stoday)){
|
||||
$where['createtime'] = ['>=', strtotime($stoday."00:00:00")];
|
||||
}
|
||||
if(!empty($etoday)){
|
||||
$where['createtime'] = ['<=', strtotime($etoday." 23:59:59")];
|
||||
}
|
||||
if(!empty($stoday) && !empty($etoday)){
|
||||
$where['createtime'] = ['between', [strtotime($stoday." 00:00:00"), strtotime($etoday." 23:59:59")]];
|
||||
}
|
||||
}
|
||||
|
||||
//获取所有工会房间ID
|
||||
$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(empty($stoday) && empty($etoday)){
|
||||
$stoday_seach = strtotime(date('Y-m-d 00:00:00',time()));
|
||||
$etoday_seach = strtotime(date('Y-m-d 23:59:59',time()));
|
||||
}else{
|
||||
$stoday_seach = strtotime($stoday);
|
||||
$etoday_seach = strtotime($etoday);
|
||||
}
|
||||
if($v['createtime'] && $stoday_seach < $v['createtime']){
|
||||
$stoday_seach = $v['createtime'];
|
||||
}
|
||||
if($v['quit_time'] && ($etoday > $v['quit_time'])){
|
||||
$etoday = $v['quit_time'];
|
||||
$etoday_seach = $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]]])
|
||||
->where('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$stoday_seach, $etoday_seach]]])
|
||||
->sum('total_price');
|
||||
$transaction += $transaction_one;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user