From b0d445fda153e5dac63ad66c8b74191601f0a4ef Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期三, 21 八月 2019 16:00:59 +0800 Subject: [PATCH] 兑换免单券 提示语修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 38 insertions(+), 8 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java index 3a2bc6e..38b279d 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java @@ -21,6 +21,7 @@ import com.yeshi.fanli.entity.money.UserMoneyDetail; import com.yeshi.fanli.exception.integral.IntegralExchangeException; import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service; import com.yeshi.fanli.service.inter.integral.CodePublishRecordService; import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService; @@ -45,6 +46,9 @@ @Resource private IntegralExchangeMapper integralExchangeMapper; + + @Resource + private ConfigService configService; @Resource private UserInfoExtraService userInfoExtraService; @@ -111,15 +115,22 @@ exchangeTip.setId(id); ExchangeTypeEnum type = exchange.getType(); if (ExchangeTypeEnum.inviteCodeActivate == type) { - //exchangeTip.setTip("娉細鍏戞崲鎴愬姛鍚庤鍒扳�滄秷鎭�-绯荤粺娑堟伅鈥濇煡鐪�"); - //exchangeTip.setGoldCoin(goldCoin + "閲戝竵"); exchangeTip.setType(type.name()); return exchangeTip; } + long exchangeCount = 0; + if (ExchangeTypeEnum.freeCouponBuy == type) { + exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, null); + if (exchangeCount >= 1) { + throw new IntegralExchangeException(1, "鑷喘鍏嶅崟鍒革紝浠呰兘鍏戞崲涓�娆�"); + } + } + Integer upperLimit = exchange.getUpperLimit(); if (upperLimit != null) { // 鏄惁鏈夐檺鍒舵瘡鏃ユ鏁� - long exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid); + Integer today = 1; + exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, today); if (exchangeCount >= upperLimit) { throw new IntegralExchangeException(1, "浠婃棩鍏戞崲宸茶揪涓婇檺"); } @@ -175,12 +186,22 @@ if (exchange == null) throw new IntegralExchangeException(1, "鍏戞崲鏂瑰紡涓嶅瓨鍦�"); + ExchangeTypeEnum type = exchange.getType(); + long exchangeCount = 0; + if (ExchangeTypeEnum.freeCouponBuy == type) { + exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, null); + if (exchangeCount >= 1) { + throw new IntegralExchangeException(1, "鑷喘鍏嶅崟鍒革紝浠呰兘鍏戞崲涓�娆�"); + } + } + Integer upperLimit = exchange.getUpperLimit(); if (upperLimit != null) { // 鏄惁鏈夐檺鍒舵瘡鏃ユ鏁� - exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid); + Integer today = 1; + exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, today); if (exchangeCount >= upperLimit) { - throw new IntegralExchangeException(1, "浠婃棩鍏戞崲宸茶揪涓婇檺"); + throw new IntegralExchangeException(1, "鍏戞崲宸茶揪涓婇檺"); } } @@ -191,17 +212,22 @@ } String thing = ""; + int couponNews = 0; try { - ExchangeTypeEnum type = exchange.getType(); if (ExchangeTypeEnum.freeCouponBuy == type) { thing = "鑷喘鍏嶅崟鍒�"; userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); + + couponNews = 1; } else if (ExchangeTypeEnum.freeCouponGive == type) { thing = "璧犻�佸厤鍗曞埜"; userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); + couponNews = 1; } else if (ExchangeTypeEnum.rebatePercentCoupon == type) { thing = "濂栧姳鍏嶅崟鍒�"; - userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(10)); + String percent = configService.get("exchange_rebate_percent"); + userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent)); + couponNews = 1; } else if (ExchangeTypeEnum.inviteCodePublish == type) { thing = "閭�璇风爜鍙戝竷鍗�"; if(codePublishRecordService.countValidRecord(uid) > 0) @@ -244,10 +270,14 @@ int surplus = goldCoinHas.intValue() - goldCoin.intValue(); exchange.setUserGoldCoin(surplus + "鏋�"); - // 鏇存柊閲戝竵 + // 鏇存柊閲戝竵 + 绂忓埄涓績娑堟伅鏁� + if (extraVO.getCouponNews() != null && extraVO.getCouponNews() > 0) + couponNews = couponNews + extraVO.getCouponNews(); + UserInfoExtraVO extraUpdate = new UserInfoExtraVO(); extraUpdate.setId(extraVO.getId()); extraUpdate.setGoldCoin(surplus); + extraUpdate.setCouponNews(couponNews); userInfoExtraService.saveUserInfoExtra(extraUpdate); // 娣诲姞鍏戞崲璁板綍 -- Gitblit v1.8.0