优化接收Stripe回调时数据重复存储问题(添加唯一索引)
This commit is contained in:
@@ -93,7 +93,7 @@ public class RequestInfoUtil {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String output;
|
||||
StringBuilder outputBuilder = new StringBuilder();
|
||||
System.out.println("Output from Server .... \n");
|
||||
// System.out.println("Output from Server .... \n");
|
||||
while ((output = br.readLine()) != null) {
|
||||
outputBuilder.append(output);
|
||||
System.out.println(output);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.ai.da.mapper.primary.entity.PaymentInfo;
|
||||
import com.ai.da.model.vo.OrderListVO;
|
||||
import com.ai.da.model.vo.PaymentInfoVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -26,4 +27,6 @@ public interface PaymentInfoMapper extends BaseMapper<PaymentInfo> {
|
||||
List<Map<String, String>> getCities();
|
||||
|
||||
List<Map<String, String>> getCountries();
|
||||
|
||||
int insertIgnore(@Param("paymentInfo")PaymentInfo paymentInfo);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.SubscriptionInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface SubscriptionInfoMapper extends BaseMapper<SubscriptionInfo> {
|
||||
|
||||
int insertIgnore(@Param("subscriptionInfo") SubscriptionInfo subscriptionInfo);
|
||||
}
|
||||
|
||||
@@ -285,7 +285,8 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
|
||||
paymentInfo.setCity(orderByOrderNo.getCity());
|
||||
paymentInfo.setIpAddress(orderByOrderNo.getIpAddress());
|
||||
}
|
||||
baseMapper.insert(paymentInfo);
|
||||
int row = baseMapper.insertIgnore(paymentInfo);
|
||||
log.info("Payment Info insert affect rows:{}", row);
|
||||
}else {
|
||||
paymentInfo.setTradeState(status);
|
||||
paymentInfo.setUpdateTime(LocalDateTime.now());
|
||||
@@ -354,7 +355,8 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
|
||||
paymentInfo.setCity(orderByOrderNo.getCity());
|
||||
paymentInfo.setIpAddress(orderByOrderNo.getIpAddress());
|
||||
}
|
||||
baseMapper.insert(paymentInfo);
|
||||
int row = baseMapper.insertIgnore(paymentInfo);
|
||||
log.info("Payment Info insert affect rows:{}", row);
|
||||
}else {
|
||||
paymentInfo.setTradeState(charge.getStatus());
|
||||
paymentInfo.setPaymentMethod(paymentMethod);
|
||||
|
||||
@@ -482,7 +482,9 @@ public class StripeServiceImpl implements StripeService {
|
||||
subscriptionInfo.setCurrentPeriodStart(subscription.getCurrentPeriodStart());
|
||||
subscriptionInfo.setCurrentPeriodEnd(subscription.getCurrentPeriodEnd());
|
||||
subscriptionInfo.setCreateTime(LocalDateTime.now());
|
||||
subscriptionInfoMapper.insert(subscriptionInfo);
|
||||
|
||||
int rows = subscriptionInfoMapper.insertIgnore(subscriptionInfo);
|
||||
log.info("Subscription info insert affect rows : {}", rows);
|
||||
|
||||
if (subscriptionInfo.getStatus().equals("active")){
|
||||
log.info("创建订阅更新账号信息");
|
||||
|
||||
Reference in New Issue
Block a user