|
@@ -4,23 +4,34 @@ import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.ruoyi.app.utils.event.PushEventService;
|
|
|
|
|
+import com.ruoyi.common.utils.LocaleUtils;
|
|
|
|
|
+import com.ruoyi.common.utils.MessageUtils;
|
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
+import com.ruoyi.common.utils.spring.SpringUtils;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
|
|
public class PayPush {
|
|
public class PayPush {
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(PayPush.class);
|
|
|
|
|
+
|
|
|
//用户端推送
|
|
//用户端推送
|
|
|
- public void apppush(String cid,String title, String content, String body){
|
|
|
|
|
- System.out.println("用户端推送cid:"+cid);
|
|
|
|
|
- String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msduser?cid="+cid+
|
|
|
|
|
- "&title="+title+"&content="+content+"&payload="+body;
|
|
|
|
|
- String res="";
|
|
|
|
|
|
|
+ public void apppush(String cid, String title, String content, String body) {
|
|
|
|
|
+ System.out.println("用户端推送cid:" + cid);
|
|
|
|
|
+ String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msduser?cid=" + cid +
|
|
|
|
|
+ "&title=" + title + "&content=" + content + "&payload=" + body;
|
|
|
|
|
+ String res = "";
|
|
|
res = HttpUtil.get(url);
|
|
res = HttpUtil.get(url);
|
|
|
- JSONObject jsonObject = JSON.parseObject(res);
|
|
|
|
|
- System.out.println("=========================1111111111111111"+res);
|
|
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(res);
|
|
|
|
|
+ System.out.println("=========================1111111111111111" + res);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//用户端批量推送
|
|
//用户端批量推送
|
|
|
- public void userPushBatch(List<String> cid, String title, String content, String body){
|
|
|
|
|
|
|
+ public void userPushBatch(List<String> cid, String title, String content, String body) {
|
|
|
String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msduser";
|
|
String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msduser";
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|
|
@@ -41,17 +52,17 @@ public class PayPush {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//骑手端推送
|
|
//骑手端推送
|
|
|
- public void qspush(String cid,String title, String content, String body){
|
|
|
|
|
- String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msdrider?cid="+cid+
|
|
|
|
|
- "&title="+title+"&content="+content+"&payload="+body+"&sound=pushsound.caf";
|
|
|
|
|
- String res="";
|
|
|
|
|
|
|
+ public void qspush(String cid, String title, String content, String body) {
|
|
|
|
|
+ String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msdrider?cid=" + cid +
|
|
|
|
|
+ "&title=" + title + "&content=" + content + "&payload=" + body + "&sound=pushsound.caf";
|
|
|
|
|
+ String res = "";
|
|
|
res = HttpUtil.get(url);
|
|
res = HttpUtil.get(url);
|
|
|
- JSONObject jsonObject = JSON.parseObject(res);
|
|
|
|
|
- System.out.println("=========================用户推送"+res);
|
|
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(res);
|
|
|
|
|
+ System.out.println("=========================用户推送" + res);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//用户端批量推送
|
|
//用户端批量推送
|
|
|
- public void qsPushBatch(List<String> cid, String title, String content, String body){
|
|
|
|
|
|
|
+ public void qsPushBatch(List<String> cid, String title, String content, String body) {
|
|
|
String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msdrider";
|
|
String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msdrider";
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|
|
@@ -72,13 +83,150 @@ public class PayPush {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//商家端推送
|
|
//商家端推送
|
|
|
- public void shpush(String cid,String title, String content, String body){
|
|
|
|
|
- System.out.println("商家cid:"+cid);
|
|
|
|
|
- String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msdstore?cid="+cid+
|
|
|
|
|
- "&title="+title+"&content="+content+"&payload="+body;
|
|
|
|
|
- String res="";
|
|
|
|
|
|
|
+ public void shpush(String cid, String title, String content, String body) {
|
|
|
|
|
+ System.out.println("商家cid:" + cid);
|
|
|
|
|
+ String url = "https://fc-mp-20ccbe79-10f8-41d7-a06c-c42581f351c1.next.bspapp.com/msdstore?cid=" + cid +
|
|
|
|
|
+ "&title=" + title + "&content=" + content + "&payload=" + body;
|
|
|
|
|
+ String res = "";
|
|
|
res = HttpUtil.get(url);
|
|
res = HttpUtil.get(url);
|
|
|
- JSONObject jsonObject = JSON.parseObject(res);
|
|
|
|
|
- System.out.println("=========================商家推送"+res);
|
|
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(res);
|
|
|
|
|
+ System.out.println("=========================商家推送" + res);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 商家推送
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param push
|
|
|
|
|
+ * @param pushEventService
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param cid
|
|
|
|
|
+ * @param title
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ * @param body
|
|
|
|
|
+ */
|
|
|
|
|
+ public static void shPush(PayPush push, PushEventService pushEventService, Long userId, String cid, String title, String content, String body, String cidType) {
|
|
|
|
|
+ if (pushEventService != null) {
|
|
|
|
|
+ pushEventService.PublisherEvent(userId, title, content, body);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (cid == null || cid.trim().isEmpty()) {
|
|
|
|
|
+ log.error("商家推送失败:Device token is empty, userId:{}", userId);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ push.shpush(cid, title, content, body);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送前设置local信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param push
|
|
|
|
|
+ * @param pushEventService
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param cid
|
|
|
|
|
+ * @param title
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ * @param body
|
|
|
|
|
+ * @param cidType
|
|
|
|
|
+ * @param ddId
|
|
|
|
|
+ */
|
|
|
|
|
+ public static void shPushHandleLocal(PayPush push, PushEventService pushEventService, Long userId, String cid, String title, String content, String body, String cidType, String ddId) {
|
|
|
|
|
+ Locale local = LocaleUtils.getUserLocale(userId);
|
|
|
|
|
+ LocaleContextHolder.setLocale(local);
|
|
|
|
|
+ title = MessageUtils.message(title);
|
|
|
|
|
+ content = MessageUtils.message(content) + ",NO:" + ddId;
|
|
|
|
|
+ shPush(push, pushEventService, userId, cid, title, content, body, cidType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 骑手推送
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param pushEventService
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param cid
|
|
|
|
|
+ * @param title
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ * @param body
|
|
|
|
|
+ */
|
|
|
|
|
+ public static void qsPush(PayPush push, PushEventService pushEventService, Long userId, String cid, String title, String content, String body, String cidType) {
|
|
|
|
|
+ if (pushEventService != null) {
|
|
|
|
|
+ pushEventService.PublisherEvent(userId, title, content, body);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (cid == null || cid.trim().isEmpty()) {
|
|
|
|
|
+ log.error("骑手推送失败:Device token is empty, userId:{}", userId);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("useId{}:cid{}:cidType{}:content:{}", userId, cid, cidType, content);
|
|
|
|
|
+ log.info("给骑手发送进入uni推送:{},{},{},{}", userId, cid, cidType, content);
|
|
|
|
|
+ push.qspush(cid, title, content, body);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送前设置local信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param push
|
|
|
|
|
+ * @param pushEventService
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param cid
|
|
|
|
|
+ * @param title
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ * @param body
|
|
|
|
|
+ * @param cidType
|
|
|
|
|
+ * @param ddId
|
|
|
|
|
+ */
|
|
|
|
|
+ public static void qsPushHandleLocal(PayPush push, PushEventService pushEventService, Long userId, String cid, String title, String content, String body, String cidType, String ddId) {
|
|
|
|
|
+ Locale local = LocaleUtils.getUserLocale(userId);
|
|
|
|
|
+ LocaleContextHolder.setLocale(local);
|
|
|
|
|
+ title = MessageUtils.message(title);
|
|
|
|
|
+ content = MessageUtils.message(content) + ",NO:" + ddId;
|
|
|
|
|
+ qsPush(push, pushEventService, userId, cid, title, content, body, cidType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户推送
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param push
|
|
|
|
|
+ * @param pushEventService
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param cid
|
|
|
|
|
+ * @param title
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ * @param body
|
|
|
|
|
+ */
|
|
|
|
|
+ public static void userPush(PayPush push, PushEventService pushEventService, Long userId, String cid, String title, String content, String body, String cidType) {
|
|
|
|
|
+ if (pushEventService != null) {
|
|
|
|
|
+ pushEventService.PublisherEvent(userId, title, content, body);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (cid == null || cid.trim().isEmpty()) {
|
|
|
|
|
+ log.error("Device token is empty, cannot send push message");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ push.apppush(cid, title, content, body);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送前设置local信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param push
|
|
|
|
|
+ * @param pushEventService
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param cid
|
|
|
|
|
+ * @param title
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ * @param body
|
|
|
|
|
+ * @param cidType
|
|
|
|
|
+ * @param ddId
|
|
|
|
|
+ */
|
|
|
|
|
+ public static void userPushHandleLocal(PayPush push, PushEventService pushEventService, Long userId, String cid, String title, String content, String body, String cidType, String ddId) {
|
|
|
|
|
+ Locale local = LocaleUtils.getUserLocale(userId);
|
|
|
|
|
+ LocaleContextHolder.setLocale(local);
|
|
|
|
|
+ title = MessageUtils.message(title);
|
|
|
|
|
+ content = MessageUtils.message(content);
|
|
|
|
|
+ if (!StringUtils.isEmpty(ddId)) {
|
|
|
|
|
+ content = content + ",NO:" + ddId;
|
|
|
|
|
+ }
|
|
|
|
|
+ userPush(push, pushEventService, userId, cid, title, content, body, cidType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|