Ver Fonte

fix 代充近一个小时只可充值一次

zoujiajian há 3 meses atrás
pai
commit
8adeea9d1a

+ 12 - 1
netflix-service/src/main/java/com/cyksj/server/recharge/impl/GptProxyRechargeServiceImpl.java

@@ -79,6 +79,8 @@ public class GptProxyRechargeServiceImpl implements GptProxyRechargeService {
 
     private final GuofenzaixianRechargeService guofenzaixianRechargeService;
 
+    private final GptUserRechargeNumRecordMapper gptUserRechargeNumRecordMapper;
+
 	private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
 
 	private HttpRequest createBaseRequest(String url) {
@@ -269,7 +271,16 @@ public class GptProxyRechargeServiceImpl implements GptProxyRechargeService {
 		if (rechargeRemainNum == null || rechargeRemainNum <= 0) {
 			throw BusinessRuntimeException.getInstance("剩余可代充次数为0");
 		}
-		if (relation.getRechargeStatus() == GroupsRelation.RechargeStatus.recharging) {
+        //近一个小时成功
+        Integer successHour = gptUserRechargeNumRecordMapper.selectCount(Wrappers.lambdaQuery(GptUserRechargeNumRecord.class)
+                .eq(GptUserRechargeNumRecord::getRelationId, relationId)
+                .in(GptUserRechargeNumRecord::getUserId, userIdList)
+                .gt(GptUserRechargeNumRecord::getCreatedTime, DateUtil.offsetHour(DateTime.now(), -1)));
+        if (successHour > 0) {
+            throw BusinessRuntimeException.getInstance("近一个小时只可充值一次");
+        }
+
+        if (relation.getRechargeStatus() == GroupsRelation.RechargeStatus.recharging) {
 			throw BusinessRuntimeException.getInstance("确认充值中");
 		}
 		if (relation.getRechargeStatus() == GroupsRelation.RechargeStatus.recharge_error) {