| | |
| | | return R.ok(one); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加活动 |
| | | */ |
| | |
| | | @ApiOperation(value = "订单优惠活动-添加活动", tags = {"管理后台-活动管理"}) |
| | | public R<Void> saveActivityConfig(@RequestBody OrderActivityInfo orderActivityInfo){ |
| | | orderActivityInfo.setIsShelf(0); |
| | | if (org.springframework.util.StringUtils.hasLength(orderActivityInfo.getVipIds())){ |
| | | List<String> vipIds = Arrays.asList(orderActivityInfo.getVipIds().split(",")); |
| | | List<OrderActivityInfo> list = orderActivityInfoService.lambdaQuery() |
| | | .le(OrderActivityInfo::getStartTime, orderActivityInfo.getStartTime()) |
| | | .or() |
| | | .ge(OrderActivityInfo::getEndTime, orderActivityInfo.getEndTime()).list(); |
| | | if (!list.isEmpty()){ |
| | | for (OrderActivityInfo activityInfo : list) { |
| | | List<String> vips = Arrays.asList(activityInfo.getVipIds().split(",")); |
| | | vipIds.retainAll(vips); |
| | | if (!vipIds.isEmpty()){ |
| | | StringBuilder message = new StringBuilder(); |
| | | List<String> collect = vips.stream().sorted().collect(Collectors.toList()); |
| | | for (String s : collect) { |
| | | switch (s){ |
| | | case "1": |
| | | message.append("普通会员,"); |
| | | break; |
| | | case "2": |
| | | message.append("黄金会员,"); |
| | | break; |
| | | case "3": |
| | | message.append("钻石会员,"); |
| | | break; |
| | | case "4": |
| | | message.append("准代理,"); |
| | | break; |
| | | case "5": |
| | | message.append("代理,"); |
| | | break; |
| | | case "6": |
| | | message.append("总代,"); |
| | | break; |
| | | case "7": |
| | | message.append("合伙人,"); |
| | | break; |
| | | } |
| | | } |
| | | StringBuilder res = message.deleteCharAt(message.length() - 1); |
| | | return R.fail(res+"在当前活动时间已有订单优惠"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderActivityInfoService.save(orderActivityInfo); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "修改活动", tags = {"管理后台-活动管理"}) |
| | | public R<Void> updateActivityConfig(@RequestBody OrderActivityInfo orderActivityInfo){ |
| | | orderActivityInfo.setId(Long.valueOf(orderActivityInfo.getIdStr())); |
| | | if (org.springframework.util.StringUtils.hasLength(orderActivityInfo.getVipIds())){ |
| | | List<String> vipIds = Arrays.asList(orderActivityInfo.getVipIds().split(",")); |
| | | List<OrderActivityInfo> list = orderActivityInfoService.lambdaQuery() |
| | | .le(OrderActivityInfo::getStartTime, orderActivityInfo.getStartTime()) |
| | | .or() |
| | | .ge(OrderActivityInfo::getEndTime, orderActivityInfo.getEndTime()).list(); |
| | | if (!list.isEmpty()){ |
| | | for (OrderActivityInfo activityInfo : list) { |
| | | List<String> vips = Arrays.asList(activityInfo.getVipIds().split(",")); |
| | | vipIds.retainAll(vips); |
| | | if (!vipIds.isEmpty()){ |
| | | StringBuilder message = new StringBuilder(); |
| | | List<String> collect = vips.stream().sorted().collect(Collectors.toList()); |
| | | for (String s : collect) { |
| | | switch (s){ |
| | | case "1": |
| | | message.append("普通会员,"); |
| | | break; |
| | | case "2": |
| | | message.append("黄金会员,"); |
| | | break; |
| | | case "3": |
| | | message.append("钻石会员,"); |
| | | break; |
| | | case "4": |
| | | message.append("准代理,"); |
| | | break; |
| | | case "5": |
| | | message.append("代理,"); |
| | | break; |
| | | case "6": |
| | | message.append("总代,"); |
| | | break; |
| | | case "7": |
| | | message.append("合伙人,"); |
| | | break; |
| | | } |
| | | } |
| | | StringBuilder res = message.deleteCharAt(message.length() - 1); |
| | | return R.fail(res+"在当前活动时间已有订单优惠"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderActivityInfoService.updateById(orderActivityInfo); |
| | | return R.ok(); |
| | | } |
| | |
| | | OrderActivityInfo 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()) |
| | | .like(orderActivityInfo.getId() != null, OrderActivityInfo::getId, orderActivityInfo.getId()) |
| | | .like(StringUtils.isNotEmpty(orderActivityInfo.getActivityName()), OrderActivityInfo::getActivityName, orderActivityInfo.getActivityName()) |
| | | .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)); |
| | | .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf()).orderByDesc(OrderActivityInfo::getCreateTime) |
| | | .orderByDesc(OrderActivityInfo::getCreateTime)) |
| | | ; |
| | | page.getRecords().forEach(item -> { |
| | | LocalDateTime startTime = item.getStartTime(); |
| | | LocalDateTime now = LocalDateTime.now(); |