| | |
| | | import cn.lili.common.utils.StringUtils; |
| | | import cn.lili.common.vo.ResultMessage; |
| | | import cn.lili.modules.goods.entity.dos.Goods; |
| | | import cn.lili.modules.goods.entity.dos.GoodsSku; |
| | | import cn.lili.modules.goods.entity.dto.GoodsCompleteMessage; |
| | | import cn.lili.modules.goods.service.GoodsService; |
| | | import cn.lili.modules.goods.service.GoodsSkuService; |
| | | import cn.lili.modules.lmk.domain.entity.CouponVirtual; |
| | | import cn.lili.modules.lmk.domain.vo.OrderCountVO; |
| | | import cn.lili.modules.lmk.enums.general.AdminRoleEnum; |
| | | import cn.lili.modules.lmk.enums.general.VirtualGoodsTypeEnum; |
| | | import cn.lili.modules.lmk.service.CouponVirtualService; |
| | | import cn.lili.modules.member.entity.dos.Member; |
| | | import cn.lili.modules.member.entity.dto.MemberAddressDTO; |
| | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | | |
| | | @Autowired |
| | | private GoodsSkuService goodsSkuService; |
| | | private final static String LOCK_ORDER_NO_MQ="lock_order_no_mq:"; |
| | | private final static String LOCK_EDIT_ORDER_ADDRESS="lock_edit_order_address:"; |
| | | private final static String LOCK_COUPON_CARD="lock_coupon_card:"; |
| | |
| | | // item.getPriceDetailDTO().setPlatFormCommissionPoint(Double.valueOf(goods.getCommission().toString())); |
| | | // e.setPriceDetailDTO(item.getPriceDetailDTO()); |
| | | // orderItems.add(e); |
| | | orderItems.add(new OrderItem(sku, item, tradeDTO)); |
| | | //特殊处理线上礼品卡问题 |
| | | String skuId = sku.getGoodsSku().getId(); |
| | | GoodsSku skuInfo = goodsSkuService.getById(skuId); |
| | | OrderItem orderItem = new OrderItem(sku, item, tradeDTO); |
| | | if (skuInfo != null) { |
| | | String goodsId = skuInfo.getGoodsId(); |
| | | Goods goodsInfo = goodsService.getById(goodsId); |
| | | if (goodsInfo != null&& VirtualGoodsTypeEnum.COUPON.name().equals(goodsInfo.getVirtualGoodsType())) { |
| | | String couponId = skuInfo.getCouponId(); |
| | | String couponName = skuInfo.getCouponName(); |
| | | orderItem.setCouponId(couponId); |
| | | orderItem.setCouponName(couponName); |
| | | } |
| | | } |
| | | orderItems.add(orderItem); |
| | | currentOrderItems.add(new OrderItem(sku, item, tradeDTO)); |
| | | } |
| | | ); |
| | |
| | | @OrderLogPoint(description = "'订单['+#orderSn+']核销,核销码['+#verificationCode+']'", orderSn = "#orderSn") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Order take(String orderSn, String verificationCode) { |
| | | log.info("订单核销订单号为:{},核销码为{}",orderSn,verificationCode); |
| | | Order order; |
| | | RLock lock = redissonClient.getLock(LOCK_COUPON_CARD + orderSn); |
| | | try { |
| | | lock.lock(); |
| | | //获取订单信息 |
| | | order = this.getBySn(orderSn); |
| | | log.info("获取到的订单信息为{}",JSON.toJSONString(order)); |
| | | //订单幂等问题 |
| | | if (OrderStatusEnum.COMPLETED.name().equals(order.getOrderStatus())) { |
| | | throw new ServiceException("当前订单已完成无法再次核验"); |
| | |
| | | List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn); |
| | | List<CouponVirtual> couponVirtuals = new ArrayList<>(); |
| | | for (OrderItem orderItem : orderItems) { |
| | | log.info("获取到的子订单信息为{}",JSON.toJSONString(orderItem)); |
| | | String couponId = orderItem.getCouponId(); |
| | | if (StringUtils.isBlank(couponId)) { |
| | | continue; |
| | |
| | | } |
| | | } |
| | | if (!couponVirtuals.isEmpty()) { |
| | | log.info("生成的兑换卡为{}",JSON.toJSONString(couponVirtuals)); |
| | | order.setCouponFlag(CouPonFlagEnum.COUPON.name()); |
| | | couponVirtualService.saveBatch(couponVirtuals); |
| | | //更新状态用于后续小程序判断弹出卷列表 |