多语言-福袋统计

This commit is contained in:
liaozetao
2024-04-09 15:52:06 +08:00
committed by khalil
parent 92eca9bbe6
commit 5d012eb3ff
11 changed files with 754 additions and 650 deletions

View File

@@ -16,6 +16,8 @@ public class RoomGiftSerial {
private String clanName;
private String partitionDesc;
public Long getTotalRadish() {
return totalRadish;
}
@@ -95,4 +97,12 @@ public class RoomGiftSerial {
public void setClanName(String clanName) {
this.clanName = clanName;
}
public String getPartitionDesc() {
return partitionDesc;
}
public void setPartitionDesc(String partitionDesc) {
this.partitionDesc = partitionDesc;
}
}

View File

@@ -17,10 +17,14 @@ public class LuckyBagRecordAdminVo extends BaseVo {
public Long erbanNo;
@FieldComment("送礼人昵称")
public String nick;
@FieldComment("送礼人地区")
private String sendPartitionDesc;
@FieldComment("收礼人平台号")
public Long receiveErbanNo;
@FieldComment("收礼人昵称")
public String receiveNick;
@FieldComment("收礼人地区")
private String receivePartitionDesc;
@FieldComment("福袋时价")
public Integer totalGoldNum;
@FieldComment("礼物名称")

View File

@@ -11,6 +11,8 @@ public class LuckyBagStatsAdminVo extends BaseVo {
public Long erbanNo;
@FieldComment("昵称")
public String nick;
@FieldComment("地区")
private String partitionDesc;
@FieldComment("福袋购买数量")
public Integer num;
@FieldComment("用户投入钻石数")

View File

@@ -13,13 +13,13 @@ import java.util.List;
public interface LuckyBagRecordAdminMapper extends BaseMapper<LuckyBagRecord> {
List<LuckyBagRecordAdminVo> getList(@Param("limit") String limit, @Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("giftName") String giftName, @Param("startDate") Date starDate, @Param("endDate") Date endDate);
List<LuckyBagRecordAdminVo> getList(@Param("limit") String limit, @Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("giftName") String giftName, @Param("startDate") Date starDate, @Param("endDate") Date endDate, @Param("sendPartitionId") Integer sendPartitionId, @Param("receivePartitionId") Integer receivePartitionId);
Integer getCount(@Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("giftName") String giftName, @Param("startDate") Date starDate, @Param("endDate") Date endDate);
Integer getCount(@Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("giftName") String giftName, @Param("startDate") Date starDate, @Param("endDate") Date endDate, @Param("sendPartitionId") Integer sendPartitionId, @Param("receivePartitionId") Integer receivePartitionId);
List<LuckyBagStatsAdminVo> luckyBagStatsList(@Param("limit") String limit, @Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("startDate") Date starDate, @Param("endDate") Date endDate);
List<LuckyBagStatsAdminVo> luckyBagStatsList(@Param("limit") String limit, @Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("startDate") Date starDate, @Param("endDate") Date endDate, @Param("partitionId") Integer partitionId);
Integer luckyBagStatsCount(@Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("startDate") Date starDate, @Param("endDate") Date endDate);
Integer luckyBagStatsCount(@Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("startDate") Date starDate, @Param("endDate") Date endDate, @Param("partitionId") Integer partitionId);
LuckyBagStatsAdminVo luckyBagStats(@Param("luckyBagId") Integer luckyBagId, @Param("erbanNo") Long erbanNo, @Param("startDate") Date starDate, @Param("endDate") Date endDate);
@@ -28,7 +28,7 @@ public interface LuckyBagRecordAdminMapper extends BaseMapper<LuckyBagRecord> {
Integer statsTotal(@Param("luckyBagId") Integer luckyBagId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
List<NewLuckyBagRecordAdminVo> getRecord(@Param("luckyBagId")Integer luckyBagId,@Param("senderErbanNo") Long senderErbanNo, @Param("startDate")Date startDate, @Param("endDate")Date endDate, @Param("startNum") Integer startNum, @Param("pageSize") Integer pageSize);
List<NewLuckyBagRecordAdminVo> getRecord(@Param("luckyBagId") Integer luckyBagId, @Param("senderErbanNo") Long senderErbanNo, @Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("startNum") Integer startNum, @Param("pageSize") Integer pageSize);
Integer recordCount(@Param("luckyBagId")Integer luckyBagId,@Param("senderErbanNo") Long senderErbanNo, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
Integer recordCount(@Param("luckyBagId") Integer luckyBagId, @Param("senderErbanNo") Long senderErbanNo, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
}

View File

@@ -36,4 +36,12 @@ public interface RoomGiftSerialMapper {
*/
List<Map<String, Object>> listClanName(@Param("uidList") List<Long> uidList);
/**
* 地区
*
* @param uidList
* @return
*/
List<Map<String, Object>> listPartitionDesc(@Param("uidList") List<Long> uidList);
}

View File

@@ -8,15 +8,15 @@ import com.accompany.admin.vo.room.RoomRevenueAdminVo;
import com.accompany.business.service.room.RoomRevenueExcelService;
import com.accompany.business.service.room.RoomService;
import com.accompany.business.service.user.UsersService;
import com.accompany.common.status.BusiStatus;
import com.accompany.core.util.DoubleUtil;
import com.accompany.business.vo.RoomVo;
import com.accompany.business.vo.room.RoomRevenueExcelVo;
import com.accompany.common.constant.Constant;
import com.accompany.common.status.BusiStatus;
import com.accompany.core.exception.ServiceException;
import com.accompany.core.model.Room;
import com.accompany.core.model.Users;
import com.accompany.core.service.user.UsersBaseService;
import com.accompany.core.util.DoubleUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
@@ -130,7 +130,6 @@ public class RoomGiftSerialService {
*/
private Map<Long, String> getTitle(List<Long> uids) {
long start = System.currentTimeMillis();
Map<Long, String> titleList = null;
// 获取到标题
if (!CollectionUtils.isEmpty(uids)) {
@@ -167,6 +166,25 @@ public class RoomGiftSerialService {
return clanNameMap;
}
private Map<Long, String> getPartitionDesc(List<Long> uidList) {
long start = System.currentTimeMillis();
Map<Long, String> partitionDescMap = null;
// 获取到标题
if (!CollectionUtils.isEmpty(uidList)) {
List<Map<String, Object>> partitionDescList = roomGiftSerialMapper.listPartitionDesc(uidList);
partitionDescMap = new HashMap<>(partitionDescList.size());
for (Map<String, Object> map : partitionDescList) {
Object uid = Optional.ofNullable(map.get("uid")).orElse(0L);
Object partitionDesc = Optional.ofNullable(map.get("partitionDesc")).orElse("");
partitionDescMap.put(Long.parseLong(uid.toString()), partitionDesc.toString());
}
} else {
partitionDescMap = Collections.emptyMap();
}
logger.info("Completed getPartitionDesc in {} ms", (System.currentTimeMillis() - start));
return partitionDescMap;
}
private List<RoomGiftSerial> listSerials(List<String> erbanNoList, Integer permit, String startTime, String endTime, Integer page, Integer size) {
StopWatch stopWatch = new StopWatch();
List<String> uidList = Collections.emptyList();
@@ -302,14 +320,25 @@ public class RoomGiftSerialService {
stopWatch.stop();
});
CompletableFuture.allOf(titleFuture, usersFuture, clanNameFuture).join();
// 填充地区
CompletableFuture<?> partitionDescFuture = totalFuture.whenComplete((serials, throwable) -> {
stopWatch.start("fill partition desc");
List<Long> uidList = serials.stream().map(RoomGiftSerial::getRoomUid).collect(Collectors.toList());
Map<Long, String> partitionDescMap = getPartitionDesc(uidList);
if (!partitionDescMap.isEmpty()) {
serials.forEach((serial) -> serial.setPartitionDesc(partitionDescMap.get(serial.getRoomUid())));
}
stopWatch.stop();
});
CompletableFuture.allOf(titleFuture, usersFuture, clanNameFuture, partitionDescFuture).join();
List<RoomGiftSerial> list = totalFuture.join();
FastDateFormat format = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
String dateFormat = format.format(new Date());
list.forEach((serial) -> serial.setExecutionTime(dateFormat));
logger.info("Completed listV5ByAsync. {}", stopWatch.prettyPrint());
PageInfo pageInfo = new PageInfo(list);
PageInfo<RoomGiftSerial> pageInfo = new PageInfo<>(list);
long count = Optional.ofNullable(countSerials(CollectionUtils.isEmpty(erbanNoList), isPermit, startTime, endTime)).orElse((long) list.size());
pageInfo.setTotal(count);
return pageInfo;

View File

@@ -23,25 +23,25 @@ public class LuckyBagRecordAdminService extends ServiceImpl<LuckyBagRecordAdminM
@Autowired
LuckyBagRecordAdminMapper luckyBagRecordAdminMapper;
public Object getList(Integer page, Integer pageSize, Integer luckyBagId, Long erbanNo, String giftName, Date startDate, Date endDate) {
public HashMap<String, Object> getList(Integer page, Integer pageSize, Integer luckyBagId, Long erbanNo, String giftName, Date startDate, Date endDate, Integer sendPartitionId, Integer receivePartitionId) {
HashMap<String, Object> data = new HashMap<>();
String limit = String.format("%d,%d", (page - 1) * pageSize, pageSize);
List<LuckyBagRecordAdminVo> result = luckyBagRecordAdminMapper.getList(limit, luckyBagId, erbanNo, giftName, startDate, endDate);
List<LuckyBagRecordAdminVo> result = luckyBagRecordAdminMapper.getList(limit, luckyBagId, erbanNo, giftName, startDate, endDate, sendPartitionId, receivePartitionId);
if (null == result || result.isEmpty()) {
data.put("rows", new ArrayList<>());
data.put("total", 0);
return data;
}
Integer count = luckyBagRecordAdminMapper.getCount(luckyBagId, erbanNo, giftName, startDate, endDate);
Integer count = luckyBagRecordAdminMapper.getCount(luckyBagId, erbanNo, giftName, startDate, endDate, sendPartitionId, receivePartitionId);
data.put("rows", result);
data.put("total", count);
return data;
}
public Object getStats(Integer page, Integer pageSize, Integer luckyBagId, Long erbanNo, Date startDate, Date endDate) {
public HashMap<String, Object> getStats(Integer page, Integer pageSize, Integer luckyBagId, Long erbanNo, Date startDate, Date endDate, Integer partitionId) {
HashMap<String, Object> data = new HashMap<>();
String limit = String.format("%d,%d", (page - 1) * pageSize, pageSize);
List<LuckyBagStatsAdminVo> result = luckyBagRecordAdminMapper.luckyBagStatsList(limit, luckyBagId, erbanNo, startDate, endDate);
List<LuckyBagStatsAdminVo> result = luckyBagRecordAdminMapper.luckyBagStatsList(limit, luckyBagId, erbanNo, startDate, endDate, partitionId);
LuckyBagStatsAdminVo stats = luckyBagRecordAdminMapper.luckyBagStats(luckyBagId, erbanNo, startDate, endDate);
data.put("stats", stats);
if (null == result || result.isEmpty()) {
@@ -49,7 +49,7 @@ public class LuckyBagRecordAdminService extends ServiceImpl<LuckyBagRecordAdminM
data.put("total", 0);
return data;
}
Integer count = luckyBagRecordAdminMapper.luckyBagStatsCount(luckyBagId, erbanNo, startDate, endDate);
Integer count = luckyBagRecordAdminMapper.luckyBagStatsCount(luckyBagId, erbanNo, startDate, endDate, partitionId);
data.put("rows", result);
data.put("total", count);
return data;

View File

@@ -6,13 +6,26 @@
<resultMap id="BaseResultMap2" type="com.accompany.admin.vo.luckybag.LuckyBagStatsAdminVo">
</resultMap>
<select id="getList" resultMap="BaseResultMap">
select a.id,a.lucky_bag_id,a.total_gold_num / lucky_bag_num as total_gold_num,a.create_time,b.erban_no,b.nick,
c.erban_no receive_erban_no,c.nick receive_nick,
a.gift_name,a.platform_value gift_value from lucky_bag_record as a
select
a.id,
a.lucky_bag_id,
a.total_gold_num / lucky_bag_num as total_gold_num,
a.create_time,
b.erban_no,
b.nick,
pi1.`desc` as sendPartitionDesc,
c.erban_no receive_erban_no,
c.nick receive_nick,
pi2.`desc` as receivePartitionDesc,
a.gift_name,
a.platform_value gift_value
from lucky_bag_record as a
join users as b
join users as c
join gift as d
on a.uid=b.uid and a.receive_uid=c.uid and a.gift_id=d.gift_id
left join partition_info as pi1 on pi1.id = b.partition_id
left join partition_info as pi2 on pi2.id = c.partition_id
where 1=1
<if test="luckyBagId != null">
and lucky_bag_id = #{luckyBagId}
@@ -29,7 +42,12 @@
<if test="endDate != null">
and a.create_time &lt; #{endDate}
</if>
<if test="sendPartitionId != null">
and b.partition_id = #{sendPartitionId}
</if>
<if test="receivePartitionId != null">
and c.partition_id = #{receivePartitionId}
</if>
order by a.id desc
<if test="limit != null">
limit ${limit}
@@ -56,6 +74,12 @@
<if test="endDate != null">
and a.create_time &lt; #{endDate}
</if>
<if test="sendPartitionId != null">
and b.partition_id = #{sendPartitionId}
</if>
<if test="receivePartitionId != null">
and c.partition_id = #{receivePartitionId}
</if>
</select>
<select id="luckyBagStats" resultMap="BaseResultMap2">
@@ -81,13 +105,17 @@
</if>
</select>
<select id="luckyBagStatsList" resultMap="BaseResultMap2">
SELECT c.erban_no,c.nick,sum(gift_num) num,
SELECT
c.erban_no,
c.nick,
pi.`desc` as partitionDesc,
sum(gift_num) num,
ifnull(sum((total_gold_num/lucky_bag_num) * gift_num),0) input_value,
ifnull(sum(total_platform_value),0) AS output_value,
ifnull(sum(total_platform_value),0)/ifnull(sum(total_gold_num),1) AS ratio
FROM lucky_bag_record AS a
JOIN users as c
ON a.uid=c.uid
JOIN users as c ON a.uid=c.uid
left join partition_info as pi on pi.id = c.partition_id
where 1=1
<if test="luckyBagId != null">
and a.lucky_bag_id = #{luckyBagId}
@@ -101,6 +129,9 @@
<if test="endDate != null">
and a.create_time &lt; #{endDate}
</if>
<if test="partitionId != null">
and c.partition_id = #{partitionId}
</if>
group by a.uid
order by input_value desc
<if test="limit != null">
@@ -125,6 +156,9 @@
<if test="endDate != null">
and a.create_time &lt; #{endDate}
</if>
<if test="partitionId != null">
and c.partition_id = #{partitionId}
</if>
</select>
<select id="stats" resultType="com.accompany.admin.vo.newLuckyBag.NewLuckyBagStatsAdminVo">

View File

@@ -173,4 +173,16 @@
#{uid}
</foreach>
</select>
<select id="listPartitionDesc" resultType="map" parameterType="java.util.List">
select
r.uid,
pi.`desc` as partitionDesc
from room as r
left join partition_info as pi on pi.partition_id = r.id
where r.uid in
<foreach collection="uidList" item="uid" open="(" separator="," close=")">
#{uid}
</foreach>
</select>
</mapper>

View File

@@ -10,10 +10,14 @@ import com.accompany.common.result.BusiResult;
import com.accompany.common.status.BusiStatus;
import com.accompany.core.util.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@RestController
@RequestMapping("/admin/luckyBagRecord")
@@ -26,35 +30,35 @@ public class LuckyBagRecordAdminController extends BaseController {
@Authorization
@RequestMapping("/list")
public BusiResult getList(Integer page, Integer pageSize, Integer luckyBagId, Long erbanNo, String giftName, Date startDate, Date endDate) {
if (null == page || null == pageSize || page <1 || pageSize < 1) {
return new BusiResult(BusiStatus.PARAMETERILLEGAL);
public BusiResult<HashMap<String, Object>> getList(Integer page, Integer pageSize, Integer luckyBagId, Long erbanNo, String giftName, Date startDate, Date endDate, Integer sendPartitionId, Integer receivePartitionId) {
if (null == page || null == pageSize || page < 1 || pageSize < 1) {
return new BusiResult<>(BusiStatus.PARAMETERILLEGAL);
}
return new BusiResult(BusiStatus.SUCCESS, luckyBagRecordAdminService.getList(page, pageSize, luckyBagId, erbanNo, giftName, startDate, endDate));
return new BusiResult<>(BusiStatus.SUCCESS, luckyBagRecordAdminService.getList(page, pageSize, luckyBagId, erbanNo, giftName, startDate, endDate, sendPartitionId, receivePartitionId));
}
@Authorization
@RequestMapping("/stats")
public BusiResult getStats(Integer page, Integer pageSize, Integer luckyBagId, Long erbanNo, Date startDate, Date endDate) {
if (null == page || null == pageSize || page <1 || pageSize < 1) {
return new BusiResult(BusiStatus.PARAMETERILLEGAL);
public BusiResult<HashMap<String, Object>> getStats(Integer page, Integer pageSize, Integer luckyBagId, Long erbanNo, Date startDate, Date endDate, Integer partitionId) {
if (null == page || null == pageSize || page < 1 || pageSize < 1) {
return new BusiResult<>(BusiStatus.PARAMETERILLEGAL);
}
return new BusiResult(BusiStatus.SUCCESS, luckyBagRecordAdminService.getStats(page, pageSize, luckyBagId, erbanNo, startDate, endDate));
return new BusiResult<>(BusiStatus.SUCCESS, luckyBagRecordAdminService.getStats(page, pageSize, luckyBagId, erbanNo, startDate, endDate, partitionId));
}
@Authorization
@RequestMapping("/statsExport")
public void statsExport(Integer luckyBagId, Long erbanNo, Date startDate, Date endDate, HttpServletResponse response) throws Exception {
List<LuckyBagStatsAdminVo> result = luckyBagRecordAdminMapper.luckyBagStatsList("0,1000000", luckyBagId, erbanNo, startDate, endDate);
List<String> fields = Arrays.asList("erbanNo", "nick", "num", "inputValue", "outputValue", "ratio");
public void statsExport(Integer luckyBagId, Long erbanNo, Date startDate, Date endDate, Integer partitionId, HttpServletResponse response) throws Exception {
List<LuckyBagStatsAdminVo> result = luckyBagRecordAdminMapper.luckyBagStatsList("0,1000000", luckyBagId, erbanNo, startDate, endDate, partitionId);
List<String> fields = Arrays.asList("erbanNo", "nick", "partitionDesc", "num", "inputValue", "outputValue", "ratio");
ExcelUtils.exportExcel("福袋数据统计", "luckybagStatsExport", fields, result, response);
}
@Authorization
@RequestMapping("/recordExport")
public void recordExport(Integer luckyBagId, Long erbanNo, String giftName, Date startDate, Date endDate, HttpServletResponse response) throws Exception {
List<LuckyBagRecordAdminVo> result= luckyBagRecordAdminMapper.getList("0,1000000", luckyBagId, erbanNo, giftName, startDate, endDate);
List<String> fields = Arrays.asList("id", "luckyBagId", "erbanNo", "nick", "receiveErbanNo", "receiveNick",
public void recordExport(Integer luckyBagId, Long erbanNo, String giftName, Date startDate, Date endDate, Integer sendPartitionId, Integer receivePartitionId, HttpServletResponse response) throws Exception {
List<LuckyBagRecordAdminVo> result = luckyBagRecordAdminMapper.getList("0,1000000", luckyBagId, erbanNo, giftName, startDate, endDate, sendPartitionId, receivePartitionId);
List<String> fields = Arrays.asList("id", "luckyBagId", "erbanNo", "nick", "sendPartitionDesc", "receiveErbanNo", "receiveNick", "receivePartitionDesc",
"totalGoldNum", "giftName", "giftValue", "createTime");
ExcelUtils.exportExcel("福袋购买记录", "luckybagRecordExport", fields, result, response);
}