Commit 7fef594390687955ba85d220d06d108131b06a54
1 parent
c21e8886
订单接口的梳理
Showing
24 changed files
with
344 additions
and
291 deletions
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java
| ... | ... | @@ -49,7 +49,7 @@ public interface ErrorCodeConstants { |
| 49 | 49 | ErrorCode COMMENT_ADDITIONAL_EXISTS = new ErrorCode(1008007003, "商品追加评价已存在"); |
| 50 | 50 | |
| 51 | 51 | // ========== 商品 收藏 1008008000 ========== |
| 52 | - ErrorCode PRODUCT_FAVORITE_EXISTS = new ErrorCode(1008008000, "该商品已经被收藏"); | |
| 53 | - ErrorCode PRODUCT_FAVORITE_NOT_EXISTS = new ErrorCode(1008008001, "商品收藏不存在"); | |
| 52 | + ErrorCode FAVORITE_EXISTS = new ErrorCode(1008008000, "该商品已经被收藏"); | |
| 53 | + ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1008008001, "商品收藏不存在"); | |
| 54 | 54 | |
| 55 | 55 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/delivery/PickUpStoreDO.java
| 1 | 1 | package cn.iocoder.yudao.module.product.dal.dataobject.delivery; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 5 | -import com.baomidou.mybatisplus.annotation.TableField; | |
| 6 | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 7 | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| 8 | 8 | import lombok.Data; |
| 9 | 9 | |
| 10 | 10 | import java.time.LocalTime; |
| 11 | 11 | |
| 12 | +// TODO @Jason:DeliveryPickUpStoreDO | |
| 12 | 13 | /** |
| 13 | 14 | * 自提门店 DO |
| 14 | 15 | * |
| ... | ... | @@ -18,6 +19,7 @@ import java.time.LocalTime; |
| 18 | 19 | @KeySequence("pick_up_store_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 19 | 20 | @Data |
| 20 | 21 | public class PickUpStoreDO extends BaseDO { |
| 22 | + | |
| 21 | 23 | /** |
| 22 | 24 | * 编号,自增 |
| 23 | 25 | */ |
| ... | ... | @@ -40,17 +42,18 @@ public class PickUpStoreDO extends BaseDO { |
| 40 | 42 | private String phone; |
| 41 | 43 | |
| 42 | 44 | /** |
| 43 | - * 区域id | |
| 45 | + * 区域 id | |
| 44 | 46 | */ |
| 45 | 47 | private Integer areaId; |
| 46 | 48 | |
| 49 | + // TODO Jason:改成 detailAddress,主要和 AddressDO 保持一致哈 | |
| 47 | 50 | /** |
| 48 | 51 | * 门店详细地址 |
| 49 | 52 | */ |
| 50 | 53 | private String address; |
| 51 | 54 | |
| 52 | 55 | /** |
| 53 | - * 门店logo | |
| 56 | + * 门店 logo | |
| 54 | 57 | */ |
| 55 | 58 | private String logo; |
| 56 | 59 | |
| ... | ... | @@ -58,7 +61,6 @@ public class PickUpStoreDO extends BaseDO { |
| 58 | 61 | * 营业开始时间 |
| 59 | 62 | */ |
| 60 | 63 | private LocalTime openingTime; |
| 61 | - | |
| 62 | 64 | /** |
| 63 | 65 | * 营业结束时间 |
| 64 | 66 | */ |
| ... | ... | @@ -68,18 +70,16 @@ public class PickUpStoreDO extends BaseDO { |
| 68 | 70 | * 纬度 |
| 69 | 71 | */ |
| 70 | 72 | private String latitude; |
| 71 | - | |
| 72 | 73 | /** |
| 73 | 74 | * 经度 |
| 74 | 75 | */ |
| 75 | 76 | private String longitude; |
| 76 | 77 | |
| 77 | 78 | /** |
| 78 | - * 门店状态(0正常 1停用) | |
| 79 | + * 门店状态 | |
| 80 | + * | |
| 81 | + * 枚举 {@link CommonStatusEnum} | |
| 79 | 82 | */ |
| 80 | 83 | private Integer status; |
| 81 | 84 | |
| 82 | - | |
| 83 | - @TableField(exist = false) | |
| 84 | - private static final long serialVersionUID = 1L; | |
| 85 | -} | |
| 86 | 85 | \ No newline at end of file |
| 86 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| ... | ... | @@ -2,14 +2,18 @@ package cn.iocoder.yudao.module.product.service.spu; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.util.ObjectUtil; |
| 5 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 6 | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 9 | +import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; | |
| 7 | 10 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 8 | 11 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; |
| 9 | 12 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 10 | 13 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 11 | 14 | import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; |
| 12 | 15 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 16 | +import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; | |
| 13 | 17 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 14 | 18 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 15 | 19 | import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; |
| ... | ... | @@ -180,8 +184,16 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 180 | 184 | |
| 181 | 185 | @Override |
| 182 | 186 | public PageResult<ProductSpuDO> getSpuPage(AppProductSpuPageReqVO pageReqVO) { |
| 183 | - //return productSpuMapper.selectPage(pageReqVO); TODO 有差异接口接受参数类型不对 | |
| 184 | - return null; | |
| 187 | + // 查找时,如果查找某个分类编号,则包含它的子分类。因为顶级分类不包含商品 | |
| 188 | + Set<Long> categoryIds = new HashSet<>(); | |
| 189 | + if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) { | |
| 190 | + categoryIds.add(pageReqVO.getCategoryId()); | |
| 191 | + List<ProductCategoryDO> categoryChildren = categoryService.getEnableCategoryList(new ProductCategoryListReqVO() | |
| 192 | + .setParentId(pageReqVO.getCategoryId()).setStatus(CommonStatusEnum.ENABLE.getStatus())); | |
| 193 | + categoryIds.addAll(CollectionUtils.convertList(categoryChildren, ProductCategoryDO::getId)); | |
| 194 | + } | |
| 195 | + // 分页查询 | |
| 196 | + return productSpuMapper.selectPage(pageReqVO, categoryIds); | |
| 185 | 197 | } |
| 186 | 198 | |
| 187 | 199 | @Override | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java
| ... | ... | @@ -23,8 +23,6 @@ public enum TradeOrderStatusEnum implements IntArrayValuable { |
| 23 | 23 | COMPLETED(30, "已完成"), |
| 24 | 24 | CANCELED(40, "已取消"); |
| 25 | 25 | |
| 26 | - // TODO 芋艿: TAKE("待核验"):虚拟订单需要核验商品 | |
| 27 | - | |
| 28 | 26 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderStatusEnum::getStatus).toArray(); |
| 29 | 27 | |
| 30 | 28 | /** | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java
| ... | ... | @@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | 6 | import java.time.LocalDateTime; |
| 7 | -import java.util.Date; | |
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 |
| ... | ... | @@ -118,9 +117,6 @@ public class TradeOrderBaseVO { |
| 118 | 117 | @Schema(description = "收件人地区编号", required = true, example = "110000") |
| 119 | 118 | private Integer receiverAreaId; |
| 120 | 119 | |
| 121 | - @Schema(description = "收件人邮编", required = true, example = "100000") | |
| 122 | - private Integer receiverPostCode; | |
| 123 | - | |
| 124 | 120 | @Schema(description = "收件人详细地址", required = true, example = "中关村大街 1 号") |
| 125 | 121 | private String receiverDetailAddress; |
| 126 | 122 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http
| 1 | -### /trade-order/confirm-create-order-info 基于商品,确认创建订单 | |
| 2 | -GET {{appApi}}/trade/order/get-create-info?items[0].skuId=1&items[0].count=1 | |
| 3 | -Authorization: Bearer {{user-access-token}} | |
| 1 | +### /trade-order/settlement 获得订单结算信息 | |
| 2 | +GET {{appApi}}/trade/order/settlement?cartIds=1 | |
| 3 | +Authorization: Bearer {{appToken}} | |
| 4 | 4 | tenant-id: {{appTenentId}} |
| 5 | 5 | |
| 6 | 6 | ### /trade-order/confirm-create-order-info-from-cart 基于购物车,确认创建订单 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
| ... | ... | @@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.trade.controller.app.order; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | |
| 6 | 5 | import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; |
| 7 | 6 | import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; |
| 8 | 7 | import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; |
| 9 | 8 | import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; |
| 9 | +import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; | |
| 10 | 10 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; |
| 11 | 11 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 12 | 12 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| ... | ... | @@ -21,7 +21,11 @@ import org.springframework.web.bind.annotation.*; |
| 21 | 21 | |
| 22 | 22 | import javax.annotation.Resource; |
| 23 | 23 | import javax.servlet.http.HttpServletRequest; |
| 24 | +import javax.validation.Valid; | |
| 25 | +import java.util.ArrayList; | |
| 26 | +import java.util.HashMap; | |
| 24 | 27 | import java.util.List; |
| 28 | +import java.util.Map; | |
| 25 | 29 | |
| 26 | 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 27 | 31 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| ... | ... | @@ -40,12 +44,78 @@ public class AppTradeOrderController { |
| 40 | 44 | @Resource |
| 41 | 45 | private ProductPropertyValueApi productPropertyValueApi; |
| 42 | 46 | |
| 43 | - @GetMapping("/get-create-info") | |
| 44 | - @Operation(summary = "基于商品,确认创建订单") | |
| 47 | + @GetMapping("/settlement") | |
| 48 | + @Operation(summary = "获得订单结算信息") | |
| 45 | 49 | @PreAuthenticated |
| 46 | - public CommonResult<AppTradeOrderGetCreateInfoRespVO> getOrderCreateInfo(AppTradeOrderCreateReqVO createReqVO) { | |
| 50 | + public CommonResult<AppTradeOrderSettlementRespVO> settlementOrder( | |
| 51 | + @Valid AppTradeOrderSettlementReqVO settlementReqVO) { | |
| 47 | 52 | // return success(tradeOrderService.getOrderConfirmCreateInfo(UserSecurityContextHolder.getUserId(), skuId, quantity, couponCardId)); |
| 48 | - return null; | |
| 53 | + AppTradeOrderSettlementRespVO settlement = new AppTradeOrderSettlementRespVO(); | |
| 54 | + | |
| 55 | + AppTradeOrderSettlementRespVO.Price price = new AppTradeOrderSettlementRespVO.Price(); | |
| 56 | + price.setOriginalPrice(1000); | |
| 57 | + price.setDeliveryPrice(200); | |
| 58 | + price.setCouponPrice(100); | |
| 59 | + price.setPointPrice(50); | |
| 60 | + price.setPayPrice(950); | |
| 61 | + | |
| 62 | + List<AppTradeOrderSettlementRespVO.Item> skus = new ArrayList<>(); | |
| 63 | + | |
| 64 | + AppTradeOrderSettlementRespVO.Item item1 = new AppTradeOrderSettlementRespVO.Item(); | |
| 65 | + item1.setCartId(1L); | |
| 66 | + item1.setSpuId(2048L); | |
| 67 | + item1.setSpuName("Apple iPhone 12"); | |
| 68 | + item1.setSkuId(1024); | |
| 69 | + item1.setPrice(500); | |
| 70 | + item1.setPicUrl("https://pro.crmeb.net/uploads/attach/2022/10/12/0c56f9abb80d2775fc1e80dbe4f8826a.jpg"); | |
| 71 | + item1.setCount(2); | |
| 72 | + List<AppProductPropertyValueDetailRespVO> properties1 = new ArrayList<>(); | |
| 73 | + AppProductPropertyValueDetailRespVO property1 = new AppProductPropertyValueDetailRespVO(); | |
| 74 | + property1.setPropertyId(1L); | |
| 75 | + property1.setPropertyName("尺寸"); | |
| 76 | + property1.setValueId(2L); | |
| 77 | + property1.setValueName("大"); | |
| 78 | + properties1.add(property1); | |
| 79 | + item1.setProperties(properties1); | |
| 80 | + | |
| 81 | + AppTradeOrderSettlementRespVO.Item item2 = new AppTradeOrderSettlementRespVO.Item(); | |
| 82 | + item2.setCartId(2L); | |
| 83 | + item2.setSpuId(3072L); | |
| 84 | + item2.setSpuName("Samsung Galaxy S21"); | |
| 85 | + item2.setSkuId(2048); | |
| 86 | + item2.setPrice(800); | |
| 87 | + item2.setPicUrl("https://pro.crmeb.net/uploads/attach/2022/10/12/0c56f9abb80d2775fc1e80dbe4f8826a.jpg"); | |
| 88 | + item2.setCount(1); | |
| 89 | + List<AppProductPropertyValueDetailRespVO> properties2 = new ArrayList<>(); | |
| 90 | + AppProductPropertyValueDetailRespVO property2 = new AppProductPropertyValueDetailRespVO(); | |
| 91 | + property2.setPropertyId(10L); | |
| 92 | + property2.setPropertyName("颜色"); | |
| 93 | + property2.setValueId(20L); | |
| 94 | + property2.setValueName("白色"); | |
| 95 | + properties2.add(property2); | |
| 96 | + item2.setProperties(properties2); | |
| 97 | + | |
| 98 | + skus.add(item1); | |
| 99 | + skus.add(item2); | |
| 100 | + | |
| 101 | + settlement.setItems(skus); | |
| 102 | + settlement.setPrice(price); | |
| 103 | + | |
| 104 | + AppTradeOrderSettlementRespVO.Address address = new AppTradeOrderSettlementRespVO.Address(); | |
| 105 | + address.setId(1L); | |
| 106 | + address.setName("John"); | |
| 107 | + address.setMobile("18888888888"); | |
| 108 | + address.setProvinceId(1L); | |
| 109 | + address.setProvinceName("Beijing"); | |
| 110 | + address.setCityId(1L); | |
| 111 | + address.setCityName("Beijing"); | |
| 112 | + address.setDistrictId(1L); | |
| 113 | + address.setDistrictName("Chaoyang Distripct"); | |
| 114 | + address.setDetailAddress("No. 10, Xinzhong Street, Chaoyang District"); | |
| 115 | + address.setDefaulted(true); | |
| 116 | + settlement.setAddress(address); | |
| 117 | + | |
| 118 | + return success(settlement); | |
| 49 | 119 | } |
| 50 | 120 | |
| 51 | 121 | @PostMapping("/create") |
| ... | ... | @@ -53,12 +123,13 @@ public class AppTradeOrderController { |
| 53 | 123 | @PreAuthenticated |
| 54 | 124 | public CommonResult<Long> createOrder(@RequestBody AppTradeOrderCreateReqVO createReqVO, |
| 55 | 125 | HttpServletRequest servletRequest) { |
| 56 | - // 获取登录用户、用户 IP 地址 | |
| 57 | - Long loginUserId = getLoginUserId(); | |
| 58 | - String clientIp = ServletUtils.getClientIP(servletRequest); | |
| 59 | - // 创建交易订单,预支付记录 | |
| 60 | - Long orderId = tradeOrderService.createOrder(loginUserId, clientIp, createReqVO); | |
| 61 | - return success(orderId); | |
| 126 | + return success(1L); | |
| 127 | +// // 获取登录用户、用户 IP 地址 | |
| 128 | +// Long loginUserId = getLoginUserId(); | |
| 129 | +// String clientIp = ServletUtils.getClientIP(servletRequest); | |
| 130 | +// // 创建交易订单,预支付记录 | |
| 131 | +// Long orderId = tradeOrderService.createOrder(loginUserId, clientIp, createReqVO); | |
| 132 | +// return success(orderId); | |
| 62 | 133 | } |
| 63 | 134 | |
| 64 | 135 | @PostMapping("/update-paid") |
| ... | ... | @@ -85,7 +156,7 @@ public class AppTradeOrderController { |
| 85 | 156 | } |
| 86 | 157 | |
| 87 | 158 | @GetMapping("/page") |
| 88 | - @Operation(summary = "获得订单交易分页") | |
| 159 | + @Operation(summary = "获得交易订单分页") | |
| 89 | 160 | public CommonResult<PageResult<AppTradeOrderPageItemRespVO>> getOrderPage(AppTradeOrderPageReqVO reqVO) { |
| 90 | 161 | // 查询订单 |
| 91 | 162 | PageResult<TradeOrderDO> pageResult = tradeOrderService.getOrderPage(getLoginUserId(), reqVO); |
| ... | ... | @@ -99,4 +170,18 @@ public class AppTradeOrderController { |
| 99 | 170 | return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems, propertyValueDetails)); |
| 100 | 171 | } |
| 101 | 172 | |
| 173 | + // TODO 芋艿:后续实现 | |
| 174 | + @GetMapping("/get-count") | |
| 175 | + @Operation(summary = "获得交易订单数量") | |
| 176 | + public CommonResult<Map<String, Integer>> getOrderCount() { | |
| 177 | + Map<String, Integer> orderCount = new HashMap<>(); | |
| 178 | + orderCount.put("allCount", 10); | |
| 179 | + orderCount.put("unpaidCount", 5); | |
| 180 | + orderCount.put("undeliveredCount", 2); | |
| 181 | + orderCount.put("deliveredCount", 1); | |
| 182 | + orderCount.put("uncommentedCount", 3); | |
| 183 | + orderCount.put("allPrice", 300); | |
| 184 | + return success(orderCount); | |
| 185 | + } | |
| 186 | + | |
| 102 | 187 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java
| ... | ... | @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.app.order.vo; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -import javax.validation.Valid; | |
| 7 | -import javax.validation.constraints.Min; | |
| 8 | 6 | import javax.validation.constraints.NotEmpty; |
| 9 | 7 | import javax.validation.constraints.NotNull; |
| 10 | 8 | import java.util.List; |
| ... | ... | @@ -20,33 +18,13 @@ public class AppTradeOrderCreateReqVO { |
| 20 | 18 | @Schema(description = "优惠劵编号", example = "1024") |
| 21 | 19 | private Long couponId; |
| 22 | 20 | |
| 23 | - @Schema(description = "备注", example = "这个是我的订单哟") | |
| 24 | - private String remark; | |
| 25 | - | |
| 26 | - @Schema(description = "是否来自购物车", required = true, example = "true") // true - 来自购物车;false - 立即购买 | |
| 27 | - @NotNull(message = "是否来自购物车不能为空") | |
| 28 | - private Boolean fromCart; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * 订单商品项列表 | |
| 32 | - */ | |
| 33 | - @NotEmpty(message = "必须选择购买的商品") | |
| 34 | - @Valid | |
| 35 | - private List<Item> items; | |
| 21 | + @Schema(description = "购物车项的编号数组", required = true, example = "true") | |
| 22 | + @NotEmpty(message = "购物车项不能为空") | |
| 23 | + private List<Long> cartIds; | |
| 36 | 24 | |
| 37 | - @Schema(description = "订单商品项") | |
| 38 | - @Data | |
| 39 | - public static class Item { | |
| 25 | + // ========== 非 AppTradeOrderSettlementReqVO 字段 ========== | |
| 40 | 26 | |
| 41 | - @Schema(description = "商品 SKU 编号", required = true, example = "111") | |
| 42 | - @NotNull(message = "商品 SKU 编号不能为空") | |
| 43 | - private Long skuId; | |
| 44 | - | |
| 45 | - @Schema(description = "商品 SKU 购买数量", required = true, example = "1024") | |
| 46 | - @NotNull(message = "商品 SKU 购买数量不能为空") | |
| 47 | - @Min(value = 1, message = "商品 SKU 购买数量必须大于 0") | |
| 48 | - private Integer count; | |
| 49 | - | |
| 50 | - } | |
| 27 | + @Schema(description = "备注", example = "这个是我的订单哟") | |
| 28 | + private String remark; | |
| 51 | 29 | |
| 52 | 30 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java
| ... | ... | @@ -40,12 +40,18 @@ public class AppTradeOrderDetailRespVO { |
| 40 | 40 | |
| 41 | 41 | // ========== 价格 + 支付基本信息 ========== |
| 42 | 42 | |
| 43 | + @Schema(description = "是否已支付", required = true, example = "true") | |
| 44 | + private Boolean payed; | |
| 45 | + | |
| 43 | 46 | @Schema(description = "支付订单编号", required = true, example = "1024") |
| 44 | 47 | private Long payOrderId; |
| 45 | 48 | |
| 46 | 49 | @Schema(description = "付款时间") |
| 47 | 50 | private LocalDateTime payTime; |
| 48 | 51 | |
| 52 | + @Schema(description = "支付渠道", required = true, example = "wx_lite_pay") | |
| 53 | + private String payChannelCode; | |
| 54 | + | |
| 49 | 55 | @Schema(description = "商品原价(总)", required = true, example = "1000") |
| 50 | 56 | private Integer originalPrice; |
| 51 | 57 | |
| ... | ... | @@ -87,9 +93,6 @@ public class AppTradeOrderDetailRespVO { |
| 87 | 93 | @Schema(description = "收件人地区名字", required = true, example = "上海 上海市 普陀区") |
| 88 | 94 | private String receiverAreaName; |
| 89 | 95 | |
| 90 | - @Schema(description = "收件人邮编", required = true, example = "100000") | |
| 91 | - private Integer receiverPostCode; | |
| 92 | - | |
| 93 | 96 | @Schema(description = "收件人详细地址", required = true, example = "中关村大街 1 号") |
| 94 | 97 | private String receiverDetailAddress; |
| 95 | 98 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderGetCreateInfoRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.controller.app.order.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.AllArgsConstructor; | |
| 5 | -import lombok.Data; | |
| 6 | - | |
| 7 | -import java.util.List; | |
| 8 | - | |
| 9 | -@Schema(description = "用户 App - 订单获得创建信息 Response VO") | |
| 10 | -@Data | |
| 11 | -public class AppTradeOrderGetCreateInfoRespVO { | |
| 12 | - | |
| 13 | - /** | |
| 14 | - * 商品分组数组 | |
| 15 | - */ | |
| 16 | - private List<ItemGroup> itemGroups; | |
| 17 | - /** | |
| 18 | - * 费用 | |
| 19 | - */ | |
| 20 | - private Fee fee; | |
| 21 | - | |
| 22 | -// /** | |
| 23 | -// * 优惠劵列表 TODO 芋艿,后续改改 | |
| 24 | -// */ | |
| 25 | -// private List<CouponCardAvailableRespDTO> coupons; | |
| 26 | - | |
| 27 | - @Schema(description = "商品分组") // 多个商品,参加同一个活动,从而形成分组 | |
| 28 | - @Data | |
| 29 | - public static class ItemGroup { | |
| 30 | - | |
| 31 | -// /** | |
| 32 | -// * 优惠活动 | |
| 33 | -// */ | |
| 34 | -// private PromotionActivityRespDTO activity; // TODO 芋艿,偷懒 | |
| 35 | - /** | |
| 36 | - * 商品 SKU 数组 | |
| 37 | - */ | |
| 38 | - private List<Sku> items; | |
| 39 | - | |
| 40 | - } | |
| 41 | - | |
| 42 | - @Schema(description = "商品 SKU") | |
| 43 | - @Data | |
| 44 | - public static class Sku { | |
| 45 | - | |
| 46 | - // SKU 自带信息 | |
| 47 | - @Schema(description = "SKU 编号", required = true, example = "1024") | |
| 48 | - private Integer id; | |
| 49 | - /** | |
| 50 | - * SPU 信息 | |
| 51 | - */ | |
| 52 | - private Spu spu; | |
| 53 | - /** | |
| 54 | - * 图片地址 | |
| 55 | - */ | |
| 56 | - private String picURL; | |
| 57 | -// /** | |
| 58 | -// * 属性数组 | |
| 59 | -// */ | |
| 60 | -// private List<ProductAttrKeyValueRespVO> attrs; // TODO 后面改下 | |
| 61 | - /** | |
| 62 | - * 价格,单位:分 | |
| 63 | - */ | |
| 64 | - private Integer price; | |
| 65 | - /** | |
| 66 | - * 库存数量 | |
| 67 | - */ | |
| 68 | - private Integer stock; | |
| 69 | - | |
| 70 | - // 非 SKU 自带信息 | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * 购买数量 | |
| 74 | - */ | |
| 75 | - private Integer buyQuantity; | |
| 76 | -// /** | |
| 77 | -// * 优惠活动 | |
| 78 | -// */ | |
| 79 | -// private PromotionActivityRespDTO activity; // TODO 芋艿,偷懒 | |
| 80 | - /** | |
| 81 | - * 原始单价,单位:分。 | |
| 82 | - */ | |
| 83 | - private Integer originPrice; | |
| 84 | - /** | |
| 85 | - * 购买单价,单位:分 | |
| 86 | - */ | |
| 87 | - private Integer buyPrice; | |
| 88 | - /** | |
| 89 | - * 最终价格,单位:分。 | |
| 90 | - */ | |
| 91 | - private Integer presentPrice; | |
| 92 | - /** | |
| 93 | - * 购买总金额,单位:分 | |
| 94 | - * | |
| 95 | - * 用途类似 {@link #presentTotal} | |
| 96 | - */ | |
| 97 | - private Integer buyTotal; | |
| 98 | - /** | |
| 99 | - * 优惠总金额,单位:分。 | |
| 100 | - */ | |
| 101 | - private Integer discountTotal; | |
| 102 | - /** | |
| 103 | - * 最终总金额,单位:分。 | |
| 104 | - * | |
| 105 | - * 注意,presentPrice * quantity 不一定等于 presentTotal 。 | |
| 106 | - * 因为,存在无法整除的情况。 | |
| 107 | - * 举个例子,presentPrice = 8.33 ,quantity = 3 的情况,presentTotal 有可能是 24.99 ,也可能是 25 。 | |
| 108 | - * 所以,需要存储一个该字段。 | |
| 109 | - */ | |
| 110 | - private Integer presentTotal; | |
| 111 | - | |
| 112 | - } | |
| 113 | - | |
| 114 | - @Data | |
| 115 | - public static class Spu { | |
| 116 | - | |
| 117 | - /** | |
| 118 | - * SPU 编号 | |
| 119 | - */ | |
| 120 | - private Integer id; | |
| 121 | - | |
| 122 | - // ========== 基本信息 ========= | |
| 123 | - /** | |
| 124 | - * SPU 名字 | |
| 125 | - */ | |
| 126 | - private String name; | |
| 127 | - /** | |
| 128 | - * 分类编号 | |
| 129 | - */ | |
| 130 | - private Integer cid; | |
| 131 | - /** | |
| 132 | - * 商品主图地址 | |
| 133 | - * | |
| 134 | - * 数组,以逗号分隔 | |
| 135 | - * | |
| 136 | - * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 | |
| 137 | - */ | |
| 138 | - private List<String> picUrls; | |
| 139 | - | |
| 140 | - } | |
| 141 | - | |
| 142 | - @Schema(description = "费用(合计)") | |
| 143 | - @Data | |
| 144 | - @AllArgsConstructor | |
| 145 | - public static class Fee { | |
| 146 | - | |
| 147 | - @Schema(description = "购买总价", required = true, example = "1024") | |
| 148 | - private Integer buyPrice; | |
| 149 | - /** | |
| 150 | - * 优惠总价 | |
| 151 | - * | |
| 152 | - * 注意,满多少元包邮,不算在优惠中。 | |
| 153 | - */ | |
| 154 | - private Integer discountTotal; | |
| 155 | - /** | |
| 156 | - * 邮费 | |
| 157 | - */ | |
| 158 | - private Integer postageTotal; | |
| 159 | - /** | |
| 160 | - * 最终价格 | |
| 161 | - * | |
| 162 | - * 计算公式 = 总价 - 优惠总价 + 邮费 | |
| 163 | - */ | |
| 164 | - private Integer presentTotal; | |
| 165 | - | |
| 166 | - } | |
| 167 | - | |
| 168 | -} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java
| ... | ... | @@ -22,6 +22,11 @@ public class AppTradeOrderPageItemRespVO { |
| 22 | 22 | @Schema(description = "购买的商品数量", required = true, example = "10") |
| 23 | 23 | private Integer productCount; |
| 24 | 24 | |
| 25 | + // ========== 价格 + 支付基本信息 ========== | |
| 26 | + | |
| 27 | + @Schema(description = "应付金额,单位:分", required = true, example = "1000") | |
| 28 | + private Integer payPrice; | |
| 29 | + | |
| 25 | 30 | /** |
| 26 | 31 | * 订单项数组 |
| 27 | 32 | */ | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.app.order.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +@Schema(description = "用户 App - 交易订单结算 Request VO") | |
| 10 | +@Data | |
| 11 | +public class AppTradeOrderSettlementReqVO { | |
| 12 | + | |
| 13 | + @Schema(description = "收件地址编号", example = "1") | |
| 14 | + private Long addressId; | |
| 15 | + | |
| 16 | + @Schema(description = "优惠劵编号", example = "1024") | |
| 17 | + private Long couponId; | |
| 18 | + | |
| 19 | + @Schema(description = "购物车项的编号数组", required = true, example = "true") | |
| 20 | + @NotEmpty(message = "购物车项不能为空") | |
| 21 | + private List<Long> cartIds; | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.app.order.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.AllArgsConstructor; | |
| 6 | +import lombok.Data; | |
| 7 | +import lombok.NoArgsConstructor; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +@Schema(description = "用户 App - 交易订单结算信息 Response VO") | |
| 12 | +@Data | |
| 13 | +public class AppTradeOrderSettlementRespVO { | |
| 14 | + | |
| 15 | + @Schema(description = "购物项数组", required = true) | |
| 16 | + private List<Item> items; | |
| 17 | + | |
| 18 | + @Schema(description = "费用", required = true) | |
| 19 | + private Price price; | |
| 20 | + | |
| 21 | + @Schema(description = "收件地址", required = true) | |
| 22 | + private Address address; | |
| 23 | + | |
| 24 | + @Schema(description = "购物项") | |
| 25 | + @Data | |
| 26 | + public static class Item { | |
| 27 | + | |
| 28 | + // ========== SPU 信息 ========== | |
| 29 | + | |
| 30 | + @Schema(description = "SPU 编号", required = true, example = "2048") | |
| 31 | + private Long spuId; | |
| 32 | + @Schema(description = "SPU 名字", required = true, example = "Apple iPhone 12") | |
| 33 | + private String spuName; | |
| 34 | + | |
| 35 | + // ========== SKU 信息 ========== | |
| 36 | + | |
| 37 | + @Schema(description = "SKU 编号", required = true, example = "1024") | |
| 38 | + private Integer skuId; | |
| 39 | + @Schema(description = "价格,单位:分", required = true, example = "100") | |
| 40 | + private Integer price; | |
| 41 | + @Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/1.png") | |
| 42 | + private String picUrl; | |
| 43 | + | |
| 44 | + @Schema(description = "属性数组", required = true, example = "100") | |
| 45 | + private List<AppProductPropertyValueDetailRespVO> properties; | |
| 46 | + | |
| 47 | + // ========== 购物车信息 ========== | |
| 48 | + | |
| 49 | + @Schema(description = "购物车编号", required = true, example = "100") | |
| 50 | + private Long cartId; | |
| 51 | + | |
| 52 | + @Schema(description = "购买数量", required = true, example = "1") | |
| 53 | + private Integer count; | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Schema(description = "费用(合计)") | |
| 58 | + @Data | |
| 59 | + @NoArgsConstructor | |
| 60 | + @AllArgsConstructor | |
| 61 | + public static class Price { | |
| 62 | + | |
| 63 | + @Schema(description = "商品原价(总),单位:分", required = true, example = "500") | |
| 64 | + private Integer originalPrice; | |
| 65 | + | |
| 66 | + @Schema(description = "运费金额,单位:分", required = true, example = "50") | |
| 67 | + private Integer deliveryPrice; | |
| 68 | + | |
| 69 | + @Schema(description = "优惠劵减免金额,单位:分", required = true, example = "100") | |
| 70 | + private Integer couponPrice; | |
| 71 | + | |
| 72 | + @Schema(description = "积分抵扣的金额,单位:分", required = true, example = "50") | |
| 73 | + private Integer pointPrice; | |
| 74 | + | |
| 75 | + @Schema(description = "实际支付金额(总),单位:分", required = true, example = "450") | |
| 76 | + private Integer payPrice; | |
| 77 | + | |
| 78 | + } | |
| 79 | + | |
| 80 | + @Schema(description = "费用(合计)") | |
| 81 | + @Data | |
| 82 | + public static class Address { | |
| 83 | + | |
| 84 | + @Schema(description = "编号", required = true, example = "1") | |
| 85 | + private Long id; | |
| 86 | + | |
| 87 | + @Schema(description = "收件人名称", required = true, example = "小王") | |
| 88 | + private String name; | |
| 89 | + | |
| 90 | + @Schema(description = "手机号", required = true, example = "15601691300") | |
| 91 | + private String mobile; | |
| 92 | + | |
| 93 | + @Schema(description = "省份编号", required = true, example = "1") | |
| 94 | + private Long provinceId; | |
| 95 | + @Schema(description = "省份名字", required = true, example = "北京") | |
| 96 | + private String provinceName; | |
| 97 | + | |
| 98 | + @Schema(description = "城市编号", required = true, example = "1") | |
| 99 | + private Long cityId; | |
| 100 | + @Schema(description = "城市名字", required = true, example = "北京") | |
| 101 | + private String cityName; | |
| 102 | + | |
| 103 | + @Schema(description = "地区编号", required = true, example = "1") | |
| 104 | + private Long districtId; | |
| 105 | + @Schema(description = "地区名字", required = true, example = "朝阳区") | |
| 106 | + private String districtName; | |
| 107 | + | |
| 108 | + @Schema(description = "详细地址", required = true, example = "望京悠乐汇 A 座") | |
| 109 | + private String detailAddress; | |
| 110 | + | |
| 111 | + @Schema(description = "是否默认收件地址", required = true, example = "true") | |
| 112 | + private Boolean defaulted; | |
| 113 | + | |
| 114 | + } | |
| 115 | + | |
| 116 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
| ... | ... | @@ -50,7 +50,6 @@ public interface TradeOrderConvert { |
| 50 | 50 | @Mapping(source = "address.name", target = "receiverName"), |
| 51 | 51 | @Mapping(source = "address.mobile", target = "receiverMobile"), |
| 52 | 52 | @Mapping(source = "address.areaId", target = "receiverAreaId"), |
| 53 | - @Mapping(source = "address.postCode", target = "receiverPostCode"), | |
| 54 | 53 | @Mapping(source = "address.detailAddress", target = "receiverDetailAddress"), |
| 55 | 54 | }) |
| 56 | 55 | TradeOrderDO convert(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | 5 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; |
| 6 | +import cn.iocoder.yudao.module.trade.dal.dataobject.cart.TradeCartDO; | |
| 6 | 7 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; |
| 7 | 8 | import com.baomidou.mybatisplus.annotation.TableField; |
| 8 | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
| ... | ... | @@ -42,6 +43,12 @@ public class TradeOrderItemDO extends BaseDO { |
| 42 | 43 | * 关联 {@link TradeOrderDO#getId()} |
| 43 | 44 | */ |
| 44 | 45 | private Long orderId; |
| 46 | + /** | |
| 47 | + * 购物车项编号 | |
| 48 | + * | |
| 49 | + * 关联 {@link TradeCartDO#getId()} | |
| 50 | + */ | |
| 51 | + private Long cartId; | |
| 45 | 52 | |
| 46 | 53 | // ========== 商品基本信息; 冗余较多字段,减少关联查询 ========== |
| 47 | 54 | /** | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java
| ... | ... | @@ -30,7 +30,6 @@ import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; |
| 30 | 30 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; |
| 31 | 31 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; |
| 32 | 32 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; |
| 33 | -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO.Item; | |
| 34 | 33 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; |
| 35 | 34 | import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 36 | 35 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| ... | ... | @@ -49,7 +48,8 @@ import java.time.LocalDateTime; |
| 49 | 48 | import java.util.*; |
| 50 | 49 | |
| 51 | 50 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 52 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 51 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 52 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; | |
| 53 | 53 | import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_ORDER_NOT_FOUND; |
| 54 | 54 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; |
| 55 | 55 | |
| ... | ... | @@ -92,7 +92,8 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 92 | 92 | @Transactional(rollbackFor = Exception.class) |
| 93 | 93 | public Long createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) { |
| 94 | 94 | // 商品 SKU 检查:可售状态、库存 |
| 95 | - List<ProductSkuRespDTO> skus = validateSkuSaleable(createReqVO.getItems()); | |
| 95 | +// List<ProductSkuRespDTO> skus = validateSkuSaleable(createReqVO.getItems()); // TODO 芋艿,临时关闭。 | |
| 96 | + List<ProductSkuRespDTO> skus = null; | |
| 96 | 97 | // 商品 SPU 检查:可售状态 |
| 97 | 98 | List<ProductSpuRespDTO> spus = validateSpuSaleable(convertSet(skus, ProductSkuRespDTO::getSpuId)); |
| 98 | 99 | // 用户收件地址的校验 |
| ... | ... | @@ -112,28 +113,28 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 112 | 113 | return tradeOrderDO.getId(); |
| 113 | 114 | } |
| 114 | 115 | |
| 115 | - /** | |
| 116 | - * 校验商品 SKU 是否可出售 | |
| 117 | - * | |
| 118 | - * @param items 商品 SKU | |
| 119 | - * @return 商品 SKU 数组 | |
| 120 | - */ | |
| 121 | - private List<ProductSkuRespDTO> validateSkuSaleable(List<Item> items) { | |
| 122 | - List<ProductSkuRespDTO> skus = productSkuApi.getSkuList(convertSet(items, Item::getSkuId)); | |
| 123 | - // SKU 不存在 | |
| 124 | - if (items.size() != skus.size()) { | |
| 125 | - throw exception(ORDER_CREATE_SKU_NOT_FOUND); | |
| 126 | - } | |
| 127 | - // 校验库存不足 | |
| 128 | - Map<Long, ProductSkuRespDTO> skuMap = convertMap(skus, ProductSkuRespDTO::getId); | |
| 129 | - items.forEach(item -> { | |
| 130 | - ProductSkuRespDTO sku = skuMap.get(item.getSkuId()); | |
| 131 | - if (item.getCount() > sku.getStock()) { | |
| 132 | - throw exception(ErrorCodeConstants.ORDER_CREATE_SKU_STOCK_NOT_ENOUGH); | |
| 133 | - } | |
| 134 | - }); | |
| 135 | - return skus; | |
| 136 | - } | |
| 116 | +// /** | |
| 117 | +// * 校验商品 SKU 是否可出售 | |
| 118 | +// * | |
| 119 | +// * @param items 商品 SKU | |
| 120 | +// * @return 商品 SKU 数组 | |
| 121 | +// */ | |
| 122 | +// private List<ProductSkuRespDTO> validateSkuSaleable(List<Item> items) { | |
| 123 | +// List<ProductSkuRespDTO> skus = productSkuApi.getSkuList(convertSet(items, Item::getSkuId)); | |
| 124 | +// // SKU 不存在 | |
| 125 | +// if (items.size() != skus.size()) { | |
| 126 | +// throw exception(ORDER_CREATE_SKU_NOT_FOUND); | |
| 127 | +// } | |
| 128 | +// // 校验库存不足 | |
| 129 | +// Map<Long, ProductSkuRespDTO> skuMap = convertMap(skus, ProductSkuRespDTO::getId); | |
| 130 | +// items.forEach(item -> { | |
| 131 | +// ProductSkuRespDTO sku = skuMap.get(item.getSkuId()); | |
| 132 | +// if (item.getCount() > sku.getStock()) { | |
| 133 | +// throw exception(ErrorCodeConstants.ORDER_CREATE_SKU_STOCK_NOT_ENOUGH); | |
| 134 | +// } | |
| 135 | +// }); | |
| 136 | +// return skus; | |
| 137 | +// } | |
| 137 | 138 | |
| 138 | 139 | /** |
| 139 | 140 | * 校验商品 SPU 是否可出售 |
| ... | ... | @@ -506,6 +507,9 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 506 | 507 | |
| 507 | 508 | @Override |
| 508 | 509 | public List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds) { |
| 510 | + if (CollUtil.isEmpty(orderIds)) { | |
| 511 | + return Collections.emptyList(); | |
| 512 | + } | |
| 509 | 513 | return tradeOrderItemMapper.selectListByOrderId(orderIds); |
| 510 | 514 | } |
| 511 | 515 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceTest.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.order; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | 3 | import cn.iocoder.yudao.framework.common.enums.TerminalEnum; |
| 5 | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 6 | 5 | import cn.iocoder.yudao.module.member.api.address.AddressApi; |
| ... | ... | @@ -93,10 +92,12 @@ public class TradeOrderServiceTest extends BaseDbUnitTest { |
| 93 | 92 | // 准备参数 |
| 94 | 93 | Long userId = 100L; |
| 95 | 94 | String userIp = "127.0.0.1"; |
| 96 | - AppTradeOrderCreateReqVO reqVO = new AppTradeOrderCreateReqVO() | |
| 97 | - .setAddressId(10L).setCouponId(101L).setRemark("我是备注").setFromCart(true) | |
| 98 | - .setItems(Arrays.asList(new AppTradeOrderCreateReqVO.Item().setSkuId(1L).setCount(3), | |
| 99 | - new AppTradeOrderCreateReqVO.Item().setSkuId(2L).setCount(4))); | |
| 95 | +// AppTradeOrderCreateReqVO reqVO = new AppTradeOrderCreateReqVO() | |
| 96 | +// .setAddressId(10L).setCouponId(101L).setRemark("我是备注").setFromCart(true) | |
| 97 | +// .setItems(Arrays.asList(new AppTradeOrderCreateReqVO.Item().setSkuId(1L).setCount(3), | |
| 98 | +// new AppTradeOrderCreateReqVO.Item().setSkuId(2L).setCount(4))); | |
| 99 | + AppTradeOrderCreateReqVO reqVO = null; | |
| 100 | + // TODO 芋艿:重新高下 | |
| 100 | 101 | // mock 方法(商品 SKU 检查) |
| 101 | 102 | ProductSkuRespDTO sku01 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(1L).setSpuId(11L) |
| 102 | 103 | .setPrice(50).setStock(100) |
| ... | ... | @@ -183,7 +184,6 @@ public class TradeOrderServiceTest extends BaseDbUnitTest { |
| 183 | 184 | assertEquals(tradeOrderDO.getReceiverName(), "芋艿"); |
| 184 | 185 | assertEquals(tradeOrderDO.getReceiverMobile(), "15601691300"); |
| 185 | 186 | assertEquals(tradeOrderDO.getReceiverAreaId(), 3306); |
| 186 | - assertEquals(tradeOrderDO.getReceiverPostCode(), 85757); | |
| 187 | 187 | assertEquals(tradeOrderDO.getReceiverDetailAddress(), "土豆村"); |
| 188 | 188 | assertEquals(tradeOrderDO.getAfterSaleStatus(), TradeOrderAfterSaleStatusEnum.NONE.getStatus()); |
| 189 | 189 | assertEquals(tradeOrderDO.getRefundPrice(), 0); | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/address/vo/AppAddressBaseVO.java
| 1 | 1 | package cn.iocoder.yudao.module.member.controller.app.address.vo; |
| 2 | + | |
| 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 3 | 4 | import lombok.Data; |
| 4 | 5 | |
| 5 | -import javax.validation.constraints.NotEmpty; | |
| 6 | 6 | import javax.validation.constraints.NotNull; |
| 7 | 7 | |
| 8 | +// TODO 芋艿:example 缺失 | |
| 8 | 9 | /** |
| 9 | 10 | * 用户收件地址 Base VO,提供给添加、修改、详细的子 VO 使用 |
| 10 | 11 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| ... | ... | @@ -24,10 +25,6 @@ public class AppAddressBaseVO { |
| 24 | 25 | @NotNull(message = "地区编号不能为空") |
| 25 | 26 | private Long areaId; |
| 26 | 27 | |
| 27 | - @Schema(description = "邮编", required = true) | |
| 28 | - @NotEmpty(message = "邮编不能为空") | |
| 29 | - private String postCode; | |
| 30 | - | |
| 31 | 28 | @Schema(description = "收件详细地址", required = true) |
| 32 | 29 | @NotNull(message = "收件详细地址不能为空") |
| 33 | 30 | private String detailAddress; | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/address/AddressDO.java
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java
| ... | ... | @@ -55,6 +55,10 @@ public class PayOrderBaseVO { |
| 55 | 55 | @NotNull(message = "支付金额,单位:分不能为空") |
| 56 | 56 | private Long amount; |
| 57 | 57 | |
| 58 | + @Schema(description = "支付金额,单位:分", required = true) | |
| 59 | + @NotNull(message = "支付金额,单位:分不能为空") | |
| 60 | + private Long price; | |
| 61 | + | |
| 58 | 62 | @Schema(description = "渠道手续费,单位:百分比") |
| 59 | 63 | private Double channelFeeRate; |
| 60 | 64 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.controller.app.order; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | +import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderRespVO; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitReqVO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; |
| 7 | 8 | import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; |
| 8 | 9 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 9 | 10 | import io.swagger.v3.oas.annotations.Operation; |
| 11 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 10 | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | 13 | import lombok.extern.slf4j.Slf4j; |
| 12 | 14 | import org.springframework.validation.annotation.Validated; |
| 13 | -import org.springframework.web.bind.annotation.PostMapping; | |
| 14 | -import org.springframework.web.bind.annotation.RequestBody; | |
| 15 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 16 | -import org.springframework.web.bind.annotation.RestController; | |
| 15 | +import org.springframework.web.bind.annotation.*; | |
| 17 | 16 | |
| 18 | 17 | import javax.annotation.Resource; |
| 19 | 18 | |
| ... | ... | @@ -28,12 +27,20 @@ import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getCli |
| 28 | 27 | public class AppPayOrderController { |
| 29 | 28 | |
| 30 | 29 | @Resource |
| 31 | - private PayOrderService orderService; | |
| 30 | + private PayOrderService payOrderService; | |
| 31 | + | |
| 32 | + // TODO 芋艿:临时 demo,技术打样。 | |
| 33 | + @GetMapping("/get") | |
| 34 | + @Operation(summary = "获得支付订单") | |
| 35 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 36 | + public CommonResult<PayOrderRespVO> getOrder(@RequestParam("id") Long id) { | |
| 37 | + return success(PayOrderConvert.INSTANCE.convert(payOrderService.getOrder(id))); | |
| 38 | + } | |
| 32 | 39 | |
| 33 | 40 | @PostMapping("/submit") |
| 34 | 41 | @Operation(summary = "提交支付订单") |
| 35 | 42 | public CommonResult<AppPayOrderSubmitRespVO> submitPayOrder(@RequestBody AppPayOrderSubmitReqVO reqVO) { |
| 36 | - PayOrderSubmitRespVO respVO = orderService.submitPayOrder(reqVO, getClientIP()); | |
| 43 | + PayOrderSubmitRespVO respVO = payOrderService.submitPayOrder(reqVO, getClientIP()); | |
| 37 | 44 | return success(PayOrderConvert.INSTANCE.convert3(respVO)); |
| 38 | 45 | } |
| 39 | 46 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java
| ... | ... | @@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespD |
| 6 | 6 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; |
| 7 | 7 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; |
| 8 | 8 | import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*; |
| 9 | -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitReqVO; | |
| 10 | 9 | import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; |
| 11 | 10 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; |
| 12 | 11 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; |
| ... | ... | @@ -28,6 +27,7 @@ public interface PayOrderConvert { |
| 28 | 27 | |
| 29 | 28 | PayOrderConvert INSTANCE = Mappers.getMapper(PayOrderConvert.class); |
| 30 | 29 | |
| 30 | + @Mapping(source = "amount", target = "price") | |
| 31 | 31 | PayOrderRespVO convert(PayOrderDO bean); |
| 32 | 32 | |
| 33 | 33 | PayOrderRespDTO convert2(PayOrderDO order); | ... | ... |