| | |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.other.api.domain.OrderActivityInfo; |
| | | import com.ruoyi.other.service.OrderActivityInfoService; |
| | | import com.ruoyi.other.service.VipSettingService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | |
| | | @Resource |
| | | private OrderActivityInfoService orderActivityInfoService; |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getNowOrderActivityInfo") |
| | | public R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){ |
| | | OrderActivityInfo one = orderActivityInfoService.getOne(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0) |
| | | .last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids) limit 0, 1")); |
| | | public R<List<OrderActivityInfo>> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){ |
| | | List<OrderActivityInfo> one = orderActivityInfoService.list(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0) |
| | | .eq(OrderActivityInfo::getIsShelf, 1).last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids)")); |
| | | return R.ok(one); |
| | | } |
| | | |
| | |
| | | * 修改活动 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperation(value = "修改活动", tags = {"管理后台-活动管理-订单优惠活动"}) |
| | | @ApiOperation(value = "修改活动", tags = {"管理后台-活动管理"}) |
| | | public R<Void> updateActivityConfig(@RequestBody OrderActivityInfo orderActivityInfo){ |
| | | orderActivityInfo.setId(Long.valueOf(orderActivityInfo.getIdStr())); |
| | | orderActivityInfoService.updateById(orderActivityInfo); |
| | |
| | | Page<OrderActivityInfo> page = orderActivityInfoService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<OrderActivityInfo>() |
| | | .eq(orderActivityInfo.getId() != null, OrderActivityInfo::getId, orderActivityInfo.getId()) |
| | | .eq(StringUtils.isNotEmpty(orderActivityInfo.getActivityName()), OrderActivityInfo::getActivityName, orderActivityInfo.getActivityName()) |
| | | .lt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 0, OrderActivityInfo::getStartTime, orderActivityInfo.getStartTime()) |
| | | .ge(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, orderActivityInfo.getStartTime()) |
| | | .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf())); |
| | | .gt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 0, OrderActivityInfo::getStartTime, LocalDateTime.now()) |
| | | .ge(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, LocalDateTime.now()) |
| | | .lt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getStartTime, LocalDateTime.now()) |
| | | .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf()).orderByDesc(OrderActivityInfo::getCreateTime)); |
| | | page.getRecords().forEach(item -> { |
| | | LocalDateTime startTime = item.getStartTime(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | |
| | | }else { |
| | | item.setStatus(0); // 未开始 |
| | | } |
| | | |
| | | String vipIds = item.getVipIds(); |
| | | if (StringUtils.isNotEmpty(vipIds)){ |
| | | String[] vipIdArr = vipIds.split(","); |
| | | if (vipIdArr.length == 7){ |
| | | item.setVipName("全部"); |
| | | }else { |
| | | List<String> vipNameList = new ArrayList<>(); |
| | | for (String vipId : vipIdArr) { |
| | | String vipName = vipSettingService.getById(Long.parseLong(vipId)).getVipName(); |
| | | vipNameList.add(vipName); |
| | | } |
| | | item.setVipName(String.join(",", vipNameList)); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | return R.ok(page); |
| | | } |