房间内流水详情
This commit is contained in:
@@ -482,15 +482,69 @@ class Room extends Model
|
||||
* 按天统计指定房间流水
|
||||
*/
|
||||
public function room_turnover_detail($room_id,$stime,$etime,$page,$page_limit) {
|
||||
$params['from_id'] = $room_id;
|
||||
$params['start_time'] = $stime;
|
||||
$params['end_time'] = $etime;
|
||||
$params['page'] = $page;
|
||||
$params['limit'] = $page_limit;
|
||||
$res = model('GiveGiftBases')->getGiftRecords($params);
|
||||
//如果没有传参数默认查询本月
|
||||
$stime = empty($stime) ? date('Y-m-01') : $stime;
|
||||
$etime = empty($etime) ? date('Y-m-d') : $etime;
|
||||
|
||||
var_dump($res);exit;
|
||||
$total_amount = 0;//房间总流水
|
||||
$list_data_array=[];
|
||||
$room_user_ratio = get_system_config_value('room_author_ratio')/100;//房主收益比例
|
||||
//判断开始时间是否小于2026年
|
||||
if(strtotime($stime) < strtotime('2026-01-01')){
|
||||
if(strtotime($etime) < strtotime('2026-01-01')){//结束时间是否小于2026年
|
||||
$this->room_turnover($room_id,$stime,$etime,$page,$page_limit);
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '查询时间跨步暂不支持跨年!', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
$params['from_id'] = $room_id;
|
||||
$params['start_time'] = $stime;
|
||||
$params['end_time'] = $etime;
|
||||
$params['page'] = $page;
|
||||
$params['limit'] = $page_limit;
|
||||
$res = model('GiveGiftBases')->getGiftRecords($params);
|
||||
$list = $res['data'];
|
||||
$list_data = [];
|
||||
|
||||
foreach ($list as &$value) {
|
||||
$value['time'] = date('Y-m-d', strtotime($value['createtime']));
|
||||
$value['sender_nickname'] = db::name('user')->where('id', $value['user_id'])->value('nickname');
|
||||
$value['sender_avatar'] = db::name('user')->where('id', $value['user_id'])->value('avatar');
|
||||
$value['receive_nickname'] = db::name('user')->where('id', $value['gift_user'])->value('nickname');
|
||||
$value['receive_avatar'] = db::name('user')->where('id', $value['gift_user'])->value('avatar');
|
||||
$value['gift_name'] = db::name('vs_gift')->where('gid', $value['gift_id'])->value('gift_name');
|
||||
//收益计算
|
||||
$value['earning'] = round($value['total_price'] * $room_user_ratio / get_system_config_value('rmb_coin_ratio'), 4);
|
||||
//按日期统计
|
||||
$list_data[$value['time']][] = $value;
|
||||
}
|
||||
$i=0;
|
||||
foreach($list_data as $k => $v){
|
||||
$list_data_array[$i]['total_price'] = 0;
|
||||
$list_data_array[$i]['total_earning'] = 0;
|
||||
$list_data_array[$i]['time'] = $k;
|
||||
$list_data_array[$i]['list'] = $v;
|
||||
//每日流水统计
|
||||
$day_total_price = model('api/RoomDailyIncome')->getTodayIncome($room_id, $k);
|
||||
$list_data_array[$i]['total_price'] = $day_total_price ;
|
||||
//每日收益
|
||||
$list_data_array[$i]['total_earning'] = round($day_total_price * $room_user_ratio / get_system_config_value('rmb_coin_ratio'), 4);
|
||||
$i++;
|
||||
}
|
||||
|
||||
//房间总流水(2026年以后的)
|
||||
$total_amount = model('api/RoomDailyIncome')->getIncomeByPeriod($room_id, $stime, $etime);
|
||||
}
|
||||
|
||||
//房主总收益
|
||||
$coin_exchange_rate = get_system_config_value('coin_exchange_rate') ?? 1;
|
||||
$total_earning = round($total_amount * $room_user_ratio / $coin_exchange_rate, 4);
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => ['total_amount' => $total_amount, 'total_earning' => $total_earning,'list' => $list_data_array]];
|
||||
}
|
||||
|
||||
|
||||
//房间流水2026年以前的
|
||||
public function room_turnover($room_id,$stime,$etime,$page,$page_limit) {
|
||||
$page = intval($page);
|
||||
$page_limit = $page_limit < 20 ? $page_limit : 20;
|
||||
$s_type =0;
|
||||
|
||||
Reference in New Issue
Block a user