From da36dbefcd945cc85d170c5c2e78682d13497f97 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 26 八月 2019 17:46:24 +0800
Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |   67 +++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
index 3289bbd..616bd92 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -204,7 +204,7 @@
 			coupon = systemCouponService.getCouponByType(couponType);
 		} else if (couponType.equals(CouponTypeEnum.rebatePercentCoupon.name())) {
 			// 闅忔満濂栧姳鍒�
-			if (percent == null || percent.compareTo(new BigDecimal(0)) > 0) {
+			if (percent == null || percent.compareTo(new BigDecimal(0)) < 1) {
 				randomRewardCoupon(1, uid, source);
 				return;
 			}  else {
@@ -1729,7 +1729,12 @@
 				continue; // 鍒镐俊鎭笉瀹屾暣
 			}
 
-			userCouponVO.setSource("鏉ユ簮锛�" + userCouponVO.getSource());
+			String source = userCouponVO.getSource();
+			if (source != null && "濂栧姳鍒稿ぉ澶╂娊".equals(source)) {
+				source = "澶╁ぉ鎶�";
+			}
+			
+			userCouponVO.setSource("鏉ユ簮锛�" + source);
 			userCouponVO.setCouponName(systemCoupon.getName());
 			userCouponVO.setCouponEffect(systemCoupon.getEffect());
 			userCouponVO.setCouponRule(systemCoupon.getRule());
@@ -1833,20 +1838,24 @@
 				userCouponVO.setCouponEffect("璧犻�佷腑");
 				userCouponVO.setCouponRule(systemCoupon.getRemark());
 				String tips = null;
+				
+				TokenTypeEnum tokenType = null;
 				if (CouponTypeEnum.freeCouponGive == type) {
 					userCouponVO.setState(UserSystemCoupon.STATE_GIVE_IN);
 					tips = configService.get("give_free_coupon_tips");
+					tokenType = TokenTypeEnum.freeCoupon;
 				}
 				
 				if (CouponTypeEnum.rebatePercentCoupon == type) {
 					userCouponVO.setState(UserSystemCoupon.STATE_GIVE_IN);
 					tips = configService.get("give_free_coupon_tips");
+					tokenType = TokenTypeEnum.rebatePercentCoupon;
 				}
 				
-				if (!StringUtil.isNullOrEmpty(tips)) {
+				if (!StringUtil.isNullOrEmpty(tips) && tokenType != null) {
 					UserSystemCouponGiveRecord record = userSystemCouponGiveRecordService.getRecordByUidAndCouponId(uid, userCouponVO.getId());
 					if (record != null) {
-						TokenRecord tokenRecord = tokenRecordService.getNearByTypeAndIdentify(CouponTypeEnum.freeCoupon.name(), record.getId().toString());
+						TokenRecord tokenRecord = tokenRecordService.getNearByTypeAndIdentify(tokenType.name(), record.getId().toString());
 						if (tokenRecord != null && !StringUtil.isNullOrEmpty(tokenRecord.getToken())) {
 							String projectChineseName = Constant.systemCommonConfig.getProjectChineseName();
 							while(tips.contains("{APP鍚嶇О}")) {
@@ -1865,28 +1874,40 @@
 						}
 					} 
 				} 
-			} else if (give && UserSystemCoupon.STATE_END_USE == state) {
-				userCouponVO.setCouponRule(systemCoupon.getRemark());
-				if (CouponTypeEnum.freeCouponGive == type) {
-					userCouponVO.setState(UserSystemCoupon.STATE_GIVE_END);
+			} else if (UserSystemCoupon.STATE_END_USE == state) {
+				
+				if (give) {
+					userCouponVO.setCouponRule(systemCoupon.getRemark());
+					if (CouponTypeEnum.freeCouponGive == type) {
+						userCouponVO.setState(UserSystemCoupon.STATE_GIVE_END);
+					}
+					
+					if (CouponTypeEnum.rebatePercentCoupon == type) {
+						userCouponVO.setState(UserSystemCoupon.STATE_GIVE_END);
+					}
+					
+					Date useTime = userCouponVO.getUseTime();
+					if (useTime != null) {
+						Map<String, Object> remainDays = new HashMap<String, Object>();
+						remainDays.put("content", "浜�" + sdf.format(useTime) + "鎴愬姛璧犻��");
+						remainDays.put("fontColor", "#CCCCCC");
+						userCouponVO.setRemainDays(remainDays);
+					}
+				} else {
+					Date useTime = userCouponVO.getUseTime();
+					if (useTime != null) {
+						Map<String, Object> remainDays = new HashMap<String, Object>();
+						remainDays.put("content", "浜�" + sdf.format(useTime) + "鎴愬姛浣跨敤");
+						remainDays.put("fontColor", "#CCCCCC");
+						userCouponVO.setRemainDays(remainDays);
+					}
 				}
 				
-				if (CouponTypeEnum.rebatePercentCoupon == type) {
-					userCouponVO.setState(UserSystemCoupon.STATE_GIVE_END);
-				}
-				
-				Date useTime = userCouponVO.getUseTime();
-				if (useTime != null) {
-					Map<String, Object> remainDays = new HashMap<String, Object>();
-					remainDays.put("content", "浜�" + sdf.format(useTime) + "鎴愬姛璧犻��");
-					remainDays.put("fontColor", "#999999");
-					userCouponVO.setRemainDays(remainDays);
-				}
 			}else if (UserSystemCoupon.STATE_OVERDUE == state) {
 				if (endTime != null) {
 					Map<String, Object> remainDays = new HashMap<String, Object>();
 					remainDays.put("content", "浜�" + sdf.format(endTime) + "杩囨湡");
-					remainDays.put("fontColor", "#999999");
+					remainDays.put("fontColor", "#CCCCCC");
 					userCouponVO.setRemainDays(remainDays);
 				}
 				
@@ -2027,11 +2048,7 @@
 		userCouponVO.setCouponTerm(couponTerm);
 		
 		Map<String, Object> remainDays = new HashMap<String, Object>();
-		
-		try {
-			remainDays.put("content", "鍓╀綑" + DateUtil.dateDiff2(new Date(), record.getGiveTime()) + "杩囨湡");
-		} catch (Exception e) {
-		}
+		remainDays.put("content", "鍓╀綑23鏃�59鍒嗚繃鏈�");
 		remainDays.put("fontColor", "#F14242");
 		userCouponVO.setRemainDays(remainDays);
 		

--
Gitblit v1.8.0