- 添加订单收件人信息
- 分离订单物流信息
This commit is contained in:
parent
4595db1d4c
commit
bbd23caeff
@ -56,6 +56,14 @@ public interface OrderService {
|
||||
*/
|
||||
CommonResult cancelOrder(Integer orderId, Integer reasons, String otherReasons);
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
*
|
||||
* @param orderDelivery
|
||||
* @return
|
||||
*/
|
||||
CommonResult orderDelivery(OrderDeliveryDTO orderDelivery);
|
||||
|
||||
/**
|
||||
* 更新订单 - 备注
|
||||
*
|
||||
|
@ -90,7 +90,7 @@ public class OrderBO implements Serializable {
|
||||
/**
|
||||
* 订单物流信息
|
||||
*/
|
||||
private OrderLogisticsBO orderLogistics;
|
||||
private OrderRecipientBO orderRecipient;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -108,7 +108,7 @@ public class OrderBO implements Serializable {
|
||||
", status=" + status +
|
||||
", remark='" + remark + '\'' +
|
||||
", orderItems=" + orderItems +
|
||||
", orderLogistics=" + orderLogistics +
|
||||
", orderRecipient=" + orderRecipient +
|
||||
'}';
|
||||
}
|
||||
|
||||
@ -229,12 +229,12 @@ public class OrderBO implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrderLogisticsBO getOrderLogistics() {
|
||||
return orderLogistics;
|
||||
public OrderRecipientBO getOrderRecipient() {
|
||||
return orderRecipient;
|
||||
}
|
||||
|
||||
public OrderBO setOrderLogistics(OrderLogisticsBO orderLogistics) {
|
||||
this.orderLogistics = orderLogistics;
|
||||
public OrderBO setOrderRecipient(OrderRecipientBO orderRecipient) {
|
||||
this.orderRecipient = orderRecipient;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,103 @@
|
||||
package cn.iocoder.mall.order.api.bo;
|
||||
|
||||
import cn.iocoder.common.framework.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 订单收件人信息 order_recipient
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-31 11:37
|
||||
*/
|
||||
public class OrderRecipientBO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 收件区域编号
|
||||
*/
|
||||
private String areaNo;
|
||||
/**
|
||||
* 收件人名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 收件手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 收件详细地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderRecipientBO{" +
|
||||
"id=" + id +
|
||||
", orderId=" + orderId +
|
||||
", areaNo='" + areaNo + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", mobile='" + mobile + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public OrderRecipientBO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public OrderRecipientBO setOrderId(Integer orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAreaNo() {
|
||||
return areaNo;
|
||||
}
|
||||
|
||||
public OrderRecipientBO setAreaNo(String areaNo) {
|
||||
this.areaNo = areaNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public OrderRecipientBO setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public OrderRecipientBO setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public OrderRecipientBO setAddress(String address) {
|
||||
this.address = address;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.mall.order.api.constant;
|
||||
|
||||
/**
|
||||
* 物流信息
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-30 22:33
|
||||
*/
|
||||
public enum LogisticsEnum {
|
||||
|
||||
LOGISTICS_1(1, "顺丰快递"),
|
||||
LOGISTICS_2(2, "圆通快递"),
|
||||
LOGISTICS_3(3, "申通快递"),
|
||||
LOGISTICS_4(4, "韵答快递"),
|
||||
LOGISTICS_5(5, "天天快递"),
|
||||
LOGISTICS_6(6, "EMS中国邮政"),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 状态值
|
||||
*/
|
||||
private Integer value;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
LogisticsEnum(int value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package cn.iocoder.mall.order.api.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-30 22:31
|
||||
*/
|
||||
public class OrderDeliveryDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 收件区域编号
|
||||
*/
|
||||
private String areaNo;
|
||||
/**
|
||||
* 收件人名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 收件手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 收件详细地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 物流 (字典)
|
||||
*/
|
||||
private Integer logistics;
|
||||
/**
|
||||
* 物流编号
|
||||
*/
|
||||
private String logisticsNo;
|
||||
|
||||
///
|
||||
/// 物理信息是跟 orderItem 走
|
||||
|
||||
/**
|
||||
* 订单 orderItemId
|
||||
*/
|
||||
private List<Integer> orderItemIds;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderDeliverGoodsDTO{" +
|
||||
"areaNo='" + areaNo + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", mobile='" + mobile + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
", logistics=" + logistics +
|
||||
", logisticsNo='" + logisticsNo + '\'' +
|
||||
", orderItemIds=" + orderItemIds +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getAreaNo() {
|
||||
return areaNo;
|
||||
}
|
||||
|
||||
public OrderDeliveryDTO setAreaNo(String areaNo) {
|
||||
this.areaNo = areaNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public OrderDeliveryDTO setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public OrderDeliveryDTO setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public OrderDeliveryDTO setAddress(String address) {
|
||||
this.address = address;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getLogistics() {
|
||||
return logistics;
|
||||
}
|
||||
|
||||
public OrderDeliveryDTO setLogistics(Integer logistics) {
|
||||
this.logistics = logistics;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLogisticsNo() {
|
||||
return logisticsNo;
|
||||
}
|
||||
|
||||
public OrderDeliveryDTO setLogisticsNo(String logisticsNo) {
|
||||
this.logisticsNo = logisticsNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Integer> getOrderItemIds() {
|
||||
return orderItemIds;
|
||||
}
|
||||
|
||||
public OrderDeliveryDTO setOrderItemIds(List<Integer> orderItemIds) {
|
||||
this.orderItemIds = orderItemIds;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.mall.order.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.bo.OrderRecipientBO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单收件人信息
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-31 12:50
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderRecipientConvert {
|
||||
|
||||
OrderRecipientConvert INSTANCE = Mappers.getMapper(OrderRecipientConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
OrderRecipientDO convert(OrderCreateDTO orderCreateDTO);
|
||||
|
||||
@Mappings({})
|
||||
List<OrderRecipientBO> convert(List<OrderRecipientDO> orderRecipientDOList);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.mall.order.biz.dao;
|
||||
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单收件人 信息
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-31 12:16
|
||||
*/
|
||||
@Repository
|
||||
public interface OrderRecipientMapper {
|
||||
|
||||
/**
|
||||
* 插入 - 订单收件人
|
||||
*
|
||||
* @param orderRecipient
|
||||
* @return
|
||||
*/
|
||||
int insert(OrderRecipientDO orderRecipient);
|
||||
|
||||
/**
|
||||
* 查询 - 根据 orderIds
|
||||
*
|
||||
* @param orderIds
|
||||
* @return
|
||||
*/
|
||||
List<OrderRecipientDO> selectByOrderIds(
|
||||
@Param("orderIds")Collection<Integer> orderIds
|
||||
);
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package cn.iocoder.mall.order.biz.dataobject;
|
||||
|
||||
import cn.iocoder.common.framework.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 订单收件人信息 order_recipient
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-31 11:37
|
||||
*/
|
||||
public class OrderRecipientDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 收件区域编号
|
||||
*/
|
||||
private String areaNo;
|
||||
/**
|
||||
* 收件人名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 收件手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 收件详细地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderRecipientDO{" +
|
||||
"id=" + id +
|
||||
", orderId=" + orderId +
|
||||
", areaNo='" + areaNo + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", mobile='" + mobile + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public OrderRecipientDO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public OrderRecipientDO setOrderId(Integer orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAreaNo() {
|
||||
return areaNo;
|
||||
}
|
||||
|
||||
public OrderRecipientDO setAreaNo(String areaNo) {
|
||||
this.areaNo = areaNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public OrderRecipientDO setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public OrderRecipientDO setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public OrderRecipientDO setAddress(String address) {
|
||||
this.address = address;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -13,14 +13,9 @@ import cn.iocoder.mall.order.biz.OrderCommon;
|
||||
import cn.iocoder.mall.order.biz.convert.OrderConvert;
|
||||
import cn.iocoder.mall.order.biz.convert.OrderItemConvert;
|
||||
import cn.iocoder.mall.order.biz.convert.OrderLogisticsConvert;
|
||||
import cn.iocoder.mall.order.biz.dao.OrderCancelMapper;
|
||||
import cn.iocoder.mall.order.biz.dao.OrderItemMapper;
|
||||
import cn.iocoder.mall.order.biz.dao.OrderLogisticsMapper;
|
||||
import cn.iocoder.mall.order.biz.dao.OrderMapper;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderCancelDO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO;
|
||||
import cn.iocoder.mall.order.biz.convert.OrderRecipientConvert;
|
||||
import cn.iocoder.mall.order.biz.dao.*;
|
||||
import cn.iocoder.mall.order.biz.dataobject.*;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -47,6 +42,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Autowired
|
||||
private OrderLogisticsMapper orderLogisticsMapper;
|
||||
@Autowired
|
||||
private OrderRecipientMapper orderRecipientMapper;
|
||||
@Autowired
|
||||
private OrderCancelMapper orderCancelMapper;
|
||||
@Autowired
|
||||
private OrderCommon orderCommon;
|
||||
@ -67,16 +64,11 @@ public class OrderServiceImpl implements OrderService {
|
||||
.map(orderDO -> orderDO.getId())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<Integer> orderLogisticsIds = orderDOList.stream()
|
||||
.map(orderDO -> orderDO.getOrderLogisticsId())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 获取物流信息
|
||||
List<OrderLogisticsDO> orderLogisticsDOList = orderLogisticsMapper.selectByIds(orderLogisticsIds);
|
||||
List<OrderLogisticsBO> orderLogisticsBOList
|
||||
= OrderLogisticsConvert.INSTANCE.convertOrderLogisticsBO(orderLogisticsDOList);
|
||||
Map<Integer, OrderLogisticsBO> orderLogisticsDOMap
|
||||
= orderLogisticsBOList.stream().collect(Collectors.toMap(OrderLogisticsBO::getId, obj -> obj));
|
||||
List<OrderRecipientDO> orderRecipientDOList = orderRecipientMapper.selectByOrderIds(orderIds);
|
||||
List<OrderRecipientBO> orderRecipientBOList = OrderRecipientConvert.INSTANCE.convert(orderRecipientDOList);
|
||||
Map<Integer, OrderRecipientBO> orderRecipientBOMap
|
||||
= orderRecipientBOList.stream().collect(Collectors.toMap(OrderRecipientBO::getOrderId, obj -> obj));
|
||||
|
||||
// 获取 订单的 items
|
||||
List<OrderItemDO> orderItemDOList = orderItemMapper
|
||||
@ -100,8 +92,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
if (orderItemBOMultimap.containsKey(orderBO.getId())) {
|
||||
orderBO.setOrderItems(orderItemBOMultimap.get(orderBO.getId()));
|
||||
}
|
||||
if (orderLogisticsDOMap.containsKey(orderBO.getOrderLogisticsId())) {
|
||||
orderBO.setOrderLogistics(orderLogisticsDOMap.get(orderBO.getOrderLogisticsId()));
|
||||
if (orderRecipientBOMap.containsKey(orderBO.getId())) {
|
||||
orderBO.setOrderRecipient(orderRecipientBOMap.get(orderBO.getId()));
|
||||
}
|
||||
return orderBO;
|
||||
}).collect(Collectors.toList());
|
||||
@ -117,7 +109,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Transactional
|
||||
public CommonResult<OrderCreateBO> createOrder(Integer userId, OrderCreateDTO orderCreateDTO) {
|
||||
List<OrderCreateItemDTO> orderItemDTOList = orderCreateDTO.getOrderItems();
|
||||
OrderLogisticsDO orderLogisticsDO = OrderLogisticsConvert.INSTANCE.convert(orderCreateDTO);
|
||||
OrderRecipientDO orderRecipientDO = OrderRecipientConvert.INSTANCE.convert(orderCreateDTO);
|
||||
List<OrderItemDO> orderItemDOList = OrderItemConvert.INSTANCE.convert(orderItemDTOList);
|
||||
|
||||
// TODO: 2019-03-24 sin 校验商品是否存在
|
||||
@ -137,17 +129,10 @@ public class OrderServiceImpl implements OrderService {
|
||||
// orderItemDO.setPrice(1000);
|
||||
// }
|
||||
|
||||
// 物流信息
|
||||
orderLogisticsDO
|
||||
.setLogisticsNo("")
|
||||
.setCreateTime(new Date())
|
||||
.setUpdateTime(null);
|
||||
orderLogisticsMapper.insert(orderLogisticsDO);
|
||||
|
||||
// order
|
||||
OrderDO orderDO = new OrderDO()
|
||||
.setUserId(userId)
|
||||
.setOrderLogisticsId(orderLogisticsDO.getId())
|
||||
.setOrderLogisticsId(null)
|
||||
.setOrderNo(UUID.randomUUID().toString().replace("-", ""))
|
||||
.setPayAmount(-1) // 先设置一个默认值,金额在下面计算
|
||||
.setClosingTime(null)
|
||||
@ -162,6 +147,14 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderDO.setUpdateTime(null);
|
||||
orderMapper.insert(orderDO);
|
||||
|
||||
// 收件人信息
|
||||
orderRecipientDO
|
||||
.setOrderId(orderDO.getId())
|
||||
.setCreateTime(new Date())
|
||||
.setUpdateTime(null);
|
||||
|
||||
orderRecipientMapper.insert(orderRecipientDO);
|
||||
|
||||
// order item
|
||||
orderItemDOList.forEach(orderItemDO -> {
|
||||
int goodsPrice = 1000; // 商品单价
|
||||
@ -271,6 +264,11 @@ public class OrderServiceImpl implements OrderService {
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult orderDelivery(OrderDeliveryDTO orderDelivery) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult updateOrderRemake(Integer orderId, String remake) {
|
||||
// 此处不做订单校验,直接设置备注即可
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?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.biz.dao.OrderRecipientMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, order_id, `area_no`, `name`, mobile, address,
|
||||
create_time, update_time
|
||||
</sql>
|
||||
|
||||
<!--
|
||||
插入数据
|
||||
-->
|
||||
<insert id="insert" parameterType="OrderRecipientDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO `order_recipient` (
|
||||
order_id, `area_no`, `name`, mobile, address,
|
||||
create_time, update_time
|
||||
) VALUES (
|
||||
#{orderId}, #{areaNo}, #{name}, #{mobile}, #{address},
|
||||
#{createTime}, #{updateTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!--
|
||||
查询 - 根据 orderIds
|
||||
-->
|
||||
<select id="selectByOrderIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM `order_recipient`
|
||||
WHERE order_id IN
|
||||
<foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user