From 84dd8c1579ea198aff6ca8afac05a5e8f6af9faf Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 21 五月 2021 10:46:22 +0800
Subject: [PATCH] 淘礼金功能完善
---
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushInfoServiceImpl.java | 747 +++++++++++++++++++++++++++++----------------------------
1 files changed, 378 insertions(+), 369 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushInfoServiceImpl.java
index ee9690a..10d2b17 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushInfoServiceImpl.java
@@ -1,369 +1,378 @@
-package com.yeshi.fanli.service.impl.push;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import com.yeshi.fanli.entity.SystemEnum;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-import com.yeshi.fanli.dao.mybatis.push.PushInfoMapper;
-import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
-import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
-import com.yeshi.fanli.entity.push.PushInfo;
-import com.yeshi.fanli.entity.push.PushInfo.PushTypeEnum;
-import com.yeshi.fanli.exception.push.PushException;
-import com.yeshi.fanli.exception.push.PushInfoException;
-import com.yeshi.fanli.service.inter.config.ConfigService;
-import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
-import com.yeshi.fanli.service.inter.push.PushInfoService;
-import com.yeshi.fanli.service.inter.push.PushService;
-import com.yeshi.fanli.util.StringUtil;
-
-import net.sf.json.JSONObject;
-
-@Service
-public class PushInfoServiceImpl implements PushInfoService {
-
- @Resource
- private PushService pushService;
-
- @Resource
- private UserSystemMsgService userSystemMsgService;
-
- @Resource
- private PushInfoMapper pushInfoMapper;
-
- @Override
- public void save(PushInfo record) throws PushInfoException, Exception {
- if (record == null) {
- throw new PushInfoException(1, "鍙傛暟涓嶆纭�");
- }
-
- PushTypeEnum type = record.getType();
- if (type == null) {
- throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鑳戒负绌�");
- }
-
- String title = record.getTitle();
- if (title == null || title.trim().length() == 0) {
- throw new PushInfoException(1, "鏍囬涓嶈兘涓虹┖");
- }
-
- String arrayAndroid = record.getArrayAndroid();
- String arrayIOS = record.getArrayIOS();
- if (StringUtil.isNullOrEmpty(arrayIOS) && StringUtil.isNullOrEmpty(arrayAndroid)) {
- throw new PushInfoException(1, "鎺ㄩ�佺増鏈笉鑳戒负绌�");
- }
-
- // 瀹氭椂鏃堕棿
- Boolean timeTask = record.isTimeTask();
- if (timeTask != null && timeTask) {
- String controlTime_str = record.getControlTime_str();
- if (controlTime_str == null || controlTime_str.trim().length() == 0) {
- throw new PushInfoException(1, "棰勮鏃堕棿涓嶈兘涓虹┖");
- }
-
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- controlTime_str = controlTime_str.replaceAll("T", " ");
- record.setControlTime(format.parse(controlTime_str));
- } else {
- record.setControlTime(null);
- }
-
- String url = record.getUrl();
- String content = record.getContent();
- if (StringUtil.isNullOrEmpty(url) && StringUtil.isNullOrEmpty(content)) {
- throw new PushInfoException(1, "鎺ㄩ�佸唴瀹规垨URL涓嶈兘涓虹┖");
- }
-
- if (url != null && (url.trim().length() == 0 || url.equalsIgnoreCase("null"))) {
- record.setUrl(null);
- }
-
- if (content != null && (content.trim().length() == 0 || content.equalsIgnoreCase("null"))) {
- record.setContent(null);
- }
-
- String uids = record.getUids();
- if (uids != null && (uids.trim().length() == 0 || uids.equalsIgnoreCase("null"))) {
- record.setUids(null);
- }
-
- // 鏁版嵁杞崲json
- convertJson(record);
- record.setState(PushInfo.STATE_INIT);
-
- Long id = record.getId();
- if (id == null) {
- record.setCreateTime(new Date());
- record.setUpdateTime(new Date());
- pushInfoMapper.insert(record);
- } else {
- // 淇敼
- PushInfo current = pushInfoMapper.selectByPrimaryKey(id);
- if (current == null) {
- throw new PushInfoException(1, "璇ヨ褰曞凡涓嶅瓨鍦�");
- }
-
- if (PushInfo.STATE_SUCCESS == current.getState()) {
- throw new PushInfoException(1, "宸叉帹閫佹垚鍔熺殑淇℃伅涓嶈兘淇敼");
- }
- record.setCreateTime(current.getCreateTime());
- record.setUpdateTime(new Date());
- pushInfoMapper.updateByPrimaryKey(record);
- }
- }
-
-
- /**
- * 杞崲json
- */
- public void convertJson(PushInfo record) {
- JSONObject json = new JSONObject();
- String url = record.getUrl();
- if (StringUtil.isNullOrEmpty(url)) {
- url = "";
- }
- json.put("url", url);
- json.put("ios", convertVersion(record.getArrayIOS()));
- json.put("android", convertVersion(record.getArrayAndroid()));
- record.setJsonData(json.toString());
- }
-
- /**
- * 杞崲list
- */
- public String convertVersion(String array) {
- String versions = "";
- if (array != null && array.trim().length() > 0) {
- Gson gson = new Gson();
- List<String> list = gson.fromJson(array, new TypeToken<ArrayList<String>>() {
- }.getType());
-
- if (list != null && list.size() > 0) {
-
- for (String version : list) {
- versions += version + ",";
- }
- if (versions.endsWith(",")) {
- versions = versions.substring(0, versions.length() - 1);
- }
- }
- }
- return versions;
- }
-
- @Override
- public void deleteBatchByPrimaryKey(List<Long> list) {
- pushInfoMapper.deleteBatchByPrimaryKey(list);
- }
-
- @Override
- public List<PushInfo> listQuery(long start, int count, String key, Integer keyType, Integer state, String type, SystemEnum system) {
-
- List<PushInfo> list = pushInfoMapper.listQuery(start, count, key, keyType, state, type, system);
- if (list == null || list.size() == 0) {
- return list;
- }
-
- for (PushInfo pushInfo : list) {
- Date controlTime = pushInfo.getControlTime();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
- if (controlTime == null) {
- pushInfo.setTimeTask(false);
- pushInfo.setControlTime_str("");
- } else {
- pushInfo.setTimeTask(true);
- pushInfo.setControlTime_str(sdf.format(controlTime));
- }
-
- String jsonData = pushInfo.getJsonData();
- JSONObject json = JSONObject.fromObject(jsonData);
- String url = json.getString("url");
- pushInfo.setUrl(url);
-
- List<String> listIOS = new ArrayList<String>();
- String versionsIOS = json.getString("ios");
- if (versionsIOS != null && versionsIOS.trim().length() > 0) {
- listIOS = Arrays.asList(versionsIOS.split(","));
- }
- pushInfo.setListIOS(listIOS);
-
- List<String> listAndroid = new ArrayList<String>();
- String versionsAndroid = json.getString("android");
- if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
- listAndroid = Arrays.asList(versionsAndroid.split(","));
- }
- pushInfo.setListAndroid(listAndroid);
- }
-
- return list;
- }
-
- @Override
- public long countQuery(String key, Integer keyType, Integer state, String type, SystemEnum system) {
- return pushInfoMapper.countQuery(key, keyType, state, type, system);
- }
-
- @Override
- public List<PushInfo> listTask(SystemEnum system) {
- return pushInfoMapper.listTask(system);
- }
-
- @Override
- public void handPush(Long id) throws Exception, PushInfoException, PushException {
- PushInfo record = pushInfoMapper.selectByPrimaryKey(id);
- if (record == null) {
- throw new PushInfoException(1, "鎺ㄩ�佷俊鎭凡涓嶅瓨鍦�");
- }
- // 鎵ц鎺ㄩ��
- executePush(record);
-
- record.setState(PushInfo.STATE_SUCCESS);
- record.setPushTime(new Date());
- record.setUpdateTime(new Date());
- pushInfoMapper.updateByPrimaryKey(record);
- }
-
- @Override
- public void taskPush(PushInfo record) {
- String msg = null;
- int state = PushInfo.STATE_FAIL;
- try {
- // 鎵ц鎺ㄩ��
- executePush(record);
- state = PushInfo.STATE_SUCCESS;
- } catch (PushInfoException e) {
- msg = e.getMsg();
- } catch (PushException e) {
- msg = e.getMsg();
- } catch (Exception e) {
- msg = "绯荤粺鎺ㄩ�佸け璐�";
- }
- record.setState(state);
- record.setPushTime(new Date());
- record.setRemark(msg);
- record.setUpdateTime(new Date());
- pushInfoMapper.updateByPrimaryKey(record);
- }
-
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void executePush(PushInfo record) throws Exception, PushInfoException, PushException {
-
- if (PushInfo.STATE_SUCCESS == record.getState()) {
- throw new PushInfoException(1, "璇ヤ俊鎭笉鑳介噸澶嶆帹閫�");
- }
-
- String title = record.getTitle();
- if (title == null || title.trim().length() == 0) {
- throw new PushInfoException(1, "鏍囬涓嶈兘涓虹┖");
- }
-
- String jsonData = record.getJsonData();
- if (StringUtil.isNullOrEmpty(jsonData) && StringUtil.isNullOrEmpty(jsonData)) {
- throw new PushInfoException(1, "鎺ㄩ�佺増鏈笉鑳戒负绌�");
- }
-
- JSONObject json = JSONObject.fromObject(jsonData);
- String url = json.getString("url");
- String content = record.getContent();
- if (StringUtil.isNullOrEmpty(url) && StringUtil.isNullOrEmpty(content)) {
- throw new PushInfoException(1, "鎺ㄩ�佸唴瀹规垨URL涓嶈兘涓虹┖");
- }
-
- List<String> listIOS = new ArrayList<String>();
- String versionsIOS = json.getString("ios");
- if (versionsIOS != null && versionsIOS.trim().length() > 0) {
- if (versionsIOS.contains("鍏ㄦ帹")) {
- listIOS = null;
- } else {
- listIOS = Arrays.asList(versionsIOS.split(","));
- }
- }
-
- List<String> listAndroid = new ArrayList<String>();
- String versionsAndroid = json.getString("android");
- if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
- if (versionsAndroid.contains("鍏ㄦ帹")) {
- listAndroid = null;
- } else {
- listAndroid = Arrays.asList(versionsAndroid.split(","));
- }
- }
-
- List<String> listuid = null;
- String uids = record.getUids();
- if (uids != null && uids.trim().length() > 0) {
- listuid = Arrays.asList(uids.split(","));
- if (listuid == null || listuid.size() == 0) {
- throw new PushInfoException(1, "鐢ㄦ埛id鏍煎紡涓嶆纭�");
- }
- }
-
- PushTypeEnum type = record.getType();
- if (type == null) {
- throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鑳戒负绌�");
- }
-
- int pushWay = 0;
- if (PushTypeEnum.ZNX == type) {
- pushWay = 1;
- } else if (PushTypeEnum.URL == type) {
- pushWay = 2;
- } else if (PushTypeEnum.BAICHUAN == type) {
- pushWay = 3;
- } else {
- throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鍖归厤");
- }
-
- if (listuid == null) { // 鍏ㄦ帹
- switch (pushWay) {
- case 1: // 绔欏唴淇�
- pushService.pushZNX(null, title, content, listIOS, listAndroid, record.getSystem());
- break;
- case 2: // 缃戦〉鎺ㄩ��
- pushService.pushUrl(null, title, content, url, listIOS, listAndroid, record.getSystem());
- break;
- case 3: // 鐧惧窛
- pushService.pushBaiChuanUrl(null, title, content, url, listIOS, listAndroid, record.getSystem());
- break;
- default:
- throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鍖归厤");
- }
-
- } else {
- for (String str_uid : listuid) {
- if (str_uid != null && str_uid.trim().length() > 0) {
- long uid = Long.parseLong(str_uid);
- switch (pushWay) {
- case 1: // 绔欏唴淇�
- pushService.pushZNX(uid, title, content, listIOS, listAndroid, record.getSystem());
- userSystemMsgService.addUserSystemMsg(uid, UserSystemMsgTypeEnum.question, title, content,
- UserSystemMsg.TIME_TAG_COMMON, null);
- break;
- case 2: // 缃戦〉鎺ㄩ��
- pushService.pushUrl(uid, title, content, url, listIOS, listAndroid, record.getSystem());
- break;
- case 3: // 鐧惧窛
- pushService.pushBaiChuanUrl(uid, title, content, url, listIOS, listAndroid, record.getSystem());
- break;
- default:
- throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鍖归厤");
- }
- }
- }
- }
-
-
- }
-}
+package com.yeshi.fanli.service.impl.push;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.SystemEnum;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.yeshi.fanli.dao.mybatis.push.PushInfoMapper;
+import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
+import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
+import com.yeshi.fanli.entity.push.PushInfo;
+import com.yeshi.fanli.entity.push.PushInfo.PushTypeEnum;
+import com.yeshi.fanli.exception.push.PushException;
+import com.yeshi.fanli.exception.push.PushInfoException;
+import com.yeshi.fanli.service.inter.config.ConfigService;
+import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
+import com.yeshi.fanli.service.inter.push.PushInfoService;
+import com.yeshi.fanli.service.inter.push.PushService;
+import com.yeshi.fanli.util.StringUtil;
+
+import net.sf.json.JSONObject;
+
+@Service
+public class PushInfoServiceImpl implements PushInfoService {
+
+ @Resource
+ private PushService pushService;
+
+ @Resource
+ private UserSystemMsgService userSystemMsgService;
+
+ @Resource
+ private PushInfoMapper pushInfoMapper;
+
+ @Override
+ public void save(PushInfo record) throws PushInfoException, Exception {
+ if (record == null) {
+ throw new PushInfoException(1, "鍙傛暟涓嶆纭�");
+ }
+
+ PushTypeEnum type = record.getType();
+ if (type == null) {
+ throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鑳戒负绌�");
+ }
+
+ String title = record.getTitle();
+ if (title == null || title.trim().length() == 0) {
+ throw new PushInfoException(1, "鏍囬涓嶈兘涓虹┖");
+ }
+
+ String arrayAndroid = record.getArrayAndroid();
+ String arrayIOS = record.getArrayIOS();
+ if (StringUtil.isNullOrEmpty(arrayIOS) && StringUtil.isNullOrEmpty(arrayAndroid)) {
+ throw new PushInfoException(1, "鎺ㄩ�佺増鏈笉鑳戒负绌�");
+ }
+
+ // 瀹氭椂鏃堕棿
+ Boolean timeTask = record.isTimeTask();
+ if (timeTask != null && timeTask) {
+ String controlTime_str = record.getControlTime_str();
+ if (controlTime_str == null || controlTime_str.trim().length() == 0) {
+ throw new PushInfoException(1, "棰勮鏃堕棿涓嶈兘涓虹┖");
+ }
+
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ controlTime_str = controlTime_str.replaceAll("T", " ");
+ record.setControlTime(format.parse(controlTime_str));
+ } else {
+ record.setControlTime(null);
+ }
+
+ String url = record.getUrl();
+ String content = record.getContent();
+ if (StringUtil.isNullOrEmpty(url) && StringUtil.isNullOrEmpty(content)) {
+ throw new PushInfoException(1, "鎺ㄩ�佸唴瀹规垨URL涓嶈兘涓虹┖");
+ }
+
+ if (url != null && (url.trim().length() == 0 || url.equalsIgnoreCase("null"))) {
+ record.setUrl(null);
+ }
+
+ if (content != null && (content.trim().length() == 0 || content.equalsIgnoreCase("null"))) {
+ record.setContent(null);
+ }
+
+ String uids = record.getUids();
+ if (uids != null && (uids.trim().length() == 0 || uids.equalsIgnoreCase("null"))) {
+ record.setUids(null);
+ }
+
+ // 鏁版嵁杞崲json
+ convertJson(record);
+ record.setState(PushInfo.STATE_INIT);
+
+ Long id = record.getId();
+ if (id == null) {
+ record.setCreateTime(new Date());
+ record.setUpdateTime(new Date());
+ pushInfoMapper.insert(record);
+ } else {
+ // 淇敼
+ PushInfo current = pushInfoMapper.selectByPrimaryKey(id);
+ if (current == null) {
+ throw new PushInfoException(1, "璇ヨ褰曞凡涓嶅瓨鍦�");
+ }
+
+ if (PushInfo.STATE_SUCCESS == current.getState()) {
+ throw new PushInfoException(1, "宸叉帹閫佹垚鍔熺殑淇℃伅涓嶈兘淇敼");
+ }
+ record.setCreateTime(current.getCreateTime());
+ record.setUpdateTime(new Date());
+ pushInfoMapper.updateByPrimaryKey(record);
+ }
+ }
+
+
+ /**
+ * 杞崲json
+ */
+ public void convertJson(PushInfo record) {
+ JSONObject json = new JSONObject();
+ String url = record.getUrl();
+ if (StringUtil.isNullOrEmpty(url)) {
+ url = "";
+ }
+ json.put("url", url);
+ json.put("ios", convertVersion(record.getArrayIOS()));
+ json.put("android", convertVersion(record.getArrayAndroid()));
+ record.setJsonData(json.toString());
+ }
+
+ /**
+ * 杞崲list
+ */
+ public String convertVersion(String array) {
+ String versions = "";
+ if (array != null && array.trim().length() > 0) {
+ Gson gson = new Gson();
+ List<String> list = gson.fromJson(array, new TypeToken<ArrayList<String>>() {
+ }.getType());
+
+ if (list != null && list.size() > 0) {
+
+ for (String version : list) {
+ versions += version + ",";
+ }
+ if (versions.endsWith(",")) {
+ versions = versions.substring(0, versions.length() - 1);
+ }
+ }
+ }
+ return versions;
+ }
+
+ @Override
+ public void deleteBatchByPrimaryKey(List<Long> list) {
+ pushInfoMapper.deleteBatchByPrimaryKey(list);
+ }
+
+ @Override
+ public List<PushInfo> listQuery(long start, int count, String key, Integer keyType, Integer state, String type, SystemEnum system) {
+
+ List<PushInfo> list = pushInfoMapper.listQuery(start, count, key, keyType, state, type, system);
+ if (list == null || list.size() == 0) {
+ return list;
+ }
+
+ for (PushInfo pushInfo : list) {
+ Date controlTime = pushInfo.getControlTime();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
+ if (controlTime == null) {
+ pushInfo.setTimeTask(false);
+ pushInfo.setControlTime_str("");
+ } else {
+ pushInfo.setTimeTask(true);
+ pushInfo.setControlTime_str(sdf.format(controlTime));
+ }
+
+ String jsonData = pushInfo.getJsonData();
+ JSONObject json = JSONObject.fromObject(jsonData);
+ String url = json.getString("url");
+ pushInfo.setUrl(url);
+
+ List<String> listIOS = new ArrayList<String>();
+ String versionsIOS = json.getString("ios");
+ if (versionsIOS != null && versionsIOS.trim().length() > 0) {
+ listIOS = Arrays.asList(versionsIOS.split(","));
+ }
+ pushInfo.setListIOS(listIOS);
+
+ List<String> listAndroid = new ArrayList<String>();
+ String versionsAndroid = json.getString("android");
+ if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
+ listAndroid = Arrays.asList(versionsAndroid.split(","));
+ }
+ pushInfo.setListAndroid(listAndroid);
+ }
+
+ return list;
+ }
+
+ @Override
+ public long countQuery(String key, Integer keyType, Integer state, String type, SystemEnum system) {
+ return pushInfoMapper.countQuery(key, keyType, state, type, system);
+ }
+
+ @Override
+ public List<PushInfo> listTask(SystemEnum system) {
+ return pushInfoMapper.listTask(system);
+ }
+
+ @Override
+ public void handPush(Long id) throws Exception, PushInfoException, PushException {
+ PushInfo record = pushInfoMapper.selectByPrimaryKey(id);
+ if (record == null) {
+ throw new PushInfoException(1, "鎺ㄩ�佷俊鎭凡涓嶅瓨鍦�");
+ }
+ // 鎵ц鎺ㄩ��
+ executePush(record);
+ record.setState(PushInfo.STATE_SUCCESS);
+ record.setPushTime(new Date());
+ record.setUpdateTime(new Date());
+ pushInfoMapper.updateByPrimaryKey(record);
+ }
+
+ @Override
+ public void taskPush(PushInfo record) {
+ String msg = null;
+ int state = PushInfo.STATE_FAIL;
+ try {
+ // 鎵ц鎺ㄩ��
+ executePush(record);
+ state = PushInfo.STATE_SUCCESS;
+ } catch (PushInfoException e) {
+ msg = e.getMsg();
+ } catch (PushException e) {
+ msg = e.getMsg();
+ } catch (Exception e) {
+ msg = "绯荤粺鎺ㄩ�佸け璐�";
+ }
+ record.setState(state);
+ record.setPushTime(new Date());
+ record.setRemark(msg);
+ record.setUpdateTime(new Date());
+ pushInfoMapper.updateByPrimaryKey(record);
+ }
+
+ @Override
+ public PushInfo selectByPrimaryKey(Long id) {
+ return pushInfoMapper.selectByPrimaryKey(id);
+ }
+
+ @Override
+ public void updateSelectiveByPrimaryKey(PushInfo info) {
+ pushInfoMapper.updateByPrimaryKeySelective(info);
+ }
+
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void executePush(PushInfo record) throws Exception, PushInfoException, PushException {
+
+ if (PushInfo.STATE_SUCCESS == record.getState()) {
+ throw new PushInfoException(1, "璇ヤ俊鎭笉鑳介噸澶嶆帹閫�");
+ }
+
+ String title = record.getTitle();
+ if (title == null || title.trim().length() == 0) {
+ throw new PushInfoException(1, "鏍囬涓嶈兘涓虹┖");
+ }
+
+ String jsonData = record.getJsonData();
+ if (StringUtil.isNullOrEmpty(jsonData) && StringUtil.isNullOrEmpty(jsonData)) {
+ throw new PushInfoException(1, "鎺ㄩ�佺増鏈笉鑳戒负绌�");
+ }
+
+ JSONObject json = JSONObject.fromObject(jsonData);
+ String url = json.getString("url");
+ String content = record.getContent();
+ if (StringUtil.isNullOrEmpty(url) && StringUtil.isNullOrEmpty(content)) {
+ throw new PushInfoException(1, "鎺ㄩ�佸唴瀹规垨URL涓嶈兘涓虹┖");
+ }
+
+ List<String> listIOS = new ArrayList<String>();
+ String versionsIOS = json.getString("ios");
+ if (versionsIOS != null && versionsIOS.trim().length() > 0) {
+ if (versionsIOS.contains("鍏ㄦ帹")) {
+ listIOS = null;
+ } else {
+ listIOS = Arrays.asList(versionsIOS.split(","));
+ }
+ }
+
+ List<String> listAndroid = new ArrayList<String>();
+ String versionsAndroid = json.getString("android");
+ if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
+ if (versionsAndroid.contains("鍏ㄦ帹")) {
+ listAndroid = null;
+ } else {
+ listAndroid = Arrays.asList(versionsAndroid.split(","));
+ }
+ }
+
+ List<String> listuid = null;
+ String uids = record.getUids();
+ if (uids != null && uids.trim().length() > 0) {
+ listuid = Arrays.asList(uids.split(","));
+ if (listuid == null || listuid.size() == 0) {
+ throw new PushInfoException(1, "鐢ㄦ埛id鏍煎紡涓嶆纭�");
+ }
+ }
+
+ PushTypeEnum type = record.getType();
+ if (type == null) {
+ throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鑳戒负绌�");
+ }
+
+ int pushWay = 0;
+ if (PushTypeEnum.ZNX == type) {
+ pushWay = 1;
+ } else if (PushTypeEnum.URL == type) {
+ pushWay = 2;
+ } else if (PushTypeEnum.BAICHUAN == type) {
+ pushWay = 3;
+ } else {
+ throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鍖归厤");
+ }
+
+ if (listuid == null) { // 鍏ㄦ帹
+ switch (pushWay) {
+ case 1: // 绔欏唴淇�
+ pushService.pushZNX(null, title, content, listIOS, listAndroid, record.getSystem());
+ break;
+ case 2: // 缃戦〉鎺ㄩ��
+ pushService.pushUrl(null, title, content, url, listIOS, listAndroid, record.getSystem());
+ break;
+ case 3: // 鐧惧窛
+ pushService.pushBaiChuanUrl(null, title, content, url, listIOS, listAndroid, record.getSystem());
+ break;
+ default:
+ throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鍖归厤");
+ }
+
+ } else {
+ for (String str_uid : listuid) {
+ if (str_uid != null && str_uid.trim().length() > 0) {
+ long uid = Long.parseLong(str_uid);
+ switch (pushWay) {
+ case 1: // 绔欏唴淇�
+ pushService.pushZNX(uid, title, content, listIOS, listAndroid, record.getSystem());
+ userSystemMsgService.addUserSystemMsg(uid, UserSystemMsgTypeEnum.question, title, content,
+ UserSystemMsg.TIME_TAG_COMMON, null);
+ break;
+ case 2: // 缃戦〉鎺ㄩ��
+ pushService.pushUrl(uid, title, content, url, listIOS, listAndroid, record.getSystem());
+ break;
+ case 3: // 鐧惧窛
+ pushService.pushBaiChuanUrl(uid, title, content, url, listIOS, listAndroid, record.getSystem());
+ break;
+ default:
+ throw new PushInfoException(1, "鎺ㄩ�佺被鍨嬩笉鍖归厤");
+ }
+ }
+ }
+ }
+
+
+ }
+}
--
Gitblit v1.8.0