Browse Source

feat : 支付修改

bilingfeng 2 years ago
parent
commit
9b1ec29612

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

@@ -16,7 +16,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功333 ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功45 ( ´・・)ノ(._.`) \n" +
                 " ______  __     __     \n" +
                 "/_____/\\/__/\\ /__/\\    \n" +
                 "\\:::__\\/\\ \\::\\\\:.\\ \\   \n" +

+ 6 - 47
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/pay/AliPayService.java

@@ -76,12 +76,6 @@ public class AliPayService extends PayBaseService {
     @Autowired
     private PayMerchantService payMerchantService;
 
-    /**
-     * 支付调起
-     *
-     * @param product : 商品参数
-     * @return : 返回调起支付参数
-     */
     @Override
     public ResultMap create(ProductPayParamBO product) {
         this.attach = product.getAttach();
@@ -94,23 +88,16 @@ public class AliPayService extends PayBaseService {
         //不同的支付途径
         switch (payDevice) {
             case 1:
-                return this.pc(product);
+                return this.pcPay(product);
             case 2:
                 return this.h5Pay(product);
             case 3:
-                return this.app(product);
+                return this.appPay(product);
             default:
                 throw new RuntimeException("未知支付方式");
         }
     }
 
-    /**
-     * 异步回调
-     *
-     * @param request  : 请求参数
-     * @param response : 返回参数
-     * @return : 返回结果
-     */
     @Override
     public String notify(HttpServletRequest request, HttpServletResponse response) {
         try {
@@ -140,12 +127,6 @@ public class AliPayService extends PayBaseService {
         return HttpStatusEnum.FAIL.getMsg();
     }
 
-    /**
-     * 同步回调
-     *
-     * @param request : 请求参数
-     * @return : 返回结果
-     */
     @Override
     public ResultMap synNotify(HttpServletRequest request) {
         try {
@@ -188,12 +169,6 @@ public class AliPayService extends PayBaseService {
         }
     }
 
-    /**
-     * h5支付
-     *
-     * @param product : 商品参数
-     * @return : 返回支付调起参数
-     */
     private ResultMap h5Pay(ProductPayParamBO product) {
         try {
             AlipayTradeWapPayResponse response = Factory.Payment
@@ -208,7 +183,8 @@ public class AliPayService extends PayBaseService {
             String body = response.getBody();
             result.put("fromData", body);
             //安卓与ios系统时才单独获取app支付地址
-            if (!product.getDeviceSystem().contains(OsEnum.SYSTEM_ANDROID.getOs()) && !product.getDeviceSystem().contains(OsEnum.SYSTEM_IOS.getOs())) {
+            if (!product.getDeviceSystem().contains(OsEnum.SYSTEM_ANDROID.getOs())
+                    && !product.getDeviceSystem().contains(OsEnum.SYSTEM_IOS.getOs())) {
                 return ResultMap.ok(product.getPayDevice(), result, product.getOutTradeNo());
             }
             Matcher matcher = pattern.matcher(body);
@@ -248,13 +224,7 @@ public class AliPayService extends PayBaseService {
         }
     }
 
-    /**
-     * pc端电脑支付
-     *
-     * @param product : 商品参数
-     * @return : 返回支付调起参数
-     */
-    private ResultMap pc(ProductPayParamBO product) {
+    private ResultMap pcPay(ProductPayParamBO product) {
         try {
             log.info("pc端支付生成,请求参数 bo:{}", product);
             AlipayTradePagePayResponse response = Factory.Payment
@@ -272,13 +242,7 @@ public class AliPayService extends PayBaseService {
         }
     }
 
-    /**
-     * app支付
-     *
-     * @param product : 商品参数
-     * @return : 返回支付调起参数
-     */
-    private ResultMap app(ProductPayParamBO product) {
+    private ResultMap appPay(ProductPayParamBO product) {
         try {
             AlipayTradeAppPayResponse response = Factory.Payment
                     .App().asyncNotify(notifyUrl)
@@ -295,11 +259,6 @@ public class AliPayService extends PayBaseService {
         }
     }
 
-    /**
-     * 配置初始化
-     *
-     * @param gamePayWayDTO : 游戏支付配置信息
-     */
     private void configInit(GamePayWayDTO gamePayWayDTO) {
         //商户信息
         PayMerchantDTO payMerchantDTO = payMerchantService.getByMerchantNo(gamePayWayDTO.getMerchantNo());

+ 5 - 26
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/pay/MiPayService.java

@@ -6,6 +6,7 @@ import com.zanxiang.common.domain.MiPayConfig;
 import com.zanxiang.common.domain.ResultMap;
 import com.zanxiang.common.enums.HttpStatusEnum;
 import com.zanxiang.common.enums.StatusEnum;
+import com.zanxiang.common.exception.BaseException;
 import com.zanxiang.common.exception.CustomException;
 import com.zanxiang.common.utils.StringUtils;
 import com.zanxiang.common.utils.URIUtil;
@@ -110,9 +111,6 @@ public class MiPayService extends PayBaseService {
         return ResultMap.ok(result);
     }
 
-    /**
-     * 查询余额
-     */
     private Long midasGetBalance(String openId, MiPayConfig miPayConfig) {
         Map<String, String> paramMap = new HashMap<>();
         paramMap.put("openid", openId);
@@ -129,12 +127,6 @@ public class MiPayService extends PayBaseService {
         return Long.valueOf(result.get("balance"));
     }
 
-
-    /**
-     * 虚拟币扣除
-     *
-     * @return
-     */
     private String midasPay(String openId, MiPayConfig miPayConfig, PlatformOrderDTO orderInfo) {
         Map<String, String> paramMap = new HashMap<>();
         paramMap.put("appid", miPayConfig.getWxAppId());
@@ -153,13 +145,6 @@ public class MiPayService extends PayBaseService {
         return result.get("bill_no");
     }
 
-    /**
-     * 获取AccessToken
-     *
-     * @param appId
-     * @param appSecret
-     * @return AccessToken
-     */
     private String getAccessToken(String appId, String appSecret) {
 //        String redisKey = RedisKeyConstant.WEIXIN_ACCESS_TOKEN + appId;
 //        String cache = redisUtil.getCache(redisKey);
@@ -192,12 +177,6 @@ public class MiPayService extends PayBaseService {
         return token;
     }
 
-    /**
-     * 接口请求
-     *
-     * @param url 请求路径
-     * @return
-     */
     private Map<String, String> miPayApi(String url, MiPayConfig miPayConfig, Map<String, String> paramMap) {
         try {
             //使用沙箱时,沙箱地址替换
@@ -226,18 +205,18 @@ public class MiPayService extends PayBaseService {
                 throw new CustomException(errmsg, errcode);
             }
             return data;
-        } catch (RuntimeException e) {
-            throw new RuntimeException("米大师接口调用失败");
+        } catch (Exception e) {
+            throw new BaseException("米大师接口调用失败");
         }
     }
 
     @Override
     public String notify(HttpServletRequest request, HttpServletResponse response) {
-        return null;
+        throw new BaseException("米大师支付不存在异步回调");
     }
 
     @Override
     public ResultMap synNotify(HttpServletRequest request) {
-        return null;
+        throw new BaseException("米大师支付不存在同步回调");
     }
 }

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

@@ -46,7 +46,7 @@ public abstract class PayBaseService {
     /**
      * 创建订单支付参数
      *
-     * @param product
+     * @param product : 支付参数
      */
     public ResultMap payCreate(ProductPayParamBO product) {
         try {