From 15bedcc619b1edb6eb987f9288db7670e5b38c46 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 07 五月 2022 19:42:23 +0800
Subject: [PATCH] bug修复

---
 app/src/main/java/com/yeshi/makemoney/app/service/manager/PushManager.java |   95 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/app/src/main/java/com/yeshi/makemoney/app/service/manager/PushManager.java b/app/src/main/java/com/yeshi/makemoney/app/service/manager/PushManager.java
index 9a6d00d..7a96afc 100644
--- a/app/src/main/java/com/yeshi/makemoney/app/service/manager/PushManager.java
+++ b/app/src/main/java/com/yeshi/makemoney/app/service/manager/PushManager.java
@@ -2,18 +2,24 @@
 
 import com.ks.lib.common.exception.ParamsException;
 import com.ks.push.exception.BPushDeviceTokenException;
-import com.ks.push.pojo.DO.BPushDeviceToken;
-import com.ks.push.pojo.DO.PushPlatform;
+import com.ks.push.exception.BPushTaskException;
+import com.ks.push.pojo.DO.*;
 import com.ks.push.service.BDeviceTokenService;
+import com.ks.push.service.BPushTaskService;
+import com.ks.push.utils.JPushUtil;
 import com.yeshi.makemoney.app.entity.SystemEnum;
+import com.yeshi.makemoney.app.entity.config.AppJumpType;
 import com.yeshi.makemoney.app.entity.config.SystemConfigKey;
 import com.yeshi.makemoney.app.service.inter.config.SystemConfigService;
 import com.yeshi.makemoney.app.vo.AcceptData;
 import org.apache.dubbo.config.annotation.Reference;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.util.Date;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author hxh
@@ -24,8 +30,11 @@
 @Component
 public class PushManager {
 
-//    @Reference(version = "1.0",check = false)
+    @Reference(version = "1.0", check = false)
     private BDeviceTokenService bdeviceTokenService;
+
+    @Reference(version = "1.0", check = false)
+    private BPushTaskService bPushTaskService;
 
     @Resource
     private SystemConfigService systemConfigService;
@@ -82,4 +91,82 @@
     }
 
 
+    /**
+     * @return void
+     * @author hxh
+     * @description 鎺ㄩ�佺鍒�
+     * @date 16:40 2022/5/7
+     * @param: system
+     * @param: uid
+     **/
+    public void pushSignIn(SystemEnum system, List<Long> uidList) throws BPushTaskException {
+        if (uidList == null || uidList.size() == 0) {
+            return;
+        }
+        Map<String, String> extras = new HashMap<>();
+        extras.put("type", AppJumpType.signIn.name());
+        String title = "绛惧埌鎻愰啋";
+        String content = "浠婃棩浣犺繕鏈鍒帮紝绛惧埌鏈�楂樺彲棰�150閲戝竵锛�";
+        push(system, uidList, title, content, extras);
+    }
+
+    /**
+     * @return void
+     * @author hxh
+     * @description 鎺ㄩ�侀噾甯佺粨绠�
+     * @date 16:41 2022/5/7
+     * @param: system
+     * @param: uid
+     * @param: goldCorn
+     * @param: money
+     **/
+    public void pushGoldCornSettle(SystemEnum system, Long uid, int goldCorn, BigDecimal money) throws BPushTaskException {
+        Map<String, String> extras = new HashMap<>();
+        extras.put("type", AppJumpType.extract.name());
+        String title = "鍒拌处鎻愰啋";
+        String content = String.format("鏄ㄦ棩閲戝竵鎶樼畻鎴愬姛锛屽叆璐�%s鍏�", money.setScale(2).toString());
+        push(system, Arrays.asList(new Long[]{uid}), title, content, extras);
+    }
+
+    /**
+     * @return void
+     * @author hxh
+     * @description 鎺ㄩ�佸唴瀹�
+     * @date 16:55 2022/5/7
+     * @param: system
+     * @param: uid
+     * @param: title
+     * @param: content
+     * @param: extras
+     **/
+    private void push(SystemEnum system, List<Long> uidList, String title, String content, Map<String, String> extras) throws BPushTaskException {
+        BPushTask bPushTask = new BPushTask();
+        BPushMessage message = new BPushMessage();
+        message.setMessage(false);
+        message.setExtras(extras);
+        message.setAndroidActivity(getPushIntent(system));
+        message.setTitle(title);
+        message.setContent(content);
+
+
+        bPushTask.setMessage(message);
+        bPushTask.setAppCode(systemConfigService.getValueCache(system, SystemConfigKey.androidPushAppCode));
+
+        BPushFilter filter = new BPushFilter();
+        if (uidList == null || uidList.size() == 0) {
+            //鎺ㄩ��30澶╁唴杩樻椿璺冪殑鐢ㄦ埛
+            filter.setMinActiveTime(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 30));
+        } else {
+            filter.setUidList(uidList.stream().map(item -> item + "").collect(Collectors.toList()));
+        }
+        bPushTask.setFilter(filter);
+        String taskId = bPushTaskService.createTask(bPushTask);
+        bPushTaskService.startPush(taskId);
+    }
+
+    private String getPushIntent(SystemEnum system) {
+        return JPushUtil.createIntent(systemConfigService.getValueCache(system, SystemConfigKey.androidPushActivity), system.getPackageName());
+    }
+
+
 }

--
Gitblit v1.8.0