diff --git a/fuintAdmin/src/views/EventMarketing/cardFavorable/index.vue b/fuintAdmin/src/views/EventMarketing/cardFavorable/index.vue index d22243905..48fb81bff 100644 --- a/fuintAdmin/src/views/EventMarketing/cardFavorable/index.vue +++ b/fuintAdmin/src/views/EventMarketing/cardFavorable/index.vue @@ -275,16 +275,15 @@ - - - 满减活动 - 储值卡付款 - 会员等级 - - + + + 满减活动 + 储值卡付款 + 会员等级 + - + @@ -473,6 +472,7 @@ export default { checkDateType: null, checkTime: [], checkOutTime: null, + exclusiveFunctionList: [], exclusiveFunction: null, claimRule: null, count: null, @@ -650,6 +650,7 @@ export default { checkDateType: null, checkTime: [], checkOutTime: null, + exclusiveFunctionList:[], exclusiveFunction: null, claimRule: null, count: null, diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeDiscount/vo/ActiveConsumptionVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeDiscount/vo/ActiveConsumptionVO.java index 6edae8ca8..ce1594ebb 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeDiscount/vo/ActiveConsumptionVO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/activeDiscount/vo/ActiveConsumptionVO.java @@ -25,6 +25,8 @@ public class ActiveConsumptionVO implements Serializable { private double amount; //折扣 private String activeGift; + private String participationAcount; //券id private Integer vouchersId; + private Integer limitAcount; } 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 4de68f71b..ccc1b5b56 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 @@ -7,7 +7,7 @@ import java.math.BigDecimal; @Data public class PaymentActiveDTO implements Serializable { - //支付类型 0:储值卡 1:没用储值卡 + //支付类型 0:储值卡 1:囤油卡 2.其他 private String type; //支付金额 private BigDecimal amount; 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 d5bd5f0ce..da9cc2e46 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 @@ -9,7 +9,9 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumption; import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionChild; +import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionRecord; import com.fuint.business.marketingActivity.activeConsumption.service.ActiveConsumptionChildService; +import com.fuint.business.marketingActivity.activeConsumption.service.ActiveConsumptionRecordService; import com.fuint.business.marketingActivity.activeConsumption.service.ActiveConsumptionService; import com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionAppletVO; import com.fuint.business.marketingActivity.activeDiscount.entity.ActiveDiscount; @@ -595,18 +597,21 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService { List canUserCardFavorableList1 = cardFavorableRecordMapper.getCanUserCardFavorableList(paymentActiveDTO); List canUserCardFavorableList = new ArrayList<>(); //如果是储值卡付款,直接过滤掉 - if (paymentActiveDTO.getType().equals("0")) { + for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList1) { + if (paymentActiveDTO.getType().equals("0") && ObjectUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && !cardFavorableRecordVO.getExclusiveFunction().contains("1")){ + canUserCardFavorableList.add(cardFavorableRecordVO); + }else if(!paymentActiveDTO.getType().equals("0")){ + canUserCardFavorableList.add(cardFavorableRecordVO); + } + } + /* if () { // canUserCardFavorableList = canUserCardFavorableList.stream().filter(cardFavorableRecordVO -> ObjectUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction())) // .filter(cardFavorableRecordVO ->cardFavorableRecordVO.getExclusiveFunction().equals("0")) // .collect(Collectors.toList()); - for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList1) { - if (ObjectUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && !cardFavorableRecordVO.getExclusiveFunction().equals("1")){ - canUserCardFavorableList.add(cardFavorableRecordVO); - }else if (ObjectUtils.isEmpty(cardFavorableRecordVO.getExclusiveFunction())){ - canUserCardFavorableList.add(cardFavorableRecordVO); - } - } - } + + }else { + + }*/ //会员等级当前优惠力度最大 //无限制条件的活动列表 @@ -640,23 +645,26 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService { //优惠券 if (CollectionUtils.isNotEmpty(canUserCardFavorableList)) { for (CardFavorableRecordVO cardFavorableRecordVO : canUserCardFavorableList) { - if (StringUtils.isEmpty(cardFavorableRecordVO.getExclusiveFunction())) { + /*if (StringUtils.isEmpty(cardFavorableRecordVO.getExclusiveFunction())) { cardFavorableRecordVOS.add(cardFavorableRecordVO); } - if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("0")) { + if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().contains("0")) { cardFavorableRecordVOS.add(cardFavorableRecordVO); - } + }*/ boolean flag = false; - if (StringUtils.isNotEmpty(cardFavorableRecordVO.getMembershipLevel()) && StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().equals("2")) { + if (StringUtils.isNotEmpty(cardFavorableRecordVO.getMembershipLevel()) && StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && cardFavorableRecordVO.getExclusiveFunction().contains("2")) { String membershipLevel = cardFavorableRecordVO.getMembershipLevel(); for (String s : membershipLevel.split(",")) { if (paymentActiveDTO.getMtUserLevel().toString().equals(s)){ flag = true; + break; } } if (!flag){ cardFavorableRecordVOS.add(cardFavorableRecordVO); } + }else if (StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && !cardFavorableRecordVO.getExclusiveFunction().contains("2")){ + cardFavorableRecordVOS.add(cardFavorableRecordVO); } } } @@ -665,8 +673,8 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService { if (ObjectUtil.isNotEmpty(activeDiscountPayVO.getParticipationCondition()) && !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().contains("2") + && StringUtils.isNotEmpty(cardFavorableRecordVO.getExclusiveFunction()) && !cardFavorableRecordVO.getExclusiveFunction().contains("0")) { ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO(); BeanUtils.copyProperties(activeDiscountPayVO, activeDiscountPayVO1); activeDiscountPayVO1.setCouponId(cardFavorableRecordVO.getId()); @@ -679,7 +687,7 @@ 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().contains("0")) { ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO(); BeanUtils.copyProperties(activeDiscountPayVO, activeDiscountPayVO1); String[] split = cardFavorableRecordVO.getOilType().split(","); @@ -719,7 +727,7 @@ 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().contains("0")) { ActiveDiscountPayVO activeDiscountPayVO1 = new ActiveDiscountPayVO(); BeanUtils.copyProperties(activeDiscountPayVO, activeDiscountPayVO1); String[] split = cardFavorableRecordVO.getOilType().split(","); @@ -982,18 +990,48 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService { return paymentActiveVO; } + @Resource + private ActiveConsumptionRecordService activeConsumptionRecordService; @Override public void activeConsumption (PaymentActiveDTO paymentActiveDTO) throws Exception { //消费有礼 + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); ArrayList activeConsumptionVOS1 = new ArrayList<>(); - List activeConsumptionVOS = oilOrderMapper.selectActiveConsumption(paymentActiveDTO.getStoreId(), paymentActiveDTO.getAmount()); + List activeConsumptionVOS = oilOrderMapper.selectActiveConsumption(paymentActiveDTO.getStoreId(), paymentActiveDTO.getOrderAmount()); if (CollectionUtils.isNotEmpty(activeConsumptionVOS)) { for (ActiveConsumptionVO activeConsumptionVO : activeConsumptionVOS) { + if (activeConsumptionVO.getParticipationAcount().equals("1")){ + Integer limitAcount = activeConsumptionVO.getLimitAcount(); + //查询这个人参与过几次 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ActiveConsumptionRecord::getActiveConsumptionId,activeConsumptionVO.getActiveId()); + queryWrapper.eq(ActiveConsumptionRecord::getStoreId,paymentActiveDTO.getStoreId()); + if (ObjectUtils.isNotEmpty(paymentActiveDTO.getUserId())){ + queryWrapper.eq(ActiveConsumptionRecord::getUserId,paymentActiveDTO.getUserId()); + }else { + queryWrapper.eq(ActiveConsumptionRecord::getUserId,nowAccountInfo.getId()); + } + + List list = activeConsumptionRecordService.list(queryWrapper); + if (CollectionUtils.isNotEmpty(list) && list.size() >= limitAcount){ + continue; + } + ActiveConsumptionRecord activeConsumptionRecord = new ActiveConsumptionRecord(); + activeConsumptionRecord.setActiveConsumptionId(activeConsumptionVO.getActiveId()); + if (ObjectUtils.isNotEmpty(paymentActiveDTO.getUserId())){ + activeConsumptionRecord.setUserId(paymentActiveDTO.getUserId()); + }else { + activeConsumptionRecord.setUserId(nowAccountInfo.getId()); + } + activeConsumptionRecord.setStoreId(paymentActiveDTO.getStoreId()); + activeConsumptionRecordService.save(activeConsumptionRecord); + } BigDecimal amount = new BigDecimal(activeConsumptionVO.getAmount()); if (ObjectUtils.isNotEmpty(activeConsumptionVO.getMoneyType()) && activeConsumptionVO.getMoneyType().equals("1") && paymentActiveDTO.getOrderAmount() >= activeConsumptionVO.getAmount()) { activeConsumptionVOS1.add(activeConsumptionVO); } + if (ObjectUtils.isNotEmpty(activeConsumptionVO.getMoneyType()) && activeConsumptionVO.getMoneyType().equals("2") && paymentActiveDTO.getAmount().compareTo(amount) > 0) { activeConsumptionVOS1.add(activeConsumptionVO); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/dto/CardFavorableDTO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/dto/CardFavorableDTO.java index 976546b63..af87374c7 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/dto/CardFavorableDTO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/dto/CardFavorableDTO.java @@ -8,6 +8,7 @@ import lombok.Data; import java.io.Serializable; import java.util.Date; +import java.util.List; /** * (CardFavorable)表实体类 @@ -76,6 +77,7 @@ public class CardFavorableDTO extends Model { private Date checkOutTime; //互斥功能 0:满减活动 1:储值卡付款 private String exclusiveFunction; + private List exclusiveFunctionList; //领取规则 0:每人限领一张 1:每人每日限领一张 private String claimRule; //发放数量 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/entity/CardFavorable.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/entity/CardFavorable.java index d3e17c411..ddbc8d431 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/entity/CardFavorable.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/entity/CardFavorable.java @@ -1,6 +1,7 @@ package com.fuint.business.marketingActivity.cardFavorable.entity; import java.util.Date; +import java.util.List; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; @@ -78,6 +79,7 @@ public class CardFavorable extends Model { private Date checkOutTime; //互斥功能 0:满减活动 1:储值卡付款 private String exclusiveFunction; + //领取规则 0:每人限领一张 1:每人每日限领一张 private String claimRule; //发放数量 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/entity/CardFavorableRecord.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/entity/CardFavorableRecord.java index ce12f792d..eb3d3dfee 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/entity/CardFavorableRecord.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/entity/CardFavorableRecord.java @@ -58,6 +58,8 @@ public class CardFavorableRecord extends Model { //更新时间 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8") private Date updateTime; + //优惠类型 0:满减券 1:折扣券 + private String discountType; //优惠金额 private Double discountAmount; //满足金额 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 80dbbb858..021f78330 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 @@ -94,11 +94,12 @@ card_favorables.endTime, card_favorables.createTime, card_favorables.useStatus, - card_favorables.exclusiveFunction + card_favorables.exclusiveFunction, + card_favorables.satisfiedAmount from (SELECT '优惠券' AS couponType, - cf.NAME couponName ,cf.id id,cf.discount_amount couponAmount,cf.card_detail couponContent,cf.instruction instruction, + cf.NAME couponName ,cf.id id,cfr.discount_amount couponAmount,cfr.satisfied_amount satisfiedAmount, cf.card_detail couponContent,cf.instruction instruction, cfr.id cardRecordId, cfr.end_time endTime, cf.exclusive_function exclusiveFunction,cfr.status useStatus,cfr.create_time createTime FROM card_favorable cf @@ -115,7 +116,7 @@ and cf.type != 1 UNION ALL SELECT '兑换券' AS couponType, - ce.NAME couponName, ce.id id, ce.count couponAmount, ce.card_detail couponContent,ce.use_instructions instruction,cer.id cardRecordId, + ce.NAME couponName, ce.id id, ce.count couponAmount, cer.gift_name couponContent,cer.active_id satisfiedAmount,ce.use_instructions instruction,cer.id cardRecordId, cer.out_time endTime, ce.qr_code_link exclusiveFunction,cer.status useStatus,cer.create_time createTime FROM card_exchange_record cer @@ -132,7 +133,7 @@ and cer.store_id = #{cardFavorableDTOS.storeId} UNION ALL SELECT '洗车券' AS couponType, - ce.NAME couponName, ce.id id, ce.count couponAmount, ce.card_detail couponContent, ce.use_instructions instruction, + ce.NAME couponName, ce.id id, ce.count couponAmount, cer.gift_name couponContent,cer.active_id satisfiedAmount, ce.use_instructions instruction, cer.id cardRecordId, cer.out_time endTime, ce.qr_code_link exclusiveFunction,cer.status useStatus,cer.create_time createTime FROM card_exchange_record cer @@ -146,16 +147,7 @@ and cer.status = #{cardFavorableDTOS.useStatus} - and cer.store_id = #{cardFavorableDTOS.storeId} UNION ALL - SELECT - '洗车卡' AS couponType, - ce.NAME couponName, ce.id id, ce.count couponAmount, ce.use_instructions couponContent,ce.use_instructions instruction,cer.id cardRecordId, - cer.out_time endTime, ce.qr_code_link exclusiveFunction,cer.status useStatus,cer.create_time createTime - FROM - card_exchange_record cer - LEFT JOIN card_exchange ce ON cer.card_exchange_id = ce.id - WHERE - cer.mt_user_id = #{cardFavorableDTOS.id} + and cer.store_id = #{cardFavorableDTOS.storeId} and cer.status = #{cardFavorableDTOS.useStatus} @@ -177,13 +169,13 @@ cf.id id, cf.NAME cardFavorableName, cf.type type, - cf.discount_amount discountAmount, + cfr.discount_amount discountAmount, cf.oil_type oilType, - cf.satisfied_amount satisfiedAmount, + cfr.satisfied_amount satisfiedAmount, cf.exclusive_function exclusiveFunction, cf.membership_level membershipLevel, - (case cf.discount_type when'1'then cf.satisfied_amount * (1-(cf.special_discount * ${paymentActiveDTO.amount})) - when '0' then cf.discount_amount + (case cf.discount_type when'1'then cfr.satisfied_amount * (1-(cfr.special_discount * ${paymentActiveDTO.amount})) + when '0' then cfr.discount_amount end) as amount FROM card_favorable cf 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 61a427c52..6de84ba96 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 @@ -83,6 +83,12 @@ public class CardFavorableServiceImpl extends ServiceImpl exclusiveFunctionList = cardFavorableDTO.getExclusiveFunctionList(); + for (String s : exclusiveFunctionList) { + exclusion+=s + ","; + } + cardFavorable.setExclusiveFunction(exclusion); cardFavorable.setMembershipLevel(userLevel); return save(cardFavorable); } @@ -251,6 +257,8 @@ public class CardFavorableServiceImpl extends ServiceImpl exclusiveFunctionList = cardFavorableDTO.getExclusiveFunctionList(); + for (String s : exclusiveFunctionList) { + exclusive += s + ','; + } + cardFavorable.setExclusiveFunction(exclusive); return updateById(cardFavorable); } @@ -305,6 +319,13 @@ public class CardFavorableServiceImpl extends ServiceImpl couponVOS = cardFavorableRecordMapper.selectAllByCondition(page,cardFavorableDTOS); List records = couponVOS.getRecords(); + for (CouponVO record : records) { + if (record.getCouponType().equals("优惠券")){ + record.setCouponContent("满"+record.getSatisfiedAmount()+"减"+record.getCouponAmount()+"元"); + }else { + record.setCouponContent("可兑换:"+record.getCouponContent()); + } + } //有效期 List collect = records.stream().filter(s -> s.getEndTime().getTime() < System.currentTimeMillis()).collect(Collectors.toList()); if (ObjectUtils.isNotEmpty(collect)){ diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/vo/CardFavorableVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/vo/CardFavorableVO.java index ca33fd2d3..245aead3c 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/vo/CardFavorableVO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/vo/CardFavorableVO.java @@ -8,6 +8,7 @@ import lombok.Data; import java.io.Serializable; import java.util.Date; +import java.util.List; /** * (CardFavorable)表实体类 @@ -28,6 +29,7 @@ public class CardFavorableVO extends Model { //是否在线 0:在线 1: 下线 private String isonline; private String[] membershipLevel; + private List exclusiveFunctionList; //优惠券名称 private String name; //卡券类型 0:油品券 1:商品券 2:通用券 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/vo/CouponVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/vo/CouponVO.java index f52cb1853..6292e9d95 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/vo/CouponVO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFavorable/vo/CouponVO.java @@ -18,6 +18,7 @@ public class CouponVO implements Serializable { private String exclusiveFunction; //券金额 private String couponAmount; + private String satisfiedAmount; //券名称 private String couponName; //券内容 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/OilOrderMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/OilOrderMapper.java index 04f182bc5..1a52e4042 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/OilOrderMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/OilOrderMapper.java @@ -110,7 +110,7 @@ public interface OilOrderMapper extends BaseMapper { * @param amount * @return */ - List selectActiveConsumption(@Param("storeId") Integer storeId, @Param("amount")BigDecimal amount); + List selectActiveConsumption(@Param("storeId") Integer storeId, @Param("amount")Double amount); Map orderStatistics( @Param("order") OilOrder order); 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 fc11cd44a..8a055d6ab 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 @@ -475,6 +475,8 @@ ac.participation_condition_money amount, ac.adapt_user_type adaptUserType, ac.money_type moneyType, + ac.participation_acount participationAcount, + ac.limit_acount limitAcount, acc.active_gift activeGift, acc.vouchers_id vouchersId FROM diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java index 090e39392..4c85c012e 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java @@ -27,6 +27,7 @@ import com.fuint.business.marketingActivity.activeDiscount.vo.ActiveDiscountVO; import com.fuint.business.marketingActivity.activeExchange.vo.PaymentActiveVO; import com.fuint.business.marketingActivity.activeFullminus.service.ActiveFullminusService; import com.fuint.business.marketingActivity.activeFullminus.vo.ActiveFullminusVO; +import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord; import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableRecordService; import com.fuint.business.marketingActivity.cardFavorable.service.CardFavorableService; import com.fuint.business.marketingActivity.cardFavorable.vo.CardFavorableVO; @@ -282,6 +283,19 @@ public class OilOrderServiceImpl extends ServiceImpl i if (StringUtils.isNotEmpty(map.get("cardFavorableId"))){ cardFavorableId = Integer.valueOf(map.get("cardFavorableId")); } + + if (ObjectUtils.isNotEmpty(cardFavorableId) && StringUtils.isNotEmpty(map.get("userId"))){ + Integer userId = Integer.valueOf(map.get("userId")); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CardFavorableRecord::getMtUserId, userId); + queryWrapper.eq(CardFavorableRecord::getCardFavorableId, cardFavorableId); + queryWrapper.eq(CardFavorableRecord::getStoreId, storeId); + queryWrapper.eq(CardFavorableRecord::getStatus, 0); + List list = cardFavorableRecordService.list(queryWrapper); + list.get(0).setStatus("1"); + cardFavorableRecordService.updateById(list.get(0)); + } + Integer recordId = null; if (StringUtils.isNotEmpty(map.get("recordId"))){ recordId = Integer.valueOf(map.get("recordId")); @@ -462,7 +476,7 @@ public class OilOrderServiceImpl extends ServiceImpl i if (ObjectUtil.isNotEmpty(jsonObjects.get(i).get("type"))){ order.setActiveType(jsonObjects.get(i).get("type").toString()); } - if (payType.equals("CASH") || payType.equals("credit")){ + if (payType.equals("CASH") || payType.equals("credit") || payType.equals("balance")){ order.setPayTime(new Date()); this.addOilTrack(jsonObjects.get(i),storeId); this.updateCardAndActiveById(storeId,userId,order.getActiveId(),order.getCouponId(),order.getActiveType(),order.getOrderAmount(),order.getPayAmount(), Integer.valueOf(order.getOils())); @@ -1105,6 +1119,7 @@ public class OilOrderServiceImpl extends ServiceImpl i @Override public Map appletPay(Map map) throws Exception { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); String orderNo = map.get("orderNo"); // 支付金额 Double payAmount = Double.valueOf(map.get("payAmount")); @@ -1146,6 +1161,18 @@ public class OilOrderServiceImpl extends ServiceImpl i // 获取油品信息 OilNumber oilNumber = oilNumberService.selectOilNumberByOilName(oilOrder.getOils(), oilOrder.getStoreId()); + if (ObjectUtils.isNotEmpty(cardFavorableId)){ + Integer userId = nowAccountInfo.getId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CardFavorableRecord::getMtUserId, userId); + queryWrapper.eq(CardFavorableRecord::getCardFavorableId, cardFavorableId); + queryWrapper.eq(CardFavorableRecord::getStoreId, nowAccountInfo.getStoreId()); + queryWrapper.eq(CardFavorableRecord::getStatus, 0); + List list = cardFavorableRecordService.list(queryWrapper); + list.get(0).setStatus("1"); + cardFavorableRecordService.updateById(list.get(0)); + } + boolean result = false; Integer userId = oilOrder.getUserId(); @@ -1512,13 +1539,16 @@ public class OilOrderServiceImpl extends ServiceImpl i String refuelMoney1 = balance.getRefuelMoney(); JSONArray objects = JSONArray.parseArray(refuelMoney); JSONArray objects1 = JSONArray.parseArray(refuelMoney1); - for (int i = 0;i implem List accountList = tAccountMapper.getStationmasterByStoreId(tAccount); if (accountList != null && accountList.size() > 0) { - redisTemplate.opsForValue().set(flag,flag,300, TimeUnit.SECONDS); + redisTemplate.opsForValue().set(flag,flag,3000, TimeUnit.SECONDS); // Object codeInRedis = redisTemplate.opsForValue().get(flag); return redisTemplate.hasKey(flag); }else { return false; } - - } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendLoginController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendLoginController.java index 90f8007f7..b717ce374 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendLoginController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendLoginController.java @@ -11,6 +11,7 @@ import com.fuint.business.storeInformation.entity.LJStore; import com.fuint.business.storeInformation.service.ILJStoreService; import com.fuint.business.userManager.entity.LJUser; import com.fuint.business.userManager.service.LJUserService; +import com.fuint.common.annotation.ExpirationCheck; import com.fuint.common.dto.AccountInfo; import com.fuint.common.dto.UserDto; import com.fuint.common.enums.AdminRoleEnum; @@ -118,6 +119,19 @@ public class BackendLoginController extends BaseController { return getFailureResult(201,"请登录终台端!"); } + LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(SysDept::getDeptId,one.getDeptId()); + SysDept one1 = iSysDeptService.getOne(queryWrapper1); + if (ObjectUtils.isNotEmpty(one1) && ObjectUtils.isNotEmpty(one1.getTurnoverType()) && one1.getTurnoverType().equals("2")){ + if (ObjectUtils.isNotEmpty(one1.getTurnoverEndTime())){ + Date date = new Date(); + Date turnoverEndTime = one1.getTurnoverEndTime(); + if (date.compareTo(turnoverEndTime)>0){ + return getFailureResult(201,"请付费后再登录!"); + } + } + } + Boolean captchaVerify = captchaService.checkCodeByUuid(captchaCode, uuid); if (!captchaVerify) { return getFailureResult(201,"图形验证码有误"); @@ -156,6 +170,7 @@ public class BackendLoginController extends BaseController { @ApiOperation(value = "终台登录") @RequestMapping(value="/doLogins", method = RequestMethod.POST) @OperationServiceLog(description = "登录后台系统") + @ExpirationCheck public ResponseObject doLogins(HttpServletRequest request, @RequestBody LoginRequest loginRequest) { String userAgent = request.getHeader("user-agent"); String accountName = loginRequest.getUsername(); @@ -173,11 +188,11 @@ public class BackendLoginController extends BaseController { LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); queryWrapper1.eq(SysDept::getDeptId,one.getDeptId()); SysDept one1 = iSysDeptService.getOne(queryWrapper1); - if (ObjectUtils.isNotEmpty(one1) && ObjectUtils.isNotEmpty(one1.getTurnoverType()) && one1.getTurnoverType().equals("2")){ + if (ObjectUtils.isNotEmpty(one1) && ObjectUtils.isNotEmpty(one1.getTurnoverType()) && one1.getTurnoverType().equals("3")){ if (ObjectUtils.isNotEmpty(one1.getTurnoverEndTime())){ Date date = new Date(); Date turnoverEndTime = one1.getTurnoverEndTime(); - if (date.compareTo(turnoverEndTime)<0){ + if (date.compareTo(turnoverEndTime)>0){ return getFailureResult(201,"请付费后再登录!"); } } diff --git a/gasStation-uni/pages/index/index.vue b/gasStation-uni/pages/index/index.vue index 520d61a69..0ff1dc24f 100644 --- a/gasStation-uni/pages/index/index.vue +++ b/gasStation-uni/pages/index/index.vue @@ -75,13 +75,13 @@ {{item.gbPrice||0}} --> - - - + + + {{item.oilName||''}} - + 会员价 @@ -102,10 +102,10 @@ {{store.name}}{{store.description ? "("+store.description+")" : ""}} - + @@ -159,7 +159,7 @@ export default { data() { return { - isOpen:false, + isOpen: false, chainStoreId: '', indicatorDots: true, autoplay: true, @@ -264,7 +264,7 @@ await this.getUserAuthority(); // await this.getOilType(); } - + await this.getTheJudgmentIsTheSame(); } else { await this.getUserAuthority(); @@ -282,14 +282,14 @@ tabbar }, methods: { - isRecharge(){ + isRecharge() { request({ url: 'business/storeInformation/store/isRecharge', method: 'get', }).then(res => { - if (res.data){ + if (res.data) { this.isOpen = true - }else{ + } else { this.isOpen = false } }) diff --git a/gasStation-uni/pagesRefuel/orderDetail/index.vue b/gasStation-uni/pagesRefuel/orderDetail/index.vue index 40bf4599b..6c6dbd1a4 100644 --- a/gasStation-uni/pagesRefuel/orderDetail/index.vue +++ b/gasStation-uni/pagesRefuel/orderDetail/index.vue @@ -39,11 +39,12 @@ - + 储值卡 - (主卡余额:¥{{user.cardBalance}}) + (主卡余额:¥{{user.cardBalance}}) @@ -51,7 +52,7 @@ - + 囤油卡 @@ -62,13 +63,14 @@ - {{oilCardRedece}}L - + - + 活动优惠 @@ -85,7 +87,7 @@ - + 优惠券优惠 @@ -97,7 +99,7 @@ - + 会员等级优惠 @@ -110,8 +112,9 @@ - - 已为您计算出最大优惠 + + 已为您计算出最大优惠 注:囤油卡不参与任何优惠活动 @@ -161,8 +164,8 @@ // 判断是否有登录token AppToken: uni.getStorageSync("App-Token"), // 是否登录 - ifLogin:false, - gradeDis:"", + ifLogin: false, + gradeDis: "", title: '', value: true, orderNo: "", @@ -175,72 +178,72 @@ oilPrice: 0, // 油品名称 oilName: "", - oilNameId:"", + oilNameId: "", // 油品类型 - oilType:"", + oilType: "", // 油品id - oilId:"", + oilId: "", // 用户信息 - user:{ - cardBalance:0, + user: { + cardBalance: 0, }, // 储值卡升数 - refuelBalance:0, + refuelBalance: 0, // 会员等级信息 - userGrade:{}, - balanceRedece:0, - oilCardRedece:0, - gradeRedece:0, - fullRedece:0, - couponRedece:0, + userGrade: {}, + balanceRedece: 0, + oilCardRedece: 0, + gradeRedece: 0, + fullRedece: 0, + couponRedece: 0, // 消费储值卡后的金额(未扣除优惠金额前的金额) - deductAmount:0, + deductAmount: 0, // 囤油卡信息 - refuelMoney:[], - refuelMoneyAfter:[], + refuelMoney: [], + refuelMoneyAfter: [], // 会员等级优惠信息 - gradeDiscount:[], + gradeDiscount: [], // 优惠券优惠信息 - couponDiscount:[], + couponDiscount: [], // 满减优惠信息 - fullReduceDiscount:[], + fullReduceDiscount: [], // 支付金额 - payAmount:0, + payAmount: 0, // 调起支付所需的数据 - orderInfo:{}, + orderInfo: {}, // 是否使用囤油卡 - isOilStorageCard:false, + isOilStorageCard: false, // 是否使用储值卡 - isStoreValueCard:false, + isStoreValueCard: false, // 是否存在可使用的等级优惠 - isGradePreferential:false, + isGradePreferential: false, // 是否存在可使用的满减或折扣优惠 - isFullPreferential:false, + isFullPreferential: false, // 是否存在可使用的优惠券 - isCoupons:false, - transferDTO:{ - type:0, - amount:0, - oilId:"", - mtUserLevel:"", - storeId:uni.getStorageSync("storeId") + isCoupons: false, + transferDTO: { + type: 0, + amount: 0, + oilId: "", + mtUserLevel: "", + storeId: uni.getStorageSync("storeId") }, - fixingLevel:{}, - isUseChildCard:false, - cardsList:[], + fixingLevel: {}, + isUseChildCard: false, + cardsList: [], query: { storeId: uni.getStorageSync("storeId"), couponType: '', useStatus: 0, pageNo: 1, pageSize: 10 - }, - checkBalance:false, - checkOilCard:false, - checkFull:false, - checkCoupon:false, - checkGrade:false, - preferentialData:{ + }, + checkBalance: false, + checkOilCard: false, + checkFull: false, + checkCoupon: false, + checkGrade: false, + preferentialData: { activeFavorableAmount: "", activeId: "", activeInfo: "", @@ -251,7 +254,7 @@ type: "", }, // 是否为固定等级会员 - isFixingLevel:false, + isFixingLevel: false, } }, onLoad(e) { @@ -266,9 +269,9 @@ }, methods: { // 选择囤油卡 - changeOilCard(val){ + changeOilCard(val) { this.checkOilCard = val - if (val){ + if (val) { this.chooseRefuelMoney() this.fullRedece = 0; this.gradeRedece = 0; @@ -283,83 +286,89 @@ memberFavorableAmount: "", type: "", }; - }else{ + } else { this.oilCardRedece = 0 - if (!this.isFixingLevel){ + if (!this.isFixingLevel) { this.getPaymentPreferential(this.user.gradeId) } } }, - + // 支付接口 - payment(){ - if (this.isUseChildCard){ - if(this.balanceRedece>0){ + payment() { + if (this.isUseChildCard) { + if (this.balanceRedece > 0) { this.isUseChildCard = true - }else{ + } else { this.isUseChildCard = false } } let map = { - orderNo : this.orderNo, - payAmount : this.payAmount, + orderNo: this.orderNo, + payAmount: this.payAmount, // payAmount : "0.01", - discountAmount : (this.fullRedece*100+this.gradeRedece*100+this.couponRedece*100)/100, - oilCardAmount : JSON.stringify(this.refuelMoneyAfter), - oilCardLiters : this.oilCardRedece, - balanceAmount : this.balanceRedece, - isOilStorageCard : this.isOilStorageCard, - tankId : uni.getStorageSync("tankId"), + discountAmount: (this.fullRedece * 100 + this.gradeRedece * 100 + this.couponRedece * 100) / 100, + oilCardAmount: JSON.stringify(this.refuelMoneyAfter), + oilCardLiters: this.oilCardRedece, + balanceAmount: this.balanceRedece, + isOilStorageCard: this.isOilStorageCard, + tankId: uni.getStorageSync("tankId"), // tankId : 6, - isUseChildCard:this.isUseChildCard, - activeId:this.preferentialData.activeId, - cardFavorableId:this.preferentialData.cardFavorableId, - recordId:this.preferentialData.recordId, - type:this.preferentialData.type, - balanceAmountSale:this.balanceRedece, - oilCardAmountSale:this.oilCardRedece, - ifLogin:this.ifLogin + isUseChildCard: this.isUseChildCard, + activeId: this.preferentialData.activeId, + cardFavorableId: this.preferentialData.cardFavorableId, + recordId: this.preferentialData.recordId, + type: this.preferentialData.type, + balanceAmountSale: this.balanceRedece, + oilCardAmountSale: this.oilCardRedece, + ifLogin: this.ifLogin }; let _this = this; request({ - url: "business/oilOrder/appletPay", - method: 'post', - data: map, + url: "business/oilOrder/appletPay", + method: 'post', + data: map, }).then(res => { let payProvider = "wxpay" - if (_this.appltType== "WECHAT"){ + if (_this.appltType == "WECHAT") { payProvider = "wxpay" - }else{ + } else { payProvider = "alipay" } - if(res.data.error){ + if (res.data.error) { request({ url: "/business/allOrderInfo/orderStatus", method: 'post', - data: {"orderNo":_this.orderNo,"status":"payFail"}, - }).then((ress)=>{}) + data: { + "orderNo": _this.orderNo, + "status": "payFail" + }, + }).then((ress) => {}) uni.showToast({ - title:res.data.error, - icon:"none" + title: res.data.error, + icon: "none" }) // _this.goBack() return; } - if(res.data.code=="error"){ + if (res.data.code == "error") { request({ url: "/business/allOrderInfo/orderStatus", method: 'post', - data: {"orderNo":_this.orderNo,"status":"payFail"}, - }).then((ress)=>{}) + data: { + "orderNo": _this.orderNo, + "status": "payFail" + }, + }).then((ress) => {}) uni.showToast({ // title:res.data.msg, - title:"支付失败,请联系商家", - icon:"none" + title: "支付失败,请联系商家", + icon: "none" }) // _this.goBack() return; } - if(res.data.success == "ok"){ + if (res.data.success == "ok") { // _this.preferentialData.storeId = _this.oilOrder.storeId // _this.preferentialData.orderAmount = _this.oilOrder.orderAmount // _this.preferentialData.oilId = _this.oilOrder.oils @@ -373,17 +382,17 @@ // url: '/pagesRefuel/orderSuccess/index' // }) uni.navigateTo({ - url: '/pagesRefuel/orderSuccess/index?orderNo='+_this.orderNo, + url: '/pagesRefuel/orderSuccess/index?orderNo=' + _this.orderNo, }) return; } - if(res.data.resultMsg == "商户订单号重复"){ + if (res.data.resultMsg == "商户订单号重复") { uni.showToast({ - title:"商户订单号重复,请重新选择订单信息进行支付!", - icon:"none" + title: "商户订单号重复,请重新选择订单信息进行支付!", + icon: "none" }) } - if (res.data.data.reservedPayInfo){ + if (res.data.data.reservedPayInfo) { _this.orderInfo = JSON.parse(res.data.data.reservedPayInfo); uni.requestPayment({ // 微信支付provider: 'wxpay' 支付宝支付 'alipay' @@ -398,7 +407,7 @@ signType: 'MD5', // 支付签名 paySign: _this.orderInfo.paySign, - success: function (res) { + success: function(res) { console.log('success'); // 支付成功后调用修改使用后的优惠券情况 // _this.preferentialData.storeId = _this.oilOrder.storeId @@ -415,29 +424,35 @@ // uni.reLaunch({ // url: '/pagesRefuel/orderSuccess/index' // }) - + uni.navigateTo({ - url: '/pagesRefuel/orderSuccess/index?orderNo='+_this.orderNo, + url: '/pagesRefuel/orderSuccess/index?orderNo=' + _this + .orderNo, }) }, - fail: function (err) { + fail: function(err) { request({ url: "/business/allOrderInfo/orderStatus", method: 'post', - data: {"orderNo":res.data.data.orderNo,"status":"payFail"}, - }).then((res)=>{ + data: { + "orderNo": res.data.data.orderNo, + "status": "payFail" + }, + }).then((res) => { uni.showToast({ - title:"支付失败!", - icon:"error" + title: "支付失败!", + icon: "error" }) }) - console.log('fail:',err); + console.log('fail:', err); } }); } - if (_this.appltType== "ALIPAY") { - my.tradePay({ tradeNO: res.data.data.reservedTransactionId }, function(resp){ - if(resp.resultCode == '9000'){ + if (_this.appltType == "ALIPAY") { + my.tradePay({ + tradeNO: res.data.data.reservedTransactionId + }, function(resp) { + if (resp.resultCode == '9000') { console.log("支付成功") // 支付成功后调用修改使用后的优惠券情况 // _this.preferentialData.storeId = _this.oilOrder.storeId @@ -452,47 +467,51 @@ // uni.reLaunch({ // url: '/pagesRefuel/orderSuccess/index' // }) - + uni.navigateTo({ - url: '/pagesRefuel/orderSuccess/index?orderNo='+_this.orderNo, + url: '/pagesRefuel/orderSuccess/index?orderNo=' + _this + .orderNo, }) - }else{ + } else { request({ url: "/business/allOrderInfo/orderStatus", method: 'post', - data: {"orderNo":res.data.data.orderNo,"status":"payFail"}, - }).then((res)=>{ + data: { + "orderNo": res.data.data.orderNo, + "status": "payFail" + }, + }).then((res) => { uni.showToast({ - title:"支付失败!", - icon:"error" + title: "支付失败!", + icon: "error" }) }) - console.log('支付失败,'+resp.resultCode); + console.log('支付失败,' + resp.resultCode); } }); } }) }, - + // 查看是否有可使用的囤油卡 - chooseRefuelMoney(){ + chooseRefuelMoney() { console.log("oilCard"); let falg = false; - for(let i = 0;i0 ){ + for (let i = 0; i < this.refuelMoney.length; i++) { + if (this.refuelMoney[i].oilType == this.oilNameId) { + if (this.refuelMoney[i].refuelMoney > 0) { falg = true } this.refuelBalance = this.refuelMoney[i].refuelMoney - if (this.refuelMoney[i].refuelMoney>0){ + if (this.refuelMoney[i].refuelMoney > 0) { this.isOilStorageCard = true } - if (this.refuelMoney[i].refuelMoney >= this.oilOrder.oilNum){ + if (this.refuelMoney[i].refuelMoney >= this.oilOrder.oilNum) { this.oilCardRedece = this.oilOrder.oilNum this.refuelMoneyAfter[i].refuelMoney = this.refuelMoney[i].refuelMoney - this.oilOrder.oilNum this.payAmount = 0 this.checkOilCard = true - }else{ + } else { this.oilCardRedece = this.refuelMoney[i].refuelMoney this.refuelMoneyAfter[i].refuelMoney = 0 if (falg) { @@ -506,195 +525,252 @@ // this.chooseCardBalance(0) // this.chooseGrade(this.user.id,this.user.gradeId) } - if (this.oilCardRedece==0){ - if (!this.isFixingLevel){ + if (this.oilCardRedece == 0) { + if (!this.isFixingLevel) { this.chooseCardBalance(0) this.getPaymentPreferential(this.user.gradeId) - }else{ + } else { this.chooseCardBalance(0) } } }, // 查看是否有可使用的储值卡金额 - chooseCardBalance(val){ + chooseCardBalance(val) { console.log("balance"); - if (this.user.cardBalance>0) { + if (this.user.cardBalance > 0) { this.isStoreValueCard = true; if (val == 0) { // 没有使用囤油卡 - if (this.user.cardBalance >= (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece)){ - this.balanceRedece = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece).toFixed(2) + if (this.user.cardBalance >= (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - + this.gradeRedece)) { + this.balanceRedece = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this + .gradeRedece).toFixed(2) } else { this.balanceRedece = this.user.cardBalance - this.deductAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece-this.balanceRedece).toFixed(2) - this.payAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece-this.balanceRedece).toFixed(2) - console.log(this.oilOrder.orderAmount, this.fullRedece, this.couponRedece, this.gradeRedece,this.balanceRedece,111); + this.deductAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this + .gradeRedece - this.balanceRedece).toFixed(2) + this.payAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this + .gradeRedece - this.balanceRedece).toFixed(2) + console.log(this.oilOrder.orderAmount, this.fullRedece, this.couponRedece, this.gradeRedece, + this.balanceRedece, 111); } - }else{ + } else { // 使用囤油卡 // 扣除囤油卡金额后需要支付的金额 let residueAmount = 0 - if(this.oilCardRedece>0){ + if (this.oilCardRedece > 0) { residueAmount = ((this.oilOrder.oilNum - this.oilCardRedece) * this.oilPrice).toFixed(2) - }else{ + } else { residueAmount = this.oilOrder.orderAmount } - if (this.user.cardBalance >= residueAmount){ + if (this.user.cardBalance >= residueAmount) { this.balanceRedece = residueAmount } else { this.balanceRedece = this.user.cardBalance - this.payAmount = ((residueAmount*100).toFixed(0) - (this.balanceRedece*100).toFixed(0))/100 + this.payAmount = ((residueAmount * 100).toFixed(0) - (this.balanceRedece * 100).toFixed(0)) / + 100 } } - }else{ - this.deductAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece).toFixed(2) - this.payAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece).toFixed(2) - console.log(this.oilOrder.orderAmount, this.fullRedece, this.couponRedece, this.gradeRedece,this.balanceRedece,222); + } else { + this.deductAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this + .gradeRedece).toFixed(2) + this.payAmount = (this.oilOrder.orderAmount - this.fullRedece - this.couponRedece - this.gradeRedece) + .toFixed(2) + console.log(this.oilOrder.orderAmount, this.fullRedece, this.couponRedece, this.gradeRedece, this + .balanceRedece, 222); } }, // 查看是否有可使用的会员等级优惠 - chooseGrade(userId,gradeId){ + chooseGrade(userId, gradeId) { console.log("userGrade"); let that = this; that.isFixingLevel = false request({ url: "business/userManager/userGrade/isUse", method: 'post', - data:{userId:userId,gradeId:gradeId,storeId:that.oilOrder.storeId} + data: { + userId: userId, + gradeId: gradeId, + storeId: that.oilOrder.storeId + } }).then((res) => { - if (res.data){ - if (res.data.fixingLevel){ - if (res.data.fixingLevel.discountType== "自定义优惠"){ - if (that.oilType == "汽油"){ + if (res.data) { + if (res.data.fixingLevel) { + if (res.data.fixingLevel.discountType == "自定义优惠") { + if (that.oilType == "汽油") { // 将数组按照金额从小到大排序 - let gasolineRule = JSON.parse(res.data.fixingLevel.gasolineRule).sort((a,b) => a.gasolineRule1 - b.gasolineRule1); - if (res.data.fixingLevel.gasolineDiscount == "满减优惠"){ - if (gasolineRule.length > 1){ - for (let i = 1; i= gasolineRule[gasolineRule.length-1].gasolineRule1){ - that.gradeRedece = gasolineRule[gasolineRule.length-1].gasolineRule2 + let gasolineRule = JSON.parse(res.data.fixingLevel.gasolineRule).sort((a, b) => + a.gasolineRule1 - b.gasolineRule1); + if (res.data.fixingLevel.gasolineDiscount == "满减优惠") { + if (gasolineRule.length > 1) { + for (let i = 1; i < gasolineRule.length; i++) { + if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length - + 1].gasolineRule1) { + that.gradeRedece = gasolineRule[gasolineRule.length - 1] + .gasolineRule2 that.isGradePreferential = true break; } - if (that.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1 && that.oilOrder.orderAmount < gasolineRule[i].gasolineRule1) { + if (that.oilOrder.orderAmount >= gasolineRule[i - 1] + .gasolineRule1 && that.oilOrder.orderAmount < gasolineRule[i] + .gasolineRule1) { that.gradeRedece = gasolineRule[i - 1].gasolineRule2 that.isGradePreferential = true } } - }else{ - if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length-1].gasolineRule1){ - that.gradeRedece = gasolineRule[gasolineRule.length-1].gasolineRule2 + } else { + if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length - 1] + .gasolineRule1) { + that.gradeRedece = gasolineRule[gasolineRule.length - 1] + .gasolineRule2 that.isGradePreferential = true } } } - if (res.data.fixingLevel.gasolineDiscount == "每升优惠"){ - if (gasolineRule.length > 1){ - for (let i = 1; i= gasolineRule[gasolineRule.length-1].gasolineRule1){ + if (res.data.fixingLevel.gasolineDiscount == "每升优惠") { + if (gasolineRule.length > 1) { + for (let i = 1; i < gasolineRule.length; i++) { + if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length - + 1].gasolineRule1) { // 计算升数 和 优惠金额 - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * gasolineRule[gasolineRule.length-1].gasolineRule3).toFixed(2) + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + gasolineRule[gasolineRule.length - 1].gasolineRule3) + .toFixed(2) that.isGradePreferential = true break; } - if (that.oilOrder.orderAmount >= gasolineRule[i - 1].gasolineRule1 && that.oilOrder.orderAmount < gasolineRule[i].gasolineRule1) { - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * gasolineRule[i - 1].gasolineRule3).toFixed(2) + if (that.oilOrder.orderAmount >= gasolineRule[i - 1] + .gasolineRule1 && that.oilOrder.orderAmount < gasolineRule[i] + .gasolineRule1) { + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + gasolineRule[i - 1].gasolineRule3).toFixed(2) that.isGradePreferential = true } } - }else{ - if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length-1].gasolineRule1){ - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * gasolineRule[gasolineRule.length-1].gasolineRule3).toFixed(2) + } else { + if (that.oilOrder.orderAmount >= gasolineRule[gasolineRule.length - 1] + .gasolineRule1) { + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + gasolineRule[gasolineRule.length - 1].gasolineRule3) + .toFixed(2) that.isGradePreferential = true } } } } - if (that.oilType == "柴油"){ + if (that.oilType == "柴油") { // 将数组按照金额从小到大排序 - let dieselRule = JSON.parse(res.data.fixingLevel.dieselRule).sort((a,b) => a.dieselRule1 - b.dieselRule1); - if (res.data.fixingLevel.dieselDiscount == "满减优惠"){ - if (dieselRule.length > 1){ - for (let i = 1; i= dieselRule[dieselRule.length-1].dieselRule1){ - that.gradeRedece = dieselRule[dieselRule.length-1].dieselRule2 + let dieselRule = JSON.parse(res.data.fixingLevel.dieselRule).sort((a, b) => a + .dieselRule1 - b.dieselRule1); + if (res.data.fixingLevel.dieselDiscount == "满减优惠") { + if (dieselRule.length > 1) { + for (let i = 1; i < dieselRule.length; i++) { + if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length - 1] + .dieselRule1) { + that.gradeRedece = dieselRule[dieselRule.length - 1] + .dieselRule2 that.isGradePreferential = true break; } - if (that.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && that.oilOrder.orderAmount < dieselRule[i].dieselRule1) { + if (that.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && + that.oilOrder.orderAmount < dieselRule[i].dieselRule1) { that.gradeRedece = dieselRule[i - 1].dieselRule2 that.isGradePreferential = true } } - }else{ - if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length-1].dieselRule1){ - that.gradeRedece = dieselRule[dieselRule.length-1].dieselRule2 + } else { + if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length - 1] + .dieselRule1) { + that.gradeRedece = dieselRule[dieselRule.length - 1].dieselRule2 that.isGradePreferential = true } } } - if (res.data.fixingLevel.dieselDiscount == "每升优惠"){ - if (dieselRule.length > 1){ - for (let i = 1; i= dieselRule[dieselRule.length-1].dieselRule1){ + if (res.data.fixingLevel.dieselDiscount == "每升优惠") { + if (dieselRule.length > 1) { + for (let i = 1; i < dieselRule.length; i++) { + if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length - 1] + .dieselRule1) { // 计算升数 和 优惠金额 - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * dieselRule[dieselRule.length-1].dieselRule3).toFixed(2) + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + dieselRule[dieselRule.length - 1].dieselRule3).toFixed( + 2) that.isGradePreferential = true break; } - if (that.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && that.oilOrder.orderAmount < dieselRule[i].dieselRule1) { - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * dieselRule[i - 1].dieselRule3).toFixed(2) + if (that.oilOrder.orderAmount >= dieselRule[i - 1].dieselRule1 && + that.oilOrder.orderAmount < dieselRule[i].dieselRule1) { + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + dieselRule[i - 1].dieselRule3).toFixed(2) that.isGradePreferential = true } } - }else{ - if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length-1].dieselRule1){ - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * dieselRule[dieselRule.length-1].dieselRule3).toFixed(2) + } else { + if (that.oilOrder.orderAmount >= dieselRule[dieselRule.length - 1] + .dieselRule1) { + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + dieselRule[dieselRule.length - 1].dieselRule3).toFixed(2) that.isGradePreferential = true } } } } - if (that.oilType == "天然气"){ + if (that.oilType == "天然气") { // 将数组按照金额从小到大排序 - let naturalGasRule = JSON.parse(res.data.fixingLevel.naturalGasRule).sort((a,b) => a.naturalGasRule1 - b.naturalGasRule1); - if (res.data.fixingLevel.naturalGasDiscount == "满减优惠"){ - if (naturalGasRule.length > 1){ - for (let i = 1; i= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){ - that.gradeRedece = naturalGasRule[naturalGasRule.length-1].naturalGasRule2 + let naturalGasRule = JSON.parse(res.data.fixingLevel.naturalGasRule).sort((a, + b) => a.naturalGasRule1 - b.naturalGasRule1); + if (res.data.fixingLevel.naturalGasDiscount == "满减优惠") { + if (naturalGasRule.length > 1) { + for (let i = 1; i < naturalGasRule.length; i++) { + if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule + .length - 1].naturalGasRule1) { + that.gradeRedece = naturalGasRule[naturalGasRule.length - 1] + .naturalGasRule2 that.isGradePreferential = true break; } - if (that.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1 && that.oilOrder.orderAmount < naturalGasRule[i].naturalGasRule1) { + if (that.oilOrder.orderAmount >= naturalGasRule[i - 1] + .naturalGasRule1 && that.oilOrder.orderAmount < naturalGasRule[ + i].naturalGasRule1) { that.gradeRedece = naturalGasRule[i - 1].naturalGasRule2 that.isGradePreferential = true } } - }else{ - if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){ - that.gradeRedece = naturalGasRule[naturalGasRule.length-1].naturalGasRule2 + } else { + if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length - + 1].naturalGasRule1) { + that.gradeRedece = naturalGasRule[naturalGasRule.length - 1] + .naturalGasRule2 that.isGradePreferential = true } } } - if (res.data.fixingLevel.naturalGasDiscount == "每升优惠"){ - if (naturalGasRule.length > 1){ - for (let i = 1; i= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){ + if (res.data.fixingLevel.naturalGasDiscount == "每升优惠") { + if (naturalGasRule.length > 1) { + for (let i = 1; i < naturalGasRule.length; i++) { + if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule + .length - 1].naturalGasRule1) { // 计算升数 和 优惠金额 - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * naturalGasRule[naturalGasRule.length-1].naturalGasRule3).toFixed(2) + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + naturalGasRule[naturalGasRule.length - 1] + .naturalGasRule3).toFixed(2) that.isGradePreferential = true break; } - if (that.oilOrder.orderAmount >= naturalGasRule[i - 1].naturalGasRule1 && that.oilOrder.orderAmount < naturalGasRule[i].naturalGasRule1) { - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * naturalGasRule[i - 1].naturalGasRule3).toFixed(2) + if (that.oilOrder.orderAmount >= naturalGasRule[i - 1] + .naturalGasRule1 && that.oilOrder.orderAmount < naturalGasRule[ + i].naturalGasRule1) { + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + naturalGasRule[i - 1].naturalGasRule3).toFixed(2) that.isGradePreferential = true } } - }else{ - if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length-1].naturalGasRule1){ - that.gradeRedece = (that.oilOrder.orderAmount/that.oilPrice * naturalGasRule[naturalGasRule.length-1].naturalGasRule3).toFixed(2) + } else { + if (that.oilOrder.orderAmount >= naturalGasRule[naturalGasRule.length - + 1].naturalGasRule1) { + that.gradeRedece = (that.oilOrder.orderAmount / that.oilPrice * + naturalGasRule[naturalGasRule.length - 1].naturalGasRule3) + .toFixed(2) that.isGradePreferential = true } } @@ -706,12 +782,12 @@ // that.gradeRedece = 0 // } } - + } }) }, // 查看是否有可使用的优惠活动 - chooseFullOrCoupon(){ + chooseFullOrCoupon() { console.log("full"); this.transferDTO.amount = this.deductAmount this.transferDTO.mtUserLevel = this.userGrade.id @@ -720,9 +796,9 @@ request({ url: "business/marketingActivity/activeExchange/test", method: 'post', - data:_this.transferDTO, + data: _this.transferDTO, }).then((res) => { - if (res.data.amount>0){ + if (res.data.amount > 0) { _this.payAmount = res.data.amount - _this.gradeRedece _this.fullRedece = res.data.favorableAmount _this.isFullPreferential = true @@ -730,7 +806,7 @@ }) }, // 查看是否有可使用的优惠券 - chooseCoupons(){ + chooseCoupons() { console.log("coupons"); request({ url: 'business/marketingActivity/cardFavorable/applet', @@ -740,46 +816,49 @@ if (res.data.records) { console.log(res.data.records); this.cardsList = res.data.records - if (this.cardsList.length>0){ + if (this.cardsList.length > 0) { this.couponRedece = this.cardsList[0].couponAmount } } }) }, - + // 计算用户应付金额 - countPayMent(){ + countPayMent() { this.payAmount = this.deductAmount; // console.log("111",this.deductAmount, this.gradeRedece, this.fullRedece, this.couponRedece); }, - + // 根据店铺id查询用户信息 - async getUser(id){ + async getUser(id) { let _this = this; request({ url: "business/userManager/user/storeUser", method: 'post', - data:{storeId:_this.oilOrder.storeId,userId:id} + data: { + storeId: _this.oilOrder.storeId, + userId: id + } }).then((res) => { - if (res.data.isUseChild=='yes'){ + if (res.data.isUseChild == 'yes') { _this.isUseChildCard = true - }else{ + } else { _this.isUseChildCard = false } _this.user = res.data.userVo; _this.user = res.data.userVo; - _this.chooseGrade(_this.user.id,_this.user.gradeId); - if (res.data.userVo.refuelMoney && res.data.userVo.refuelMoney!='null'){ + _this.chooseGrade(_this.user.id, _this.user.gradeId); + if (res.data.userVo.refuelMoney && res.data.userVo.refuelMoney != 'null') { _this.refuelMoney = JSON.parse(res.data.userVo.refuelMoney) _this.refuelMoneyAfter = JSON.parse(res.data.userVo.refuelMoney) _this.chooseRefuelMoney() - }else{ - - if (!this.isFixingLevel){ + } else { + + if (!this.isFixingLevel) { _this.chooseCardBalance(0) - console.log(this.balanceRedece,154); + console.log(this.balanceRedece, 154); _this.getPaymentPreferential(this.user.gradeId) - }else{ + } else { _this.chooseCardBalance(0) } } @@ -787,11 +866,11 @@ // _this.chooseGrade(res.data.userVo.id,res.data.userVo.gradeId) }) }, - getPaymentPreferential(gradeId){ + getPaymentPreferential(gradeId) { let type = 0; - if (this.balanceRedece==0){ - type = 1 - }else{ + if (this.balanceRedece == 0) { + type = 2 + } else { type = 0 } let map = { @@ -811,20 +890,21 @@ request({ url: "business/marketingActivity/activeExchange/getPaymentActive", method: 'get', - params:map, + params: map, }).then((res) => { this.preferentialData = res.data - if (res.data.memberFavorableAmount){ + if (res.data.memberFavorableAmount) { this.gradeRedece = res.data.memberFavorableAmount } - if (res.data.cardFavorableAmount){ + if (res.data.cardFavorableAmount) { this.couponRedece = res.data.cardFavorableAmount } - if (res.data.activeFavorableAmount){ + if (res.data.activeFavorableAmount) { this.fullRedece = res.data.activeFavorableAmount } - console.log(this.gradeRedece,this.couponRedece,this.fullRedece,res.data.memberFavorableAmount,"2231"); - + console.log(this.gradeRedece, this.couponRedece, this.fullRedece, res.data + .memberFavorableAmount, "2231"); + this.chooseCardBalance(0) // this.payAmount = (this.payAmount - this.fullRedece - this.couponRedece - this.gradeRedece).toFixed(2) }) @@ -840,7 +920,7 @@ orderNo: _this.orderNo }, }).then((res) => { - if(res.data){ + if (res.data) { // console.log(res); _this.oilOrder = res.data // _this.getStaffList(res.data.staffId) @@ -851,7 +931,7 @@ if (_this.AppToken) { _this.getUser(res.data.userId) _this.ifLogin = true - }else{ + } else { _this.ifLogin = false _this.payAmount = _this.oilOrder.orderAmount } @@ -908,7 +988,7 @@