Selaa lähdekoodia

fix : SDK兼容通用客户端包

bilingfeng 1 vuosi sitten
vanhempi
commit
6853ffc955

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -23,7 +23,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <兼容客服支付, 且发送指定客服消息, 优化阿里云市场接口> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <兼容ios通用客户端> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 5 - 6
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/IAliApiService.java

@@ -11,16 +11,15 @@ import reactor.util.function.Tuple2;
 public interface IAliApiService {
 
     /**
-     * 阿里实名认证, 仅用在测试环境
+     * 语音呼叫
      *
-     * @param cardName : 名字
-     * @param cardId   : 身份证
-     * @return : 返回检测结果
+     * @param param  : 模块参数
+     * @param mobile : 手机号
      */
-    Tuple2<Boolean, String> authenticationCheck(String cardName, String cardId);
+    void phoneCall(String param, String mobile);
 
     /**
-     * 阿里实名认证, 包含归属地, 用在生产环境
+     * 阿里实名认证
      *
      * @param cardName : 名字
      * @param cardId   : 身份证

+ 5 - 30
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/AliApiServiceImpl.java

@@ -7,7 +7,6 @@ import com.zanxiang.game.module.sdk.service.IAliApiService;
 import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.*;
 import org.springframework.stereotype.Service;
@@ -18,8 +17,6 @@ import org.springframework.web.util.UriComponentsBuilder;
 import reactor.util.function.Tuple2;
 import reactor.util.function.Tuples;
 
-import java.util.UUID;
-
 /**
  * @author : lingfeng
  * @time : 2023-12-12
@@ -37,7 +34,8 @@ public class AliApiServiceImpl implements IAliApiService {
      */
     private final String APP_CODE = "f395b1587fc04a49a975f908660fb1e9";
 
-    public void phoneCall(String param) {
+    @Override
+    public void phoneCall(String param, String mobile) {
         RestTemplate restTemplate = new RestTemplate();
         String host = "https://jumfixed.market.alicloudapi.com/voice-notify/send";
         HttpHeaders headers = new HttpHeaders();
@@ -45,7 +43,7 @@ public class AliApiServiceImpl implements IAliApiService {
         headers.set("Content-Type", ContentType.FORM_URLENCODED.getValue());
         //参数
         MultiValueMap<String, String> requestParams = new LinkedMultiValueMap<>();
-        requestParams.add("mobile", "13100690278");
+        requestParams.add("mobile", mobile);
         requestParams.add("templateId", "JMJNAWUQOJP9");
         requestParams.add("param", param);
         String result = null;
@@ -59,29 +57,6 @@ public class AliApiServiceImpl implements IAliApiService {
         log.error("阿里语音呼叫结果, result : {}", result);
     }
 
-    @Override
-    public Tuple2<Boolean, String> authenticationCheck(String cardName, String cardId) {
-        String host = "https://dskj.market.alicloudapi.com/platform/check/verified";
-        String url = host + "?certCode=" + cardId + "&realName=" + cardName;
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("Authorization", "APPCODE " + this.APP_CODE);
-        headers.set("X-Ca-Nonce", UUID.randomUUID().toString());
-        HttpEntity httpEntity = new HttpEntity<>(headers);
-        CardCheckResult result;
-        try {
-            String resultStr = restTemplate.postForObject(url, httpEntity, String.class);
-            result = JsonUtil.toObj(resultStr, CardCheckResult.class);
-        } catch (Exception e) {
-            log.error("请求阿里实名认证接口异常(OLD), cardName : {}, cardId : {}, e : {}", cardName, cardId, e.getMessage());
-            throw new BaseException("请求阿里实名认证接口异常");
-        }
-        if (result == null || !result.isSuccess()) {
-            log.error("请求阿里实名认证接口返回值为空(OLD), cardName : {}, cardId : {}, result : {}", cardName, cardId, JsonUtil.toString(result));
-            throw new BaseException("实名认证失败");
-        }
-        return Tuples.of(result.isPast(), Strings.EMPTY);
-    }
-
     @Override
     public Tuple2<Boolean, String> userCardCheck(String cardName, String cardId) {
         String url = "https://eid.shumaidata.com/eid/check";
@@ -98,11 +73,11 @@ public class AliApiServiceImpl implements IAliApiService {
             String body = responseEntity.getBody();
             result = JsonUtil.toObj(body, CardCheckResult.class);
         } catch (Exception e) {
-            log.error("请求阿里实名认证接口异常(NEW), cardName : {}, cardId : {}, e : {}", cardName, cardId, e.getMessage());
+            log.error("请求阿里实名认证接口异常, cardName : {}, cardId : {}, e : {}", cardName, cardId, e.getMessage());
             throw new BaseException("请求阿里实名认证接口异常");
         }
         if (result == null || result.isFail()) {
-            log.error("请求阿里实名认证接口返回值为空(NEW),cardName : {},cardId : {}, result : {}", cardName, cardId, JsonUtil.toString(result));
+            log.error("请求阿里实名认证接口返回值为空,cardName : {},cardId : {}, result : {}", cardName, cardId, JsonUtil.toString(result));
             throw new BaseException("实名认证失败");
         }
         log.error("实名认证结果, result : {}", JsonUtil.toString(result));

+ 2 - 9
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameAppletServiceImpl.java

@@ -78,14 +78,12 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
 
     @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);
         GameAppletDTO gameAppletDTO = this.getByAppId(appId);
         GameAppletDTO.MsgConfigBean msgConfigBean = gameAppletDTO.getMsgConfigBean();
         if (msgConfigBean == null) {
             throw new BaseException("参数错误, 小游戏应用缺少消息推送配置");
         }
         String mySignature = SignUtil.SHA1(msgConfigBean.getMsgPushToken(), timestamp, nonce);
-        log.error("计算出来的签名, signature : {},  mySignature : {}", signature, mySignature);
         if (!Objects.equals(mySignature, signature)) {
             throw new BaseException("验证签名不匹配");
         }
@@ -94,8 +92,6 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
 
     @Override
     public String appletMsg(String appId, String signature, String timestamp, String nonce, String postData) throws Exception {
-        log.error("接收到事件消息, appId : {}, signature : {}, timestamp : {}, nonce : {}, postData : {}",
-                appId, signature, timestamp, nonce, postData);
         String result = HttpStatusEnum.SUCCESS.getMsg();
         if (Strings.isBlank(postData)) {
             return result;
@@ -134,7 +130,6 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
     }
 
     private String miPayMessage(AppletMsgDTO appletMsgDTO, GameAppletDTO gameAppletDTO) {
-        log.error("米大师支付回调 appletMsgDTO : {}", JsonUtil.toString(appletMsgDTO));
         Map<String, Object> failResultMap = new HashMap<>(2);
         failResultMap.put("ErrCode", 99999L);
         failResultMap.put("ErrMsg", "internal error");
@@ -152,9 +147,7 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
         }
         //支付内容
         String payload = miniGame.getPayload();
-        log.error("-----------> 支付信息 payload : {}", payload);
         AppletMsgDTO.PayloadBean payloadBean = JsonUtil.toObj(payload, AppletMsgDTO.PayloadBean.class);
-        log.error("-----------> payload 对象转换成功 payloadBean : {}", JsonUtil.toString(payloadBean));
         if (payloadBean == null) {
             log.error("米大师支付回调参数错误, 没有支付信息 appletMsgDTO : {}", JsonUtil.toString(appletMsgDTO));
             return failResult;
@@ -176,7 +169,6 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
                     mySign, miniGame.getPayEventSig(), appKey);
             return failResult;
         }
-        log.error("米大师支付回调签名匹配成功, 开始计算业务数据--------------->");
         //更新订单信息
         Boolean miPayNotifyResult = miPayService.miPayNotify(payloadBean.getOutTradeNo(),
                 Tuples.of(weChatPayInfo.getMchOrderNo(), weChatPayInfo.getTransactionId()));
@@ -202,7 +194,8 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
 
     private String customLinkMessage(GameAppletDTO gameAppletDTO, UserDTO userDTO) {
         //判断是否配置了第三方客服链接
-        KfLink kfLink = kfLinkService.getById(gameAppletDTO.getAppId());
+        KfLink kfLink = kfLinkService.getOne(new LambdaQueryWrapper<KfLink>()
+                .eq(KfLink::getAppId, gameAppletDTO.getAppId()));
         if (kfLink == null || Strings.isBlank(kfLink.getCustomLink())) {
             return HttpStatusEnum.SUCCESS.getMsg();
         }

+ 6 - 8
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/LoginServiceImpl.java

@@ -4,7 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.zanxiang.game.module.base.pojo.enums.BanStatusEnum;
 import com.zanxiang.game.module.base.pojo.enums.HttpStatusEnum;
-import com.zanxiang.game.module.mybatis.entity.*;
+import com.zanxiang.game.module.mybatis.entity.GameExt;
+import com.zanxiang.game.module.mybatis.entity.User;
+import com.zanxiang.game.module.mybatis.entity.UserCard;
+import com.zanxiang.game.module.mybatis.entity.UserShare;
 import com.zanxiang.game.module.sdk.constant.RedisKeyConstant;
 import com.zanxiang.game.module.sdk.enums.LoginTypeEnum;
 import com.zanxiang.game.module.sdk.enums.SmsTypeEnum;
@@ -94,9 +97,6 @@ public class LoginServiceImpl implements IRegisterLoginService {
     @Autowired
     private IUserAgentLogService userAgentLogService;
 
-    @Autowired
-    private IGameService gameService;
-
     @Autowired
     private IGameUserRoleService gameUserRoleService;
 
@@ -252,16 +252,14 @@ public class LoginServiceImpl implements IRegisterLoginService {
     }
 
     private Tuple2<Boolean, Long> userGuideCheck(User user) {
-        //游戏信息
-        Game game = gameService.getById(user.getGameId());
         //非导量用户
-        if (user.getRelationUserId() == null || game.getGuideGameId() == null) {
+        if (user.getRelationUserId() == null) {
             return Tuples.of(Boolean.FALSE, 0L);
         }
         //导量用户信息
         User relationUser = userService.getById(user.getRelationUserId());
         //确定导量匹配
-        if (relationUser != null && Objects.equals(relationUser.getRelationUserId(), user.getId())) {
+        if (relationUser != null) {
             try {
                 //监测角色是否导全, 或者导过之后又跑去小程序创建了其他角色
                 gameUserRoleService.userGuideGameRoleCheck(user, relationUser);

+ 1 - 6
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/PerformOrderServiceImpl.java

@@ -69,9 +69,6 @@ public class PerformOrderServiceImpl implements IPerformOrderService {
     @Autowired
     private IGameAppletService gameAppletService;
 
-    @Autowired
-    private IGameService gameService;
-
     @Override
     @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
     public Boolean pushCp(PlatformOrderDTO orderInfo) {
@@ -87,12 +84,10 @@ public class PerformOrderServiceImpl implements IPerformOrderService {
         }
         //用户信息
         User user = userService.getById(orderInfo.getUserId());
-        //游戏信息
-        Game game = gameService.getById(orderInfo.getGameId());
         //回调CP
         Map<String, String> map = new HashMap<>(9);
         //用户存在关联用户id, 且游戏存在导量游戏id, 判定为导量用户, 提交CP原始用户id
-        if (user.getRelationUserId() != null && game.getGuideGameId() != null) {
+        if (user.getRelationUserId() != null) {
             map.put("userId", String.valueOf(user.getRelationUserId()));
         } else {
             map.put("userId", String.valueOf(orderInfo.getUserId()));

+ 1 - 13
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/UserCardServiceImpl.java

@@ -17,7 +17,6 @@ import com.zanxiang.module.util.pojo.ResultVO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import reactor.util.function.Tuple2;
@@ -46,12 +45,6 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
     @Autowired
     private IAliApiService aliApiService;
 
-    /**
-     * 服务器域名
-     */
-    @Value("${server.domain}")
-    private String serverUrl;
-
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ResultVO<Boolean> userAuthentication(UserCardUpdateParam param, UserData userData) {
@@ -77,12 +70,7 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
             return ResultVO.fail(HttpStatusEnum.CARD_ID_ERROR.getMsg());
         }
         //阿里实名认证
-        Tuple2<Boolean, String> tuple2;
-        if (this.serverUrl.contains("test")) {
-            tuple2 = aliApiService.authenticationCheck(cardName, cardId);
-        } else {
-            tuple2 = aliApiService.userCardCheck(cardName, cardId);
-        }
+        Tuple2<Boolean, String> tuple2 = aliApiService.userCardCheck(cardName, cardId);
         //实名认证失败
         if (!tuple2.getT1()) {
             return ResultVO.fail(HttpStatusEnum.AUTHENTICATION_FAIL.getMsg());

+ 1 - 6
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/UserServiceImpl.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.game.module.base.pojo.enums.HttpStatusEnum;
-import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.entity.GameExt;
 import com.zanxiang.game.module.mybatis.entity.User;
 import com.zanxiang.game.module.mybatis.entity.UserCard;
@@ -50,9 +49,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     @Autowired
     private IUserCardService userCardService;
 
-    @Autowired
-    private IGameService gameService;
-
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ResultVO<Boolean> findPassword(FindPasswordParam param, UserData userData) {
@@ -192,8 +188,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
                 .token(userData.getToken())
                 .build();
         //判断用户是否为导量H5用户, 修正用户id
-        Game game = gameService.getById(user.getGameId());
-        if (user.getRelationUserId() != null && game.getGuideGameId() != null) {
+        if (user.getRelationUserId() != null) {
             userVO.setUserId(user.getRelationUserId());
         }
         log.error("获取用户详情返回用户信息, userVO : {}", JsonUtil.toString(userVO));

+ 4 - 4
game-module/game-module-sdk/src/main/resources/logback.xml

@@ -20,8 +20,8 @@
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
             <!-- 日志文件名格式 -->
             <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
+            <!-- 日志最大的历史 30天 -->
+            <maxHistory>30</maxHistory>
         </rollingPolicy>
         <encoder>
             <pattern>${log.pattern}</pattern>
@@ -42,8 +42,8 @@
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
             <!-- 日志文件名格式 -->
             <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 日志最大的历史 60天 -->
-            <maxHistory>60</maxHistory>
+            <!-- 日志最大的历史 30天 -->
+            <maxHistory>30</maxHistory>
         </rollingPolicy>
         <encoder>
             <pattern>${log.pattern}</pattern>