房间流水统计
This commit is contained in:
@@ -481,7 +481,22 @@ class Room extends Model
|
||||
* 房间流水明细
|
||||
* 按天统计指定房间流水
|
||||
*/
|
||||
public function room_turnover_detail($room_id,$stime,$etime,$page,$page_limit) {
|
||||
public function room_turnover_detail($userId,$room_id,$stime,$etime,$page,$page_limit) {
|
||||
//查看用户和房间的关系
|
||||
$isOwner = 0;
|
||||
$isHost = 0;
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id])->value('user_id');
|
||||
if($owner != $userId){
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id ,'user_id' => $userId,'type' => 1,'deletetime' => null])->find();
|
||||
if(!$host){
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => ['total_amount' => 0, 'total_earning' => 0,'list' => null]];
|
||||
}else{
|
||||
$isHost = 1;
|
||||
}
|
||||
}else{
|
||||
$isOwner = 1;
|
||||
}
|
||||
|
||||
//如果没有传参数默认查询本月
|
||||
$stime = empty($stime) ? date('Y-m-01') : $stime;
|
||||
$etime = empty($etime) ? date('Y-m-d') : $etime;
|
||||
@@ -514,7 +529,10 @@ class Room extends Model
|
||||
$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);
|
||||
if($isOwner){
|
||||
$value['earning'] = round($value['total_price'] * $room_user_ratio / get_system_config_value('rmb_coin_ratio'), 4);
|
||||
}
|
||||
$value['earning'] = 0;
|
||||
//按日期统计
|
||||
$list_data[$value['time']][] = $value;
|
||||
}
|
||||
@@ -525,10 +543,12 @@ class Room extends Model
|
||||
$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);
|
||||
if($isOwner) {
|
||||
$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++;
|
||||
}
|
||||
|
||||
@@ -538,7 +558,14 @@ class Room extends Model
|
||||
|
||||
//房主总收益
|
||||
$coin_exchange_rate = get_system_config_value('coin_exchange_rate') ?? 1;
|
||||
$total_earning = round($total_amount * $room_user_ratio / $coin_exchange_rate, 4);
|
||||
if($isOwner) {
|
||||
$total_earning = round($total_amount * $room_user_ratio / $coin_exchange_rate, 4);
|
||||
}else{
|
||||
$total_earning = db::name('user_earnings_log')
|
||||
->where(['user_id' => $userId,'room_id' => $room_id,'change_type' => 19])
|
||||
->where('createtime', 'between', [strtotime($stime), strtotime($etime)])
|
||||
->sum('earnings');
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => ['total_amount' => $total_amount, 'total_earning' => $total_earning,'list' => $list_data_array]];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user