Commit af01395a by 吕明尚

增加次卡的判断

parent 4c543c47
......@@ -35,8 +35,8 @@ public class ConsumerSecondaryCardController extends BaseController {
}
@GetMapping("/query")
public AjaxResult selectByConsumerId() {
return success(consumerSecondaryCardService.selectByConsumerId());
public AjaxResult selectByConsumerId(Long packId) {
return success(consumerSecondaryCardService.selectByPaclId(packId));
}
}
......@@ -19,4 +19,8 @@ public class ConsumerSecondaryCardVo extends ConsumerSecondaryCard {
private String confName;
//次卡金额
private BigDecimal confAmount;
//是否适用当前套餐
private Integer isUse;
//原因
private String reason;
}
......@@ -54,4 +54,12 @@ public class OrderComputedPriceRequest {
@ApiModelProperty(value = "标签id")
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
public int deleteConsumerSecondaryCardById(Long id);
List<ConsumerSecondaryCardVo> selectByConsumerId();
List<ConsumerSecondaryCardVo> selectByPaclId(Long packId);
}
package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
import share.common.utils.DateUtils;
import share.system.domain.ConsumerSecondaryCard;
import share.system.domain.SConsumer;
import share.system.domain.SPack;
import share.system.domain.vo.ConsumerSecondaryCardVo;
import share.system.mapper.ConsumerSecondaryCardMapper;
import share.system.service.ConsumerSecondaryCardService;
import share.system.service.IPackService;
import share.system.service.SConsumerService;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 用户次卡Service业务层处理
......@@ -25,6 +33,8 @@ public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecond
private ConsumerSecondaryCardMapper consumerSecondaryCardMapper;
@Autowired
private SConsumerService sConsumerService;
@Autowired
private IPackService packService;
/**
* 查询用户次卡
......@@ -97,8 +107,32 @@ public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecond
@Override
public List<ConsumerSecondaryCardVo> selectByConsumerId() {
SConsumer info = sConsumerService.getInfo();
if (ObjectUtil.isNull(info)) {
throw new BaseException("您的登录已过期,请先登录");
}
ConsumerSecondaryCardVo vo = new ConsumerSecondaryCardVo();
vo.setConsumerId(info.getId());
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