增加导出

This commit is contained in:
hy001 2026-06-04 12:11:55 +08:00
parent 7f7649d6bd
commit c8e9c8c257
14 changed files with 469 additions and 114 deletions

View File

@ -1,6 +1,6 @@
package com.red.circle.wallet.inner.model.cmd;
import com.red.circle.framework.core.dto.CommonCommand;
import com.red.circle.common.business.dto.cmd.HistoryRangeTimeQryPageCmd;
import jakarta.validation.constraints.NotBlank;
import java.io.Serial;
import lombok.Data;
@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class UserFreightBalanceRunningWaterExportQryCmd extends CommonCommand {
public class UserFreightBalanceRunningWaterExportQryCmd extends HistoryRangeTimeQryPageCmd {
@Serial
private static final long serialVersionUID = 1L;
@ -27,7 +27,31 @@ public class UserFreightBalanceRunningWaterExportQryCmd extends CommonCommand {
/**
* 日期yyyyMM.
*/
@NotBlank
private String monthDate;
/**
* 发送人用户id.
*/
private Long userId;
/**
* 接收人用户id.
*/
private Long acceptUserId;
/**
* 来源.
*/
private String origin;
/**
* 查询后台操作流水.
*/
private Boolean queryBackOperationUser;
/**
* 操作用户ID多个用逗号分隔.
*/
private String createUsers;
}

View File

@ -42,5 +42,9 @@ public class UserFreightBalanceRunningWaterPageQryCmd extends HistoryRangeTimeQr
*/
private Boolean queryBackOperationUser;
/**
* 操作用户ID多个用逗号分隔.
*/
private String createUsers;
}

View File

@ -50,6 +50,11 @@ public class UserGoldRunningWaterBackQryCmd extends Command {
@JsonSerialize(using = ToStringSerializer.class)
private Long backOperationUser;
/**
* 后台操作用户ID多个用逗号分隔.
*/
private String backOperationUsers;
/**
* 跟踪id.
*/

View File

@ -141,15 +141,22 @@ public class UserFreightRestController extends BaseController {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("Export Freight RunningWater " + query.getMonthDate(),
StandardCharsets.UTF_8)
.replaceAll("\\+", "%20");
String sheetName = URLEncoder.encode("Export Freight RunningWater " + query.getMonthDate(),
String fileName = URLEncoder.encode("Export Freight RunningWater " + getExportNameSuffix(query),
StandardCharsets.UTF_8)
.replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), UserFreightBalanceRunningWaterExportModel.class)
.sheet(sheetName).doWrite(userFreightService.listExport(query));
.sheet("FreightRunningWater").doWrite(userFreightService.listExport(query));
}
private String getExportNameSuffix(UserFreightBalanceRunningWaterExportQryCmd query) {
if (query.getMonthDate() != null && !query.getMonthDate().isBlank()) {
return query.getMonthDate();
}
if (query.getStartTime() != null || query.getEndTime() != null) {
return query.getStartTime() + "-" + query.getEndTime();
}
return "Filtered";
}
/**

View File

@ -9,11 +9,13 @@ import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.wallet.inner.model.cmd.DeductGoldCmd;
import com.red.circle.wallet.inner.model.cmd.DiamondCmd;
import com.red.circle.wallet.inner.model.cmd.SendGoldCmd;
import com.red.circle.wallet.inner.model.cmd.UserGoldRunningWaterBackQryCmd;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import com.red.circle.wallet.inner.model.cmd.SendGoldCmd;
import com.red.circle.wallet.inner.model.cmd.UserGoldRunningWaterBackQryCmd;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -48,10 +50,20 @@ public class UserWalletRestController extends BaseController {
* 流水列表.
*/
@GetMapping("/gold/running-water/cls")
public UserGoldRunningWaterClsTmpCO getGoldRunningWaterCls(UserGoldRunningWaterBackQryCmd query) {
return userWalletService.getGoldRunningWaterCls(query);
}
public UserGoldRunningWaterClsTmpCO getGoldRunningWaterCls(UserGoldRunningWaterBackQryCmd query) {
return userWalletService.getGoldRunningWaterCls(query);
}
/**
* 流水导出.
*/
@GetMapping("/gold/running-water/cls/export")
public void exportGoldRunningWaterCls(
HttpServletResponse response,
@Validated UserGoldRunningWaterBackQryCmd query) throws IOException {
userWalletService.exportGoldRunningWater(response, query);
}
@OpsOperationReqLog("发送金币")
@PostMapping("/send-gold")
public void sendGold(@RequestBody @Validated SendGoldCmd param) {

View File

@ -94,6 +94,12 @@ public class UserFreightBalanceRunningWaterExportModel implements Serializable {
@ExcelProperty(value = "Origin Name")
private String originName;
/**
* 操作人.
*/
@ExcelProperty(value = "Operator")
private String operationUserNickname;
/**
* 备注
*/

View File

@ -0,0 +1,91 @@
package com.red.circle.console.app.excel.model.wallet;
import com.alibaba.excel.annotation.ExcelProperty;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 后台金币流水导出.
*/
@Data
@Accessors(chain = true)
public class UserGoldRunningWaterExportModel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 流水ID.
*/
@ExcelProperty(value = "Record ID")
private String recordId;
/**
* 系统来源.
*/
@ExcelProperty(value = "Sys Origin")
private String sysOrigin;
/**
* 用户ID.
*/
@ExcelProperty(value = "User ID")
private String userId;
/**
* 用户账号.
*/
@ExcelProperty(value = "User Account")
private String userAccount;
/**
* 用户昵称.
*/
@ExcelProperty(value = "User Nickname")
private String userNickname;
/**
* 类型.
*/
@ExcelProperty(value = "Type")
private String type;
/**
* 金币金额.
*/
@ExcelProperty(value = "Amount")
private BigDecimal quantity;
/**
* 操作后余额.
*/
@ExcelProperty(value = "Balance")
private BigDecimal balance;
/**
* 原因.
*/
@ExcelProperty(value = "Reason")
private String originName;
/**
* 备注.
*/
@ExcelProperty(value = "Remark")
private String remark;
/**
* 操作人.
*/
@ExcelProperty(value = "Operator")
private String backOperationName;
/**
* 操作时间.
*/
@ExcelProperty(value = "Create Time")
private String createTime;
}

View File

@ -456,6 +456,11 @@ public class UserFreightBalanceServiceImpl implements
Map<Long, RegionConfigDTO> regionConfigMap = ResponseAssert.requiredSuccess(
userRegionClient.mapUserRegionConfig(
new UserRegionConfigMapCmd().setUserIds(userIds)));
Map<Long, String> opsUserNicknameMap = userService.mapBackUserNickname(
waters.stream()
.map(UserFreightBalanceRunningWaterDTO::getCreateUser)
.filter(Objects::nonNull)
.collect(Collectors.toSet()));
return waters.stream().map(water -> {
@ -472,6 +477,9 @@ public class UserFreightBalanceServiceImpl implements
.map(RegionConfigDTO::getRegionCode)
.orElse("未知"));
exportModel.setOriginName(FreightBalanceOrigin.getDesc(water.getOrigin()));
exportModel.setOperationUserNickname(Optional.ofNullable(water.getCreateUser())
.map(opsUserNicknameMap::get)
.orElse(""));
exportModel.setAccount(getAccountDescribe(sendUser));
exportModel.setNickname(Optional.ofNullable(sendUser)
.map(UserProfileDTO::getUserNickname).orElse("?"));

View File

@ -1,18 +1,23 @@
package com.red.circle.console.app.service.app.user;
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
import com.red.circle.common.business.core.enums.ReceiptType;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.enums.DiamondOrigin;
import com.red.circle.console.app.convertor.WalletAppConvertor;
import com.red.circle.console.app.dto.clienobject.user.UserGoldBalanceCO;
import com.red.circle.console.app.dto.clienobject.user.UserGoldRunningWaterCO;
import com.red.circle.console.app.dto.clienobject.user.UserGoldRunningWaterClsTmpCO;
import com.red.circle.console.infra.database.rds.service.admin.UserService;
import com.red.circle.console.inner.error.ConsoleErrorCode;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.mybatis.constant.PageConstant;
import com.red.circle.order.inner.endpoint.UserRechargeCountClient;
package com.red.circle.console.app.service.app.user;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
import com.red.circle.common.business.core.enums.ReceiptType;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.enums.DiamondOrigin;
import com.red.circle.console.app.convertor.WalletAppConvertor;
import com.red.circle.console.app.dto.clienobject.user.UserGoldBalanceCO;
import com.red.circle.console.app.dto.clienobject.user.UserGoldRunningWaterCO;
import com.red.circle.console.app.dto.clienobject.user.UserGoldRunningWaterClsTmpCO;
import com.red.circle.console.app.excel.EasyExcelUtils;
import com.red.circle.console.app.excel.model.wallet.UserGoldRunningWaterExportModel;
import com.red.circle.console.infra.database.rds.service.admin.UserService;
import com.red.circle.console.inner.error.ConsoleErrorCode;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.mybatis.constant.PageConstant;
import com.red.circle.order.inner.endpoint.UserRechargeCountClient;
import com.red.circle.order.inner.model.enums.MonthlyRechargeType;
import com.red.circle.other.inner.endpoint.activity.CumulativeRechargeClient;
import com.red.circle.other.inner.endpoint.sys.AnchorSalaryExchangeGoldClient;
@ -21,11 +26,11 @@ import com.red.circle.other.inner.model.cmd.sys.SysAnchorSalaryExchangeGoldCmd;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.date.TimestampUtils;
import com.red.circle.tool.core.num.ArithmeticUtils;
import com.red.circle.tool.core.sequence.IdWorkerUtils;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.other.inner.asserts.user.UserErrorCode;
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
import com.red.circle.other.inner.endpoint.user.user.UserSvipClient;
import com.red.circle.tool.core.sequence.IdWorkerUtils;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.other.inner.asserts.user.UserErrorCode;
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
import com.red.circle.other.inner.endpoint.user.user.UserSvipClient;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.wallet.inner.endpoint.wallet.WalletDiamondClient;
import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
@ -35,15 +40,23 @@ import com.red.circle.wallet.inner.model.cmd.DiamondCmd;
import com.red.circle.wallet.inner.model.cmd.DiamondReceiptCmd;
import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd;
import com.red.circle.wallet.inner.model.cmd.SendGoldCmd;
import com.red.circle.wallet.inner.model.cmd.UserGoldRunningWaterBackQryCmd;
import com.red.circle.wallet.inner.model.dto.UserGoldRunningWaterClsHistoryDTO;
import com.red.circle.wallet.inner.model.dto.UserGoldRunningWaterHistoryDTO;
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import com.red.circle.wallet.inner.model.cmd.UserGoldRunningWaterBackQryCmd;
import com.red.circle.wallet.inner.model.dto.UserGoldRunningWaterClsHistoryDTO;
import com.red.circle.wallet.inner.model.dto.UserGoldRunningWaterDTO;
import com.red.circle.wallet.inner.model.dto.UserGoldRunningWaterHistoryDTO;
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -54,12 +67,16 @@ import org.springframework.stereotype.Service;
* @author pengliang on 2022/7/21
*/
@Service
@RequiredArgsConstructor
public class UserWalletServiceImpl implements UserWalletService {
private final UserService userService;
private final UserSvipClient userSvipClient;
private final WalletGoldClient walletGoldClient;
@RequiredArgsConstructor
public class UserWalletServiceImpl implements UserWalletService {
private static final int EXPORT_BATCH_SIZE = 1000;
private static final DateTimeFormatter EXPORT_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private final UserService userService;
private final UserSvipClient userSvipClient;
private final WalletGoldClient walletGoldClient;
private final UserProfileClient userProfileClient;
private final UserLevelClient userLevelClient;
private final WalletAppConvertor walletAppConvertor;
@ -178,6 +195,133 @@ public class UserWalletServiceImpl implements UserWalletService {
);
}
@Override
public void exportGoldRunningWater(HttpServletResponse response, UserGoldRunningWaterBackQryCmd query)
throws IOException {
UserGoldRunningWaterBackQryCmd exportQuery = copyGoldRunningWaterQuery(query)
.setContext(null)
.setLastId(null)
.setLimit(EXPORT_BATCH_SIZE);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
String fileName = URLEncoder.encode("GmGoldRunningWater", StandardCharsets.UTF_8)
.replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
ExcelWriter excelWriter = null;
try {
excelWriter = EasyExcel.write(response.getOutputStream(), UserGoldRunningWaterExportModel.class)
.registerWriteHandler(EasyExcelUtils.getStyleStrategy())
.build();
WriteSheet sheet = EasyExcel.writerSheet("GmGoldRunningWater").build();
boolean wroteAnyData = false;
while (true) {
List<UserGoldRunningWaterCO> waters = listGoldRunningWater(exportQuery);
if (CollectionUtils.isEmpty(waters)) {
break;
}
excelWriter.write(toGoldRunningWaterExportModels(waters), sheet);
wroteAnyData = true;
Long nextLastId = getLastRunningWaterId(waters);
if (Objects.isNull(nextLastId) || Objects.equals(nextLastId, exportQuery.getLastId())) {
break;
}
exportQuery.setLastId(nextLastId);
}
if (!wroteAnyData) {
excelWriter.write(Lists.newArrayList(), sheet);
}
} finally {
if (Objects.nonNull(excelWriter)) {
excelWriter.finish();
}
}
}
private UserGoldRunningWaterBackQryCmd copyGoldRunningWaterQuery(
UserGoldRunningWaterBackQryCmd source) {
if (Objects.isNull(source)) {
return new UserGoldRunningWaterBackQryCmd();
}
return new UserGoldRunningWaterBackQryCmd()
.setId(source.getId())
.setSysOrigin(source.getSysOrigin())
.setUserId(source.getUserId())
.setQueryBackOperationUser(source.getQueryBackOperationUser())
.setBackOperationUser(source.getBackOperationUser())
.setBackOperationUsers(source.getBackOperationUsers())
.setTrackId(source.getTrackId())
.setType(source.getType())
.setOrigin(source.getOrigin())
.setStartTime(source.getStartTime())
.setEndTime(source.getEndTime());
}
private List<UserGoldRunningWaterExportModel> toGoldRunningWaterExportModels(
List<UserGoldRunningWaterCO> waters) {
return waters.stream()
.map(water -> {
UserGoldRunningWaterDTO runningWater = water.getRunningWater();
UserProfileDTO userProfile = water.getUserProfile();
return new UserGoldRunningWaterExportModel()
.setRecordId(Objects.toString(runningWater.getId(), ""))
.setSysOrigin(runningWater.getSysOrigin())
.setUserId(Objects.toString(runningWater.getUserId(), ""))
.setUserAccount(getAccountDescribe(userProfile))
.setUserNickname(Optional.ofNullable(userProfile)
.map(UserProfileDTO::getUserNickname).orElse(""))
.setType(getGoldRunningWaterTypeName(runningWater.getType()))
.setQuantity(runningWater.getQuantity())
.setBalance(runningWater.getBalance())
.setOriginName(runningWater.getOriginName())
.setRemark(runningWater.getRemark())
.setBackOperationName(StringUtils.isBlank(water.getBackOperationName())
? "-" : water.getBackOperationName())
.setCreateTime(formatExportTime(runningWater.getCreateTime()));
})
.toList();
}
private Long getLastRunningWaterId(List<UserGoldRunningWaterCO> waters) {
if (CollectionUtils.isEmpty(waters)) {
return null;
}
return Optional.ofNullable(waters.get(waters.size() - 1))
.map(UserGoldRunningWaterCO::getRunningWater)
.map(UserGoldRunningWaterDTO::getId)
.orElse(null);
}
private String getGoldRunningWaterTypeName(Integer type) {
if (Objects.equals(type, 0)) {
return "增加";
}
if (Objects.equals(type, 1)) {
return "减少";
}
return Objects.toString(type, "");
}
private String formatExportTime(Long time) {
if (Objects.isNull(time)) {
return "";
}
return EXPORT_TIME_FORMATTER.format(
Instant.ofEpochMilli(time).atZone(ZoneId.systemDefault()));
}
private String getAccountDescribe(UserProfileDTO userProfile) {
if (Objects.isNull(userProfile)) {
return "";
}
if (Objects.nonNull(userProfile.getOwnSpecialId())) {
return userProfile.getOwnSpecialId().getAccount() + "(" + userProfile.getAccount() + ")";
}
return userProfile.getAccount();
}
private UserGoldRunningWaterClsTmpCO getGoldRunningWaterDbFallback(
UserGoldRunningWaterBackQryCmd query) {
if (StringUtils.isNotBlank(query.getContext()) && Objects.isNull(query.getLastId())) {

View File

@ -4,11 +4,13 @@ import com.red.circle.console.app.dto.clienobject.user.UserGoldBalanceCO;
import com.red.circle.console.app.dto.clienobject.user.UserGoldRunningWaterCO;
import com.red.circle.console.app.dto.clienobject.user.UserGoldRunningWaterClsTmpCO;
import com.red.circle.wallet.inner.model.cmd.DeductGoldCmd;
import com.red.circle.wallet.inner.model.cmd.DiamondCmd;
import com.red.circle.wallet.inner.model.cmd.SendGoldCmd;
import com.red.circle.wallet.inner.model.cmd.UserGoldRunningWaterBackQryCmd;
import java.math.BigDecimal;
import java.util.List;
import com.red.circle.wallet.inner.model.cmd.DiamondCmd;
import com.red.circle.wallet.inner.model.cmd.SendGoldCmd;
import com.red.circle.wallet.inner.model.cmd.UserGoldRunningWaterBackQryCmd;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
/**
* 用户钱包 服务.
@ -29,15 +31,21 @@ public interface UserWalletService {
List<UserGoldRunningWaterCO> listGoldRunningWater(UserGoldRunningWaterBackQryCmd query);
/**
* 查询用户金币流水 cls.
*/
UserGoldRunningWaterClsTmpCO getGoldRunningWaterCls(UserGoldRunningWaterBackQryCmd query);
/**
* 发送金币.
*/
void sendGold(SendGoldCmd param);
/**
* 查询用户金币流水 cls.
*/
UserGoldRunningWaterClsTmpCO getGoldRunningWaterCls(UserGoldRunningWaterBackQryCmd query);
/**
* 导出用户金币流水.
*/
void exportGoldRunningWater(HttpServletResponse response, UserGoldRunningWaterBackQryCmd query)
throws IOException;
/**
* 发送金币.
*/
void sendGold(SendGoldCmd param);
/**
* 扣除金币.

View File

@ -8,7 +8,6 @@ import com.red.circle.other.infra.database.cache.service.other.EmojiCacheService
import com.red.circle.tool.core.collection.CollectionUtils;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -41,19 +40,15 @@ public class EmojiAllQryExe {
}
public List<UserEmojiBackpackCache> listUserEmojiBackpackCache(AppExtCommand cmd) {
List<UserEmojiBackpackCache> emojiBackpackCaches = emojiCacheService.listEmojiAll(cmd.requireReqSysOrigin());
List<Long> emojiBagIds = emojiCacheService.listEmojiBagIds(cmd.requiredReqUserId());
if (CollectionUtils.isEmpty(emojiBagIds)) {
List<UserEmojiBackpackCache> emojiBackpackCaches = emojiCacheService.listEmojiAll(
cmd.requireReqSysOrigin());
if (CollectionUtils.isEmpty(emojiBackpackCaches)) {
return emojiBackpackCaches;
}
return emojiBackpackCaches.stream().peek(cache -> {
if (emojiBagIds.contains(cache.getId())) {
cache.setHave(Boolean.TRUE);
}
}).collect(Collectors.toList());
return emojiBackpackCaches.stream()
.peek(cache -> cache.setHave(Boolean.TRUE))
.collect(Collectors.toList());
}
}

View File

@ -7,7 +7,6 @@ import com.red.circle.other.infra.database.cache.entity.material.UserEmojiBackpa
import com.red.circle.other.infra.database.cache.service.other.EmojiCacheService;
import com.red.circle.tool.core.collection.CollectionUtils;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@ -24,26 +23,13 @@ public class UserEmojiBackpackQryExe {
private final EmojiAppConvertor emojiAppConvertor;
public List<UserEmojiBagCO> execute(AppExtCommand cmd) {
return Optional
.ofNullable(emojiCacheService.getBySystemUserBag(cmd.requireReqSysOrigin()))
.map(systemBag -> getUserEmojiBagIncludeSystem(cmd, systemBag))
.orElseGet(() -> getUserEmojiBags(cmd));
}
private List<UserEmojiBagCO> getUserEmojiBagIncludeSystem(AppExtCommand cmd,
UserEmojiBackpackCache systemBag) {
List<UserEmojiBagCO> userEmojiBag = CollectionUtils.newArrayList();
userEmojiBag.add(emojiAppConvertor.toUserEmojiBagCO(systemBag));
List<UserEmojiBagCO> userEmojiBags = getUserEmojiBags(cmd);
if (CollectionUtils.isNotEmpty(userEmojiBags)) {
userEmojiBag.addAll(userEmojiBags);
List<UserEmojiBackpackCache> emojiBackpackCaches = emojiCacheService.listEmojiAll(
cmd.requireReqSysOrigin());
if (CollectionUtils.isEmpty(emojiBackpackCaches)) {
return CollectionUtils.newArrayList();
}
return userEmojiBag;
}
private List<UserEmojiBagCO> getUserEmojiBags(AppExtCommand cmd) {
return emojiAppConvertor.toListUserEmojiBagCO(
emojiCacheService.listEmojiBag(cmd.requiredReqUserId()));
emojiBackpackCaches.forEach(cache -> cache.setHave(Boolean.TRUE));
return emojiAppConvertor.toListUserEmojiBagCO(emojiBackpackCaches);
}
}

View File

@ -7,6 +7,7 @@ import com.red.circle.framework.mybatis.mybatisplus.LambdaQueryWrapperChain;
import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.date.TimestampUtils;
import com.red.circle.tool.core.parse.DataTypeUtils;
import com.red.circle.tool.core.text.StringUtils;
import com.red.circle.wallet.infra.database.rds.dao.FreightBalanceRunningWaterDAO;
import com.red.circle.wallet.infra.database.rds.entity.freight.FreightBalanceRunningWater;
@ -17,6 +18,7 @@ import com.red.circle.wallet.inner.model.cmd.UserFreightSellerRunningWaterPageQr
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -99,6 +101,7 @@ public class FreightBalanceRunningWaterServiceImpl extends
@Override
public PageResult<FreightBalanceRunningWater> pageRunningWater(
UserFreightBalanceRunningWaterPageQryCmd query) {
List<Long> createUsers = parseLongIds(query.getCreateUsers());
return query()
.eq(StringUtils.isNotBlank(query.getSysOrigin()),
FreightBalanceRunningWater::getSysOrigin, query.getSysOrigin())
@ -113,7 +116,9 @@ public class FreightBalanceRunningWaterServiceImpl extends
.le(Objects.nonNull(query.getEndTime()),
FreightBalanceRunningWater::getCreateTime, query.endTimeToLocalDateTime())
.gt(Objects.equals(query.getQueryBackOperationUser(), true),
FreightBalanceRunningWater::getUpdateUser, 0)
FreightBalanceRunningWater::getCreateUser, 0)
.in(CollectionUtils.isNotEmpty(createUsers), FreightBalanceRunningWater::getCreateUser,
createUsers)
.orderByDesc(FreightBalanceRunningWater::getCreateTime)
.page(query.getPageQuery());
}
@ -132,12 +137,44 @@ public class FreightBalanceRunningWaterServiceImpl extends
@Override
public List<FreightBalanceRunningWater> listExportBalanceRunningWater(
UserFreightBalanceRunningWaterExportQryCmd query) {
List<Long> createUsers = parseLongIds(query.getCreateUsers());
return query()
.eq(FreightBalanceRunningWater::getSysOrigin, query.getSysOrigin())
.apply("DATE_FORMAT(create_time,'%Y%m')={0}", query.getMonthDate())
.eq(StringUtils.isNotBlank(query.getSysOrigin()),
FreightBalanceRunningWater::getSysOrigin, query.getSysOrigin())
.eq(Objects.nonNull(query.getUserId()),
FreightBalanceRunningWater::getUserId, query.getUserId())
.eq(Objects.nonNull(query.getAcceptUserId()),
FreightBalanceRunningWater::getAcceptUserId, query.getAcceptUserId())
.eq(StringUtils.isNotBlank(query.getOrigin()),
FreightBalanceRunningWater::getOrigin, query.getOrigin())
.ge(Objects.nonNull(query.getStartTime()),
FreightBalanceRunningWater::getCreateTime, query.startTimeToLocalDateTime())
.le(Objects.nonNull(query.getEndTime()),
FreightBalanceRunningWater::getCreateTime, query.endTimeToLocalDateTime())
.gt(Objects.equals(query.getQueryBackOperationUser(), true),
FreightBalanceRunningWater::getCreateUser, 0)
.in(CollectionUtils.isNotEmpty(createUsers), FreightBalanceRunningWater::getCreateUser,
createUsers)
.apply(Objects.isNull(query.getStartTime()) && Objects.isNull(query.getEndTime())
&& StringUtils.isNotBlank(query.getMonthDate()),
"DATE_FORMAT(create_time,'%Y%m')={0}", query.getMonthDate())
.orderByDesc(FreightBalanceRunningWater::getCreateTime)
.list();
}
private List<Long> parseLongIds(String values) {
if (StringUtils.isBlank(values)) {
return CollectionUtils.newArrayList();
}
return Arrays.stream(values.split(","))
.map(String::trim)
.filter(StringUtils::isNotBlank)
.map(DataTypeUtils::toLong)
.filter(Objects::nonNull)
.distinct()
.toList();
}
@Override
public boolean existsRecord(String txId) {
if (!StringUtils.isNotBlank(txId)) {

View File

@ -146,11 +146,12 @@ public class WalletGoldClientServiceImpl implements WalletGoldClientService {
}
@Override
public List<UserGoldRunningWaterHistoryDTO> listWater(UserGoldRunningWaterBackQryCmd cmd) {
List<String> querySysOrigin = listWaterQuerySysOrigin(cmd);
LambdaQueryWrapperChain<WalletGoldAssetRecord> queryChain = walletGoldAssetRecordService.query();
@Override
public List<UserGoldRunningWaterHistoryDTO> listWater(UserGoldRunningWaterBackQryCmd cmd) {
List<String> querySysOrigin = listWaterQuerySysOrigin(cmd);
List<Long> backOperationUsers = parseLongIds(cmd.getBackOperationUsers());
LambdaQueryWrapperChain<WalletGoldAssetRecord> queryChain = walletGoldAssetRecordService.query();
if (CollectionUtils.isEmpty(querySysOrigin) || querySysOrigin.size() <= 1) {
queryChain.eq(WalletGoldAssetRecord::getSysOrigin,
@ -164,9 +165,12 @@ public class WalletGoldClientServiceImpl implements WalletGoldClientService {
.le(WalletGoldAssetRecord::getCreateTime, cmd.getEndTime())
.eq(Objects.nonNull(cmd.getId()), WalletGoldAssetRecord::getId, cmd.getId())
.eq(Objects.nonNull(cmd.getQueryBackOperationUser()), WalletGoldAssetRecord::getOpUserType,
cmd.getQueryBackOperationUser())
.eq(Objects.nonNull(cmd.getBackOperationUser()), WalletGoldAssetRecord::getCreateUser,
DataTypeUtils.toInteger(cmd.getQueryBackOperationUser()))
.eq(CollectionUtils.isEmpty(backOperationUsers) && Objects.nonNull(cmd.getBackOperationUser()),
WalletGoldAssetRecord::getCreateUser,
cmd.getBackOperationUser())
.in(CollectionUtils.isNotEmpty(backOperationUsers), WalletGoldAssetRecord::getCreateUser,
backOperationUsers)
.eq(Objects.nonNull(cmd.getType()), WalletGoldAssetRecord::getType, cmd.getType())
.eq(Objects.nonNull(cmd.getUserId()), WalletGoldAssetRecord::getUserId, cmd.getUserId())
.eq(StringUtils.isNotBlank(cmd.getTrackId()), WalletGoldAssetRecord::getEventId,
@ -301,10 +305,10 @@ public class WalletGoldClientServiceImpl implements WalletGoldClientService {
private String getQueryString(UserGoldRunningWaterBackQryCmd cmd) {
List<String> query = Stream.of(
toQuery("sysOrigin", querySysOrigin(cmd)),
toQuery("sysOrigin", querySysOrigin(cmd)),
toQuery("id", cmd.getId()),
toQuery("opUserType", DataTypeUtils.toInteger(cmd.getQueryBackOperationUser())),
toQuery("createUser", cmd.getBackOperationUser()),
toQuery("createUser", getBackOperationUsers(cmd)),
toQuery("type", cmd.getType()),
toQuery("userId", cmd.getUserId()),
toQuery("eventId", cmd.getTrackId()),
@ -315,7 +319,7 @@ public class WalletGoldClientServiceImpl implements WalletGoldClientService {
return StringUtils.isBlank(queryString) ? "*" : queryString;
}
private List<String> getOrigin(String origin) {
private List<String> getOrigin(String origin) {
if (StringUtils.isBlank(origin)) {
return null;
}
@ -323,10 +327,34 @@ public class WalletGoldClientServiceImpl implements WalletGoldClientService {
? Stream.of(origin.split(",")).filter(StringUtils::isNotBlank).toList()
: List.of(origin);
}
/**
* cls最多一次返回1000条.
}
private List<String> getBackOperationUsers(UserGoldRunningWaterBackQryCmd cmd) {
List<Long> backOperationUsers = parseLongIds(cmd.getBackOperationUsers());
if (CollectionUtils.isNotEmpty(backOperationUsers)) {
return backOperationUsers.stream().map(Objects::toString).toList();
}
if (Objects.nonNull(cmd.getBackOperationUser())) {
return List.of(Objects.toString(cmd.getBackOperationUser()));
}
return null;
}
private List<Long> parseLongIds(String values) {
if (StringUtils.isBlank(values)) {
return Lists.newArrayList();
}
return Arrays.stream(values.split(","))
.map(StringUtils::trim)
.filter(StringUtils::isNotBlank)
.map(DataTypeUtils::toLong)
.filter(Objects::nonNull)
.distinct()
.toList();
}
/**
* cls最多一次返回1000条.
*/
private Integer getLimit(UserGoldRunningWaterBackQryCmd cmd) {
if (Objects.nonNull(cmd.getLimit()) && cmd.getLimit() > 0) {