| | |
| | | |
| | | cartMapper.insert(c); |
| | | } else { |
| | | c.setNum(c.getNum() + dto.getNum()); |
| | | c.setNum((c.getNum()==null?0:c.getNum()) + dto.getNum()); |
| | | c.update(userId); |
| | | if (c.getNum() <= 0) { |
| | | cartMapper.deleteById(c.getId()); |
| | |
| | | |
| | | BigDecimal totalAmount = order.getFlowerAmount().add(p.getPacking()).add(transportFee);//使用优惠券之前的总价 |
| | | CouponRecordDO coupon = useCouponRecord(order.getId(), totalAmount, dto.getCouponRecordId()); |
| | | log.info("用户优惠券: " + coupon); |
| | | if(coupon != null){ |
| | | order.setMemberCouponId(coupon.getId()); |
| | | order.setMemberCouponCode(coupon.getCouponCode()); |
| | |
| | | } |
| | | |
| | | private CouponRecordDO useCouponRecord(String orderId, BigDecimal amount, String couponRecordId){ |
| | | log.info("使用用户优惠券id: " + couponRecordId + "; 订单id: " + orderId); |
| | | if(StringUtils.isNotEmpty(couponRecordId)){ |
| | | //优惠券使用和验证,如果不符合使用条件需要抛出异常。需调用优惠券使用方法 |
| | | couponRecordService.useCoupon(couponRecordId, orderId, amount); |
| | |
| | | return ls; |
| | | } |
| | | |
| | | public List<OrderCheckLocationListDTO> selectOrderCheckLocationList(OrderQueryDTO dto) { |
| | | dto.setIdList(splitParam(dto.getIds())); |
| | | dto.setStartDate(parseLocalDateTime(dto.getStartDateStr(), true)); |
| | | dto.setEndDate(parseLocalDateTime(dto.getEndDateStr(), false)); |
| | | |
| | | dto.setCreateStartDate(parseLocalDateTime(dto.getCreateStartDateStr(), 17, 0, 0, -1)); |
| | | dto.setCreateEndDate(parseLocalDateTime(dto.getCreateEndDateStr(), 17, 0, 0, 0)); |
| | | |
| | | List<OrderCheckListDTO> ls = orderMapper.selectOrderCheckList(dto); |
| | | |
| | | List<OrderCheckLocationListDTO> result = new ArrayList<>(); |
| | | |
| | | if (ls != null && ls.size() > 0) { |
| | | List<String> orderIds = new ArrayList<>(); |
| | | Map<Long, OrderCheckLocationListDTO> rMap = new HashMap<>(); |
| | | Map<String, OrderCheckListDTO> orderMap = new HashMap<>(); |
| | | for (OrderCheckListDTO c : ls) { |
| | | orderIds.add(c.getId()); |
| | | |
| | | orderMap.put(c.getId(), c); |
| | | |
| | | Long locationId = c.getWarehouseLocationId(); |
| | | OrderCheckLocationListDTO llc = rMap.get(locationId); |
| | | if(llc == null){ |
| | | llc = new OrderCheckLocationListDTO(); |
| | | BeanUtils.copyProperties(c, llc); |
| | | rMap.put(locationId, llc); |
| | | |
| | | result.add(llc); |
| | | } |
| | | |
| | | BigDecimal t = llc.getTotalAmount(); |
| | | if(t == null){ |
| | | t = new BigDecimal(0); |
| | | } |
| | | t = t.add(c.getTotalAmount()); |
| | | llc.setTotalAmount(t); |
| | | } |
| | | |
| | | Map<Long, String> stationMap = prepareStationMap(); |
| | | |
| | | List<OrderItem> itemList = orderItemMapper.selectList(new QueryWrapper<OrderItem>() |
| | | .in("order_id", orderIds)); |
| | | Map<String, List<OrderItemLocationListDTO>> map = new HashMap<>(); |
| | | |
| | | for (OrderItem oi : itemList) { |
| | | String orderId = oi.getOrderId(); |
| | | List<OrderItemLocationListDTO> ll = map.computeIfAbsent(orderId, k -> new ArrayList<>()); |
| | | OrderItemLocationListDTO d = new OrderItemLocationListDTO(); |
| | | BeanUtils.copyProperties(oi, d); |
| | | d.setStationName(stationMap.get(oi.getStationId())); |
| | | |
| | | OrderCheckListDTO c = orderMap.get(oi.getOrderId()); |
| | | d.setOrderNo(c.getOrderNo()); |
| | | d.setOrderId(c.getId()); |
| | | |
| | | ll.add(d); |
| | | } |
| | | |
| | | for (OrderCheckListDTO c : ls) { |
| | | String orderId = c.getId(); |
| | | Long locationId = c.getWarehouseLocationId(); |
| | | OrderCheckLocationListDTO r = rMap.get(locationId); |
| | | List<OrderItemLocationListDTO> items = r.getItems(); |
| | | if(items == null){ |
| | | items = new ArrayList<>(); |
| | | r.setItems(items); |
| | | } |
| | | items.addAll(map.get(orderId)); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public Page<OrderListDTO> selectPartnerOrderList(Page page, OrderQueryDTO dto) { |
| | | Partner p = getCurrentPartner(); |
| | | dto.setPartnerId(p.getId()); |