From 4114e871bcb3dce771b6aed64a1027d0bbb95ca6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 16 五月 2019 15:28:37 +0800
Subject: [PATCH] 增加动态用户

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java |  104 +++++++++++++++++----------------------------------
 1 files changed, 35 insertions(+), 69 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java
index 1589e60..e48dfb2 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/PushController.java
@@ -6,9 +6,6 @@
 
 import javax.annotation.Resource;
 
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,17 +14,16 @@
 
 import com.yeshi.fanli.entity.accept.AcceptData;
 import com.yeshi.fanli.entity.common.JumpDetailV2;
+import com.yeshi.fanli.entity.goods.CommonGoods;
 import com.yeshi.fanli.entity.push.DeviceActive;
-import com.yeshi.fanli.entity.push.DeviceTokenIOS;
 import com.yeshi.fanli.entity.push.PushGoods;
 import com.yeshi.fanli.entity.push.PushGoodsGroup;
 import com.yeshi.fanli.entity.push.PushGoodsRecord;
-import com.yeshi.fanli.entity.system.System;
+import com.yeshi.fanli.entity.system.BusinessSystem;
 import com.yeshi.fanli.exception.push.PushGoodsGroupException;
-import com.yeshi.fanli.goods.CommonGoods;
 import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
+import com.yeshi.fanli.service.inter.config.BusinessSystemService;
 import com.yeshi.fanli.service.inter.config.ConfigService;
-import com.yeshi.fanli.service.inter.config.SystemService;
 import com.yeshi.fanli.service.inter.push.DeviceActiveService;
 import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
 import com.yeshi.fanli.service.inter.push.IOSPushService;
@@ -40,12 +36,15 @@
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.factory.JumpDetailParamsFactory;
 
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
 @Controller
 @RequestMapping(value = "api/v1/push")
 public class PushController {
 
 	@Resource
-	private SystemService systemService;
+	private BusinessSystemService businessSystemService;
 
 	@Resource
 	private PushRecordService pushRecordService;
@@ -58,31 +57,32 @@
 
 	@Resource
 	private DeviceActiveService deviceActiveService;
-	
+
 	@Resource
 	private PushService pushService;
-	
+
 	@Resource
-	private PushGoodsService PushGoodsService;
-	
+	private PushGoodsService pushGoodsService;
+
 	@Resource
 	private PushGoodsGroupService pushGoodsGroupService;
-	
+
 	@Resource
 	private PushGoodsRecordService pushGoodsRecordService;
-	
+
 	@Resource
 	private JumpDetailV2Service jumpDetailV2Service;
-	
+
 	@Resource
 	private ConfigService configService;
-	
+
 	@Resource(name = "taskExecutor")
 	private TaskExecutor executor;
 
 	@RequestMapping(value = "callback", method = RequestMethod.POST)
 	public void callback(AcceptData acceptData, String pushId, PrintWriter out) {
-		System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ绯荤粺"));
 			return;
@@ -107,20 +107,8 @@
 	public void insertIOSDeviceToken(AcceptData acceptData, String deviceToken, PrintWriter out) {
 		if (!StringUtil.isNullOrEmpty(acceptData.getDevice()) && !StringUtil.isNullOrEmpty(deviceToken)) {
 			// 娣诲姞璁惧娲昏穬璁板綍
-			DeviceActive da = new DeviceActive();
-			da.setDeviceToken(deviceToken);
-			da.setPlatform(DeviceActive.PLATFORM_IOS);
-			da.setVersionCode(Integer.parseInt(acceptData.getVersion()));
-			deviceActiveService.addDeviceActive(da);
-
-			DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
-			if (deviceTokenIOS == null)
-				iosPushService.addDeviceToken(null, Integer.parseInt(acceptData.getVersion()), deviceToken,
-						acceptData.getDevice());
-			else {
-				deviceTokenIOS.setDevice(acceptData.getDevice());
-				iosPushService.updateDeviceToken(deviceTokenIOS);
-			}
+			iosPushService.addDeviceToken(null, Integer.parseInt(acceptData.getVersion()), deviceToken,
+					acceptData.getDevice());
 			out.print(JsonUtil.loadTrue(0, null, "鎴愬姛"));
 		}
 	}
@@ -136,24 +124,9 @@
 	@RequestMapping(value = "/uidBindDeviceToken", method = RequestMethod.POST)
 	public void uidBindIOSDeviceToken(AcceptData acceptData, Long uid, String deviceToken, PrintWriter out) {
 		if (uid != null && uid != 0 && !StringUtil.isNullOrEmpty(deviceToken)) {
-			// 娣诲姞璁惧娲昏穬璁板綍
-			DeviceActive da = new DeviceActive();
-			da.setDeviceToken(deviceToken);
-			da.setPlatform(DeviceActive.PLATFORM_IOS);
-			da.setVersionCode(Integer.parseInt(acceptData.getVersion()));
-			deviceActiveService.addDeviceActive(da);
 			// 娣诲姞token
-			DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
-			if (deviceTokenIOS != null) {
-				deviceTokenIOS.setUid(uid);
-				deviceTokenIOS.setDevice(acceptData.getDevice());
-				deviceTokenIOS.setVersion(Integer.parseInt(acceptData.getVersion()));
-				iosPushService.updateDeviceToken(deviceTokenIOS);
-			} else {
-				iosPushService.addDeviceToken(uid, Integer.parseInt(acceptData.getVersion()), deviceToken,
-						acceptData.getDevice());
-			}
-			out.print(JsonUtil.loadTrueResult(""));
+			iosPushService.addDeviceToken(uid, Integer.parseInt(acceptData.getVersion()), deviceToken,
+					acceptData.getDevice());
 		}
 	}
 
@@ -165,12 +138,8 @@
 	 */
 	@RequestMapping(value = "/unBind", method = RequestMethod.POST)
 	public void unBind(AcceptData acceptData, String deviceToken, PrintWriter out) {
-		if (!StringUtil.isNullOrEmpty(deviceToken)) {
-			DeviceTokenIOS deviceTokenIOS = iosPushService.getDeviceTokenByDeviceToken(deviceToken);
-			if (deviceTokenIOS != null) {
-				deviceTokenIOS.setUid(null);
-				iosPushService.updateDeviceToken(deviceTokenIOS);
-			}
+		if (!StringUtil.isNullOrEmpty(acceptData.getDevice())) {
+			iosPushService.unBindUidAndDevice(acceptData.getDevice());
 			out.print(JsonUtil.loadTrue(0, null, "瑙g粦鎴愬姛"));
 		}
 	}
@@ -202,10 +171,9 @@
 		deviceTokenHWService.unBindDeviceToken(acceptData.getDevice());
 		out.print(JsonUtil.loadTrueResult("鎴愬姛"));
 	}
-	
-	
+
 	/**
-	 * 瑙g粦鎺ㄩ��
+	 * 鍟嗗搧鎺ㄩ�佽褰�
 	 * 
 	 * @param acceptData
 	 * @param out
@@ -224,11 +192,11 @@
 
 			// 璁惧娉ㄥ唽鏃堕棿
 			Date createTime = deviceActive.getCreateTime();
-			count = PushGoodsService.countHistoryByPushTime(uid, createTime);
+			count = pushGoodsService.countHistoryByPushTime(uid, createTime);
 
 			int pageSize = Constant.PAGE_SIZE;
 
-			list = PushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, uid, createTime);
+			list = pushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, uid, createTime);
 			if (list != null && list.size() > 0) {
 				for (PushGoods pushGoods : list) {
 					JSONObject result = new JSONObject();
@@ -269,20 +237,18 @@
 
 					result.put("picture", picture);
 
-					String fontColor1 = "#888888";
-					String fontColor2 = "#F14242";
+					String fontColor1 = "#666666";
+					String fontColor2 = "#E5005C";
 					JSONArray array = new JSONArray();
-
-					
 
 					JSONObject contentJson1 = new JSONObject();
 					contentJson1.put("color", fontColor1);
-					contentJson1.put("content", "鏈鎺ㄩ�佸叡");
-					
+					contentJson1.put("content", "鏈鎺ㄨ崘鍏�");
+
 					JSONObject contentJson2 = new JSONObject();
 					contentJson2.put("color", fontColor2);
 					contentJson2.put("content", totalgoods);
-					
+
 					JSONObject contentJson3 = new JSONObject();
 					contentJson3.put("color", fontColor1);
 					contentJson3.put("content", "涓晢鍝�");
@@ -340,8 +306,8 @@
 						Long deviceId = deviceActive.getId();
 
 						for (PushGoods pushGoods : listPush) {
-							List<PushGoodsRecord> listRecord = pushGoodsRecordService.listByPushIdAndDeviceId(
-									pushGoods.getId(), deviceId);
+							List<PushGoodsRecord> listRecord = pushGoodsRecordService
+									.listByPushIdAndDeviceId(pushGoods.getId(), deviceId);
 							if (listRecord != null && listRecord.size() > 0) {
 								continue; // 宸茶璁板綍
 							}
@@ -362,5 +328,5 @@
 			});
 		}
 	}
-	
+
 }

--
Gitblit v1.8.0