diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/entity/CardCoupon.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/entity/CardCoupon.java index 7f9d3bea2..33da5ad28 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/entity/CardCoupon.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/entity/CardCoupon.java @@ -66,6 +66,8 @@ public class CardCoupon extends Model { private Integer zkStartAmount; //折扣卷满多少元的终 private Integer zkEndAmount; + //折扣最大优惠金额 + private Double zkMaxAmount; //适用会员等级 可多选 private String membershipLevel; //生效日期类型1.领取后多少天内有效 2指定具体使用日期 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml index 6550b31ef..d3ee783ef 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponUserMapper.xml @@ -8,7 +8,7 @@ main.mt_user_id AS mtUserId FROM card_coupon_user main - LEFT JOIN card_coupon cc ON main.card_coupon_id = cc.id + INNER JOIN card_coupon cc ON main.card_coupon_id = cc.id WHERE main.store_id = #{storeId} AND main.mt_user_id = #{userId} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java index dc104a17e..caac2f6d8 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponUserService.java @@ -44,5 +44,15 @@ public interface CardCouponUserService extends IService { * @return */ IPage queryPage(Page page,CardCouponUserVo cardCouponUserVo); + + /** + * 查某用户某些优惠券的使用记录 + * @author vinjor-M + * @date 17:31 2024/9/25 + * @param userId 用户id + * @param couponIdList 优惠券idList + * @return java.util.List + **/ + List selectListByUsed(Integer userId,List couponIdList); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java index b73932e9b..f3edda2f1 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponUserServiceImpl.java @@ -145,5 +145,24 @@ public class CardCouponUserServiceImpl extends ServiceImpl + * @author vinjor-M + * @date 17:31 2024/9/25 + **/ + @Override + public List selectListByUsed(Integer userId, List couponIdList) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(CardCouponUser::getMtUserId,userId) + .in(CardCouponUser::getCardCouponId,couponIdList) + //已核销的 + .eq(CardCouponUser::getStatus,"1"); + return this.list(queryWrapper); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/impl/PayCenterServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/impl/PayCenterServiceImpl.java index 8740166f6..f68d40643 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/impl/PayCenterServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/service/impl/PayCenterServiceImpl.java @@ -3,6 +3,8 @@ package com.fuint.pay.service.impl; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRecord; import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule; @@ -13,6 +15,8 @@ import com.fuint.business.marketingActivity.activePrice.service.ActivePriceServi import com.fuint.business.marketingActivity.activePrice.service.ActiveSubPriceService; import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO; import com.fuint.business.marketingActivity.activePrice.vo.ActiveSubPriceRespVO; +import com.fuint.business.marketingActivity.cardCoupon.entity.CardCoupon; +import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService; import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO; import com.fuint.business.userGroup.entity.UserDiscount; @@ -27,6 +31,7 @@ import com.fuint.pay.service.PayCenterService; import com.fuint.pay.util.CheckUtil; import com.fuint.pay.vo.ActivityVO; import com.fuint.pay.vo.CouponVO; +import com.fuint.pay.vo.GoodsVO; import com.google.common.collect.ImmutableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -166,11 +171,13 @@ public class PayCenterServiceImpl implements PayCenterService { List actTypeList = Arrays.asList("1,2".split(StrUtil.COMMA)); List recordAllList = activePriceRecordService.selectListByUserIdAndActIds(userId, filteredList.stream().map(ActivePriceRuleRespVO::getId).collect(Collectors.toList()),null,actTypeList); - filteredList = filteredList.stream() - //过滤掉超过每日参加次数限制的 - .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getDayLimitNum(),nowDate,recordAllList, "day")) - //过滤掉超过累计参加次数限制的 - .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getLimitNum(),null,recordAllList,null)).collect(Collectors.toList()); + if(!recordAllList.isEmpty()){ + filteredList = filteredList.stream() + //过滤掉超过每日参加次数限制的 + .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getDayLimitNum(),nowDate,recordAllList, "day")) + //过滤掉超过累计参加次数限制的 + .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getLimitNum(),null,recordAllList,null)).collect(Collectors.toList()); + } /*4.得到用户最终可以参加的活动,计算优惠金额并转换成统一的对象*/ List rtnList = new ArrayList<>(); if(!filteredList.isEmpty()){ @@ -227,13 +234,15 @@ public class PayCenterServiceImpl implements PayCenterService { List actTypeList = Arrays.asList("3".split(StrUtil.COMMA)); List recordAllList = activePriceRecordService.selectListByUserIdAndActIds(userId, null,filteredList.stream().map(ActiveSubPriceRespVO::getId).collect(Collectors.toList()),actTypeList); - filteredList = filteredList.stream() - //过滤掉超过每日参加次数限制的 - .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getDayLimitNum(),nowDate,recordAllList,"day")) - //过滤掉超过每月参加次数限制的 - .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getMonthLimitNum(),nowDate,recordAllList,"month")) - //过滤掉超过累计参加次数限制的 - .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getLimitNum(),null,recordAllList,null)).collect(Collectors.toList()); + if(!recordAllList.isEmpty()){ + filteredList = filteredList.stream() + //过滤掉超过每日参加次数限制的 + .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getDayLimitNum(),nowDate,recordAllList,"day")) + //过滤掉超过每月参加次数限制的 + .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getMonthLimitNum(),nowDate,recordAllList,"month")) + //过滤掉超过累计参加次数限制的 + .filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getLimitNum(),null,recordAllList,null)).collect(Collectors.toList()); + } /*4.得到用户最终可以参加的活动,计算优惠金额并转换成统一的对象*/ List rtnList = new ArrayList<>(); if(!filteredList.isEmpty()){ @@ -350,26 +359,58 @@ public class PayCenterServiceImpl implements PayCenterService { Integer storeId = nowAccountInfo.getStoreId(); int userId = Integer.parseInt(map.get("userId")); //油号id - Integer oilId = Integer.valueOf(map.get("oilId")); - //油单价 - Double oilPrice = Double.valueOf(map.get("oilPrice")); + Integer oilId = Integer.valueOf(map.getOrDefault("oilId","99999")); //加油金额(不含商品金额) - Double oilAmount = Double.valueOf(map.get("oilAmount")); - //订单总额(含商品金额) - Double orderAmount = Double.valueOf(map.get("orderAmount")); + Double oilAmount = Double.valueOf(map.getOrDefault("oilAmount","0")); //油升数 - Double oilLiter = Double.valueOf(map.get("oilLiter")); + Double oilLiter = Double.valueOf(map.getOrDefault("oilLiter","0")); + //选择的商品 + List goodsList = new ArrayList<>(); + String goodsStr = map.getOrDefault("goods",""); + if(StringUtils.isNotEmpty(goodsStr)){ + JSONArray goodsArray = JSONUtil.parseArray(map.get("goods")); + goodsList = goodsArray.toList(GoodsVO.class); + } /*1.先查满足条件的所有生效中的优惠券*/ List couponVOList = cardCouponUserService.selectAllList(storeId, userId, nowDate); /*2.进行初步过滤,这里只过滤优惠券硬性的限制*/ + List finalGoodsList = goodsList; List filteredList = couponVOList.stream() //当前时间在 适用时间段内 或者 当前时间不在 不适用时间段内的 - .filter(rule -> this.checkTimeCouponPrex(rule,nowDate)).collect(Collectors.toList()); -// //是否满足最低消费金额 -// .filter(rule-> rule.getConsumeAmount() <=oilAmount) -// //适用当前支付方式的 -// .filter(rule-> rule.getUsePaymentWay().contains(payWay)) + .filter(rule -> this.checkTimeCouponPrex(rule,nowDate)) + //如果是油品券,需要过滤出当前油品可用的 + .filter(rule -> checkUtil.checkOilCoupon(rule,oilId)) + //如果是油品券,需要过滤出达到满减条件的 + .filter(rule -> checkUtil.checkMaxCoupon(rule,oilAmount,oilLiter)) + //如果是单品立减券,需要过滤出当前选择的商品可用且满足最低消费金额的 + .filter(rule-> checkUtil.checkGoodsCoupon(rule, finalGoodsList)).collect(Collectors.toList()); + if(filteredList.isEmpty()){ + return new ArrayList<>(); + } + /*3.再次过滤,这里过滤掉用户已经超出参加次数限制的*/ + List filteredCoupIdList = filteredList.stream().map(CardCoupon::getId).collect(Collectors.toList()); + //查出本用户这些优惠券的使用记录 + List usedList = cardCouponUserService.selectListByUsed(userId,filteredCoupIdList); + if(!usedList.isEmpty()){ + //过滤 + filteredList = filteredList.stream() + //过滤掉使用次数限制的 + .filter(rule->checkUtil.checkUseNumCoupon(rule.getId(),rule.getLimitTotalDay(), rule.getLimitTotalNum(), nowDate,usedList)).collect(Collectors.toList()); + } + /*4.得到用户最终可以使用的优惠券,计算优惠金额并转换成统一的对象*/ List rtnList = new ArrayList<>(); + if(!filteredList.isEmpty()){ + for(CardCouponVO rule:filteredList){ + CouponVO couponVO = new CouponVO(); + couponVO.setId(rule.getDataId()); + couponVO.setCouponId(rule.getId()); + couponVO.setName(rule.getName()); + couponVO.setUseWithOther(rule.getUseWithOther()); + //计算优惠金额 + couponVO.setDisAmount(checkUtil.computeDisAmountCoupon(rule,oilAmount,oilLiter)); + rtnList.add(couponVO); + } + } return rtnList; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/util/CheckUtil.java b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/util/CheckUtil.java index 6a3735d12..cd0dc80de 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/util/CheckUtil.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/util/CheckUtil.java @@ -8,14 +8,18 @@ import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRecord import com.fuint.business.marketingActivity.activePrice.entity.ActiveSubPriceRule; import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO; import com.fuint.business.marketingActivity.activePrice.vo.ActiveSubPriceRespVO; +import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; +import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO; import com.fuint.business.userGroup.entity.UserDiscount; import com.fuint.common.util.StringUtils; +import com.fuint.pay.vo.GoodsVO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.text.DecimalFormat; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.LocalTime; import java.util.*; import java.util.stream.Collectors; @@ -234,6 +238,127 @@ public class CheckUtil { } } } + /** + * 判断当前加油的油号是否符合优惠券预设的油号----优惠券专用 + * @author vinjor-M + * @date 14:42 2024/9/21 + * @param couponVO 优惠券对象 + * @param oilId 当前加油选择的油号id + * @return java.lang.Boolean + **/ + public Boolean checkOilCoupon(CardCouponVO couponVO, Integer oilId){ + //代金券、折扣券、油品立减券才需要判断油品是否满足 + List couponTypeList = Arrays.asList("1","3","4"); + if(couponTypeList.contains(couponVO.getType())){ + if("1".equals(couponVO.getOilLimit())){ + //不限制油品,符合 + return true; + }else{ + //限制油品 + if(StringUtils.isNotEmpty(couponVO.getOilNumber())){ + List oilIdList = Arrays.asList(couponVO.getOilNumber().split(StrUtil.COMMA)); + return oilIdList.contains(oilId.toString()); + }else{ + //没有配置可用油号,不满足 + return false; + } + } + }else{ + //其他券不需要判断油品 + return true; + } + } + /** + * 判断当前加油金额或者加油升数是否达到满减条件----优惠券专用 + * @author vinjor-M + * @date 14:42 2024/9/21 + * @param couponVO 优惠券对象 + * @param oilAmount 加油金额 + * @param oilLiter 加油升数 + * @return java.lang.Boolean + **/ + public Boolean checkMaxCoupon(CardCouponVO couponVO, Double oilAmount,Double oilLiter){ + //代金券、折扣券、油品立减券才需要判断加油升数、加油金额是否达到满减条件 + List couponTypeList = Arrays.asList("1","3","4"); + if(couponTypeList.contains(couponVO.getType())){ + Double thisValue; + if("1".equals(couponVO.getUseType())){ + //加油金额 + thisValue = oilAmount; + }else if("2".equals(couponVO.getUseType())){ + //加油升数 + thisValue = oilLiter; + }else { + //超出预设值范围,不满足 + return false; + } + if("1".equals(couponVO.getType())){ + //代金券 + return checkMaxCouponChild(null,couponVO.getReachAmount(),thisValue); + }else if("3".equals(couponVO.getType())){ + //折扣券 + return checkMaxCouponChild(couponVO.getZkStartAmount().doubleValue(),couponVO.getZkEndAmount().doubleValue(),thisValue); + }else if("4".equals(couponVO.getType())){ + //油品立减券 + return checkMaxCouponChild(null,couponVO.getReachAmount(),thisValue); + }else{ + //超出预设值范围,不可用 + return false; + } + }else{ + //其他券不需要判断,默认满足 + return true; + } + } + + /** + * 判断加油金额或者加油升数是否符合某区间范围 + * @author vinjor-M + * @date 16:45 2024/9/25 + * @param min 最小值,可能为null + * @param max 最大值,一定有值 + * @param thisValue 加油金额或加油升数,一定有值 + * @return java.lang.Boolean + **/ + public Boolean checkMaxCouponChild(Double min,Double max,Double thisValue){ + if(null==min){ + return thisValue>=max; + }else { + return isBetween(thisValue,min,max); + } + } + + /** + * 判断当前订单选择的商品是否满足优惠券的使用规则----优惠券专用 + * @author vinjor-M + * @date 14:42 2024/9/21 + * @param couponVO 优惠券对象 + * @param goodsList 选择的商品列表 + * @return java.lang.Boolean + **/ + public Boolean checkGoodsCoupon(CardCouponVO couponVO, List goodsList){ + if("5".equals(couponVO.getType()) || goodsList.isEmpty()){ + //单品立减券 + if(StringUtils.isNotEmpty(couponVO.getProductIds())){ + //限制使用的商品id + List ruleGoodsList = Arrays.asList(couponVO.getProductIds().split(StrUtil.COMMA)); + //过滤出符合条件的本订单的商品 + List filteredList = goodsList.stream().filter(goods->ruleGoodsList.contains(goods.getId())).collect(Collectors.toList()); + //计算符合条件的商品订单总金额 + double orderAmount =0.0; + if(!filteredList.isEmpty()){ + orderAmount = filteredList.stream().mapToDouble(GoodsVO::getAmount).sum(); + } + return orderAmount>=couponVO.getReachAmount(); + }else{ + //未设置可用商品,不符合 + return false; + } + }else{ + //其他券或者本订单未选择商品不需要判断商品 + return true; + } + } /** @@ -279,6 +404,55 @@ public class CheckUtil { return maxNum>nowNum; } + /** + * 判断当前优惠券每多少天使用了多少次 是否满足优惠券设置的限制条件 + * @author vinjor-M + * @date 14:51 2024/9/21 + * @param coupId 优惠券id + * @param dayNum 多少天内 + * @param maxNum 最大次数限制 + * @param nowDate 结算日期 + * @param recordAllList 所有使用记录 + * @return java.lang.Boolean + **/ + public Boolean checkUseNumCoupon(Integer coupId, Integer dayNum, Integer maxNum, Date nowDate, List recordAllList){ + if(0==dayNum){ + //每多少天 设置为0,代表不显示 + return true; + } + int nowNum = 0; + //开始时间是结算时间 向前推 dayNum 天 + LocalDateTime startTime = DateUtil.offsetDay(nowDate,-3).toLocalDateTime(); + //结束时间为结算的时间 + LocalDateTime endTime = DateUtil.date(nowDate).toLocalDateTime(); + //优惠券使用时间过滤出近 dayNum 天内使用的次数 + nowNum = (int) recordAllList.stream() + .filter(item->item.getCardCouponId().equals(coupId)) + .filter(item->checkDateTimeIsIn(item.getUseTime(),startTime,endTime)) + .count(); + return maxNum>nowNum; + } + + /** + * 判断一个时间是否在一个时间区间内 + * @author vinjor-M + * @date 18:09 2024/9/25 + * @param useDate 使用时间 + * @param startTime 时间区间起始 + * @param endTime 时间区间结束 + * @return java.lang.Boolean + **/ + private Boolean checkDateTimeIsIn(Date useDate,LocalDateTime startTime,LocalDateTime endTime){ + LocalDateTime userDateTime = DateUtil.date(useDate).toLocalDateTime(); + if(userDateTime.isAfter(startTime) && userDateTime.isBefore(endTime)){ + return true; + }else if(userDateTime.equals(startTime ) || userDateTime.equals(endTime)){ + return true; + }else{ + return false; + } + } + /** * 根据活动优惠规则,计算优惠金额,,四舍五入保留2位小数--分时优惠和限时特价使用 * @author vinjor-M @@ -399,6 +573,48 @@ public class CheckUtil { return Double.valueOf(df.format(disAmount)); } + /** + * 根据优惠券优惠规则,计算优惠金额,,四舍五入保留2位小数--优惠券专用 + * @author vinjor-M + * @date 16:35 2024/9/21 + * @param coupon 优惠券 + * @param oilAmount 加油总价 + * @param oilLiter 加油升数 + * @return java.lang.Double + **/ + public Double computeDisAmountCoupon(CardCouponVO coupon, Double oilAmount, Double oilLiter){ + //默认优惠后总价等于原来的总价 + Double newOilAmount = oilAmount; + //优惠金额 + Double disAmount = 0.0; + DecimalFormat df = new DecimalFormat("#.00"); + try { + //1 按加油金额,否则 按加油升数 + Double thisValue = "1".equals(coupon.getUseType())?oilAmount:oilLiter; + if("1".equals(coupon.getType())){ + //代金券-直接拿优惠金额 + disAmount = coupon.getReduceAmount(); + }else if("3".equals(coupon.getType())){ + //折扣券,打折 + newOilAmount = newOilAmount*coupon.getZkData(); + disAmount = oilAmount - newOilAmount; + if(disAmount>coupon.getZkMaxAmount()){ + //超出折扣最大优惠金额 + disAmount = coupon.getZkMaxAmount(); + } + }else if("4".equals(coupon.getType())){ + //油品立减券,每满多少升减多少钱 + //计算能除尽多少次,就减多少次 + int thisInt = (int) (thisValue / coupon.getLjOilNum()); + //计算优惠金额 + disAmount = thisInt * coupon.getLjOilAmount(); + } + }catch (Exception e){ + log.error("优惠券优惠金额计算失败:"+e.getMessage(),e); + } + return Double.valueOf(df.format(disAmount)); + } + /** * 从一个日期里面获取时间,00:00格式 * @author vinjor-M @@ -512,7 +728,7 @@ public class CheckUtil { * @return boolean **/ private static boolean isBetween(double value, double min, double max) { - return value > min && value < max; + return value >= min && value <= max; } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/vo/CouponVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/vo/CouponVO.java index 3f517a70b..a77efa1c6 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/vo/CouponVO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/vo/CouponVO.java @@ -11,8 +11,14 @@ import java.io.Serializable; **/ @Data public class CouponVO implements Serializable { - /** 优惠券id */ + /** 优惠券和用户关联表的id */ private Integer id; + /** 优惠券id */ + private Integer couponId; /** 优惠券名称 */ private String name; + /**是否可与其他优惠一起使用1可以0不可以*/ + private String useWithOther; + /** 优惠金额 */ + private Double disAmount; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/pay/vo/GoodsVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/vo/GoodsVO.java new file mode 100644 index 000000000..2bbb75016 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/pay/vo/GoodsVO.java @@ -0,0 +1,20 @@ +package com.fuint.pay.vo; + +import lombok.Data; + +/** + * 订单选择的商品 + * @author vinjor-M + * @date 14:42 2024/9/25 +**/ +@Data +public class GoodsVO { + /** 商品id */ + private String id; + /** 商品数量 */ + private Integer num; + /** 商品单价 */ + private Double price; + /** 总金额 */ + private Double amount; +} diff --git a/fuintBackend/fuint-application/src/main/resources/application.properties b/fuintBackend/fuint-application/src/main/resources/application.properties index 597d7d885..1fa299b97 100644 --- a/fuintBackend/fuint-application/src/main/resources/application.properties +++ b/fuintBackend/fuint-application/src/main/resources/application.properties @@ -1,7 +1,7 @@ # \u57FA\u672C\u914D\u7F6E server.port=8080 env.profile=dev -env.properties.path=D:/workspaces/oil-stations/fuintBackend/configure/ +env.properties.path=D:/my_project/oil-station/fuintBackend/configure/ #env.properties.path=F:/work/oilSystem/fuintBackend/configure/ #env.properties.path=D:/oil/new-oil/oilSystem/fuintBackend/configure/ #env.properties.path=D:/work/oilSystem/fuintBackend/configure/ diff --git a/fuintBackend/lib/mvn.txt b/fuintBackend/lib/mvn.txt index ec3724568..d1ba7cb41 100644 --- a/fuintBackend/lib/mvn.txt +++ b/fuintBackend/lib/mvn.txt @@ -1 +1 @@ -mvn install:install-file -Dfile=D:\Code\yuzhan\oil-station\fuintBackend\lib\yly_sdk_2.2.jar -DgroupId=yly_sdk -DartifactId=yly_sdk -Dversion=2.2 -Dpackaging=jar +mvn install:install-file -Dfile=D:\Code\yuzhan\oil-station\fuintBackend\lib\yly_sdk_2.2.jar -DgroupId=yly_sdk -DartifactId=yly_sdk -Dversion=2.2 -Dpackaging=jar \ No newline at end of file diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue b/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue index 3c604c641..e6ee02129 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue @@ -65,7 +65,7 @@
活动优惠 -
-¥0.00
+
@@ -83,22 +83,19 @@
优惠券 -
-¥0.00
+
- -
- 优惠券1 -
-¥0.00
+
+ +
+ {{null==item.ruleName?item.actName:item.ruleName}}
-¥{{item.disAmount}}
+
+
-
- 优惠券2 -
-¥0.00
-
-
- 优惠券3 -
-¥0.00
+
+ 暂无可用优惠券
@@ -544,8 +541,12 @@ export default { }, //可参加的活动 activityList:[], + //可用优惠券 + couponList:[], //选中的活动 actId_ruleId chooseAct:"", + //选中的优惠券 + chooseCoupon:"", //支付方式--默认支付宝 payWay: "ALIPAY", //订单总金额 @@ -655,6 +656,17 @@ export default { } }, watch: { + orderAmount: { + handler(newVal) { + console.log("订单总金额发生变化", newVal); + //查询可用优惠活动 + this.getActivity() + //查可用优惠券 + this.getCoupon() + }, + deep: true, + immediate: true, + }, //监听子弹窗成功 提交了 然后再隐藏子元素标签 oilGunClearing: { immediate: true, @@ -667,8 +679,6 @@ export default { this.orderAmount = this.getGoodsNum } this.refuelingAmount = false - //查询可用优惠活动 - this.getActivity() } }, //监听商品总金额发生变化 @@ -994,21 +1004,38 @@ export default { */ getCoupon(){ //组装请求参数 - if(this.oilGunClearing!='' && this.oilGunClearing.hasOwnProperty("oilNameId") && this.chooseVipUser.hasOwnProperty("id")){ - // 保留两位小数 - let oilLiter = (this.oilGunClearing.amount / this.oilGunClearing.oilPrice).toFixed(2) - //油枪已结算,且已选择会员 + if(this.chooseVipUser.hasOwnProperty("id") && (this.goodsList.length>0 || (this.oilGunClearing!='' && this.oilGunClearing.hasOwnProperty("oilNameId")))){ + //已选择会员且(选了商品或者加了油) let dataObj = { - userId: this.chooseVipUser.id, - oilId: this.oilGunClearing.oilNameId, - oilPrice:this.oilGunClearing.oilPrice, - oilAmount: this.oilGunClearing.amount, - orderAmount: this.orderAmount, - oilLiter: oilLiter + userId: this.chooseVipUser.id + } + if(this.oilGunClearing!='' && this.oilGunClearing.hasOwnProperty("oilNameId")){ + //加油油枪有值 + dataObj['oilId'] = this.oilGunClearing.oilNameId + dataObj['oilAmount'] = this.oilGunClearing.amount + dataObj['oilLiter'] = this.oilLiter + } + if(this.goodsList.length>0){ + let goodsArray = [] + for (let i = 0; i < this.goodsList.length; i++) { + let thisGoods = this.goodsList[i] + let goods = { + id: thisGoods.id, + num:thisGoods.num, + price:thisGoods.retailPrice, + amount:thisGoods.retailPrice * thisGoods.num + } + goodsArray.push(goods) + dataObj['goods'] = JSON.stringify(goodsArray) + } + console.log(dataObj) } getCouponList(dataObj).then(res => { - console.log("返回结果",res) + console.log("返回的可用的优惠券",res) + this.couponList = res.data }) + }else{ + this.couponList=[] } }, copyToClipboard(textToCopy) {