mitao
2024-07-31 de0026f420814a34a0e94c2de702b563b7e9234e
ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionGoodsServiceImpl.java
@@ -34,6 +34,7 @@
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.page.BeanUtils;
import com.ruoyi.common.core.utils.page.CollUtils;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.system.api.constants.ConfigEnum;
import com.ruoyi.system.api.constants.NotificationTypeConstant;
@@ -247,7 +248,19 @@
            auctionGoodsOrg.setSharePic(dto.getSharePic());
            this.updateById(auctionGoodsOrg);
        }
        auctionAsyncMethodService.auctionGoodsScheduleTask(Lists.newArrayList(auctionGoods));
        if (auctionGoods.getEndTime().isBefore(LocalDateTime.now())) {
            // 退回剩余库存
            GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
            goodsStockUpdDTO.setAuctionStock(auctionGoods.getAuctionStock());
            goodsStockUpdDTO.setGoodsSkuId(auctionGoods.getGoodsSkuId());
            goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO),
                    SecurityConstants.INNER);
            auctionGoods.setStartStatus(AuctionStartStatusEnum.ENDED);
            this.updateById(auctionGoods);
        } else {
            auctionAsyncMethodService.auctionGoodsScheduleTask(Lists.newArrayList(auctionGoods));
        }
    }
    /**
@@ -409,7 +422,8 @@
                for (OrderAuctionBond orderAuctionBond : auctionBondList) {
                    // 已中标需在订单完成后退保证金
                    if (unRefundMemberIdList.contains(orderAuctionBond.getMemberId())) {
                    if (unRefundMemberIdList.contains(orderAuctionBond.getMemberId())
                            || Objects.isNull(orderAuctionBond.getBond())) {
                        continue;
                    }
                    RefundDTO refundDTO = new RefundDTO();
@@ -420,10 +434,10 @@
                // 远程调用订单服务进行退款
                Map<String, Object> data = orderClient.refund(refundDTOList,
                        SecurityConstants.INNER).getData();
                if (CollUtils.isNotEmpty(data)) {
                // 处理退款返回结果
                List<String> successfulOrders = new ArrayList<>();
                List<String> failedOrders = new ArrayList<>();
                data.forEach((key, value) -> {
                    if ((boolean) value) {
                        successfulOrders.add(key);
@@ -439,9 +453,11 @@
                    }
                    return null;
                }).filter(Objects::nonNull).collect(Collectors.toList());
                // 远程调用订单服务修改订单状态
                orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.REFUNDED,
                        SecurityConstants.INNER);
                }
            }
        }
    }
@@ -901,6 +917,19 @@
        this.updateById(auctionGoods);
    }
    /**
     * 根据商品id获取正在进行的拍卖商品
     *
     * @param id 商品id
     * @return
     */
    @Override
    public List<AuctionGoods> getAuctionGoodsBySkuId(Long id) {
        return this.list(new LambdaQueryWrapper<AuctionGoods>().eq(AuctionGoods::getGoodsSkuId,
                        id).eq(AuctionGoods::getListingStatus, ListingStatusEnum.ON_SHELVES)
                .eq(AuctionGoods::getStartStatus, AuctionStartStatusEnum.IN_AUCTION));
    }
    public static void main(String[] args) throws JsonProcessingException {
        Map<String, Object> map = new ConcurrentHashMap<>();
        map.put("notification_type", NotificationTypeConstant.AUCTION_GOODS);
@@ -910,4 +939,5 @@
        String msg = objectMapper.writeValueAsString(map);
        System.out.println(msg);
    }
}