diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/game/party3rd/HotGameRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/game/party3rd/HotGameRestController.java index 9714d25d..d563f49b 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/game/party3rd/HotGameRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/game/party3rd/HotGameRestController.java @@ -7,14 +7,19 @@ import com.red.circle.component.game.hotgame.response.HotGameCoin; import com.red.circle.component.game.hotgame.response.HotGameErrorEnum; import com.red.circle.component.game.hotgame.response.HotGameResponse; import com.red.circle.framework.web.annotation.IgnoreResultResponse; +import com.red.circle.other.app.dto.clientobject.game.HotGameUpdateRequest; import com.red.circle.other.app.service.game.override.domain.HotGameUserProfile; import com.red.circle.other.app.service.game.override.service.HotGameService; import com.red.circle.tool.core.sequence.IdWorkerUtils; import com.red.circle.tool.core.text.StringUtils; import com.red.circle.tool.crypto.SecurityUtils; import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -46,7 +51,10 @@ public class HotGameRestController { } query.setToken(SecurityUtils.urlDecode(query.getToken())); - if (!query.verifySign(hotGameProperties.getSignKey())) { + + String sign = SecurityUtils.md5(Stream.of(query.getGameId(), query.getUid(), query.getToken(), hotGameProperties.getSignKey()).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(""))).toUpperCase(); + + if (!sign.equals(query.getSign())) { return new HotGameResponse() .setErrorCode(HotGameErrorEnum.SIGN_VERIFY_FAIL.getErrorCode()); } @@ -55,7 +63,7 @@ public class HotGameRestController { @IgnoreResultResponse @PostMapping("/updateBalance") - public HotGameResponse updateUserCoin(@RequestBody HotGameUserCoinUpdate update) { + public HotGameResponse updateUserCoin(@RequestBody HotGameUpdateRequest update) { if (Objects.isNull(update) || StringUtils.isBlanks(update.getUid(), update.getGameId(), update.getOrderId(), update.getSign()) || Objects.isNull(update.getType()) || Objects.isNull(update.getCoin())) { @@ -66,14 +74,30 @@ public class HotGameRestController { ).setErrorCode(HotGameErrorEnum.PARAM_ERROR.getErrorCode()); } update.setToken(SecurityUtils.urlDecode(update.getToken())); - if (!update.verifySign(hotGameProperties.getSignKey())) { + + String sign = SecurityUtils.md5(Stream.of( + update.getOrderId(), + update.getGameId(), + update.getRoundId(), + update.getUid(), + update.getCoin(), + update.getType(), + update.getToken(), + hotGameProperties.getSignKey() + ) + .filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(""))).toUpperCase(); + + if (!sign.equals(update.getSign())) { return new HotGameResponse() .setData(new HotGameCoin() .setBalanceCoin(0L) .setResponseId(IdWorkerUtils.getIdStr())) .setErrorCode(HotGameErrorEnum.SIGN_VERIFY_FAIL.getErrorCode()); } - return hostGameService.updateUserCoin(update); + + HotGameUserCoinUpdate coinUpdate = new HotGameUserCoinUpdate(); + BeanUtils.copyProperties(update, coinUpdate); + return hostGameService.updateUserCoin(coinUpdate); } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/game/HotGameUpdateRequest.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/game/HotGameUpdateRequest.java new file mode 100644 index 00000000..f7e2c19c --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/game/HotGameUpdateRequest.java @@ -0,0 +1,17 @@ +package com.red.circle.other.app.dto.clientobject.game; + +import lombok.Data; + +@Data +public class HotGameUpdateRequest { + + private String orderId; + private String gameId; + private String roundId; + private String uid; + private Long coin; + private Integer type; + private String token; + private String sign; + +}