Commit af01395a by 吕明尚

增加次卡的判断

parent 4c543c47
...@@ -35,8 +35,8 @@ public class ConsumerSecondaryCardController extends BaseController { ...@@ -35,8 +35,8 @@ public class ConsumerSecondaryCardController extends BaseController {
} }
@GetMapping("/query") @GetMapping("/query")
public AjaxResult selectByConsumerId() { public AjaxResult selectByConsumerId(Long packId) {
return success(consumerSecondaryCardService.selectByConsumerId()); return success(consumerSecondaryCardService.selectByPaclId(packId));
} }
} }
...@@ -19,4 +19,8 @@ public class ConsumerSecondaryCardVo extends ConsumerSecondaryCard { ...@@ -19,4 +19,8 @@ public class ConsumerSecondaryCardVo extends ConsumerSecondaryCard {
private String confName; private String confName;
//次卡金额 //次卡金额
private BigDecimal confAmount; private BigDecimal confAmount;
//是否适用当前套餐
private Integer isUse;
//原因
private String reason;
} }
...@@ -54,4 +54,12 @@ public class OrderComputedPriceRequest { ...@@ -54,4 +54,12 @@ public class OrderComputedPriceRequest {
@ApiModelProperty(value = "标签id") @ApiModelProperty(value = "标签id")
private Long roomLabelId; private Long roomLabelId;
//次卡ID
@ApiModelProperty(value = "次卡ID")
private Long secondaryCardId;
//月卡ID
@ApiModelProperty(value = "月卡ID")
private Long monthlyCardId;
} }
...@@ -62,4 +62,6 @@ public interface ConsumerSecondaryCardService extends IService<ConsumerSecondary ...@@ -62,4 +62,6 @@ public interface ConsumerSecondaryCardService extends IService<ConsumerSecondary
public int deleteConsumerSecondaryCardById(Long id); public int deleteConsumerSecondaryCardById(Long id);
List<ConsumerSecondaryCardVo> selectByConsumerId(); List<ConsumerSecondaryCardVo> selectByConsumerId();
List<ConsumerSecondaryCardVo> selectByPaclId(Long packId);
} }
package share.system.service.impl; package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import share.system.domain.ConsumerSecondaryCard; import share.system.domain.ConsumerSecondaryCard;
import share.system.domain.SConsumer; import share.system.domain.SConsumer;
import share.system.domain.SPack;
import share.system.domain.vo.ConsumerSecondaryCardVo; import share.system.domain.vo.ConsumerSecondaryCardVo;
import share.system.mapper.ConsumerSecondaryCardMapper; import share.system.mapper.ConsumerSecondaryCardMapper;
import share.system.service.ConsumerSecondaryCardService; import share.system.service.ConsumerSecondaryCardService;
import share.system.service.IPackService;
import share.system.service.SConsumerService; import share.system.service.SConsumerService;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* 用户次卡Service业务层处理 * 用户次卡Service业务层处理
...@@ -25,6 +33,8 @@ public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecond ...@@ -25,6 +33,8 @@ public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecond
private ConsumerSecondaryCardMapper consumerSecondaryCardMapper; private ConsumerSecondaryCardMapper consumerSecondaryCardMapper;
@Autowired @Autowired
private SConsumerService sConsumerService; private SConsumerService sConsumerService;
@Autowired
private IPackService packService;
/** /**
* 查询用户次卡 * 查询用户次卡
...@@ -97,8 +107,32 @@ public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecond ...@@ -97,8 +107,32 @@ public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecond
@Override @Override
public List<ConsumerSecondaryCardVo> selectByConsumerId() { public List<ConsumerSecondaryCardVo> selectByConsumerId() {
SConsumer info = sConsumerService.getInfo(); SConsumer info = sConsumerService.getInfo();
if (ObjectUtil.isNull(info)) {
throw new BaseException("您的登录已过期,请先登录");
}
ConsumerSecondaryCardVo vo = new ConsumerSecondaryCardVo(); ConsumerSecondaryCardVo vo = new ConsumerSecondaryCardVo();
vo.setConsumerId(info.getId()); vo.setConsumerId(info.getId());
return consumerSecondaryCardMapper.selectByConsumerId(vo); return consumerSecondaryCardMapper.selectByConsumerId(vo);
} }
@Override
public List<ConsumerSecondaryCardVo> selectByPaclId(Long packId) {
SConsumer info = sConsumerService.getInfo();
if (ObjectUtil.isNull(info)) {
throw new BaseException("您的登录已过期,请先登录");
}
Map<Long, SPack> packMap = packService.list().stream().collect(Collectors.toMap(SPack::getId, Function.identity()));
ConsumerSecondaryCardVo vo = new ConsumerSecondaryCardVo();
vo.setConsumerId(info.getId());
List<ConsumerSecondaryCardVo> consumerSecondaryCardVos = consumerSecondaryCardMapper.selectByConsumerId(vo);
consumerSecondaryCardVos.stream().forEach(item -> {
if (item.getPackId().equals(packId)) {
item.setIsUse(YesNoEnum.yes.getIndex());
} else {
item.setIsUse(YesNoEnum.no.getIndex());
item.setReason("当前次卡适用于" + packMap.get(item.getPackId()).getName() + "套餐" + ",不适用于" + packMap.get(packId).getName() + "套餐");
}
});
return consumerSecondaryCardVos;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment