RechargeRightsServiceImpl.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.kym.service.impl;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.yulichang.base.MPJBaseServiceImpl;
  4. import com.github.yulichang.toolkit.JoinWrappers;
  5. import com.github.yulichang.wrapper.MPJLambdaWrapper;
  6. import com.kym.common.exception.BusinessException;
  7. import com.kym.common.utils.CommUtil;
  8. import com.kym.entity.ActivityStation;
  9. import com.kym.entity.Coupon;
  10. import com.kym.entity.RechargeRights;
  11. import com.kym.entity.queryParams.RightsQueryParam;
  12. import com.kym.entity.common.PageBean;
  13. import com.kym.entity.common.PageParams;
  14. import com.kym.mapper.RechargeRightsMapper;
  15. import com.kym.service.RechargeRightsService;
  16. import org.springframework.stereotype.Service;
  17. import java.util.List;
  18. /**
  19. * <p>
  20. * 充值权益表 服务实现类
  21. * </p>
  22. *
  23. * @author skyline
  24. * @since 2023-10-18
  25. */
  26. @Service
  27. public class RechargeRightsServiceImpl extends MPJBaseServiceImpl<RechargeRightsMapper, RechargeRights> implements RechargeRightsService {
  28. /**
  29. * 所选站点可以参与的充值权益卡活动
  30. *
  31. * @param params
  32. * @return
  33. */
  34. @Override
  35. public PageBean<RechargeRights> listAvailableRechargeRights(RightsQueryParam params) {
  36. if (CommUtil.isEmptyOrNull(params.getStationId())) {
  37. throw new BusinessException("请选择充电站点");
  38. }
  39. PageHelper.startPage(params.getPageNum(), params.getPageSize());
  40. MPJLambdaWrapper<RechargeRights> wrapper = JoinWrappers.lambda(RechargeRights.class)
  41. .selectAll(RechargeRights.class)
  42. .leftJoin(ActivityStation.class, ActivityStation::getActivityId, RechargeRights::getActivityId)
  43. .eq(RechargeRights::getStatus, Coupon.STATUS_进行中)
  44. .eq(ActivityStation::getStationId, params.getStationId());
  45. List<RechargeRights> res = this.selectJoinList(RechargeRights.class, wrapper);
  46. return new PageBean<>(res);
  47. }
  48. @Override
  49. public PageBean<RechargeRights> listRechargeRight(PageParams pageParams, String activityId) {
  50. PageHelper.startPage(pageParams.getPageNum(), pageParams.getPageSize());
  51. var list = lambdaQuery().eq(!CommUtil.isEmptyOrNull(activityId), RechargeRights::getActivityId, activityId).orderByAsc(RechargeRights::getEndTime).list();
  52. return new PageBean<>(list);
  53. }
  54. }