|
@@ -52,6 +52,34 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
return echoStr;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小游戏消息推送
|
|
|
+ *
|
|
|
+ * @param appId 应用程序id
|
|
|
+ * @param signature 签名
|
|
|
+ * @param timestamp 时间戳
|
|
|
+ * @param nonce 现时标志
|
|
|
+ * @param echoStr 回声str
|
|
|
+ * @return {@link String}
|
|
|
+ * @throws Exception 异常
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String appletMsg(String appId, String signature, String timestamp, String nonce, String echoStr, String postData) throws Exception {
|
|
|
+ log.error("接收到事件消息, appId : {}, signature : {}, timestamp : {}, nonce : {}, echoStr : {}, postData : {}",
|
|
|
+ appId, signature, timestamp, nonce, echoStr, postData);
|
|
|
+ GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
|
|
|
+ .eq(GameApplet::getAppId, appId));
|
|
|
+ if (gameApplet == null) {
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+ String mySignature = SignUtil.SHA1(gameApplet.getMsgPushToken(), timestamp, nonce);
|
|
|
+ log.error("计算出来的签名, signature : {}, mySignature : {}", signature, mySignature);
|
|
|
+ if (!Objects.equals(mySignature, signature)) {
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过游戏id查询
|
|
|
*
|