bonus push fix & improve

This commit is contained in:
zz 2022-06-16 21:32:44 +08:00
parent 021a5b6fa0
commit 712b79d0fa
2 changed files with 25 additions and 17 deletions

View File

@ -1,9 +1,14 @@
package com.xhpc.evcs.jpa;
import com.xhpc.order.domain.XhpcHistoryOrder;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.query.QueryByExampleExecutor;
import org.springframework.stereotype.Repository;
@ -11,16 +16,19 @@ import java.util.List;
@Repository
public interface XhpcHistoryOrderRepository extends JpaRepository<XhpcHistoryOrder, Long>,
QueryByExampleExecutor<XhpcHistoryOrder>, JpaSpecificationExecutor<XhpcHistoryOrder> {
QueryByExampleExecutor<XhpcHistoryOrder>, JpaSpecificationExecutor<XhpcHistoryOrder>, PagingAndSortingRepository<XhpcHistoryOrder, Long> {
List<XhpcHistoryOrder> findByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(Long hisOrderId, int i);
List<XhpcHistoryOrder> findTop100ByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(Long hisOrderId, int i);
List<XhpcHistoryOrder> findByConfirmResultNotAndOperatorId3rdptyEvcsIsNotNull(int succCode);
List<XhpcHistoryOrder> findByConfirmResultNotAndSource(int confirmResult, int source);
@Query("select ho from XhpcHistoryOrder ho join EtPushFailedOrder fo on ho.historyOrderId = fo.id where fo" +
".operatorId3rdpty = ?1")
List<XhpcHistoryOrder> findJoinPushFailedOrders(String operatorId3irdpty);
@Query("select ho from XhpcHistoryOrder ho join EtPushFailedOrder fo on ho.historyOrderId = fo.id where fo.operatorId3rdpty = ?1")
List<XhpcHistoryOrder> findJoinPushFailedOrders(@Param("operatorId3irdpty")String operatorId3irdpty, Pageable pageable);
default List<XhpcHistoryOrder> findTop10JoinPushFailedOrders(String operatorId3irdpty) {
return findJoinPushFailedOrders(operatorId3irdpty, PageRequest.of(0, 100));
}
}

View File

@ -49,24 +49,24 @@ public class NotificationChargeOrderInfo4BonusTask extends CoreDispatcher {
// maybe对接第三方
if (authSecretTokenOut != null) {
final List<XhpcHistoryOrder> notYetPushOrder =
xhpcHistoryOrderRepository.findByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(authSecretTokenOut.getLastPushOrder(), 0);
xhpcHistoryOrderRepository.findTop100ByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(authSecretTokenOut.getLastPushOrder(), 0);
for (XhpcHistoryOrder xhpcHistoryOrder : notYetPushOrder) {
List<XhpcStatisticsTimeInterval> statisticTimeIntervalList =
statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId());
xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList);
notify(xhpcHistoryOrder, authSecretTokenOut, false);
}
final List<XhpcHistoryOrder> pushFailedOrders =
xhpcHistoryOrderRepository.findJoinPushFailedOrders(authSecretTokenOut.getOperatorId3irdpty());
for (XhpcHistoryOrder xhpcHistoryOrder : pushFailedOrders) {
List<XhpcStatisticsTimeInterval> statisticTimeIntervalList =
statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId());
xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList);
final boolean notify = notify(xhpcHistoryOrder, authSecretTokenOut, true);
if (notify) {
etPushFailedOrderRepository.deleteById(xhpcHistoryOrder.getHistoryOrderId());
}
}
// final List<XhpcHistoryOrder> pushFailedOrders =
// xhpcHistoryOrderRepository.findTop10JoinPushFailedOrders(authSecretTokenOut.getOperatorId3irdpty());
// for (XhpcHistoryOrder xhpcHistoryOrder : pushFailedOrders) {
// List<XhpcStatisticsTimeInterval> statisticTimeIntervalList =
// statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId());
// xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList);
// final boolean notify = notify(xhpcHistoryOrder, authSecretTokenOut, true);
// if (notify) {
// etPushFailedOrderRepository.deleteById(xhpcHistoryOrder.getHistoryOrderId());
// }
// }
}
}