From 2a99c607e5c7dc640d3608b35a20b451e42922c3 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 17 九月 2019 09:45:02 +0800 Subject: [PATCH] 品牌 --- fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java | 45 +++++++++++++++++++++++++++++++++------------ 1 files changed, 33 insertions(+), 12 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 e63e0cb..a4913bf 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 @@ -20,6 +20,7 @@ import com.yeshi.fanli.entity.integral.IntegralExchange; import com.yeshi.fanli.entity.integral.IntegralExchange.ExchangeTypeEnum; import com.yeshi.fanli.entity.money.UserMoneyDetail; +import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; import com.yeshi.fanli.exception.integral.IntegralExchangeException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.config.ConfigService; @@ -113,6 +114,11 @@ if (exchange == null) throw new IntegralExchangeException(1, "鍏戞崲鏂瑰紡涓嶅瓨鍦�"); + Integer state = exchange.getState(); + if (state == null || state != 1) + throw new IntegralExchangeException(1, "鍏戞崲娲诲姩鏈紑鍚�"); + + Integer goldCoin = exchange.getGoldCoin(); ExchangeTipVO exchangeTip = new ExchangeTipVO(); @@ -190,9 +196,12 @@ if (exchange == null) throw new IntegralExchangeException(1, "鍏戞崲鏂瑰紡涓嶅瓨鍦�"); - ExchangeTypeEnum type = exchange.getType(); + Integer state = exchange.getState(); + if (state == null || state != 1) + throw new IntegralExchangeException(1, "鍏戞崲娲诲姩鏈紑鍚�"); long exchangeCount = 0; + ExchangeTypeEnum type = exchange.getType(); if (ExchangeTypeEnum.freeCouponBuy == type) { exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, null); if (exchangeCount >= 1) { @@ -218,30 +227,38 @@ String thing = ""; String thingNum = ""; int couponNews = 0; + boolean once = false; // 鍏戞崲涓�娆℃槸鍚︽秷澶� try { if (ExchangeTypeEnum.freeCouponBuy == type) { + List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid, CouponTypeEnum.freeCouponBuy.name()); + if (listCoupon != null && listCoupon.size() > 0) + throw new IntegralExchangeException(1, "鑷喘鍏嶅崟鍒革紝浠呰兘鍏戞崲涓�娆�"); + thing = "鑷喘鍏嶅崟鍒�"; thingNum = "1寮�"; - userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); - + userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); + once = true; couponNews = 1; } else if (ExchangeTypeEnum.freeCouponGive == type) { thing = "璧犻�佸厤鍗曞埜"; thingNum = "1寮�"; - userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); + userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); couponNews = 1; } else if (ExchangeTypeEnum.rebatePercentCoupon == type) { - thing = "濂栧姳鍏嶅崟鍒�"; - thingNum = "3澶�"; + thing = "杩斿埄濂栧姳鍒�"; + thingNum = "1寮�"; String percent = configService.get("exchange_rebate_percent"); - userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent)); + userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent)); couponNews = 1; } else if (ExchangeTypeEnum.inviteCodePublish == type) { thing = "閭�璇风爜鍙戝竷鍗�"; - thingNum = "1缁�"; + thingNum = "3澶�"; if(codePublishRecordService.countValidRecord(uid) > 0) throw new IntegralExchangeException(1, "涓夊ぉ涔嬪唴涓嶅彲閲嶅鍏戞崲"); codePublishRecordService.publishInviteCode(uid); + + exchange.setNeedJump(true); + exchange.setBtnName("鍘绘煡鐪�"); } else if (ExchangeTypeEnum.taoLiJin == type) { thing = "鎺ㄥ箍绾㈠寘"; thingNum = exchange.getAmount() + "鍏�"; @@ -317,7 +334,12 @@ } }); + if (once) // 鍏戞崲涔嬪悗娑堝け + exchange = null; + return exchange; + } catch (IntegralExchangeException e) { + throw new IntegralExchangeException(1, e.getMsg()); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new IntegralExchangeException(1, "鍏戞崲寮傚父"); @@ -367,7 +389,7 @@ @Override - public void exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException { + public String exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException { if (uid == null || uid <= 0) throw new IntegralExchangeException(1, "鐢ㄦ埛鏈櫥褰�"); @@ -401,7 +423,6 @@ throw new IntegralExchangeException(1, "鍏戞崲澶辫触锛岃鐢ㄦ埛閭�璇风爜涓嶅瓨鍦�"); String inviteCode = inviteExtra.getInviteCode(); - userInfoExtraService.activateInviteCode(uid, inviteExtra.getInviteCode()); // 鍓╀綑閲戝竵 int surplus = goldCoinHas.intValue() - goldCoin.intValue(); @@ -442,11 +463,11 @@ userOtherMsgNotificationService.exchangeMsg(uid, beizu, msgOther); } }); + + return inviteCode; } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new IntegralExchangeException(1, "鍏戞崲澶辫触"); } - - } } -- Gitblit v1.8.0