From 3994d99321095552dd9995fb07184693e87a1e0d Mon Sep 17 00:00:00 2001 From: dzq Date: Sat, 26 Apr 2025 16:09:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(cabinet):=20=E5=9C=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=B8=AD=E5=A2=9E=E5=8A=A0=E6=8C=89cell=5Fid=E5=88=86?= =?UTF-8?q?=E7=BB=84=E4=BB=A5=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在SearchCabinetCellWithOrdersQuery中增加groupBy语句,确保查询结果按cell_id分组,避免重复数据展示。同时,将CabinetCellController和CabinetCellApplicationService中的查询类型统一为SearchCabinetCellWithOrdersQuery,以保持一致性。 --- .../cabinet/CabinetCellController.java | 3 ++- .../cell/CabinetCellApplicationService.java | 3 ++- .../query/SearchCabinetCellWithOrdersQuery.java | 3 ++- .../shop/payment/PaymentApplicationService.java | 17 +++++++++++++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/CabinetCellController.java b/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/CabinetCellController.java index da7ed3e..f48e6cc 100644 --- a/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/CabinetCellController.java +++ b/agileboot-admin/src/main/java/com/agileboot/admin/controller/cabinet/CabinetCellController.java @@ -11,6 +11,7 @@ import com.agileboot.domain.cabinet.cell.command.UpdateCabinetCellCommand; import com.agileboot.domain.cabinet.cell.db.CabinetCellEntity; import com.agileboot.domain.cabinet.cell.dto.CabinetCellDTO; import com.agileboot.domain.cabinet.cell.query.SearchCabinetCellQuery; +import com.agileboot.domain.cabinet.cell.query.SearchCabinetCellWithOrdersQuery; import com.agileboot.domain.common.command.BulkOperationCommand; import io.swagger.v3.oas.annotations.Operation; import java.util.List; @@ -38,7 +39,7 @@ public class CabinetCellController extends BaseController { @Operation(summary = "格口列表") @GetMapping - public ResponseDTO> list(SearchCabinetCellQuery query) { + public ResponseDTO> list(SearchCabinetCellWithOrdersQuery query) { PageDTO page = cabinetCellApplicationService.getCabinetCellList(query); return ResponseDTO.ok(page); } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/CabinetCellApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/CabinetCellApplicationService.java index c513622..abb1f21 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/CabinetCellApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/CabinetCellApplicationService.java @@ -2,6 +2,7 @@ package com.agileboot.domain.cabinet.cell; import com.agileboot.common.core.page.PageDTO; import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO; +import com.agileboot.domain.cabinet.cell.query.SearchCabinetCellWithOrdersQuery; import com.agileboot.domain.common.command.BulkOperationCommand; import com.agileboot.domain.cabinet.cell.command.AddCabinetCellCommand; import com.agileboot.domain.cabinet.cell.command.UpdateCabinetCellCommand; @@ -29,7 +30,7 @@ public class CabinetCellApplicationService { private final CabinetCellModelFactory cabinetCellModelFactory; private final ShopGoodsService shopGoodsService; - public PageDTO getCabinetCellList(SearchCabinetCellQuery query) { + public PageDTO getCabinetCellList(SearchCabinetCellWithOrdersQuery query) { // Page page = cabinetCellService.getCellList(query); Page page = cabinetCellService.getCellListWithOrders(query); List goodsList = shopGoodsService.selectAll(); diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/query/SearchCabinetCellWithOrdersQuery.java b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/query/SearchCabinetCellWithOrdersQuery.java index 49e5313..008b4ab 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/query/SearchCabinetCellWithOrdersQuery.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/cabinet/cell/query/SearchCabinetCellWithOrdersQuery.java @@ -31,7 +31,8 @@ public class SearchCabinetCellWithOrdersQuery extends AbstractPageQuery { .eq(usageStatus != null, "cc.usage_status", usageStatus) .eq(availableStatus != null, "cc.available_status", availableStatus) .eq("cc.deleted", false) - .between(startTime != null && endTime != null, "cc.create_time", startTime, endTime); + .between(startTime != null && endTime != null, "cc.create_time", startTime, endTime) + .groupBy("cc.cell_id"); this.timeRangeColumn = "create_time"; diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/payment/PaymentApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/payment/PaymentApplicationService.java index 422320b..ff5849c 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/payment/PaymentApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/payment/PaymentApplicationService.java @@ -15,10 +15,13 @@ import com.agileboot.common.utils.OpenSignUtil; import com.agileboot.domain.shop.order.model.OrderModel; import com.agileboot.domain.shop.order.model.OrderModelFactory; import com.agileboot.domain.shop.payment.dto.*; +import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService; +import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.stereotype.Service; import java.net.URLEncoder; @@ -32,13 +35,16 @@ import java.util.UUID; @RequiredArgsConstructor public class PaymentApplicationService { private final OrderModelFactory orderModelFactory; + private final PaymentOperationLogApplicationService paymentOperationLogApplicationService; private static final Object LOCKER = new Object(); public WxJsApiPreCreateResponse callJsApiPreCreate(WxJsApiPreCreateRequest request) { String gatewayUrl = PayApiConstants.pay_url; + String result = ""; + String jsonBody = ""; try { - String jsonBody = JSONUtil.toJsonStr(request); + jsonBody = JSONUtil.toJsonStr(request); log.info("callJsApiPreCreate 请求body:{}", jsonBody); // 使用try-with-resources自动关闭连接 @@ -50,7 +56,7 @@ public class PaymentApplicationService { // 获取HTTP状态码和响应体 int status = httpResponse.getStatus(); - String result = httpResponse.body(); + result = httpResponse.body(); log.info("callJsApiPreCreate 响应body:{}", result); // 先校验HTTP状态码 @@ -74,6 +80,13 @@ public class PaymentApplicationService { } } catch (Exception e) { + AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand(); + paymentOperationLogCommand.setParams("body:" + jsonBody + " result:" + result); + paymentOperationLogCommand.setOperationType("submitOrder"); + paymentOperationLogCommand.setStatus(2); + paymentOperationLogCommand.setRemark(ExceptionUtils.getStackTrace(e)); + paymentOperationLogCommand.initBaseEntity(); + paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand); throw new RuntimeException("支付网关调用失败:" + e.getLocalizedMessage(), e); } }