diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java index 972614316..adb385add 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java @@ -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); /** * 监听支付动作 diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderBO.java index 41a67260c..75a8d97c9 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderBO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderBO.java @@ -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; + } } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderDeleteStatusEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderDeleteStatusEnum.java new file mode 100644 index 000000000..b75b7105f --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderDeleteStatusEnum.java @@ -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; + } +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderPayStatusEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderPayStatusEnum.java index b9e9c507b..852cd835f 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderPayStatusEnum.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderPayStatusEnum.java @@ -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; } } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderStatusEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderStatusEnum.java index dd4b315b2..d52dca864 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderStatusEnum.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderStatusEnum.java @@ -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; + } +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCreateDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCreateDTO.java index 81cb3b819..c1c769367 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCreateDTO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCreateDTO.java @@ -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; } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReceiverInformationDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReceiverInformationDTO.java new file mode 100644 index 000000000..bcf5091a9 --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReceiverInformationDTO.java @@ -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; + } +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderUpdateDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderUpdateDTO.java index 93ef4be1a..9ccf7a7ba 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderUpdateDTO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderUpdateDTO.java @@ -9,4 +9,8 @@ import java.io.Serializable; * @time 2019-03-16 14:46 */ public class OrderUpdateDTO implements Serializable { + + + + } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderConvert.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderConvert.java index e5209c17e..ac6b2dfb2 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderConvert.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderConvert.java @@ -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 convert(List orderCreateItemDTOList); + + /** + * 转换 OrderDO - orderReceiverInformationDTO + * + * @param orderReceiverInformationDTO + * @return + */ + @Mappings({}) + OrderDO convert(OrderReceiverInformationDTO orderReceiverInformationDTO); } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderItemMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderItemMapper.java new file mode 100644 index 000000000..f53ac33b7 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderItemMapper.java @@ -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); +} diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java index 45ad68977..207e76627 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java @@ -18,4 +18,12 @@ public interface OrderMapper { * @param orderDO */ void insert(OrderDO orderDO); + + /** + * 更新 - 根据 id 更新 + * + * @param orderDO + * @return + */ + int updateById(OrderDO orderDO); } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java index f4fcb79d3..f0efef0ab 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java @@ -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; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java index 20fe8ff2a..4c9c920b0 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java @@ -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; + } } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java index 6263d5d58..970b559b5 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java @@ -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 orderItemDTOList = orderCreateDTO.getOrderItems(); OrderDO orderDO = OrderConvert.INSTANCE.convert(orderCreateDTO); List 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 diff --git a/order/order-service-impl/src/main/resources/config/application.yaml b/order/order-service-impl/src/main/resources/config/application.yaml index 598257e83..378b08680 100644 --- a/order/order-service-impl/src/main/resources/config/application.yaml +++ b/order/order-service-impl/src/main/resources/config/application.yaml @@ -22,4 +22,9 @@ dubbo: port: -1 name: dubbo scan: - base-packages: cn.iocoder.mall.order.service \ No newline at end of file + base-packages: cn.iocoder.mall.order.service + +# logging +logging: + level: + cn.iocoder.mall.order.dao: debug diff --git a/order/order-service-impl/src/main/resources/mapper/OrderItemMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderItemMapper.xml new file mode 100644 index 000000000..4271d7fcb --- /dev/null +++ b/order/order-service-impl/src/main/resources/mapper/OrderItemMapper.xml @@ -0,0 +1,23 @@ + + + + + + id, order_id, commodity_id, quantity, price, + status, deliveryTime + + + + + INSERT INTO `order_item` ( + order_id, commodity_id, quantity, price, + status, deliveryTime + ) VALUES ( + #{orderId}, #{commodityId}, #{quantity}, #{price}, + #{status}, #{deliveryTime} + ) + + + \ No newline at end of file diff --git a/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml index 04cab6fd0..a1ac6d962 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml @@ -3,21 +3,79 @@ - 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 + - 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} ) + + + + + , order_no = #{orderNo} + + + , price = #{price} + + + , receiver_area_no = #{receiverAreaNo} + + + , receiver_mobile = #{receiverMobile} + + + , receiver_address = #{receiverAddress} + + + , status = #{status} + + + , pay_status = #{payStatus} + + + , delete_status = #{deleteStatus} + + + , create_time = #{createTime} + + + , payment_time = #{paymentTime} + + + , delivery_time = #{deliveryTime} + + + , closing_time = #{closingTime} + + + , remark = #{remark} + + + + + + + UPDATE `order` + + WHERE id = #{id} + \ No newline at end of file diff --git a/order/order-service-impl/src/test/java/cn/iocoder/mall/order/service/OrderServiceImplTest.java b/order/order-service-impl/src/test/java/cn/iocoder/mall/order/service/OrderServiceImplTest.java index 971e5441e..6cbc1753f 100644 --- a/order/order-service-impl/src/test/java/cn/iocoder/mall/order/service/OrderServiceImplTest.java +++ b/order/order-service-impl/src/test/java/cn/iocoder/mall/order/service/OrderServiceImplTest.java @@ -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()