| | |
| | | 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; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | |
| | | @Resource |
| | | private OrderActivityInfoService orderActivityInfoService; |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | |
| | | |
| | | /** |
| | |
| | | @PostMapping("/save") |
| | | @ApiOperation(value = "订单优惠活动-添加活动", tags = {"管理后台-活动管理"}) |
| | | public R<Void> saveActivityConfig(@RequestBody OrderActivityInfo orderActivityInfo){ |
| | | orderActivityInfo.setIsShelf(0); |
| | | orderActivityInfoService.save(orderActivityInfo); |
| | | return R.ok(); |
| | | } |
| | |
| | | * 修改活动 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperation(value = "修改活动", tags = {"管理后台-活动管理-订单优惠活动"}) |
| | | @ApiOperation(value = "修改活动", tags = {"管理后台-活动管理"}) |
| | | public R<Void> updateActivityConfig(@RequestBody OrderActivityInfo orderActivityInfo){ |
| | | orderActivityInfo.setId(Long.valueOf(orderActivityInfo.getIdStr())); |
| | | orderActivityInfoService.updateById(orderActivityInfo); |
| | | return R.ok(); |
| | | } |
| | |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | OrderActivityInfo orderActivityInfo){ |
| | | |
| | | return R.ok(orderActivityInfoService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<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() == 0, OrderActivityInfo::getStartTime, orderActivityInfo.getStartTime()) |
| | | .ge(orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, orderActivityInfo.getStartTime()) |
| | | .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf()))); |
| | | .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())); |
| | | page.getRecords().forEach(item -> { |
| | | LocalDateTime startTime = item.getStartTime(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime endTime = item.getEndTime(); |
| | | if (endTime.isBefore(now)){ |
| | | item.setStatus(2); //已结束 |
| | | }else if (startTime.isBefore(now)){ |
| | | item.setStatus(1); // 已开始 |
| | | }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); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("/getDetailById") |
| | | @ApiOperation(value = "订单优惠活动-获取活动详情", tags = {"管理后台-活动管理"}) |
| | | public R<OrderActivityInfo> getDetailById(@RequestParam("id") Long id){ |
| | | return R.ok(orderActivityInfoService.getById(id)); |
| | | public R<OrderActivityInfo> getDetailById(@RequestParam("id") String id){ |
| | | return R.ok(orderActivityInfoService.getById(Long.parseLong(id))); |
| | | } |
| | | |
| | | |