New file |
| | |
| | | package com.ruoyi.auction.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 拍卖参加记录 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | | * @since 2024-07-29 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @TableName("t_auction_bond_jl") |
| | | @ApiModel(value = "AuctionBondJl对象", description = "拍卖参加记录") |
| | | public class AuctionBondJl implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | @ApiModelProperty(value = "拍卖参加记录id") |
| | | @TableId(value = "id", type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "拍卖场id") |
| | | private Long auctionSalesroomId; |
| | | |
| | | @ApiModelProperty(value = "拍卖商品id") |
| | | private Long auctionGoodsId; |
| | | |
| | | @ApiModelProperty(value = "会员id") |
| | | private Long memberId; |
| | | |
| | | private Integer isState; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.auction.mapper; |
| | | |
| | | import com.ruoyi.auction.domain.AuctionBondJl; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * 拍卖参加记录 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | | * @since 2024-07-29 |
| | | */ |
| | | public interface AuctionBondJlMapper extends BaseMapper<AuctionBondJl> { |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.auction.service; |
| | | |
| | | import com.ruoyi.auction.domain.AuctionBondJl; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 拍卖参加记录 服务类 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | | * @since 2024-07-29 |
| | | */ |
| | | public interface IAuctionBondJlService extends IService<AuctionBondJl> { |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.auction.service.impl; |
| | | |
| | | import com.ruoyi.auction.domain.AuctionBondJl; |
| | | import com.ruoyi.auction.mapper.AuctionBondJlMapper; |
| | | import com.ruoyi.auction.service.IAuctionBondJlService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 拍卖参加记录 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | | * @since 2024-07-29 |
| | | */ |
| | | @Service |
| | | public class AuctionBondJlServiceImpl extends ServiceImpl<AuctionBondJlMapper, AuctionBondJl> implements IAuctionBondJlService { |
| | | |
| | | } |
| | |
| | | RefundDTO refundDTO = new RefundDTO(); |
| | | refundDTO.setOrderNo(orderAuctionBond.getOrderNo()); |
| | | refundDTO.setAmount(orderAuctionBond.getBond()); |
| | | refundDTOList.add(refundDTO); |
| | | } |
| | | // 远程调用订单服务进行退款 |
| | | Map<String, Object> data = orderClient.refund(refundDTOList, |
| | |
| | | return null; |
| | | }).filter(Objects::nonNull).collect(Collectors.toList()); |
| | | // 远程调用订单服务修改订单状态 |
| | | orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.PAID,SecurityConstants.INNER); |
| | | orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.REFUNDED, |
| | | SecurityConstants.INNER); |
| | | } |
| | | } |
| | | } |
| | |
| | | @Transactional |
| | | public void endAuctionGoods(Long id) throws JsonProcessingException { |
| | | AuctionGoods auctionGoods = this.getById(id); |
| | | if (StringUtils.isNotNull(auctionGoods) && auctionGoods.getListingStatus().equals( |
| | | ListingStatusEnum.ON_SHELVES) && auctionGoods.getStartStatus() |
| | | if (StringUtils.isNotNull(auctionGoods) && auctionGoods.getStartStatus() |
| | | .equals(AuctionStartStatusEnum.IN_AUCTION)) { |
| | | // 远程调用商品服务,获取商品信息 |
| | | GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(auctionGoods.getGoodsSkuId(), |
| | |
| | | RefundDTO refundDTO = new RefundDTO(); |
| | | refundDTO.setOrderNo(orderAuctionBond.getOrderNo()); |
| | | refundDTO.setAmount(orderAuctionBond.getBond()); |
| | | refundDTOList.add(refundDTO); |
| | | } |
| | | // 远程调用订单服务进行退款 |
| | | Map<String, Object> data = orderClient.refund(refundDTOList, |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.auction.mapper.AuctionBondJlMapper"> |
| | | |
| | | </mapper> |
| | |
| | | // 秒杀已经开始 |
| | | if (LocalDateTime.now().isAfter(startTime)) { |
| | | handleStartDelayTask(id, DelayTaskEnum.SECKILL_START_TASK, startTime, 3L); |
| | | log.info(">>>>>>>>>>>>>>>>>>>>秒杀商品:{} 开始秒杀<<<<<<<<<<<<<<<<<<<<", id); |
| | | } else { |
| | | Duration duration = Duration.between(LocalDateTime.now(), startTime); |
| | | handleStartDelayTask(id, DelayTaskEnum.SECKILL_START_TASK, startTime, |
| | | duration.getSeconds()); |
| | | } |
| | | log.info(">>>>>>>>>>>>>>>>>>>>秒杀商品:{} 开始秒杀<<<<<<<<<<<<<<<<<<<<", id); |
| | | // 秒杀结束延时任务 |
| | | handleEndDelayTask(id, DelayTaskEnum.SECKILL_END_TASK, endTime); |
| | | } |
| | |
| | | startDelayTask.setExecuteTime(LocalDateTime.now().plusSeconds(timeout)); |
| | | startDelayTask.setRedisKey( |
| | | startTaskKey); |
| | | sysUserClient.addDelayTask(startDelayTask, SecurityConstants.INNER); |
| | | |
| | | } |
| | | } |
| | | redisService.setCacheObject(startTaskKey, startTime, timeout, TimeUnit.SECONDS); |
| | |
| | | import com.ruoyi.goods.service.IGoodsSkuService; |
| | | import com.ruoyi.goods.service.IMemberGoodsCollectionService; |
| | | import com.ruoyi.goods.service.async.AsyncMethodService; |
| | | import com.ruoyi.system.api.constants.DelayTaskEnum; |
| | | import com.ruoyi.system.api.constants.NotificationTypeConstant; |
| | | import com.ruoyi.system.api.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.system.api.domain.GoodsGroupPurchaseInfo; |
| | | import com.ruoyi.system.api.domain.GoodsSku; |
| | | import com.ruoyi.system.api.domain.Order; |
| | | import com.ruoyi.system.api.domain.WebsocketMessageDTO; |
| | | import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO; |
| | | import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; |
| | | import com.ruoyi.system.api.domain.dto.ListStatusDTO; |
| | | import com.ruoyi.system.api.domain.dto.OrderDTO; |
| | |
| | | goodsSku.getSkuName())); |
| | | } |
| | | } |
| | | if (goodsGroupPurchase.getListingStatus().equals(ListingStatusEnum.ON_SHELVES)) { |
| | | asyncMethodService.groupPurchaseScheduleTask(Lists.newArrayList(goodsGroupPurchase)); |
| | | } |
| | | asyncMethodService.groupPurchaseScheduleTask(Lists.newArrayList(goodsGroupPurchase)); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (groupPurchase.getStartStatus().equals(StartStatusEnum.STARTED)) { |
| | | throw new ServiceException("该商品已开始团购,不能下架"); |
| | | } |
| | | //移除该团购商品延时任务 |
| | | redisService.deleteObject(DelayTaskEnum.GROUP_PURCHASES_START_TASK.getCode() + "-" |
| | | + groupPurchase.getId()); |
| | | redisService.deleteObject( |
| | | DelayTaskEnum.GROUP_PURCHASES_END_TASK.getCode() + "-" + groupPurchase.getId()); |
| | | // 退回剩余库存 |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setAuctionStock( |
| | | groupPurchase.getLimitNumber() * groupPurchase.getGroupSize()); |
| | | goodsStockUpdDTO.setGoodsSkuId(groupPurchase.getGoodsSkuId()); |
| | | goodsSkuService.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO)); |
| | | } |
| | | //修改状态 |
| | | groupPurchase.setListingStatus(dto.getListingStatus()); |
| | | groupPurchase.setStartStatus(StartStatusEnum.ENDED); |
| | | if (!groupPurchase.getGroupStatus().equals(GroupStatusEnum.FORMED_INTO_A_GROUP)) { |
| | | List<GoodsGroupPurchaseInfo> groupPurchaseInfoList = goodsGroupPurchaseInfoService.lambdaQuery() |
| | | .eq(GoodsGroupPurchaseInfo::getGroupPurchaseId, dto.getId()).list(); |
| | | long count = groupPurchaseInfoList.stream().filter(info -> info.getGroupStatus() == 1) |
| | | .count(); |
| | | if (count > 0) { |
| | | groupPurchase.setGroupStatus(GroupStatusEnum.FORMED_INTO_A_GROUP); |
| | | } else { |
| | | groupPurchase.setGroupStatus(GroupStatusEnum.GROUP_FAILURE); |
| | | } |
| | | this.updateById(groupPurchase); |
| | | if (dto.getListingStatus().equals(ListingStatusEnum.ON_SHELVES)) { |
| | | asyncMethodService.groupPurchaseScheduleTask(Lists.newArrayList(groupPurchase)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.goods.service.IGoodsSkuService; |
| | | import com.ruoyi.goods.service.IMemberGoodsCollectionService; |
| | | import com.ruoyi.goods.service.async.AsyncMethodService; |
| | | import com.ruoyi.system.api.constants.DelayTaskEnum; |
| | | import com.ruoyi.system.api.constants.NotificationTypeConstant; |
| | | import com.ruoyi.system.api.domain.GoodsBrand; |
| | | import com.ruoyi.system.api.domain.GoodsCategory; |
| | |
| | | goodsStockUpdDTO.setAuctionStock(upd.getSeckillStock() * -1); |
| | | goodsStockUpdDTO.setGoodsSkuId(goodsSeckill.getGoodsSkuId()); |
| | | goodsSkuService.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO)); |
| | | if (goodsSeckill.getListingStatus().equals(ListingStatusEnum.ON_SHELVES)) { |
| | | asyncMethodService.seckillScheduleTask(Lists.newArrayList(goodsSeckill)); |
| | | } |
| | | asyncMethodService.seckillScheduleTask(Lists.newArrayList(goodsSeckill)); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | goodsSeckill.setListingStatus(dto.getListingStatus()); |
| | | if (dto.getListingStatus().equals(ListingStatusEnum.REMOVED_FROM_THE_SHELF)) { |
| | | //移除该秒杀商品的延时任务 |
| | | redisService.deleteObject( |
| | | DelayTaskEnum.SECKILL_START_TASK.getCode() + "-" + goodsSeckill.getId()); |
| | | redisService.deleteObject( |
| | | DelayTaskEnum.SECKILL_END_TASK.getCode() + "-" + goodsSeckill.getId()); |
| | | // 退回剩余库存 |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setAuctionStock(goodsSeckill.getSeckillStock()); |
| | | goodsStockUpdDTO.setGoodsSkuId(goodsSeckill.getGoodsSkuId()); |
| | | goodsSkuService.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO)); |
| | | goodsSeckill.setSeckillStock(0); |
| | | } |
| | | this.updateById(goodsSeckill); |
| | | if (dto.getListingStatus().equals(ListingStatusEnum.ON_SHELVES)) { |
| | | asyncMethodService.seckillScheduleTask(Lists.newArrayList(goodsSeckill)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | GoodsSeckill goodsSeckill = this.getById(seckillId); |
| | | // 秒杀商品不能为空且上架状态为上架中 状态为未开始 |
| | | if (StringUtils.isNotNull(goodsSeckill) |
| | | && goodsSeckill.getStartStatus().equals(StartStatusEnum.NOT_STARTED) && |
| | | goodsSeckill.getListingStatus() |
| | | .equals(ListingStatusEnum.ON_SHELVES)) { |
| | | && goodsSeckill.getStartStatus().equals(StartStatusEnum.NOT_STARTED)) { |
| | | //开始秒杀 |
| | | this.lambdaUpdate().set(GoodsSeckill::getStartStatus, StartStatusEnum.STARTED) |
| | | .eq(GoodsSeckill::getId, seckillId).update(); |
| | |
| | | package com.ruoyi.goods.task; |
| | | |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.enums.StartStatusEnum; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.system.api.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.goods.service.IGoodsGroupPurchaseService; |
| | | import com.ruoyi.goods.service.IGoodsSeckillService; |
| | | import com.ruoyi.goods.service.async.AsyncMethodService; |
| | | import com.ruoyi.system.api.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.system.api.domain.GoodsSeckill; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | |
| | | log.info(">>>>>>>>>>>>>>>>>>>>定时任务秒杀/团购开始执行<<<<<<<<<<<<<<<<<<<<"); |
| | | LocalDateTime checkTime = LocalDateTime.now().plusHours(1); |
| | | List<GoodsSeckill> list = goodsSeckillService.lambdaQuery() |
| | | .eq(GoodsSeckill::getListingStatus, ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsSeckill::getStartStatus, StartStatusEnum.NOT_STARTED) |
| | | .le(GoodsSeckill::getStartTime, checkTime) |
| | | .list(); |
| | |
| | | asyncMethodService.seckillScheduleTask(list); |
| | | } |
| | | List<GoodsGroupPurchase> groupPurchaseList = goodsGroupPurchaseService.lambdaQuery() |
| | | .eq(GoodsGroupPurchase::getListingStatus, ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsGroupPurchase::getStartStatus, StartStatusEnum.NOT_STARTED) |
| | | .le(GoodsGroupPurchase::getStartTime, checkTime).list(); |
| | | if (StringUtils.isNotEmpty(groupPurchaseList)) { |
| | |
| | | |
| | | @OnMessage |
| | | public void onMessage(String message, Session session) { |
| | | String msg = message.replace("你", "我").replace("吗", "").replace("PING", "PONG") |
| | | .replace("ping", "pong"); |
| | | WebSocketUsers.sendMessageToUserByText(session, msg); |
| | | // String msg = message.replace("你", "我").replace("吗", "").replace("PING", "PONG") |
| | | // .replace("ping", "pong"); |
| | | // WebSocketUsers.sendMessageToUserByText(session, msg); |
| | | } |
| | | } |