完善了小程序端用户创建订单接口

This commit is contained in:
chen-xin-zhi 2024-11-09 15:23:36 +08:00
parent 51cfb9eb00
commit c25a92777e
3 changed files with 20 additions and 2 deletions

View File

@ -1,23 +1,27 @@
package com.cultural.heritage.model.dto.order.capital; package com.cultural.heritage.model.dto.order.capital;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@Schema(description = "订单明细主要信息请求体", requiredProperties = {"goodId", "quantity"})
public class OrderItemMainInfoAddRequest implements Serializable { public class OrderItemMainInfoAddRequest implements Serializable {
/** /**
* 商品id * 商品id
*/ */
@Schema(description = "商品id(id > 0)", example = "8")
private Long goodId; private Long goodId;
/** /**
* 购买 * 购买
*/ */
@Schema(description = "购买数量", example = "10")
private Integer quantity; private Integer quantity;

View File

@ -1,5 +1,6 @@
package com.cultural.heritage.model.dto.order.capital; package com.cultural.heritage.model.dto.order.capital;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.io.Serial; import java.io.Serial;
@ -7,63 +8,75 @@ import java.io.Serializable;
import java.util.List; import java.util.List;
@Data @Data
@Schema(description = "订单主要信息请求体", requiredProperties = {"userId", "userName", "orderNumber", "addressId", "contactsId",
"couponId", "totalAmount", "orderStatus", "note", "orderItemMainInfoAddRequestList"})
public class OrderMainInfoAddRequest implements Serializable { public class OrderMainInfoAddRequest implements Serializable {
/** /**
* 用户id * 用户id
*/ */
@Schema(description = "用户id(id > 0)", example = "2")
private Long userId; private Long userId;
/** /**
* 用户昵称 * 用户昵称
*/ */
@Schema(description = "用户昵称", example = "Hello")
private String userName; private String userName;
/** /**
* 订单编号 * 订单编号
*/ */
@Schema(description = "订单编号", example = "1432442845453453")
private String orderNumber; private String orderNumber;
/** /**
* 地址id * 地址id
*/ */
@Schema(description = "地址id(id > 0)", example = "12")
private Long addressId; private Long addressId;
/** /**
* 联系人id * 联系人id
*/ */
@Schema(description = "联系人id(id > 0)", example = "3")
private Long contactsId; private Long contactsId;
/** /**
* 优惠券id * 优惠券id
*/ */
@Schema(description = "优惠券id(id > 0)", example = "2")
private Long couponId; private Long couponId;
/** /**
* 订单总金额 * 订单总金额
*/ */
@Schema(description = "订单总金额", example = "560")
private Double totalAmount; private Double totalAmount;
/** /**
* 订单状态 * 订单状态
*/ */
@Schema(description = "订单状态", example = "已支付")
private String orderStatus; private String orderStatus;
/** /**
* 订单备注 * 订单备注
*/ */
@Schema(description = "订单备注", example = "希望能完整体验非遗文化,保持产品原貌,妥善包装")
private String note; private String note;
/** /**
* 订单主要明细信息 * 订单主要明细信息
*/ */
@Schema(description = "订单主要明细信息")
private List<OrderItemMainInfoAddRequest> orderItemMainInfoAddRequestList; private List<OrderItemMainInfoAddRequest> orderItemMainInfoAddRequestList;

View File

@ -43,8 +43,9 @@ public class CartRecordServiceImpl extends ServiceImpl<CartRecordMapper, CartRec
boolean result = this.updateById(cartRecord); boolean result = this.updateById(cartRecord);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
} else { } else {
BeanUtils.copyProperties(cartRecordAddRequest, cartRecord); CartRecord cartGood = new CartRecord();
boolean result = this.save(cartRecord); BeanUtils.copyProperties(cartRecordAddRequest, cartGood);
boolean result = this.save(cartGood);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
} }
return true; return true;