|
@@ -206,7 +206,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
break;
|
|
|
case "REFUND":
|
|
|
log.error("苹果消耗类型订单退款通知");
|
|
|
- this.doRefund(obj);
|
|
|
+ this.dorefund(obj);
|
|
|
break;
|
|
|
default:
|
|
|
log.error("苹果通知未处理的状态");
|
|
@@ -220,7 +220,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
* @author 十一
|
|
|
* @date 2020/10/16 16:58
|
|
|
*/
|
|
|
- private void doRefund(JSONObject obj) {
|
|
|
+ private void dorefund(JSONObject obj) {
|
|
|
Object receiptInfo = obj.get("latest_receipt_info");
|
|
|
if (receiptInfo != null) {
|
|
|
HashMap receiptInfoMap = JSON.parseObject(receiptInfo.toString(), HashMap.class);
|
|
@@ -229,7 +229,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
if (originalTransactionId != null) {
|
|
|
// 更新订单状态为退款状态
|
|
|
Order order = orderDao.getByPayNo(originalTransactionId.toString());
|
|
|
- order.setPayStatus(PayStatusEnum.Refund);
|
|
|
+ order.setPayStatus(PayStatusEnum.REFUND);
|
|
|
LocalDateTime cancelTime;
|
|
|
if (cancellationDateMs != null) {
|
|
|
cancelTime = LocalDateTime.ofEpochSecond(Long.valueOf(cancellationDateMs.toString()),
|
|
@@ -278,7 +278,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
log.warn("{}订阅关闭", obj.get("notification_type").toString());
|
|
|
//如果订阅已经关闭
|
|
|
userSubscriptionDetailService.updateUserSubscriptionDetailStatus(originalTransactionId,
|
|
|
- productId, SubscriptionStatus.DebitFailed, null);
|
|
|
+ productId, SubscriptionStatus.DEBITFAILED, null);
|
|
|
return;
|
|
|
}
|
|
|
//解析latest_receipt_info
|
|
@@ -323,7 +323,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
String originalTransactionId = infoMap.get("original_transaction_id").toString();
|
|
|
log.warn("{}订阅失败通知", originalTransactionId);
|
|
|
userSubscriptionDetailService.updateUserSubscriptionDetailStatus(originalTransactionId,
|
|
|
- productId, SubscriptionStatus.DebitFailed, null);
|
|
|
+ productId, SubscriptionStatus.DEBITFAILED, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -335,7 +335,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
@Override
|
|
|
public Boolean checkSubscription(UserLoginInfo userLoginInfo, String productId) {
|
|
|
Boolean result = userSubscriptionDetailService.checkSubscription(userLoginInfo.getUserId(),
|
|
|
- productId, SubscriptionStatus.Subscription);
|
|
|
+ productId, SubscriptionStatus.SUBSCRIPTION);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -351,9 +351,9 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
// auto_renew_status_change_date_ms订阅改变的时间
|
|
|
Date autorenewStatusChangeDate = new Date(Long.valueOf(obj.get("auto_renew_status_change_date_ms").toString()));
|
|
|
if (closeStatus.equals(obj.get("auto_renew_status").toString())) {
|
|
|
- autoRenewStatus = SubscriptionStatus.UnSubscription;
|
|
|
+ autoRenewStatus = SubscriptionStatus.UN_SUBSCRIPTION;
|
|
|
} else {
|
|
|
- autoRenewStatus = SubscriptionStatus.Subscription;
|
|
|
+ autoRenewStatus = SubscriptionStatus.SUBSCRIPTION;
|
|
|
}
|
|
|
String info;
|
|
|
Object latestReceiptInfo = obj.get("latest_receipt_info");
|
|
@@ -364,7 +364,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
HashMap infoMap = JSON.parseObject(info, HashMap.class);
|
|
|
String productId = infoMap.get("product_id").toString();
|
|
|
String originalTransactionId = infoMap.get("original_transaction_id").toString();
|
|
|
- if (autoRenewStatus.equals(SubscriptionStatus.UnSubscription)) {
|
|
|
+ if (autoRenewStatus.equals(SubscriptionStatus.UN_SUBSCRIPTION)) {
|
|
|
log.warn("{}订阅关闭", obj.get("notification_type").toString());
|
|
|
}
|
|
|
userSubscriptionDetailService.updateUserSubscriptionDetailStatus(originalTransactionId,
|
|
@@ -418,11 +418,11 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
// IosPayContent content = iosPayContentService.getByProductId(productId);
|
|
|
//更新订单状态为已退款状态
|
|
|
Date cancelTime = new Date(Long.valueOf(cancellationDateMs));
|
|
|
- orderDao.updateOrderStatus(transactionId, PayStatusEnum.Refund, cancelTime);
|
|
|
+ orderDao.updateOrderStatus(transactionId, PayStatusEnum.REFUND, cancelTime);
|
|
|
log.warn("{}订阅取消通知", originalTransactionId);
|
|
|
//设置订阅详情的状态为已退款
|
|
|
userSubscriptionDetailService.updateUserSubscriptionDetailStatus(originalTransactionId,
|
|
|
- productId, SubscriptionStatus.Cancel, null);
|
|
|
+ productId, SubscriptionStatus.CANCEL, null);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -449,7 +449,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
for (TransactionalUserIdParam transactionalUserIdParam : list) {
|
|
|
VerifyVO vo = new VerifyVO();
|
|
|
vo.setProductId(transactionalUserIdParam.getProductId());
|
|
|
- vo.setStatus(IosPayStatusEnum.Fail);
|
|
|
+ vo.setStatus(IosPayStatusEnum.FAIL);
|
|
|
vo.setTransactionalId(transactionalUserIdParam.getTransactionalId());
|
|
|
resultList.add(vo);
|
|
|
}
|
|
@@ -485,7 +485,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
vo.setTransactionalId(transactionalUserIdParam.getTransactionalId());
|
|
|
// 用于判断用户伪造票据的问题
|
|
|
if (inappListMap.size() == 0) {
|
|
|
- vo.setStatus(IosPayStatusEnum.Fail);
|
|
|
+ vo.setStatus(IosPayStatusEnum.FAIL);
|
|
|
resultList.add(vo);
|
|
|
continue;
|
|
|
}
|
|
@@ -528,13 +528,13 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
// 处理逻辑并且发送通知
|
|
|
process(payItem, order, originalTransactionId, purchaseDateMs, expiresDateMs);
|
|
|
// 判断是否是消费型订单,只需要判断expires_date_ms是否为空,并且当前订单的用户id不为空
|
|
|
- if (expiresDateMs != null && !order.getPayStatus().equals(PayStatusEnum.abnormal)) {
|
|
|
+ if (expiresDateMs != null && !order.getPayStatus().equals(PayStatusEnum.ABNORMAL)) {
|
|
|
// 处理订阅型票据
|
|
|
processSubscriptionReceipt(payItem, currentUserId, param, obj, pendingRenewalInfo);
|
|
|
}
|
|
|
- vo.setStatus(IosPayStatusEnum.Success);
|
|
|
+ vo.setStatus(IosPayStatusEnum.SUCCESS);
|
|
|
// 更改订单状态为已处理
|
|
|
- order.setOrderStatus(OrderStatusEnum.Finish);
|
|
|
+ order.setOrderStatus(OrderStatusEnum.FINISH);
|
|
|
orderDao.updateById(order);
|
|
|
} else {
|
|
|
// 判断下一期订阅的productId和客户端提交的productId是否一致,如果一致,则更新下一期订阅的类型
|
|
@@ -548,7 +548,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
transactionalUserIdParam.getProductId());
|
|
|
}
|
|
|
}
|
|
|
- vo.setStatus(IosPayStatusEnum.Success);
|
|
|
+ vo.setStatus(IosPayStatusEnum.SUCCESS);
|
|
|
}
|
|
|
resultList.add(vo);
|
|
|
// 如果是用户未找到
|
|
@@ -558,18 +558,18 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
if (order != null) {
|
|
|
order.setOrderStatus(OrderStatusEnum.Error);
|
|
|
}
|
|
|
- vo.setStatus(IosPayStatusEnum.Success);
|
|
|
+ vo.setStatus(IosPayStatusEnum.SUCCESS);
|
|
|
resultList.add(vo);
|
|
|
log.error("用户id为空,标记当前支付异常{}", transactionId);
|
|
|
|
|
|
// 为了避免发生错误的时候异常订单信息会被回滚,新开事务保证不会回滚
|
|
|
IApplePayService service = (IApplePayService) AopContext.currentProxy();
|
|
|
service.updateOrderStatusAndSaveExceptionInfo(order,
|
|
|
- UserSubscriptionErrorTypeEnum.ProcessException,
|
|
|
+ UserSubscriptionErrorTypeEnum.PROCESS_EXCEPTION,
|
|
|
param.getReceiptData(),
|
|
|
obj);
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
- vo.setStatus(IosPayStatusEnum.Success);
|
|
|
+ vo.setStatus(IosPayStatusEnum.SUCCESS);
|
|
|
resultList.add(vo);
|
|
|
log.error("重复校验新的支付单号{},用户id{}", transactionId, currentUserId, e);
|
|
|
} catch (Exception e) {
|
|
@@ -582,11 +582,11 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
// 为了避免发生错误的时候异常订单信息会被回滚,新开事务保证不会回滚
|
|
|
IApplePayService service = (IApplePayService) AopContext.currentProxy();
|
|
|
service.updateOrderStatusAndSaveExceptionInfo(order,
|
|
|
- UserSubscriptionErrorTypeEnum.ProcessException,
|
|
|
+ UserSubscriptionErrorTypeEnum.PROCESS_EXCEPTION,
|
|
|
param.getReceiptData(),
|
|
|
obj);
|
|
|
|
|
|
- vo.setStatus(IosPayStatusEnum.Fail);
|
|
|
+ vo.setStatus(IosPayStatusEnum.FAIL);
|
|
|
resultList.add(vo);
|
|
|
log.error("票据{}验证失败,原始票据为{}",
|
|
|
obj.get("transaction_id").toString(),
|
|
@@ -604,10 +604,10 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
&& pendingRenewalInfo.toString().contains(transactionalUserIdParam.getProductId())) {
|
|
|
log.error("{}单号找不到,当前订阅状态为订阅降级,用户订阅详情是{}",
|
|
|
transactionalUserIdParam.getTransactionalId(), pendingRenewalInfo.toString());
|
|
|
- vo.setStatus(IosPayStatusEnum.Success);
|
|
|
+ vo.setStatus(IosPayStatusEnum.SUCCESS);
|
|
|
} else {
|
|
|
log.error("{}单号找不到,异常", transactionalUserIdParam.getTransactionalId());
|
|
|
- vo.setStatus(IosPayStatusEnum.Fail);
|
|
|
+ vo.setStatus(IosPayStatusEnum.FAIL);
|
|
|
}
|
|
|
resultList.add(vo);
|
|
|
}
|
|
@@ -640,7 +640,7 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
VerifyVO vo = new VerifyVO();
|
|
|
vo.setProductId(p.getProductId());
|
|
|
vo.setTransactionalId(p.getTransactionalId());
|
|
|
- vo.setStatus(IosPayStatusEnum.Fail);
|
|
|
+ vo.setStatus(IosPayStatusEnum.FAIL);
|
|
|
resultList.add(vo);
|
|
|
}
|
|
|
return resultList;
|
|
@@ -767,13 +767,13 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
order.setCreateTime(LocalDateTime.now());
|
|
|
order.setPayType(PayTypeEnum.IOSPay);
|
|
|
order.setPayNo(payNo);
|
|
|
- order.setPayStatus(PayStatusEnum.Payed);
|
|
|
+ order.setPayStatus(PayStatusEnum.PAYED);
|
|
|
if (param != null) {
|
|
|
order.setDeviceToken(param.getDeviceToken());
|
|
|
}
|
|
|
order.setUserId(currentUserId);
|
|
|
//设置状态为待处理
|
|
|
- order.setOrderStatus(OrderStatusEnum.Todo);
|
|
|
+ order.setOrderStatus(OrderStatusEnum.TODO);
|
|
|
//保存支付订单
|
|
|
orderDao.save(order);
|
|
|
return order;
|
|
@@ -802,13 +802,13 @@ public class ApplePayServiceImpl implements IApplePayService {
|
|
|
.set(UserSubscriptionDetail::getExpireTime, new Date(purchaseDateMs))
|
|
|
.set(UserSubscriptionDetail::getProductId, detail.getProductId())
|
|
|
.set(UserSubscriptionDetail::getUpdateTime, new Date())
|
|
|
- .set(UserSubscriptionDetail::getStatus, SubscriptionStatus.Subscription)
|
|
|
+ .set(UserSubscriptionDetail::getStatus, SubscriptionStatus.SUBSCRIPTION)
|
|
|
.set(UserSubscriptionDetail::getUserId, userId);
|
|
|
userSubscriptionDetailDao.update(uw);
|
|
|
} else {
|
|
|
UserSubscriptionDetail detailInfo = new UserSubscriptionDetail();
|
|
|
detailInfo.setProductId(detail.getProductId());
|
|
|
- detailInfo.setStatus(SubscriptionStatus.Subscription);
|
|
|
+ detailInfo.setStatus(SubscriptionStatus.SUBSCRIPTION);
|
|
|
detailInfo.setUpdateTime(new Date());
|
|
|
detailInfo.setAutoRenewProductId(productId);
|
|
|
detailInfo.setExpireTime(new Date(purchaseDateMs));
|