Search in sources :

Example 6 with Order

use of com.whoiszxl.entity.Order in project shopzz by whoiszxl.

the class OrderServiceImpl method buildOrder.

private Order buildOrder(Long orderId, String orderNo, OrderSubmitCommand orderSubmitCommand) {
    Order order = new Order();
    order.setId(orderId);
    order.setOrderNo(orderNo);
    order.setMemberId(AuthUtils.getMemberId());
    order.setUsername("not set");
    order.setOrderStatus(OrderStatusConstants.UNKNOWN);
    // 收货地址配置
    ResponseResult<MemberAddressFeignDTO> memberAddressResult = memberFeignClient.getMemberAddress(orderSubmitCommand.getAddressId());
    if (!memberAddressResult.isOk()) {
        ExceptionCatcher.catchValidateEx(ResponseResult.buildError("地址无效"));
    }
    AssertUtils.isNotNull(memberAddressResult.getData(), "地址无效");
    String addressJson = JsonUtil.toJson(memberAddressResult.getData());
    order.setSnapshotAddress(addressJson);
    order.setPayType(OrderPayTypeConstants.NOT_SET);
    order.setOrderComment(orderSubmitCommand.getOrderComment());
    return order;
}
Also used : Order(com.whoiszxl.entity.Order)

Example 7 with Order

use of com.whoiszxl.entity.Order in project shopzz by whoiszxl.

the class OrderServiceImpl method getOrderInfo.

@Override
public OrderInfoDTO getOrderInfo(Long orderId) {
    // 获取订单信息
    Order order = this.getById(orderId);
    // 获取订单条目信息
    List<OrderItem> orderItemList = orderItemService.list(new LambdaQueryWrapper<OrderItem>().eq(OrderItem::getOrderId, orderId));
    List<OrderItemDTO> orderItemDTOList = dozerUtils.mapList(orderItemList, OrderItemDTO.class);
    OrderInfoDTO orderInfoDTO = new OrderInfoDTO();
    orderInfoDTO.setOrderId(order.getId());
    orderInfoDTO.setMemberId(order.getMemberId());
    orderInfoDTO.setTotalAmount(order.getTotalAmount());
    orderInfoDTO.setOrderItemDTOList(orderItemDTOList);
    return orderInfoDTO;
}
Also used : Order(com.whoiszxl.entity.Order) OrderItem(com.whoiszxl.entity.OrderItem) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 8 with Order

use of com.whoiszxl.entity.Order in project shopzz by whoiszxl.

the class OrderFeignClientImpl method notifyDcPaySuccess.

@Override
public ResponseResult<Boolean> notifyDcPaySuccess(List<Long> orderIds) {
    // 1. 更新订单到发货状态
    List<Order> orderList = orderIds.stream().map(orderId -> {
        Order order = new Order();
        order.setId(orderId);
        order.setOrderStatus(OrderStatusConstants.WAIT_FOR_DELIVERY);
        order.setUpdatedBy("system");
        return order;
    }).collect(Collectors.toList());
    boolean updateFlag = orderService.updateBatchById(orderList);
    for (Long orderId : orderIds) {
        OrderInfoDTO orderInfo = orderService.getOrderInfo(orderId);
        // 通知商品中心更新库存
        ResponseResult result = productFeignClient.paySuccessUpdateStock(orderInfo);
        if (!result.isOk()) {
            log.info("库存更新失败");
        }
    // TODO 通知WMS订单支付成功,更新WMS中心库存,WMS新增出库单
    // TODO 更新会员中心等级与积分
    }
    return ResponseResult.buildByFlag(updateFlag);
}
Also used : Order(com.whoiszxl.entity.Order) ResponseResult(com.whoiszxl.bean.ResponseResult) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Autowired(org.springframework.beans.factory.annotation.Autowired) OrderInfoDTO(com.whoiszxl.dto.OrderInfoDTO) Order(com.whoiszxl.entity.Order) OrderService(com.whoiszxl.service.OrderService) OrderStatusConstants(com.whoiszxl.constants.OrderStatusConstants) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) ResponseResult(com.whoiszxl.bean.ResponseResult) OrderInfoDTO(com.whoiszxl.dto.OrderInfoDTO)

Example 9 with Order

use of com.whoiszxl.entity.Order in project shopzz by whoiszxl.

the class OrderServiceImpl method createOrderInfo.

/**
 * 创建订单和订单条目信息
 * @param memberDetailDTO 用户信息
 * @param orderSubmitVo 提交的订单信息
 * @return
 */
private OrderCreateInfo createOrderInfo(MemberDetailDTO memberDetailDTO, OrderSubmitVO orderSubmitVo) {
    MemberDTO member = memberDetailDTO.getMember();
    // 1. 生成订单号
    long orderId = idWorker.nextId();
    // 2. 创建订单和订单条目的基本信息
    Order order = buildOrder(member, orderId, orderSubmitVo);
    List<OrderItem> orderItems = buildOrderItems(orderId);
    // 3. 价格计算
    assert orderItems != null;
    computePrice(order, orderItems);
    OrderCreateInfo orderCreateInfo = new OrderCreateInfo();
    orderCreateInfo.setOrder(order);
    orderCreateInfo.setOrderItemList(orderItems);
    orderCreateInfo.setFare(BigDecimal.ZERO);
    orderCreateInfo.setPayPrice(order.getTotalAmount());
    return orderCreateInfo;
}
Also used : Order(com.whoiszxl.entity.Order) OrderItem(com.whoiszxl.entity.OrderItem) OrderCreateInfo(com.whoiszxl.entity.vo.OrderCreateInfo)

Example 10 with Order

use of com.whoiszxl.entity.Order in project shopzz by whoiszxl.

the class OrderServiceImpl method buildOrder.

/**
 * 构建订单
 * @param member
 * @param orderId
 * @return
 */
private Order buildOrder(MemberDTO member, long orderId, OrderSubmitVO orderSubmitVo) {
    Order order = new Order();
    order.setId(orderId);
    order.setOrderSn(orderId + "");
    // 1. 设置用户信息与订单状态
    order.setMemberId(member.getId());
    order.setUsername(member.getUsername());
    order.setOrderStatus(OrderStatusConstants.UNKNOWN);
    // 2. 配置收货信息
    MemberAddressDTO memberAddress = memberFeignClient.getMemberAddress(orderSubmitVo.getMemberAddressId());
    order.setReceiverName(memberAddress.getReciverName());
    order.setReceiverPhone(memberAddress.getReciverPhone());
    order.setReceiverPostCode("todo");
    order.setReceiverProvince(memberAddress.getProvince());
    order.setReceiverCity(memberAddress.getCity());
    order.setReceiverRegion(memberAddress.getDistrict());
    order.setReceiverDetailAddress(memberAddress.getDetailAddress());
    order.setCreatedBy(member.getUsername());
    order.setUpdatedBy(member.getUsername());
    // 3. 配置支付类型
    order.setPayType(orderSubmitVo.getPayType());
    order.setOrderComment(orderSubmitVo.getOrderComment());
    return order;
}
Also used : Order(com.whoiszxl.entity.Order)

Aggregations

Order (com.whoiszxl.entity.Order)15 OrderItem (com.whoiszxl.entity.OrderItem)5 OrderCreateInfo (com.whoiszxl.entity.vo.OrderCreateInfo)4 ResponseResult (com.whoiszxl.bean.ResponseResult)3 Transactional (org.springframework.transaction.annotation.Transactional)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 OrderStatusConstants (com.whoiszxl.constants.OrderStatusConstants)2 OrderInfoDTO (com.whoiszxl.dto.OrderInfoDTO)2 PayInfoDc (com.whoiszxl.entity.PayInfoDc)2 MQSender (com.whoiszxl.mq.MQSender)2 OrderService (com.whoiszxl.service.OrderService)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 RestController (org.springframework.web.bind.annotation.RestController)2 SaCheckLogin (cn.dev33.satoken.annotation.SaCheckLogin)1 OrderCreateInfoDTO (com.whoiszxl.cqrs.dto.OrderCreateInfoDTO)1 OrderCreateInfoDTO (com.whoiszxl.dto.OrderCreateInfoDTO)1 OrderItemVO (com.whoiszxl.entity.vo.OrderItemVO)1