| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | 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.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.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.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | private OrderClient orderClient; |
| | | @Autowired |
| | | private OtherClient otherClient; |
| | | @Autowired |
| | | private VipClient vipClient; |
| | | @Autowired |
| | | private ChargingPileClient chargingPileClient; |
| | | @Autowired |
| | | private ChargingOrderClient chargingOrderClient; |
| | | @Autowired |
| | | private TAppUserVipDetailService tAppUserVipDetailService; |
| | | |
| | | @Override |
| | | public PageInfo<ExchangeRecordVO> pagelist(ExchangeRecordGoodsQuery dto) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | return pageInfo; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private TAppUserMapper tAppUserMapper; |
| | | @Override |
| | | public PageInfo<CouponListVOVO> couponList(CouponListDto dto) { |
| | | // todo token获取用户id |
| | | Long userId = 11L; |
| | | dto.setUserId(userId); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | PageInfo<CouponListVOVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<CouponListVOVO> list = this.baseMapper.couponList(pageInfo,dto.getUserId()); |
| | | TAppUser tAppUser = tAppUserMapper.selectById(dto.getUserId()); |
| | | Integer isVip = 0;// 是否能享受会员折扣 |
| | | if (tAppUser.getVipEndTime() == null){ |
| | | // 不是会员 |
| | | }else { |
| | | // 判断会员有没有过期 |
| | | if (tAppUser.getVipEndTime().isAfter(java.time.LocalDateTime.now())){ |
| | | // 没过期 判断用户本月会员充电折扣次数是否还有剩余 |
| | | TAppUserVipDetail tAppUserVipDetail = tAppUserVipDetailService.list(new LambdaQueryWrapper<TAppUserVipDetail>() |
| | | .orderByDesc(TAppUserVipDetail::getStartTime)).get(0); |
| | | LocalDateTime startTime = tAppUserVipDetail.getStartTime(); |
| | | LocalDateTime endTime = tAppUserVipDetail.getEndTime(); |
| | | TChargingCountQuery tChargingCountQuery = new TChargingCountQuery(); |
| | | tChargingCountQuery.setStartTime(startTime); |
| | | tChargingCountQuery.setEndTime(endTime); |
| | | tChargingCountQuery.setUserId(dto.getUserId()); |
| | | // 当月已享受会员折扣充电次数 |
| | | Integer data = chargingOrderClient.getChargingCount(tChargingCountQuery).getData(); |
| | | // 查询用户当前会员每月享受折扣次数和折扣比例是多少 |
| | | Integer vipId = tAppUser.getVipId(); |
| | | TVip data1 = vipClient.getInfo1(vipId).getData(); |
| | | Integer discountTimes = data1.getDiscountTimes(); |
| | | if (data>=discountTimes){ |
| | | // 不能再享受会员折扣 |
| | | }else{ |
| | | isVip = 1; |
| | | } |
| | | } |
| | | } |
| | | for (CouponListVOVO couponListVOVO : list) { |
| | | couponListVOVO.setValidityTime("有效期:"+format.format(couponListVOVO.getCreateTime())+" - "+format.format(couponListVOVO.getEndTime())); |
| | | } |
| | | List<CouponListVOVO> data = otherClient.getCouponInfoByCouponIds(list).getData(); |
| | | for (CouponListVOVO datum : data) { |
| | | // 根据当前时间段和预付金额计算服务费 |
| | | |
| | | } |
| | | pageInfo.setRecords(data); |
| | | return pageInfo; |
| | | } |