feat: enrich withdrawal audit info
This commit is contained in:
@@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.starry.admin.common.exception.CustomException;
|
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.module.entity.PlayOrderInfoEntity;
|
||||||
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
|
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
|
||||||
import com.starry.admin.modules.withdraw.entity.EarningsBackfillLogEntity;
|
import com.starry.admin.modules.withdraw.entity.EarningsBackfillLogEntity;
|
||||||
@@ -36,6 +40,7 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -59,6 +64,10 @@ public class AdminWithdrawalController {
|
|||||||
private IEarningsBackfillLogService backfillLogService;
|
private IEarningsBackfillLogService backfillLogService;
|
||||||
@Resource
|
@Resource
|
||||||
private IPlayOrderInfoService orderInfoService;
|
private IPlayOrderInfoService orderInfoService;
|
||||||
|
@Resource
|
||||||
|
private IPlayClerkUserInfoService clerkUserInfoService;
|
||||||
|
@Resource
|
||||||
|
private IPlayCustomUserInfoService customUserInfoService;
|
||||||
|
|
||||||
@ApiOperation("分页查询提现请求")
|
@ApiOperation("分页查询提现请求")
|
||||||
@PostMapping("/requests/listByPage")
|
@PostMapping("/requests/listByPage")
|
||||||
@@ -112,7 +121,39 @@ public class AdminWithdrawalController {
|
|||||||
.in(PlayOrderInfoEntity::getId, orderIds)
|
.in(PlayOrderInfoEntity::getId, orderIds)
|
||||||
.list()
|
.list()
|
||||||
.stream()
|
.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());
|
List<ClerkEarningLineVo> vos = new ArrayList<>(lines.size());
|
||||||
for (EarningsLineEntity line : lines) {
|
for (EarningsLineEntity line : lines) {
|
||||||
@@ -131,6 +172,22 @@ public class AdminWithdrawalController {
|
|||||||
vo.setOrderNo(order.getOrderNo());
|
vo.setOrderNo(order.getOrderNo());
|
||||||
vo.setOrderStatus(order.getOrderStatus());
|
vo.setOrderStatus(order.getOrderStatus());
|
||||||
vo.setOrderEndTime(toLocalDateTime(order.getOrderEndTime()));
|
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);
|
vos.add(vo);
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ public class ClerkEarningLineVo {
|
|||||||
private String orderNo;
|
private String orderNo;
|
||||||
private String orderStatus;
|
private String orderStatus;
|
||||||
|
|
||||||
|
private String orderCustomerId;
|
||||||
|
private String orderCustomerNickname;
|
||||||
|
private String orderClerkId;
|
||||||
|
private String orderClerkNickname;
|
||||||
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private LocalDateTime orderEndTime;
|
private LocalDateTime orderEndTime;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.starry.admin.common.apitest.ApiTestDataSeeder;
|
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.module.entity.PlayOrderInfoEntity;
|
||||||
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
|
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
|
||||||
import com.starry.admin.modules.withdraw.entity.EarningsLineEntity;
|
import com.starry.admin.modules.withdraw.entity.EarningsLineEntity;
|
||||||
@@ -40,6 +42,10 @@ class AdminWithdrawalControllerApiTest extends AbstractApiTest {
|
|||||||
private IWithdrawalService withdrawalService;
|
private IWithdrawalService withdrawalService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPlayOrderInfoService orderInfoService;
|
private IPlayOrderInfoService orderInfoService;
|
||||||
|
@Autowired
|
||||||
|
private IPlayClerkUserInfoService clerkUserInfoService;
|
||||||
|
@Autowired
|
||||||
|
private IPlayCustomUserInfoService customUserInfoService;
|
||||||
|
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
private final List<String> earningsToCleanup = new ArrayList<>();
|
private final List<String> earningsToCleanup = new ArrayList<>();
|
||||||
@@ -83,6 +89,9 @@ class AdminWithdrawalControllerApiTest extends AbstractApiTest {
|
|||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
JsonNode data = objectMapper.readTree(result.getResponse().getContentAsString()).get("data");
|
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 foundOrder = false;
|
||||||
boolean foundMissing = false;
|
boolean foundMissing = false;
|
||||||
for (JsonNode node : data) {
|
for (JsonNode node : data) {
|
||||||
@@ -90,6 +99,10 @@ class AdminWithdrawalControllerApiTest extends AbstractApiTest {
|
|||||||
if (order.getOrderNo().equals(orderNo)) {
|
if (order.getOrderNo().equals(orderNo)) {
|
||||||
Assertions.assertThat(node.path("orderStatus").asText()).isEqualTo(order.getOrderStatus());
|
Assertions.assertThat(node.path("orderStatus").asText()).isEqualTo(order.getOrderStatus());
|
||||||
Assertions.assertThat(node.path("earningType").asText()).isEqualTo(EarningsType.ORDER.name());
|
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;
|
foundOrder = true;
|
||||||
}
|
}
|
||||||
if (node.path("orderNo").isNull()) {
|
if (node.path("orderNo").isNull()) {
|
||||||
@@ -151,7 +164,11 @@ class AdminWithdrawalControllerApiTest extends AbstractApiTest {
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
.andExpect(jsonPath("$.data[0].orderNo").value(nullValue()))
|
.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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user