diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoCustomerController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoCustomerController.java index ee984b0..260ea13 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoCustomerController.java +++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoCustomerController.java @@ -100,7 +100,7 @@ public class GaoCustomerController { @RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE) @PostMapping("/update") public void update(@RequestBody GaoCustomer customer) { - service.update(customer); + service.updateWithAttachment(customer); } @AOPLog diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventRecordController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventRecordController.java index e79352b..427c534 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventRecordController.java +++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoEventRecordController.java @@ -93,11 +93,24 @@ public class GaoEventRecordController { @AOPLog @RequestRateLimit @PostMapping("/create") - @JsonView(ResponseView.Public.class) public void create(@RequestBody GaoEventRecord record) { service.create(record); } + @AOPLog + @RequestRateLimit + @PostMapping("/create/batch") + public void createBatch(@RequestBody List recordList) { + service.createBatch(recordList); + } + + @AOPLog + @RequestRateLimit + @PostMapping("/create/customer") + public void createWithCustomer(@RequestBody GaoCustomer customer) { + service.createWithCustomer(customer); + } + @AOPLog @RequestRateLimit @RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_UPDATE) diff --git a/src/main/java/com/imyeyu/api/modules/gao/entity/GaoCustomer.java b/src/main/java/com/imyeyu/api/modules/gao/entity/GaoCustomer.java index 9a5b573..af788d8 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/entity/GaoCustomer.java +++ b/src/main/java/com/imyeyu/api/modules/gao/entity/GaoCustomer.java @@ -99,6 +99,9 @@ public class GaoCustomer extends UUIDEntity { @Transient private GaoEventRecord eventRecord; + @Transient + private List eventRecordList; + public boolean hasIntroducer() { return TimiJava.isNotEmpty(introducerCustomerId); } diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoCustomerService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoCustomerService.java index f544164..b9b0ca0 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoCustomerService.java +++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoCustomerService.java @@ -19,6 +19,8 @@ import java.util.stream.Collectors; /// @since 2026-07-27 14:12 public interface GaoCustomerService extends BaseService { + void updateWithAttachment(GaoCustomer customer); + /// 按编码查询客户 /// /// @param code 客户编码 diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoEventRecordService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoEventRecordService.java index 3ad884f..3fb4fb8 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoEventRecordService.java +++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoEventRecordService.java @@ -1,13 +1,16 @@ package com.imyeyu.api.modules.gao.service; +import com.imyeyu.api.modules.gao.entity.GaoCustomer; import com.imyeyu.api.modules.gao.entity.GaoEventRecord; import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView; import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage; import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage; +import com.imyeyu.java.TimiJava; import com.imyeyu.spring.bean.PageResult; import com.imyeyu.spring.service.BaseService; import java.io.IOException; +import java.util.List; /// 登记事件记录服务 /// @@ -15,6 +18,14 @@ import java.io.IOException; /// @since 2026-07-27 14:09 public interface GaoEventRecordService extends BaseService { + default void createBatch(List recordList) { + for (GaoEventRecord record : TimiJava.safeIterable(recordList)) { + create(record); + } + } + + void createWithCustomer(GaoCustomer customer); + /// 按任意时间范围查询登记事件记录 /// /// @param req 范围查询请求 diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java index f268ac7..9053b0a 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java +++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java @@ -146,10 +146,8 @@ public class GaoCustomerServiceImplement extends AbstractEntityService customerIdList = TimiJava.defaultIfEmpty(record.getCustomerIdList(), List.of(record.getCustomerId())); - if (TimiJava.isNotEmpty(record.getCustomer())) { - // 客户未创建,补录客户后登记 - customerService.create(record.getCustomer()); - customerIdList.add(record.getCustomer().getId()); - } TimiException.required(customerIdList, "not found customerId or empty customerIdList"); GaoEventRecord firstRecord = null; @@ -171,6 +167,34 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService pageByRange(GaoEventRecordPage page) { PageResult result = new PageResult<>();