feat: enrich withdrawal audit info

This commit is contained in:
irving
2025-11-08 20:09:07 -05:00
parent 438aef7af7
commit 7d07e32271
3 changed files with 81 additions and 2 deletions

View File

@@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
import com.starry.admin.modules.withdraw.entity.EarningsBackfillLogEntity;
@@ -36,6 +40,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
@@ -59,6 +64,10 @@ public class AdminWithdrawalController {
private IEarningsBackfillLogService backfillLogService;
@Resource
private IPlayOrderInfoService orderInfoService;
@Resource
private IPlayClerkUserInfoService clerkUserInfoService;
@Resource
private IPlayCustomUserInfoService customUserInfoService;
@ApiOperation("分页查询提现请求")
@PostMapping("/requests/listByPage")
@@ -112,7 +121,39 @@ public class AdminWithdrawalController {
.in(PlayOrderInfoEntity::getId, orderIds)
.list()
.stream()
.collect(Collectors.toMap(PlayOrderInfoEntity::getId, it -> it));
.collect(Collectors.toMap(PlayOrderInfoEntity::getId, Function.identity()));
Map<String, PlayClerkUserInfoEntity> clerkMap = Collections.emptyMap();
Map<String, PlayCustomUserInfoEntity> customerMap = Collections.emptyMap();
if (!orderMap.isEmpty()) {
List<String> clerkIds = orderMap.values().stream()
.map(PlayOrderInfoEntity::getAcceptBy)
.filter(clerkIdValue -> clerkIdValue != null && !clerkIdValue.isEmpty())
.distinct()
.collect(Collectors.toList());
if (!clerkIds.isEmpty()) {
clerkMap = clerkUserInfoService.lambdaQuery()
.eq(PlayClerkUserInfoEntity::getTenantId, tenantId)
.in(PlayClerkUserInfoEntity::getId, clerkIds)
.list()
.stream()
.collect(Collectors.toMap(PlayClerkUserInfoEntity::getId, Function.identity()));
}
List<String> customerIds = orderMap.values().stream()
.map(PlayOrderInfoEntity::getPurchaserBy)
.filter(customerIdValue -> customerIdValue != null && !customerIdValue.isEmpty())
.distinct()
.collect(Collectors.toList());
if (!customerIds.isEmpty()) {
customerMap = customUserInfoService.lambdaQuery()
.eq(PlayCustomUserInfoEntity::getTenantId, tenantId)
.in(PlayCustomUserInfoEntity::getId, customerIds)
.list()
.stream()
.collect(Collectors.toMap(PlayCustomUserInfoEntity::getId, Function.identity()));
}
}
List<ClerkEarningLineVo> vos = new ArrayList<>(lines.size());
for (EarningsLineEntity line : lines) {
@@ -131,6 +172,22 @@ public class AdminWithdrawalController {
vo.setOrderNo(order.getOrderNo());
vo.setOrderStatus(order.getOrderStatus());
vo.setOrderEndTime(toLocalDateTime(order.getOrderEndTime()));
String clerkId = order.getAcceptBy();
if (clerkId != null && !clerkId.isEmpty()) {
vo.setOrderClerkId(clerkId);
PlayClerkUserInfoEntity clerk = clerkMap.get(clerkId);
if (clerk != null) {
vo.setOrderClerkNickname(clerk.getNickname());
}
}
String customerId = order.getPurchaserBy();
if (customerId != null && !customerId.isEmpty()) {
vo.setOrderCustomerId(customerId);
PlayCustomUserInfoEntity customer = customerMap.get(customerId);
if (customer != null) {
vo.setOrderCustomerNickname(customer.getNickname());
}
}
}
}
vos.add(vo);

View File

@@ -27,6 +27,11 @@ public class ClerkEarningLineVo {
private String orderNo;
private String orderStatus;
private String orderCustomerId;
private String orderCustomerNickname;
private String orderClerkId;
private String orderClerkNickname;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime orderEndTime;

View File

@@ -8,6 +8,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.starry.admin.common.apitest.ApiTestDataSeeder;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
import com.starry.admin.modules.withdraw.entity.EarningsLineEntity;
@@ -40,6 +42,10 @@ class AdminWithdrawalControllerApiTest extends AbstractApiTest {
private IWithdrawalService withdrawalService;
@Autowired
private IPlayOrderInfoService orderInfoService;
@Autowired
private IPlayClerkUserInfoService clerkUserInfoService;
@Autowired
private IPlayCustomUserInfoService customUserInfoService;
private final ObjectMapper objectMapper = new ObjectMapper();
private final List<String> earningsToCleanup = new ArrayList<>();
@@ -83,6 +89,9 @@ class AdminWithdrawalControllerApiTest extends AbstractApiTest {
.andReturn();
JsonNode data = objectMapper.readTree(result.getResponse().getContentAsString()).get("data");
String expectedClerkNickname = clerkUserInfoService.selectById(ApiTestDataSeeder.DEFAULT_CLERK_ID).getNickname();
String expectedCustomerNickname = customUserInfoService.selectById(ApiTestDataSeeder.DEFAULT_CUSTOMER_ID).getNickname();
boolean foundOrder = false;
boolean foundMissing = false;
for (JsonNode node : data) {
@@ -90,6 +99,10 @@ class AdminWithdrawalControllerApiTest extends AbstractApiTest {
if (order.getOrderNo().equals(orderNo)) {
Assertions.assertThat(node.path("orderStatus").asText()).isEqualTo(order.getOrderStatus());
Assertions.assertThat(node.path("earningType").asText()).isEqualTo(EarningsType.ORDER.name());
Assertions.assertThat(node.path("orderClerkId").asText()).isEqualTo(ApiTestDataSeeder.DEFAULT_CLERK_ID);
Assertions.assertThat(node.path("orderClerkNickname").asText()).isEqualTo(expectedClerkNickname);
Assertions.assertThat(node.path("orderCustomerId").asText()).isEqualTo(ApiTestDataSeeder.DEFAULT_CUSTOMER_ID);
Assertions.assertThat(node.path("orderCustomerNickname").asText()).isEqualTo(expectedCustomerNickname);
foundOrder = true;
}
if (node.path("orderNo").isNull()) {
@@ -151,7 +164,11 @@ class AdminWithdrawalControllerApiTest extends AbstractApiTest {
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.data[0].orderNo").value(nullValue()))
.andExpect(jsonPath("$.data[0].orderId").value(orphanOrderId));
.andExpect(jsonPath("$.data[0].orderId").value(orphanOrderId))
.andExpect(jsonPath("$.data[0].orderClerkId").value(nullValue()))
.andExpect(jsonPath("$.data[0].orderClerkNickname").value(nullValue()))
.andExpect(jsonPath("$.data[0].orderCustomerId").value(nullValue()))
.andExpect(jsonPath("$.data[0].orderCustomerNickname").value(nullValue()));
}
@Test