diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreMemberController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreMemberController.java new file mode 100644 index 000000000..c0144e342 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreMemberController.java @@ -0,0 +1,40 @@ +package com.ruoyi.web.controller.xkt; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.XktBaseController; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.web.controller.xkt.vo.storeMember.StoreMemberCreateVO; +import com.ruoyi.xkt.service.IStoreMemberService; +import io.swagger.annotations.Api; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 档口购买会员controller + * + * @author ruoyi + * @date 2025-03-26 + */ +@Api(tags = "档口购买会员") +@RestController +@RequiredArgsConstructor +@RequestMapping("/rest/v1/store-members") +public class StoreMemberController extends XktBaseController { + + final IStoreMemberService storeMemberService; + + @PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')") + @Log(title = "", businessType = BusinessType.INSERT) + @PostMapping + public R create(@Validated @RequestBody StoreMemberCreateVO createVO) { + return R.ok(storeMemberService.create(createVO.getStoreId())); + } + + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreProductController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreProductController.java index 9ec2daee4..5696773f1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreProductController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreProductController.java @@ -148,9 +148,6 @@ public class StoreProductController extends XktBaseController { BeanUtil.toBean(cateCountVO, StoreProdStatusCateNumDTO.class)), StoreProdStatusCateCountResVO.class)); } - /** - * 导出档口商品列表 - */ @Log(title = "档口商品", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, StoreProduct storeProduct) { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/advertRound/AdRoundStoreBoughtResVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/advertRound/AdRoundStoreBoughtResVO.java index bc747b0d7..dc713d9c6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/advertRound/AdRoundStoreBoughtResVO.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/advertRound/AdRoundStoreBoughtResVO.java @@ -31,6 +31,8 @@ public class AdRoundStoreBoughtResVO { private Long storeId; @ApiModelProperty(value = "推广展示类型 时间范围 位置枚举") private Integer showType; + @ApiModelProperty(value = "广告位置类型 时间范围 位置枚举") + private Integer displayType; @ApiModelProperty(value = "投放开始时间") @JsonFormat(pattern = "MM月dd日", timezone = "GMT+8") private Date startTime; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/storeMember/StoreMemberCreateVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/storeMember/StoreMemberCreateVO.java new file mode 100644 index 000000000..0e1e046e2 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/storeMember/StoreMemberCreateVO.java @@ -0,0 +1,28 @@ +package com.ruoyi.web.controller.xkt.vo.storeMember; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** + * @author liujiang + * @version v1.0 + * @date 2025/3/27 15:12 + */ +@ApiModel("档口购买会员") +@Data +@Accessors(chain = true) +public class StoreMemberCreateVO { + + @NotNull(message = "档口ID不能为空!") + @ApiModelProperty(value = "档口ID", required = true) + private Long storeId; + @NotNull(message = "会员金额不能为空!") + @ApiModelProperty(value = "会员金额") + private BigDecimal amount; + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java index 72269677d..9d226d358 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java @@ -257,5 +257,9 @@ public class CacheConstants { * 所有的推广 */ public static final String ADVERT_KEY = "advert:"; + /** + * 档口会员 + */ + public static final String STORE_MEMBER = "store_member:"; } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java index 3608aeb7b..2e9caad2c 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java @@ -674,6 +674,9 @@ public class XktTask { */ public void autoCloseTimeoutStore() { + + + // TODO 更新未交年费档口 // TODO 更新未交年费档口 diff --git a/xkt/src/main/java/com/ruoyi/xkt/domain/StoreMember.java b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreMember.java new file mode 100644 index 000000000..3fa3f0c0e --- /dev/null +++ b/xkt/src/main/java/com/ruoyi/xkt/domain/StoreMember.java @@ -0,0 +1,44 @@ +package com.ruoyi.xkt.domain; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.ruoyi.common.core.domain.XktBaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 档口会员 store_member + * + * @author liujiang + * @date 2025-06-25 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class StoreMember extends XktBaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 广告ID + */ + @TableId + private Long id; + /** + * 档口ID + */ + private Long storeId; + /** + * 会员等级 + */ + private Integer level; + /** + * 生效日期 yyyy-MM-dd + */ + private Date startTime; + /** + * 截止日期 yyyy-MM-dd + */ + private Date endTime; + +} diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/advertRound/AdRoundStoreBoughtResDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/advertRound/AdRoundStoreBoughtResDTO.java index 1aca06662..e887c33fa 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/dto/advertRound/AdRoundStoreBoughtResDTO.java +++ b/xkt/src/main/java/com/ruoyi/xkt/dto/advertRound/AdRoundStoreBoughtResDTO.java @@ -30,6 +30,8 @@ public class AdRoundStoreBoughtResDTO { private String typeName; @ApiModelProperty(value = "推广档口ID") private Long storeId; + @ApiModelProperty(value = "广告位置类型 时间范围 位置枚举") + private Integer displayType; @ApiModelProperty(value = "1 时间范围 2位置枚举") private Integer showType; @ApiModelProperty(value = "投放开始时间") diff --git a/xkt/src/main/java/com/ruoyi/xkt/enums/StoreMemberLevel.java b/xkt/src/main/java/com/ruoyi/xkt/enums/StoreMemberLevel.java new file mode 100644 index 000000000..d7c821912 --- /dev/null +++ b/xkt/src/main/java/com/ruoyi/xkt/enums/StoreMemberLevel.java @@ -0,0 +1,35 @@ +package com.ruoyi.xkt.enums; + +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.exception.ServiceException; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 档口会员类型 + * + * @author liujiang + * @date 2025-04-02 23:42 + */ +@Getter +@AllArgsConstructor +public enum StoreMemberLevel { + + // 实力质造 + STRENGTH_CONSTRUCT(1, "实力质造"), + + + ; + + private final Integer value; + private final String label; + + public static StoreMemberLevel of(Integer value) { + for (StoreMemberLevel e : StoreMemberLevel.values()) { + if (e.getValue().equals(value)) { + return e; + } + } + throw new ServiceException("档口会员类型不存在!", HttpStatus.ERROR); + } +} diff --git a/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreMemberMapper.java b/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreMemberMapper.java new file mode 100644 index 000000000..4e32e5b07 --- /dev/null +++ b/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreMemberMapper.java @@ -0,0 +1,16 @@ +package com.ruoyi.xkt.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.xkt.domain.StoreMember; +import org.springframework.stereotype.Repository; + +/** + * 推广营销Mapper接口 + * + * @author ruoyi + * @date 2025-03-26 + */ +@Repository +public interface StoreMemberMapper extends BaseMapper { + +} diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/IStoreMemberService.java b/xkt/src/main/java/com/ruoyi/xkt/service/IStoreMemberService.java new file mode 100644 index 000000000..043bc4f49 --- /dev/null +++ b/xkt/src/main/java/com/ruoyi/xkt/service/IStoreMemberService.java @@ -0,0 +1,18 @@ +package com.ruoyi.xkt.service; + +/** + * 推广营销Service接口 + * + * @author ruoyi + * @date 2025-03-26 + */ +public interface IStoreMemberService { + + /** + * 档口购买会员 + * + * @param storeId 档口ID + * @return Integer + */ + Integer create(Long storeId); +} diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/AdvertRoundServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/AdvertRoundServiceImpl.java index 7a50c31cf..b135dbb11 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/AdvertRoundServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/AdvertRoundServiceImpl.java @@ -259,7 +259,8 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService { } resList.add(typeRoundResDTO); }); - return resList; + // 按照roundId升序排 + return resList.stream().sorted(Comparator.comparing(AdRoundTypeRoundResDTO::getRoundId)).collect(Collectors.toList()); } /** @@ -360,7 +361,10 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService { // 如果是最近的播放轮次,且当前时间在 晚上10:00:01 之后到 当天23:59:59 都显示 biddingTempStatus 字段 final Integer biddingStatus = tenClockAfter && roundIdList.contains(x.getRoundId()) ? x.getBiddingTempStatus() : x.getBiddingStatus(); return BeanUtil.toBean(x, AdRoundStoreBoughtResDTO.class).setAdvertRoundId(x.getId()).setBiddingStatus(biddingStatus) - .setBiddingStatusName(AdBiddingStatus.of(biddingStatus).getLabel()).setTypeName(AdType.of(x.getTypeId()).getLabel()) + // 如果是已出价,则显示 "已出价:50" + .setBiddingStatusName(AdBiddingStatus.of(biddingStatus).getLabel() + + (Objects.equals(biddingStatus, AdBiddingStatus.BIDDING.getValue()) ? ":" + x.getPayPrice() : "")) + .setTypeName(AdType.of(x.getTypeId()).getLabel()) // 如果是时间范围则不返回position .setPosition(Objects.equals(x.getShowType(), AdShowType.TIME_RANGE.getValue()) ? null : x.getPosition()); }) @@ -408,8 +412,7 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService { boughtRoundList.add(BeanUtil.toBean(record, AdRoundStoreBoughtResDTO.class) .setTypeName(AdType.of(record.getTypeId()).getLabel()) .setBiddingStatusName(AdBiddingStatus.of(record.getBiddingStatus()).getLabel() - + ",最新出价:" + positionEnumMaxPriceMap.get(record.getAdvertRoundId())) - ); + + ",最新出价:" + positionEnumMaxPriceMap.get(record.getAdvertRoundId()))); }); } return boughtRoundList; @@ -581,9 +584,9 @@ public class AdvertRoundServiceImpl implements IAdvertRoundService { @Transactional public Integer create(AdRoundStoreCreateDTO createDTO) { // 判断截止时间是否超时,并且只会处理马上播放的这一轮。比如 5.1-5.3,当前为4.30,处理这一轮;当前为5.2,处理这一轮;当前为5.3(最后一天),处理下一轮。 - if (DateUtils.getTime().compareTo(this.getDeadline(createDTO.getSymbol())) > 0) { + /*if (DateUtils.getTime().compareTo(this.getDeadline(createDTO.getSymbol())) > 0) { throw new ServiceException("竞价失败,已过系统截止时间!", HttpStatus.ERROR); - } + }*/ Store store = redisCache.getCacheObject(CacheConstants.STORE_KEY + createDTO.getStoreId()); if (ObjectUtils.isEmpty(store)) { throw new ServiceException("档口不存在!", HttpStatus.ERROR); diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreMemberServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreMemberServiceImpl.java new file mode 100644 index 000000000..1368d2000 --- /dev/null +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreMemberServiceImpl.java @@ -0,0 +1,54 @@ +package com.ruoyi.xkt.service.impl; + +import com.ruoyi.common.constant.CacheConstants; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.xkt.domain.StoreMember; +import com.ruoyi.xkt.enums.StoreMemberLevel; +import com.ruoyi.xkt.mapper.StoreMemberMapper; +import com.ruoyi.xkt.service.IStoreMemberService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.util.Optional; + +/** + * 推广营销Service业务层处理 + * + * @author ruoyi + * @date 2025-03-26 + */ +@Service +@RequiredArgsConstructor +public class StoreMemberServiceImpl implements IStoreMemberService { + + final StoreMemberMapper storeMemberMapper; + final RedisCache redisCache; + + /** + * 档口购买会员 + * + * @param storeId 档口ID + * @return Integer + */ + @Override + @Transactional + public Integer create(Long storeId) { + Optional.ofNullable(storeId).orElseThrow(() -> new RuntimeException("档口ID不能为空")); + StoreMember storeMember = new StoreMember(); + storeMember.setStoreId(storeId); + // 最低等级会员:实力质造 + storeMember.setLevel(StoreMemberLevel.STRENGTH_CONSTRUCT.getValue()); + storeMember.setStartTime(java.sql.Date.valueOf(LocalDate.now())); + // 过期时间设置为1年后 + storeMember.setEndTime(java.sql.Date.valueOf(LocalDate.now().plusYears(1))); + storeMember.setCreateBy(SecurityUtils.getUsername()); + int count = this.storeMemberMapper.insert(storeMember); + // 将档口会员信息添加到 redis 中 + redisCache.setCacheObject(CacheConstants.STORE_MEMBER + storeId, StoreMemberLevel.STRENGTH_CONSTRUCT.getValue()); + return count; + } + +}