v1.0:fix-谷歌支付重复回调报错
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.accompany.payment.google;
|
||||
package com.accompany.business.service.payment;
|
||||
|
||||
import com.accompany.business.service.ChargeService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
@@ -10,6 +11,7 @@ import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.payment.dto.AppInnerPayRecordDTO;
|
||||
import com.accompany.payment.google.AndroidPublisherHelper;
|
||||
import com.accompany.payment.google.dto.GooglePayLimitConfigDTO;
|
||||
import com.accompany.payment.model.ChargeProd;
|
||||
import com.accompany.payment.model.ChargeRecord;
|
||||
@@ -41,6 +43,8 @@ public class GooglePlayBillingService {
|
||||
@Autowired
|
||||
private ChargeProdService chargeProdService;
|
||||
@Autowired
|
||||
private ChargeService chargeService;
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
@Autowired
|
||||
private UsersBaseService usersBaseService;
|
||||
@@ -146,7 +150,7 @@ public class GooglePlayBillingService {
|
||||
return limitConfig;
|
||||
}
|
||||
|
||||
public ChargeRecord verifyOrder(String chargeRecordId, String packageName, String googlePlayProdId, String purchaseToken) {
|
||||
public void verifyOrder(String chargeRecordId, String packageName, String googlePlayProdId, String purchaseToken) {
|
||||
String lockKey = RedisKey.lock_pay_callback_notify.getKey(chargeRecordId);
|
||||
RLock lock = redissonClient.getLock(lockKey);
|
||||
try {
|
||||
@@ -159,7 +163,7 @@ public class GooglePlayBillingService {
|
||||
}
|
||||
if (!Constant.ChargeRecordStatus.create.equals(chargeRecord.getChargeStatus()) && !Constant.ChargeRecordStatus.error.equals(chargeRecord.getChargeStatus())) {
|
||||
log.info("[google play billing]订单状态不是创建或错误,不进行处理。chargeRecordId: {}", chargeRecordId);
|
||||
throw new ServiceException(BusiStatus.RECORD_ALREADY_EXIST);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!chargeRecord.getChargeProdId().equalsIgnoreCase(googlePlayProdId)) {
|
||||
@@ -181,7 +185,7 @@ public class GooglePlayBillingService {
|
||||
|
||||
chargeRecord.setPingxxChargeId(purchase.getOrderId());
|
||||
|
||||
return chargeRecord;
|
||||
chargeService.updateAppPayData(chargeRecord);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[google play billing]校验google内购失败", e);
|
@@ -7,8 +7,7 @@ import com.accompany.core.enumeration.BusinessStatusCodeEnum;
|
||||
import com.accompany.core.vo.BaseRequestVO;
|
||||
import com.accompany.core.vo.BaseResponseVO;
|
||||
import com.accompany.payment.dto.AppInnerPayRecordDTO;
|
||||
import com.accompany.payment.google.GooglePlayBillingService;
|
||||
import com.accompany.payment.model.ChargeRecord;
|
||||
import com.accompany.business.service.payment.GooglePlayBillingService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -48,8 +47,7 @@ public class GooglePlayBillingChargeController {
|
||||
@PostMapping("/verifyOrder")
|
||||
@Authorization
|
||||
public BaseResponseVO<String> verifyOrder(String chargeRecordId, String packageName, String googlePlayProdId, String purchaseToken) {
|
||||
ChargeRecord chargeRecord = googlePlayBillingService.verifyOrder(chargeRecordId, packageName, googlePlayProdId, purchaseToken);
|
||||
chargeService.updateAppPayData(chargeRecord);
|
||||
googlePlayBillingService.verifyOrder(chargeRecordId, packageName, googlePlayProdId, purchaseToken);
|
||||
return new BaseResponseVO<>(BusinessStatusCodeEnum.SUCCESS, BusinessStatusCodeEnum.SUCCESS.getReasonPhrase(), purchaseToken);
|
||||
}
|
||||
}
|
||||
|
@@ -20,9 +20,9 @@ public class ChargeServiceTest extends CommonTest {
|
||||
|
||||
@Test
|
||||
public void updateAppPayDataTest_tarot() {
|
||||
String recordId = "a33e6eae652d4854b8baed6186867e95";
|
||||
String recordId = "0e37ee2d797140b5b5221096035207fb";
|
||||
ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(recordId);
|
||||
chargeRecord.setPingxxChargeId("1231451231231251233");
|
||||
chargeRecord.setPingxxChargeId("GPA.3353-6664-6089-22552");
|
||||
|
||||
chargeService.updateAppPayData(chargeRecord);
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package servicetest;
|
||||
|
||||
import com.accompany.business.controller.apppay.GooglePlayBillingChargeController;
|
||||
import com.accompany.payment.google.AndroidPublisherHelper;
|
||||
import com.accompany.payment.google.GooglePlayBillingService;
|
||||
import com.accompany.business.service.payment.GooglePlayBillingService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.api.services.androidpublisher.model.ProductPurchase;
|
||||
import org.junit.Test;
|
||||
@@ -11,15 +12,27 @@ import java.io.IOException;
|
||||
|
||||
public class GooglePlayBillingServiceTest extends CommonTest {
|
||||
|
||||
@Autowired
|
||||
private GooglePlayBillingChargeController googlePlayBillingChargeController;
|
||||
|
||||
@Autowired
|
||||
private GooglePlayBillingService googlePlayBillingVerifyService;
|
||||
|
||||
@Test
|
||||
public void replayRequest() {
|
||||
String chargeRecordId = "0e37ee2d797140b5b5221096035207fb";
|
||||
String packageName = "com.vele.peko";
|
||||
String prodId = "goods_hkd_79.00";
|
||||
String token ="hfmhgidemlkcaabkedjncfob.AO-J1OwLWKs9OpKCyi9cWIA_jZuv0aAyTMYUA7Pg-QMvvJE-JWsxqNhZfRwVtuU_aXyMz7GWwC8Ztrvy9e9x3sljmipddygvxw";
|
||||
googlePlayBillingChargeController.verifyOrder(chargeRecordId, packageName, prodId, token);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyOrderTest() throws Exception {
|
||||
String chargeRecordId = "d9e457c4e7bc4d918d1a869bc49003fd ";
|
||||
String packageName = "com.vele.ananplay";
|
||||
String prodId = "goods_cent_1499";
|
||||
String token ="lefpcedapihlpjcmjgnombhd.AO-J1OyZHdP6rv5D1sqFUyWsk1QbBuMS1oV4aTuet7CtgeKLZe_S6yjpOdkLpSTRT123gIQ8LSR7mWcayJtXCizwmMis7tqnTg";
|
||||
String chargeRecordId = "0e37ee2d797140b5b5221096035207fb";
|
||||
String packageName = "com.vele.peko";
|
||||
String prodId = "goods_hkd_79.00";
|
||||
String token ="hfmhgidemlkcaabkedjncfob.AO-J1OwLWKs9OpKCyi9cWIA_jZuv0aAyTMYUA7Pg-QMvvJE-JWsxqNhZfRwVtuU_aXyMz7GWwC8Ztrvy9e9x3sljmipddygvxw";
|
||||
googlePlayBillingVerifyService.verifyOrder(chargeRecordId, packageName, prodId, token);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user