Search in sources :

Example 1 with OrderItem

use of cn.lili.modules.order.order.entity.dos.OrderItem in project lilishop by lilishop.

the class MemberEvaluationServiceImpl method addMemberEvaluation.

@Override
@Transactional(rollbackFor = Exception.class)
public MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO, Boolean isSelf) {
    // 获取子订单信息
    OrderItem orderItem = orderItemService.getBySn(memberEvaluationDTO.getOrderItemSn());
    // 获取订单信息
    Order order = orderService.getBySn(orderItem.getOrderSn());
    // 检测是否可以添加会员评价
    Member member;
    checkMemberEvaluation(orderItem, order);
    if (Boolean.TRUE.equals(isSelf)) {
        // 自我评价商品时,获取当前登录用户信息
        member = memberService.getUserInfo();
    } else {
        // 获取用户信息 非自己评价时,读取数据库
        member = memberService.getById(order.getMemberId());
    }
    // 获取商品信息
    GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(memberEvaluationDTO.getSkuId());
    // 新增用户评价
    MemberEvaluation memberEvaluation = new MemberEvaluation(memberEvaluationDTO, goodsSku, member, order);
    // 过滤商品咨询敏感词
    memberEvaluation.setContent(SensitiveWordsFilter.filter(memberEvaluation.getContent()));
    // 添加评价
    this.save(memberEvaluation);
    // 修改订单货物评价状态为已评价
    orderItemService.updateCommentStatus(orderItem.getSn(), CommentStatusEnum.FINISHED);
    // 发送商品评价消息
    String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_COMMENT_COMPLETE.name();
    rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(memberEvaluation), RocketmqSendCallbackBuilder.commonCallback());
    return memberEvaluationDTO;
}
Also used : Order(cn.lili.modules.order.order.entity.dos.Order) GoodsSku(cn.lili.modules.goods.entity.dos.GoodsSku) MemberEvaluation(cn.lili.modules.member.entity.dos.MemberEvaluation) OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem) Member(cn.lili.modules.member.entity.dos.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with OrderItem

use of cn.lili.modules.order.order.entity.dos.OrderItem in project lilishop by lilishop.

the class RedisLimiterHelperTest method testBatchUpdate.

@Test
public void testBatchUpdate() {
    OrderItem orderItem = new OrderItem();
    orderItem.setId("1356539557729796097");
    orderItem.setCreateBy("1356539557729796097");
    OrderItem orderItem1 = new OrderItem();
    orderItem1.setId("1356787800921341953");
    orderItem1.setCreateBy("1356787800921341953");
    List<OrderItem> orderItemList = new ArrayList<>();
    orderItemList.add(orderItem);
    orderItemList.add(orderItem1);
    orderItemService.updateBatchById(orderItemList);
}
Also used : OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem) ArrayList(java.util.ArrayList) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 3 with OrderItem

use of cn.lili.modules.order.order.entity.dos.OrderItem in project lilishop by lilishop.

the class VerificationOrderExecute method orderChange.

@Override
public void orderChange(OrderMessage orderMessage) {
    // 订单状态为待核验,添加订单添加核验码
    if (orderMessage.getNewStatus().equals(OrderStatusEnum.TAKE)) {
        // 获取订单信息
        Order order = orderService.getBySn(orderMessage.getOrderSn());
        // 获取随机数,判定是否存在
        String code = getCode(order.getStoreId());
        // 设置订单验证码
        orderService.update(new LambdaUpdateWrapper<Order>().set(Order::getVerificationCode, code).eq(Order::getSn, orderMessage.getOrderSn()));
        // 修改虚拟订单货物可以进行售后、投诉
        orderItemService.update(new LambdaUpdateWrapper<OrderItem>().eq(OrderItem::getOrderSn, orderMessage.getOrderSn()).set(OrderItem::getAfterSaleStatus, OrderItemAfterSaleStatusEnum.NOT_APPLIED).set(OrderItem::getCommentStatus, OrderComplaintStatusEnum.NO_APPLY));
    }
}
Also used : Order(cn.lili.modules.order.order.entity.dos.Order) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem)

Example 4 with OrderItem

use of cn.lili.modules.order.order.entity.dos.OrderItem in project lilishop by lilishop.

the class FullDiscountExecute method giftOrderHandler.

/**
 * 赠品订单处理
 *
 * @param skuList       赠品列表
 * @param originOrder   原始订单
 * @param orderTypeEnum 订单类型
 */
private void giftOrderHandler(List<GoodsSku> skuList, Order originOrder, OrderTypeEnum orderTypeEnum) {
    // 初始化订单对象/订单日志/自订单
    Order order = new Order();
    List<OrderItem> orderItems = new ArrayList<>();
    List<OrderLog> orderLogs = new ArrayList<>();
    // 初始化价格详情
    PriceDetailDTO priceDetailDTO = new PriceDetailDTO();
    // 复制通用属性
    BeanUtil.copyProperties(originOrder, order, "id");
    BeanUtil.copyProperties(priceDetailDTO, order, "id");
    // 生成订单参数
    order.setSn(SnowFlake.createStr("G"));
    order.setParentOrderSn(originOrder.getSn());
    order.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name());
    order.setOrderStatus(OrderStatusEnum.UNPAID.name());
    order.setPayStatus(PayStatusEnum.PAID.name());
    order.setOrderType(orderTypeEnum.name());
    order.setNeedReceipt(false);
    order.setPriceDetailDTO(priceDetailDTO);
    order.setClientType(originOrder.getClientType());
    // 订单日志
    String message = "赠品订单[" + order.getSn() + "]创建";
    orderLogs.add(new OrderLog(order.getSn(), originOrder.getMemberId(), UserEnums.MEMBER.name(), originOrder.getMemberName(), message));
    // 生成子订单
    for (GoodsSku goodsSku : skuList) {
        OrderItem orderItem = new OrderItem();
        BeanUtil.copyProperties(goodsSku, orderItem, "id");
        BeanUtil.copyProperties(priceDetailDTO, orderItem, "id");
        orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.NEW.name());
        orderItem.setCommentStatus(CommentStatusEnum.NEW.name());
        orderItem.setComplainStatus(OrderComplaintStatusEnum.NEW.name());
        orderItem.setNum(1);
        orderItem.setOrderSn(order.getSn());
        orderItem.setImage(goodsSku.getThumbnail());
        orderItem.setGoodsName(goodsSku.getGoodsName());
        orderItem.setSkuId(goodsSku.getId());
        orderItem.setCategoryId(goodsSku.getCategoryPath().substring(goodsSku.getCategoryPath().lastIndexOf(",") + 1));
        orderItem.setGoodsPrice(goodsSku.getPrice());
        orderItem.setPriceDetailDTO(priceDetailDTO);
        orderItems.add(orderItem);
    }
    // 保存订单
    orderService.save(order);
    orderItemService.saveBatch(orderItems);
    orderLogService.saveBatch(orderLogs);
    // 发送订单已付款消息(PS:不在这里处理逻辑是因为期望加交给消费者统一处理库存等等问题)
    OrderMessage orderMessage = new OrderMessage();
    orderMessage.setOrderSn(order.getSn());
    orderMessage.setPaymentMethod(order.getPaymentMethod());
    orderMessage.setNewStatus(OrderStatusEnum.PAID);
    String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.STATUS_CHANGE.name();
    // 发送订单变更mq消息
    rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(orderMessage), RocketmqSendCallbackBuilder.commonCallback());
}
Also used : Order(cn.lili.modules.order.order.entity.dos.Order) GoodsSku(cn.lili.modules.goods.entity.dos.GoodsSku) PriceDetailDTO(cn.lili.modules.order.order.entity.dto.PriceDetailDTO) OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem) ArrayList(java.util.ArrayList) OrderLog(cn.lili.modules.order.trade.entity.dos.OrderLog) OrderMessage(cn.lili.modules.order.order.entity.dto.OrderMessage)

Example 5 with OrderItem

use of cn.lili.modules.order.order.entity.dos.OrderItem in project lilishop by lilishop.

the class OrderEveryDayTaskExecute method closeComplaint.

/**
 * 关闭允许交易投诉
 *
 * @param orderSetting 订单设置
 */
private void closeComplaint(OrderSetting orderSetting) {
    // 订单关闭交易投诉申请时间 = 当前时间 - 自动关闭交易投诉申请天数
    DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseComplaint());
    // 关闭售后订单=未售后订单+小于订单关闭售后申请时间
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.le("o.complete_time", receiveTime);
    queryWrapper.eq("oi.complain_status", OrderComplaintStatusEnum.NO_APPLY.name());
    List<OrderItem> orderItems = orderItemMapper.waitOperationOrderItem(queryWrapper);
    // 判断是否有符合条件的订单,关闭允许售后申请处理
    if (!orderItems.isEmpty()) {
        // 获取订单货物ID
        List<String> orderItemIdList = orderItems.stream().map(OrderItem::getId).collect(Collectors.toList());
        // 修改订单投诉状态
        LambdaUpdateWrapper<OrderItem> lambdaUpdateWrapper = new LambdaUpdateWrapper<OrderItem>().set(OrderItem::getComplainStatus, OrderItemAfterSaleStatusEnum.EXPIRED.name()).in(OrderItem::getId, orderItemIdList);
        orderItemService.update(lambdaUpdateWrapper);
    }
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem) DateTime(cn.hutool.core.date.DateTime)

Aggregations

OrderItem (cn.lili.modules.order.order.entity.dos.OrderItem)24 Order (cn.lili.modules.order.order.entity.dos.Order)11 ServiceException (cn.lili.common.exception.ServiceException)7 GoodsSku (cn.lili.modules.goods.entity.dos.GoodsSku)5 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)5 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)5 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)4 ArrayList (java.util.ArrayList)4 Transactional (org.springframework.transaction.annotation.Transactional)4 DateTime (cn.hutool.core.date.DateTime)3 PriceDetailDTO (cn.lili.modules.order.order.entity.dto.PriceDetailDTO)3 OrderLog (cn.lili.modules.order.trade.entity.dos.OrderLog)3 AuthUser (cn.lili.common.security.AuthUser)2 OrderMessage (cn.lili.modules.order.order.entity.dto.OrderMessage)2 OrderItemAfterSaleStatusEnum (cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum)2 OrderDetailVO (cn.lili.modules.order.order.entity.vo.OrderDetailVO)2 List (java.util.List)2 PromotionTypeEnum (cn.lili.common.enums.PromotionTypeEnum)1 GoodsCompleteMessage (cn.lili.modules.goods.entity.dto.GoodsCompleteMessage)1 Member (cn.lili.modules.member.entity.dos.Member)1