From e8a4da082678c5d91a47a313fd669240947d1271 Mon Sep 17 00:00:00 2001 From: zhaohengkun Date: Fri, 18 Oct 2024 09:33:26 +0800 Subject: [PATCH] =?UTF-8?q?BUG=20+=20=E6=94=B6=E9=93=B6=E5=8F=B0=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/EventMarketing/cardCoupon.js | 9 ++ .../activeConsumption/index.vue | 6 +- .../EventMarketing/activeNewlyweds/index.vue | 6 +- .../EventMarketing/openCardGift/birthday.vue | 6 +- .../EventMarketing/openCardGift/invite.vue | 6 +- .../EventMarketing/openCardGift/popUp.vue | 6 +- .../openCardGift/userConsume.vue | 6 +- .../openCardGift/userRecharge.vue | 6 +- .../cashierGoods/mapper/xml/MtGoodsMapper.xml | 1 + .../controller/CardCouponController.java | 11 ++- .../cardCoupon/mapper/CardCouponMapper.java | 3 + .../mapper/CardCouponUserMapper.java | 3 + .../mapper/xml/CardCouponMapper.xml | 27 +++++- .../mapper/xml/CardCouponUserMapper.xml | 20 ++++ .../cardCoupon/service/CardCouponService.java | 6 +- .../service/impl/CardCouponServiceImpl.java | 61 ++++++++++--- .../service/impl/PayCenterServiceImpl.java | 65 +++++++++---- .../java/com/fuint/pay/util/CheckUtil.java | 20 ++-- .../views/cashier/NewComponents/newHome.vue | 91 +++++++++++++++---- 19 files changed, 278 insertions(+), 81 deletions(-) diff --git a/fuintAdmin/src/api/EventMarketing/cardCoupon.js b/fuintAdmin/src/api/EventMarketing/cardCoupon.js index 415fec320..783da8681 100644 --- a/fuintAdmin/src/api/EventMarketing/cardCoupon.js +++ b/fuintAdmin/src/api/EventMarketing/cardCoupon.js @@ -9,6 +9,15 @@ export function listCardCoupon(query) { }) } +// 查询优惠券剩余数量>0的 +export function getCardCouponNum(query) { + return request({ + url: 'cardCoupon/queryByNum', + method: 'get', + params: query + }) +} + // 根据id优惠券活动列表 export function getCardCoupon(id) { return request({ diff --git a/fuintAdmin/src/views/EventMarketing/activeConsumption/index.vue b/fuintAdmin/src/views/EventMarketing/activeConsumption/index.vue index b5ce9edd1..4a0e5df8e 100644 --- a/fuintAdmin/src/views/EventMarketing/activeConsumption/index.vue +++ b/fuintAdmin/src/views/EventMarketing/activeConsumption/index.vue @@ -256,7 +256,7 @@ import { } from "@/api/EventMarketing/activeConsumption"; import {listUserGrade} from "@/api/staff/user/usergrade"; import {getOilNameList} from "@/api/order/oilnumgun"; -import {listCardCoupon} from "@/api/EventMarketing/cardCoupon"; +import {getCardCouponNum} from "@/api/EventMarketing/cardCoupon"; import {listUserLabel} from "@/api/staff/user/userlabel"; export default { @@ -538,8 +538,8 @@ export default { }, getCardCoupon() { - listCardCoupon({status: 1}).then(res => { - this.cardCouponList = res.data.records + getCardCouponNum({status: 1}).then(res => { + this.cardCouponList = res.data }) }, addPoints(orderType) { diff --git a/fuintAdmin/src/views/EventMarketing/activeNewlyweds/index.vue b/fuintAdmin/src/views/EventMarketing/activeNewlyweds/index.vue index f7532fb29..d9be3959c 100644 --- a/fuintAdmin/src/views/EventMarketing/activeNewlyweds/index.vue +++ b/fuintAdmin/src/views/EventMarketing/activeNewlyweds/index.vue @@ -125,7 +125,7 @@ import { getActiveFullminus, updateActiveFullminus } from "@/api/EventMarketing/activeFullminus"; -import {listCardCoupon} from "@/api/EventMarketing/cardCoupon"; +import {getCardCouponNum} from "@/api/EventMarketing/cardCoupon"; export default { name: "ActiveNewlyweds", @@ -255,8 +255,8 @@ export default { } }, getCardCoupon() { - listCardCoupon({status: 1}).then(res => { - this.cardCouponList = res.data.records + getCardCouponNum({status: 1}).then(res => { + this.cardCouponList = res.data console.log("数据",this.cardCouponList) }) }, diff --git a/fuintAdmin/src/views/EventMarketing/openCardGift/birthday.vue b/fuintAdmin/src/views/EventMarketing/openCardGift/birthday.vue index 4968b40ac..f68a2e3bf 100644 --- a/fuintAdmin/src/views/EventMarketing/openCardGift/birthday.vue +++ b/fuintAdmin/src/views/EventMarketing/openCardGift/birthday.vue @@ -134,7 +134,7 @@ import { } from "@/api/EventMarketing/activeNewlyweds"; import {getoilName, listExchange, listFavorable, looklook, looklooklook} from "@/api/EventMarketing/activeConsumption"; import QRCode from "qrcodejs2"; -import {listCardCoupon} from "@/api/EventMarketing/cardCoupon"; +import {getCardCouponNum} from "@/api/EventMarketing/cardCoupon"; import {listUserGrade} from "@/api/staff/user/usergrade"; import {addActiveBirthday, editActiveBirthday, getActiveBirthday} from "@/api/EventMarketing/activeBirthday"; @@ -281,8 +281,8 @@ export default { }) }, getCardCoupon() { - listCardCoupon({status: 1}).then(res => { - this.cardCouponList = res.data.records + getCardCouponNum({status: 1}).then(res => { + this.cardCouponList = res.data }) }, getInfo() { diff --git a/fuintAdmin/src/views/EventMarketing/openCardGift/invite.vue b/fuintAdmin/src/views/EventMarketing/openCardGift/invite.vue index faf8f5464..4e966c51e 100644 --- a/fuintAdmin/src/views/EventMarketing/openCardGift/invite.vue +++ b/fuintAdmin/src/views/EventMarketing/openCardGift/invite.vue @@ -119,7 +119,7 @@ import { } from "@/api/EventMarketing/activeNewlyweds"; import {getoilName, listExchange, listFavorable, looklook, looklooklook} from "@/api/EventMarketing/activeConsumption"; import QRCode from "qrcodejs2"; -import {listCardCoupon} from "@/api/EventMarketing/cardCoupon"; +import {getCardCouponNum} from "@/api/EventMarketing/cardCoupon"; import { getActiveRecommendInfo, insertActiveRecommend, @@ -259,8 +259,8 @@ export default { } }, getCardCoupon() { - listCardCoupon({status: 1}).then(res => { - this.cardCouponList = res.data.records + getCardCouponNum({status: 1}).then(res => { + this.cardCouponList = res.data }) }, getInfo() { diff --git a/fuintAdmin/src/views/EventMarketing/openCardGift/popUp.vue b/fuintAdmin/src/views/EventMarketing/openCardGift/popUp.vue index 7f3794e56..e3c20b82a 100644 --- a/fuintAdmin/src/views/EventMarketing/openCardGift/popUp.vue +++ b/fuintAdmin/src/views/EventMarketing/openCardGift/popUp.vue @@ -158,7 +158,7 @@ import { } from "@/api/EventMarketing/activeNewlyweds"; import {getoilName, listExchange, listFavorable, looklook, looklooklook} from "@/api/EventMarketing/activeConsumption"; import QRCode from "qrcodejs2"; -import {listCardCoupon} from "@/api/EventMarketing/cardCoupon"; +import {getCardCouponNum} from "@/api/EventMarketing/cardCoupon"; import {listUserGrade} from "@/api/staff/user/usergrade"; import {addActivePopUp, editActivePopUp, getActivePopUp} from "@/api/EventMarketing/activePopUp"; @@ -350,8 +350,8 @@ export default { }) }, getCardCoupon(){ - listCardCoupon({status:1}).then(res => { - this.cardCouponList = res.data.records + getCardCouponNum({status:1}).then(res => { + this.cardCouponList = res.data }) }, getInfo(){ diff --git a/fuintAdmin/src/views/EventMarketing/openCardGift/userConsume.vue b/fuintAdmin/src/views/EventMarketing/openCardGift/userConsume.vue index 5779e5fae..9f5b7a757 100644 --- a/fuintAdmin/src/views/EventMarketing/openCardGift/userConsume.vue +++ b/fuintAdmin/src/views/EventMarketing/openCardGift/userConsume.vue @@ -146,7 +146,7 @@ import { } from "@/api/EventMarketing/activeNewlyweds"; import {getoilName, listExchange, listFavorable, looklook, looklooklook} from "@/api/EventMarketing/activeConsumption"; import QRCode from "qrcodejs2"; -import {listCardCoupon} from "@/api/EventMarketing/cardCoupon"; +import {getCardCouponNum} from "@/api/EventMarketing/cardCoupon"; import {listUserGrade} from "@/api/staff/user/usergrade"; import {getOilNameList, oilNumberList} from "@/api/order/oilnumgun"; import { @@ -330,8 +330,8 @@ export default { }) }, getCardCoupon(){ - listCardCoupon({status:1}).then(res => { - this.cardCouponList = res.data.records + getCardCouponNum({status:1}).then(res => { + this.cardCouponList = res.data }) }, getInfo(){ diff --git a/fuintAdmin/src/views/EventMarketing/openCardGift/userRecharge.vue b/fuintAdmin/src/views/EventMarketing/openCardGift/userRecharge.vue index d2dfdaac7..fff803227 100644 --- a/fuintAdmin/src/views/EventMarketing/openCardGift/userRecharge.vue +++ b/fuintAdmin/src/views/EventMarketing/openCardGift/userRecharge.vue @@ -133,7 +133,7 @@ import { } from "@/api/EventMarketing/activeNewlyweds"; import {getoilName, listExchange, listFavorable, looklook, looklooklook} from "@/api/EventMarketing/activeConsumption"; import QRCode from "qrcodejs2"; -import {listCardCoupon} from "@/api/EventMarketing/cardCoupon"; +import {getCardCouponNum} from "@/api/EventMarketing/cardCoupon"; import {listUserGrade} from "@/api/staff/user/usergrade"; import { addActiveUserRecharge, @@ -283,8 +283,8 @@ export default { }) }, getCardCoupon(){ - listCardCoupon({status:1}).then(res => { - this.cardCouponList = res.data.records + getCardCouponNum({status:1}).then(res => { + this.cardCouponList = res.data }) }, getInfo(){ diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/cashierGoods/mapper/xml/MtGoodsMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/cashierGoods/mapper/xml/MtGoodsMapper.xml index 9d9fdb841..c84e407f5 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/cashierGoods/mapper/xml/MtGoodsMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/cashierGoods/mapper/xml/MtGoodsMapper.xml @@ -319,6 +319,7 @@ mt_goods god left JOIN supplier sup on god.supplier_id = sup.id + god.stock > 0 and ${key} = #{value} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/controller/CardCouponController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/controller/CardCouponController.java index ffa344e43..b144f82ce 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/controller/CardCouponController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/controller/CardCouponController.java @@ -62,6 +62,15 @@ public class CardCouponController extends BaseController { return getSuccessResult(this.cardCouponService.pageVo(page, cardCoupon)); } +// 查询 优惠券 剩余数量 >0 的 + @GetMapping("/queryByNum") + public ResponseObject queryByNum(@Param("cardCoupon") CardCoupon cardCoupon) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + cardCoupon.setStoreId(nowAccountInfo.getStoreId()); + return getSuccessResult(this.cardCouponService.queryByNum(cardCoupon)); + + } + /** * 不分页查询在使用中的优惠卷 * @@ -220,7 +229,7 @@ public class CardCouponController extends BaseController { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); cardCouponUser.setStoreId(nowAccountInfo.getStoreId()); cardCouponUser.setChainStoreId(nowAccountInfo.getChainStoreId()); - return getSuccessResult(cardCouponService.sendCoupon(cardCouponUser)); + return cardCouponService.sendCoupon(cardCouponUser); } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponMapper.java index f9a9fff08..58dde9d10 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponMapper.java @@ -19,6 +19,7 @@ import java.util.List; @Mapper public interface CardCouponMapper extends BaseMapper { IPage pageVo(Page page, @Param("cardCoupon") CardCoupon cardCoupon); + List queryByNum(@Param("cardCoupon") CardCoupon cardCoupon); IPage selectAllByPageAndStoreId(Page page, @Param("cardCoupon")CardCoupon cardCoupon); IPage selectAllByPageAndIds(Page page,@Param("ids") List ids); @@ -30,5 +31,7 @@ public interface CardCouponMapper extends BaseMapper { */ List selectByStoreIdCount(CardCouponUniVo cardCouponUniVos); List getCanUseCoupon(@Param("cardCoupon") CardCoupon cardCoupon); + + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java index 7b6657980..fdff2dc97 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/CardCouponUserMapper.java @@ -42,5 +42,8 @@ public interface CardCouponUserMapper extends BaseMapper { IPage queryPage(Page page,@Param("entity") CardCouponUserVo cardCouponUserVo); List selectCouponCount(@Param("storeId") Integer storeId,@Param("userId") Integer userId); + + List selectCardCouponUserList(@Param("params") Map params); + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponMapper.xml index 0f4d3e750..8e4bf0b84 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/mapper/xml/CardCouponMapper.xml @@ -9,7 +9,6 @@ FROM card_coupon cc - cc.tf_total - cc.tf_get_num >0 and cc.store_id = #{cardCoupon.storeId} @@ -121,5 +120,31 @@ order by cc.create_time desc + 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 c0d6a60b9..ac8527997 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 @@ -37,4 +37,24 @@ WHERE store_id = #{storeId} AND mt_user_id = #{userId} group by card_coupon_id + + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponService.java index ace58dbe1..6bd9ef72d 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/CardCouponService.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.fuint.business.marketingActivity.cardCoupon.entity.CardCoupon; import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser; import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUniVo; +import com.fuint.framework.web.ResponseObject; import java.util.List; @@ -17,6 +18,9 @@ import java.util.List; */ public interface CardCouponService extends IService { IPage pageVo(Page page, CardCoupon cardCoupon); + + List queryByNum(CardCoupon cardCoupon); + List getCanUseCoupon(CardCoupon cardCoupon); @@ -28,7 +32,7 @@ public interface CardCouponService extends IService { int isOnLine(Integer id); IPage selectAllByPageAndStoreId(Page page, CardCoupon cardCoupon); - int sendCoupon(CardCouponUser cardCouponUser); + ResponseObject sendCoupon(CardCouponUser cardCouponUser); CardCoupon selectOneBuId(Integer id); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponServiceImpl.java index 7db51d1d4..7a81da1e8 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponServiceImpl.java @@ -27,8 +27,10 @@ import com.fuint.business.userManager.service.LJUserService; import com.fuint.business.userManager.vo.LJUserVo; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; +import com.fuint.framework.web.ResponseObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; @@ -43,13 +45,15 @@ import java.util.stream.Collectors; public class CardCouponServiceImpl extends ServiceImpl implements CardCouponService { - + @Autowired + private CardCouponMapper cardCouponMapper; @Autowired private CardCouponUserMapper cardCouponUserMapper; @Autowired private LJUserService userService; @Autowired private UserBalanceMapper userBalanceMapper; + @Override public IPage pageVo(Page page, CardCoupon cardCoupon) { IPage cardCouponIPage = baseMapper.pageVo(page, cardCoupon); @@ -57,6 +61,11 @@ public class CardCouponServiceImpl extends ServiceImpl queryByNum(CardCoupon cardCoupon) { + return baseMapper.queryByNum(cardCoupon); + } + @Override public List getCanUseCoupon(CardCoupon cardCoupon) { return baseMapper.getCanUseCoupon(cardCoupon); @@ -65,7 +74,7 @@ public class CardCouponServiceImpl extends ServiceImpl cardCouponUniVos = baseMapper.selectAllByPageAndStoreId(page, cardCoupon); //用户拥有的优惠券以及数量 - List list= cardCouponUserMapper.selectCouponCount(cardCoupon.getStoreId(), nowAccountInfo.getId()); + List list = cardCouponUserMapper.selectCouponCount(cardCoupon.getStoreId(), nowAccountInfo.getId()); Map map = list.stream().collect(Collectors.toMap(CardCouponUniVo::getId, CardCouponUniVo::getCount)); CardCouponUniVo cardCouponUniVo1 = new CardCouponUniVo(); @@ -106,7 +115,7 @@ public class CardCouponServiceImpl extends ServiceImpl m1 = new HashMap<>(); + m1.put("cardCouponId", cardCouponUser.getCardCouponId()); + m1.put("mtUserId", cardCouponUser.getMtUserId()); + List list = cardCouponUserMapper.selectCardCouponUserList(m1); + + m1.put("createTimeStart", com.fuint.common.util.DateUtil.getTodayMidnight()); + m1.put("createTimeEnd", com.fuint.common.util.DateUtil.getTomorrowMidnight()); + List list2 = cardCouponUserMapper.selectCardCouponUserList(m1); + + //查询 优惠券 信息 + CardCoupon card = cardCouponMapper.selectById(cardCouponUser.getCardCouponId()); + + if (card.getGetNumLimit() <= list.size()) { + return new ResponseObject(500, "领取失败,超出总领取上限", null); + } + + if (card.getDayGetLimit() <= list2.size()) { + return new ResponseObject(500, "领取失败,超出每日领取上限", null); + } + // 修改优惠券领取数量 + card.setTfGetNum(card.getTfGetNum() + 1); + card.setCreateTime(null); + cardCouponMapper.updateById(card); + + // 给用户添加 优惠券 cardCouponUser.setMobile(ljUserVo.getMobile()); //通过优惠卷策略计算 开始时间 结束时间 CardCoupon cardCoupon = this.getById(cardCouponUser.getCardCouponId()); - if (cardCoupon.getTimeType().equals("1")){ + if (cardCoupon.getTimeType().equals("1")) { cardCouponUser.setStartTime(new Date()); - cardCouponUser.setEndTime(DateUtil.offsetDay(new Date(),cardCoupon.getValidityDay())); - }else { + cardCouponUser.setEndTime(DateUtil.offsetDay(new Date(), cardCoupon.getValidityDay())); + } else { cardCouponUser.setStartTime(cardCoupon.getEffectiveDateStart()); cardCouponUser.setEndTime(cardCoupon.getEffectiveDateEnd()); } - return cardCouponUserMapper.insert(cardCouponUser); + return new ResponseObject(200, "领取成功", null); } @Override @@ -201,7 +237,7 @@ public class CardCouponServiceImpl extends ServiceImpl getLijianAct(Date nowDate, Integer userId, Integer gradeId, Integer storeId, - List labelIdList, Double oilAmount, Double oilLiter, + List labelIdList, Double orderAmount, Double oilLiter, Integer oilId, String payWay) { /*1.先查满足条件的所有生效中的活动规则*/ List activeSubPriceList = activeSubPriceService.selectAllAct(storeId, nowDate); @@ -288,7 +286,8 @@ public class PayCenterServiceImpl implements PayCenterService { //适用当前油号的 .filter(rule -> checkUtil.checkOilLijian(rule.getApplyOilType(), rule.getApplyOil(), oilId)) //适用当前支付方式的 - .filter(rule -> rule.getPaymentType().contains(payWay)).collect(Collectors.toList()); + .filter(rule -> rule.getPaymentType().contains(payWay)) + .collect(Collectors.toList()); /*3.再次过滤,这里过滤掉用户已经超出参加次数限制的*/ //符合条件的活动规则,查询当前会员已经参与的记录,此处查立减营销的参与记录 List actTypeList = Arrays.asList("3".split(StrUtil.COMMA)); @@ -313,7 +312,11 @@ public class PayCenterServiceImpl implements PayCenterService { activityVO.setType("3"); activityVO.setActName(rule.getActiveName()); activityVO.setPayTypes(rule.getPaymentType()); - activityVO.setDisAmount(checkUtil.computeDisAmountLijian(rule, oilAmount, oilLiter)); + Double aDouble = checkUtil.computeDisAmountLijian(rule, orderAmount, oilLiter); + if (aDouble <= 0){ + continue; + } + activityVO.setDisAmount(checkUtil.computeDisAmountLijian(rule, orderAmount, oilLiter)); rtnList.add(activityVO); } } @@ -422,6 +425,8 @@ public class PayCenterServiceImpl implements PayCenterService { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); Integer storeId = nowAccountInfo.getStoreId(); int userId = Integer.parseInt(map.get("userId")); + //查询出用户信息 + UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(userId, storeId); //油号id Integer oilId = Integer.valueOf(map.getOrDefault("oilId", "99999")); //加油金额(不含商品金额) @@ -430,6 +435,7 @@ public class PayCenterServiceImpl implements PayCenterService { Double oilLiter = Double.valueOf(map.getOrDefault("oilLiter", "0")); //支付方式 String payWay = map.get("payWay"); + //还需要 加油升数 订单金额 if ("after_pay".equals(payWay)) { //挂账,不可以用优惠券 return new ArrayList<>(); @@ -448,12 +454,15 @@ public class PayCenterServiceImpl implements PayCenterService { List filteredList = couponVOList.stream() //当前时间在 适用时间段内 或者 当前时间不在 不适用时间段内的 .filter(rule -> this.checkTimeCouponPrex(rule, nowDate)) + //过滤会员等级 + .filter(rule -> checkUtil.checkGradeId(userBalance.getGradeId(), rule.getMembershipLevel())) //如果是油品券,需要过滤出当前油品可用的 .filter(rule -> checkUtil.checkOilCoupon(rule, oilId)) //如果是油品券,需要过滤出达到满减条件的 .filter(rule -> checkUtil.checkMaxCoupon(rule, oilAmount, oilLiter)) - //如果是单品立减券,需要过滤出当前选择的商品可用且满足最低消费金额的 - .filter(rule -> checkUtil.checkGoodsCoupon(rule, finalGoodsList)).collect(Collectors.toList()); + //直接 去掉类型是 2,5 卡券类型 1代金券、2兑换券、3折扣券、4油品立减券、5单品代金券 + .filter(rule -> rule != null && !Arrays.asList("2", "5").contains(rule.getType())) + .collect(Collectors.toList()); if (filteredList.isEmpty()) { return new ArrayList<>(); } @@ -691,14 +700,14 @@ public class PayCenterServiceImpl implements PayCenterService { // 此活动上架 收银台可送 且 已领取 + 活动发放数量 < 总数量 且 未超过 总上限 当日上限 if (card.getStatus().equals("1") && card.getSySend().equals("1") && - card.getTfGetNum()+child.getGiftCardTotal() < card.getTfTotal() && + card.getTfGetNum() + child.getGiftCardTotal() < card.getTfTotal() && list1.size() < card.getGetNumLimit() && list2.count() < card.getDayGetLimit()) { // 将优惠卷 与 当前用户关联 并且 优惠卷 领取数量 + 方法数量 card.setTfGetNum(card.getTfGetNum() + child.getGiftCardTotal()); cardCouponService.updateById(card); - for (int i = 0; i checkUtil.isBetween(cardCouponUser.getCreateTime(), DateUtil.getTodayMidnight(), DateUtil.getTomorrowMidnight())); // 此 优惠卷 上架 收银台可送 且 活动发放数量+已领取 < 总数量 且 未超过 总上限 当日上限 先都判断一下不为 null 防止空指针 - card.setTfGetNum( (card.getTfGetNum() == null) ? 0 : card.getTfGetNum()); + card.setTfGetNum((card.getTfGetNum() == null) ? 0 : card.getTfGetNum()); - if ( card.getStatus().equals("1") && + if (card.getStatus().equals("1") && card.getSySend().equals("1") && (child.getGiftCardTotal() + card.getTfGetNum()) < card.getTfTotal() && list1.size() < card.getGetNumLimit() && @@ -1071,7 +1080,7 @@ public class PayCenterServiceImpl implements PayCenterService { ) { // 将优惠卷 与 当前用户关联 并且 优惠卷 领取数量 + 活动设定赠送优惠卷数量 - card.setTfGetNum(card.getTfGetNum()+child.getGiftCardTotal()); + card.setTfGetNum(card.getTfGetNum() + child.getGiftCardTotal()); cardCouponService.updateById(card); // 并且 循环 添加多张优惠卷与用户领取记录表 for (int i = 0; i < child.getGiftCardTotal(); i++) { @@ -1152,6 +1161,22 @@ public class PayCenterServiceImpl implements PayCenterService { } + public Boolean filterCardCouponVOType(CardCouponVO cardCouponVO) { +// 卡券类型 1代金券、2兑换券、3折扣券、4油品立减券、5单品代金券 + if ("1".equals(cardCouponVO.getType()) || "3".equals(cardCouponVO.getType()) || "4".equals(cardCouponVO.getType())) { + + + + } else if ("2".equals(cardCouponVO.getType())) { + + + } else if ("5".equals(cardCouponVO.getType())) { + + + } + + return null; + } /** * 推荐消费有礼 活动时间前置处理 0永久有效;1自定义 @@ -1203,7 +1228,7 @@ public class PayCenterServiceImpl implements PayCenterService { **/ private Boolean checkTimeCouponPrex(CardCouponVO rule, Date nowDate) { - if (rule.getAvailableDay() ==null && rule.getAvailableWeek() == null){ + if (StringUtils.isEmpty(rule.getAvailableDay()) && StringUtils.isEmpty(rule.getAvailableWeek()) ) { return true; } String startTimeStr; @@ -1212,12 +1237,14 @@ public class PayCenterServiceImpl implements PayCenterService { //适用时间 startTimeStr = checkUtil.getTimeFromDate(rule.getAvailablePeriodStart()); endTimeStr = checkUtil.getTimeFromDate(rule.getAvailablePeriodEnd()); - return checkUtil.checkTime(rule.getAvailableType(), "1".equals(rule.getAvailableType()) ? rule.getAvailableWeek() : rule.getAvailableDay(), startTimeStr, endTimeStr, nowDate); + Boolean aBoolean = checkUtil.checkTime(rule.getAvailableType(), "1".equals(rule.getAvailableType()) ? rule.getAvailableWeek() : rule.getAvailableDay(), startTimeStr, endTimeStr, nowDate); + return aBoolean; } else if ("1".equals(rule.getAvailableOrUn())) { //不适用时间 startTimeStr = checkUtil.getTimeFromDate(rule.getUnAvailablePeriodStart()); endTimeStr = checkUtil.getTimeFromDate(rule.getUnAvailablePeriodEnd()); - return checkUtil.checkTimeReverse(rule.getUnAvailableType(), "1".equals(rule.getUnAvailableType()) ? rule.getUnAvailableWeek() : rule.getUnAvailableDay(), startTimeStr, endTimeStr, nowDate); + Boolean aBoolean = checkUtil.checkTimeReverse(rule.getUnAvailableType(), "1".equals(rule.getUnAvailableType()) ? rule.getUnAvailableWeek() : rule.getUnAvailableDay(), startTimeStr, endTimeStr, nowDate); + return aBoolean; } else { //超出预设值范围,不可用 return false; 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 dd7cb3f5f..20480232d 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 @@ -63,7 +63,7 @@ public class CheckUtil { } /** - * 判断某活动设置的可用会员等级(可以通用 就是比较 某个数值 是否在某组字符串中含有) + * 判断某活动设置的可用会员等级(可以通用 就是比较 某个字符串 是否在某组字符串中含有) * * @param gradeId 当前会员的等级 * @param gradeIds 活动设置的会员等级Ids @@ -414,6 +414,8 @@ public class CheckUtil { } } + + /** * 判断当前加油的油号是否符合优惠券预设的油号----优惠券专用 * @@ -450,20 +452,20 @@ public class CheckUtil { * 判断当前加油金额或者加油升数是否达到满减条件----优惠券专用 * * @param couponVO 优惠券对象 - * @param oilAmount 加油金额 + * @param orderAmount 订单金额 * @param oilLiter 加油升数 * @return java.lang.Boolean * @author vinjor-M * @date 14:42 2024/9/21 **/ - public Boolean checkMaxCoupon(CardCouponVO couponVO, Double oilAmount, Double oilLiter) { + public Boolean checkMaxCoupon(CardCouponVO couponVO, Double orderAmount, Double oilLiter) { //代金券、折扣券、油品立减券才需要判断加油升数、加油金额是否达到满减条件 List couponTypeList = Arrays.asList("1", "3", "4"); if (couponTypeList.contains(couponVO.getType())) { Double thisValue; if ("1".equals(couponVO.getUseType())) { - //加油金额 - thisValue = oilAmount; + //订单金额 + thisValue = orderAmount; } else if ("2".equals(couponVO.getUseType())) { //加油升数 thisValue = oilLiter; @@ -777,15 +779,15 @@ public class CheckUtil { * 根据优惠券优惠规则,计算优惠金额,,四舍五入保留2位小数--优惠券专用 * * @param coupon 优惠券 - * @param oilAmount 加油总价 + * @param orderAmount 订单金额 * @param oilLiter 加油升数 * @return java.lang.Double * @author vinjor-M * @date 16:35 2024/9/21 **/ - public Double computeDisAmountCoupon(CardCouponVO coupon, Double oilAmount, Double oilLiter) { + public Double computeDisAmountCoupon(CardCouponVO coupon, Double orderAmount, Double oilLiter) { //默认优惠后总价等于原来的总价 - Double newOilAmount = oilAmount; + Double newOilAmount = orderAmount; //优惠金额 Double disAmount = 0.0; DecimalFormat df = new DecimalFormat("#.00"); @@ -796,7 +798,7 @@ public class CheckUtil { } else if ("3".equals(coupon.getType())) { //折扣券,打折 newOilAmount = newOilAmount * coupon.getZkData(); - disAmount = oilAmount - newOilAmount; + disAmount = orderAmount - newOilAmount; if (disAmount > coupon.getZkMaxAmount()) { //超出折扣最大优惠金额 disAmount = coupon.getZkMaxAmount(); diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue b/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue index 5bb550a14..00d065d47 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/newHome.vue @@ -73,7 +73,7 @@
|
合计:¥{{ orderAmount }}
-
+
活动优惠 @@ -131,7 +131,9 @@
¥{{ realAmount }}
-
优惠合计:¥{{ disTotal }}
+
油品优惠:¥-{{ parseFloat(disOil).toFixed(2)}}
+
商品优惠:¥-{{ parseFloat(disGoods).toFixed(2) }}
+
优惠合计:¥-{{ parseFloat(disTotal).toFixed(2) }}
立即结算
@@ -212,7 +214,7 @@
{{ item.stock }}
{{ item.retailPrice }}
-
{{ item.retailPrice }}
+
{{ item.memberPrice}}
@@ -584,6 +586,9 @@ export default { dicts: ['CardCoupon_type'], data() { return { + disOil: 0.00, + disGoods: 0.00, + loadingPreferential: false, dialogVisible:false, isClickable: false, // 默认不可点击 payForm: { @@ -715,6 +720,40 @@ export default { } }, watch: { + //监听 会员登录 刷新一下商品会员价 计算 + chooseVipUser:{ + deep: true, + handler(newVal) { + this.goodsList = this.goodsList.map( + item => { + return item; + } + ) + } + }, + //监听商品列表 变化计算商品优惠 + goodsList: { + handler(newVal) { + //如果会员不为空 + if (this.chooseVipUser.hasOwnProperty("id")) { + this.disGoods = 0.00; + // 计算商品会员价 + console.log("走了啊", this.goodsList); + this.goodsList.forEach(item => { + const memberPrice = Number(item.retailPrice - item.memberPrice); + const num = Number(item.num); + const product = (memberPrice * num).toFixed(2); // 固定为两位小数 + this.disGoods = (parseFloat(this.disGoods) + parseFloat(product)).toFixed(2); + }); + + // 优惠总金额赋值 + this.disTotal = 0.00; + this.disTotal = (parseFloat(this.disGoods) + parseFloat(this.disOil)).toFixed(2); + + } + }, + deep: true, + }, //监听结算金额 是否获取 realAmount: { handler(newVal) { @@ -776,6 +815,8 @@ export default { console.log('油枪发生变化', newValue); if (newValue && newValue.hasOwnProperty("oilNameId")) { this.orderAmount = (Number(newValue.amount) + Number(this.getGoodsNum)).toFixed(2) + // 保留两位小数 + this.oilLiter = (this.oilGunClearing.amount / this.oilGunClearing.oilPrice).toFixed(2) } else { this.orderAmount = this.getGoodsNum } @@ -795,8 +836,7 @@ export default { } else { this.orderAmount = newVal } - //刷新可用优惠券 - this.getCoupon() + //商品 没有优惠券了 当前页面不能使用 } }, components: { @@ -821,8 +861,6 @@ export default { }, getGoodsItem() { if (this.oilGunClearing.amount && this.oilGunClearing.amount !== undefined) { - // 保留两位小数 - this.oilLiter = (this.oilGunClearing.amount / this.oilGunClearing.oilPrice).toFixed(2) // 8号枪(21.03L/191.7936元) return `${this.oilGunClearing.gunName}(${this.oilLiter}L/${this.oilGunClearing.amount}元)` @@ -858,6 +896,11 @@ export default { }, sendCouponClick() { + console.log("数量",this.sendCoupon.tfTotal - this.sendCoupon.tfGetNum) + if (this.sendCoupon.tfTotal - this.sendCoupon.tfGetNum <=0){ + this.$message.error("优惠券已领完") + return + } //this.sendCoupon this.chooseVipUser.id this.sendCoupon.mtUserId = this.chooseVipUser.id this.sendCoupon.fromType = "4" @@ -866,8 +909,14 @@ export default { this.sendCoupon.status = null sendCouponFun(this.sendCoupon).then( res => { - this.$message.success("赠送成功") - this.freeTicket = false + if (res.code == 200){ + this.$message.success("赠送成功") + this.freeTicket = false + } + else { + this.$message.error(res.msg) + } + } ) }, @@ -893,13 +942,18 @@ export default { * */ getDisTotal() { this.disTotal = 0.00 + this.disOil = 0.00 if ("" != this.chooseCouponId) { - this.disTotal += this.chooseCoupon.disAmount + this.disOil = parseFloat(this.disOil)+ parseFloat(this.chooseCoupon.disAmount); } if ("" != this.chooseActId) { - this.disTotal += this.chooseAct.disAmount + this.disOil = parseFloat(this.disOil)+ parseFloat(this.chooseAct.disAmount); } - this.disTotal = (this.disTotal).toFixed(2) + + console.log("油品优惠金额", this.disOil); + console.log("商品优惠金额", this.disGoods); + + this.disTotal = parseFloat(this.disOil)+ parseFloat(this.disGoods); }, /** * 监听活动选择切换 @@ -1448,7 +1502,7 @@ export default { oilId: this.oilGunClearing.oilNameId, oilPrice: this.oilGunClearing.oilPrice, oilAmount: this.oilGunClearing.amount, - orderAmount: this.orderAmount, + // orderAmount: this.orderAmount, payWay: this.payType, oilLiter: this.oilLiter } @@ -1464,13 +1518,15 @@ export default { /** * @description 油枪金额和商品金额发生变化,请求后端查询可用优惠券 * 传入后台的参数,会员的用户id、加油油号、加油订单金额(不包括商品金额)、加油订单总金额(包括商品金额)、加油总升数 + * 修改后 会员的用户id、加油油号、加油订单金额、加油总升数 (现在收银台 使用优惠券 是必须有油品才行) * @author vinjor-m * @date 2024年9月19日 */ getCoupon() { + this.loadingPreferential = true; this.chooseCouponId = '' - //组装请求参数 - if (this.chooseVipUser.hasOwnProperty("id") && (this.goodsList.length > 0 || (this.oilGunClearing != '' && this.oilGunClearing.hasOwnProperty("oilNameId")))) { + //组装请求参数 必须有会员id 以及 商品 和 油品的任意一种 + if (this.chooseVipUser.hasOwnProperty("id") && this.oilGunClearing != '' && this.oilGunClearing.hasOwnProperty("oilNameId") ) { //已选择会员且(选了商品或者加了油) let dataObj = { userId: this.chooseVipUser.id, @@ -1479,7 +1535,7 @@ export default { if (this.oilGunClearing != '' && this.oilGunClearing.hasOwnProperty("oilNameId")) { //加油油枪有值 dataObj['oilId'] = this.oilGunClearing.oilNameId - dataObj['oilAmount'] = this.oilGunClearing.amount + dataObj['oilAmount'] = this.oilGunClearing.amount dataObj['oilLiter'] = this.oilLiter } if (this.goodsList.length > 0) { @@ -1500,9 +1556,11 @@ export default { getCouponList(dataObj).then(res => { console.log("返回的可用的优惠券", res) this.couponList = res.data + this.loadingPreferential = false; }) } else { this.couponList = [] + this.loadingPreferential = false; } }, restVipUser() { @@ -2048,6 +2106,7 @@ export default { }, handleSelect(row) { let bo1 = true + console.log('当前选择的商品',row) // 如果 item 存在 goodsList 则 属性+1 不存在直接添加到数组 // 使用 map 生成新数组 防止vue监听不到数组内数据变化 this.goodsList = this.goodsList.map(