| | |
| | | package com.dsh.activity.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.BodySideAppointment; |
| | | import com.dsh.activity.entity.IntroduceRewards; |
| | | import com.dsh.activity.feignclient.model.IntrduceOfUserRequest; |
| | | import com.dsh.activity.feignclient.model.PurchaseRecordVo; |
| | | import com.dsh.activity.feignclient.other.model.Store; |
| | | import com.dsh.activity.model.*; |
| | | import com.dsh.activity.service.IntroduceRewardsService; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api |
| | | @CrossOrigin |
| | |
| | | @RequestMapping("") |
| | | public class IntroduceRewardsController { |
| | | |
| | | |
| | | @Autowired |
| | | private IntroduceRewardsService idrService; |
| | | |
| | | private final SimpleDateFormat mat = new SimpleDateFormat("MM-dd HH:mm"); |
| | | /** |
| | | * 获取所有体测预约记录 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/introduce/listAll") |
| | | public List<IntroduceVO> listAll(@RequestBody IntroduceQuery query){ |
| | | |
| | | return null; |
| | | } |
| | | /** |
| | | * 增加/修改介绍有礼记录 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/introduce/addIntroduce") |
| | | public Object addIntroduce(@RequestBody IntroduceRewards introduceRewards){ |
| | | if (introduceRewards.getId()!=null){ |
| | | return idrService.updateById(introduceRewards); |
| | | }else { |
| | | return idrService.save(introduceRewards); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上/下架介绍有礼 type = 1上架 type=2下架 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/introduce/changeState") |
| | | public Object changeState(@RequestBody IntroduceChangeStateDTO dto){ |
| | | return idrService.changeState(dto); |
| | | } |
| | | |
| | | @PostMapping("/base/introduce/useOfRewards") |
| | | public List<PurchaseRecordVo> queryAppUsersofIntroduce(@RequestBody IntrduceOfUserRequest request){ |
| | |
| | | List<IntroduceRewards> list = idrService.list(new QueryWrapper<IntroduceRewards>() |
| | | .ge("startTime",request.getStartTime()) |
| | | .lt("endTime",request.getEndTime())); |
| | | IntroduceRewards introduceRewards = list.get(0); |
| | | request.getUserIds().forEach( userId -> { |
| | | PurchaseRecordVo recordVo = new PurchaseRecordVo(); |
| | | recordVo.setPurchaseAmount("+"+introduceRewards.getGiveClass()); |
| | | recordVo.setPurchaseType("介绍有礼"); |
| | | recordVos.add(recordVo); |
| | | } ); |
| | | if (request.getUserIds().size() > 0 && list.size() > 0){ |
| | | IntroduceRewards introduceRewards = list.get(0); |
| | | request.getUserIds().forEach( userId -> { |
| | | PurchaseRecordVo recordVo = new PurchaseRecordVo(); |
| | | recordVo.setPurchaseAmount("+"+introduceRewards.getGiveClass()); |
| | | recordVo.setPurchaseType("介绍有礼"); |
| | | recordVos.add(recordVo); |
| | | } ); |
| | | } |
| | | return recordVos; |
| | | } |
| | | |
| | | @PostMapping("/base/introduce/getGiftList") |
| | | public Integer getGiftList(@RequestBody String cityCode){ |
| | | List<IntroduceRewards> list = idrService.list(new LambdaQueryWrapper<IntroduceRewards>().eq(IntroduceRewards::getCityCode,cityCode).ge(IntroduceRewards::getStartTime,new Date()).le(IntroduceRewards::getEndTime,new Date())); |
| | | int sum = list.stream().mapToInt(IntroduceRewards::getGiveClass).sum(); |
| | | return sum; |
| | | } |
| | | |
| | | } |