Parcourir la source

feat : sdk调试支付提交

bilingfeng il y a 2 ans
Parent
commit
f7cd7ef00e
16 fichiers modifiés avec 216 ajouts et 216 suppressions
  1. 4 2
      game-module/game-mybatis/src/main/java/com/zanxiang/mybatis/entity/Order.java
  2. 4 0
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/constant/RedisKeyConstant.java
  3. 1 34
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/controller/PayController.java
  4. 7 7
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/bo/PlatformOrderBO.java
  5. 1 1
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/bo/ProductPayAttachParamBO.java
  6. 1 1
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/bo/ProductPayParamBO.java
  7. 3 5
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/dto/PlatformOrderDTO.java
  8. 10 0
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/GameUserRoleServiceImpl.java
  9. 8 0
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/LoginServiceImpl.java
  10. 41 3
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/OrderPayServiceImpl.java
  11. 77 67
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/PerformOrderServiceImpl.java
  12. 0 80
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/PlatformOrderServiceImpl.java
  13. 5 3
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/OrderPayService.java
  14. 0 9
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/PlatformOrderService.java
  15. 1 1
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/pay/PayBaseService.java
  16. 53 3
      game-module/game-sdk/src/main/java/com/zanxiang/sdk/util/RedisUtil.java

+ 4 - 2
game-module/game-mybatis/src/main/java/com/zanxiang/mybatis/entity/Order.java

@@ -209,8 +209,10 @@ public class Order {
      */
     private String fromDevice;
 
-    private String payDevice;
-
+    /**
+     * 支付类型, 1:PC, 2: h5支付, 3: App支付, 4: 小程序支付, 5: 米大师支付
+     */
+    private Integer payDevice;
 
     /**
      * 创建时间

+ 4 - 0
game-module/game-sdk/src/main/java/com/zanxiang/sdk/constant/RedisKeyConstant.java

@@ -37,6 +37,10 @@ public class RedisKeyConstant {
      */
     public static final String AUTH_STATE_KEY = RedisKeyConstant.REDIS_PREFIX + "auth_state";
 
+    /**
+     * 角色信息更新
+     */
+    public static final String ROLE_UPDATE_KEY = RedisKeyConstant.REDIS_PREFIX + "role_update";
 
     /**
      * 微信ACCESS_TOKEN key

+ 1 - 34
game-module/game-sdk/src/main/java/com/zanxiang/sdk/controller/PayController.java

@@ -3,20 +3,15 @@ package com.zanxiang.sdk.controller;
 import com.zanxiang.common.domain.ResultMap;
 import com.zanxiang.common.domain.ResultVO;
 import com.zanxiang.common.enums.PayWayEnum;
-import com.zanxiang.common.utils.StringUtils;
 import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.sdk.annotation.UnSignCheck;
 import com.zanxiang.sdk.annotation.ValidLogin;
-import com.zanxiang.sdk.domain.bo.PlatformOrderBO;
-import com.zanxiang.sdk.domain.bo.ProductPayParamBO;
 import com.zanxiang.sdk.domain.params.ProductPayParam;
 import com.zanxiang.sdk.domain.params.UserData;
 import com.zanxiang.sdk.service.OrderPayService;
-import com.zanxiang.sdk.service.PlatformOrderService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -40,39 +35,11 @@ public class PayController {
     @Resource
     private OrderPayService orderPayService;
 
-    @Autowired
-    private PlatformOrderService platformOrderService;
-
     @ApiOperation(value = "支付参数生成")
     @PostMapping(value = "/create")
     public ResultMap create(@Validated @RequestBody ProductPayParam product, @ValidLogin UserData userData) {
         log.error("接收到支付请求, product : {}", JsonUtil.toString(product));
-        String userId = String.valueOf(userData.getUserId());
-        String cpId = "1";
-        if (StringUtils.isEmpty(product.getOrderId())) {
-            PlatformOrderBO orderBO = new PlatformOrderBO();
-            orderBO.setAmount(product.getAmount());
-            orderBO.setProductName(product.getProductName());
-            orderBO.setProductId(product.getProductId());
-            orderBO.setMgUserId(userData.getUserId());
-            orderBO.setUserId(userId);
-            orderBO.setGameId(userData.getGameId());
-            orderBO.setCpId(cpId);
-            orderBO.setFromDevice(userData.getDeviceSystem());
-            orderBO.setPayDevice(userData.getDeviceType().toString());
-            String orderId = platformOrderService.create(orderBO);
-            product.setOrderId(orderId);
-        }
-        ProductPayParamBO bo = new ProductPayParamBO();
-        bo.setGameId(userData.getGameId().toString());
-        bo.setUserId(userId);
-        bo.setPayDevice(product.getPayDevice() == null ? userData.getDeviceType() : product.getPayDevice());
-        bo.setDeviceSystem(userData.getDeviceSystem());
-        bo.setSpbillCreateIp(userData.getIp());
-        bo.setOutTradeNo(product.getOrderId());
-        bo.setPayWay(product.getPayWay());
-        bo.setCode(product.getCode());
-        return orderPayService.payCreate(bo);
+        return orderPayService.payCreate(product, userData);
     }
 
     @UnSignCheck

+ 7 - 7
game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/bo/PlatformOrderBO.java

@@ -13,7 +13,7 @@ public class PlatformOrderBO {
     /**
      * cpId
      */
-    private String cpId;
+    private Long cpId;
 
     /**
      * CP订单号
@@ -23,8 +23,7 @@ public class PlatformOrderBO {
     /**
      * 充值用户
      */
-//    @NonNull
-    private String userId;
+    private Long userId;
 
     /**
      * 游戏玩家ID
@@ -34,13 +33,11 @@ public class PlatformOrderBO {
     /**
      * 游戏ID
      */
-//    @NonNull
     private Long gameId;
 
     /**
      * 货物总价
      */
-//    @NonNull
     private BigDecimal amount;
 
     /**
@@ -124,7 +121,7 @@ public class PlatformOrderBO {
      * 最近通知时间
      */
     private Long lastCpNotifyTime;
-    
+
     /**
      * 是否切量  0 否 1 是
      */
@@ -145,7 +142,10 @@ public class PlatformOrderBO {
      */
     private String fromDevice;
 
-    private String payDevice;
+    /**
+     * 支付类型, 1:PC, 2: h5支付, 3: App支付, 4: 小程序支付, 5: 米大师支付
+     */
+    private Integer payDevice;
 
     /**
      * CP通知状态,1为待处理,2为成功,-1为失败

+ 1 - 1
game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/bo/ProductPayAttachParamBO.java

@@ -11,7 +11,7 @@ import lombok.Data;
 @Data
 public class ProductPayAttachParamBO {
 
-    private String userId;
+    private Long userId;
 
     private String gamePayWayId;
 

+ 1 - 1
game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/bo/ProductPayParamBO.java

@@ -19,7 +19,7 @@ public class ProductPayParamBO {
     /**
      * 玩家id
      */
-    private String userId;
+    private Long userId;
 
     /**
      * 商品ID

+ 3 - 5
game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/dto/PlatformOrderDTO.java

@@ -26,7 +26,6 @@ public class PlatformOrderDTO implements Serializable {
     /**
      * 充值用户
      */
-//    @NonNull
     private String userId;
 
     /**
@@ -37,14 +36,12 @@ public class PlatformOrderDTO implements Serializable {
     /**
      * 游戏ID
      */
-//    @NonNull
     @JsonSerialize(using = ToStringSerializer.class)
     private Long gameId;
 
     /**
      * 货物总价
      */
-//    @NonNull
     private BigDecimal amount;
 
     /**
@@ -60,13 +57,11 @@ public class PlatformOrderDTO implements Serializable {
     /**
      * 游戏商品数量
      */
-//    @NonNull
     private Integer productCnt;
 
     /**
      * 游戏商品名称
      */
-//    @NonNull
     private String productName;
 
     /**
@@ -191,6 +186,9 @@ public class PlatformOrderDTO implements Serializable {
 
     private String payDevice;
 
+    /**
+     * 角色id
+     */
     private String roleId;
 
     /**

+ 10 - 0
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/GameUserRoleServiceImpl.java

@@ -3,11 +3,13 @@ package com.zanxiang.sdk.service.Impl;
 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.module.redis.service.IDistributedLockComponent;
 import com.zanxiang.module.util.DateUtil;
 import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.mybatis.entity.GameUser;
 import com.zanxiang.mybatis.entity.GameUserRole;
 import com.zanxiang.mybatis.mapper.GameUserRoleMapper;
+import com.zanxiang.sdk.constant.RedisKeyConstant;
 import com.zanxiang.sdk.domain.params.GameUserRoleUpdateParam;
 import com.zanxiang.sdk.domain.params.UserData;
 import com.zanxiang.sdk.service.GameUserRoleService;
@@ -18,6 +20,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author : xufeng
@@ -30,10 +33,16 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
     @Autowired
     private GameUserService gameUserService;
 
+    @Autowired
+    private IDistributedLockComponent distributedLockComponent;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateUserGameRole(GameUserRoleUpdateParam param, UserData userData) {
         log.error("上报用户信息, param : {}", JsonUtil.toString(param));
+        if (!distributedLockComponent.doLock(RedisKeyConstant.ROLE_UPDATE_KEY + "_" + userData.getUserId(), 0L, 1L, TimeUnit.MINUTES)) {
+            return Boolean.FALSE;
+        }
         //上报类型
         Integer dataType = param.getDataType();
         //查询玩家信息
@@ -78,6 +87,7 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
                     .eq(GameUserRole::getRoleId, param.getRoleId())
             );
         }
+        distributedLockComponent.unlock(RedisKeyConstant.ROLE_UPDATE_KEY + "_" + userData.getUserId());
         return Boolean.TRUE;
     }
 }

+ 8 - 0
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/LoginServiceImpl.java

@@ -106,6 +106,10 @@ public class LoginServiceImpl implements RegisterLoginService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ResultVO<UserLoginVO> loginPassword(LoginPasswordParam param, UserData userData) {
+
+        log.error("账号注册, userData : {}", JsonUtil.toString(userData));
+
+
         String username = param.getUsername();
         String password = param.getPassword();
         //用户信息
@@ -170,6 +174,10 @@ public class LoginServiceImpl implements RegisterLoginService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ResultVO<UserLoginVO> loginMobile(LoginMobileParam param, UserData userData) {
+
+        log.error("手机号注册, userData : {}", JsonUtil.toString(userData));
+
+
         String mobile = param.getMobile();
         //验证码校验
         HttpStatusEnum httpStatusEnum = smsService.smsCheck(SmsTypeEnum.SMS_REG.getType(), mobile, param.getCode());

+ 41 - 3
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/OrderPayServiceImpl.java

@@ -4,10 +4,15 @@ import com.zanxiang.common.domain.ResultMap;
 import com.zanxiang.common.enums.OrderStateEnum;
 import com.zanxiang.common.exception.BaseException;
 import com.zanxiang.common.utils.SpringUtils;
+import com.zanxiang.mybatis.entity.Game;
 import com.zanxiang.mybatis.entity.Order;
+import com.zanxiang.sdk.domain.bo.PlatformOrderBO;
 import com.zanxiang.sdk.domain.bo.ProductPayParamBO;
+import com.zanxiang.sdk.domain.params.ProductPayParam;
+import com.zanxiang.sdk.domain.params.UserData;
 import com.zanxiang.sdk.enums.PayTypeEnum;
 import com.zanxiang.sdk.service.GamePayWayService;
+import com.zanxiang.sdk.service.GameService;
 import com.zanxiang.sdk.service.OrderPayService;
 import com.zanxiang.sdk.service.PlatformOrderService;
 import com.zanxiang.sdk.service.pay.PayBaseService;
@@ -35,11 +40,44 @@ public class OrderPayServiceImpl implements OrderPayService {
     @Autowired
     public GamePayWayService gamePayWayService;
 
+    @Autowired
+    private GameService gameService;
+
     @Override
-    public ResultMap payCreate(ProductPayParamBO product) {
-        PayTypeEnum payTypeEnum = PayTypeEnum.getByPayType(product.getPayWay());
+    public ResultMap payCreate(ProductPayParam product, UserData userData) {
+        Long userId = userData.getUserId();
+        Game game = gameService.getById(userData.getGameId());
+        if (game == null) {
+            throw new BaseException("参数错误, 游戏信息不存在");
+        }
+        //创建订单
+        PlatformOrderBO orderBO = new PlatformOrderBO();
+        orderBO.setAmount(product.getAmount());
+        orderBO.setProductName(product.getProductName());
+        orderBO.setProductId(product.getProductId());
+        orderBO.setMgUserId(userData.getUserId());
+        orderBO.setUserId(userData.getUserId());
+        orderBO.setGameId(userData.getGameId());
+        orderBO.setCpId(game.getCpId());
+        orderBO.setCpOrderId(product.getOrderId());
+        orderBO.setFromDevice(userData.getDeviceSystem());
+        orderBO.setPayDevice(userData.getDeviceType());
+        String orderId = platformOrderService.create(orderBO);
+        product.setOrderId(orderId);
+        //创建支付参数
+        ProductPayParamBO bo = new ProductPayParamBO();
+        bo.setGameId(userData.getGameId().toString());
+        bo.setUserId(userId);
+        bo.setPayDevice(product.getPayDevice() == null ? userData.getDeviceType() : product.getPayDevice());
+        bo.setDeviceSystem(userData.getDeviceSystem());
+        bo.setSpbillCreateIp(userData.getIp());
+        bo.setOutTradeNo(product.getOrderId());
+        bo.setPayWay(product.getPayWay());
+        bo.setCode(product.getCode());
+        //调起支付
+        PayTypeEnum payTypeEnum = PayTypeEnum.getByPayType(bo.getPayWay());
         PayBaseService service = SpringUtils.getBean(payTypeEnum.getClazz());
-        return service.payCreate(product);
+        return service.payCreate(bo);
     }
 
     @Override

+ 77 - 67
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/PerformOrderServiceImpl.java

@@ -11,6 +11,7 @@ import com.zanxiang.common.enums.ResEnum;
 import com.zanxiang.common.utils.DateUtils;
 import com.zanxiang.common.utils.MD5Util;
 import com.zanxiang.common.utils.StringUtils;
+import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.mybatis.entity.*;
 import com.zanxiang.sdk.domain.dto.PlatformOrderDTO;
 import com.zanxiang.sdk.domain.mapper.OrderCompleteCreateMapper;
@@ -75,75 +76,84 @@ public class PerformOrderServiceImpl implements PerformOrderService {
     @Override
     public Boolean pushCp(PlatformOrderDTO orderInfo) {
         logger.info("订单:{} 充值成功推送cp方回调 ----------start---------", orderInfo.getId());
-        if (orderInfo.getCpStatus() == CpStatusEnum.SUCCESS.getCode()) {
-            return true;
-        }
-        if (orderInfo.getGameId() <= 0) {
-            logger.error("订单:{} 充值成功推送cp方回调失败,订单中GameId不存在", orderInfo.getId());
-            return false;
-        }
-        String orderId = orderInfo.getId();
 
-        //获取游戏中的app_key与app_key信息
-        Game gameInfo = gameService.getById(orderInfo.getGameId());
-        if (Objects.isNull(gameInfo)) {
-            logger.error("订单:{} 充值成功推送cp方回调失败,订单中GameId:{} 的游戏信息未找到", orderInfo.getId(), orderInfo.getGameId());
-            return false;
-        }
-        String appKey = gameInfo.getAppKey();
-        String cpPaybackUrl = gameInfo.getCpPaybackUrl();
-        if (StringUtils.isEmpty(gameInfo.getAppKey()) || StringUtils.isEmpty(gameInfo.getCpPaybackUrl())) {
-            logger.error("订单:{} 充值成功推送cp方回调失败,订单中GameId:{} 的游戏信息中,AppKey:{} 或 CpPaybackUrl:{} 为空", orderInfo.getId(), orderInfo.getGameId(), appKey, cpPaybackUrl);
-            return false;
-        }
+
+
+        logger.error("推送CP方---------------------> " + JsonUtil.toString(orderInfo));
+
+//        if (orderInfo.getCpStatus() == CpStatusEnum.SUCCESS.getCode()) {
+//            return true;
+//        }
+//        //订单id
+//        String orderId = orderInfo.getCpOrderId();
+//        //获取游戏中的app_key与app_key信息
+//        Game gameInfo = gameService.getById(orderInfo.getGameId());
+//
+//        String appKey = gameInfo.getAppKey();
+//        String cpPaybackUrl = gameInfo.getCpPaybackUrl();
+//        if (StringUtils.isEmpty(gameInfo.getAppKey()) || StringUtils.isEmpty(gameInfo.getCpPaybackUrl())) {
+//            logger.error("订单:{} 充值成功推送cp方回调失败,订单中GameId:{} 的游戏信息中,AppKey:{} 或 CpPaybackUrl:{} 为空", orderInfo.getId(), orderInfo.getGameId(), appKey, cpPaybackUrl);
+//            return false;
+//        }
+//        HashMap<String, String> map = new HashMap<>();
+//        map.put("app_id", String.valueOf(orderInfo.getGameId()));
+//        map.put("cp_order_id", orderInfo.getCpOrderId());
+//        map.put("mem_id", orderInfo.getMgUserId());
+//        map.put("order_status", String.valueOf(orderInfo.getStatus()));
+//        map.put("pay_time", String.valueOf(orderInfo.getPayTime()));
+//        map.put("product_id", orderInfo.getProductId());
+//        map.put("product_price", String.valueOf(orderInfo.getAmount()));
+//        map.put("ext", orderInfo.getExt());
+//        map.put("app_key", appKey);
+//        TreeMap<String, String> keySort = new TreeMap<>(map);
+//        //拼接字符串
+//        String param = Signer.getSignCheckContent(keySort);
+//        //拼接app_key
+//        param += "&app_key=" + appKey;
+//        //生成sign
+//        String sign = MD5Util.MD5Encode(param, Constants.UTF8);
+//        map.remove("app_key");
+//        map.put("sign", sign);
+//        //拼接sign请求
+//        param += "&sign=" + sign;
+//        try {
+//            Integer i = orderInfo.getCpNotifyCnt() + 1;
+//            String s = HttpUtil.postData(cpPaybackUrl, param);
+//            boolean pushSuccess = s.trim().toLowerCase(Locale.ROOT).equals(ResEnum.SUCCESS.getMsg());
+//            //更新订单状态
+//            Order order = new Order();
+//            order.setId(orderId);
+//            order.setCpNotifyCnt(i);
+//            order.setLastCpNotifyTime(LocalDateTime.now());
+//            order.setCpStatus(pushSuccess ? CpStatusEnum.SUCCESS.getCode() : CpStatusEnum.FAILLE.getCode());
+//            platformOrderService.updateById(order);
+//            LogPayCp logPayCp = new LogPayCp();
+//            logPayCp.setOrderId(orderId);
+//            logPayCp.setCpOrderId(orderInfo.getCpOrderId());
+//            logPayCp.setStatus(orderInfo.getStatus());
+//            logPayCp.setCpStatus(pushSuccess ? CpStatusEnum.SUCCESS.getCode() : CpStatusEnum.FAILLE.getCode());
+//            logPayCp.setCpPaybackUrl(cpPaybackUrl);
+//            logPayCp.setParams(param);
+//            logPayCp.setExt(orderInfo.getExt());
+//            logPayCp.setNotifyCnt(i);
+//            logPayCpService.save(logPayCp);
+//            logger.info("订单:{} 充值成功推送cp方回调 ----------end---------", orderInfo.getId());
+//            return true;
+//        } catch (Exception e) {
+//            logger.error("订单:{} 充值成功推送cp方回调 失败 e:{}", orderId, e);
+//        }
+        return true;
+    }
+
+    public void test(){
+        String url = "https://api.vmicro.cn/pm/notify/ly.php?channel_id=61";
         HashMap<String, String> map = new HashMap<>();
-        map.put("app_id", String.valueOf(orderInfo.getGameId()));
-        map.put("cp_order_id", orderInfo.getCpOrderId());
-        map.put("mem_id", orderInfo.getMgUserId());
-        map.put("order_status", String.valueOf(orderInfo.getStatus()));
-        map.put("pay_time", String.valueOf(orderInfo.getPayTime()));
-        map.put("product_id", orderInfo.getProductId());
-        map.put("product_price", String.valueOf(orderInfo.getAmount()));
-        map.put("ext", orderInfo.getExt());
-        map.put("app_key", appKey);
-        TreeMap<String, String> keySort = new TreeMap<>(map);
-        //拼接字符串
-        String param = Signer.getSignCheckContent(keySort);
-        //拼接app_key
-        param += "&app_key=" + appKey;
-        //生成sign
-        String sign = MD5Util.MD5Encode(param, Constants.UTF8);
-        map.remove("app_key");
-        map.put("sign", sign);
-        //拼接sign请求
-        param += "&sign=" + sign;
-        try {
-            Integer i = orderInfo.getCpNotifyCnt() + 1;
-            String s = HttpUtil.postData(cpPaybackUrl, param);
-            boolean pushSuccess = s.trim().toLowerCase(Locale.ROOT).equals(ResEnum.SUCCESS.getMsg());
-            //更新订单状态
-            Order order = new Order();
-            order.setId(orderId);
-            order.setCpNotifyCnt(i);
-            order.setLastCpNotifyTime(LocalDateTime.now());
-            order.setCpStatus(pushSuccess ? CpStatusEnum.SUCCESS.getCode() : CpStatusEnum.FAILLE.getCode());
-            platformOrderService.updateById(order);
-            LogPayCp logPayCp = new LogPayCp();
-            logPayCp.setOrderId(orderId);
-            logPayCp.setCpOrderId(orderInfo.getCpOrderId());
-            logPayCp.setStatus(orderInfo.getStatus());
-            logPayCp.setCpStatus(pushSuccess ? CpStatusEnum.SUCCESS.getCode() : CpStatusEnum.FAILLE.getCode());
-            logPayCp.setCpPaybackUrl(cpPaybackUrl);
-            logPayCp.setParams(param);
-            logPayCp.setExt(orderInfo.getExt());
-            logPayCp.setNotifyCnt(i);
-            logPayCpService.save(logPayCp);
-            logger.info("订单:{} 充值成功推送cp方回调 ----------end---------", orderInfo.getId());
-            return true;
-        } catch (Exception e) {
-            logger.error("订单:{} 充值成功推送cp方回调 失败 e:{}", orderId, e);
-        }
-        return false;
+        map.put("userId", "83");
+        map.put("money", "10");
+        map.put("time", String.valueOf(System.currentTimeMillis()));
+        map.put("serverId", "60076");
+        map.put("roleId", "635788e11100264a56573114");
+        map.put("roleName", "付晓亦");
     }
 
     @Override

+ 0 - 80
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/PlatformOrderServiceImpl.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.common.enums.OrderStateEnum;
 import com.zanxiang.common.exception.BaseException;
-import com.zanxiang.common.exception.ParamNullException;
 import com.zanxiang.common.utils.StringUtils;
 import com.zanxiang.common.utils.bean.BeanUtils;
 import com.zanxiang.mybatis.entity.Order;
@@ -14,8 +13,6 @@ import com.zanxiang.sdk.domain.dto.PlatformOrderDTO;
 import com.zanxiang.sdk.listener.OrderPaySuccessEvent;
 import com.zanxiang.sdk.service.PlatformOrderService;
 import lombok.extern.slf4j.Slf4j;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Component;
@@ -44,7 +41,6 @@ public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> im
     public String create(PlatformOrderBO platformOrderBO) {
         try {
             log.info("生成订单请求参数 platformOrderBO:{}", platformOrderBO);
-            this.checkParam(platformOrderBO, "create");
             Order data = BeanUtils.copy(platformOrderBO, Order.class);
             if (save(data)) {
                 OrderPaySuccessEvent orderPaySuccessEvent = new OrderPaySuccessEvent(this, data.getId());
@@ -89,7 +85,6 @@ public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> im
     public Boolean cancel(PlatformOrderBO platformOrderBO) {
         log.info("订单支付取消请求参数 platformOrderBO:{}", platformOrderBO);
         try {
-            this.checkParam(platformOrderBO, "cancel");
             Order order = new Order();
             order.setId(platformOrderBO.getId());
             order.setStatus(OrderStateEnum.CANCEL.getCode());
@@ -106,84 +101,9 @@ public class PlatformOrderServiceImpl extends ServiceImpl<OrderMapper, Order> im
         }
     }
 
-    @Override
-    public PlatformOrderDTO info(String id, String userId) {
-//        Order order = orderMapper.selectByPrimaryKey(Long.valueOf(id));
-        Order order = getOne(new LambdaQueryWrapper<Order>().eq(Order::getId, id).eq(Order::getUserId, userId));
-        return BeanUtils.copy(order, PlatformOrderDTO.class);
-    }
-
     @Override
     public PlatformOrderDTO info(String id) {
         Order order = getOne(new LambdaQueryWrapper<Order>().eq(Order::getId, id));
         return BeanUtils.copy(order, PlatformOrderDTO.class);
     }
-
-    /**
-     * 检查订单参数
-     *
-     * @param platformOrderBO
-     * @return
-     */
-    private Boolean checkParam(PlatformOrderBO platformOrderBO, String active) {
-        switch (active) {
-            case "create":
-                if (platformOrderBO.getCpId() == null) {
-                    throw new ParamNullException("CpId");
-                }
-                if (platformOrderBO.getUserId() == null) {
-                    throw new ParamNullException("UserId");
-                }
-                if (platformOrderBO.getMgUserId() == null) {
-                    throw new ParamNullException("MgUserId");
-                }
-                if (StringUtils.isEmpty(platformOrderBO.getProductId())) {
-                    throw new ParamNullException("ProductId");
-                }
-                if (StringUtils.isEmpty(platformOrderBO.getProductName())) {
-                    throw new ParamNullException("ProductName");
-                }
-//                if (platformOrderBO.getProductCnt() == null) {
-//                    throw new NullPointerException("ProductCnt");
-//                }
-                if (platformOrderBO.getAmount() == null) {
-                    throw new ParamNullException("Amount");
-                }
-                break;
-            case "pay":
-                if (platformOrderBO.getId() == null) {
-                    throw new ParamNullException("id");
-                }
-//                if (platformOrderBO.getUserId() == null) {
-//                    throw new ParamNullException("UserId");
-//                }
-                if (platformOrderBO.getStatus() == 0) {
-                    throw new ParamNullException("Status");
-                }
-                if (StringUtils.isEmpty(platformOrderBO.getGamePaywayId())) {
-                    throw new ParamNullException("GamePaywayId");
-                }
-                if (platformOrderBO.getRealAmount() == null) {
-                    throw new ParamNullException("RealAmount");
-                }
-                if (StringUtils.isEmpty(platformOrderBO.getMerchantOrderNo())) {
-                    throw new ParamNullException("MerchantOrderNo");
-                }
-
-
-                break;
-
-            case "cancel":
-                if (platformOrderBO.getId() == null) {
-                    throw new NullPointerException("id");
-                }
-
-                break;
-            default:
-                return false;
-        }
-        return true;
-    }
-
-
 }

+ 5 - 3
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/OrderPayService.java

@@ -1,7 +1,8 @@
 package com.zanxiang.sdk.service;
 
 import com.zanxiang.common.domain.ResultMap;
-import com.zanxiang.sdk.domain.bo.ProductPayParamBO;
+import com.zanxiang.sdk.domain.params.ProductPayParam;
+import com.zanxiang.sdk.domain.params.UserData;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -16,10 +17,11 @@ public interface OrderPayService {
     /**
      * 订单支付
      *
-     * @param product : 商品信息
+     * @param product  : 商品信息
+     * @param userData : 用户信息
      * @return : 返回接过参数
      */
-    ResultMap payCreate(ProductPayParamBO product);
+    ResultMap payCreate(ProductPayParam product, UserData userData);
 
     /**
      * 支付异步回调

+ 0 - 9
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/PlatformOrderService.java

@@ -38,15 +38,6 @@ public interface PlatformOrderService extends IService<Order> {
      */
     Boolean cancel(PlatformOrderBO platformOrderBO);
 
-    /**
-     * 单一订单详情获取
-     *
-     * @param id
-     * @param userId
-     * @return PlatformOrderDTO
-     */
-    PlatformOrderDTO info(String id, String userId);
-
     /**
      * 单一订单详情获取
      *

+ 1 - 1
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/pay/PayBaseService.java

@@ -48,7 +48,7 @@ public abstract class PayBaseService {
     public ResultMap payCreate(ProductPayParamBO product) {
         try {
             //获取订单信息
-            PlatformOrderDTO info = platformOrderService.info(product.getOutTradeNo(), product.getUserId());
+            PlatformOrderDTO info = platformOrderService.info(product.getOutTradeNo());
             if (info == null) {
                 throw new RuntimeException("订单不存在");
             }

+ 53 - 3
game-module/game-sdk/src/main/java/com/zanxiang/sdk/util/RedisUtil.java

@@ -2,6 +2,7 @@ package com.zanxiang.sdk.util;
 
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.ListOperations;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.SetOperations;
 import org.springframework.data.redis.core.ValueOperations;
@@ -106,7 +107,7 @@ public class RedisUtil<T> {
             Long add = setOperations.add(key, t);
             return add != null && add >= 1;
         } catch (Exception e) {
-            log.error("Set添加失败,key : " + key + " e :" + e.toString());
+            log.error("Set添加失败,key : {}, e : {}", key, e.getMessage());
         }
         return false;
     }
@@ -124,7 +125,7 @@ public class RedisUtil<T> {
             Long remove = setOperations.remove(key, t);
             return remove != null && remove >= 1;
         } catch (Exception e) {
-            log.error("Set删除失败,key : " + key + " e :" + e.toString());
+            log.error("Set删除失败,key : {}, e : {}", key, e.getMessage());
         }
         return false;
     }
@@ -141,8 +142,57 @@ public class RedisUtil<T> {
             SetOperations<String, T> setOperations = redisTemplate.opsForSet();
             return setOperations.isMember(key, t);
         } catch (Exception e) {
-            log.error("Set元素是否存在,key : " + key + " e :" + e.toString());
+            log.error("Set元素是否存在判断异常, key : {}, e : {}", key, e.getMessage());
         }
         return false;
     }
+
+    /**
+     * 添加单个缓存到list
+     *
+     * @param key   : 缓存key
+     * @param t     : 缓存元素
+     * @param isTop : isTop :  真:前 假:后
+     * @return : 返回添加结果
+     */
+    public boolean setListCache(String key, T t, boolean isTop) {
+        try {
+            ListOperations<String, T> listOperations = redisTemplate.opsForList();
+            if (isTop) {
+                listOperations.leftPush(key, t);
+            } else {
+                listOperations.rightPush(key, t);
+            }
+            return true;
+        } catch (Exception e) {
+            log.error("redis添加队列元素失败,key : {}, e : {}", key, e.getMessage());
+        }
+        return false;
+    }
+
+    /**
+     * 获取列表中的前or后的值
+     *
+     * @param key   : 缓存key
+     * @param isTop :  真:前 假:后
+     * @return : 返回缓存数据
+     */
+    public T getListOneCache(String key, boolean isTop) {
+        try {
+            if (redisTemplate.hasKey(key)) {
+                ListOperations<String, T> listOperations = redisTemplate.opsForList();
+                T t = null;
+                if (isTop) {
+                    t = listOperations.leftPop(key);
+                } else {
+                    t = listOperations.rightPop(key);
+                }
+                return t;
+            }
+
+        } catch (Exception e) {
+            log.error("redis获取队列元素失败,key : {}, e : {}", key, e.getMessage());
+        }
+        return null;
+    }
 }