工会流水计算
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;
|
||||
}
|
||||
|
||||
@@ -645,9 +645,15 @@ class Guild extends Model
|
||||
$ss = 0;
|
||||
if($total_transaction){
|
||||
//根据工会流水 获取补贴比例 单位%
|
||||
$subsidy_config = db::name('vs_guild_subsidy_config')->where('end_amount >= '. $total_transaction)
|
||||
->where('end_amount > '. $total_transaction)->value('subsidy_ratio');
|
||||
$ss = round($total_transaction * ($subsidy_config / 100),2) ;
|
||||
//获取补贴配置
|
||||
$config = db::name('vs_guild_subsidy_config')->where(['status' => 1])->order('end_amount desc')->select(); //配置查询
|
||||
foreach ($config as $k => $v) {
|
||||
if ($total_transaction >= $v['end_amount']) {
|
||||
$subsidy_ratio = $v['subsidy_ratio'];
|
||||
$ss = ($total_transaction * ($subsidy_ratio / 100)) / get_system_config_value('rmb_coin_ratio');//转为钻石
|
||||
break; // 找到匹配项后提前退出循环
|
||||
}
|
||||
}
|
||||
}
|
||||
//待开发
|
||||
$data['list'][1]['name'] = "本周流水";
|
||||
@@ -790,19 +796,18 @@ class Guild extends Model
|
||||
$room_data = [];
|
||||
$i=0;
|
||||
foreach ($list as $k=>$v){
|
||||
$add_guild_time = $v['createtime'];
|
||||
if(!$start_time){
|
||||
$start_time = $add_guild_time;
|
||||
$end_time = time();
|
||||
} else{
|
||||
$start_time = $start_time;
|
||||
$end_time = strtotime($end_time." 23:59:59");
|
||||
$start_time_seach = $value['createtime'];
|
||||
$end_time_seach = time();
|
||||
}else{
|
||||
$start_time_seach = strtotime($start_time." 00:00:00");
|
||||
$end_time_seach = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($v['createtime'] && $start_time_all < $v['createtime']){
|
||||
$start_time = $v['createtime'];
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_seach = $value['createtime'];
|
||||
}
|
||||
if($v['quit_time'] && ($end_time_all > $v['quit_time'])){
|
||||
$start_time = $v['quit_time'];
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_seach = $value['quit_time'];
|
||||
}
|
||||
$room_info = db::name('vs_room')->where(['id'=>$v['room_id'],'room_status'=>1,'delete_time'=>0])->find();
|
||||
if($room_info){
|
||||
@@ -812,7 +817,7 @@ class Guild extends Model
|
||||
$room_data[$i]['room_cover'] = localpath_to_netpath($room_info['room_cover']);
|
||||
$room_data[$i]['total_price'] = db::name('vs_give_gift')
|
||||
->where('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time, $end_time]]])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_seach, $end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user