From 14f7e66ffcf53ac5790442f7403f948f6d78e3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Sat, 21 Sep 2024 14:21:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B09.21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CardGiftController.java | 10 +++++++ .../cardGift/service/CardGiftService.java | 7 +++++ .../service/impl/CardGiftServiceImpl.java | 27 +++++++++++++++++++ 3 files changed, 44 insertions(+) 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(); + } }