|  | @@ -10,9 +10,12 @@ import com.zanxiang.sdk.domain.dto.GameAppletDTO;
 | 
	
		
			
				|  |  |  import com.zanxiang.sdk.domain.params.UserData;
 | 
	
		
			
				|  |  |  import com.zanxiang.sdk.domain.vo.GameAppletVO;
 | 
	
		
			
				|  |  |  import com.zanxiang.sdk.service.GameAppletService;
 | 
	
		
			
				|  |  | +import com.zanxiang.sdk.util.SignUtil;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.util.Objects;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * @author : lingfeng
 | 
	
		
			
				|  |  |   * @time : 2022-07-08
 | 
	
	
		
			
				|  | @@ -23,7 +26,34 @@ import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApplet> implements GameAppletService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     * 通过游戏id和app id
 | 
	
		
			
				|  |  | +     * 小游戏消息推送
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param appId     应用程序id
 | 
	
		
			
				|  |  | +     * @param signature 签名
 | 
	
		
			
				|  |  | +     * @param timestamp 时间戳
 | 
	
		
			
				|  |  | +     * @param nonce     现时标志
 | 
	
		
			
				|  |  | +     * @param echoStr   回声str
 | 
	
		
			
				|  |  | +     * @return {@link String}
 | 
	
		
			
				|  |  | +     * @throws Exception 异常
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public String appletMsgCheck(String appId, String signature, String timestamp, String nonce, String echoStr) throws Exception {
 | 
	
		
			
				|  |  | +        log.error("验证参数, appId : {}, signature : {}, timestamp : {}, nonce : {}, echoStr : {}", appId, signature, timestamp, nonce, echoStr);
 | 
	
		
			
				|  |  | +        GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
 | 
	
		
			
				|  |  | +                .eq(GameApplet::getAppId, appId));
 | 
	
		
			
				|  |  | +        if (gameApplet == null) {
 | 
	
		
			
				|  |  | +            throw new BaseException("参数错误, 游戏小程序信息不存在");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        String mySignature = SignUtil.SHA1(gameApplet.getMsgPushToken(), timestamp, nonce);
 | 
	
		
			
				|  |  | +        log.error("计算出来的签名, signature : {},  mySignature : {}", signature, mySignature);
 | 
	
		
			
				|  |  | +        if (!Objects.equals(mySignature, signature)) {
 | 
	
		
			
				|  |  | +            throw new BaseException("签名不匹配");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return echoStr;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 通过游戏id查询
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @param gameId 游戏id
 | 
	
		
			
				|  |  |       * @return {@link GameAppletDTO}
 |