From a966dafb8877552267a94fe8c544c5ea72cf5650 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期一, 16 六月 2025 09:44:40 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/2.0' into 2.0 --- ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/business/MerLotteryEventController.java | 140 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 127 insertions(+), 13 deletions(-) diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/business/MerLotteryEventController.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/business/MerLotteryEventController.java index baa4810..52f9647 100644 --- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/business/MerLotteryEventController.java +++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/business/MerLotteryEventController.java @@ -1,18 +1,42 @@ package com.ruoyi.goods.controller.business; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.uuid.IdUtils; +import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.goods.api.domain.LotteryEvent; +import com.ruoyi.goods.api.domain.LotteryEventPrize; +import com.ruoyi.goods.domain.dto.DelShopLotteryDrawDto; +import com.ruoyi.goods.domain.dto.ShopLotteryDrawListDto; +import com.ruoyi.goods.domain.dto.ShopWinningRecordDto; +import com.ruoyi.goods.domain.vo.ShopLotteryDrawListVo; +import com.ruoyi.goods.domain.vo.ShopLotteryDrawVo; +import com.ruoyi.goods.domain.vo.ShopWinningRecordVo; +import com.ruoyi.goods.service.goods.GoodsService; +import com.ruoyi.goods.service.lottery.ILotteryEventPrizeService; import com.ruoyi.goods.service.lottery.ILotteryEventService; -import org.springframework.web.bind.annotation.*; +import com.ruoyi.goods.service.lottery.IUserLotteryEventService; +import com.ruoyi.system.api.domain.poji.goods.Goods; +import com.ruoyi.system.api.domain.poji.shop.Shop; +import com.ruoyi.system.api.service.RemoteShopService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.time.LocalDateTime; import java.util.List; /** * @author zhibing.pu * @Date 2025/5/8 18:13 */ +@Api(value = "商户端商户相关接口", tags = "商户端商户相关接口", description = "商户端商户相关接口") @RestController @RequestMapping("/mer/lotteryEvent") public class MerLotteryEventController { @@ -20,19 +44,109 @@ @Resource private ILotteryEventService lotteryEventService; + @Resource + private RemoteShopService remoteShopService; - /** - * 根据开启方式获取活动列表 - * - * @param activityType - * @return - */ - @ResponseBody - @PostMapping("/getLotteryEventList") - public R<List<LotteryEvent>> getLotteryEventList(@RequestParam("activityType") Integer activityType) { - List<LotteryEvent> list = lotteryEventService.list(new LambdaQueryWrapper<LotteryEvent>().eq(LotteryEvent::getActivityType, activityType) - .eq(LotteryEvent::getDelFlag, 0).last(" and now() between start_time and end_time")); - return R.ok(list); + @Resource + private ILotteryEventPrizeService lotteryEventPrizeService; + + @Resource + private IUserLotteryEventService userLotteryEventService; + + @Resource + private GoodsService goodsService; + + + @RequestMapping(value = "/getShopLotteryDrawList", method = RequestMethod.POST) + @ApiOperation(value = "获取门店抽奖活动列表【2.0】") + public R<ShopLotteryDrawVo> getShopLotteryDrawList(@RequestBody ShopLotteryDrawListDto dto) { + Page<ShopLotteryDrawListVo> page = new Page<>(); + page.setSize(dto.getPageSize()); + page.setCurrent(dto.getPageNum()); + Shop shop = remoteShopService.getShop(dto.getShopId()).getData(); + ShopLotteryDrawVo shopLotteryDrawVo = new ShopLotteryDrawVo(); + shopLotteryDrawVo.setLotteryDrawFlag(shop.getLotteryDrawFlag()); + List<ShopLotteryDrawListVo> shopLotteryDrawList = lotteryEventService.getShopLotteryDrawList(page, dto.getShopId()); + page.setRecords(shopLotteryDrawList); + shopLotteryDrawVo.setPage(page); + return R.ok(shopLotteryDrawVo); + } + + @RequestMapping(value = "/delShopLotteryDraw", method = RequestMethod.POST) + @ApiOperation(value = "门店删除抽奖活动【2.0】") + public R delShopLotteryDraw(@RequestBody DelShopLotteryDrawDto dto) { + LotteryEvent lotteryEvent = lotteryEventService.getById(dto.getId()); + if (null == lotteryEvent) { + return R.fail("抽奖活动不存在"); + } + if (LocalDateTime.now().isAfter(lotteryEvent.getStartTime())) { + return R.fail("删除失败"); + } + if (!lotteryEvent.getShopId().equals(dto.getShopId())) { + return R.fail("删除失败"); + } + lotteryEvent.setDelFlag(1); + lotteryEventService.updateById(lotteryEvent); + return R.ok(); + } + + + @RequestMapping(value = "/getShopLotteryDrawInfo", method = RequestMethod.POST) + @ApiOperation(value = "获取门店抽奖详情【2.0】") + public R<LotteryEvent> getShopLotteryDrawInfo(@RequestBody DelShopLotteryDrawDto dto) { + LotteryEvent lotteryEvent = lotteryEventService.getById(dto.getId()); + if (null == lotteryEvent) { + return R.fail("抽奖活动不存在"); + } + if (!lotteryEvent.getShopId().equals(dto.getShopId())) { + return R.fail("查询失败"); + } + List<LotteryEventPrize> list = lotteryEventPrizeService.list(new LambdaQueryWrapper<LotteryEventPrize>().eq(LotteryEventPrize::getLotteryEventId, dto.getId())); + lotteryEvent.setPrizes(list); + return R.ok(lotteryEvent); + } + + + @RequestMapping(value = "/editShopLotteryDraw", method = RequestMethod.POST) + @ApiOperation(value = "保存门店抽奖【2.0】") + public R editShopLotteryDraw(@RequestBody LotteryEvent lotteryEvent) { + if (lotteryEvent.getId() == null) { + lotteryEvent.setId(IdUtils.simpleUUID()); + } + lotteryEvent.setUpdateTime(LocalDateTime.now()); + lotteryEvent.setUpdateUserId(SecurityUtils.getUserId()); + lotteryEventService.saveOrUpdate(lotteryEvent); + //先删除原有的奖品 + lotteryEventPrizeService.remove(new LambdaQueryWrapper<LotteryEventPrize>().eq(LotteryEventPrize::getLotteryEventId, lotteryEvent.getId())); + //添加新的奖品 + List<LotteryEventPrize> prizes = lotteryEvent.getPrizes(); + prizes.forEach(s -> { + s.setId(IdUtils.simpleUUID()); + if (s.getPrizeType() == 2 && StringUtils.isEmpty(s.getObjectName())) { + Goods goods = goodsService.getById(s.getObjectId()); + s.setObjectName(goods.getGoodsName()); + } + s.setLotteryEventId(lotteryEvent.getId()); + }); + lotteryEventPrizeService.saveOrUpdateBatch(prizes); + return R.ok(); + } + + @RequestMapping(value = "/getShopWinningRecord", method = RequestMethod.POST) + @ApiOperation(value = "获取中奖记录列表【2.0】") + public R<Page<ShopWinningRecordVo>> getShopWinningRecord(@RequestBody ShopWinningRecordDto dto) { + LotteryEvent lotteryEvent = lotteryEventService.getById(dto.getId()); + if (null == lotteryEvent) { + return R.fail("抽奖活动不存在"); + } + if (!lotteryEvent.getShopId().equals(dto.getShopId())) { + return R.fail("查询失败"); + } + Page<ShopWinningRecordVo> page = new Page<>(); + page.setSize(dto.getPageSize()); + page.setCurrent(dto.getPageNum()); + List<ShopWinningRecordVo> shopWinningRecordVoList = userLotteryEventService.getShopWinningRecord(page, dto.getId()); + return R.ok(page.setRecords(shopWinningRecordVoList)); } -- Gitblit v1.7.1