add 新增查看礼物详情列表
fix 调整礼物金额
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user