This commit is contained in:
齐天大圣 2024-03-11 10:45:22 +08:00
parent 7f990d9b34
commit 8e6cb5413b
7 changed files with 574 additions and 533 deletions

View File

@ -33,4 +33,10 @@ public class ActiveDiscountPayVO implements Serializable {
private BigDecimal cardFavorableAmount;
//优惠券信息
private String cardFavorableInfo;
//会员日类型 1 2
private String memberDayType;
//每周的会员日
private String weekDay;
//每月的会员日
private String monthDay;
}

View File

@ -81,6 +81,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.TextStyle;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -133,44 +136,46 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
private ActiveConsumptionChildService activeConsumptionChildService;
@Resource
private CardFuelDieselService cardFuelDieselService;
/**
* 分页查询所有
*
* @param
* @param cardExchangeRecord
* @return
*/
@Override
public List<ActiveExchangeRecordVO> select(Integer pageNo,Integer pageSize, CardExchangeRecord cardExchangeRecord) {
public List<ActiveExchangeRecordVO> select(Integer pageNo, Integer pageSize, CardExchangeRecord cardExchangeRecord) {
//兑换券
LambdaQueryWrapper<CardExchangeRecord> exchangeRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtils.isNotEmpty(cardExchangeRecord.getMobile())){
exchangeRecordLambdaQueryWrapper.eq(CardExchangeRecord::getMobile,cardExchangeRecord.getMobile());
if (ObjectUtils.isNotEmpty(cardExchangeRecord.getMobile())) {
exchangeRecordLambdaQueryWrapper.eq(CardExchangeRecord::getMobile, cardExchangeRecord.getMobile());
}
if (ObjectUtils.isNotEmpty(cardExchangeRecord.getTicketCode())){
exchangeRecordLambdaQueryWrapper.eq(CardExchangeRecord::getTicketCode,cardExchangeRecord.getTicketCode());
if (ObjectUtils.isNotEmpty(cardExchangeRecord.getTicketCode())) {
exchangeRecordLambdaQueryWrapper.eq(CardExchangeRecord::getTicketCode, cardExchangeRecord.getTicketCode());
}
List<CardExchangeRecord> cardExchangeRecordList = cardExchangeRecordService.list(exchangeRecordLambdaQueryWrapper);
//封装兑换券vo
List<ActiveExchangeRecordVO> activeExchangeRecordVOList = cardExchangeRecordList.stream().map(s->{
List<ActiveExchangeRecordVO> activeExchangeRecordVOList = cardExchangeRecordList.stream().map(s -> {
ActiveExchangeRecordVO activeExchangeRecordVO = new ActiveExchangeRecordVO();
BeanUtils.copyProperties(s,activeExchangeRecordVO);
BeanUtils.copyProperties(s, activeExchangeRecordVO);
activeExchangeRecordVO.setCardType("1");
return activeExchangeRecordVO;
}).collect(Collectors.toList());
//优惠券
LambdaQueryWrapper<CardFavorableRecord> cardFavorableRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtils.isNotEmpty(cardExchangeRecord.getMobile())){
cardFavorableRecordLambdaQueryWrapper.eq(CardFavorableRecord::getMobile,cardExchangeRecord.getMobile());
if (ObjectUtils.isNotEmpty(cardExchangeRecord.getMobile())) {
cardFavorableRecordLambdaQueryWrapper.eq(CardFavorableRecord::getMobile, cardExchangeRecord.getMobile());
}
if (ObjectUtils.isNotEmpty(cardExchangeRecord.getTicketCode())){
cardFavorableRecordLambdaQueryWrapper.eq(CardFavorableRecord::getTicketCode,cardExchangeRecord.getTicketCode());
if (ObjectUtils.isNotEmpty(cardExchangeRecord.getTicketCode())) {
cardFavorableRecordLambdaQueryWrapper.eq(CardFavorableRecord::getTicketCode, cardExchangeRecord.getTicketCode());
}
List<CardFavorableRecord> cardFavorableRecordList = cardFavorableRecordService.list(cardFavorableRecordLambdaQueryWrapper);
//封装兑换券vo
List<ActiveExchangeRecordVO> activeExchangeRecordVOList1 = cardFavorableRecordList.stream().map(s->{
List<ActiveExchangeRecordVO> activeExchangeRecordVOList1 = cardFavorableRecordList.stream().map(s -> {
ActiveExchangeRecordVO activeExchangeRecordVO1 = new ActiveExchangeRecordVO();
BeanUtils.copyProperties(s,activeExchangeRecordVO1);
BeanUtils.copyProperties(s, activeExchangeRecordVO1);
activeExchangeRecordVO1.setCardType("0");
return activeExchangeRecordVO1;
}).collect(Collectors.toList());
@ -203,6 +208,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
/**
* 核销卡券
*
* @param activeExchangeRecordDTO
* @return
*/
@ -211,14 +217,14 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
public boolean updateOneById(ActiveExchangeRecordDTO activeExchangeRecordDTO) {
boolean update = false;
//核销优惠券
if (ObjectUtils.isNotEmpty(activeExchangeRecordDTO) && activeExchangeRecordDTO.getCardType().equals("0")){
if (ObjectUtils.isNotEmpty(activeExchangeRecordDTO) && activeExchangeRecordDTO.getCardType().equals("0")) {
CardFavorableRecord cardFavorableRecord = new CardFavorableRecord();
BeanUtils.copyProperties(activeExchangeRecordDTO,cardFavorableRecord);
BeanUtils.copyProperties(activeExchangeRecordDTO, cardFavorableRecord);
update = cardFavorableRecordService.updateById(cardFavorableRecord);
}else {
} else {
//核销兑换券
CardExchangeRecord cardExchangeRecord = new CardExchangeRecord();
BeanUtils.copyProperties(activeExchangeRecordDTO,cardExchangeRecord);
BeanUtils.copyProperties(activeExchangeRecordDTO, cardExchangeRecord);
update = cardExchangeRecordService.updateById(cardExchangeRecord);
}
return update;
@ -226,6 +232,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
/**
* 查询满减活动
*
* @param pageNo
* @param pageSize
* @param transferDTO
@ -236,9 +243,9 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
ArrayList<MaxoutVO> maxoutVOArrayList = new ArrayList<>();
//构造满减券查询条件
LambdaQueryWrapper<ActiveFullminus> fullminusLambdaQueryWrapper = new LambdaQueryWrapper<>();
fullminusLambdaQueryWrapper.eq(ActiveFullminus::getStoreId,transferDTO.getStoreId());
fullminusLambdaQueryWrapper.eq(ActiveFullminus::getIsonline,0);
fullminusLambdaQueryWrapper.eq(ActiveFullminus::getStatus,0);
fullminusLambdaQueryWrapper.eq(ActiveFullminus::getStoreId, transferDTO.getStoreId());
fullminusLambdaQueryWrapper.eq(ActiveFullminus::getIsonline, 0);
fullminusLambdaQueryWrapper.eq(ActiveFullminus::getStatus, 0);
fullminusLambdaQueryWrapper.orderByDesc(ActiveFullminus::getCreateTime);
List<ActiveFullminus> activeFullminusList = activeFullminusService.list(fullminusLambdaQueryWrapper);
for (ActiveFullminus activeFullminus : activeFullminusList) {
@ -266,9 +273,9 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
//构造折扣券查询条件
LambdaQueryWrapper<ActiveDiscount> discountLambdaQueryWrapper = new LambdaQueryWrapper<>();
discountLambdaQueryWrapper.eq(ActiveDiscount::getStoreId,transferDTO.getStoreId());
discountLambdaQueryWrapper.eq(ActiveDiscount::getIsonline,0);
discountLambdaQueryWrapper.eq(ActiveDiscount::getStatus,0);
discountLambdaQueryWrapper.eq(ActiveDiscount::getStoreId, transferDTO.getStoreId());
discountLambdaQueryWrapper.eq(ActiveDiscount::getIsonline, 0);
discountLambdaQueryWrapper.eq(ActiveDiscount::getStatus, 0);
discountLambdaQueryWrapper.orderByDesc(ActiveDiscount::getCreateTime);
//符合油号判断
List<ActiveDiscount> activeDiscountList = activeDiscountService.list(discountLambdaQueryWrapper);
@ -277,18 +284,18 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
MaxoutVO maxoutVO = new MaxoutVO();
String[] split = activeDiscount.getDieselUserLevel().split(",");
for (String s : split) {
if(transferDTO.getGradeId().equals(Integer.parseInt(s))){
if (transferDTO.getGradeId().equals(Integer.parseInt(s))) {
// 会员等级判断符合油号判断
if (activeDiscount.getDieselUserLevel().contains(String.valueOf(userGradeService.selectUserGradeById(transferDTO.getGradeId()).getId())) &&
activeDiscount.getAdaptOil().contains(String.valueOf(transferDTO.getOilName()))&&
activeDiscount.getActiveStartTime().getTime()<=new Date().getTime() &&
new Date().getTime()<=activeDiscount.getActiveEndTime().getTime()){
BeanUtils.copyProperties(activeDiscount,maxoutVO);
activeDiscount.getAdaptOil().contains(String.valueOf(transferDTO.getOilName())) &&
activeDiscount.getActiveStartTime().getTime() <= new Date().getTime() &&
new Date().getTime() <= activeDiscount.getActiveEndTime().getTime()) {
BeanUtils.copyProperties(activeDiscount, maxoutVO);
LambdaQueryWrapper<ActiveDiscountChild> queryWrappers = new LambdaQueryWrapper<>();
queryWrappers.eq(ActiveDiscountChild::getActiveDiscountId,activeDiscount.getId());
queryWrappers.eq(ActiveDiscountChild::getActiveDiscountId, activeDiscount.getId());
//判断符合金额
queryWrappers.le(ActiveDiscountChild::getAmount,transferDTO.getOilPrice() * transferDTO.getOilLiters());
queryWrappers.le(ActiveDiscountChild::getAmount, transferDTO.getOilPrice() * transferDTO.getOilLiters());
queryWrappers.orderByDesc(ActiveDiscountChild::getAmount);
maxoutVO.setActiveDiscountChildList(activeDiscountChildService.list(queryWrappers));
maxoutVOArrayList.add(maxoutVO);
@ -303,23 +310,23 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
public List<ExchangeFavorableVO> selectCardFavorableList(Integer pageNo, Integer pageSize, TransferDTO transferDTO) {
//查询优惠券领取记录
LambdaQueryWrapper<CardFavorableRecord> recordLambdaQueryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtils.isNotEmpty(transferDTO.getUserId())){
recordLambdaQueryWrapper.eq(CardFavorableRecord::getMtUserId,transferDTO.getUserId());
if (ObjectUtils.isNotEmpty(transferDTO.getUserId())) {
recordLambdaQueryWrapper.eq(CardFavorableRecord::getMtUserId, transferDTO.getUserId());
}
recordLambdaQueryWrapper.eq(CardFavorableRecord::getStoreId,transferDTO.getStoreId());
recordLambdaQueryWrapper.eq(CardFavorableRecord::getStatus,"0");
recordLambdaQueryWrapper.eq(CardFavorableRecord::getStoreId, transferDTO.getStoreId());
recordLambdaQueryWrapper.eq(CardFavorableRecord::getStatus, "0");
List<CardFavorableRecord> list = cardFavorableRecordService.list(recordLambdaQueryWrapper);
//筛查优惠券
ArrayList<ExchangeFavorableVO> exchangeFavorableVOArrayList = new ArrayList<>();
for (CardFavorableRecord cardFavorableRecord : list) {
ExchangeFavorableVO exchangeFavorableVO = new ExchangeFavorableVO();
LambdaQueryWrapper<CardFavorable> cardFavorableLambdaQueryWrapper = new LambdaQueryWrapper<>();
cardFavorableLambdaQueryWrapper.eq(CardFavorable::getId,cardFavorableRecord.getCardFavorableId());
cardFavorableLambdaQueryWrapper.eq(CardFavorable::getId, cardFavorableRecord.getCardFavorableId());
//cardFavorableLambdaQueryWrapper.in(CardFavorable::getOilType,transferDTO.getOilName());
cardFavorableLambdaQueryWrapper.le(CardFavorable::getSatisfiedAmount,transferDTO.getOilPrice() * transferDTO.getOilLiters());
cardFavorableLambdaQueryWrapper.le(CardFavorable::getSatisfiedAmount, transferDTO.getOilPrice() * transferDTO.getOilLiters());
//OilName oilName = oilNameService.selectOilNameById(transferDTO.getOilName());
List<CardFavorable> list1 = cardFavorableService.list(cardFavorableLambdaQueryWrapper);
if (list1.size()>0) {
if (list1.size() > 0) {
CardFavorable cardFavorable = list1.get(0);
//符合油号判断
if (cardFavorable.getOilType().contains(String.valueOf(transferDTO.getOilName()))) {
@ -342,8 +349,10 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
return exchangeFavorableVOArrayList;
}
/**
* 分页查询所有数据
*
* @return
*/
@Override
@ -353,13 +362,13 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
CardValue cardValue = new CardValue();
cardValue.setStoreId(activeExchangeRecordDTO.getStoreId());
List<CardValueAppletVO> cardValueAppletVOS = cardValueService.selectAllApplet(cardValue);
if (CollectionUtils.isNotEmpty(cardValueAppletVOS)){
if (CollectionUtils.isNotEmpty(cardValueAppletVOS)) {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("储值卡充值活动");
activeAppletVO.setDes(cardValueAppletVOS.get(0).getDiscountActiveDescribe());
activeAppletVO.setTime(cardValueAppletVOS.get(0).getTime());
activeAppletVOS.add(activeAppletVO);
}else {
} else {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("储值卡充值活动");
activeAppletVO.setDes("活动准备中,敬请期待!");
@ -369,13 +378,13 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
CardFuelDiesel cardFuelDiesel = new CardFuelDiesel();
cardFuelDiesel.setStoreId(activeExchangeRecordDTO.getStoreId());
List<CardFuelDieselVO> cardFuelDieselVOS = cardFuelDieselService.selectAllAppletByStorId(cardFuelDiesel);
if (CollectionUtils.isNotEmpty(cardFuelDieselVOS)){
if (CollectionUtils.isNotEmpty(cardFuelDieselVOS)) {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("囤油卡充值活动");
activeAppletVO.setDes(cardFuelDieselVOS.get(0).getDiscountActiveDescribe());
activeAppletVO.setTime(cardFuelDieselVOS.get(0).getTime());
activeAppletVOS.add(activeAppletVO);
}else {
} else {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("囤油卡充值活动");
activeAppletVO.setDes("活动准备中,敬请期待!");
@ -385,13 +394,13 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
ActiveConsumption consumption = new ActiveConsumption();
consumption.setStoreId(activeExchangeRecordDTO.getStoreId());
List<ActiveConsumptionAppletVO> activeConsumptionAppletVOS = activeConsumptionService.selectAllApplet(consumption);
if (CollectionUtils.isNotEmpty(activeConsumptionAppletVOS)){
if (CollectionUtils.isNotEmpty(activeConsumptionAppletVOS)) {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("消费有礼活动");
activeAppletVO.setDes(activeConsumptionAppletVOS.get(0).getActiveDescribe());
activeAppletVO.setTime(activeConsumptionAppletVOS.get(0).getTime());
activeAppletVOS.add(activeAppletVO);
}else {
} else {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("消费有礼活动");
activeAppletVO.setDes("活动准备中,敬请期待!");
@ -401,13 +410,13 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
ActiveDiscount activeDiscount = new ActiveDiscount();
activeDiscount.setStoreId(activeExchangeRecordDTO.getStoreId());
List<ActiveDiscountAppletVO> activeDiscountAppletVOS = activeDiscountService.selectAllApplet(activeDiscount);
if (CollectionUtils.isNotEmpty(activeDiscountAppletVOS)){
if (CollectionUtils.isNotEmpty(activeDiscountAppletVOS)) {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("折扣营销活动");
activeAppletVO.setDes(activeDiscountAppletVOS.get(0).getDiscountActiveDescribe());
activeAppletVO.setTime(activeDiscountAppletVOS.get(0).getTime());
activeAppletVOS.add(activeAppletVO);
}else {
} else {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("折扣营销活动");
activeAppletVO.setDes("活动准备中,敬请期待!");
@ -417,13 +426,13 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
ActiveFullminus activeFullminus = new ActiveFullminus();
activeFullminus.setStoreId(activeExchangeRecordDTO.getStoreId());
List<ActiveFullminusAppletVO> activeFullminusAppletVOS = activeFullminusService.selectAllApplet(activeFullminus);
if (CollectionUtils.isNotEmpty(activeFullminusAppletVOS)){
if (CollectionUtils.isNotEmpty(activeFullminusAppletVOS)) {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("满减营销活动");
activeAppletVO.setDes(activeFullminusAppletVOS.get(0).getFullminusActiveDescribe());
activeAppletVO.setTime(activeFullminusAppletVOS.get(0).getTime());
activeAppletVOS.add(activeAppletVO);
}else {
} else {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("满减营销活动");
activeAppletVO.setDes("活动准备中,敬请期待!");
@ -431,13 +440,13 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
//新人有礼
List<ActiveNewlywedsAppletVO> activeNewlywedsAppletVOS = activeNewlywedsService.selectApplet(consumption);
if (ObjectUtils.isNotEmpty(activeNewlywedsAppletVOS)){
if (ObjectUtils.isNotEmpty(activeNewlywedsAppletVOS)) {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("新人有礼活动");
activeAppletVO.setDes(activeNewlywedsAppletVOS.get(0).getNewlywedsActiveDescribe());
activeAppletVO.setTime(activeNewlywedsAppletVOS.get(0).getTime());
activeAppletVOS.add(activeAppletVO);
}else {
} else {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("新人有礼活动");
activeAppletVO.setDes("活动准备中,敬请期待!");
@ -445,13 +454,13 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
//推荐有礼
List<ActiveRecommendAppletVO> activeRecommendAppletVOS = activeRecommendService.selectApplet(consumption);
if (ObjectUtils.isNotEmpty(activeRecommendAppletVOS)){
if (ObjectUtils.isNotEmpty(activeRecommendAppletVOS)) {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("推荐有礼活动");
activeAppletVO.setDes(activeRecommendAppletVOS.get(0).getRecommendActiveDescribeIn());
activeAppletVO.setTime("永久有效");
activeAppletVOS.add(activeAppletVO);
}else {
} else {
ActiveAppletVO activeAppletVO = new ActiveAppletVO();
activeAppletVO.setName("推荐有礼活动");
activeAppletVO.setDes("活动准备中,敬请期待!");
@ -463,6 +472,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
/**
* 优惠活动接口
*
* @param paymentActiveDTO
* @return
*/
@ -472,33 +482,50 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
Integer storeId = paymentActiveDTO.getStoreId();
double finalAmount = 0.00;
Integer userId = TokenUtil.getNowAccountInfo().getId();
//获取今日是周几
DayOfWeek dayOfWeek = LocalDate.now().getDayOfWeek();
String displayName = dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault());
//折扣有限制
List<ActiveDiscountPayVO> activeDiscountVOList = oilOrderMapper.selectActiveDiscount(storeId,paymentActiveDTO.getAmount(),paymentActiveDTO.getOilId(),paymentActiveDTO.getMtUserLevel());
List<ActiveDiscountPayVO> activeDiscountVOList = oilOrderMapper.selectActiveDiscount(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel());
for (ActiveDiscountPayVO activeDiscountPayVO : activeDiscountVOList) {
//
if (activeDiscountPayVO.getMemberDayType().equals("1")) {
String weekDay = activeDiscountPayVO.getWeekDay();
if (weekDay.contains(displayName)) {
} else if (activeDiscountPayVO.getMemberDayType().equals("2")) {
} else {
}
//
}
}
//折扣无限制
List<ActiveDiscountPayVO> activeDiscountVOLists = oilOrderMapper.selectActiveDiscounts(storeId,paymentActiveDTO.getAmount(),paymentActiveDTO.getOilId(),paymentActiveDTO.getMtUserLevel());
List<ActiveDiscountPayVO> activeDiscountVOLists = oilOrderMapper.selectActiveDiscounts(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel());
activeDiscountVOList.addAll(activeDiscountVOLists);
//满减有限制
List<ActiveDiscountPayVO> activeFuletVOList = oilOrderMapper.selectActiveFule(storeId,paymentActiveDTO.getAmount(),paymentActiveDTO.getOilId(),paymentActiveDTO.getMtUserLevel());
List<ActiveDiscountPayVO> activeFuletVOList = oilOrderMapper.selectActiveFule(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel());
//满减无限制
List<ActiveDiscountPayVO> activeFuletVOLists = oilOrderMapper.selectActiveFules(storeId,paymentActiveDTO.getAmount(),paymentActiveDTO.getOilId(),paymentActiveDTO.getMtUserLevel());
List<ActiveDiscountPayVO> activeFuletVOLists = oilOrderMapper.selectActiveFules(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel());
activeFuletVOList.addAll(activeFuletVOLists);
//优惠券
paymentActiveDTO.setUserId(userId);
if (ObjectUtils.isNotEmpty(paymentActiveDTO.getUserId())){
if (ObjectUtils.isNotEmpty(paymentActiveDTO.getUserId())) {
userId = paymentActiveDTO.getUserId();
}
paymentActiveDTO.setUserId(userId);
List<CardFavorableRecordVO> canUserCardFavorableList = cardFavorableRecordMapper.getCanUserCardFavorableList(paymentActiveDTO);
//如果是储值卡付款直接过滤掉
if(paymentActiveDTO.getType().equals("0")){
if (paymentActiveDTO.getType().equals("0")) {
canUserCardFavorableList = canUserCardFavorableList.stream().filter(cardFavorableRecordVO -> cardFavorableRecordVO.getExclusiveFunction().equals("0"))
.collect(Collectors.toList());
}
//会员等级当前优惠力度最大
//无限制条件的活动列表
List<ActiveDiscountPayVO> resList =new ArrayList<>();
List<ActiveDiscountPayVO> resList = new ArrayList<>();
//无限制条件的优惠券的列表
ArrayList<CardFavorableRecordVO> cardFavorableRecordVOS = new ArrayList<>();
//优惠券和折扣活动的组合列表
@ -506,7 +533,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
//优惠券和满减活动的组合列表
ArrayList<ActiveDiscountPayVO> cardAndComPays = new ArrayList<>();
//折扣
if (CollectionUtils.isNotEmpty(activeDiscountVOList)){
if (CollectionUtils.isNotEmpty(activeDiscountVOList)) {
for (ActiveDiscountPayVO activeDiscountPayVO : activeDiscountVOList) {
//if (activeDiscountPayVO.getParticipationCondition().equals("0")){
activeDiscountPayVO.setType("2");
@ -516,7 +543,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
}
//满减
if (CollectionUtils.isNotEmpty(activeFuletVOList)){
if (CollectionUtils.isNotEmpty(activeFuletVOList)) {
for (ActiveDiscountPayVO activeDiscountPayVO : activeFuletVOList) {
//if (activeDiscountPayVO.getParticipationCondition().equals("0")){
activeDiscountPayVO.setActiveDiscount(activeDiscountPayVO.getDiscount());
@ -526,9 +553,9 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
}
//优惠券
if (CollectionUtils.isNotEmpty(canUserCardFavorableList)){
if (CollectionUtils.isNotEmpty(canUserCardFavorableList)) {
for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList) {
if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("0")){
if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("0")) {
cardFavorableRecordVOS.add(cardFavorableRecordVO);
}
}
@ -536,12 +563,12 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
//折扣+优惠券
for (ActiveDiscountPayVO activeDiscountPayVO : activeDiscountVOList) {
if (ObjectUtil.isNotEmpty(activeDiscountPayVO.getParticipationCondition())
&& !activeDiscountPayVO.getParticipationCondition().equals("1")){
&& !activeDiscountPayVO.getParticipationCondition().equals("1")) {
for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList) {
if(StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("2")
&& StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && !cardFavorableRecordVO.getExclusiveFunction().equals("0")){
if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("2")
&& StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && !cardFavorableRecordVO.getExclusiveFunction().equals("0")) {
ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO();
BeanUtils.copyProperties(activeDiscountPayVO,activeDiscountPayVO1);
BeanUtils.copyProperties(activeDiscountPayVO, activeDiscountPayVO1);
activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId());
double discountAmount = cardFavorableRecordVO.getDiscountAmount();
BigDecimal bigDecimal = BigDecimal.valueOf(discountAmount);
@ -552,12 +579,12 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
activeDiscountPayVO1.setCardFavorableAmount(BigDecimal.valueOf(cardFavorableRecordVO.getDiscountAmount()));
activeDiscountPayVO1.setCardFavorableInfo(cardFavorableRecordVO.getCardFavorableName());
cardAndDisPays.add(activeDiscountPayVO1);
}else if( StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("0")){
} else if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("0")) {
ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO();
BeanUtils.copyProperties(activeDiscountPayVO,activeDiscountPayVO1);
BeanUtils.copyProperties(activeDiscountPayVO, activeDiscountPayVO1);
String[] split = cardFavorableRecordVO.getOilType().split(",");
for (String oilId : split) {
if((paymentActiveDTO.getOilId()).toString().equals(oilId)){
if ((paymentActiveDTO.getOilId()).toString().equals(oilId)) {
activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId());
double discountAmount = cardFavorableRecordVO.getDiscountAmount();
activeDiscountPayVO1.setActiveDiscount(activeDiscountPayVO1.getDiscount());
@ -578,11 +605,11 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
//满减+优惠券
for (ActiveDiscountPayVO activeDiscountPayVO : activeFuletVOList) {
if (ObjectUtils.isNotEmpty(activeDiscountPayVO.getParticipationCondition())
&& !activeDiscountPayVO.getParticipationCondition().equals("1")){
&& !activeDiscountPayVO.getParticipationCondition().equals("1")) {
for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList) {
if(StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && ObjectUtils.isNotEmpty(cardFavorableRecordVO) && cardFavorableRecordVO.getType().equals("2") && !cardFavorableRecordVO.getExclusiveFunction().equals("0")){
if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && ObjectUtils.isNotEmpty(cardFavorableRecordVO) && cardFavorableRecordVO.getType().equals("2") && !cardFavorableRecordVO.getExclusiveFunction().equals("0")) {
ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO();
BeanUtils.copyProperties(activeDiscountPayVO,activeDiscountPayVO1);
BeanUtils.copyProperties(activeDiscountPayVO, activeDiscountPayVO1);
activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId());
double discountAmount = cardFavorableRecordVO.getDiscountAmount();
activeDiscountPayVO1.setActiveDiscount(activeDiscountPayVO1.getDiscount());
@ -592,12 +619,12 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
activeDiscountPayVO1.setCardFavorableAmount(BigDecimal.valueOf(cardFavorableRecordVO.getDiscountAmount()));
activeDiscountPayVO1.setCardFavorableInfo(cardFavorableRecordVO.getCardFavorableName());
cardAndComPays.add(activeDiscountPayVO1);
}else if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("0")){
} else if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("0")) {
ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO();
BeanUtils.copyProperties(activeDiscountPayVO,activeDiscountPayVO1);
BeanUtils.copyProperties(activeDiscountPayVO, activeDiscountPayVO1);
String[] split = cardFavorableRecordVO.getOilType().split(",");
for (String oilId : split) {
if((paymentActiveDTO.getOilId()).toString().equals(oilId)){
if ((paymentActiveDTO.getOilId()).toString().equals(oilId)) {
activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId());
double discountAmount = cardFavorableRecordVO.getDiscountAmount();
activeDiscountPayVO1.setActiveDiscount(activeDiscountPayVO1.getDiscount());
@ -630,23 +657,23 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
ArrayList<ActiveDiscountPayVO> activeDiscountPayVOS = new ArrayList<>();
//1.无限制条件的活动和优惠券分别选出一个优惠最大的来
//活动
if (CollectionUtils.isNotEmpty(resList)){
if (CollectionUtils.isNotEmpty(resList)) {
ActiveDiscountPayVO activeDiscountPayVO = resList.stream().max(Comparator.comparingDouble(ActiveDiscountPayVO::getDiscounts)).get();
activeDiscountPayVOS.add(activeDiscountPayVO);
}
//优惠券
CardFavorableRecordVO cardFavorableRecordVO = new CardFavorableRecordVO();
if (CollectionUtils.isNotEmpty(cardFavorableRecordVOS)){
if (CollectionUtils.isNotEmpty(cardFavorableRecordVOS)) {
cardFavorableRecordVO = cardFavorableRecordVOS.stream().max(Comparator.comparingDouble(CardFavorableRecordVO::getDiscountAmount)).get();
}
//2.有限制条件的活动和优惠券组合比较出一个优惠最大的来
//满减+优惠券
if (CollectionUtils.isNotEmpty(cardAndDisPays)){
if (CollectionUtils.isNotEmpty(cardAndDisPays)) {
ActiveDiscountPayVO activeDiscountPayVO1 = cardAndDisPays.stream().max(Comparator.comparingDouble(ActiveDiscountPayVO::getDiscounts)).get();
activeDiscountPayVOS.add(activeDiscountPayVO1);
}
//折扣+优惠券
if (CollectionUtils.isNotEmpty(cardAndComPays)){
if (CollectionUtils.isNotEmpty(cardAndComPays)) {
ActiveDiscountPayVO activeDiscountPayVO2 = cardAndComPays.stream().max(Comparator.comparingDouble(ActiveDiscountPayVO::getDiscounts)).get();
activeDiscountPayVOS.add(activeDiscountPayVO2);
}
@ -656,19 +683,19 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
activeDiscountPayVO3 = activeDiscountPayVOS.stream().max(Comparator.comparingDouble(ActiveDiscountPayVO::getDiscounts)).get();
}
//4. 3和优惠券比较
if(ObjectUtils.isNotEmpty(activeDiscountPayVO3)){
if (ObjectUtils.isNotEmpty(activeDiscountPayVO3)) {
finalAmount = activeDiscountPayVO3.getDiscounts();
if (ObjectUtils.isNotEmpty(cardFavorableRecordVO) && finalAmount < cardFavorableRecordVO.getDiscountAmount()){
if (ObjectUtils.isNotEmpty(cardFavorableRecordVO) && finalAmount < cardFavorableRecordVO.getDiscountAmount()) {
PaymentActiveVO paymentActiveVO1 = new PaymentActiveVO();
//单用优惠券优惠力度最大
paymentActiveVO1.setCardFavorableId(cardFavorableRecordVO.getId());
//金额
paymentActiveVO1.setCardFavorableAmount(BigDecimal.valueOf(cardFavorableRecordVO.getDiscountAmount()));
//优惠券名字
paymentActiveVO1.setCardFavorableInfo(cardFavorableRecordVO.getCardFavorableName() + ""+cardFavorableRecordVO.getSatisfiedAmount() + "" + cardFavorableRecordVO.getDiscountAmount() + "");
BeanUtils.copyProperties(paymentActiveVO1,paymentActiveVO);
paymentActiveVO1.setCardFavorableInfo(cardFavorableRecordVO.getCardFavorableName() + "" + cardFavorableRecordVO.getSatisfiedAmount() + "" + cardFavorableRecordVO.getDiscountAmount() + "");
BeanUtils.copyProperties(paymentActiveVO1, paymentActiveVO);
//return paymentActiveVO1;
}else {
} else {
PaymentActiveVO paymentActiveVO2 = new PaymentActiveVO();
//活动或活动+优惠券优惠力度最大
paymentActiveVO2.setActiveId(activeDiscountPayVO3.getActiveId());
@ -679,7 +706,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
paymentActiveVO2.setCardFavorableId(activeDiscountPayVO3.getCouponId());
paymentActiveVO2.setCardFavorableInfo(activeDiscountPayVO3.getCardFavorableInfo());
paymentActiveVO2.setCardFavorableAmount(activeDiscountPayVO3.getCardFavorableAmount());
BeanUtils.copyProperties(paymentActiveVO2,paymentActiveVO);
BeanUtils.copyProperties(paymentActiveVO2, paymentActiveVO);
//return paymentActiveVO2;
}
}
@ -687,7 +714,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
//会员等级优惠
Integer oilId = paymentActiveDTO.getOilId();
double oilPriceById = oilNumberMapper.getOilPriceById(oilId,storeId);
double oilPriceById = oilNumberMapper.getOilPriceById(oilId, storeId);
BigDecimal bigDecimal1 = BigDecimal.valueOf(oilPriceById);
String oilTypebyId = oilNameMapper.getOilTypebyId(oilId);
@ -793,60 +820,60 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
//三个优惠都不为空
BigDecimal bigDecimal = new BigDecimal("0.00");
if (ObjectUtils.isNotEmpty(paymentActiveVO.getActiveFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getCardFavorableAmount())&& ObjectUtils.isNotEmpty(paymentActiveVO.getMemberFavorableAmount())) {
if (ObjectUtils.isNotEmpty(paymentActiveVO.getActiveFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getCardFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getMemberFavorableAmount())) {
BigDecimal add3 = paymentActiveVO.getActiveFavorableAmount().add(paymentActiveVO.getCardFavorableAmount()).add(paymentActiveVO.getMemberFavorableAmount());
if (add3.compareTo(paymentActiveDTO.getAmount()) > 0){
if (add3.compareTo(paymentActiveDTO.getAmount()) > 0) {
BigDecimal add21 = paymentActiveVO.getActiveFavorableAmount().add(paymentActiveVO.getCardFavorableAmount());
BigDecimal add22 = paymentActiveVO.getActiveFavorableAmount().add(paymentActiveVO.getMemberFavorableAmount());
BigDecimal add23 = paymentActiveVO.getCardFavorableAmount().add(paymentActiveVO.getMemberFavorableAmount());
if (add21.compareTo(add22)>0 && add21.compareTo(add23)>0){
if (add21.compareTo(add22) > 0 && add21.compareTo(add23) > 0) {
paymentActiveVO.setMemberFavorableAmount(bigDecimal);
}
if (add22.compareTo(add21)>0 && add22.compareTo(add23)>0){
if (add22.compareTo(add21) > 0 && add22.compareTo(add23) > 0) {
paymentActiveVO.setCardFavorableAmount(bigDecimal);
}
if (add23.compareTo(add21)>0 && add23.compareTo(add22)>0){
if (add23.compareTo(add21) > 0 && add23.compareTo(add22) > 0) {
paymentActiveVO.setActiveFavorableAmount(bigDecimal);
}
if (paymentActiveVO.getActiveFavorableAmount().compareTo(add23)>0){
if (paymentActiveVO.getActiveFavorableAmount().compareTo(add23) > 0) {
paymentActiveVO.setCardFavorableAmount(bigDecimal);
paymentActiveVO.setMemberFavorableAmount(bigDecimal);
}
if (paymentActiveVO.getCardFavorableAmount().compareTo(add22)>0){
if (paymentActiveVO.getCardFavorableAmount().compareTo(add22) > 0) {
paymentActiveVO.setActiveFavorableAmount(bigDecimal);
paymentActiveVO.setMemberFavorableAmount(bigDecimal);
}
if (paymentActiveVO.getMemberFavorableAmount().compareTo(add21)>0){
if (paymentActiveVO.getMemberFavorableAmount().compareTo(add21) > 0) {
paymentActiveVO.setActiveFavorableAmount(bigDecimal);
paymentActiveVO.setCardFavorableAmount(bigDecimal);
}
}
}
//有空值
if (ObjectUtils.isEmpty(paymentActiveVO.getActiveFavorableAmount()) || ObjectUtils.isEmpty(paymentActiveVO.getCardFavorableAmount()) || ObjectUtils.isEmpty(paymentActiveVO.getMemberFavorableAmount())){
if (ObjectUtils.isEmpty(paymentActiveVO.getActiveFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getCardFavorableAmount())&& ObjectUtils.isNotEmpty(paymentActiveVO.getMemberFavorableAmount())){
if (paymentActiveVO.getCardFavorableAmount().add(paymentActiveVO.getMemberFavorableAmount()).compareTo(paymentActiveDTO.getAmount())>0){
if (paymentActiveVO.getCardFavorableAmount().compareTo(paymentActiveVO.getMemberFavorableAmount())>0){
if (ObjectUtils.isEmpty(paymentActiveVO.getActiveFavorableAmount()) || ObjectUtils.isEmpty(paymentActiveVO.getCardFavorableAmount()) || ObjectUtils.isEmpty(paymentActiveVO.getMemberFavorableAmount())) {
if (ObjectUtils.isEmpty(paymentActiveVO.getActiveFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getCardFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getMemberFavorableAmount())) {
if (paymentActiveVO.getCardFavorableAmount().add(paymentActiveVO.getMemberFavorableAmount()).compareTo(paymentActiveDTO.getAmount()) > 0) {
if (paymentActiveVO.getCardFavorableAmount().compareTo(paymentActiveVO.getMemberFavorableAmount()) > 0) {
paymentActiveVO.setMemberFavorableAmount(bigDecimal);
}else {
} else {
paymentActiveVO.setCardFavorableAmount(bigDecimal);
}
}
}
if (ObjectUtils.isEmpty(paymentActiveVO.getCardFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getActiveFavorableAmount())&& ObjectUtils.isNotEmpty(paymentActiveVO.getMemberFavorableAmount())){
if (paymentActiveVO.getActiveFavorableAmount().add(paymentActiveVO.getMemberFavorableAmount()).compareTo(paymentActiveDTO.getAmount())>0){
if (paymentActiveVO.getActiveFavorableAmount().compareTo(paymentActiveVO.getMemberFavorableAmount())>0){
if (ObjectUtils.isEmpty(paymentActiveVO.getCardFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getActiveFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getMemberFavorableAmount())) {
if (paymentActiveVO.getActiveFavorableAmount().add(paymentActiveVO.getMemberFavorableAmount()).compareTo(paymentActiveDTO.getAmount()) > 0) {
if (paymentActiveVO.getActiveFavorableAmount().compareTo(paymentActiveVO.getMemberFavorableAmount()) > 0) {
paymentActiveVO.setMemberFavorableAmount(bigDecimal);
}else {
} else {
paymentActiveVO.setActiveFavorableAmount(bigDecimal);
}
}
}
if (ObjectUtils.isEmpty(paymentActiveVO.getMemberFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getCardFavorableAmount())&& ObjectUtils.isNotEmpty(paymentActiveVO.getActiveFavorableAmount())){
if (paymentActiveVO.getCardFavorableAmount().add(paymentActiveVO.getActiveFavorableAmount()).compareTo(paymentActiveDTO.getAmount())>0){
if (paymentActiveVO.getCardFavorableAmount().compareTo(paymentActiveVO.getActiveFavorableAmount())>0){
if (ObjectUtils.isEmpty(paymentActiveVO.getMemberFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getCardFavorableAmount()) && ObjectUtils.isNotEmpty(paymentActiveVO.getActiveFavorableAmount())) {
if (paymentActiveVO.getCardFavorableAmount().add(paymentActiveVO.getActiveFavorableAmount()).compareTo(paymentActiveDTO.getAmount()) > 0) {
if (paymentActiveVO.getCardFavorableAmount().compareTo(paymentActiveVO.getActiveFavorableAmount()) > 0) {
paymentActiveVO.setActiveFavorableAmount(bigDecimal);
}else {
} else {
paymentActiveVO.setCardFavorableAmount(bigDecimal);
}
}
@ -856,19 +883,19 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
@Override
public void activeConsumption(PaymentActiveDTO paymentActiveDTO) {
public void activeConsumption (PaymentActiveDTO paymentActiveDTO){
//消费有礼
ArrayList<ActiveConsumptionVO> activeConsumptionVOS1 = new ArrayList<>();
List<ActiveConsumptionVO> activeConsumptionVOS = oilOrderMapper.selectActiveConsumption(paymentActiveDTO.getStoreId(), paymentActiveDTO.getAmount());
if (CollectionUtils.isNotEmpty(activeConsumptionVOS)){
if (CollectionUtils.isNotEmpty(activeConsumptionVOS)) {
for (ActiveConsumptionVO activeConsumptionVO : activeConsumptionVOS) {
BigDecimal amount = new BigDecimal(activeConsumptionVO.getAmount());
if (ObjectUtils.isNotEmpty(activeConsumptionVO.getMoneyType()) && activeConsumptionVO.getMoneyType().equals("1")
&& paymentActiveDTO.getOrderAmount()>=activeConsumptionVO.getAmount()){
&& paymentActiveDTO.getOrderAmount() >= activeConsumptionVO.getAmount()) {
activeConsumptionVOS1.add(activeConsumptionVO);
}
if (ObjectUtils.isNotEmpty(activeConsumptionVO.getMoneyType()) && activeConsumptionVO.getMoneyType().equals("2")
&& paymentActiveDTO.getAmount().compareTo(amount)>0){
&& paymentActiveDTO.getAmount().compareTo(amount) > 0) {
activeConsumptionVOS1.add(activeConsumptionVO);
}
}
@ -881,38 +908,38 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
Integer storeId1 = paymentActiveDTO.getStoreId();
Integer chainStoreId = iljStoreService.selectStoreByStoreId(storeId1).getChainStoreId();
//用户余额
UserBalance userBalance = userBalanceService.selectUserBalance(paymentActiveDTO.getUserId(),chainStoreId);
UserBalance userBalance = userBalanceService.selectUserBalance(paymentActiveDTO.getUserId(), chainStoreId);
UserBalance userBalance1 = new UserBalance();
if (CollectionUtils.isNotEmpty(activeConsumptionVOS1)){
if (CollectionUtils.isNotEmpty(activeConsumptionVOS1)) {
for (ActiveConsumptionVO activeConsumptionVO : activeConsumptionVOS1) {
if (activeConsumptionVO.getAdaptUserType().equals("2") && activeConsumptionVO.getOilId().contains(paymentActiveDTO.getOilId().toString()) &&
StringUtils.isNotEmpty(activeConsumptionVO.getAdaptUser()) && activeConsumptionVO.getAdaptUser().contains(paymentActiveDTO.getMtUserLevel().toString()) || activeConsumptionVO.getAdaptUserType().equals("0") && activeConsumptionVO.getOilId().contains(paymentActiveDTO.getOilId().toString())
|| activeConsumptionVO.getAdaptUserType().equals("1") && activeConsumptionVO.getOilId().contains(paymentActiveDTO.getOilId().toString()) && StringUtils.isNotEmpty(paymentActiveDTO.getMtUserLevel().toString())){
|| activeConsumptionVO.getAdaptUserType().equals("1") && activeConsumptionVO.getOilId().contains(paymentActiveDTO.getOilId().toString()) && StringUtils.isNotEmpty(paymentActiveDTO.getMtUserLevel().toString())) {
//如果满足条件/给当前用户加积分
//用户 (新用户新建 老用户叠加)
if (ObjectUtils.isNotEmpty(userBalance)){
if (ObjectUtils.isNotEmpty(userBalance)) {
//积分
if (ObjectUtils.isNotEmpty(userBalance.getPoints()) && ObjectUtils.isNotEmpty(activeConsumptionVO.getPoints())){
if (ObjectUtils.isNotEmpty(userBalance.getPoints()) && ObjectUtils.isNotEmpty(activeConsumptionVO.getPoints())) {
userBalance.setPoints(userBalance.getPoints() + activeConsumptionVO.getPoints());
}
userBalanceService.updateUserBalance(userBalance);
}else {
} else {
userBalance1.setMtUserId(paymentActiveDTO.getUserId());
userBalance1.setChainStoreId(chainStoreId);
//积分
if (ObjectUtils.isNotEmpty(activeConsumptionVO.getPoints())){
if (ObjectUtils.isNotEmpty(activeConsumptionVO.getPoints())) {
userBalance1.setPoints(activeConsumptionVO.getPoints());
}
userBalanceService.save(userBalance1);
}
//查询改活动下的卡券列表
LambdaQueryWrapper<ActiveConsumptionChild> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveConsumptionChild::getActiveConsumptionId,activeConsumptionVO.getActiveId());
queryWrapper.eq(ActiveConsumptionChild::getActiveConsumptionId, activeConsumptionVO.getActiveId());
List<ActiveConsumptionChild> list = activeConsumptionChildService.list(queryWrapper);
if (ObjectUtils.isNotEmpty(list)){
if (ObjectUtils.isNotEmpty(list)) {
for (ActiveConsumptionChild activeConsumptionChild : list) {
if (ObjectUtils.isNotEmpty(activeConsumptionChild) && activeConsumptionChild.getActiveGift().equals("1")){
if (ObjectUtils.isNotEmpty(activeConsumptionChild) && activeConsumptionChild.getActiveGift().equals("1")) {
CardFavorableRecord cardFavorableRecord = new CardFavorableRecord();
cardFavorableRecord.setCardFavorableId(activeConsumptionChild.getVouchersId());
cardFavorableRecord.setStoreId(storeId1);
@ -924,7 +951,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
cardFavorableRecord.setActiveId(activeConsumptionChild.getActiveConsumptionId());
cardFavorableRecordService.addCardFavorableRecord(cardFavorableRecord);
//兑换券
}else if (ObjectUtils.isNotEmpty(activeConsumptionChild) && activeConsumptionChild.getActiveGift().equals("2")){
} else if (ObjectUtils.isNotEmpty(activeConsumptionChild) && activeConsumptionChild.getActiveGift().equals("2")) {
CardExchangeRecord cardExchangeRecord = new CardExchangeRecord();
cardExchangeRecord.setCardExchangeId(activeConsumptionChild.getVouchersId());
cardExchangeRecord.setStoreId(storeId1);
@ -969,4 +996,4 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
}
}
}
}

View File

@ -41,7 +41,7 @@ public interface ActiveNewlywedsService extends IService<ActiveNewlyweds> {
* @return
*/
ActiveNewlywedsVO getOneById(Serializable id);
ActiveNewlywedsVO getOneByStoreId(Serializable id);
List<ActiveNewlywedsVO> getOneByStoreId(Serializable id);
List<ActiveNewlywedsVO> getOneByIdApplet(ActiveConsumption activeConsumption);
/**

View File

@ -62,7 +62,8 @@ public class ActiveNewlywedsRecordsServiceImpl extends ServiceImpl<ActiveNewlywe
Integer userId = nowAccountInfo.getId();
LJUserVo ljUserVo = userService.selectUserById(userId,activeNewlywedsRecords.getStoreId());
//保存新人有礼记录
ActiveNewlywedsVO activeNewlyweds = activeNewlywedsService.getOneByStoreId(activeNewlywedsRecords.getStoreId());
List<ActiveNewlywedsVO> activeNewlywedsVOList = activeNewlywedsService.getOneByStoreId(activeNewlywedsRecords.getStoreId());
for (ActiveNewlywedsVO activeNewlyweds : activeNewlywedsVOList) {
activeNewlywedsRecords.setActiveNewlywedsId(activeNewlyweds.getId());
activeNewlywedsRecords.setChainStoreId(nowAccountInfo.getChainStoreId());
activeNewlywedsRecords.setStoreId(nowAccountInfo.getStoreId());
@ -110,6 +111,8 @@ public class ActiveNewlywedsRecordsServiceImpl extends ServiceImpl<ActiveNewlywe
}
userBalanceService.updateUserBalance(userBalance);
}
}
return save;
}
}

View File

@ -358,14 +358,18 @@ public class ActiveNewlywedsServiceImpl extends ServiceImpl<ActiveNewlywedsMappe
* @return
*/
@Override
public ActiveNewlywedsVO getOneByStoreId(Serializable id) {
ActiveNewlywedsVO activeNewlywedsVO = new ActiveNewlywedsVO();
activeNewlywedsVO.setCourtesyReward(new String[0]);
public List<ActiveNewlywedsVO> getOneByStoreId(Serializable id) {
ArrayList<ActiveNewlywedsVO> arrayList = new ArrayList<>();
if (ObjectUtils.isNotEmpty(id)){
//获取新人有礼活动信息
LambdaQueryWrapper<ActiveNewlyweds> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveNewlyweds::getStoreId,id);
ActiveNewlyweds activeNewlyweds = getOne(lambdaQueryWrapper);
lambdaQueryWrapper.eq(ActiveNewlyweds::getStoreId,id).eq(ActiveNewlyweds::getIsonline,0);
//ActiveNewlyweds activeNewlyweds = getOne(lambdaQueryWrapper);
List<ActiveNewlyweds> newlywedsList = list(lambdaQueryWrapper);
for (ActiveNewlyweds activeNewlyweds : newlywedsList) {
ActiveNewlywedsVO activeNewlywedsVO = new ActiveNewlywedsVO();
activeNewlywedsVO.setCourtesyReward(new String[0]);
//获取兑换物品信息
if (ObjectUtils.isNotEmpty(activeNewlyweds)){
LambdaQueryWrapper<ActiveNewlywedsChild> queryWrapper = new LambdaQueryWrapper<>();
@ -385,8 +389,10 @@ public class ActiveNewlywedsServiceImpl extends ServiceImpl<ActiveNewlywedsMappe
ArrayList<ActiveNewlywedsChild> activeNewlywedsChildList = new ArrayList<>();
activeNewlywedsVO.setActiveNewlywedsChildList(activeNewlywedsChildList);
}
arrayList.add(activeNewlywedsVO);
}
return activeNewlywedsVO;
}
return arrayList;
}
/**

View File

@ -130,6 +130,9 @@ public class CardExchangeRecordController extends BaseController {
CardExchangeRecord byId = cardExchangeRecordService.getById(cardExchangeRecord.getId());
Integer cardExchangeId = byId.getCardExchangeId();
CardExchange cardExchange = cardExchangeService.getById(cardExchangeId);
if (cardExchange.getType().equals("1")){
return getSuccessResult(this.cardExchangeRecordService.updateById(cardExchangeRecord));
}
Integer giftId = cardExchange.getGiftId();
LJOrder ljOrder = new LJOrder();
ljOrder.setTerminal("pc");

View File

@ -118,9 +118,7 @@
WHERE
cer.mt_user_id = #{cardFavorableDTOS.id}
and ce.type = 0
<if test="cardFavorableDTOS.useStatus!=null and cardFavorableDTOS.useStatus != ''">
and cer.status = #{cardFavorableDTOS.useStatus}
</if>
and cer.store_id = #{cardFavorableDTOS.storeId} UNION ALL
SELECT
'洗车券' AS couponType,
@ -132,9 +130,7 @@
WHERE
cer.mt_user_id = #{cardFavorableDTOS.id}
and ce.type = 1
<if test="cardFavorableDTOS.useStatus!=null and cardFavorableDTOS.useStatus != ''">
and cer.status = #{cardFavorableDTOS.useStatus}
</if>
and cer.store_id = #{cardFavorableDTOS.storeId} UNION ALL
SELECT
'洗车卡' AS couponType,