| | |
| | | SECKILL_END_TASK("秒杀商品延时任务", "秒杀商品定时结束任务"), |
| | | GROUP_PURCHASES_START_TASK("团购商品延时任务", "团购商品定时开始任务"), |
| | | GROUP_PURCHASES_END_TASK("团购商品延时任务", "团购商品定时结束任务"), |
| | | AUCTION_GOODS_START_TASK("拍卖商品延时任务", "拍卖商品定时开始任务"), |
| | | AUCTION_GOODS_END_TASK("拍卖商品延时任务", "拍卖商品定时结束任务"), |
| | | ; |
| | | |
| | | String name; |
| | |
| | | |
| | | String SECKILL = "seckill"; |
| | | String GROUP_PURCHASE = "group_purchase"; |
| | | String AUCTION_GOODS = "auction_goods"; |
| | | } |
| | |
| | | package com.ruoyi.system.api.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private String skuName; |
| | | |
| | | @ApiModelProperty(value = "商品年份") |
| | | private String years; |
| | | private LocalDateTime years; |
| | | |
| | | @ApiModelProperty(value = "商品分类id") |
| | | private Long categoryId; |
| | |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroom; |
| | | import com.ruoyi.system.api.feignClient.AuctionClient; |
| | | import com.ruoyi.system.api.feignClient.OrderClient; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | /** |
| | |
| | | return R.fail("获取普通拍卖商品失败" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<?> endAuctionGoods(Long id, String source) { |
| | | return R.fail("结束普通拍卖商品失败" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<?> startAuctionGoods(Long id, String source) { |
| | | return R.fail("开始普通拍卖商品失败" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroom; |
| | | import com.ruoyi.system.api.domain.GoodsFlavorType; |
| | | import com.ruoyi.system.api.domain.OrderAuctionBond; |
| | | import com.ruoyi.system.api.factory.AuctionFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestHeader; |
| | | |
| | |
| | | @PostMapping("/forepart/auction-goods/getAuctionGoodsOne") |
| | | R<AuctionGoods> getauctionGoodsOne(@RequestBody Long auctionGoodsId, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | |
| | | @PutMapping("/auction-goods/end/{id}") |
| | | R<?> endAuctionGoods(@PathVariable("id") Long id, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | |
| | | @PutMapping("/auction-goods/start/{id}") |
| | | R<?> startAuctionGoods(@PathVariable("id") Long id, |
| | | @RequestHeader(SecurityConstants.FROM_SOURCE) String source); |
| | | } |
New file |
| | |
| | | package com.ruoyi.auction.controller.inner; |
| | | |
| | | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.ruoyi.auction.service.IAuctionGoodsService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | | * 拍卖商品表 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | | * @since 2024-05-16 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/auction-goods") |
| | | public class AuctionGoodsController { |
| | | |
| | | private final IAuctionGoodsService auctionGoodsService; |
| | | |
| | | @PutMapping("/auction-goods/end/{id}") |
| | | R<?> endAuctionGoods(@PathVariable("id") Long id) { |
| | | try { |
| | | auctionGoodsService.endAuctionGoods(id); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("结束拍卖商品异常", e); |
| | | return R.fail(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PutMapping("/auction-goods/start/{id}") |
| | | R<?> startAuctionGoods(@PathVariable("id") Long id) { |
| | | try { |
| | | auctionGoodsService.startAuctionGoods(id); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("开始拍卖商品异常", e); |
| | | return R.fail(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | * @author mitao |
| | | * @since 2024-05-16 |
| | | */ |
| | | @Api(value = "拍卖商品管理相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "拍卖商品管理相关接口", tags = {"管理后台-拍卖商品管理相关接口"}) |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/mgt/auction-goods") |
| | |
| | | @RestController |
| | | @RequestMapping("/mgt/auction-salesroom") |
| | | @RequiredArgsConstructor |
| | | @Api(value = "拍卖场管理相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "拍卖场管理相关接口", tags = {"管理后台-拍卖场管理相关接口"}) |
| | | public class MgtAuctionSalesroomController { |
| | | |
| | | private final IAuctionSalesroomService auctionSalesroomService; |
| | |
| | | package com.ruoyi.auction.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionGoodsDTO; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionGoodsQuery; |
| | | import com.ruoyi.auction.controller.management.vo.MgtAuctionGoodsVO; |
| | |
| | | AuctionGoodsinfoVO getAuctionGoodsInfo(@RequestBody AuctionGoodsListDTO auctionGoodsListDTO); |
| | | |
| | | PageDTO<AuctionGoodsListVO> getWdAuctionSalesList(@RequestBody AuctionGoodsListDTO auctionGoodsListDTO); |
| | | |
| | | void endAuctionGoods(Long id) throws JsonProcessingException; |
| | | |
| | | void startAuctionGoods(Long id) throws JsonProcessingException; |
| | | } |
New file |
| | |
| | | package com.ruoyi.auction.service.async; |
| | | |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.system.api.constants.DelayTaskEnum; |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | import com.ruoyi.system.api.domain.DelayTask; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import java.time.Duration; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/5/24 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | public class AuctionAsyncMethodService { |
| | | |
| | | private final RedisService redisService; |
| | | private final SysUserClient sysUserClient; |
| | | |
| | | @Async |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void auctionGoodsScheduleTask(List<AuctionGoods> auctionGoodsList) { |
| | | for (AuctionGoods auctionGoods : auctionGoodsList) { |
| | | LocalDateTime startTime = auctionGoods.getStartTime(); |
| | | LocalDateTime endTime = auctionGoods.getEndTime(); |
| | | // 普通拍品在一小时内开始 |
| | | if (isWithinOneHour(startTime)) { |
| | | Long id = auctionGoods.getId(); |
| | | // 普通拍品已经开始,三秒后执行 |
| | | if (LocalDateTime.now().isAfter(startTime)) { |
| | | handleStartDelayTask(id, DelayTaskEnum.AUCTION_GOODS_START_TASK, startTime, 3L); |
| | | } else { |
| | | Duration duration = Duration.between(LocalDateTime.now(), startTime); |
| | | handleStartDelayTask(id, DelayTaskEnum.AUCTION_GOODS_START_TASK, startTime, |
| | | duration.getSeconds()); |
| | | } |
| | | // 普通拍品结束延时任务 |
| | | handleEndDelayTask(id, DelayTaskEnum.AUCTION_GOODS_END_TASK, endTime); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private boolean isWithinOneHour(LocalDateTime startTime) { |
| | | LocalDateTime checkTime = LocalDateTime.now().plusHours(1); |
| | | return checkTime.isAfter(startTime); |
| | | } |
| | | |
| | | private void handleEndDelayTask(Long id, DelayTaskEnum delayTaskEnum, LocalDateTime endTime) { |
| | | String endTaskKey = delayTaskEnum.getCode() + "-" + id; |
| | | DelayTask endDelayTask = sysUserClient.getDelayTask( |
| | | endTaskKey, SecurityConstants.INNER).getData(); |
| | | // 如果延时任务为空,创建延时任务控制活动定时开始和结束 |
| | | Duration duration = Duration.between(LocalDateTime.now(), endTime); |
| | | if (StringUtils.isNull(endDelayTask)) { |
| | | createEndDelayTask(endTime, endTaskKey, duration); |
| | | } else { |
| | | if (!endDelayTask.getExecuteTime().isEqual(endTime)) { |
| | | sysUserClient.deleteDelayTask(endTaskKey, |
| | | SecurityConstants.INNER); |
| | | redisService.deleteObject(endTaskKey); |
| | | createEndDelayTask(endTime, endTaskKey, duration); |
| | | } |
| | | } |
| | | log.info(">>>>>>>>>>>>>>>>>>>>延时任务{}执行了<<<<<<<<<<<<<<<<<<<<", endTaskKey); |
| | | } |
| | | |
| | | private void createEndDelayTask(LocalDateTime endTime, String seckillEndTaskKey, |
| | | Duration duration) { |
| | | DelayTask endDelayTask; |
| | | redisService.setCacheObject( |
| | | seckillEndTaskKey, |
| | | endTime, duration.getSeconds(), TimeUnit.SECONDS); |
| | | endDelayTask = new DelayTask(); |
| | | endDelayTask.setDelFlag(0); |
| | | endDelayTask.setCreateTime(LocalDateTime.now()); |
| | | endDelayTask.setExecuteTime(endTime); |
| | | endDelayTask.setRedisKey(seckillEndTaskKey); |
| | | sysUserClient.addDelayTask(endDelayTask, SecurityConstants.INNER); |
| | | } |
| | | |
| | | private void handleStartDelayTask(Long id, DelayTaskEnum delayTaskEnum, LocalDateTime startTime, |
| | | Long timeout) { |
| | | String startTaskKey = delayTaskEnum.getCode() + "-" + id; |
| | | redisService.setCacheObject( |
| | | startTaskKey, |
| | | startTime, timeout, TimeUnit.SECONDS); |
| | | // 查询延时任务 |
| | | DelayTask startDelayTask = sysUserClient.getDelayTask( |
| | | startTaskKey, SecurityConstants.INNER).getData(); |
| | | if (StringUtils.isNull(startDelayTask)) { |
| | | startDelayTask = new DelayTask(); |
| | | startDelayTask.setDelFlag(0); |
| | | startDelayTask.setCreateTime(LocalDateTime.now()); |
| | | startDelayTask.setExecuteTime(LocalDateTime.now().plusSeconds(timeout)); |
| | | startDelayTask.setRedisKey( |
| | | startTaskKey); |
| | | sysUserClient.addDelayTask(startDelayTask, SecurityConstants.INNER); |
| | | } else { |
| | | if (!startDelayTask.getExecuteTime().isEqual(startTime)) { |
| | | sysUserClient.deleteDelayTask( |
| | | startTaskKey, SecurityConstants.INNER); |
| | | redisService.deleteObject( |
| | | startTaskKey); |
| | | startDelayTask.setDelFlag(0); |
| | | startDelayTask.setCreateTime(LocalDateTime.now()); |
| | | startDelayTask.setExecuteTime(LocalDateTime.now().plusSeconds(timeout)); |
| | | startDelayTask.setRedisKey( |
| | | startTaskKey); |
| | | sysUserClient.addDelayTask(startDelayTask, SecurityConstants.INNER); |
| | | } |
| | | } |
| | | log.info(">>>>>>>>>>>>>>>>>>>>延时任务{}执行了<<<<<<<<<<<<<<<<<<<<", startTaskKey); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.auction.domain.AuctionBrowseRecord; |
| | | import com.ruoyi.auction.mapper.AuctionBrowseRecordMapper; |
| | | import com.ruoyi.auction.mapper.AuctionGoodsMapper; |
| | | import com.ruoyi.auction.mapper.AuctionSalesroomMapper; |
| | | import com.ruoyi.auction.service.IAuctionBrowseRecordService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | |
| | | import com.ruoyi.system.api.domain.vo.WdMemberAuctionSalesroomVO; |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import com.ruoyi.system.api.feignClient.OrderClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionGoodsDTO; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionGoodsQuery; |
| | |
| | | import com.ruoyi.auction.service.IAuctionBrowseRecordService; |
| | | import com.ruoyi.auction.service.IAuctionGoodsService; |
| | | import com.ruoyi.auction.service.IMemberAuctionCollectionService; |
| | | import com.ruoyi.auction.service.async.AuctionAsyncMethodService; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.enums.AuctionOrderTypeEnum; |
| | | import com.ruoyi.common.core.enums.AuctionStartStatusEnum; |
| | | import com.ruoyi.common.core.enums.BidStatusEnum; |
| | | import com.ruoyi.common.core.enums.BondStatusEnum; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.enums.OrderFromEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.page.BeanUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.system.api.constants.NotificationTypeConstant; |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | import com.ruoyi.system.api.domain.GoodsBrand; |
| | | import com.ruoyi.system.api.domain.GoodsCategory; |
| | |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import com.ruoyi.system.api.feignClient.MemberClient; |
| | | import com.ruoyi.system.api.feignClient.OrderClient; |
| | | import com.ruoyi.system.api.util.WebSocketUsers; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | private final MemberClient memberClient; |
| | | private final OrderClient orderClient; |
| | | private final IAuctionBidRecordService auctionBidRecordService; |
| | | |
| | | private final AuctionAsyncMethodService auctionAsyncMethodService; |
| | | // 创建一个静态共享的ObjectMapper实例以重用 |
| | | private static final ObjectMapper objectMapper = new ObjectMapper(); |
| | | @Resource |
| | | private IMemberAuctionCollectionService memberAuctionCollectionService; |
| | | |
| | |
| | | auctionGoodsOrg.getAuctionStock() - dto.getAuctionStock()); |
| | | goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), |
| | | SecurityConstants.INNER); |
| | | auctionAsyncMethodService.auctionGoodsScheduleTask(Lists.newArrayList(auctionGoods)); |
| | | } |
| | | } |
| | | |
| | |
| | | page.setRecords(auctionGoodsVOS); |
| | | return PageDTO.of(page); |
| | | } |
| | | |
| | | @Override |
| | | public void endAuctionGoods(Long id) throws JsonProcessingException { |
| | | AuctionGoods auctionGoods = this.getById(id); |
| | | if (StringUtils.isNotNull(auctionGoods) && auctionGoods.getListingStatus().equals( |
| | | ListingStatusEnum.ON_SHELVES) && auctionGoods.getStartStatus() |
| | | .equals(AuctionStartStatusEnum.IN_PREVIEW)) { |
| | | this.lambdaUpdate().set(AuctionGoods::getStartStatus, AuctionStartStatusEnum.IN_AUCTION) |
| | | .eq(AuctionGoods::getId, id); |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_GOODS); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", id); |
| | | map.put("message_type", "start"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | | log.info("===================>发送websocket通知,消息体{}", msg); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void startAuctionGoods(Long id) throws JsonProcessingException { |
| | | AuctionGoods auctionGoods = this.getById(id); |
| | | if (StringUtils.isNotNull(auctionGoods) && auctionGoods.getListingStatus().equals( |
| | | ListingStatusEnum.ON_SHELVES) && auctionGoods.getStartStatus() |
| | | .equals(AuctionStartStatusEnum.IN_AUCTION)) { |
| | | this.lambdaUpdate().set(AuctionGoods::getStartStatus, AuctionStartStatusEnum.ENDED) |
| | | .eq(AuctionGoods::getId, id); |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_GOODS); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", id); |
| | | map.put("message_type", "end"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | | log.info("===================>发送websocket通知,消息体{}", msg); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.auction.service.impl; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayApiException; |
| | |
| | | import com.ruoyi.auction.domain.AuctionVideo; |
| | | import com.ruoyi.auction.mapper.AuctionSalesroomGoodsMapper; |
| | | import com.ruoyi.auction.mapper.AuctionSalesroomMapper; |
| | | import com.ruoyi.auction.service.*; |
| | | import com.ruoyi.auction.service.IAuctionBidRecordService; |
| | | import com.ruoyi.auction.service.IAuctionBrowseRecordService; |
| | | import com.ruoyi.auction.service.IAuctionGoodsService; |
| | | import com.ruoyi.auction.service.IAuctionSalesroomGoodsService; |
| | | import com.ruoyi.auction.service.IAuctionSalesroomService; |
| | | import com.ruoyi.auction.service.IAuctionVideoService; |
| | | import com.ruoyi.auction.util.CreateQrCode; |
| | | import com.ruoyi.auction.util.HttpUtils; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private WxMaService wxMaService; |
| | | // @Resource |
| | | // private WxMaService wxMaService; |
| | | |
| | | @Resource |
| | | private AuctionSalesroomGoodsMapper auctionSalesroomGoodsMapper; |
| | |
| | | String openid; |
| | | String sessionKey = null; |
| | | //获取session |
| | | session = wxMaService.getUserService().getSessionInfo(appMiniLoginDto.getCode()); |
| | | // session = wxMaService.getUserService().getSessionInfo(appMiniLoginDto.getCode()); |
| | | if (session != null && StringUtils.isNotBlank(session.getOpenid())) { |
| | | unionid = session.getUnionid(); |
| | | openid = session.getOpenid(); |
New file |
| | |
| | | package com.ruoyi.auction.task; |
| | | |
| | | import com.ruoyi.auction.service.IAuctionGoodsService; |
| | | import com.ruoyi.auction.service.async.AuctionAsyncMethodService; |
| | | 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.AuctionGoods; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/5/24 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @RequiredArgsConstructor |
| | | public class AuctionGoodsScheduler { |
| | | |
| | | private final AuctionAsyncMethodService asyncMethodService; |
| | | private final IAuctionGoodsService auctionGoodsService; |
| | | |
| | | @Scheduled(cron = "0 0 */1 * * ?") |
| | | private void timingTask() { |
| | | handleTaskStart(); |
| | | } |
| | | |
| | | private void handleTaskStart() { |
| | | log.info(">>>>>>>>>>>>>>>>>>>>定时任务秒杀/团购开始执行<<<<<<<<<<<<<<<<<<<<"); |
| | | LocalDateTime checkTime = LocalDateTime.now().plusHours(1); |
| | | List<AuctionGoods> list = auctionGoodsService.lambdaQuery() |
| | | .eq(AuctionGoods::getListingStatus, ListingStatusEnum.ON_SHELVES) |
| | | .eq(AuctionGoods::getStartStatus, StartStatusEnum.NOT_STARTED) |
| | | .le(AuctionGoods::getStartTime, checkTime) |
| | | .list(); |
| | | if (StringUtils.isNotEmpty(list)) { |
| | | asyncMethodService.auctionGoodsScheduleTask(list); |
| | | } |
| | | } |
| | | } |
| | |
| | | @RestController |
| | | @RequestMapping("/mgt/goods-brand") |
| | | @RequiredArgsConstructor |
| | | @Api(value = "管理后台商品品牌相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "管理后台商品品牌相关接口", tags = {"管理后台-商品品牌相关接口"}) |
| | | public class MgtGoodsBrandController { |
| | | |
| | | private final IGoodsBrandService goodsBrandService; |
| | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/mgt/goods-category") |
| | | @Api(value = "管理后台商品分类相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "管理后台商品分类相关接口", tags = {"管理后台-商品分类相关接口"}) |
| | | public class MgtGoodsCategoryController { |
| | | |
| | | private final IGoodsCategoryService goodsCategoryService; |
| | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/mgt/goods-flavor-type") |
| | | @Api(value = "管理后台商品香型相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "管理后台商品香型相关接口", tags = {"管理后台-商品香型相关接口"}) |
| | | public class MgtGoodsFlavorTypeController { |
| | | |
| | | private final IGoodsFlavorTypeService goodsFlavorTypeService; |
| | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/mgt/goods-group-purchase") |
| | | @Api(value = "管理后台商品团购相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "管理后台商品团购相关接口", tags = {"管理后台-商品团购相关接口"}) |
| | | public class MgtGoodsGroupPurchaseController { |
| | | |
| | | private final IGoodsGroupPurchaseService goodsGroupPurchaseService; |
| | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/mgt/goods-info-title") |
| | | @Api(value = "管理后台商品信息标题相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "管理后台商品信息标题相关接口", tags = {"管理后台-商品信息标题相关接口"}) |
| | | public class MgtGoodsInfoTitleController { |
| | | |
| | | private final IGoodsInfoTitleService goodsInfoTitleService; |
| | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/mgt/goods-seckill") |
| | | @Api(value = "管理后台商品秒杀相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "管理后台商品秒杀相关接口", tags = {"管理后台-商品秒杀相关接口"}) |
| | | public class MgtGoodsSeckillController { |
| | | |
| | | private final IGoodsSeckillService goodsSeckillService; |
| | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/mgt/goods-series") |
| | | @Api(value = "管理后台商品系列相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "管理后台商品系列相关接口", tags = {"管理后台-商品系列相关接口"}) |
| | | public class MgtGoodsSeriesController { |
| | | |
| | | private final IGoodsSeriesService goodsSeriesService; |
| | |
| | | @RestController |
| | | @RequestMapping("/mgt/goods-sku") |
| | | @RequiredArgsConstructor |
| | | @Api(value = "管理后台商品相关接口", tags = {"管理后台接口"}) |
| | | @Api(value = "管理后台商品相关接口", tags = {"管理后台-商品相关接口"}) |
| | | public class MgtGoodsSkuController { |
| | | |
| | | private final IGoodsSkuService goodsSkuService; |
| | |
| | | package com.ruoyi.goods.controller.management.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotBlank; |
| | |
| | | |
| | | @ApiModelProperty(value = "商品年份") |
| | | @NotBlank(message = "商品年份不能为空") |
| | | private String years; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime years; |
| | | |
| | | @ApiModelProperty(value = "商品分类id") |
| | | @NotNull(message = "商品分类id不能为空") |
| | |
| | | package com.ruoyi.goods.controller.management.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.goods.controller.management.dto.GoodsInfoTitleValueDTO; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import lombok.Data; |
| | | |
| | |
| | | private String skuName; |
| | | |
| | | @ApiModelProperty(value = "商品年份") |
| | | private String years; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime years; |
| | | |
| | | @ApiModelProperty(value = "商品分类id") |
| | | private Long categoryId; |
| | |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import java.time.Duration; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | @Async |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void seckillScheduleTask(GoodsSeckill goodsSeckill) { |
| | | LocalDateTime startTime = goodsSeckill.getStartTime(); |
| | | LocalDateTime endTime = goodsSeckill.getEndTime(); |
| | | //秒杀在一小时内开始 |
| | | if (isWithinOneHour(startTime)) { |
| | | Long id = goodsSeckill.getId(); |
| | | //秒杀已经开始 |
| | | if (LocalDateTime.now().isAfter(startTime)) { |
| | | handleStartDelayTask(id, DelayTaskEnum.SECKILL_START_TASK, startTime, 3L); |
| | | } else { |
| | | Duration duration = Duration.between(LocalDateTime.now(), startTime); |
| | | handleStartDelayTask(id, DelayTaskEnum.SECKILL_START_TASK, startTime, |
| | | duration.getSeconds()); |
| | | public void seckillScheduleTask(List<GoodsSeckill> goodsSeckillList) { |
| | | for (GoodsSeckill goodsSeckill : goodsSeckillList) { |
| | | LocalDateTime startTime = goodsSeckill.getStartTime(); |
| | | LocalDateTime endTime = goodsSeckill.getEndTime(); |
| | | // 秒杀在一小时内开始 |
| | | if (isWithinOneHour(startTime)) { |
| | | Long id = goodsSeckill.getId(); |
| | | // 秒杀已经开始 |
| | | if (LocalDateTime.now().isAfter(startTime)) { |
| | | handleStartDelayTask(id, DelayTaskEnum.SECKILL_START_TASK, startTime, 3L); |
| | | } 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); |
| | | } |
| | | log.info(">>>>>>>>>>>>>>>>>>>>秒杀商品:{} 开始秒杀<<<<<<<<<<<<<<<<<<<<", id); |
| | | //秒杀结束延时任务 |
| | | handleEndDelayTask(id, DelayTaskEnum.SECKILL_END_TASK, endTime); |
| | | |
| | | } |
| | | } |
| | | |
| | | @Async |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void groupPurchaseScheduleTask(GoodsGroupPurchase groupPurchase) { |
| | | LocalDateTime startTime = groupPurchase.getStartTime(); |
| | | LocalDateTime endTime = groupPurchase.getEndTime(); |
| | | //秒杀在一小时内开始 |
| | | if (isWithinOneHour(startTime)) { |
| | | Long id = groupPurchase.getId(); |
| | | //秒杀已经开始,三秒后执行 |
| | | if (LocalDateTime.now().isAfter(startTime)) { |
| | | handleStartDelayTask(id, DelayTaskEnum.GROUP_PURCHASES_START_TASK, startTime, 3L); |
| | | } else { |
| | | Duration duration = Duration.between(LocalDateTime.now(), startTime); |
| | | handleStartDelayTask(id, DelayTaskEnum.GROUP_PURCHASES_START_TASK, startTime, |
| | | duration.getSeconds()); |
| | | public void groupPurchaseScheduleTask(List<GoodsGroupPurchase> groupPurchaseList) { |
| | | for (GoodsGroupPurchase goodsGroupPurchase : groupPurchaseList) { |
| | | LocalDateTime startTime = goodsGroupPurchase.getStartTime(); |
| | | LocalDateTime endTime = goodsGroupPurchase.getEndTime(); |
| | | // 团购在一小时内开始 |
| | | if (isWithinOneHour(startTime)) { |
| | | Long id = goodsGroupPurchase.getId(); |
| | | // 团购已经开始,三秒后执行 |
| | | if (LocalDateTime.now().isAfter(startTime)) { |
| | | handleStartDelayTask(id, DelayTaskEnum.GROUP_PURCHASES_START_TASK, startTime, |
| | | 3L); |
| | | } else { |
| | | Duration duration = Duration.between(LocalDateTime.now(), startTime); |
| | | handleStartDelayTask(id, DelayTaskEnum.GROUP_PURCHASES_START_TASK, startTime, |
| | | duration.getSeconds()); |
| | | } |
| | | // 团购结束延时任务 |
| | | handleEndDelayTask(id, DelayTaskEnum.GROUP_PURCHASES_END_TASK, endTime); |
| | | } |
| | | //秒杀结束延时任务 |
| | | handleEndDelayTask(id, DelayTaskEnum.GROUP_PURCHASES_END_TASK, endTime); |
| | | } |
| | | } |
| | | |
| | | |
| | | private boolean isWithinOneHour(LocalDateTime startTime) { |
| | | LocalDateTime checkTime = LocalDateTime.now().plusHours(1); |
| | | return checkTime.isAfter(startTime); |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.enums.GroupStatusEnum; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | |
| | | .ge(GoodsSku::getStock, latestStock) |
| | | .eq(GoodsSku::getId, goodsSku.getId()); |
| | | this.updateById(goodsGroupPurchase); |
| | | asyncMethodService.groupPurchaseScheduleTask(goodsGroupPurchase); |
| | | asyncMethodService.groupPurchaseScheduleTask(Lists.newArrayList(goodsGroupPurchase)); |
| | | } |
| | | } |
| | | |
| | |
| | | public void startGroupPurchase(Long groupPurchaseId) throws JsonProcessingException { |
| | | log.info(">>>>>>>>>>>>>>>>>>>>{}团购商品开始团购<<<<<<<<<<<<<<<<<<<<", groupPurchaseId); |
| | | GoodsGroupPurchase groupPurchase = this.getById(groupPurchaseId); |
| | | if (StringUtils.isNotNull(groupPurchase)) { |
| | | if (StringUtils.isNotNull(groupPurchase) && groupPurchase.getStartStatus() |
| | | .equals(StartStatusEnum.NOT_STARTED) && groupPurchase.getListingStatus() |
| | | .equals(ListingStatusEnum.ON_SHELVES)) { |
| | | this.lambdaUpdate().set(GoodsGroupPurchase::getStartStatus, StartStatusEnum.STARTED) |
| | | .eq(GoodsGroupPurchase::getId, groupPurchaseId).update(); |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.GROUP_PURCHASE); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", groupPurchaseId); |
| | | map.put("message_type", "start"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | |
| | | public void endGroupPurchase(Long groupPurchaseId) throws JsonProcessingException { |
| | | log.info(">>>>>>>>>>>>>>>>>>>>{}团购商品结束团购<<<<<<<<<<<<<<<<<<<<", groupPurchaseId); |
| | | GoodsGroupPurchase groupPurchase = this.getById(groupPurchaseId); |
| | | if (StringUtils.isNotNull(groupPurchase)) { |
| | | if (StringUtils.isNotNull(groupPurchase) && groupPurchase.getStartStatus() |
| | | .equals(StartStatusEnum.STARTED)) { |
| | | this.lambdaUpdate().set(GoodsGroupPurchase::getStartStatus, StartStatusEnum.ENDED) |
| | | .eq(GoodsGroupPurchase::getId, groupPurchaseId).update(); |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.GROUP_PURCHASE); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", groupPurchaseId); |
| | | map.put("message_type", "end"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | |
| | | .set(GoodsSku::getStock, goodsSku.getStock() - seckillStock) |
| | | .ge(GoodsSku::getStock, seckillStock) |
| | | .eq(GoodsSku::getId, goodsSku.getId()); |
| | | asyncMethodService.seckillScheduleTask(goodsSeckill); |
| | | asyncMethodService.seckillScheduleTask(Lists.newArrayList(goodsSeckill)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | GoodsSeckill goodsSeckillUpd = BeanUtils.copyBean(upd, GoodsSeckill.class); |
| | | this.updateById(goodsSeckillUpd); |
| | | asyncMethodService.seckillScheduleTask(goodsSeckill); |
| | | asyncMethodService.seckillScheduleTask(Lists.newArrayList(goodsSeckill)); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void startSeckill(Long seckillId) throws JsonProcessingException { |
| | | log.info(">>>>>>>>>>>>>>>>>>>>{}秒杀开始<<<<<<<<<<<<<<<<<<<<", seckillId); |
| | | GoodsSeckill goodsSeckill = this.getById(seckillId); |
| | | //秒杀商品不能为空且状态为未开始 |
| | | // 秒杀商品不能为空且上架状态为上架中 状态为未开始 |
| | | if (StringUtils.isNotNull(goodsSeckill) |
| | | && goodsSeckill.getStartStatus().equals(StartStatusEnum.NOT_STARTED)) { |
| | | && goodsSeckill.getStartStatus().equals(StartStatusEnum.NOT_STARTED) && |
| | | goodsSeckill.getListingStatus() |
| | | .equals(ListingStatusEnum.ON_SHELVES)) { |
| | | //开始秒杀 |
| | | this.lambdaUpdate().set(GoodsSeckill::getStartStatus, StartStatusEnum.STARTED) |
| | | .eq(GoodsSeckill::getId, seckillId).update(); |
| | |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.SECKILL); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", seckillId); |
| | | map.put("message_type", "start"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.SECKILL); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", seckillId); |
| | | map.put("message_type", "end"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | |
| | | String goodsLock = "goods_lock:" + skus.getId(); |
| | | RLock redissonLock = redissonClient.getLock(goodsLock); |
| | | try { |
| | | redissonLock.lock(100, TimeUnit.SECONDS); |
| | | redissonLock.lock(30, TimeUnit.SECONDS); |
| | | Integer auctionStock = stockMap.get(skus.getId()); |
| | | if (StringUtils.isNotNull(auctionStock) && auctionStock > 0) { |
| | | // 更新商品库存,更新五次失败抛出异常 |
| | |
| | | |
| | | private boolean updateGoodsStock(GoodsSku skus, Integer auctionStock) { |
| | | return this.lambdaUpdate() |
| | | .set(GoodsSku::getStock, skus.getStock() + auctionStock) |
| | | .set(skus.getStock() + auctionStock > 0, GoodsSku::getStock, |
| | | skus.getStock() + auctionStock) |
| | | .eq(GoodsSku::getId, skus.getId()) |
| | | .eq(GoodsSku::getStock, skus.getStock()) |
| | | .update(); |
| | |
| | | |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.enums.StartStatusEnum; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.goods.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.goods.service.IGoodsGroupPurchaseService; |
| | | import com.ruoyi.goods.service.IGoodsSeckillService; |
| | |
| | | .eq(GoodsSeckill::getStartStatus, StartStatusEnum.NOT_STARTED) |
| | | .le(GoodsSeckill::getStartTime, checkTime) |
| | | .list(); |
| | | for (GoodsSeckill goodsSeckill : list) { |
| | | asyncMethodService.seckillScheduleTask(goodsSeckill); |
| | | if (StringUtils.isNotEmpty(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(); |
| | | for (GoodsGroupPurchase goodsGroupPurchase : groupPurchaseList) { |
| | | asyncMethodService.groupPurchaseScheduleTask(goodsGroupPurchase); |
| | | if (StringUtils.isNotEmpty(groupPurchaseList)) { |
| | | asyncMethodService.groupPurchaseScheduleTask(groupPurchaseList); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @InnerAuth |
| | | @PostMapping("/addDelayTask") |
| | | public R<?> addDelayTask(@RequestBody DelayTask delayTask) { |
| | | public R<?> |
| | | addDelayTask(@RequestBody DelayTask delayTask) { |
| | | delayTaskService.addDelayTask(delayTask); |
| | | return R.ok(); |
| | | } |
| | |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.system.api.constants.DelayTaskEnum; |
| | | import com.ruoyi.system.api.feignClient.AuctionClient; |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import java.util.Date; |
| | | import javax.annotation.Resource; |
| | |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | @Resource |
| | | private GoodsSkuClient goodsSkuClient; |
| | | @Resource |
| | | private AuctionClient auctionClient; |
| | | public RedisListener(RedisMessageListenerContainer listenerContainer, |
| | | RedisTemplate redisTemplate) { |
| | | super(listenerContainer); |
| | |
| | | else if(DelayTaskEnum.GROUP_PURCHASES_END_TASK.getCode().equals(operation)){ |
| | | //自动结束团购任务 |
| | | autoEndGroupPurchase(id); |
| | | } else if (DelayTaskEnum.AUCTION_GOODS_START_TASK.getCode().equals(operation)) { |
| | | // 自动开始团购任务 |
| | | autoStartAuctionGoods(id); |
| | | } else if (DelayTaskEnum.AUCTION_GOODS_END_TASK.getCode().equals(operation)) { |
| | | // 自动结束团购任务 |
| | | autoEndAuctionGoods(id); |
| | | }else if(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode().equals(operation)){ |
| | | //自动取消订单 |
| | | autoCancelOrder(id); |
| | |
| | | } |
| | | } |
| | | |
| | | @Async |
| | | public void autoEndAuctionGoods(Long id) { |
| | | auctionClient.endAuctionGoods(id, SecurityConstants.INNER); |
| | | } |
| | | |
| | | @Async |
| | | public void autoStartAuctionGoods(Long id) { |
| | | auctionClient.startAuctionGoods(id, SecurityConstants.INNER); |
| | | } |
| | | |
| | | public <T> T getAndSet(final String key, T value){ |
| | | T oldValue=null; |
| | | try { |