yujian
2019-01-22 2366d2ada9e67f915a06b51b3c5be08a00847f0c
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushServiceImpl.java
@@ -22,6 +22,7 @@
import com.yeshi.fanli.service.inter.user.AccountMessageService;
import com.yeshi.fanli.service.inter.user.SystemZnxService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
@Service
public class PushServiceImpl implements PushService {
@@ -54,20 +55,24 @@
   @Resource
   private XMPushService xmPushService;
   @Resource
   private PushRecordMapper pushRecordMapper;
   @Resource
   private AccountMessageMapper accountMessageMapper;
   @Async("pushExecutor")
   @Override
   public void pushGoods(Long uid, String url, String title, String content) throws PushException {
      String gids = url.split("id=")[1];
      String gid = gids.split("&")[0];
      if (StringUtil.isNullOrEmpty(gid))
         throw new PushException(1, "商品解析失败");
      if (StringUtil.isNullOrEmpty(title))
         throw new PushException(1, "请填写推送标题");
      if (StringUtil.isNullOrEmpty(content))
         throw new PushException(1, "请填写推送内容");
      PushRecord pushRecord = new PushRecord();
      pushRecord.setState(1);
@@ -76,10 +81,11 @@
      pushRecord.setTitle(title);
      pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
      pushRecord.setAccount(1);
      pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
      xmPushService.pushGoods(uid, Long.parseLong(gid), title, content);
      iosPushService.pushGoods(uid, Long.parseLong(gid), title, content);
      //hwPushService.pushGoods(uid, Long.parseLong(gid), title, content);
      // hwPushService.pushGoods(uid, Long.parseLong(gid), title, content);
      pushRecordMapper.insertSelective(pushRecord);
   }
@@ -87,12 +93,21 @@
   @Async("pushExecutor")
   @Override
   public void pushUrl(Long uid, String url, String title, String content) throws PushException {
      if (StringUtil.isNullOrEmpty(url))
         throw new PushException(1, "无推送链接");
      if (StringUtil.isNullOrEmpty(title))
         throw new PushException(1, "无推送标题");
      if (StringUtil.isNullOrEmpty(content))
         throw new PushException(1, "无推送内容");
      PushRecord pushRecord = new PushRecord();
      pushRecord.setState(1);
      pushRecord.setType(PushController.URL);
      pushRecord.setUrl(url);
      pushRecord.setTitle(title);
      pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
      pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
      xmPushService.pushUrl(uid, url, title, content);
      iosPushService.pushUrl(uid, url, title, content);
@@ -103,9 +118,13 @@
   @Async("pushExecutor")
   @Override
   public void pushZNX(Long uId, String title, String content) throws PushException {
      if (StringUtil.isNullOrEmpty(title))
         throw new PushException(1, "无推送标题");
      if (StringUtil.isNullOrEmpty(content))
         throw new PushException(1, "无推送内容");
      /* 无uid , 广播 数据插入系统表 */
      if (uId == null||uId==0) {
      if (uId == null || uId == 0) {
         // 插入数据库(系统站内信数据)
         SystemZnx systemZnx = new SystemZnx();
         systemZnx.setTitle(title);
@@ -118,6 +137,8 @@
         pushRecord.setState(1); // 成功
         pushRecord.setType(4); // 类型:站内信
         pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
         pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
         xmPushService.pushZNX(uId, null, systemZnx);
         iosPushService.pushZNX(uId, null, systemZnx);
         hwPushService.pushZNX(uId, null, systemZnx);
@@ -143,9 +164,25 @@
         pushRecord.setState(1); // 成功
         pushRecord.setType(PushController.ZNX); // 类型:站内信
         pushRecord.setAppName(Constant.systemCommonConfig.getProjectChineseName());
         pushRecord.setCreatetime(java.lang.System.currentTimeMillis());
         pushRecordMapper.insertSelective(pushRecord);
      }
   }
   @Override
   public void pushWEEX(Long uid, String title, String content, String weexUrl) throws PushException {
      if (StringUtil.isNullOrEmpty(title))
         throw new PushException(1, "无推送标题");
      if (StringUtil.isNullOrEmpty(content))
         throw new PushException(1, "无推送内容");
      iosPushService.pushWEEX(uid, title, content, weexUrl);
   }
   @Override
   public void pushBaiChuanUrl(Long uid, String title, String content, String url) throws PushException {
//      iosPushService.pushBaiChuanUrl(uid, title, content, url);
      xmPushService.pushBaiChuanUrl(uid, title, content, url);
   }
}