|
@@ -0,0 +1,87 @@
|
|
|
+package com.zanxiang.game.module.sdk.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.zanxiang.game.module.base.pojo.enums.PayWayEnum;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.GameExt;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.GameRemitLog;
|
|
|
+import com.zanxiang.game.module.mybatis.mapper.GameRemitLogMapper;
|
|
|
+import com.zanxiang.game.module.sdk.pojo.param.GameRemitLogParam;
|
|
|
+import com.zanxiang.game.module.sdk.service.IGameExtService;
|
|
|
+import com.zanxiang.game.module.sdk.service.IGameRemitLogService;
|
|
|
+import com.zanxiang.game.module.sdk.util.SignUtil;
|
|
|
+import com.zanxiang.module.util.exception.BaseException;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author : lingfeng
|
|
|
+ * @time : 2023-07-17
|
|
|
+ * @description : 游戏提现记录
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class GameRemitLogServiceImpl extends ServiceImpl<GameRemitLogMapper, GameRemitLog> implements IGameRemitLogService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGameExtService gameExtService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean addOrUpdate(GameRemitLogParam param) {
|
|
|
+ GameExt gameExt = gameExtService.getByGameAppId(param.getAppId());
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append("payKey=").append(gameExt.getPayKey());
|
|
|
+ sb.append("&appId=").append(param.getAppId());
|
|
|
+ sb.append("&userId=").append(param.getUserId());
|
|
|
+ sb.append("&merchantOrderNo=").append(param.getMerchantOrderNo());
|
|
|
+ sb.append("&createdTime=").append(param.getCreatedTime());
|
|
|
+
|
|
|
+ log.error("加密签名字符串, str : {}", sb.toString());
|
|
|
+
|
|
|
+ String mySign;
|
|
|
+ try {
|
|
|
+ mySign = SignUtil.MD5(sb.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("md5工具类加密异常, str : {}, e : {}", sb.toString(), e.getMessage());
|
|
|
+ throw new BaseException("MD5加密异常");
|
|
|
+ }
|
|
|
+ //签名错误
|
|
|
+ if (!Objects.equals(mySign, param.getSign())) {
|
|
|
+ log.error("游戏提现签名验证失败, mySign : {}, sign : {}", mySign, param.getSign());
|
|
|
+ throw new BaseException("签名验证失败");
|
|
|
+ }
|
|
|
+ GameRemitLog gameRemitLog = super.getOne(new LambdaQueryWrapper<GameRemitLog>()
|
|
|
+ .eq(GameRemitLog::getMerchantOrderNo, param.getMerchantOrderNo()));
|
|
|
+ if (gameRemitLog == null) {
|
|
|
+ gameRemitLog = this.transform(param, gameExt.getGameId());
|
|
|
+ } else {
|
|
|
+ gameRemitLog.setUserId(param.getUserId());
|
|
|
+ gameRemitLog.setGameId(gameExt.getGameId());
|
|
|
+ gameRemitLog.setAmount(param.getAmount());
|
|
|
+ gameRemitLog.setPayPlatform(PayWayEnum.getKeyByPayWayId(param.getPayPlatform()));
|
|
|
+ gameRemitLog.setPayAccount(param.getPayAccount());
|
|
|
+ gameRemitLog.setCreatedTime(param.getCreatedTime());
|
|
|
+ gameRemitLog.setUpdateTime(LocalDateTime.now());
|
|
|
+ }
|
|
|
+ return super.saveOrUpdate(gameRemitLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ private GameRemitLog transform(GameRemitLogParam param, Long gameId) {
|
|
|
+ return GameRemitLog.builder()
|
|
|
+ .userId(param.getUserId())
|
|
|
+ .gameId(gameId)
|
|
|
+ .merchantOrderNo(param.getMerchantOrderNo())
|
|
|
+ .amount(param.getAmount())
|
|
|
+ .payPlatform(PayWayEnum.getKeyByPayWayId(param.getPayPlatform()))
|
|
|
+ .payAccount(param.getPayAccount())
|
|
|
+ .createdTime(param.getCreatedTime())
|
|
|
+ .createTime(LocalDateTime.now())
|
|
|
+ .updateTime(LocalDateTime.now())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|