From bf6989e1f9cc614cf0439f048280cbcdb78d4009 Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期五, 29 八月 2025 02:12:03 +0800 Subject: [PATCH] 提交本地代码 --- framework/src/main/java/cn/lili/modules/lmk/enums/general/PrizeUserActionEnum.java | 20 +++++++-- framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeActivity.java | 5 ++ buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java | 8 ++-- framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java | 4 ++ framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java | 59 +++++++++++++++++++++++++++-- framework/src/main/java/cn/lili/modules/lmk/domain/form/AddPrizeNumForm.java | 6 ++- 6 files changed, 85 insertions(+), 17 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java b/buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java index a13df76..90a9c91 100644 --- a/buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java +++ b/buyer-api/src/main/java/cn/lili/controller/lmk/PrizeController.java @@ -63,11 +63,11 @@ /** * 澧炲姞鎶藉娆℃暟 * - * @param prizeActivityId + * @param addPrizeNumForm * @return */ - @PostMapping("/addPrizeNum/{prizeActivityId}") - public Result addPrizeNum(@PathVariable String prizeActivityId, @RequestBody AddPrizeNumForm addPrizeNumForm) { - return prizeService.grantRecord(prizeActivityId); + @PostMapping("/addPrizeNum") + public Result addPrizeNum( @RequestBody AddPrizeNumForm addPrizeNumForm) { + return prizeService.addPrizeNum(addPrizeNumForm); } } diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeActivity.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeActivity.java index 558b021..8961563 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeActivity.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/PrizeActivity.java @@ -1,5 +1,6 @@ package cn.lili.modules.lmk.domain.entity; +import cn.lili.modules.lmk.enums.general.PrizeActivityStatusEnum; import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -55,7 +56,9 @@ private String activityCover; @TableField("enable_status") - /** 鏄惁寮�鍚椿鍔� */ + /** 鏄惁寮�鍚椿鍔� + * @see PrizeActivityStatusEnum + * */ private String enableStatus; @TableField("popup") diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/AddPrizeNumForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/AddPrizeNumForm.java index b5e4c40..ac64b4a 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/domain/form/AddPrizeNumForm.java +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/AddPrizeNumForm.java @@ -16,6 +16,8 @@ *鎶藉娲诲姩id */ private String prizeActivityId; - - + /** + * 鍏朵粬鎵╁睍鍙傛暟JSON鏍煎紡鐨勫瓧绗︿覆鐢ㄤ簬鏍¢獙鏁版嵁鐨勬湁鏁堟�� + */ + private String extend; } diff --git a/framework/src/main/java/cn/lili/modules/lmk/enums/general/PrizeUserActionEnum.java b/framework/src/main/java/cn/lili/modules/lmk/enums/general/PrizeUserActionEnum.java index 95f4d32..de039e9 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/enums/general/PrizeUserActionEnum.java +++ b/framework/src/main/java/cn/lili/modules/lmk/enums/general/PrizeUserActionEnum.java @@ -10,10 +10,20 @@ /** * 鑾峰彇浼樻儬鍗风殑鏂瑰紡 */ - SYSTEM("绯荤粺璧犻��"), - BUY("璐拱"), - SHARE("鍒嗕韩"), - SEE_SHOP("鐪嬪晢鍩�"), - SEE_VIDEO("鐪嬭棰�"); + SYSTEM("绯荤粺璧犻��",1), + BUY("璐拱",1), + SHARE("鍒嗕韩",1), + SEE_SHOP("鐪嬪晢鍩�",1), + SEE_VIDEO("鐪嬭棰�",1); private final String description; + private final Integer sendNumber; + + public static PrizeUserActionEnum select(String name) { + for (PrizeUserActionEnum prizeUserActionEnum : values()) { + if (prizeUserActionEnum.name().equals(name)) { + return prizeUserActionEnum; + } + } + return null; + } } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java b/framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java index 5e528da..a67ac86 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/PrizeService.java @@ -1,7 +1,9 @@ package cn.lili.modules.lmk.service; import cn.lili.base.Result; +import cn.lili.modules.lmk.domain.form.AddPrizeNumForm; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; public interface PrizeService { @@ -14,4 +16,6 @@ Result grantRecord( String prizeActivityId); + Result addPrizeNum(AddPrizeNumForm addPrizeNumForm); + } diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java index c0359cf..60f23e6 100644 --- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java @@ -7,6 +7,7 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.StringUtils; import cn.lili.modules.lmk.domain.entity.*; +import cn.lili.modules.lmk.domain.form.AddPrizeNumForm; import cn.lili.modules.lmk.domain.query.PrizeRecordTimeQuery; import cn.lili.modules.lmk.domain.vo.PrizeDetailVO; import cn.lili.modules.lmk.domain.vo.PrizeProbabilityVO; @@ -56,6 +57,7 @@ private final RocketmqCustomProperties rocketmqCustomProperties; private final RocketMQTemplate rocketMQTemplate; private final COSUtil cosUtil; + @Override @Transactional(rollbackFor = Exception.class) public Result prize(String prizeId) { @@ -174,7 +176,7 @@ prizeRecordTimeQuery.setEndTime(endTime); prizeRecordTimeQuery.setRecordActivityId(prizeId); prizeRecordListByTime = prizeRecordService.getPrizeRecordListByTime(prizeRecordTimeQuery); - prizeRecordListByTime.stream().filter(item->{ + prizeRecordListByTime.stream().filter(item -> { return item.getActivityPrizeRefId() != null; }).forEach(item -> { ActivityRefPrize activityRefPrize = canPrizeMap.get(item.getActivityPrizeRefId()); @@ -384,7 +386,7 @@ if (useNum >= maxPrize) { return Result.ok().data(0); } else { - return Result.ok().data(userPrizeNum>maxPrize?maxPrize-useNum:notUseNum); + return Result.ok().data(userPrizeNum > maxPrize ? maxPrize - useNum : notUseNum); } } @@ -421,16 +423,16 @@ } PrizeDetailVO data = prizeActivityService.prizeInfo(prizeActivityId); String activityCover = data.getActivityCover(); - if (StringUtils.isNotBlank(activityCover)&&!activityCover.contains("http")) { + if (StringUtils.isNotBlank(activityCover) && !activityCover.contains("http")) { data.setActivityCover(cosUtil.getPreviewUrl(activityCover)); } data.getPrizeInfoVOS().forEach(info -> { String prizeImg = info.getPrizeImg(); String prizeCover = info.getPrizeCover(); - if (StringUtils.isNotBlank(prizeImg)&&!prizeImg.contains("http")) { + if (StringUtils.isNotBlank(prizeImg) && !prizeImg.contains("http")) { info.setPrizeImg(cosUtil.getPreviewUrl(prizeImg)); } - if (StringUtils.isNotBlank(prizeCover)&&!prizeCover.contains("http")) { + if (StringUtils.isNotBlank(prizeCover) && !prizeCover.contains("http")) { info.setPrizeCover(cosUtil.getPreviewUrl(prizeCover)); } }); @@ -441,4 +443,51 @@ public Result grantRecord(String prizeActivityId) { return prizeDrawService.grantRecord(prizeActivityId); } + + @Override + public Result addPrizeNum(AddPrizeNumForm addPrizeNumForm) { + PrizeActivity activity = prizeActivityService.getById(addPrizeNumForm.getPrizeActivityId()); + if (activity == null) { + throw new ServiceException("褰撳墠娲诲姩涓嶅瓨鍦�"); + } + if (!PrizeActivityStatusEnum.ON.name().equals(activity.getEnableStatus())) { + throw new ServiceException("褰撳墠娲诲姩娌″紑鍚�"); + } + Date date = new Date(); + //娲诲姩缁撴潫涓嶉渶瑕佹坊鍔� + if (date.after(activity.getEndTime())) { + throw new ServiceException("褰撳墠娲诲姩宸茬粨鏉�"); + } + Integer maxPrize = activity.getMaxPrize(); + String userId = addPrizeNumForm.getUserId(); + List<PrizeNumber> prizeNumberList = getPrizeNumberList(activity.getId(), userId); + if (prizeNumberList.size() >= maxPrize) { + throw new ServiceException("鎶藉娆℃暟宸茶揪鍒颁笂闄愪簡"); + } + PrizeUserActionEnum actionEnum = PrizeUserActionEnum.select(addPrizeNumForm.getAddType()); + if (actionEnum == null) { + throw new ServiceException("褰撳墠绫诲瀷涓嶅瓨鍦�"); + } + Boolean check ; + //todo 杩涜鏁版嵁鏍¢獙 + switch (actionEnum) { + case BUY: + System.err.println("BUY"); + break; + case SHARE: + //鐩存帴鑾峰緱鎶藉娆℃暟 + System.err.println("SHARE"); + break; + case SEE_SHOP: + System.err.println("SEE_SHOP"); + break; + case SEE_VIDEO: + System.err.println("SEE_VIDEO"); + break; + default: + + break; + } + return null; + } } -- Gitblit v1.8.0