add 新增查看礼物详情列表

fix 调整礼物金额
This commit is contained in:
zlzw 2024-11-29 17:56:02 +08:00
parent e4e5696b70
commit e450964cd8
10 changed files with 205 additions and 36 deletions

31
Web/html/body/config.html Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>系统设置</title>
<link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body>
<div id="header"></div>
不想做了,鸽
</body>
<script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script>
<script src="/js/httpUtils.js"></script>
<script src="/layui/layui.js"></script>
<script>
headerModel = 5;
$('#header').load("/html/header.html");
</script>
<script>
</script>
<style>
</style>
</html>

View File

@ -222,7 +222,7 @@
}); });
} }
}); });
</script> </script>

View File

@ -249,38 +249,60 @@
var lables = []; var lables = [];
var values = []; var values = [];
data.data.guardInfo.forEach(item => { data.data.guardInfo.forEach(item => {
lables.push(item.gift_name + "\n" + item.total_price / 100 + "¥") lables.push(item.gift_name + "\n" + item.total_price + "¥")
values.push(item.total_num) values.push(item.total_num)
}); });
data.data.giftInfo.forEach(item => { data.data.giftInfo.forEach(item => {
lables.push(item.gift_name + "\n" + item.total_price / 100 + "¥") lables.push(item.gift_name + "\n" + item.total_price + "¥")
values.push(item.total_gift_num) values.push(item.total_gift_num)
}); });
if (chartView !== null) { setChart(lables, values, data)
chartView.destroy()
}
chartView = new Chart($('#giftChart').get(0), {
type: 'pie',
data: {
labels: lables,
datasets: [{
label: '礼物(总额:' + data.data.price / 100 + "¥)",
data: values,
borderWidth: 1
}
]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
}) })
} }
function setChart(lables, values, data) {
if (chartView !== null) {
chartView.destroy()
}
chartView = new Chart($('#giftChart').get(0), {
type: 'pie',
data: {
labels: lables,
datasets: [{
label: '礼物(总额:' + data.data.price + "¥)",
data: values,
borderWidth: 1
}
]
},
options: {
scales: {
y: {
beginAtZero: true
}
},
onClick: (e) => {
var giftName=e.chart.tooltip.title[0]
console.log(e.chart.tooltip.title)
layer.open({
type: 2, // page 层类型
area: ['650px', '400px'],
title: '礼物详情',
shade: 0.6, // 遮罩透明度
shadeClose: false, // 点击遮罩区域,关闭弹层
maxmin: true, // 允许全屏最小化
anim: 1, // 0-6 的动画形式,-1 不开启
// btn: ['确定', '取消'],
content: '/html/ui/videoGiftItem.html?roomId=' + roomId + "&videoId=" + videoId + "&giftName=" + giftName,
yes: function (index, layero) {
}
});
}
}
});
}
function initMenu(data) { function initMenu(data) {
var view = $("#menuView").get(0); var view = $("#menuView").get(0);
laytpl($('#menulist').get(0).innerHTML).render(data, function (html) { laytpl($('#menulist').get(0).innerHTML).render(data, function (html) {
@ -345,11 +367,11 @@
initSC(data.data.superChat) initSC(data.data.superChat)
$('#danmuSize').get(0).innerHTML = data.data.danmuCount; $('#danmuSize').get(0).innerHTML = data.data.danmuCount;
barrageRenderer.setBarrages(data.data.danmu) barrageRenderer.setBarrages(data.data.danmu)
}else{ } else {
barrageRenderer.barrageLayoutCalculate.allBarrageInstances.push(...data.data.danmu); barrageRenderer.barrageLayoutCalculate.allBarrageInstances.push(...data.data.danmu);
} }
if(data.data.nextDanmu){ if (data.data.nextDanmu) {
loadDanmu(page+1) loadDanmu(page + 1)
} }
// barrageRenderer.setBarrages(data.data.danmu); // barrageRenderer.setBarrages(data.data.danmu);
}) })

View File

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="/layui/css/layui.css">
</head>
<table class="layui-hide" id="giftList" lay-filter="followTable"></table>
<body>
</body>
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script>
<script src="/js/httpUtils.js"></script>
<script>
var roomId = getParam("roomId");
var videoId = getParam("videoId");
var giftName = getParam("giftName");
layui.use(function () {
var laytpl = layui.laytpl;
var table = layui.table;
table.render({
elem: '#giftList',
url: '/live/gift/info/item?roomId=' + roomId + "&videoId=" + videoId + "&giftName=" + giftName,
height: 'full',
totalRow: false, // 开启合计行
page: false,
response: {
statusCode: 100 // 重新规定成功的状态码为 200table 组件默认为 0
},
parseData: function (res) {
return {
"code": res.status, //解析接口状态
"msg": res.message, //解析提示文本
"data": res.data, //解析数据列表
"count": res.count
};
},
cols: [[
{ type: 'checkbox', fixed: 'left' },
{ field: 'icon', title: '礼物', width: 80, templet: '<div><image src="" onerror="showImage(\'{{= d.icon }}\',this);" style="width: 30px;height: 30px;"></div>' },
{ field: 'gift_id', title: '礼物ID', width: 80, sort: true },
{ field: 'sender_name', title: '用户名', width: 150, sort: true, templet: '<div><a href="https://space.bilibili.com/{{= d.sender_uid}}" target="_blank">{{= d.sender_name}}</a>' },
{ field: 'sender_face', title: '用户头像', width: 80, templet: '<div><image src="" onerror="showImage(\'{{= d.sender_face }}\',this);" style="width: 30px;height: 30px;"></div>' },
{ field: 'gift_num', title: '数量', width: 80, sort: true },
{ field: 'price', title: '价值(电池)', width: 80, sort: true },
{ field: 'sql_time', title: '时间', width: 180 }
]],
done: function () {
onDone()
},
error: function (res, msg) {
console.log(res, msg)
}
});
function onDone() {
}
})
</script>

View File

@ -12,7 +12,7 @@ public class LiveGiftDatabaseBean extends AbsDatabasesBean {
@JSONField(name = "id") @JSONField(name = "id")
int id; int id;
@JSONField(name = "gift_id") @JSONField(name = "gift_id")
private int giftId; private long giftId;
@JSONField(name = "gift_name") @JSONField(name = "gift_name")
private String giftName; private String giftName;
@JSONField(name = "price") @JSONField(name = "price")
@ -22,9 +22,9 @@ public class LiveGiftDatabaseBean extends AbsDatabasesBean {
@JSONField(name = "icon") @JSONField(name = "icon")
private String icon; private String icon;
@JSONField(name = "gift_num") @JSONField(name = "gift_num")
private int giftNum; private long giftNum;
@JSONField(name = "sender_uid") @JSONField(name = "sender_uid")
private long senderUid; private String senderUid;
@JSONField(name = "sender_name") @JSONField(name = "sender_name")
private String senderName; private String senderName;
@JSONField(name = "sender_face") @JSONField(name = "sender_face")

View File

@ -182,7 +182,7 @@ public class WSSendGift extends WSData {
@JSONField(name = "base") @JSONField(name = "base")
private Base base; private Base base;
@JSONField(name = "uid") @JSONField(name = "uid")
private long uid; private String uid;
} }
@lombok.Data @lombok.Data

View File

@ -125,7 +125,7 @@ public class BiliLiveDatabase extends SQLiteManager {
"SUM(`gift_num`) AS `total_gift_num`," + "SUM(`gift_num`) AS `total_gift_num`," +
"CASE " + "CASE " +
"WHEN `coin_type` = 'silver' THEN 0 " + "WHEN `coin_type` = 'silver' THEN 0 " +
"ELSE SUM(`price` * `gift_num`) " + "ELSE SUM(`price` / 100 * `gift_num`) " +
"END AS `total_price`" + "END AS `total_price`" +
"FROM " + "FROM " +
"`gift` " + "`gift` " +
@ -144,7 +144,7 @@ public class BiliLiveDatabase extends SQLiteManager {
"filtered_gifts " + "filtered_gifts " +
"GROUP BY " + "GROUP BY " +
"`gift_name`, `icon`;"; "`gift_name`, `icon`;";
String guardSql = "SELECT `gift_name`, SUM(`num`) AS `total_num`,SUM(`price`*`num`) as `total_price`" + String guardSql = "SELECT `gift_name`, SUM(`num`) AS `total_num`,SUM(`price` /100 *`num`) as `total_price`" +
"FROM `guardBuy` where `sql_time` >= '" + startTimeLong + "' and `sql_time` <= '" + endTimeLong + "'" + "FROM `guardBuy` where `sql_time` >= '" + startTimeLong + "' and `sql_time` <= '" + endTimeLong + "'" +
"GROUP BY `gift_name`;"; "GROUP BY `gift_name`;";
String superChatSql = "SELECT SUM(`price`*100) as `total_price`, count(`price`) as `total_count`" + String superChatSql = "SELECT SUM(`price`*100) as `total_price`, count(`price`) as `total_count`" +
@ -233,6 +233,11 @@ public class BiliLiveDatabase extends SQLiteManager {
return super.get(tableName, where, clazz); return super.get(tableName, where, clazz);
} }
@Override
public <T extends AbsDatabasesBean> List<T> get(String table, String where, Class<T> tClass) {
return super.get(table, where, tClass);
}
@Override @Override
public int getCount(String table) { public int getCount(String table) {
return super.getCount(table); return super.getCount(table);

View File

@ -49,7 +49,12 @@ public class LiveController {
@RequestMapping("/live/gift/info") @RequestMapping("/live/gift/info")
@ResponseBody @ResponseBody
public JSONObject download(String roomId, String videoId) { public JSONObject info(String roomId, String videoId) {
return ResultData.success(liveService.getGiftInfo(roomId, videoId)); return ResultData.success(liveService.getGiftInfo(roomId, videoId));
} }
@RequestMapping("/live/gift/info/item")
@ResponseBody
public JSONObject infoItem(String roomId,String videoId,String giftName) {
return ResultData.success(liveService.getGiftItemInfo(roomId, videoId, giftName));
}
} }

View File

@ -58,7 +58,7 @@ public class VideoFileController {
try { try {
length = new URL(url).openConnection().getContentLength(); length = new URL(url).openConnection().getContentLength();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); return Tools.getFile(new File("Web"+ File.separator+"assets"+File.separator+"def.png"));
} }
if (img.exists()&&length==img.length()) { if (img.exists()&&length==img.length()) {
return Tools.getFile(img); return Tools.getFile(img);

View File

@ -5,11 +5,14 @@ import com.alibaba.fastjson2.JSONObject;
import com.yutou.biliapi.api.LiveApi; import com.yutou.biliapi.api.LiveApi;
import com.yutou.biliapi.bean.live.LiveAnchorInfo; import com.yutou.biliapi.bean.live.LiveAnchorInfo;
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean; import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
import com.yutou.biliapi.bean.live.database.LiveGiftDatabaseBean;
import com.yutou.biliapi.bean.live.database.LiveGuardBuyBean;
import com.yutou.biliapi.bean.live.database.LiveVideoDatabaseBean; import com.yutou.biliapi.bean.live.database.LiveVideoDatabaseBean;
import com.yutou.biliapi.databases.BiliLiveDatabase; import com.yutou.biliapi.databases.BiliLiveDatabase;
import com.yutou.biliapi.net.BiliLiveNetApiManager; import com.yutou.biliapi.net.BiliLiveNetApiManager;
import com.yutou.bilibili.Tools.DateFormatUtils; import com.yutou.bilibili.Tools.DateFormatUtils;
import com.yutou.bilibili.datas.web.LiveData; import com.yutou.bilibili.datas.web.LiveData;
import com.yutou.common.databases.AbsDatabasesBean;
import com.yutou.common.okhttp.HttpLoggingInterceptor; import com.yutou.common.okhttp.HttpLoggingInterceptor;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -111,6 +114,41 @@ public class LiveService {
return database.getGiftInfo(startTime, endTime); return database.getGiftInfo(startTime, endTime);
} }
public JSONArray getGiftItemInfo(String roomId, String videoId, String giftName) {
BiliLiveDatabase database = databasesService.getLiveDatabase(roomId);
LiveVideoDatabaseBean videoBean = database.getVideo(videoId);
if (videoBean == null) {
return new JSONArray();
}
long startTime = videoBean.getStartTime().getTime();
long endTime = videoBean.getStopTime() == null ? System.currentTimeMillis() : videoBean.getStopTime().getTime();
String where = " `sql_time` >= " + "\"" + startTime + "\"" +
" and " + " `sql_time` <= " + "\"" + endTime + "\"" +
" and " + " `gift_name` = " + "\"" + giftName + "\"";
List<LiveGiftDatabaseBean> list = database.get(new LiveGiftDatabaseBean().getTableName(), where, LiveGiftDatabaseBean.class);
List<LiveGuardBuyBean> list2 = database.get(new LiveGuardBuyBean().getTableName(), where, LiveGuardBuyBean.class);
JSONArray array = new JSONArray();
array.addAll(list);
array.addAll(
list2.stream().map(it->{
LiveGiftDatabaseBean tmp=new LiveGiftDatabaseBean();
tmp.setGiftId(it.getGiftID());
tmp.setGiftName(it.getGiftName());
tmp.setGiftNum(it.getNum());
tmp.setPrice(it.getPrice());
tmp.setIcon("/assets/def.png");
tmp.setSenderUid(it.getUid());
tmp.setSenderName(it.getUsername());
tmp.setSenderFace("/assets/def.png");
tmp.setSql_time(it.getSql_time());
return tmp;
}).toList()
);
return array;
}
public static void main(String[] args) { public static void main(String[] args) {
HttpLoggingInterceptor.setLog(true); HttpLoggingInterceptor.setLog(true);
LiveService service = new LiveService(); LiveService service = new LiveService();