| | |
| | | package com.dsh.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.account.entity.CoachType; |
| | | import com.dsh.account.entity.RechargeRecords; |
| | | import com.dsh.account.entity.TAppUser; |
| | | import com.dsh.account.entity.VipPayment; |
| | | import com.dsh.account.model.IncomeQuery; |
| | | import com.dsh.account.model.dto.VipPaymentDto; |
| | | import com.dsh.account.model.dto.VipRefundDto; |
| | | import com.dsh.account.model.query.RechargeRecordsQuery; |
| | | import com.dsh.account.model.query.coachQuery.CoachQuery; |
| | | import com.dsh.account.model.vo.CoachSerchVO; |
| | | import com.dsh.account.model.vo.RechargeRecordsVO; |
| | | import com.dsh.account.model.vo.VipPaymentListVO; |
| | | import com.dsh.account.service.*; |
| | | import net.bytebuddy.asm.Advice; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 充值记录控制器 |
| | |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("/finance/rechargeList") |
| | | public List<RechargeRecordsVO> rechargeList(@RequestBody RechargeRecordsQuery query){ |
| | | public List<RechargeRecordsVO> rechargeList(@RequestBody RechargeRecordsQuery query) { |
| | | List<RechargeRecordsVO> rechargeRecordsVOS = rechargeRecordsService.rechargeList(query); |
| | | for (RechargeRecordsVO rechargeRecordsVO : rechargeRecordsVOS) { |
| | | TAppUser byId = appUserService.getById(rechargeRecordsVO.getAppUserId()); |
| | | if (byId==null)continue; |
| | | if (byId == null) continue; |
| | | Date vipEndTime = byId.getVipEndTime(); |
| | | if (vipEndTime==null){ |
| | | if (vipEndTime == null) { |
| | | rechargeRecordsVO.setType(2); |
| | | continue; |
| | | } |
| | | if (rechargeRecordsVO.getPayTime().after(vipEndTime)){ |
| | | if (rechargeRecordsVO.getPayTime().after(vipEndTime)) { |
| | | rechargeRecordsVO.setType(2); |
| | | }else{ |
| | | } else { |
| | | rechargeRecordsVO.setType(1); |
| | | } |
| | | } |
| | | return rechargeRecordsVOS; |
| | | return rechargeRecordsVOS; |
| | | } |
| | | |
| | | /** |
| | | * 数据统计-充值记录列表数据 |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("/finance/rechargeList1") |
| | | public List<RechargeRecords> rechargeList1(@RequestBody RechargeRecordsQuery query){ |
| | | public List<RechargeRecords> rechargeList1(@RequestBody RechargeRecordsQuery query) { |
| | | List<RechargeRecords> payStatus = rechargeRecordsService.list(new QueryWrapper<RechargeRecords>().eq("payStatus", 2)); |
| | | for (RechargeRecords list : payStatus) { |
| | | TAppUser byId = appUserService.getById(list.getAppUserId()); |
| | |
| | | } |
| | | return payStatus; |
| | | } |
| | | |
| | | /** |
| | | * 加入会员列表数据 |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("/finance/vipPaymentList") |
| | | public List<VipPayment> registrationList(@RequestBody IncomeQuery query){ |
| | | public List<VipPayment> registrationList(@RequestBody IncomeQuery query) { |
| | | return rechargeRecordsService.listAll(query); |
| | | } |
| | | /** |
| | | * 退费 |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("/finance/refund") |
| | | public String refund(@RequestBody VipRefundDto vipRefundDto) throws ParseException { |
| | | VipPayment vipPayment = vipPaymentService.getById(vipRefundDto.getId()); |
| | | if (vipPayment==null){ |
| | | return "500"; |
| | | } |
| | | Integer appUserId = vipPayment.getAppUserId(); |
| | | TAppUser appUser = appUserService.getById(appUserId); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date parse = simpleDateFormat.parse(vipRefundDto.getEndTime() + " 00:00:00"); |
| | | appUser.setVipEndTime( parse); |
| | | if (parse.before(new Date())){ |
| | | appUser.setIsVip(0); |
| | | } |
| | | appUserService.updateById(appUser); |
| | | vipPayment.setState(3); |
| | | vipPaymentService.updateById(vipPayment); |
| | | return "200"; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/finance/vipPayment") |
| | | List<VipPaymentListVO> vipPayment(@RequestBody VipPaymentDto vipPaymentDto){ |
| | | List<VipPaymentListVO> vipPaymentListVOS = new ArrayList<>(); |
| | | |
| | | List<Integer> payStatus = new ArrayList<>(); |
| | | payStatus.add(2); |
| | | LambdaQueryWrapper<VipPayment> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | vipPaymentLambdaQueryWrapper.in(vipPaymentDto.getUserIds()!=null&&!vipPaymentDto.getUserIds().isEmpty(),VipPayment::getAppUserId, vipPaymentDto.getUserIds()); |
| | | vipPaymentLambdaQueryWrapper.in(vipPaymentDto.getVipIds()!=null&&!vipPaymentDto.getVipIds().isEmpty(),VipPayment::getVipId, vipPaymentDto.getVipIds()); |
| | | vipPaymentLambdaQueryWrapper.in(VipPayment::getPayStatus,payStatus); |
| | | vipPaymentLambdaQueryWrapper.ge(StringUtils.hasLength(vipPaymentDto.getStartTime()), VipPayment::getInsertTime, vipPaymentDto.getStartTime()); |
| | | vipPaymentLambdaQueryWrapper.le(StringUtils.hasLength(vipPaymentDto.getEndTime()), VipPayment::getInsertTime, vipPaymentDto.getEndTime()); |
| | | if (vipPaymentDto.getIsRefund()!=null&&vipPaymentDto.getIsRefund()==1){ |
| | | payStatus.add(3); |
| | | } |
| | | List<VipPayment> list = vipPaymentService.list(vipPaymentLambdaQueryWrapper); |
| | | // 使用 Stream + 手动拷贝提升性能和可读性(或使用 MapStruct) |
| | | vipPaymentListVOS = list.stream().map(vipDetail -> { |
| | | VipPaymentListVO vo = new VipPaymentListVO(); |
| | | BeanUtils.copyProperties(vipDetail,vo); // 注意参数顺序是否正确 |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | for (VipPaymentListVO vipPaymentListVO : vipPaymentListVOS) { |
| | | if (vipPaymentListVO.getPayStatus()==2){ |
| | | vipPaymentListVO.setIsRefund(0); |
| | | }else { |
| | | vipPaymentListVO.setIsRefund(1); |
| | | } |
| | | } |
| | | return vipPaymentListVOS; |
| | | } |
| | | } |