From d1bcc87e41d8d176ce58ee9e27a17ec93d0d7cb2 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 23 八月 2019 11:59:18 +0800
Subject: [PATCH] Merge branch 'mater-1.6.0' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |   46 ++++++++++++++++------------------------------
 1 files changed, 16 insertions(+), 30 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 63c8534..43b17bc 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
@@ -1,7 +1,6 @@
 package com.yeshi.fanli.service.impl.user;
 
 import java.math.BigDecimal;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -1267,32 +1266,9 @@
 			userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord);
 
 			UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
-
-			int expiryDay = 15;
-
-			SystemCoupon systemCoupon = userSystemCoupon.getSystemCoupon();
-			SystemCoupon coupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
-			if (coupon != null) {
-				expiryDay = coupon.getExpiryDay();
-			}
-
-			// 缁撴潫鏃ユ湡
-			Date endTime = null;
-			try {
-				// 浠婂ぉ鍦ㄥ唴  鍑忓幓涓�澶�
-				String endDay = DateUtil.plusDay(expiryDay - 1, new Date());
-				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
-				endTime = format.parse(endDay);
-			} catch (ParseException e) {
-				e.printStackTrace();
-			}
 			// 鐘舵�佸垵濮嬪寲
 			userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
 			userSystemCoupon.setUseTime(null);
-
-			// 鏈夋晥鏈熸椂闂撮噸鏂板畾涔�
-			userSystemCoupon.setStartTime(new Date());
-			userSystemCoupon.setEndTime(endTime);
 			userSystemCoupon.setUpdateTime(new Date());
 			userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
 		}
@@ -1390,8 +1366,10 @@
 		Date now = new Date();
 		Date endTime = userCoupon.getEndTime();
 		if (endTime != null && endTime.getTime() < now.getTime()) {
-			
-			// TODO 杩囨湡
+			// 杩囨湡
+			List<UserSystemCoupon> list = new ArrayList<UserSystemCoupon>();
+			list.add(userCoupon);
+			updateCounponInvalid(list);
 			return;
 		}
 		
@@ -1753,7 +1731,7 @@
 				userCouponVO.setCouponPicture(systemCoupon.getPicture());
 			}
 
-			if (UserSystemCoupon.STATE_CAN_USE == state) {
+			if (UserSystemCoupon.STATE_CAN_USE == state || UserSystemCoupon.STATE_IN_USE == state) {
 				int differentDays = 0;
 				if (endTime != null && startTime != null) {
 					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@@ -1853,12 +1831,19 @@
 							}
 							tips = tips.replace("{鍙d护}", tokenRecord.getToken()).replace("{涓嬭浇閾炬帴}", configService.get("app_down_link"));
 						}
+						
+						Date endTimeGive = record.getEndTime();
+						if (endTimeGive != null) {
+							Map<String, Object> remainDays = new HashMap<String, Object>();
+							remainDays.put("content", "鍓╀綑" + DateUtil.dateDiff2(new Date(), endTimeGive) + "杩囨湡");
+							remainDays.put("fontColor", "#F14242");
+							userCouponVO.setRemainDays(remainDays);
+						}
 					}
 				} else {
 					tips = "";
 				}
 				userCouponVO.setGiveTips(tips);
-				
 			} else if (UserSystemCoupon.STATE_END_USE == state) {
 				if (give && CouponTypeEnum.freeCouponGive == type) {
 					userCouponVO.setState(UserSystemCoupon.STATE_GIVE_END);
@@ -2006,8 +1991,9 @@
 			Date now = new Date();
 			Date endTime = userCoupon.getEndTime();
 			if (endTime != null && endTime.getTime() < now.getTime()) {
-				
-				// TODO 杩囨湡
+				List<UserSystemCoupon> list = new ArrayList<UserSystemCoupon>();
+				list.add(userCoupon);
+				updateCounponInvalid(list);
 				continue;
 			}
 			

--
Gitblit v1.8.0