diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/controller/CardGiftController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/controller/CardGiftController.java index b6d12922b..78905692a 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/controller/CardGiftController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/controller/CardGiftController.java @@ -243,5 +243,15 @@ public class CardGiftController extends BaseController { public ResponseObject countGiftValue(CardGift cardGift) { return getSuccessResult(this.cardGiftService.countGiftValue(cardGift)); } + + /** + * 根据卡号和卡密获取礼品卡面值 + * @param cardGift + * @return + */ + @GetMapping("getCardAmount") + public ResponseObject getCardAmount(CardGift cardGift){ + return getSuccessResult(this.cardGiftService.getCardAmount(cardGift)); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/CardGiftService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/CardGiftService.java index e24d3b999..708f1cd56 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/CardGiftService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/CardGiftService.java @@ -66,5 +66,12 @@ public interface CardGiftService extends IService { List selectGiftValue(CardGift cardGift); List> countGiftValue(CardGift cardGift); + + /** + * 获取礼品卡面值 + * @param cardGift + * @return + */ + Double getCardAmount(CardGift cardGift); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/impl/CardGiftServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/impl/CardGiftServiceImpl.java index 9a5c12daf..48c68c7ec 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/impl/CardGiftServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardGift/service/impl/CardGiftServiceImpl.java @@ -1,5 +1,7 @@ package com.fuint.business.marketingActivity.cardGift.service.impl; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.excel.EasyExcelFactory; import com.alipay.api.domain.LoginUserDTO; @@ -318,5 +320,30 @@ public class CardGiftServiceImpl extends ServiceImpl i cardGift.setStoreId(nowAccountInfo.getStoreId()); return cardGiftMapper.countGiftValue(cardGift); } + + /** + * 获取礼品卡面值 + * + * @param cardGift + * @return + */ + @Override + public Double getCardAmount(CardGift cardGift) { + if (ObjectUtil.isEmpty(cardGift.getNumber()) && ObjectUtil.isEmpty(cardGift.getCardPassword())){ + throw new RuntimeException("请输入卡号或卡密"); + } + DateTime now = DateUtil.date(); + CardGift cardGift1 = cardGiftMapper.selectOne(new LambdaQueryWrapper() + .eq(CardGift::getNumber, cardGift.getNumber()) + .eq(CardGift::getCardPassword, cardGift.getCardPassword()) + .eq(CardGift::getStoreId, cardGift.getStoreId()) + .eq(CardGift::getUseStatus, 0) + .le(CardGift::getEffectiveTimeStart, now) + .ge(CardGift::getEffectiveTimeEnd, now)); + if (ObjectUtil.isEmpty(cardGift1)) { + throw new RuntimeException("卡号或卡密不存在或已过期"); + } + return cardGift1.getCardAmount(); + } }