Commit da0a78b0 by 吕明尚

Merge branch 'dev' into test

parents d9565acf efbc0c32
package share.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.page.TableDataInfo;
import share.system.domain.vo.ConsumerMonthlyCardVo;
import share.system.request.MonthlyCardRequest;
import share.system.service.ConsumerMonthlyCardService;
import java.util.List;
......@@ -39,4 +39,11 @@ public class ConsumerMonthlyCardController extends BaseController {
public AjaxResult selectByConsumerId() {
return success(consumerMonthlyCardService.selectByConsumerId());
}
//查询可用卡类
@PostMapping("/queryCardType")
public AjaxResult queryCardType(@RequestBody @Validated MonthlyCardRequest monthlyCardRequest) {
return success(consumerMonthlyCardService.queryCardType(monthlyCardRequest));
}
}
package share.system.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "MonthlyCardRequest对象", description = "查询可用次卡对象")
public class MonthlyCardRequest {
@ApiModelProperty(value = "门店ID", required = true)
@NotNull(message = "门店ID不能为空")
private Long storeId;
@ApiModelProperty(value = "房间ID", required = true)
@NotNull(message = "房间ID不能为空")
private Long roomId;
@ApiModelProperty(value = "套餐ID")
private Long packId;
@ApiModelProperty(value = "标签id")
private Long roomLabelId;
}
......@@ -3,8 +3,10 @@ package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.ConsumerMonthlyCard;
import share.system.domain.vo.ConsumerMonthlyCardVo;
import share.system.request.MonthlyCardRequest;
import java.util.List;
import java.util.Map;
/**
* 用户月卡Service接口
......@@ -62,4 +64,6 @@ public interface ConsumerMonthlyCardService extends IService<ConsumerMonthlyCard
public int deleteConsumerMonthlyCardById(Long id);
List<ConsumerMonthlyCardVo> selectByConsumerId();
Map<String, List<Long>> queryCardType(MonthlyCardRequest monthlyCardRequest);
}
package share.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils;
import share.system.domain.ConsumerMonthlyCard;
import share.system.domain.SConsumer;
import share.system.domain.*;
import share.system.domain.vo.ConsumerMonthlyCardVo;
import share.system.mapper.ConsumerMonthlyCardMapper;
import share.system.service.ConsumerMonthlyCardService;
import share.system.service.SConsumerService;
import share.system.request.MonthlyCardRequest;
import share.system.service.*;
import java.util.List;
import java.math.BigDecimal;
import java.util.*;
/**
* 用户月卡Service业务层处理
......@@ -25,6 +30,16 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
private ConsumerMonthlyCardMapper consumerMonthlyCardMapper;
@Autowired
private SConsumerService sConsumerService;
@Autowired
private ConsumerMemberService consumerMemberService;
@Autowired
private ConsumerSecondaryCardService consumerSecondaryCardService;
@Autowired
private RoomLabelService roomLabelService;
@Autowired
private IPackService packService;
@Autowired
private ISRoomService roomService;
/**
* 查询用户月卡
......@@ -101,4 +116,80 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
vo.setConsumerId(info.getId());
return consumerMonthlyCardMapper.selectByConsumerId(vo);
}
@Override
public Map<String, List<Long>> 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<Long>> map = new HashMap<>();
List<Long> consumerMonthlyCardList = new ArrayList<>();
List<Long> consumerSecondaryCardList = new ArrayList<>();
if (ObjectUtil.isNotEmpty(consumerMember)) {
SRoom room = roomService.getById(monthlyCardRequest.getRoomId());
consumerMonthlyCard = baseMapper.selectOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getConsumerId, user.getId()));
consumerSecondaryCard = consumerSecondaryCardService.list(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getConsumerId, user.getId()).orderByAsc(ConsumerSecondaryCard::getNumber));
if (!ObjectUtils.isEmpty(monthlyCardRequest.getRoomLabelId())) {
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(monthlyCardRequest.getRoomLabelId());
if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
//标签没绑定套餐
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
consumerMonthlyCardList.add(consumerMonthlyCard.getId());
map.put("consumerMonthlyCard", consumerMonthlyCardList);
}
if (CollectionUtil.isNotEmpty(consumerSecondaryCard)) {
//过滤时长相等的
consumerSecondaryCard.stream().forEach(item -> {
if (Objects.equals(item.getSingleDuration(), Integer.valueOf(roomLabel.getPromotionDuration()))
&& item.getSingleAmount().compareTo(new BigDecimal(roomLabel.getPromotionDuration()).multiply(room.getPrice())) >= 0) {
consumerSecondaryCardList.add(item.getId());
map.put("consumerSecondaryCard", consumerSecondaryCardList);
}
});
}
return map;
} else {
SPack byId = packService.getById(roomLabel.getPackId());
//标签绑定了套餐,套餐也开启了
if (!ObjectUtils.isEmpty(byId) && byId.getIsOpen().equals(YesNoEnum.yes.getIndex())) {
if (CollectionUtil.isNotEmpty(consumerSecondaryCard)) {
//过滤时长相等的
consumerSecondaryCard.stream().forEach(item -> {
if (Objects.equals(item.getSingleDuration(), Integer.valueOf(byId.getDuration()))
&& item.getSingleAmount().compareTo(byId.getPrice()) >= 0) {
consumerSecondaryCardList.add(item.getId());
map.put("consumerSecondaryCard", consumerSecondaryCardList);
}
});
}
return map;
//标签绑定了套餐,套餐没开启,小时
} else {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
consumerMonthlyCardList.add(consumerMonthlyCard.getId());
map.put("consumerMonthlyCard", consumerMonthlyCardList);
}
return map;
}
}
} else if (!ObjectUtils.isEmpty(monthlyCardRequest.getPackId())) {
//通宵和早间套餐
SPack pack = packService.getById(monthlyCardRequest.getPackId());
if (CollectionUtil.isNotEmpty(consumerSecondaryCard)) {
//过滤时长相等的
consumerSecondaryCard.stream().forEach(item -> {
if (Objects.equals(item.getSingleDuration(), Integer.valueOf(pack.getDuration()))
&& item.getSingleAmount().compareTo(pack.getPrice()) >= 0) {
consumerSecondaryCardList.add(item.getId());
map.put("consumerSecondaryCard", consumerSecondaryCardList);
}
});
}
}
}
return new HashMap<>();
}
}
......@@ -927,8 +927,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
ConsumerMonthlyCard consumerMonthlyCard = consumerMonthlyCardService.getById(request.getMonthlyCardId());
ConsumerSecondaryCard consumerSecondaryCard = consumerSecondaryCardService.getById(request.getSecondaryCardId());
ConsumerMonthlyCard consumerMonthlyCard = null;
ConsumerSecondaryCard consumerSecondaryCard = null;
if (ObjectUtil.isNotEmpty(request.getMonthlyCardId())) {
consumerMonthlyCard = consumerMonthlyCardService.getOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getId, request.getMonthlyCardId()));
}
if (ObjectUtil.isNotEmpty(request.getSecondaryCardId())) {
consumerSecondaryCard = consumerSecondaryCardService.getOne(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getId, request.getSecondaryCardId()));
}
List<SStore> stores = storeService.list();
SRoom room = roomService.getById(request.getRoomId());
SStore sStore = storeService.getById(request.getStoreId());
......@@ -3151,7 +3157,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFeeNow(remainingBalance);
priceResponse.setMemberDiscount(totalFee.subtract(remainingBalance));
totalFee = remainingBalance.multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100));
;
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setPayFee(remainingBalance);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
......@@ -3162,7 +3167,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private BigDecimal getBigDecimal(ConsumerSecondaryCard consumerSecondaryCard,
ComputedOrderPriceResponse priceResponse, SPack byId, BigDecimal payPrice) {
if (Integer.valueOf(byId.getDuration()) > (consumerSecondaryCard.getSingleDuration()) && consumerSecondaryCard.getSingleAmount().compareTo(byId.getPrice()) > 0) {
if (consumerSecondaryCard.getSingleDuration() >= Integer.valueOf(byId.getDuration()) && consumerSecondaryCard.getSingleAmount().compareTo(byId.getPrice()) >= 0) {
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
priceResponse.setTotalFeeNow(BigDecimal.ZERO);
......
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