- 添加订单 info
This commit is contained in:
parent
204452c9d0
commit
0ca854587e
|
@ -4,6 +4,7 @@ import cn.iocoder.common.framework.vo.CommonResult;
|
||||||
import cn.iocoder.mall.order.api.OrderLogisticsService;
|
import cn.iocoder.mall.order.api.OrderLogisticsService;
|
||||||
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
|
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
|
||||||
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
||||||
|
import com.alibaba.dubbo.config.annotation.Reference;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -23,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@Api(description = "订单物流信息")
|
@Api(description = "订单物流信息")
|
||||||
public class OrderLogisticsController {
|
public class OrderLogisticsController {
|
||||||
|
|
||||||
@Autowired
|
@Reference(validation = "true")
|
||||||
private OrderLogisticsService orderLogisticsService;
|
private OrderLogisticsService orderLogisticsService;
|
||||||
|
|
||||||
@GetMapping("logistics_info")
|
@GetMapping("logistics_info")
|
||||||
|
|
|
@ -3,12 +3,12 @@ package cn.iocoder.mall.order.application.controller.users;
|
||||||
import cn.iocoder.common.framework.util.HttpUtil;
|
import cn.iocoder.common.framework.util.HttpUtil;
|
||||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
import cn.iocoder.common.framework.vo.CommonResult;
|
||||||
|
import cn.iocoder.mall.admin.api.DataDictService;
|
||||||
|
import cn.iocoder.mall.admin.api.bo.DataDictBO;
|
||||||
import cn.iocoder.mall.order.api.CartService;
|
import cn.iocoder.mall.order.api.CartService;
|
||||||
import cn.iocoder.mall.order.api.OrderService;
|
import cn.iocoder.mall.order.api.OrderService;
|
||||||
import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO;
|
import cn.iocoder.mall.order.api.bo.*;
|
||||||
import cn.iocoder.mall.order.api.bo.CartItemBO;
|
import cn.iocoder.mall.order.api.constant.DictKeysConstants;
|
||||||
import cn.iocoder.mall.order.api.bo.OrderCreateBO;
|
|
||||||
import cn.iocoder.mall.order.api.bo.OrderPageBO;
|
|
||||||
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
|
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
|
||||||
import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
|
import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
|
||||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||||
|
@ -20,6 +20,7 @@ import cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO;
|
||||||
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
||||||
import com.alibaba.dubbo.config.annotation.Reference;
|
import com.alibaba.dubbo.config.annotation.Reference;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -43,8 +44,11 @@ public class UsersOrderController {
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
@Reference(validation = "true")
|
@Reference(validation = "true")
|
||||||
private CartService cartService;
|
private CartService cartService;
|
||||||
|
@Reference(validation = "true")
|
||||||
|
private DataDictService dataDictService;
|
||||||
|
|
||||||
@GetMapping("order_page")
|
@GetMapping("order_page")
|
||||||
|
@ApiOperation("订单分页")
|
||||||
public CommonResult<OrderPageBO> getOrderPage(@Validated OrderQueryDTO orderQueryDTO) {
|
public CommonResult<OrderPageBO> getOrderPage(@Validated OrderQueryDTO orderQueryDTO) {
|
||||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||||
orderQueryDTO.setUserId(userId);
|
orderQueryDTO.setUserId(userId);
|
||||||
|
@ -52,6 +56,7 @@ public class UsersOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("create_order")
|
@PostMapping("create_order")
|
||||||
|
@ApiOperation("创建订单")
|
||||||
public CommonResult<OrderCreateBO> createOrder(@RequestBody @Validated OrderCreatePO orderCreatePO) {
|
public CommonResult<OrderCreateBO> createOrder(@RequestBody @Validated OrderCreatePO orderCreatePO) {
|
||||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||||
OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.convert(orderCreatePO);
|
OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.convert(orderCreatePO);
|
||||||
|
@ -60,6 +65,7 @@ public class UsersOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("create_order_from_cart")
|
@PostMapping("create_order_from_cart")
|
||||||
|
@ApiOperation("创建订单购物车")
|
||||||
public CommonResult<OrderCreateBO> createOrderFromCart(@RequestParam("userAddressId") Integer userAddressId,
|
public CommonResult<OrderCreateBO> createOrderFromCart(@RequestParam("userAddressId") Integer userAddressId,
|
||||||
@RequestParam(value = "remark", required = false) String remark,
|
@RequestParam(value = "remark", required = false) String remark,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
|
@ -85,6 +91,7 @@ public class UsersOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("confirm_create_order")
|
@GetMapping("confirm_create_order")
|
||||||
|
@ApiOperation("确认创建订单")
|
||||||
public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam("skuId") Integer skuId,
|
public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam("skuId") Integer skuId,
|
||||||
@RequestParam("quantity") Integer quantity) {
|
@RequestParam("quantity") Integer quantity) {
|
||||||
// 创建 CalcOrderPriceDTO 对象,并执行价格计算
|
// 创建 CalcOrderPriceDTO 对象,并执行价格计算
|
||||||
|
@ -99,9 +106,22 @@ public class UsersOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("confirm_receiving")
|
@PostMapping("confirm_receiving")
|
||||||
|
@ApiOperation("确认收货")
|
||||||
public CommonResult confirmReceiving(@RequestParam("orderId") Integer orderId) {
|
public CommonResult confirmReceiving(@RequestParam("orderId") Integer orderId) {
|
||||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||||
return orderService.confirmReceiving(userId, orderId);
|
return orderService.confirmReceiving(userId, orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("info")
|
||||||
|
@ApiOperation("订单详情")
|
||||||
|
public CommonResult<OrderInfoBO> orderInfo(@RequestParam("orderId") Integer orderId) {
|
||||||
|
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||||
|
CommonResult<OrderInfoBO> commonResult = orderService.info(userId, orderId);
|
||||||
|
|
||||||
|
OrderInfoBO orderInfoBO = commonResult.getData();
|
||||||
|
CommonResult<DataDictBO> dictResult = dataDictService
|
||||||
|
.getDataDict(DictKeysConstants.ORDER_STATUS_KEY, orderInfoBO.getStatus());
|
||||||
|
orderInfoBO.setStatusText(dictResult.getData().getDisplayName());
|
||||||
|
return commonResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,15 @@ public interface OrderService {
|
||||||
*/
|
*/
|
||||||
CommonResult<OrderRecipientBO> getOrderRecipientBO(Integer orderId);
|
CommonResult<OrderRecipientBO> getOrderRecipientBO(Integer orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单info
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param orderId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CommonResult<OrderInfoBO> info(Integer userId, Integer orderId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单 - 创建
|
* 订单 - 创建
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
package cn.iocoder.mall.order.api.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单 info
|
||||||
|
*
|
||||||
|
* @author Sin
|
||||||
|
* @time 2019-04-14 15:36
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class OrderInfoBO implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单编号
|
||||||
|
*/
|
||||||
|
private String orderNo;
|
||||||
|
/**
|
||||||
|
* 价格(分)
|
||||||
|
*/
|
||||||
|
private Integer price;
|
||||||
|
/**
|
||||||
|
* 交易金额
|
||||||
|
*/
|
||||||
|
private Integer payAmount;
|
||||||
|
/**
|
||||||
|
* 物流金额 (分)
|
||||||
|
*/
|
||||||
|
private Integer logisticsPrice;
|
||||||
|
/**
|
||||||
|
* 付款时间(待发货)
|
||||||
|
*/
|
||||||
|
private Date paymentTime;
|
||||||
|
/**
|
||||||
|
* 发货时间(待收货)
|
||||||
|
*/
|
||||||
|
private Date deliveryTime;
|
||||||
|
/**
|
||||||
|
* 收货时间(已签收)
|
||||||
|
*/
|
||||||
|
private Date receiverTime;
|
||||||
|
/**
|
||||||
|
* 成交时间(用户确认收货 -> status = 已完成)
|
||||||
|
*/
|
||||||
|
private Date closingTime;
|
||||||
|
/**
|
||||||
|
* 是否退货
|
||||||
|
*
|
||||||
|
* - 1、没有
|
||||||
|
* - 2、换货
|
||||||
|
* - 3、退货
|
||||||
|
* - 4、换货 + 退货
|
||||||
|
*/
|
||||||
|
private Integer hasReturnExchange;
|
||||||
|
/**
|
||||||
|
* 状态(如果有多个商品分开发货需要全部商品发完才会改变状态)
|
||||||
|
*
|
||||||
|
* - 1、待付款
|
||||||
|
* - 2、待发货
|
||||||
|
* - 3、待收获
|
||||||
|
* - 4、已完成
|
||||||
|
* - 5、已关闭
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 转换的字典值
|
||||||
|
*/
|
||||||
|
private String statusText;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 其他信息
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机人信息
|
||||||
|
*/
|
||||||
|
private Recipient recipient;
|
||||||
|
/**
|
||||||
|
* 最新物流信息
|
||||||
|
*/
|
||||||
|
private LogisticsDetail latestLogisticsDetail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public static class Recipient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 订单id
|
||||||
|
*/
|
||||||
|
private Integer orderId;
|
||||||
|
/**
|
||||||
|
* 收件区域编号
|
||||||
|
*/
|
||||||
|
private String areaNo;
|
||||||
|
/**
|
||||||
|
* 收件人名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 收件手机号
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
/**
|
||||||
|
* 配送类型
|
||||||
|
*
|
||||||
|
* - 1 快递
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
/**
|
||||||
|
* 收件详细地址
|
||||||
|
*/
|
||||||
|
private String address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public static class LogisticsDetail {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 物流id
|
||||||
|
*/
|
||||||
|
private Integer orderLogisticsId;
|
||||||
|
/**
|
||||||
|
* 物流时间
|
||||||
|
*/
|
||||||
|
private Date logisticsTime;
|
||||||
|
/**
|
||||||
|
* 物流信息
|
||||||
|
*/
|
||||||
|
private String logisticsInformation;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package cn.iocoder.mall.order.api.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典 keys 定义
|
||||||
|
*
|
||||||
|
* @author Sin
|
||||||
|
* @time 2019-04-14 17:46
|
||||||
|
*/
|
||||||
|
public class DictKeysConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单 - status
|
||||||
|
*/
|
||||||
|
public static final String ORDER_STATUS_KEY = "order_status";
|
||||||
|
}
|
|
@ -12,11 +12,28 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface OrderCommon {
|
public interface OrderCommon {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算订单金额
|
* 计算总价格
|
||||||
|
*
|
||||||
|
* @param items
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer calculatedPrice(List<OrderItemDO> items);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算订单实付金额
|
||||||
*
|
*
|
||||||
* @param items
|
* @param items
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer calculatedAmount(List<OrderItemDO> items);
|
Integer calculatedAmount(List<OrderItemDO> items);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算物流金额
|
||||||
|
*
|
||||||
|
* @param items
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer calculatedLogisticsPrice(List<OrderItemDO> items);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,18 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@Component
|
@Component
|
||||||
public class OrderCommonImpl implements OrderCommon {
|
public class OrderCommonImpl implements OrderCommon {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer calculatedPrice(List<OrderItemDO> items) {
|
||||||
|
if (CollectionUtils.isEmpty(items)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
AtomicInteger totalPrice = new AtomicInteger(0);
|
||||||
|
items.forEach(orderItemDO -> {
|
||||||
|
totalPrice.addAndGet(orderItemDO.getPrice() * orderItemDO.getQuantity());
|
||||||
|
});
|
||||||
|
return totalPrice.get();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer calculatedAmount(List<OrderItemDO> items) {
|
public Integer calculatedAmount(List<OrderItemDO> items) {
|
||||||
if (CollectionUtils.isEmpty(items)) {
|
if (CollectionUtils.isEmpty(items)) {
|
||||||
|
@ -27,4 +39,16 @@ public class OrderCommonImpl implements OrderCommon {
|
||||||
});
|
});
|
||||||
return totalAmount.get();
|
return totalAmount.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer calculatedLogisticsPrice(List<OrderItemDO> items) {
|
||||||
|
if (CollectionUtils.isEmpty(items)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
AtomicInteger totalAmount = new AtomicInteger(0);
|
||||||
|
items.forEach(orderItemDO -> {
|
||||||
|
totalAmount.addAndGet(orderItemDO.getLogisticsPrice());
|
||||||
|
});
|
||||||
|
return totalAmount.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.mall.order.biz.convert;
|
package cn.iocoder.mall.order.biz.convert;
|
||||||
|
|
||||||
import cn.iocoder.mall.order.api.bo.OrderBO;
|
import cn.iocoder.mall.order.api.bo.OrderBO;
|
||||||
|
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
|
||||||
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
|
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
|
@ -21,4 +22,7 @@ public interface OrderConvert {
|
||||||
|
|
||||||
@Mappings({})
|
@Mappings({})
|
||||||
List<OrderBO> convertPageBO(List<OrderDO> orderDOList);
|
List<OrderBO> convertPageBO(List<OrderDO> orderDOList);
|
||||||
|
|
||||||
|
@Mappings({})
|
||||||
|
OrderInfoBO convert(OrderDO orderDO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.mall.order.biz.convert;
|
package cn.iocoder.mall.order.biz.convert;
|
||||||
|
|
||||||
|
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
|
||||||
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
|
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
|
||||||
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
|
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
@ -21,4 +22,7 @@ public interface OrderLogisticsDetailConvert {
|
||||||
|
|
||||||
@Mappings({})
|
@Mappings({})
|
||||||
List<OrderLogisticsInfoBO.LogisticsDetail> convertLogisticsDetail(List<OrderLogisticsDetailDO> orderLogisticsDOList);
|
List<OrderLogisticsInfoBO.LogisticsDetail> convertLogisticsDetail(List<OrderLogisticsDetailDO> orderLogisticsDOList);
|
||||||
|
|
||||||
|
@Mappings({})
|
||||||
|
OrderInfoBO.LogisticsDetail convertLogisticsDetail(OrderLogisticsDetailDO orderLogisticsDetailDO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.mall.order.biz.convert;
|
package cn.iocoder.mall.order.biz.convert;
|
||||||
|
|
||||||
|
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
|
||||||
import cn.iocoder.mall.order.api.bo.OrderRecipientBO;
|
import cn.iocoder.mall.order.api.bo.OrderRecipientBO;
|
||||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||||
import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO;
|
import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO;
|
||||||
|
@ -32,4 +33,7 @@ public interface OrderRecipientConvert {
|
||||||
|
|
||||||
@Mappings({})
|
@Mappings({})
|
||||||
List<OrderRecipientBO> convert(List<OrderRecipientDO> orderRecipientDOList);
|
List<OrderRecipientBO> convert(List<OrderRecipientDO> orderRecipientDOList);
|
||||||
|
|
||||||
|
@Mappings({})
|
||||||
|
OrderInfoBO.Recipient convertOrderInfoRecipient(OrderRecipientDO orderRecipientDO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,4 +43,14 @@ public interface OrderLogisticsDetailMapper {
|
||||||
List<OrderLogisticsDetailDO> selectByOrderLogisticsIds(
|
List<OrderLogisticsDetailDO> selectByOrderLogisticsIds(
|
||||||
@Param("orderLogisticsIds") Collection<Integer> orderLogisticsIds
|
@Param("orderLogisticsIds") Collection<Integer> orderLogisticsIds
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询 - 获取最新的物流信息
|
||||||
|
*
|
||||||
|
* @param orderLogisticsIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrderLogisticsDetailDO selectLatest(
|
||||||
|
@Param("orderLogisticsIds") Collection<Integer> orderLogisticsIds
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,14 @@ public class OrderDO extends DeletableDO {
|
||||||
* 订单编号
|
* 订单编号
|
||||||
*/
|
*/
|
||||||
private String orderNo;
|
private String orderNo;
|
||||||
|
/**
|
||||||
|
* 价格(分)
|
||||||
|
*/
|
||||||
|
private Integer price;
|
||||||
|
/**
|
||||||
|
* 物流金额 (分)
|
||||||
|
*/
|
||||||
|
private Integer logisticsPrice;
|
||||||
/**
|
/**
|
||||||
* 交易金额
|
* 交易金额
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -56,6 +56,10 @@ public class OrderItemDO extends DeletableDO {
|
||||||
* 支付金额(实付金额)
|
* 支付金额(实付金额)
|
||||||
*/
|
*/
|
||||||
private Integer payAmount;
|
private Integer payAmount;
|
||||||
|
/**
|
||||||
|
* 物流金额 (分)
|
||||||
|
*/
|
||||||
|
private Integer logisticsPrice;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// 时间信息
|
/// 时间信息
|
||||||
|
|
|
@ -5,7 +5,6 @@ import cn.iocoder.common.framework.util.DateUtil;
|
||||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
import cn.iocoder.common.framework.vo.CommonResult;
|
||||||
import cn.iocoder.mall.order.api.OrderLogisticsService;
|
import cn.iocoder.mall.order.api.OrderLogisticsService;
|
||||||
import cn.iocoder.mall.order.api.bo.OrderLogisticsBO;
|
|
||||||
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
|
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
|
||||||
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
|
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
|
||||||
import cn.iocoder.mall.order.biz.convert.OrderLogisticsConvert;
|
import cn.iocoder.mall.order.biz.convert.OrderLogisticsConvert;
|
||||||
|
@ -34,6 +33,7 @@ import java.util.stream.Collectors;
|
||||||
* @time 2019-04-12 21:32
|
* @time 2019-04-12 21:32
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@com.alibaba.dubbo.config.annotation.Service(validation = "true")
|
||||||
public class OrderLogisticsServiceImpl implements OrderLogisticsService {
|
public class OrderLogisticsServiceImpl implements OrderLogisticsService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -63,7 +63,9 @@ public class OrderLogisticsServiceImpl implements OrderLogisticsService {
|
||||||
|
|
||||||
// 获取物流 信息
|
// 获取物流 信息
|
||||||
Set<Integer> orderLogisticsIds = orderItemDOList.stream()
|
Set<Integer> orderLogisticsIds = orderItemDOList.stream()
|
||||||
.map(o -> o.getOrderLogisticsId()).collect(Collectors.toSet());
|
.filter(o -> o.getOrderLogisticsId() != null)
|
||||||
|
.map(o -> o.getOrderLogisticsId())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
List<OrderLogisticsDO> orderLogisticsDOList = orderLogisticsMapper.selectByIds(orderLogisticsIds);
|
List<OrderLogisticsDO> orderLogisticsDOList = orderLogisticsMapper.selectByIds(orderLogisticsIds);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.Date;
|
||||||
* @time 2019-03-30 15:35
|
* @time 2019-03-30 15:35
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@com.alibaba.dubbo.config.annotation.Service(validation = "true")
|
||||||
public class OrderReturnServiceImpl implements OrderReturnService {
|
public class OrderReturnServiceImpl implements OrderReturnService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -12,10 +12,7 @@ import cn.iocoder.mall.order.api.dto.*;
|
||||||
import cn.iocoder.mall.order.biz.OrderCommon;
|
import cn.iocoder.mall.order.biz.OrderCommon;
|
||||||
import cn.iocoder.mall.order.biz.constants.OrderDeliveryTypeEnum;
|
import cn.iocoder.mall.order.biz.constants.OrderDeliveryTypeEnum;
|
||||||
import cn.iocoder.mall.order.biz.constants.OrderRecipientTypeEnum;
|
import cn.iocoder.mall.order.biz.constants.OrderRecipientTypeEnum;
|
||||||
import cn.iocoder.mall.order.biz.convert.OrderConvert;
|
import cn.iocoder.mall.order.biz.convert.*;
|
||||||
import cn.iocoder.mall.order.biz.convert.OrderItemConvert;
|
|
||||||
import cn.iocoder.mall.order.biz.convert.OrderLogisticsConvert;
|
|
||||||
import cn.iocoder.mall.order.biz.convert.OrderRecipientConvert;
|
|
||||||
import cn.iocoder.mall.order.biz.dao.*;
|
import cn.iocoder.mall.order.biz.dao.*;
|
||||||
import cn.iocoder.mall.order.biz.dataobject.*;
|
import cn.iocoder.mall.order.biz.dataobject.*;
|
||||||
import cn.iocoder.mall.pay.api.PayTransactionService;
|
import cn.iocoder.mall.pay.api.PayTransactionService;
|
||||||
|
@ -55,6 +52,8 @@ public class OrderServiceImpl implements OrderService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderLogisticsMapper orderLogisticsMapper;
|
private OrderLogisticsMapper orderLogisticsMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private OrderLogisticsDetailMapper orderLogisticsDetailMapper;
|
||||||
|
@Autowired
|
||||||
private OrderRecipientMapper orderRecipientMapper;
|
private OrderRecipientMapper orderRecipientMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderCancelMapper orderCancelMapper;
|
private OrderCancelMapper orderCancelMapper;
|
||||||
|
@ -152,6 +151,41 @@ public class OrderServiceImpl implements OrderService {
|
||||||
return CommonResult.success(orderRecipientBO);
|
return CommonResult.success(orderRecipientBO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<OrderInfoBO> info(Integer userId, Integer orderId) {
|
||||||
|
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||||
|
if (orderDO == null) {
|
||||||
|
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<OrderItemDO> itemDOList = orderItemMapper
|
||||||
|
.selectByDeletedAndOrderId(orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
||||||
|
|
||||||
|
Set<Integer> orderLogisticsIds = itemDOList.stream()
|
||||||
|
.filter(o -> o.getOrderLogisticsId() != null)
|
||||||
|
.map(o -> o.getOrderLogisticsId())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 收件人信息
|
||||||
|
OrderRecipientDO orderRecipientDO = orderRecipientMapper.selectByOrderId(orderId);
|
||||||
|
|
||||||
|
// 订单物流信息
|
||||||
|
OrderLogisticsDetailDO orderLogisticsDetailDO = null;
|
||||||
|
if (!CollectionUtils.isEmpty(orderLogisticsIds)) {
|
||||||
|
orderLogisticsDetailDO = orderLogisticsDetailMapper.selectLatest(orderLogisticsIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert 信息
|
||||||
|
OrderInfoBO.LogisticsDetail logisticsDetail
|
||||||
|
= OrderLogisticsDetailConvert.INSTANCE.convertLogisticsDetail(orderLogisticsDetailDO);
|
||||||
|
|
||||||
|
OrderInfoBO.Recipient recipient = OrderRecipientConvert.INSTANCE.convertOrderInfoRecipient(orderRecipientDO);
|
||||||
|
OrderInfoBO orderInfoBO = OrderConvert.INSTANCE.convert(orderDO);
|
||||||
|
orderInfoBO.setRecipient(recipient);
|
||||||
|
orderInfoBO.setLatestLogisticsDetail(logisticsDetail);
|
||||||
|
return CommonResult.success(orderInfoBO);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public CommonResult<OrderCreateBO> createOrder(OrderCreateDTO orderCreateDTO) {
|
public CommonResult<OrderCreateBO> createOrder(OrderCreateDTO orderCreateDTO) {
|
||||||
|
@ -196,6 +230,7 @@ public class OrderServiceImpl implements OrderService {
|
||||||
orderItemDO.setSkuImage(Optional.ofNullable(productSkuDetailBO.getSpu().getPicUrls().get(0)).get());
|
orderItemDO.setSkuImage(Optional.ofNullable(productSkuDetailBO.getSpu().getPicUrls().get(0)).get());
|
||||||
orderItemDO.setSkuName(productSkuDetailBO.getSpu().getName());
|
orderItemDO.setSkuName(productSkuDetailBO.getSpu().getName());
|
||||||
orderItemDO.setPrice(productSkuDetailBO.getPrice());
|
orderItemDO.setPrice(productSkuDetailBO.getPrice());
|
||||||
|
orderItemDO.setLogisticsPrice(0);
|
||||||
|
|
||||||
int payAmount = orderItemDO.getQuantity() * orderItemDO.getPrice();
|
int payAmount = orderItemDO.getQuantity() * orderItemDO.getPrice();
|
||||||
orderItemDO.setPayAmount(payAmount);
|
orderItemDO.setPayAmount(payAmount);
|
||||||
|
@ -206,10 +241,14 @@ public class OrderServiceImpl implements OrderService {
|
||||||
// TODO: 2019-04-11 Sin 订单号需要生成规则
|
// TODO: 2019-04-11 Sin 订单号需要生成规则
|
||||||
String orderNo = UUID.randomUUID().toString().replace("-", "").substring(0, 16);
|
String orderNo = UUID.randomUUID().toString().replace("-", "").substring(0, 16);
|
||||||
Integer totalAmount = orderCommon.calculatedAmount(orderItemDOList);
|
Integer totalAmount = orderCommon.calculatedAmount(orderItemDOList);
|
||||||
|
Integer totalPrice = orderCommon.calculatedPrice(orderItemDOList);
|
||||||
|
Integer totalLogisticsPrice = orderCommon.calculatedLogisticsPrice(orderItemDOList);
|
||||||
OrderDO orderDO = new OrderDO()
|
OrderDO orderDO = new OrderDO()
|
||||||
.setUserId(userId)
|
.setUserId(userId)
|
||||||
.setOrderNo(orderNo)
|
.setOrderNo(orderNo)
|
||||||
|
.setPrice(totalPrice)
|
||||||
.setPayAmount(totalAmount)
|
.setPayAmount(totalAmount)
|
||||||
|
.setLogisticsPrice(totalLogisticsPrice)
|
||||||
.setClosingTime(null)
|
.setClosingTime(null)
|
||||||
.setDeliveryTime(null)
|
.setDeliveryTime(null)
|
||||||
.setPaymentTime(null)
|
.setPaymentTime(null)
|
||||||
|
@ -223,7 +262,9 @@ public class OrderServiceImpl implements OrderService {
|
||||||
orderMapper.insert(orderDO);
|
orderMapper.insert(orderDO);
|
||||||
|
|
||||||
// 收件人信息
|
// 收件人信息
|
||||||
CommonResult<UserAddressBO> userAddressResult = userAddressService.getAddress(userId, orderCreateDTO.getUserAddressId());
|
CommonResult<UserAddressBO> userAddressResult
|
||||||
|
= userAddressService.getAddress(userId, orderCreateDTO.getUserAddressId());
|
||||||
|
|
||||||
if (userAddressResult.isError()) {
|
if (userAddressResult.isError()) {
|
||||||
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_USER_ADDRESS_FAIL.getCode());
|
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_USER_ADDRESS_FAIL.getCode());
|
||||||
}
|
}
|
||||||
|
@ -310,9 +351,16 @@ public class OrderServiceImpl implements OrderService {
|
||||||
orderItemMapper.updateById(new OrderItemDO().setId(orderItemId).setPayAmount(payAmount));
|
orderItemMapper.updateById(new OrderItemDO().setId(orderItemId).setPayAmount(payAmount));
|
||||||
|
|
||||||
// 再重新计算订单金额
|
// 再重新计算订单金额
|
||||||
List<OrderItemDO> orderItemDOList = orderItemMapper.selectByDeletedAndOrderId(orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
List<OrderItemDO> orderItemDOList = orderItemMapper
|
||||||
Integer orderPayAmount = orderCommon.calculatedAmount(orderItemDOList);
|
.selectByDeletedAndOrderId(orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
||||||
orderMapper.updateById(new OrderDO().setId(orderId).setPayAmount(orderPayAmount));
|
Integer price = orderCommon.calculatedPrice(orderItemDOList);
|
||||||
|
Integer amount = orderCommon.calculatedAmount(orderItemDOList);
|
||||||
|
orderMapper.updateById(
|
||||||
|
new OrderDO()
|
||||||
|
.setId(orderId)
|
||||||
|
.setPrice(price)
|
||||||
|
.setPayAmount(amount)
|
||||||
|
);
|
||||||
return CommonResult.success(null);
|
return CommonResult.success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,4 +46,19 @@
|
||||||
#{orderLogisticsId}
|
#{orderLogisticsId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
查询 - 最新的物流信息
|
||||||
|
-->
|
||||||
|
<select id="selectLatest" resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO">
|
||||||
|
SELECT
|
||||||
|
<include refid="FIELDS"/>
|
||||||
|
FROM order_logistics_detail
|
||||||
|
WHERE order_logistics_id IN
|
||||||
|
<foreach collection="orderLogisticsIds" item="orderLogisticsId" separator="," open="(" close=")">
|
||||||
|
#{orderLogisticsId}
|
||||||
|
</foreach>
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
LIMIT 0, 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
<mapper namespace="cn.iocoder.mall.order.biz.dao.OrderMapper">
|
<mapper namespace="cn.iocoder.mall.order.biz.dao.OrderMapper">
|
||||||
|
|
||||||
<sql id="FIELDS">
|
<sql id="FIELDS">
|
||||||
id, user_id, order_no, pay_amount, payment_time,
|
id, user_id, order_no, price, pay_amount, logistics_price,
|
||||||
delivery_time, receiver_time, closing_time,
|
payment_time, delivery_time, receiver_time, closing_time,
|
||||||
has_return_exchange,
|
has_return_exchange,
|
||||||
status, remark, create_time, update_time, `deleted`
|
status, remark, create_time, update_time, `deleted`
|
||||||
</sql>
|
</sql>
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
-->
|
-->
|
||||||
<insert id="insert" parameterType="OrderDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
<insert id="insert" parameterType="OrderDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||||
INSERT INTO `order` (
|
INSERT INTO `order` (
|
||||||
user_id, order_no, pay_amount, payment_time,
|
user_id, order_no, price, pay_amount, logistics_price,
|
||||||
delivery_time, receiver_time, closing_time,
|
payment_time, delivery_time, receiver_time, closing_time,
|
||||||
has_return_exchange,
|
has_return_exchange,
|
||||||
status, remark, create_time, update_time, `deleted`
|
status, remark, create_time, update_time, `deleted`
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{userId}, #{orderNo}, #{payAmount}, #{paymentTime},
|
#{userId}, #{orderNo}, #{price}, #{payAmount}, #{logisticsPrice},
|
||||||
#{deliveryTime}, #{receiverTime}, #{closingTime},
|
#{paymentTime}, #{deliveryTime}, #{receiverTime}, #{closingTime},
|
||||||
#{hasReturnExchange},
|
#{hasReturnExchange},
|
||||||
#{status}, #{remark}, #{createTime}, #{updateTime}, #{deleted}
|
#{status}, #{remark}, #{createTime}, #{updateTime}, #{deleted}
|
||||||
)
|
)
|
||||||
|
@ -34,9 +34,15 @@
|
||||||
<if test="orderNo != null">
|
<if test="orderNo != null">
|
||||||
, order_no = #{orderNo}
|
, order_no = #{orderNo}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="price != null">
|
||||||
|
, price = #{price}
|
||||||
|
</if>
|
||||||
<if test="payAmount != null">
|
<if test="payAmount != null">
|
||||||
, pay_amount = #{payAmount}
|
, pay_amount = #{payAmount}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="logisticsPrice != null">
|
||||||
|
, logistics_price = #{logisticsPrice}
|
||||||
|
</if>
|
||||||
|
|
||||||
<if test="paymentTime != null">
|
<if test="paymentTime != null">
|
||||||
, payment_time = #{paymentTime}
|
, payment_time = #{paymentTime}
|
||||||
|
|
Loading…
Reference in New Issue