From 5e5748b521057916e99f38299874e844096d7bc2 Mon Sep 17 00:00:00 2001 From: Timi Date: Thu, 13 Aug 2026 00:46:32 +0800 Subject: [PATCH] add customer in gao point ledger list api --- .../modules/gao/entity/GaoPointLedger.java | 5 ++++ .../GaoPointLedgerServiceImplement.java | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointLedger.java b/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointLedger.java index 550c558..1e63444 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointLedger.java +++ b/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointLedger.java @@ -1,6 +1,7 @@ package com.imyeyu.api.modules.gao.entity; import com.fasterxml.jackson.databind.JsonNode; +import com.imyeyu.spring.annotation.table.Transient; import com.imyeyu.spring.entity.UUIDEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -83,4 +84,8 @@ public class GaoPointLedger extends UUIDEntity { /// 发生时间 private Long occurredAt; + + /// 客户信息 + @Transient + private GaoCustomer customer; } diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointLedgerServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointLedgerServiceImplement.java index 8b55c00..76b8b7e 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointLedgerServiceImplement.java +++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointLedgerServiceImplement.java @@ -2,11 +2,15 @@ package com.imyeyu.api.modules.gao.service.implement; import com.fasterxml.jackson.databind.JsonNode; import com.imyeyu.api.config.dbsource.TimiServerDBConfig; +import com.imyeyu.api.modules.common.entity.Attachment; +import com.imyeyu.api.modules.common.service.AttachmentService; +import com.imyeyu.api.modules.gao.entity.GaoCustomer; import com.imyeyu.api.modules.gao.entity.GaoPointAccount; import com.imyeyu.api.modules.gao.entity.GaoPointLedger; import com.imyeyu.api.modules.gao.entity.GaoPointRule; import com.imyeyu.api.modules.gao.entity.GaoEventRecord; import com.imyeyu.api.modules.gao.mapper.GaoPointLedgerMapper; +import com.imyeyu.api.modules.gao.service.GaoCustomerService; import com.imyeyu.api.modules.gao.service.GaoPointAccountService; import com.imyeyu.api.modules.gao.service.GaoPointLedgerService; import com.imyeyu.api.modules.gao.vo.GaoPointAdjustRequest; @@ -23,6 +27,9 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; +import java.util.Map; + /// GAO 客户积分流水服务实现 /// /// @author Codex @@ -33,6 +40,8 @@ public class GaoPointLedgerServiceImplement extends AbstractEntityService result = new PageResult<>(); result.setTotal(mapper.countByQuery(page)); result.setList(mapper.selectByQuery(page)); + fillCustomer(result.getList()); return result; } + private void fillCustomer(List ledgerList) { + List customerIdList = ledgerList.stream().map(GaoPointLedger::getCustomerId).filter(TimiJava::isNotEmpty).distinct().toList(); + if (customerIdList.isEmpty()) { + return; + } + + Map customerMap = customerService.mapByIdList(customerIdList); + Map> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList); + for (GaoPointLedger ledger : ledgerList) { + GaoCustomer customer = customerMap.get(ledger.getCustomerId()); + if (customer == null) { + continue; + } + customer.setAttachmentList(attachmentMap.get(customer.getId())); + ledger.setCustomer(customer); + } + } + private GaoPointLedger apply(String storeId, String customerId, GaoPointLedger.ChangeType changeType, long pointDelta, String ruleId, String eventId, String eventRecordId, JsonNode sourcePayload, String idempotencyKey, String remark, String operatorUserId, Long occurredAt) { GaoPointLedger existing = mapper.selectByIdempotencyKey(idempotencyKey); if (existing != null) {