diff --git a/fuintAdmin/src/views/EventMarketing/activeDiscount/index.vue b/fuintAdmin/src/views/EventMarketing/activeDiscount/index.vue index 8baa3e987..a6dce5e34 100644 --- a/fuintAdmin/src/views/EventMarketing/activeDiscount/index.vue +++ b/fuintAdmin/src/views/EventMarketing/activeDiscount/index.vue @@ -105,7 +105,7 @@
- +
diff --git a/fuintAdmin/src/views/EventMarketing/cardFavorable/index.vue b/fuintAdmin/src/views/EventMarketing/cardFavorable/index.vue index 0db1a4639..9ef4a8c21 100644 --- a/fuintAdmin/src/views/EventMarketing/cardFavorable/index.vue +++ b/fuintAdmin/src/views/EventMarketing/cardFavorable/index.vue @@ -174,12 +174,12 @@ - - + + - + @@ -460,9 +460,6 @@ export default { checkTime: [ { required: true, message: '不能为空', trigger: 'change' } ], - exclusiveFunction: [ - { required: true, message: '不能为空', trigger: 'change' } - ], claimRule: [ { required: true, message: '不能为空', trigger: 'change' } ], diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeDiscount/vo/ActiveDiscountPayVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeDiscount/vo/ActiveDiscountPayVO.java index b1224241d..be78dbfac 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeDiscount/vo/ActiveDiscountPayVO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeDiscount/vo/ActiveDiscountPayVO.java @@ -9,14 +9,28 @@ import java.math.BigDecimal; public class ActiveDiscountPayVO implements Serializable { //活动id private Integer activeId; + //1满减2折扣 + private String type; //活动名称 private String activeName; //满足金额 private BigDecimal amount; - //折扣 + //总折扣 private BigDecimal discount; + //活动优惠价格 + private BigDecimal activeDiscount; + //折扣 + private double discounts; //可用油品 private String oilId; //适用会员 private String adaptUser; + //参与条件 0:不限制 1:优惠订单不参与 + private String participationCondition; + //优惠券id + private Integer couponId; + //优惠券金额 + private BigDecimal cardFavorableAmount; + //优惠券信息 + private String cardFavorableInfo; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/controller/ActiveExchangeController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/controller/ActiveExchangeController.java index 9ad995779..3b0a853cf 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/controller/ActiveExchangeController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/controller/ActiveExchangeController.java @@ -93,12 +93,12 @@ public class ActiveExchangeController extends BaseController { /** - * test + * 满减折扣优惠券会员等级总优惠 * @param paymentActiveDTO * @return */ - @PostMapping("test") - public ResponseObject paymentActiveVO(@RequestBody PaymentActiveDTO paymentActiveDTO) { + @GetMapping("getPaymentActive") + public ResponseObject getPaymentActive(PaymentActiveDTO paymentActiveDTO) { return getSuccessResult(this.activeExchangeService.paymentActive(paymentActiveDTO)); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/dto/PaymentActiveDTO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/dto/PaymentActiveDTO.java index 96c0d148a..846669931 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/dto/PaymentActiveDTO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/dto/PaymentActiveDTO.java @@ -17,4 +17,6 @@ public class PaymentActiveDTO implements Serializable { private Integer storeId; //会员等级 private Integer mtUserLevel; + //用户id + private Integer userId; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/service/ActiveExchangeService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/service/ActiveExchangeService.java index 637853d55..7112ef183 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/service/ActiveExchangeService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/service/ActiveExchangeService.java @@ -56,4 +56,10 @@ public interface ActiveExchangeService { * @return */ PaymentActiveVO paymentActive(PaymentActiveDTO paymentActiveDTO); + + /** + * 消费有礼后续处理 + * @param paymentActiveDTO + */ + void activeConsumption(PaymentActiveDTO paymentActiveDTO); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/service/impl/ActiveExchangeServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/service/impl/ActiveExchangeServiceImpl.java index c5c1105d7..d7e392f05 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/service/impl/ActiveExchangeServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/service/impl/ActiveExchangeServiceImpl.java @@ -1,5 +1,7 @@ package com.fuint.business.marketingActivity.activeExchange.service.impl; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; @@ -32,8 +34,11 @@ import com.fuint.business.marketingActivity.cardExchange.entity.CardExchangeReco import com.fuint.business.marketingActivity.cardExchange.service.CardExchangeRecordService; import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorable; import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord; +import com.fuint.business.marketingActivity.cardFavorable.mapper.CardFavorableRecordMapper; import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableRecordService; import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableService; +import com.fuint.business.marketingActivity.cardFavorable.vo.CardFavorableRecordVO; +import com.fuint.business.marketingActivity.cardFavorable.vo.CouponVO; import com.fuint.business.marketingActivity.cardValue.entity.CardValue; import com.fuint.business.marketingActivity.cardValue.service.CardValueService; import com.fuint.business.marketingActivity.cardValue.vo.CardValueAppletVO; @@ -41,10 +46,14 @@ import com.fuint.business.marketingActivity.cardValueOrders.entity.CardValueOrde import com.fuint.business.marketingActivity.cardValueOrders.mapper.CardValueOrdersMapper; import com.fuint.business.order.mapper.OilOrderMapper; import com.fuint.business.petrolStationManagement.entity.OilName; +import com.fuint.business.petrolStationManagement.mapper.OilNameMapper; +import com.fuint.business.petrolStationManagement.mapper.OilNumberMapper; import com.fuint.business.petrolStationManagement.service.OilNameService; import com.fuint.business.storeInformation.service.ILJStoreService; import com.fuint.business.userManager.entity.LJUser; +import com.fuint.business.userManager.entity.LJUserGrade; import com.fuint.business.userManager.entity.UserBalance; +import com.fuint.business.userManager.mapper.LJUserGradeMapper; import com.fuint.business.userManager.mapper.LJUserMapper; import com.fuint.business.userManager.service.LJUserGradeService; import com.fuint.business.userManager.service.LJUserService; @@ -53,6 +62,7 @@ import com.fuint.business.userManager.vo.LJUserVo; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -60,9 +70,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.math.RoundingMode; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -82,6 +91,8 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService { @Resource private LJUserGradeService userGradeService; @Resource + private LJUserGradeMapper ljUserGradeMapper; + @Resource private CardFavorableService cardFavorableService; @Resource private ActiveConsumptionService activeConsumptionService; @@ -94,15 +105,17 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService { @Resource private OilOrderMapper oilOrderMapper; @Resource - private LJUserMapper ljUserMapper; - @Resource private UserBalanceService userBalanceService; @Resource private ILJStoreService iljStoreService; @Autowired private LJUserService userService; @Resource - private CardValueOrdersMapper cardValueOrdersMapper; + private CardFavorableRecordMapper cardFavorableRecordMapper; + @Resource + private OilNameMapper oilNameMapper; + @Resource + private OilNumberMapper oilNumberMapper; /** * 分页查询所有 * @param @@ -423,49 +436,311 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService { public PaymentActiveVO paymentActive(PaymentActiveDTO paymentActiveDTO) { PaymentActiveVO paymentActiveVO = new PaymentActiveVO(); Integer storeId = paymentActiveDTO.getStoreId(); - BigDecimal amount = new BigDecimal(0.00); - BigDecimal fullAmount = new BigDecimal(0.00); - BigDecimal a = new BigDecimal(0.1); - BigDecimal b = new BigDecimal(10); + double finalAmount = 0.00; + Integer userId = TokenUtil.getNowAccountInfo().getId(); + //折扣 + List activeDiscountVOList = oilOrderMapper.selectActiveDiscount(storeId,paymentActiveDTO.getAmount(),paymentActiveDTO.getOilId(),paymentActiveDTO.getMtUserLevel()); + //满减 + List activeFuletVOList = oilOrderMapper.selectActiveFule(storeId,paymentActiveDTO.getAmount(),paymentActiveDTO.getOilId(),paymentActiveDTO.getMtUserLevel()); + //优惠券 + paymentActiveDTO.setUserId(userId); + List canUserCardFavorableList = cardFavorableRecordMapper.getCanUserCardFavorableList(paymentActiveDTO); + //会员等级当前优惠力度最大 + + //无限制条件的活动列表 + List resList =new ArrayList<>(); + //无限制条件的优惠券的列表 + ArrayList cardFavorableRecordVOS = new ArrayList<>(); + //优惠券和折扣活动的组合列表 + ArrayList cardAndDisPays = new ArrayList<>(); + //优惠券和满减活动的组合列表 + ArrayList cardAndComPays = new ArrayList<>(); //折扣 - List activeDiscountVOList = oilOrderMapper.selectActiveDiscount(storeId,paymentActiveDTO.getAmount()); if (CollectionUtils.isNotEmpty(activeDiscountVOList)){ for (ActiveDiscountPayVO activeDiscountPayVO : activeDiscountVOList) { - if (activeDiscountPayVO.getOilId().contains(paymentActiveDTO.getOilId().toString()) && - activeDiscountPayVO.getAdaptUser().contains(paymentActiveDTO.getMtUserLevel().toString())){ - if (activeDiscountPayVO.getAmount().multiply(activeDiscountPayVO.getDiscount()).compareTo(amount) > 0){ - amount = paymentActiveDTO.getAmount().subtract(((b.subtract(activeDiscountPayVO.getDiscount())).multiply(paymentActiveDTO.getAmount()).multiply(a))); - paymentActiveVO.setActiveId(activeDiscountPayVO.getActiveId()); - paymentActiveVO.setAmount(amount); - paymentActiveVO.setFavorableAmount((b.subtract(activeDiscountPayVO.getDiscount())).multiply(activeDiscountPayVO.getAmount()).multiply(a)); - } + if (activeDiscountPayVO.getParticipationCondition().equals("0")){ + activeDiscountPayVO.setType("2"); + activeDiscountPayVO.setActiveDiscount(activeDiscountPayVO.getDiscount()); + resList.add(activeDiscountPayVO); } } } //满减 - List activeFuletVOList = oilOrderMapper.selectActiveFule(storeId,paymentActiveDTO.getAmount()); if (CollectionUtils.isNotEmpty(activeFuletVOList)){ for (ActiveDiscountPayVO activeDiscountPayVO : activeFuletVOList) { - if (activeDiscountPayVO.getOilId().contains(paymentActiveDTO.getOilId().toString()) && - activeDiscountPayVO.getAdaptUser().contains(paymentActiveDTO.getMtUserLevel().toString())){ - //如果满足条件 - if ((paymentActiveDTO.getAmount()).compareTo(activeDiscountPayVO.getAmount()) >= 0){ - fullAmount = paymentActiveDTO.getAmount().subtract(activeDiscountPayVO.getDiscount()); - if (amount.compareTo(fullAmount) > 0){ - amount = paymentActiveDTO.getAmount().subtract(activeDiscountPayVO.getDiscount()); - paymentActiveVO.setActiveId(activeDiscountPayVO.getActiveId()); - paymentActiveVO.setAmount(amount); - paymentActiveVO.setFavorableAmount(paymentActiveDTO.getAmount().subtract(fullAmount)); - } - } + if (activeDiscountPayVO.getParticipationCondition().equals("0")){ + activeDiscountPayVO.setActiveDiscount(activeDiscountPayVO.getDiscount()); + activeDiscountPayVO.setType("1"); + resList.add(activeDiscountPayVO); } } } + //优惠券 + if (CollectionUtils.isNotEmpty(canUserCardFavorableList)){ + for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList) { + if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("0")){ + cardFavorableRecordVOS.add(cardFavorableRecordVO); + } + } + } + //折扣+优惠券 + for (ActiveDiscountPayVO activeDiscountPayVO : activeDiscountVOList) { + for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList) { + if(cardFavorableRecordVO.getType().equals("2") && !cardFavorableRecordVO.getExclusiveFunction().equals("0")){ + ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO(); + BeanUtils.copyProperties(activeDiscountPayVO,activeDiscountPayVO1); + activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId()); + double discountAmount = cardFavorableRecordVO.getDiscountAmount(); + BigDecimal bigDecimal = BigDecimal.valueOf(discountAmount); + activeDiscountPayVO1.setActiveDiscount(activeDiscountPayVO1.getDiscount()); + BigDecimal discount = activeDiscountPayVO1.getDiscount(); + activeDiscountPayVO1.setDiscount(bigDecimal.add(discount)); + + activeDiscountPayVO1.setCardFavorableAmount(BigDecimal.valueOf(cardFavorableRecordVO.getDiscountAmount())); + activeDiscountPayVO1.setCardFavorableInfo(cardFavorableRecordVO.getCardFavorableName()); + cardAndDisPays.add(activeDiscountPayVO1); + }else if( !cardFavorableRecordVO.getExclusiveFunction().equals("0")){ + ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO(); + BeanUtils.copyProperties(activeDiscountPayVO,activeDiscountPayVO1); + String[] split = cardFavorableRecordVO.getOilType().split(","); + if(paymentActiveDTO.getOilId().equals(split)){ + activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId()); + double discountAmount = cardFavorableRecordVO.getDiscountAmount(); + activeDiscountPayVO1.setActiveDiscount(activeDiscountPayVO1.getDiscount()); + BigDecimal bigDecimal = BigDecimal.valueOf(discountAmount); + BigDecimal discount = activeDiscountPayVO1.getDiscount(); + activeDiscountPayVO1.setDiscount(bigDecimal.add(discount)); + activeDiscountPayVO1.setCardFavorableAmount(BigDecimal.valueOf(cardFavorableRecordVO.getDiscountAmount())); + activeDiscountPayVO1.setCardFavorableInfo(cardFavorableRecordVO.getCardFavorableName()); + cardAndDisPays.add(activeDiscountPayVO1); + } + } + } + } + //满减+优惠券 + for (ActiveDiscountPayVO activeDiscountPayVO : activeFuletVOList) { + for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList) { + if(cardFavorableRecordVO.getType().equals("2") && !cardFavorableRecordVO.getExclusiveFunction().equals("0")){ + ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO(); + BeanUtils.copyProperties(activeDiscountPayVO,activeDiscountPayVO1); + activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId()); + double discountAmount = cardFavorableRecordVO.getDiscountAmount(); + activeDiscountPayVO1.setActiveDiscount(activeDiscountPayVO1.getDiscount()); + BigDecimal bigDecimal = BigDecimal.valueOf(discountAmount); + BigDecimal discount = activeDiscountPayVO1.getDiscount(); + activeDiscountPayVO1.setDiscount(bigDecimal.add(discount)); + activeDiscountPayVO1.setCardFavorableAmount(BigDecimal.valueOf(cardFavorableRecordVO.getDiscountAmount())); + activeDiscountPayVO1.setCardFavorableInfo(cardFavorableRecordVO.getCardFavorableName()); + cardAndComPays.add(activeDiscountPayVO1); + }else if (!cardFavorableRecordVO.getExclusiveFunction().equals("0")){ + ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO(); + BeanUtils.copyProperties(activeDiscountPayVO,activeDiscountPayVO1); + String[] split = cardFavorableRecordVO.getOilType().split(","); + if(paymentActiveDTO.getOilId().equals(split)){ + activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId()); + double discountAmount = cardFavorableRecordVO.getDiscountAmount(); + activeDiscountPayVO1.setActiveDiscount(activeDiscountPayVO1.getDiscount()); + BigDecimal bigDecimal = BigDecimal.valueOf(discountAmount); + BigDecimal discount = activeDiscountPayVO1.getDiscount(); + activeDiscountPayVO1.setDiscount(bigDecimal.add(discount)); + activeDiscountPayVO1.setCardFavorableAmount(BigDecimal.valueOf(cardFavorableRecordVO.getDiscountAmount())); + activeDiscountPayVO1.setCardFavorableInfo(cardFavorableRecordVO.getCardFavorableName()); + cardAndComPays.add(activeDiscountPayVO1); + } + } + } + + } + for (ActiveDiscountPayVO activeDiscountPayVO : resList) { + double v = activeDiscountPayVO.getDiscount().doubleValue(); + activeDiscountPayVO.setDiscounts(v); + } + for (ActiveDiscountPayVO activeDiscountPayVO : cardAndDisPays) { + double v = activeDiscountPayVO.getDiscount().doubleValue(); + activeDiscountPayVO.setDiscounts(v); + } + for (ActiveDiscountPayVO activeDiscountPayVO : cardAndComPays) { + double v = activeDiscountPayVO.getDiscount().doubleValue(); + activeDiscountPayVO.setDiscounts(v); + } + + ArrayList activeDiscountPayVOS = new ArrayList<>(); + //1.无限制条件的活动和优惠券分别选出一个优惠最大的来 + //活动 + ActiveDiscountPayVO activeDiscountPayVO = resList.stream().max(Comparator.comparingDouble(ActiveDiscountPayVO::getDiscounts)).get(); + activeDiscountPayVOS.add(activeDiscountPayVO); + //优惠券 + CardFavorableRecordVO cardFavorableRecordVO = new CardFavorableRecordVO(); + if (CollectionUtils.isNotEmpty(cardFavorableRecordVOS)){ + cardFavorableRecordVO = cardFavorableRecordVOS.stream().max(Comparator.comparingDouble(CardFavorableRecordVO::getDiscountAmount)).get(); + } + //2.有限制条件的活动和优惠券组合比较出一个优惠最大的来 + //满减+优惠券 + if (CollectionUtils.isNotEmpty(cardAndDisPays)){ + ActiveDiscountPayVO activeDiscountPayVO1 = cardAndDisPays.stream().max(Comparator.comparingDouble(ActiveDiscountPayVO::getDiscounts)).get(); + activeDiscountPayVOS.add(activeDiscountPayVO1); + } + //折扣+优惠券 + if (CollectionUtils.isNotEmpty(cardAndComPays)){ + ActiveDiscountPayVO activeDiscountPayVO2 = cardAndComPays.stream().max(Comparator.comparingDouble(ActiveDiscountPayVO::getDiscounts)).get(); + activeDiscountPayVOS.add(activeDiscountPayVO2); + } + //3.活动和活动+优惠券的组合比较 + if (CollectionUtils.isNotEmpty(activeDiscountPayVOS)){ + ActiveDiscountPayVO activeDiscountPayVO3 = activeDiscountPayVOS.stream().max(Comparator.comparingDouble(ActiveDiscountPayVO::getDiscounts)).get(); + //4. 3和优惠券比较 + if(ObjectUtils.isNotEmpty(activeDiscountPayVO3)){ + finalAmount = activeDiscountPayVO3.getDiscounts(); + 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); + //return paymentActiveVO1; + }else { + PaymentActiveVO paymentActiveVO2 = new PaymentActiveVO(); + //活动或活动+优惠券优惠力度最大 + paymentActiveVO2.setActiveId(activeDiscountPayVO3.getActiveId()); + paymentActiveVO2.setActiveInfo(activeDiscountPayVO3.getActiveName()); + paymentActiveVO2.setType(activeDiscountPayVO3.getType()); + paymentActiveVO2.setActiveFavorableAmount(activeDiscountPayVO3.getActiveDiscount()); + + paymentActiveVO2.setCardFavorableId(activeDiscountPayVO3.getCouponId()); + paymentActiveVO2.setCardFavorableInfo(activeDiscountPayVO3.getCardFavorableInfo()); + paymentActiveVO2.setCardFavorableAmount(activeDiscountPayVO3.getCardFavorableAmount()); + BeanUtils.copyProperties(paymentActiveVO2,paymentActiveVO); + //return paymentActiveVO2; + } + } + } + //会员等级优惠 + + Integer oilId = paymentActiveDTO.getOilId(); + double oilPriceById = oilNumberMapper.getOilPriceById(oilId,storeId); + BigDecimal bigDecimal1 = BigDecimal.valueOf(oilPriceById); + String oilTypebyId = oilNameMapper.getOilTypebyId(oilId); + + String gradeId = ljUserGradeMapper.selectByUserId(paymentActiveDTO.getStoreId(), userId); + if (StringUtils.isNotEmpty(gradeId)){ + LJUserGrade ljUserGrade = ljUserGradeMapper.selectAllByGradeId(gradeId); + if (ObjectUtils.isNotEmpty(ljUserGrade)){ + if (oilTypebyId.equals("汽油")){ + if (ljUserGrade.getGasolineDiscount().equals("无优惠")){ + + }else if (ljUserGrade.getGasolineDiscount().equals("每升优惠")){ + String gasolineRule = ljUserGrade.getGasolineRule(); + List jsonObjects = JSONArray.parseArray(gasolineRule, JSONObject.class); + for (JSONObject jsonObject : jsonObjects) { + Integer gasolineRule1 = jsonObject.getInteger("gasolineRule1"); + BigDecimal bigDecimal = BigDecimal.valueOf(gasolineRule1); + if (paymentActiveDTO.getAmount().compareTo(bigDecimal)>=0){ + //升数 + BigDecimal divide = paymentActiveDTO.getAmount().divide(bigDecimal1,2,RoundingMode.HALF_UP); + Integer gasolineRule3 = jsonObject.getInteger("gasolineRule3"); + BigDecimal bigDecimal2 = BigDecimal.valueOf(gasolineRule3); + BigDecimal multiply = divide.multiply(bigDecimal2); + paymentActiveVO.setMemberFavorableAmount(multiply); + } + } + }else { + String gasolineRule = ljUserGrade.getGasolineRule(); + List jsonObjects = JSONArray.parseArray(gasolineRule, JSONObject.class); + for (JSONObject jsonObject : jsonObjects) { + Integer gasolineRule1 = jsonObject.getInteger("gasolineRule1"); + BigDecimal bigDecimal = BigDecimal.valueOf(gasolineRule1); + if (paymentActiveDTO.getAmount().compareTo(bigDecimal)>=0){ + //升数 + Integer gasolineRule3 = jsonObject.getInteger("gasolineRule2"); + BigDecimal bigDecimal2 = BigDecimal.valueOf(gasolineRule3); + paymentActiveVO.setMemberFavorableAmount(bigDecimal2); + } + } + } + } + if (oilTypebyId.equals("柴油")){ + if (ljUserGrade.getGasolineDiscount().equals("无优惠")){ + + }else if (ljUserGrade.getGasolineDiscount().equals("每升优惠")){ + String gasolineRule = ljUserGrade.getDieselRule(); + List jsonObjects = JSONArray.parseArray(gasolineRule, JSONObject.class); + for (JSONObject jsonObject : jsonObjects) { + Integer gasolineRule1 = jsonObject.getInteger("dieselRule1"); + BigDecimal bigDecimal = BigDecimal.valueOf(gasolineRule1); + if (paymentActiveDTO.getAmount().compareTo(bigDecimal)>=0){ + //升数 + BigDecimal divide = paymentActiveDTO.getAmount().divide(bigDecimal1,2,RoundingMode.HALF_UP); + Integer gasolineRule3 = jsonObject.getInteger("dieselRule3"); + BigDecimal bigDecimal2 = BigDecimal.valueOf(gasolineRule3); + BigDecimal multiply = divide.multiply(bigDecimal2); + paymentActiveVO.setMemberFavorableAmount(multiply); + } + } + }else { + String gasolineRule = ljUserGrade.getDieselRule(); + List jsonObjects = JSONArray.parseArray(gasolineRule, JSONObject.class); + for (JSONObject jsonObject : jsonObjects) { + Integer gasolineRule1 = jsonObject.getInteger("dieselRule1"); + BigDecimal bigDecimal = BigDecimal.valueOf(gasolineRule1); + if (paymentActiveDTO.getAmount().compareTo(bigDecimal)>=0){ + //升数 + Integer gasolineRule3 = jsonObject.getInteger("dieselRule3"); + BigDecimal bigDecimal2 = BigDecimal.valueOf(gasolineRule3); + paymentActiveVO.setMemberFavorableAmount(bigDecimal2); + } + } + } + + } + if (oilTypebyId.equals("天然气")){ + if (ljUserGrade.getGasolineDiscount().equals("无优惠")){ + + }else if (ljUserGrade.getGasolineDiscount().equals("每升优惠")){ + String gasolineRule = ljUserGrade.getNaturalGasRule(); + List jsonObjects = JSONArray.parseArray(gasolineRule, JSONObject.class); + for (JSONObject jsonObject : jsonObjects) { + Integer gasolineRule1 = jsonObject.getInteger("naturalGas1"); + BigDecimal bigDecimal = BigDecimal.valueOf(gasolineRule1); + if (paymentActiveDTO.getAmount().compareTo(bigDecimal)>=0){ + //升数 + BigDecimal divide = paymentActiveDTO.getAmount().divide(bigDecimal1,2,RoundingMode.HALF_UP); + Integer gasolineRule3 = jsonObject.getInteger("naturalGas3"); + BigDecimal bigDecimal2 = BigDecimal.valueOf(gasolineRule3); + BigDecimal multiply = divide.multiply(bigDecimal2); + paymentActiveVO.setMemberFavorableAmount(multiply); + } + } + }else { + String gasolineRule = ljUserGrade.getGasolineRule(); + List jsonObjects = JSONArray.parseArray(gasolineRule, JSONObject.class); + for (JSONObject jsonObject : jsonObjects) { + Integer gasolineRule1 = jsonObject.getInteger("naturalGas1"); + BigDecimal bigDecimal = BigDecimal.valueOf(gasolineRule1); + if (paymentActiveDTO.getAmount().compareTo(bigDecimal)>=0){ + //升数 + Integer gasolineRule3 = jsonObject.getInteger("naturalGas3"); + BigDecimal bigDecimal2 = BigDecimal.valueOf(gasolineRule3); + paymentActiveVO.setMemberFavorableAmount(bigDecimal2); + } + } + } + + } + + } + } + return paymentActiveVO; + } + + @Override + public void activeConsumption(PaymentActiveDTO paymentActiveDTO) { //消费有礼 - List activeConsumptionVOS = oilOrderMapper.selectActiveConsumption(storeId, paymentActiveDTO.getAmount()); + List activeConsumptionVOS = oilOrderMapper.selectActiveConsumption(paymentActiveDTO.getStoreId(), paymentActiveDTO.getAmount()); //连锁店信息 LJUser ljUserVo = userService.queryUserByUserId(TokenUtil.getNowAccountInfo().getId()); - String accountName = TokenUtil.getNowAccountInfo().getAccountName(); Integer storeId1 = paymentActiveDTO.getStoreId(); Integer chainStoreId = iljStoreService.selectStoreByStoreId(storeId1).getChainStoreId(); //用户余额 @@ -519,6 +794,5 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService { } } } - return paymentActiveVO; } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/vo/PaymentActiveVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/vo/PaymentActiveVO.java index cafd9e95d..65c8f2555 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/vo/PaymentActiveVO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeExchange/vo/PaymentActiveVO.java @@ -9,8 +9,18 @@ import java.math.BigDecimal; public class PaymentActiveVO implements Serializable { //活动id private Integer activeId; - //应付金额 - private BigDecimal amount; - //优惠金额 - private BigDecimal favorableAmount; + //活动信息 + private String activeInfo; + //1满减2折扣 + private String type; + //活动优惠金额 + private BigDecimal activeFavorableAmount; + //优惠券id + private Integer cardFavorableId; + //优惠券信息 + private String cardFavorableInfo; + //优惠券金额 + private BigDecimal cardFavorableAmount; + //等级会员优惠金额 + private BigDecimal memberFavorableAmount; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/controller/CardFavorableController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/controller/CardFavorableController.java index 4dca3f2ee..ba70acc03 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/controller/CardFavorableController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/controller/CardFavorableController.java @@ -121,7 +121,7 @@ public class CardFavorableController extends BaseController { /** - *查询我的优惠券接口(小程序端) + *查询我的卡券接口(小程序端) * @param pageNo * @param pageSize * @param cardFavorableDTOS diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/mapper/CardFavorableRecordMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/mapper/CardFavorableRecordMapper.java index 8de67897e..ae8809e49 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/mapper/CardFavorableRecordMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/mapper/CardFavorableRecordMapper.java @@ -3,6 +3,7 @@ package com.fuint.business.marketingActivity.cardFavorable.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.marketingActivity.activeExchange.dto.PaymentActiveDTO; import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableDTOS; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -35,5 +36,7 @@ public interface CardFavorableRecordMapper extends BaseMapper selectAllByCondition(Integer id); IPage selectAllByCondition(@Param("page") Page page, @Param("cardFavorableDTOS") CardFavorableDTOS cardFavorableDTOS); + + List getCanUserCardFavorableList(@Param("paymentActiveDTO") PaymentActiveDTO paymentActiveDTO); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/mapper/xml/CardFavorableRecordMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/mapper/xml/CardFavorableRecordMapper.xml index 3439694e2..06348c748 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/mapper/xml/CardFavorableRecordMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/mapper/xml/CardFavorableRecordMapper.xml @@ -116,5 +116,30 @@ + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/impl/CardFavorableServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/impl/CardFavorableServiceImpl.java index ec02bdb8c..4e64e243f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/impl/CardFavorableServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/service/impl/CardFavorableServiceImpl.java @@ -17,6 +17,7 @@ import com.fuint.business.store.service.StoreService; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -145,9 +146,11 @@ public class CardFavorableServiceImpl extends ServiceImpl { * @param amount * @return */ - List selectActiveDiscount(@Param("storeId") Integer storeId, @Param("amount") BigDecimal amount); + List selectActiveDiscount(@Param("storeId") Integer storeId, @Param("amount") BigDecimal amount,@Param("oilId") Integer oilId,@Param("levelId") Integer levelId); /** * 满减 @@ -98,7 +98,7 @@ public interface OilOrderMapper extends BaseMapper { * @param amount * @return */ - List selectActiveFule(@Param("storeId") Integer storeId, @Param("amount")BigDecimal amount); + List selectActiveFule(@Param("storeId") Integer storeId, @Param("amount")BigDecimal amount,@Param("oilId") Integer oilId,@Param("levelId") Integer levelId); /** * 消费有礼 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/OilOrderMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/OilOrderMapper.xml index 6973c2dd6..ba01d7811 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/OilOrderMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/OilOrderMapper.xml @@ -349,14 +349,22 @@ ad.NAME activeName, ad.diesel_user_level adaptUser, ad.adapt_oil oilId, - adc.amount amount, - adc.discount discount + ad.limit_acount as limitAcount, + ad.participation_condition, + (case ad.store_id when ${storeId} then adc.amount * (1-(adc.discount * 0.1)) + end) as discount FROM active_discount ad - LEFT JOIN active_discount_child adc ON ad.id = adc.active_discount_id - where ad.store_id = #{storeId} - and adc.amount <= #{amount} - and ad.status = 0 + LEFT JOIN active_discount_child adc ON ad.id = adc.active_discount_id + WHERE + ad.store_id = #{storeId} + AND adc.amount #{amount} + and now() BETWEEN ad.active_start_time + AND ad.active_end_time + AND ad.STATUS = 0 + AND concat(',',ad.adapt_oil,',') like concat('%',#{oilId},'%') + AND concat(',',ad.diesel_user_level,',') like concat('%',#{levelId},'%') + GROUP BY ad.id + @@ -34,4 +37,4 @@ - \ No newline at end of file + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/mapper/xml/OilNumberMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/mapper/xml/OilNumberMapper.xml index fb573dd7e..427f13edd 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/mapper/xml/OilNumberMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/mapper/xml/OilNumberMapper.xml @@ -145,4 +145,8 @@ onu.store_id = #{storeId} and onu.state = '启用' + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserGradeMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserGradeMapper.java index 9ba8f9a59..e9b107495 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserGradeMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserGradeMapper.java @@ -18,4 +18,8 @@ public interface LJUserGradeMapper extends BaseMapper { * @return */ public IPage selectUserGradeList(Page page, @Param("userGrade") LJUserGrade userGrade); + + String selectByUserId(@Param("storeId") Integer storeId, @Param("userId") Integer userId); + + LJUserGrade selectAllByGradeId(String gradeId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserGradeMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserGradeMapper.xml index 594a7ec80..705ab712d 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserGradeMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserGradeMapper.xml @@ -12,4 +12,12 @@ order by grade - \ No newline at end of file + + + + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/impl/LJUserGradeServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/impl/LJUserGradeServiceImpl.java index d70954804..3631e9017 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/impl/LJUserGradeServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/service/impl/LJUserGradeServiceImpl.java @@ -129,7 +129,7 @@ public class LJUserGradeServiceImpl extends ServiceImpl