From 9b90320985a781ab17cae38fac583ccb420e64a5 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 2 Jul 2023 12:55:15 +0800 Subject: [PATCH] =?UTF-8?q?mall=20+=20trade=EF=BC=9A=201=E3=80=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=85=8D=E9=80=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProductCommentServiceImplTest.java | 1 - .../enums/delivery/DeliveryTypeEnum.java | 1 + .../AppDeliverPickUpStoreController.java | 26 ++++++++++++++++--- .../app/order/AppTradeOrderController.java | 8 ++++++ .../order/vo/AppTradeOrderDetailRespVO.java | 3 +++ .../vo/AppTradeOrderSettlementReqVO.java | 2 +- .../dal/dataobject/order/TradeOrderDO.java | 16 ++++++------ .../service/order/TradeOrderServiceTest.java | 13 +++++----- 8 files changed, 50 insertions(+), 20 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java index 7684def99..8d3a3d5b8 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java +++ b/yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java @@ -151,7 +151,6 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { // 测试分页 tab count AppCommentStatisticsRespVO tabsCount = productCommentService.getCommentStatistics(spuId, Boolean.TRUE); - assertEquals(6, tabsCount.getAllCount()); assertEquals(4, tabsCount.getGoodCount()); assertEquals(2, tabsCount.getMediocreCount()); assertEquals(0, tabsCount.getNegativeCount()); diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java index 210f5c307..7754f115d 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java @@ -15,6 +15,7 @@ import java.util.Arrays; @AllArgsConstructor public enum DeliveryTypeEnum implements IntArrayValuable { + NULL(0, "无需物流"), EXPRESS(1, "快递发货"), PICK_UP(2, "用户自提"),; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java index 4803b17c4..275eacde8 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; @@ -17,7 +18,7 @@ import java.util.Random; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -@Tag(name = "用户 App - 门店自提") +@Tag(name = "用户 App - 自提门店") @RestController @RequestMapping("/trade/delivery/pick-up-store") @Validated @@ -37,8 +38,8 @@ public class AppDeliverPickUpStoreController { store.setLogo("https://www.iocoder.cn/" + (i + 1) + ".png"); store.setPhone("15601691300"); store.setAreaId(random.nextInt(100000)); - store.setAreaName(RandomUtil.randomString(10)); - store.setDetailAddress(RandomUtil.randomString(10)); + store.setAreaName("上海-" + RandomUtil.randomString(10)); + store.setDetailAddress("普陀区-" + RandomUtil.randomString(10)); store.setLatitude(random.nextDouble() * 10); store.setLongitude(random.nextDouble() * 10); store.setDistance(random.nextInt(1000)); @@ -49,4 +50,23 @@ public class AppDeliverPickUpStoreController { return success(list); } + @GetMapping("/get") + @Operation(summary = "获得自提门店") + @Parameter(name = "id", description = "门店编号") + public CommonResult getOrder(@RequestParam("id") Long id) { + AppDeliveryPickUpStoreRespVO store = new AppDeliveryPickUpStoreRespVO(); + Random random = new Random(); + store.setId(random.nextLong()); + store.setName(RandomUtil.randomString(10)); + store.setLogo("https://www.iocoder.cn/" + (1) + ".png"); + store.setPhone("15601691300"); + store.setAreaId(random.nextInt(100000)); + store.setAreaName("上海-" + RandomUtil.randomString(10)); + store.setDetailAddress("普陀区-" + RandomUtil.randomString(10)); + store.setLatitude(random.nextDouble() * 10); + store.setLongitude(random.nextDouble() * 10); + store.setDistance(random.nextInt(1000)); + return success(store); + } + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java index 908850d76..6567e3169 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java @@ -127,6 +127,14 @@ public class AppTradeOrderController { return success(orderCount); } + @PutMapping("/take") + @Operation(summary = "确认交易订单收货") + @Parameter(name = "id", description = "交易订单编号") + public CommonResult takeOrder(@RequestParam("id") Long id) { + // TODO @芋艿:未实现,mock 用 + return success(true); + } + @DeleteMapping("/cancel") @Operation(summary = "取消交易订单") @Parameter(name = "id", description = "交易订单编号") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java index f0915e27e..f9e6a6864 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java @@ -102,6 +102,9 @@ public class AppTradeOrderDetailRespVO { @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "中关村大街 1 号") private String receiverDetailAddress; + @Schema(description = "自提门店编号", example = "1088") + private Long pickUpStoreId; + // ========== 售后基本信息 ========== // ========== 营销基本信息 ========== diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java index 9c0623fed..f3a7d9120 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java @@ -44,7 +44,7 @@ public class AppTradeOrderSettlementReqVO { private Long addressId; @Schema(description = "自提门店编号", example = "1088") - private Long pickupStoreId; + private Long pickUpStoreId; @Schema(description = "收件人名称", example = "芋艿") // 选择门店自提时,该字段为联系人名 private String receiverName; @Schema(description = "收件人手机", example = "15601691300") // 选择门店自提时,该字段为联系人手机 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java index 0a4d2c25c..011e8546f 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order; import cn.iocoder.yudao.framework.common.enums.TerminalEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; import cn.iocoder.yudao.module.trade.enums.order.*; import com.baomidou.mybatisplus.annotation.KeySequence; @@ -171,13 +172,6 @@ public class TradeOrderDO extends BaseDO { * 枚举 {@link DeliveryTypeEnum} */ private Integer deliveryType; - /** - * 配置模板的编号 - * - * 关联 DeliveryTemplateDO 的 id 编号 - */ - // TODO 芋艿:需要删除 - private Long deliveryTemplateId; /** * 发货物流公司编号 */ @@ -197,7 +191,6 @@ public class TradeOrderDO extends BaseDO { */ private LocalDateTime deliveryTime; - // TODO @芋艿:pickUpStoreId; /** * 收货时间 */ @@ -219,6 +212,13 @@ public class TradeOrderDO extends BaseDO { */ private String receiverDetailAddress; + /** + * 自提门店编号 + * + * 关联 {@link DeliveryPickUpStoreDO#getId()} + */ + private Long pickUpStoreId; + // ========== 售后基本信息 ========== /** * 售后状态 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java index 184d1c178..9401f4caf 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java @@ -115,7 +115,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest { when(productSpuApi.getSpuList(eq(asSet(11L, 21L)))).thenReturn(Arrays.asList(spu01, spu02)); // mock 方法(用户收件地址的校验) AddressRespDTO addressRespDTO = new AddressRespDTO().setId(10L).setUserId(userId).setName("芋艿") - .setMobile("15601691300").setAreaId(3306).setPostCode("85757").setDetailAddress("土豆村"); + .setMobile("15601691300").setAreaId(3306).setDetailAddress("土豆村"); when(addressApi.getAddress(eq(10L), eq(userId))).thenReturn(addressRespDTO); // mock 方法(价格计算) PriceCalculateRespDTO.OrderItem priceOrderItem01 = new PriceCalculateRespDTO.OrderItem() @@ -150,12 +150,12 @@ public class TradeOrderServiceTest extends BaseDbUnitTest { }))).thenReturn(1000L); // 调用方法 - Long tradeOrderId = tradeOrderService.createOrder(userId, userIp, reqVO); + TradeOrderDO order = tradeOrderService.createOrder(userId, userIp, reqVO); // 断言 TradeOrderDO 订单 List tradeOrderDOs = tradeOrderMapper.selectList(); assertEquals(tradeOrderDOs.size(), 1); TradeOrderDO tradeOrderDO = tradeOrderDOs.get(0); - assertEquals(tradeOrderDO.getId(), tradeOrderId); + assertEquals(tradeOrderDO.getId(), order.getId()); assertNotNull(tradeOrderDO.getNo()); assertEquals(tradeOrderDO.getType(), TradeOrderTypeEnum.NORMAL.getType()); assertEquals(tradeOrderDO.getTerminal(), TerminalEnum.H5.getTerminal()); @@ -176,7 +176,6 @@ public class TradeOrderServiceTest extends BaseDbUnitTest { assertEquals(tradeOrderDO.getPayPrice(), 80); assertEquals(tradeOrderDO.getPayOrderId(), 1000L); assertNull(tradeOrderDO.getPayChannelCode()); - assertNull(tradeOrderDO.getDeliveryTemplateId()); assertNull(tradeOrderDO.getLogisticsId()); assertEquals(tradeOrderDO.getDeliveryStatus(), TradeOrderDeliveryStatusEnum.UNDELIVERED.getStatus()); assertNull(tradeOrderDO.getDeliveryTime()); @@ -195,7 +194,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest { TradeOrderItemDO tradeOrderItemDO01 = tradeOrderItemDOs.get(0); assertNotNull(tradeOrderItemDO01.getId()); assertEquals(tradeOrderItemDO01.getUserId(), userId); - assertEquals(tradeOrderItemDO01.getOrderId(), tradeOrderId); + assertEquals(tradeOrderItemDO01.getOrderId(), order.getId()); assertEquals(tradeOrderItemDO01.getSpuId(), 11L); assertEquals(tradeOrderItemDO01.getSkuId(), 1L); assertEquals(tradeOrderItemDO01.getProperties().size(), 1); @@ -213,7 +212,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest { TradeOrderItemDO tradeOrderItemDO02 = tradeOrderItemDOs.get(1); assertNotNull(tradeOrderItemDO02.getId()); assertEquals(tradeOrderItemDO02.getUserId(), userId); - assertEquals(tradeOrderItemDO02.getOrderId(), tradeOrderId); + assertEquals(tradeOrderItemDO02.getOrderId(), order.getId()); assertEquals(tradeOrderItemDO02.getSpuId(), 21L); assertEquals(tradeOrderItemDO02.getSkuId(), 2L); assertEquals(tradeOrderItemDO02.getProperties().size(), 1); @@ -239,7 +238,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest { verify(couponApi).useCoupon(argThat(reqDTO -> { assertEquals(reqDTO.getId(), reqVO.getCouponId()); assertEquals(reqDTO.getUserId(), userId); - assertEquals(reqDTO.getOrderId(), tradeOrderId); + assertEquals(reqDTO.getOrderId(), order.getId()); return true; })); }