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 |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 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 c1040fa..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) {
@@ -221,25 +230,29 @@
 		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澶�";
+				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);
@@ -325,6 +338,8 @@
 				exchange = null;
 			
 			return exchange;
+		} catch (IntegralExchangeException e) {
+			throw new IntegralExchangeException(1, e.getMsg());
 		} catch (Exception e) {
 			LogHelper.errorDetailInfo(e);
 			throw new IntegralExchangeException(1, "鍏戞崲寮傚父");

--
Gitblit v1.8.0