| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.dto.CouponListDto; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.other.api.vo.CouponListVOVO; |
| | | import com.ruoyi.account.api.vo.ExchangeRecordVO; |
| | | import com.ruoyi.account.mapper.TAppCouponMapper; |
| | | import com.ruoyi.account.mapper.TAppUserMapper; |
| | | import com.ruoyi.account.service.TAppCouponService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.order.api.query.TChargingCountQuery; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | import java.math.BigInteger; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private ChargingOrderClient chargingOrderClient; |
| | | @Autowired |
| | | private TAppUserVipDetailService tAppUserVipDetailService; |
| | | @Autowired |
| | | private TAppUserMapper tAppUserMapper; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Override |
| | | public PageInfo<ExchangeRecordVO> pagelist(ExchangeRecordGoodsQuery dto) { |
| | | public List<ExchangeRecordVO> pagelist(ExchangeRecordGoodsQuery dto) { |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(1); |
| | | integers.add(2); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | PageInfo<ExchangeRecordVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<ExchangeRecordVO> list = this.baseMapper.pageList(pageInfo,dto); |
| | | QueryWrapper<TAppCoupon> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("coupon_id",dto.getCouponId()); |
| | | wrapper.in("ways_to_obtain",integers); |
| | | if (StringUtils.hasLength(dto.getPhone())){ |
| | | List<Long> collect = tAppUserMapper.selectList(new QueryWrapper<TAppUser>().like("phone", dto.getPhone())).stream() |
| | | .map(TAppUser::getId).collect(Collectors.toList()); |
| | | if(collect.isEmpty()){ |
| | | collect.add(-1L); |
| | | } |
| | | wrapper.in("app_user_id",collect); |
| | | } |
| | | if (dto.getStatus()!=null){ |
| | | wrapper.eq("status",dto.getStatus()); |
| | | } |
| | | List<TAppCoupon> tAppCoupons = this.baseMapper.selectList(wrapper); |
| | | List<ExchangeRecordVO> list = new ArrayList<>(); |
| | | // 订单ids |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (TAppCoupon tAppCoupon : tAppCoupons) { |
| | | ExchangeRecordVO exchangeRecordVO = new ExchangeRecordVO(); |
| | | BeanUtils.copyProperties(tAppCoupon,exchangeRecordVO); |
| | | list.add(exchangeRecordVO); |
| | | } |
| | | for (ExchangeRecordVO exchangeRecordVO : list) { |
| | | TAppUser tAppUser = tAppUserMapper.selectById(exchangeRecordVO.getAppUserId()); |
| | | if (tAppUser!=null)exchangeRecordVO.setPhone(tAppUser.getPhone()); |
| | | switch (exchangeRecordVO.getWaysToObtain()){ |
| | | case 1: |
| | | if (exchangeRecordVO.getOrderId()!=null){ |
| | | stringBuilder.append(exchangeRecordVO.getOrderId()).append(","); |
| | | if (exchangeRecordVO.getId()!=null){ |
| | | stringBuilder.append("-").append(exchangeRecordVO.getId()).append(","); |
| | | }else{ |
| | | stringBuilder.append("0").append(","); |
| | | } |
| | | break; |
| | | case 2: |
| | | if (exchangeRecordVO.getOrderId()!=null){ |
| | | stringBuilder.append("-").append(exchangeRecordVO.getOrderId()).append(","); |
| | | if (exchangeRecordVO.getId()!=null){ |
| | | stringBuilder.append(exchangeRecordVO.getId()).append(","); |
| | | }else{ |
| | | stringBuilder.append("-").append("0").append(","); |
| | | stringBuilder.append("0").append(","); |
| | | } |
| | | break; |
| | | } |
| | |
| | | exchangeRecordVO.setEndTime1(format.format(date)); |
| | | exchangeRecordVO.setCreateTime1(format.format(date1)); |
| | | if (exchangeRecordVO.getStatus()==1){ |
| | | if (exchangeRecordVO.getDelFlag() == 1){ |
| | | if (exchangeRecordVO.getDelFlag()){ |
| | | // 删除了 就是已取消状态 |
| | | exchangeRecordVO.setStatus(4); |
| | | }else{ |
| | |
| | | } |
| | | } |
| | | if (exchangeRecordVO.getStatus()==2){ |
| | | if (exchangeRecordVO.getDelFlag() == 1){ |
| | | if (exchangeRecordVO.getDelFlag()){ |
| | | // 删除了 就是已取消状态 |
| | | exchangeRecordVO.setStatus(4); |
| | | }else{ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 去除最后一个字符 |
| | | if (StringUtils.hasText(stringBuilder.toString())){ |
| | | String string = stringBuilder.deleteCharAt(stringBuilder.length() - 1).toString(); |
| | |
| | | list.get(i).setOrderId(data.get(i)); |
| | | } |
| | | } |
| | | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | return list; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private TAppUserMapper tAppUserMapper; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Override |
| | | public PageInfo<CouponListVOVO> couponList(CouponListDto dto) { |
| | | // todo token获取用户id |