add 新增查看礼物详情列表
fix 调整礼物金额
This commit is contained in:
parent
e4e5696b70
commit
e450964cd8
31
Web/html/body/config.html
Normal file
31
Web/html/body/config.html
Normal 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>
|
@ -222,7 +222,7 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -249,38 +249,60 @@
|
||||
var lables = [];
|
||||
var values = [];
|
||||
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)
|
||||
});
|
||||
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)
|
||||
});
|
||||
if (chartView !== null) {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
setChart(lables, values, data)
|
||||
})
|
||||
|
||||
}
|
||||
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) {
|
||||
var view = $("#menuView").get(0);
|
||||
laytpl($('#menulist').get(0).innerHTML).render(data, function (html) {
|
||||
@ -345,11 +367,11 @@
|
||||
initSC(data.data.superChat)
|
||||
$('#danmuSize').get(0).innerHTML = data.data.danmuCount;
|
||||
barrageRenderer.setBarrages(data.data.danmu)
|
||||
}else{
|
||||
} else {
|
||||
barrageRenderer.barrageLayoutCalculate.allBarrageInstances.push(...data.data.danmu);
|
||||
}
|
||||
if(data.data.nextDanmu){
|
||||
loadDanmu(page+1)
|
||||
if (data.data.nextDanmu) {
|
||||
loadDanmu(page + 1)
|
||||
}
|
||||
// barrageRenderer.setBarrages(data.data.danmu);
|
||||
})
|
||||
|
68
Web/html/ui/videoGiftItem.html
Normal file
68
Web/html/ui/videoGiftItem.html
Normal 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 // 重新规定成功的状态码为 200,table 组件默认为 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>
|
@ -12,7 +12,7 @@ public class LiveGiftDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "id")
|
||||
int id;
|
||||
@JSONField(name = "gift_id")
|
||||
private int giftId;
|
||||
private long giftId;
|
||||
@JSONField(name = "gift_name")
|
||||
private String giftName;
|
||||
@JSONField(name = "price")
|
||||
@ -22,9 +22,9 @@ public class LiveGiftDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "icon")
|
||||
private String icon;
|
||||
@JSONField(name = "gift_num")
|
||||
private int giftNum;
|
||||
private long giftNum;
|
||||
@JSONField(name = "sender_uid")
|
||||
private long senderUid;
|
||||
private String senderUid;
|
||||
@JSONField(name = "sender_name")
|
||||
private String senderName;
|
||||
@JSONField(name = "sender_face")
|
||||
|
@ -182,7 +182,7 @@ public class WSSendGift extends WSData {
|
||||
@JSONField(name = "base")
|
||||
private Base base;
|
||||
@JSONField(name = "uid")
|
||||
private long uid;
|
||||
private String uid;
|
||||
}
|
||||
|
||||
@lombok.Data
|
||||
|
@ -125,7 +125,7 @@ public class BiliLiveDatabase extends SQLiteManager {
|
||||
"SUM(`gift_num`) AS `total_gift_num`," +
|
||||
"CASE " +
|
||||
"WHEN `coin_type` = 'silver' THEN 0 " +
|
||||
"ELSE SUM(`price` * `gift_num`) " +
|
||||
"ELSE SUM(`price` / 100 * `gift_num`) " +
|
||||
"END AS `total_price`" +
|
||||
"FROM " +
|
||||
"`gift` " +
|
||||
@ -144,7 +144,7 @@ public class BiliLiveDatabase extends SQLiteManager {
|
||||
"filtered_gifts " +
|
||||
"GROUP BY " +
|
||||
"`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 + "'" +
|
||||
"GROUP BY `gift_name`;";
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends AbsDatabasesBean> List<T> get(String table, String where, Class<T> tClass) {
|
||||
return super.get(table, where, tClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(String table) {
|
||||
return super.getCount(table);
|
||||
|
@ -49,7 +49,12 @@ public class LiveController {
|
||||
|
||||
@RequestMapping("/live/gift/info")
|
||||
@ResponseBody
|
||||
public JSONObject download(String roomId, String videoId) {
|
||||
public JSONObject info(String roomId, String 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));
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class VideoFileController {
|
||||
try {
|
||||
length = new URL(url).openConnection().getContentLength();
|
||||
} 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()) {
|
||||
return Tools.getFile(img);
|
||||
|
@ -5,11 +5,14 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.biliapi.api.LiveApi;
|
||||
import com.yutou.biliapi.bean.live.LiveAnchorInfo;
|
||||
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.databases.BiliLiveDatabase;
|
||||
import com.yutou.biliapi.net.BiliLiveNetApiManager;
|
||||
import com.yutou.bilibili.Tools.DateFormatUtils;
|
||||
import com.yutou.bilibili.datas.web.LiveData;
|
||||
import com.yutou.common.databases.AbsDatabasesBean;
|
||||
import com.yutou.common.okhttp.HttpLoggingInterceptor;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -111,6 +114,41 @@ public class LiveService {
|
||||
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) {
|
||||
HttpLoggingInterceptor.setLog(true);
|
||||
LiveService service = new LiveService();
|
||||
|
Loading…
Reference in New Issue
Block a user