Commit 990b5277 by 吕明尚

修改次卡推荐接口

parent 9d554fa7
package share.web.controller.system;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.core.page.TableDataInfo;
import share.common.utils.JsonConvertUtil;
import share.system.domain.vo.ConsumerMonthlyCardVo;
import share.system.request.MonthlyCardRequest;
import share.system.response.MonthlyCardResponse;
import share.system.service.ConsumerMonthlyCardService;
import java.util.List;
......@@ -18,6 +22,7 @@ import java.util.List;
* @author wuwenlong
* @date 2024-08-27
*/
@Slf4j
@RestController
@RequestMapping("/consumerMonthlyCard")
public class ConsumerMonthlyCardController extends BaseController {
......@@ -43,7 +48,10 @@ public class ConsumerMonthlyCardController extends BaseController {
//查询可用卡类
@PostMapping("/queryCardType")
public AjaxResult queryCardType(@RequestBody @Validated MonthlyCardRequest monthlyCardRequest) {
return success(consumerMonthlyCardService.queryCardType(monthlyCardRequest));
public R<MonthlyCardResponse> queryCardType(@RequestBody @Validated MonthlyCardRequest monthlyCardRequest) {
log.debug("ConsumerMonthlyCardController method queryCardType 入参 {}", JsonConvertUtil.write2JsonStr(monthlyCardRequest));
MonthlyCardResponse monthlyCardResponse = consumerMonthlyCardService.queryCardType(monthlyCardRequest);
log.debug("ConsumerMonthlyCardController method queryCardType 出参 {}", JsonConvertUtil.write2JsonStr(monthlyCardResponse));
return R.ok(monthlyCardResponse);
}
}
package share.system.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import share.system.domain.ConsumerMonthlyCard;
import share.system.domain.ConsumerSecondaryCard;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "MonthlyCardResponse", description = "卡包响应对象")
public class MonthlyCardResponse {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "月卡")
private List<ConsumerMonthlyCard> consumerMonthlyCard;
@ApiModelProperty(value = "次卡")
private List<ConsumerSecondaryCard> consumerSecondaryCard;
}
......@@ -4,10 +4,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.ConsumerMonthlyCard;
import share.system.domain.vo.ConsumerMonthlyCardVo;
import share.system.request.MonthlyCardRequest;
import share.system.response.MonthlyCardResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 用户月卡Service接口
......@@ -66,7 +66,7 @@ public interface ConsumerMonthlyCardService extends IService<ConsumerMonthlyCard
List<ConsumerMonthlyCardVo> selectByConsumerId();
Map<String, List<Object>> queryCardType(MonthlyCardRequest monthlyCardRequest);
MonthlyCardResponse queryCardType(MonthlyCardRequest monthlyCardRequest);
List<ConsumerMonthlyCard> confNameByIds(ArrayList<Long> longs);
}
......@@ -14,10 +14,13 @@ import share.system.domain.*;
import share.system.domain.vo.ConsumerMonthlyCardVo;
import share.system.mapper.ConsumerMonthlyCardMapper;
import share.system.request.MonthlyCardRequest;
import share.system.response.MonthlyCardResponse;
import share.system.service.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* 用户月卡Service业务层处理
......@@ -121,13 +124,13 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
}
@Override
public Map<String, List<Object>> queryCardType(MonthlyCardRequest monthlyCardRequest) {
public MonthlyCardResponse queryCardType(MonthlyCardRequest monthlyCardRequest) {
SConsumer user = sConsumerService.getInfo();
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()).eq(ConsumerMember::getIsRights
, YesNoEnum.yes.getIndex()));
ConsumerMonthlyCard consumerMonthlyCard = null;
List<ConsumerSecondaryCard> consumerSecondaryCard = null;
Map<String, List<Object>> map = new HashMap<>();
MonthlyCardResponse map = new MonthlyCardResponse();
List<ConsumerMonthlyCard> consumerMonthlyCardList = new ArrayList<>();
List<ConsumerSecondaryCard> consumerSecondaryCardList = new ArrayList<>();
......@@ -146,7 +149,7 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
//标签没绑定套餐
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && new BigDecimal(label.getDuration()).compareTo(BigDecimal.ONE) >= 0) {
consumerMonthlyCardList.add(consumerMonthlyCard);
map.put("consumerMonthlyCard", Collections.singletonList(consumerMonthlyCardList));
map.setConsumerMonthlyCard(consumerMonthlyCardList);
}
if (CollectionUtil.isNotEmpty(consumerSecondaryCard)) {
//过滤时长相等的
......@@ -155,7 +158,7 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
if (Objects.equals(item.getSingleDuration(), Integer.valueOf(label.getDuration()))
&& item.getSingleAmount().compareTo(new BigDecimal(label.getDuration()).multiply(room.getPrice())) >= 0) {
consumerSecondaryCardList.add(item);
map.put("consumerSecondaryCard", Collections.singletonList(consumerSecondaryCardList));
map.setConsumerSecondaryCard(consumerSecondaryCardList);
}
}
......@@ -172,20 +175,20 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
if (Objects.equals(item.getSingleDuration(), Integer.valueOf(byId.getDuration()))
&& item.getSingleAmount().compareTo(byId.getPrice()) >= 0) {
consumerSecondaryCardList.add(item);
map.put("consumerSecondaryCard", Collections.singletonList(consumerSecondaryCardList));
map.setConsumerSecondaryCard(consumerSecondaryCardList);
}
});
}
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && consumerMonthlyCard.getFreeDuration().compareTo(new BigDecimal(byId.getDuration())) >= 0) {
consumerMonthlyCardList.add(consumerMonthlyCard);
map.put("consumerMonthlyCard", Collections.singletonList(consumerMonthlyCardList));
map.setConsumerMonthlyCard(consumerMonthlyCardList);
}
return map;
//标签绑定了套餐,套餐没开启,小时
} else {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && new BigDecimal(label.getDuration()).compareTo(BigDecimal.ONE) >= 0) {
consumerMonthlyCardList.add(consumerMonthlyCard);
map.put("consumerMonthlyCard", Collections.singletonList(consumerMonthlyCardList));
map.setConsumerMonthlyCard(consumerMonthlyCardList);
}
if (CollectionUtil.isNotEmpty(consumerSecondaryCard)) {
//过滤时长相等的
......@@ -194,7 +197,7 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
if (Objects.equals(item.getSingleDuration(), Integer.valueOf(label.getDuration()))
&& item.getSingleAmount().compareTo(new BigDecimal(label.getDuration()).multiply(room.getPrice())) >= 0) {
consumerSecondaryCardList.add(item);
map.put("consumerSecondaryCard", Collections.singletonList(consumerSecondaryCardList));
map.setConsumerSecondaryCard(consumerSecondaryCardList);
}
}
});
......@@ -211,18 +214,18 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
if (Objects.equals(item.getSingleDuration(), Integer.valueOf(pack.getDuration()))
&& item.getSingleAmount().compareTo(pack.getPrice()) >= 0) {
consumerSecondaryCardList.add(item);
map.put("consumerSecondaryCard", Collections.singletonList(consumerSecondaryCardList));
map.setConsumerSecondaryCard(consumerSecondaryCardList);
}
});
}
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && consumerMonthlyCard.getFreeDuration().compareTo(new BigDecimal(pack.getDuration())) >= 0) {
consumerMonthlyCardList.add(consumerMonthlyCard);
map.put("consumerMonthlyCard", Collections.singletonList(consumerMonthlyCardList));
map.setConsumerMonthlyCard(consumerMonthlyCardList);
}
return map;
}
}
return new HashMap<>();
return new MonthlyCardResponse();
}
@Override
......
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