- 添加订单 创建、更新收件人信息 操作
parent
ba7669f3a2
commit
b1b70318dc
|
@ -2,6 +2,7 @@ package cn.iocoder.mall.order.api;
|
|||
|
||||
import cn.iocoder.mall.order.api.bo.OrderBO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReceiverInformationDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderUpdateDTO;
|
||||
|
||||
/**
|
||||
|
@ -27,12 +28,23 @@ public interface OrderService {
|
|||
*/
|
||||
void updateOrder(OrderUpdateDTO orderUpdateDTO);
|
||||
|
||||
/**
|
||||
* 更新订单 - 收件这信息
|
||||
*
|
||||
* 包含:
|
||||
* - 详细地址
|
||||
* - 区域编号
|
||||
* - 联系人电话
|
||||
* - 联系人姓名
|
||||
*/
|
||||
void updateOrderReceiverInformation(OrderReceiverInformationDTO orderReceiverInfoDTO);
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
*
|
||||
* @param orderId
|
||||
* @param id
|
||||
*/
|
||||
void deleteOrder(String orderId);
|
||||
void deleteOrder(Integer id);
|
||||
|
||||
/**
|
||||
* 监听支付动作
|
||||
|
|
|
@ -9,4 +9,53 @@ import java.io.Serializable;
|
|||
* @time 2019-03-16 14:38
|
||||
*/
|
||||
public class OrderBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderNo;
|
||||
/**
|
||||
* 交易金额
|
||||
*/
|
||||
private Integer price;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderBO{" +
|
||||
"id=" + id +
|
||||
", orderNo='" + orderNo + '\'' +
|
||||
", price=" + price +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public OrderBO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOrderNo() {
|
||||
return orderNo;
|
||||
}
|
||||
|
||||
public OrderBO setOrderNo(String orderNo) {
|
||||
this.orderNo = orderNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public OrderBO setPrice(Integer price) {
|
||||
this.price = price;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package cn.iocoder.mall.order.api.constants;
|
||||
|
||||
/**
|
||||
* 订单 deleteStatus
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-17 20:58
|
||||
*/
|
||||
public enum OrderDeleteStatusEnum {
|
||||
|
||||
DELETE_NO(0, "正常"),
|
||||
DELETE_YES(1, "已删除")
|
||||
;
|
||||
|
||||
private final int value;
|
||||
|
||||
private final String name;
|
||||
|
||||
OrderDeleteStatusEnum(int value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -17,10 +17,18 @@ public enum OrderPayStatusEnum {
|
|||
|
||||
private final int value;
|
||||
|
||||
private final String text;
|
||||
private final String name;
|
||||
|
||||
OrderPayStatusEnum(int value, String text) {
|
||||
OrderPayStatusEnum(int value, String name) {
|
||||
this.value = value;
|
||||
this.text = text;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,18 @@ public enum OrderStatusEnum {
|
|||
|
||||
private final int value;
|
||||
|
||||
private final String text;
|
||||
private final String name;
|
||||
|
||||
OrderStatusEnum(int value, String text) {
|
||||
OrderStatusEnum(int value, String name) {
|
||||
this.value = value;
|
||||
this.text = text;
|
||||
}}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ public class OrderCreateDTO implements Serializable {
|
|||
*/
|
||||
@NotNull
|
||||
private String receiverAreaNo;
|
||||
/**
|
||||
* 收件人名称
|
||||
*/
|
||||
@NotNull
|
||||
private String receiverName;
|
||||
/**
|
||||
* 收件手机号
|
||||
*/
|
||||
|
@ -44,6 +49,7 @@ public class OrderCreateDTO implements Serializable {
|
|||
public String toString() {
|
||||
return "OrderCreateDTO{" +
|
||||
"receiverAreaNo='" + receiverAreaNo + '\'' +
|
||||
", receiverName='" + receiverName + '\'' +
|
||||
", receiverMobile='" + receiverMobile + '\'' +
|
||||
", receiverAddress='" + receiverAddress + '\'' +
|
||||
", remark='" + remark + '\'' +
|
||||
|
@ -60,6 +66,15 @@ public class OrderCreateDTO implements Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public String getReceiverName() {
|
||||
return receiverName;
|
||||
}
|
||||
|
||||
public OrderCreateDTO setReceiverName(String receiverName) {
|
||||
this.receiverName = receiverName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getReceiverMobile() {
|
||||
return receiverMobile;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
package cn.iocoder.mall.order.api.dto;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 订单收件人信息
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-17 20:22
|
||||
*/
|
||||
public class OrderReceiverInformationDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 订单 id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 收件区域编号
|
||||
*/
|
||||
@NotNull
|
||||
private String receiverAreaNo;
|
||||
/**
|
||||
* 收件人名称
|
||||
*/
|
||||
@NotNull
|
||||
private String receiverName;
|
||||
/**
|
||||
* 收件手机号
|
||||
*/
|
||||
@NotNull
|
||||
@Size(max = 11, min = 11)
|
||||
// TODO: 2019-03-17 Sin 此处需要添加 手机号校验,需要添加新的注解
|
||||
private String receiverMobile;
|
||||
/**
|
||||
* 收件详细地址
|
||||
*/
|
||||
@NotNull
|
||||
@Size(max = 250, min = 10, message = "收件地址应该在 10 ~ 250 个字符之间")
|
||||
private String receiverAddress;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderReceiverInformationDTO{" +
|
||||
"id=" + id +
|
||||
", receiverAreaNo='" + receiverAreaNo + '\'' +
|
||||
", receiverName='" + receiverName + '\'' +
|
||||
", receiverMobile='" + receiverMobile + '\'' +
|
||||
", receiverAddress='" + receiverAddress + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public OrderReceiverInformationDTO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getReceiverAreaNo() {
|
||||
return receiverAreaNo;
|
||||
}
|
||||
|
||||
public OrderReceiverInformationDTO setReceiverAreaNo(String receiverAreaNo) {
|
||||
this.receiverAreaNo = receiverAreaNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getReceiverName() {
|
||||
return receiverName;
|
||||
}
|
||||
|
||||
public OrderReceiverInformationDTO setReceiverName(String receiverName) {
|
||||
this.receiverName = receiverName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getReceiverMobile() {
|
||||
return receiverMobile;
|
||||
}
|
||||
|
||||
public OrderReceiverInformationDTO setReceiverMobile(String receiverMobile) {
|
||||
this.receiverMobile = receiverMobile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getReceiverAddress() {
|
||||
return receiverAddress;
|
||||
}
|
||||
|
||||
public OrderReceiverInformationDTO setReceiverAddress(String receiverAddress) {
|
||||
this.receiverAddress = receiverAddress;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -9,4 +9,8 @@ import java.io.Serializable;
|
|||
* @time 2019-03-16 14:46
|
||||
*/
|
||||
public class OrderUpdateDTO implements Serializable {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.iocoder.mall.order.convert;
|
|||
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReceiverInformationDTO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderDO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderItemDO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
@ -22,7 +23,7 @@ public interface OrderConvert {
|
|||
OrderConvert INSTANCE = Mappers.getMapper(OrderConvert.class);
|
||||
|
||||
/**
|
||||
* 转换 OrderDO
|
||||
* 转换 OrderDO - OrderCreateDTO
|
||||
*
|
||||
* @param orderCreateDTO
|
||||
* @return
|
||||
|
@ -31,11 +32,20 @@ public interface OrderConvert {
|
|||
OrderDO convert(OrderCreateDTO orderCreateDTO);
|
||||
|
||||
/**
|
||||
* 转换 OrderItemDO
|
||||
* 转换 OrderItemDO - orderCreateItemDTOList
|
||||
*
|
||||
* @param orderCreateItemDTOList
|
||||
* @return
|
||||
*/
|
||||
@Mappings({})
|
||||
List<OrderItemDO> convert(List<OrderCreateItemDTO> orderCreateItemDTOList);
|
||||
|
||||
/**
|
||||
* 转换 OrderDO - orderReceiverInformationDTO
|
||||
*
|
||||
* @param orderReceiverInformationDTO
|
||||
* @return
|
||||
*/
|
||||
@Mappings({})
|
||||
OrderDO convert(OrderReceiverInformationDTO orderReceiverInformationDTO);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package cn.iocoder.mall.order.dao;
|
||||
|
||||
import cn.iocoder.mall.order.dataobject.OrderItemDO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 订单 item mapper
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-16 15:09
|
||||
*/
|
||||
@Repository
|
||||
public interface OrderItemMapper {
|
||||
|
||||
/**
|
||||
* 插入数据
|
||||
*
|
||||
* @param orderItemDO
|
||||
*/
|
||||
void insert(OrderItemDO orderItemDO);
|
||||
}
|
|
@ -18,4 +18,12 @@ public interface OrderMapper {
|
|||
* @param orderDO
|
||||
*/
|
||||
void insert(OrderDO orderDO);
|
||||
|
||||
/**
|
||||
* 更新 - 根据 id 更新
|
||||
*
|
||||
* @param orderDO
|
||||
* @return
|
||||
*/
|
||||
int updateById(OrderDO orderDO);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class OrderDO implements Serializable {
|
|||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String id;
|
||||
private Integer id;
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
|
@ -27,6 +27,10 @@ public class OrderDO implements Serializable {
|
|||
* 收件区域编号
|
||||
*/
|
||||
private String receiverAreaNo;
|
||||
/**
|
||||
* 收件人名称
|
||||
*/
|
||||
private String receiverName;
|
||||
/**
|
||||
* 收件手机号
|
||||
*/
|
||||
|
@ -55,6 +59,13 @@ public class OrderDO implements Serializable {
|
|||
* - 2、已退款
|
||||
*/
|
||||
private Integer payStatus;
|
||||
/**
|
||||
* 删除状态
|
||||
*
|
||||
* - 0 未删除
|
||||
* - 1 已删除
|
||||
*/
|
||||
private Integer deleteStatus;
|
||||
/**
|
||||
* 订单创建时间
|
||||
*/
|
||||
|
@ -78,15 +89,17 @@ public class OrderDO implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Order{" +
|
||||
"id='" + id + '\'' +
|
||||
return "OrderDO{" +
|
||||
"id=" + id +
|
||||
", orderNo='" + orderNo + '\'' +
|
||||
", price=" + price +
|
||||
", receiverAreaNo='" + receiverAreaNo + '\'' +
|
||||
", receiverName='" + receiverName + '\'' +
|
||||
", receiverMobile='" + receiverMobile + '\'' +
|
||||
", receiverAddress='" + receiverAddress + '\'' +
|
||||
", status=" + status +
|
||||
", payStatus=" + payStatus +
|
||||
", deleteStatus=" + deleteStatus +
|
||||
", createTime=" + createTime +
|
||||
", paymentTime=" + paymentTime +
|
||||
", deliveryTime=" + deliveryTime +
|
||||
|
@ -95,11 +108,11 @@ public class OrderDO implements Serializable {
|
|||
'}';
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public OrderDO setId(String id) {
|
||||
public OrderDO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
@ -131,6 +144,15 @@ public class OrderDO implements Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public String getReceiverName() {
|
||||
return receiverName;
|
||||
}
|
||||
|
||||
public OrderDO setReceiverName(String receiverName) {
|
||||
this.receiverName = receiverName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getReceiverMobile() {
|
||||
return receiverMobile;
|
||||
}
|
||||
|
@ -167,6 +189,15 @@ public class OrderDO implements Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Integer getDeleteStatus() {
|
||||
return deleteStatus;
|
||||
}
|
||||
|
||||
public OrderDO setDeleteStatus(Integer deleteStatus) {
|
||||
this.deleteStatus = deleteStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cn.iocoder.mall.order.dataobject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单 item
|
||||
|
@ -13,11 +14,11 @@ public class OrderItemDO implements Serializable {
|
|||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String id;
|
||||
private Integer id;
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderId;
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 商品编号
|
||||
*/
|
||||
|
@ -42,33 +43,38 @@ public class OrderItemDO implements Serializable {
|
|||
* - 41、已退货
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 发货时间
|
||||
*/
|
||||
private Date deliveryTime;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderItem{" +
|
||||
"id='" + id + '\'' +
|
||||
return "OrderItemDO{" +
|
||||
"id=" + id +
|
||||
", orderId='" + orderId + '\'' +
|
||||
", commodityId='" + commodityId + '\'' +
|
||||
", quantity=" + quantity +
|
||||
", price=" + price +
|
||||
", status=" + status +
|
||||
", deliveryTime=" + deliveryTime +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public OrderItemDO setId(String id) {
|
||||
public OrderItemDO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
public Integer getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public OrderItemDO setOrderId(String orderId) {
|
||||
public OrderItemDO setOrderId(Integer orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
}
|
||||
|
@ -108,4 +114,13 @@ public class OrderItemDO implements Serializable {
|
|||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDeliveryTime() {
|
||||
return deliveryTime;
|
||||
}
|
||||
|
||||
public OrderItemDO setDeliveryTime(Date deliveryTime) {
|
||||
this.deliveryTime = deliveryTime;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,26 @@ package cn.iocoder.mall.order.service;
|
|||
|
||||
import cn.iocoder.mall.order.api.OrderService;
|
||||
import cn.iocoder.mall.order.api.bo.OrderBO;
|
||||
import cn.iocoder.mall.order.api.constants.OrderDeleteStatusEnum;
|
||||
import cn.iocoder.mall.order.api.constants.OrderPayStatusEnum;
|
||||
import cn.iocoder.mall.order.api.constants.OrderStatusEnum;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReceiverInformationDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderUpdateDTO;
|
||||
import cn.iocoder.mall.order.convert.OrderConvert;
|
||||
import cn.iocoder.mall.order.dao.OrderItemMapper;
|
||||
import cn.iocoder.mall.order.dao.OrderMapper;
|
||||
import cn.iocoder.mall.order.dataobject.OrderDO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderItemDO;
|
||||
import cn.iocoder.mall.order.convert.OrderConvert;
|
||||
import cn.iocoder.mall.order.dao.OrderMapper;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 订单 service impl
|
||||
|
@ -26,26 +35,45 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
@Autowired
|
||||
private OrderItemMapper orderItemMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public OrderBO createOrder(OrderCreateDTO orderCreateDTO) {
|
||||
List<OrderCreateItemDTO> orderItemDTOList = orderCreateDTO.getOrderItems();
|
||||
OrderDO orderDO = OrderConvert.INSTANCE.convert(orderCreateDTO);
|
||||
List<OrderItemDO> orderItemDOList = OrderConvert.INSTANCE.convert(orderItemDTOList);
|
||||
|
||||
// order
|
||||
orderDO.setOrderNo(UUID.randomUUID().toString().replace("-", ""));
|
||||
orderDO.setPrice(1000);
|
||||
orderDO.setCreateTime(new Date());
|
||||
orderDO.setClosingTime(null);
|
||||
orderDO.setDeliveryTime(null);
|
||||
orderDO.setPaymentTime(null);
|
||||
orderDO.setStatus(OrderStatusEnum.WAIT_SHIPMENT.getValue());
|
||||
orderDO.setPayStatus(OrderPayStatusEnum.WAITING_PAYMENT.getValue());
|
||||
orderDO.setDeleteStatus(OrderDeleteStatusEnum.DELETE_NO.getValue());
|
||||
orderMapper.insert(orderDO);
|
||||
String a = "";
|
||||
// orderConvert.con
|
||||
// for (OrderCreateItemDTO orderCreateItemDTO : orderItemDTOList) {
|
||||
// OrderItemDO orderItemDO = new OrderItemDO();
|
||||
// orderItemDO.setId();
|
||||
// orderItemDO.setCommodityId();
|
||||
// orderItemDO.setOrderId();
|
||||
// orderItemDO.setPrice();
|
||||
// orderItemDO.setQuantity();
|
||||
// orderItemDO.setStatus();
|
||||
// }
|
||||
// orderMapper.insert();
|
||||
return null;
|
||||
|
||||
// order item
|
||||
int goodsPrice = 1000;
|
||||
orderItemDOList.forEach(orderItemDO -> {
|
||||
int price = orderItemDO.getQuantity() * goodsPrice;
|
||||
orderItemDO
|
||||
.setStatus(OrderStatusEnum.WAIT_SHIPMENT.getValue())
|
||||
.setOrderId(orderDO.getId())
|
||||
.setPrice(price)
|
||||
.setDeliveryTime(null);
|
||||
|
||||
orderItemMapper.insert(orderItemDO);
|
||||
});
|
||||
|
||||
return new OrderBO()
|
||||
.setId(orderDO.getId())
|
||||
.setOrderNo(orderDO.getOrderNo())
|
||||
.setPrice(orderDO.getPrice());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,8 +82,19 @@ public class OrderServiceImpl implements OrderService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteOrder(String orderId) {
|
||||
public void updateOrderReceiverInformation(OrderReceiverInformationDTO orderReceiverInfoDTO) {
|
||||
// TODO: 2019-03-17 需要做校验 手机号
|
||||
OrderDO orderDO = OrderConvert.INSTANCE.convert(orderReceiverInfoDTO);
|
||||
orderMapper.updateById(orderDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOrder(Integer id) {
|
||||
// 删除订单操作,一般用于 用户端删除,是否存在检查可以过掉
|
||||
orderMapper.updateById(new OrderDO()
|
||||
.setId(id)
|
||||
.setDeleteStatus(OrderDeleteStatusEnum.DELETE_YES.getValue())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,3 +23,8 @@ dubbo:
|
|||
name: dubbo
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.order.service
|
||||
|
||||
# logging
|
||||
logging:
|
||||
level:
|
||||
cn.iocoder.mall.order.dao: debug
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.mall.order.dao.OrderItemMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, order_id, commodity_id, quantity, price,
|
||||
status, deliveryTime
|
||||
</sql>
|
||||
|
||||
<!--
|
||||
插入数据
|
||||
-->
|
||||
<insert id="insert" parameterType="OrderItemDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO `order_item` (
|
||||
order_id, commodity_id, quantity, price,
|
||||
status, deliveryTime
|
||||
) VALUES (
|
||||
#{orderId}, #{commodityId}, #{quantity}, #{price},
|
||||
#{status}, #{deliveryTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
|
@ -3,21 +3,79 @@
|
|||
<mapper namespace="cn.iocoder.mall.order.dao.OrderMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, order_no, price, receiver_area_no, receiver_mobile,
|
||||
receiver_address, status, pay_status, create_time,
|
||||
order_no, price, receiver_area_no, receiver_mobile,
|
||||
receiver_address, `status`, pay_status, create_time,
|
||||
payment_time, delivery_time, closing_time, remark
|
||||
</sql>
|
||||
|
||||
<!--
|
||||
插入数据
|
||||
-->
|
||||
<insert id="insert" parameterType="OrderDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO order (
|
||||
id, order_no, price, receiver_area_no, receiver_mobile,
|
||||
receiver_address, status, pay_status, create_time,
|
||||
INSERT INTO `order` (
|
||||
order_no, price, receiver_area_no, receiver_mobile,
|
||||
receiver_address, `status`, pay_status, create_time,
|
||||
payment_time, delivery_time, closing_time, remark
|
||||
) VALUES (
|
||||
${orderNo}, ${price}, ${receiverAreaNo}, ${receiverMobile},
|
||||
${receiverAddress}, ${status}, ${payStatus}, ${createTime},
|
||||
${paymentTime}, ${deliveryTime}, ${closingTime}, ${remark}
|
||||
#{orderNo}, ${price}, #{receiverAreaNo}, #{receiverMobile},
|
||||
#{receiverAddress}, #{status}, #{payStatus}, #{createTime},
|
||||
#{paymentTime}, #{deliveryTime}, #{closingTime}, #{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!--
|
||||
更新 - 可更新的字段
|
||||
-->
|
||||
<sql id="updateSql" >
|
||||
<set>
|
||||
<if test="orderNo != null">
|
||||
, order_no = #{orderNo}
|
||||
</if>
|
||||
<if test="price != null">
|
||||
, price = #{price}
|
||||
</if>
|
||||
<if test="receiverAreaNo != null">
|
||||
, receiver_area_no = #{receiverAreaNo}
|
||||
</if>
|
||||
<if test="receiverMobile != null">
|
||||
, receiver_mobile = #{receiverMobile}
|
||||
</if>
|
||||
<if test="receiverAddress != null">
|
||||
, receiver_address = #{receiverAddress}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
, status = #{status}
|
||||
</if>
|
||||
<if test="payStatus != null">
|
||||
, pay_status = #{payStatus}
|
||||
</if>
|
||||
<if test="deleteStatus != null">
|
||||
, delete_status = #{deleteStatus}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
, create_time = #{createTime}
|
||||
</if>
|
||||
<if test="paymentTime != null">
|
||||
, payment_time = #{paymentTime}
|
||||
</if>
|
||||
<if test="deliveryTime != null">
|
||||
, delivery_time = #{deliveryTime}
|
||||
</if>
|
||||
<if test="closingTime != null">
|
||||
, closing_time = #{closingTime}
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
, remark = #{remark}
|
||||
</if>
|
||||
</set>
|
||||
</sql>
|
||||
|
||||
<!--
|
||||
更新 - 根据 id 更新
|
||||
-->
|
||||
<update id="updateById" parameterType="OrderDO">
|
||||
UPDATE `order`
|
||||
<include refid="updateSql" />
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
|
@ -8,8 +8,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -26,9 +26,18 @@ public class OrderServiceImplTest {
|
|||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Test
|
||||
public void createOrderTest() {
|
||||
// Properties properties = System.getProperties();
|
||||
// String url = properties.getProperty("spring.datasource.url");
|
||||
// System.err.println(url);
|
||||
|
||||
String url = environment.getProperty("spring.datasource.url");
|
||||
System.err.println(url);
|
||||
|
||||
|
||||
OrderCreateItemDTO orderCreateItemDTO
|
||||
= new OrderCreateItemDTO()
|
||||
|
|
Loading…
Reference in New Issue