mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-16 03:01:53 +08:00
订单接口的梳理
This commit is contained in:
@@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
@@ -118,9 +117,6 @@ public class TradeOrderBaseVO {
|
||||
@Schema(description = "收件人地区编号", required = true, example = "110000")
|
||||
private Integer receiverAreaId;
|
||||
|
||||
@Schema(description = "收件人邮编", required = true, example = "100000")
|
||||
private Integer receiverPostCode;
|
||||
|
||||
@Schema(description = "收件人详细地址", required = true, example = "中关村大街 1 号")
|
||||
private String receiverDetailAddress;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
### /trade-order/confirm-create-order-info 基于商品,确认创建订单
|
||||
GET {{appApi}}/trade/order/get-create-info?items[0].skuId=1&items[0].count=1
|
||||
Authorization: Bearer {{user-access-token}}
|
||||
### /trade-order/settlement 获得订单结算信息
|
||||
GET {{appApi}}/trade/order/settlement?cartIds=1
|
||||
Authorization: Bearer {{appToken}}
|
||||
tenant-id: {{appTenentId}}
|
||||
|
||||
### /trade-order/confirm-create-order-info-from-cart 基于购物车,确认创建订单
|
||||
|
@@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.trade.controller.app.order;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO;
|
||||
import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi;
|
||||
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
@@ -21,7 +21,11 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
@@ -40,12 +44,78 @@ public class AppTradeOrderController {
|
||||
@Resource
|
||||
private ProductPropertyValueApi productPropertyValueApi;
|
||||
|
||||
@GetMapping("/get-create-info")
|
||||
@Operation(summary = "基于商品,确认创建订单")
|
||||
@GetMapping("/settlement")
|
||||
@Operation(summary = "获得订单结算信息")
|
||||
@PreAuthenticated
|
||||
public CommonResult<AppTradeOrderGetCreateInfoRespVO> getOrderCreateInfo(AppTradeOrderCreateReqVO createReqVO) {
|
||||
public CommonResult<AppTradeOrderSettlementRespVO> settlementOrder(
|
||||
@Valid AppTradeOrderSettlementReqVO settlementReqVO) {
|
||||
// return success(tradeOrderService.getOrderConfirmCreateInfo(UserSecurityContextHolder.getUserId(), skuId, quantity, couponCardId));
|
||||
return null;
|
||||
AppTradeOrderSettlementRespVO settlement = new AppTradeOrderSettlementRespVO();
|
||||
|
||||
AppTradeOrderSettlementRespVO.Price price = new AppTradeOrderSettlementRespVO.Price();
|
||||
price.setOriginalPrice(1000);
|
||||
price.setDeliveryPrice(200);
|
||||
price.setCouponPrice(100);
|
||||
price.setPointPrice(50);
|
||||
price.setPayPrice(950);
|
||||
|
||||
List<AppTradeOrderSettlementRespVO.Item> skus = new ArrayList<>();
|
||||
|
||||
AppTradeOrderSettlementRespVO.Item item1 = new AppTradeOrderSettlementRespVO.Item();
|
||||
item1.setCartId(1L);
|
||||
item1.setSpuId(2048L);
|
||||
item1.setSpuName("Apple iPhone 12");
|
||||
item1.setSkuId(1024);
|
||||
item1.setPrice(500);
|
||||
item1.setPicUrl("https://pro.crmeb.net/uploads/attach/2022/10/12/0c56f9abb80d2775fc1e80dbe4f8826a.jpg");
|
||||
item1.setCount(2);
|
||||
List<AppProductPropertyValueDetailRespVO> properties1 = new ArrayList<>();
|
||||
AppProductPropertyValueDetailRespVO property1 = new AppProductPropertyValueDetailRespVO();
|
||||
property1.setPropertyId(1L);
|
||||
property1.setPropertyName("尺寸");
|
||||
property1.setValueId(2L);
|
||||
property1.setValueName("大");
|
||||
properties1.add(property1);
|
||||
item1.setProperties(properties1);
|
||||
|
||||
AppTradeOrderSettlementRespVO.Item item2 = new AppTradeOrderSettlementRespVO.Item();
|
||||
item2.setCartId(2L);
|
||||
item2.setSpuId(3072L);
|
||||
item2.setSpuName("Samsung Galaxy S21");
|
||||
item2.setSkuId(2048);
|
||||
item2.setPrice(800);
|
||||
item2.setPicUrl("https://pro.crmeb.net/uploads/attach/2022/10/12/0c56f9abb80d2775fc1e80dbe4f8826a.jpg");
|
||||
item2.setCount(1);
|
||||
List<AppProductPropertyValueDetailRespVO> properties2 = new ArrayList<>();
|
||||
AppProductPropertyValueDetailRespVO property2 = new AppProductPropertyValueDetailRespVO();
|
||||
property2.setPropertyId(10L);
|
||||
property2.setPropertyName("颜色");
|
||||
property2.setValueId(20L);
|
||||
property2.setValueName("白色");
|
||||
properties2.add(property2);
|
||||
item2.setProperties(properties2);
|
||||
|
||||
skus.add(item1);
|
||||
skus.add(item2);
|
||||
|
||||
settlement.setItems(skus);
|
||||
settlement.setPrice(price);
|
||||
|
||||
AppTradeOrderSettlementRespVO.Address address = new AppTradeOrderSettlementRespVO.Address();
|
||||
address.setId(1L);
|
||||
address.setName("John");
|
||||
address.setMobile("18888888888");
|
||||
address.setProvinceId(1L);
|
||||
address.setProvinceName("Beijing");
|
||||
address.setCityId(1L);
|
||||
address.setCityName("Beijing");
|
||||
address.setDistrictId(1L);
|
||||
address.setDistrictName("Chaoyang Distripct");
|
||||
address.setDetailAddress("No. 10, Xinzhong Street, Chaoyang District");
|
||||
address.setDefaulted(true);
|
||||
settlement.setAddress(address);
|
||||
|
||||
return success(settlement);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@@ -53,12 +123,13 @@ public class AppTradeOrderController {
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> createOrder(@RequestBody AppTradeOrderCreateReqVO createReqVO,
|
||||
HttpServletRequest servletRequest) {
|
||||
// 获取登录用户、用户 IP 地址
|
||||
Long loginUserId = getLoginUserId();
|
||||
String clientIp = ServletUtils.getClientIP(servletRequest);
|
||||
// 创建交易订单,预支付记录
|
||||
Long orderId = tradeOrderService.createOrder(loginUserId, clientIp, createReqVO);
|
||||
return success(orderId);
|
||||
return success(1L);
|
||||
// // 获取登录用户、用户 IP 地址
|
||||
// Long loginUserId = getLoginUserId();
|
||||
// String clientIp = ServletUtils.getClientIP(servletRequest);
|
||||
// // 创建交易订单,预支付记录
|
||||
// Long orderId = tradeOrderService.createOrder(loginUserId, clientIp, createReqVO);
|
||||
// return success(orderId);
|
||||
}
|
||||
|
||||
@PostMapping("/update-paid")
|
||||
@@ -85,7 +156,7 @@ public class AppTradeOrderController {
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得订单交易分页")
|
||||
@Operation(summary = "获得交易订单分页")
|
||||
public CommonResult<PageResult<AppTradeOrderPageItemRespVO>> getOrderPage(AppTradeOrderPageReqVO reqVO) {
|
||||
// 查询订单
|
||||
PageResult<TradeOrderDO> pageResult = tradeOrderService.getOrderPage(getLoginUserId(), reqVO);
|
||||
@@ -99,4 +170,18 @@ public class AppTradeOrderController {
|
||||
return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems, propertyValueDetails));
|
||||
}
|
||||
|
||||
// TODO 芋艿:后续实现
|
||||
@GetMapping("/get-count")
|
||||
@Operation(summary = "获得交易订单数量")
|
||||
public CommonResult<Map<String, Integer>> getOrderCount() {
|
||||
Map<String, Integer> orderCount = new HashMap<>();
|
||||
orderCount.put("allCount", 10);
|
||||
orderCount.put("unpaidCount", 5);
|
||||
orderCount.put("undeliveredCount", 2);
|
||||
orderCount.put("deliveredCount", 1);
|
||||
orderCount.put("uncommentedCount", 3);
|
||||
orderCount.put("allPrice", 300);
|
||||
return success(orderCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.app.order.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
@@ -20,33 +18,13 @@ public class AppTradeOrderCreateReqVO {
|
||||
@Schema(description = "优惠劵编号", example = "1024")
|
||||
private Long couponId;
|
||||
|
||||
@Schema(description = "购物车项的编号数组", required = true, example = "true")
|
||||
@NotEmpty(message = "购物车项不能为空")
|
||||
private List<Long> cartIds;
|
||||
|
||||
// ========== 非 AppTradeOrderSettlementReqVO 字段 ==========
|
||||
|
||||
@Schema(description = "备注", example = "这个是我的订单哟")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否来自购物车", required = true, example = "true") // true - 来自购物车;false - 立即购买
|
||||
@NotNull(message = "是否来自购物车不能为空")
|
||||
private Boolean fromCart;
|
||||
|
||||
/**
|
||||
* 订单商品项列表
|
||||
*/
|
||||
@NotEmpty(message = "必须选择购买的商品")
|
||||
@Valid
|
||||
private List<Item> items;
|
||||
|
||||
@Schema(description = "订单商品项")
|
||||
@Data
|
||||
public static class Item {
|
||||
|
||||
@Schema(description = "商品 SKU 编号", required = true, example = "111")
|
||||
@NotNull(message = "商品 SKU 编号不能为空")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "商品 SKU 购买数量", required = true, example = "1024")
|
||||
@NotNull(message = "商品 SKU 购买数量不能为空")
|
||||
@Min(value = 1, message = "商品 SKU 购买数量必须大于 0")
|
||||
private Integer count;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -40,12 +40,18 @@ public class AppTradeOrderDetailRespVO {
|
||||
|
||||
// ========== 价格 + 支付基本信息 ==========
|
||||
|
||||
@Schema(description = "是否已支付", required = true, example = "true")
|
||||
private Boolean payed;
|
||||
|
||||
@Schema(description = "支付订单编号", required = true, example = "1024")
|
||||
private Long payOrderId;
|
||||
|
||||
@Schema(description = "付款时间")
|
||||
private LocalDateTime payTime;
|
||||
|
||||
@Schema(description = "支付渠道", required = true, example = "wx_lite_pay")
|
||||
private String payChannelCode;
|
||||
|
||||
@Schema(description = "商品原价(总)", required = true, example = "1000")
|
||||
private Integer originalPrice;
|
||||
|
||||
@@ -87,9 +93,6 @@ public class AppTradeOrderDetailRespVO {
|
||||
@Schema(description = "收件人地区名字", required = true, example = "上海 上海市 普陀区")
|
||||
private String receiverAreaName;
|
||||
|
||||
@Schema(description = "收件人邮编", required = true, example = "100000")
|
||||
private Integer receiverPostCode;
|
||||
|
||||
@Schema(description = "收件人详细地址", required = true, example = "中关村大街 1 号")
|
||||
private String receiverDetailAddress;
|
||||
|
||||
|
@@ -1,168 +0,0 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.app.order.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 订单获得创建信息 Response VO")
|
||||
@Data
|
||||
public class AppTradeOrderGetCreateInfoRespVO {
|
||||
|
||||
/**
|
||||
* 商品分组数组
|
||||
*/
|
||||
private List<ItemGroup> itemGroups;
|
||||
/**
|
||||
* 费用
|
||||
*/
|
||||
private Fee fee;
|
||||
|
||||
// /**
|
||||
// * 优惠劵列表 TODO 芋艿,后续改改
|
||||
// */
|
||||
// private List<CouponCardAvailableRespDTO> coupons;
|
||||
|
||||
@Schema(description = "商品分组") // 多个商品,参加同一个活动,从而形成分组
|
||||
@Data
|
||||
public static class ItemGroup {
|
||||
|
||||
// /**
|
||||
// * 优惠活动
|
||||
// */
|
||||
// private PromotionActivityRespDTO activity; // TODO 芋艿,偷懒
|
||||
/**
|
||||
* 商品 SKU 数组
|
||||
*/
|
||||
private List<Sku> items;
|
||||
|
||||
}
|
||||
|
||||
@Schema(description = "商品 SKU")
|
||||
@Data
|
||||
public static class Sku {
|
||||
|
||||
// SKU 自带信息
|
||||
@Schema(description = "SKU 编号", required = true, example = "1024")
|
||||
private Integer id;
|
||||
/**
|
||||
* SPU 信息
|
||||
*/
|
||||
private Spu spu;
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
private String picURL;
|
||||
// /**
|
||||
// * 属性数组
|
||||
// */
|
||||
// private List<ProductAttrKeyValueRespVO> attrs; // TODO 后面改下
|
||||
/**
|
||||
* 价格,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
private Integer stock;
|
||||
|
||||
// 非 SKU 自带信息
|
||||
|
||||
/**
|
||||
* 购买数量
|
||||
*/
|
||||
private Integer buyQuantity;
|
||||
// /**
|
||||
// * 优惠活动
|
||||
// */
|
||||
// private PromotionActivityRespDTO activity; // TODO 芋艿,偷懒
|
||||
/**
|
||||
* 原始单价,单位:分。
|
||||
*/
|
||||
private Integer originPrice;
|
||||
/**
|
||||
* 购买单价,单位:分
|
||||
*/
|
||||
private Integer buyPrice;
|
||||
/**
|
||||
* 最终价格,单位:分。
|
||||
*/
|
||||
private Integer presentPrice;
|
||||
/**
|
||||
* 购买总金额,单位:分
|
||||
*
|
||||
* 用途类似 {@link #presentTotal}
|
||||
*/
|
||||
private Integer buyTotal;
|
||||
/**
|
||||
* 优惠总金额,单位:分。
|
||||
*/
|
||||
private Integer discountTotal;
|
||||
/**
|
||||
* 最终总金额,单位:分。
|
||||
*
|
||||
* 注意,presentPrice * quantity 不一定等于 presentTotal 。
|
||||
* 因为,存在无法整除的情况。
|
||||
* 举个例子,presentPrice = 8.33 ,quantity = 3 的情况,presentTotal 有可能是 24.99 ,也可能是 25 。
|
||||
* 所以,需要存储一个该字段。
|
||||
*/
|
||||
private Integer presentTotal;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Spu {
|
||||
|
||||
/**
|
||||
* SPU 编号
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
// ========== 基本信息 =========
|
||||
/**
|
||||
* SPU 名字
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 分类编号
|
||||
*/
|
||||
private Integer cid;
|
||||
/**
|
||||
* 商品主图地址
|
||||
*
|
||||
* 数组,以逗号分隔
|
||||
*
|
||||
* 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张
|
||||
*/
|
||||
private List<String> picUrls;
|
||||
|
||||
}
|
||||
|
||||
@Schema(description = "费用(合计)")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class Fee {
|
||||
|
||||
@Schema(description = "购买总价", required = true, example = "1024")
|
||||
private Integer buyPrice;
|
||||
/**
|
||||
* 优惠总价
|
||||
*
|
||||
* 注意,满多少元包邮,不算在优惠中。
|
||||
*/
|
||||
private Integer discountTotal;
|
||||
/**
|
||||
* 邮费
|
||||
*/
|
||||
private Integer postageTotal;
|
||||
/**
|
||||
* 最终价格
|
||||
*
|
||||
* 计算公式 = 总价 - 优惠总价 + 邮费
|
||||
*/
|
||||
private Integer presentTotal;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -22,6 +22,11 @@ public class AppTradeOrderPageItemRespVO {
|
||||
@Schema(description = "购买的商品数量", required = true, example = "10")
|
||||
private Integer productCount;
|
||||
|
||||
// ========== 价格 + 支付基本信息 ==========
|
||||
|
||||
@Schema(description = "应付金额,单位:分", required = true, example = "1000")
|
||||
private Integer payPrice;
|
||||
|
||||
/**
|
||||
* 订单项数组
|
||||
*/
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.app.order.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 交易订单结算 Request VO")
|
||||
@Data
|
||||
public class AppTradeOrderSettlementReqVO {
|
||||
|
||||
@Schema(description = "收件地址编号", example = "1")
|
||||
private Long addressId;
|
||||
|
||||
@Schema(description = "优惠劵编号", example = "1024")
|
||||
private Long couponId;
|
||||
|
||||
@Schema(description = "购物车项的编号数组", required = true, example = "true")
|
||||
@NotEmpty(message = "购物车项不能为空")
|
||||
private List<Long> cartIds;
|
||||
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.app.order.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 交易订单结算信息 Response VO")
|
||||
@Data
|
||||
public class AppTradeOrderSettlementRespVO {
|
||||
|
||||
@Schema(description = "购物项数组", required = true)
|
||||
private List<Item> items;
|
||||
|
||||
@Schema(description = "费用", required = true)
|
||||
private Price price;
|
||||
|
||||
@Schema(description = "收件地址", required = true)
|
||||
private Address address;
|
||||
|
||||
@Schema(description = "购物项")
|
||||
@Data
|
||||
public static class Item {
|
||||
|
||||
// ========== SPU 信息 ==========
|
||||
|
||||
@Schema(description = "SPU 编号", required = true, example = "2048")
|
||||
private Long spuId;
|
||||
@Schema(description = "SPU 名字", required = true, example = "Apple iPhone 12")
|
||||
private String spuName;
|
||||
|
||||
// ========== SKU 信息 ==========
|
||||
|
||||
@Schema(description = "SKU 编号", required = true, example = "1024")
|
||||
private Integer skuId;
|
||||
@Schema(description = "价格,单位:分", required = true, example = "100")
|
||||
private Integer price;
|
||||
@Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/1.png")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "属性数组", required = true, example = "100")
|
||||
private List<AppProductPropertyValueDetailRespVO> properties;
|
||||
|
||||
// ========== 购物车信息 ==========
|
||||
|
||||
@Schema(description = "购物车编号", required = true, example = "100")
|
||||
private Long cartId;
|
||||
|
||||
@Schema(description = "购买数量", required = true, example = "1")
|
||||
private Integer count;
|
||||
|
||||
}
|
||||
|
||||
@Schema(description = "费用(合计)")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Price {
|
||||
|
||||
@Schema(description = "商品原价(总),单位:分", required = true, example = "500")
|
||||
private Integer originalPrice;
|
||||
|
||||
@Schema(description = "运费金额,单位:分", required = true, example = "50")
|
||||
private Integer deliveryPrice;
|
||||
|
||||
@Schema(description = "优惠劵减免金额,单位:分", required = true, example = "100")
|
||||
private Integer couponPrice;
|
||||
|
||||
@Schema(description = "积分抵扣的金额,单位:分", required = true, example = "50")
|
||||
private Integer pointPrice;
|
||||
|
||||
@Schema(description = "实际支付金额(总),单位:分", required = true, example = "450")
|
||||
private Integer payPrice;
|
||||
|
||||
}
|
||||
|
||||
@Schema(description = "费用(合计)")
|
||||
@Data
|
||||
public static class Address {
|
||||
|
||||
@Schema(description = "编号", required = true, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "收件人名称", required = true, example = "小王")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "手机号", required = true, example = "15601691300")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "省份编号", required = true, example = "1")
|
||||
private Long provinceId;
|
||||
@Schema(description = "省份名字", required = true, example = "北京")
|
||||
private String provinceName;
|
||||
|
||||
@Schema(description = "城市编号", required = true, example = "1")
|
||||
private Long cityId;
|
||||
@Schema(description = "城市名字", required = true, example = "北京")
|
||||
private String cityName;
|
||||
|
||||
@Schema(description = "地区编号", required = true, example = "1")
|
||||
private Long districtId;
|
||||
@Schema(description = "地区名字", required = true, example = "朝阳区")
|
||||
private String districtName;
|
||||
|
||||
@Schema(description = "详细地址", required = true, example = "望京悠乐汇 A 座")
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "是否默认收件地址", required = true, example = "true")
|
||||
private Boolean defaulted;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -50,7 +50,6 @@ public interface TradeOrderConvert {
|
||||
@Mapping(source = "address.name", target = "receiverName"),
|
||||
@Mapping(source = "address.mobile", target = "receiverMobile"),
|
||||
@Mapping(source = "address.areaId", target = "receiverAreaId"),
|
||||
@Mapping(source = "address.postCode", target = "receiverPostCode"),
|
||||
@Mapping(source = "address.detailAddress", target = "receiverDetailAddress"),
|
||||
})
|
||||
TradeOrderDO convert(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO,
|
||||
|
@@ -212,10 +212,6 @@ public class TradeOrderDO extends BaseDO {
|
||||
* 收件人地区编号
|
||||
*/
|
||||
private Integer receiverAreaId;
|
||||
/**
|
||||
* 收件人邮编
|
||||
*/
|
||||
private Integer receiverPostCode;
|
||||
/**
|
||||
* 收件人详细地址
|
||||
*/
|
||||
|
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.cart.TradeCartDO;
|
||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -42,6 +43,12 @@ public class TradeOrderItemDO extends BaseDO {
|
||||
* 关联 {@link TradeOrderDO#getId()}
|
||||
*/
|
||||
private Long orderId;
|
||||
/**
|
||||
* 购物车项编号
|
||||
*
|
||||
* 关联 {@link TradeCartDO#getId()}
|
||||
*/
|
||||
private Long cartId;
|
||||
|
||||
// ========== 商品基本信息; 冗余较多字段,减少关联查询 ==========
|
||||
/**
|
||||
|
@@ -30,7 +30,6 @@ import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO.Item;
|
||||
import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
|
||||
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
@@ -49,7 +48,8 @@ import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_ORDER_NOT_FOUND;
|
||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
||||
|
||||
@@ -92,7 +92,8 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) {
|
||||
// 商品 SKU 检查:可售状态、库存
|
||||
List<ProductSkuRespDTO> skus = validateSkuSaleable(createReqVO.getItems());
|
||||
// List<ProductSkuRespDTO> skus = validateSkuSaleable(createReqVO.getItems()); // TODO 芋艿,临时关闭。
|
||||
List<ProductSkuRespDTO> skus = null;
|
||||
// 商品 SPU 检查:可售状态
|
||||
List<ProductSpuRespDTO> spus = validateSpuSaleable(convertSet(skus, ProductSkuRespDTO::getSpuId));
|
||||
// 用户收件地址的校验
|
||||
@@ -112,28 +113,28 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
return tradeOrderDO.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验商品 SKU 是否可出售
|
||||
*
|
||||
* @param items 商品 SKU
|
||||
* @return 商品 SKU 数组
|
||||
*/
|
||||
private List<ProductSkuRespDTO> validateSkuSaleable(List<Item> items) {
|
||||
List<ProductSkuRespDTO> skus = productSkuApi.getSkuList(convertSet(items, Item::getSkuId));
|
||||
// SKU 不存在
|
||||
if (items.size() != skus.size()) {
|
||||
throw exception(ORDER_CREATE_SKU_NOT_FOUND);
|
||||
}
|
||||
// 校验库存不足
|
||||
Map<Long, ProductSkuRespDTO> skuMap = convertMap(skus, ProductSkuRespDTO::getId);
|
||||
items.forEach(item -> {
|
||||
ProductSkuRespDTO sku = skuMap.get(item.getSkuId());
|
||||
if (item.getCount() > sku.getStock()) {
|
||||
throw exception(ErrorCodeConstants.ORDER_CREATE_SKU_STOCK_NOT_ENOUGH);
|
||||
}
|
||||
});
|
||||
return skus;
|
||||
}
|
||||
// /**
|
||||
// * 校验商品 SKU 是否可出售
|
||||
// *
|
||||
// * @param items 商品 SKU
|
||||
// * @return 商品 SKU 数组
|
||||
// */
|
||||
// private List<ProductSkuRespDTO> validateSkuSaleable(List<Item> items) {
|
||||
// List<ProductSkuRespDTO> skus = productSkuApi.getSkuList(convertSet(items, Item::getSkuId));
|
||||
// // SKU 不存在
|
||||
// if (items.size() != skus.size()) {
|
||||
// throw exception(ORDER_CREATE_SKU_NOT_FOUND);
|
||||
// }
|
||||
// // 校验库存不足
|
||||
// Map<Long, ProductSkuRespDTO> skuMap = convertMap(skus, ProductSkuRespDTO::getId);
|
||||
// items.forEach(item -> {
|
||||
// ProductSkuRespDTO sku = skuMap.get(item.getSkuId());
|
||||
// if (item.getCount() > sku.getStock()) {
|
||||
// throw exception(ErrorCodeConstants.ORDER_CREATE_SKU_STOCK_NOT_ENOUGH);
|
||||
// }
|
||||
// });
|
||||
// return skus;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 校验商品 SPU 是否可出售
|
||||
@@ -506,6 +507,9 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
|
||||
@Override
|
||||
public List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds) {
|
||||
if (CollUtil.isEmpty(orderIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return tradeOrderItemMapper.selectListByOrderId(orderIds);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user