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; package com.xhpc.evcs.jpa;
import com.xhpc.order.domain.XhpcHistoryOrder; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; 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.data.repository.query.QueryByExampleExecutor;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -11,16 +16,19 @@ import java.util.List;
@Repository @Repository
public interface XhpcHistoryOrderRepository extends JpaRepository<XhpcHistoryOrder, Long>, 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> findByConfirmResultNotAndOperatorId3rdptyEvcsIsNotNull(int succCode);
List<XhpcHistoryOrder> findByConfirmResultNotAndSource(int confirmResult, int source); List<XhpcHistoryOrder> findByConfirmResultNotAndSource(int confirmResult, int source);
@Query("select ho from XhpcHistoryOrder ho join EtPushFailedOrder fo on ho.historyOrderId = fo.id where fo" + @Query("select ho from XhpcHistoryOrder ho join EtPushFailedOrder fo on ho.historyOrderId = fo.id where fo.operatorId3rdpty = ?1")
".operatorId3rdpty = ?1") List<XhpcHistoryOrder> findJoinPushFailedOrders(@Param("operatorId3irdpty")String operatorId3irdpty, Pageable pageable);
List<XhpcHistoryOrder> findJoinPushFailedOrders(String operatorId3irdpty);
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对接第三方 // maybe对接第三方
if (authSecretTokenOut != null) { if (authSecretTokenOut != null) {
final List<XhpcHistoryOrder> notYetPushOrder = final List<XhpcHistoryOrder> notYetPushOrder =
xhpcHistoryOrderRepository.findByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(authSecretTokenOut.getLastPushOrder(), 0); xhpcHistoryOrderRepository.findTop100ByHistoryOrderIdGreaterThanAndStateGreaterThanOrderByHistoryOrderIdAsc(authSecretTokenOut.getLastPushOrder(), 0);
for (XhpcHistoryOrder xhpcHistoryOrder : notYetPushOrder) { for (XhpcHistoryOrder xhpcHistoryOrder : notYetPushOrder) {
List<XhpcStatisticsTimeInterval> statisticTimeIntervalList = List<XhpcStatisticsTimeInterval> statisticTimeIntervalList =
statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId()); statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId());
xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList); xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList);
notify(xhpcHistoryOrder, authSecretTokenOut, false); notify(xhpcHistoryOrder, authSecretTokenOut, false);
} }
final List<XhpcHistoryOrder> pushFailedOrders = // final List<XhpcHistoryOrder> pushFailedOrders =
xhpcHistoryOrderRepository.findJoinPushFailedOrders(authSecretTokenOut.getOperatorId3irdpty()); // xhpcHistoryOrderRepository.findTop10JoinPushFailedOrders(authSecretTokenOut.getOperatorId3irdpty());
for (XhpcHistoryOrder xhpcHistoryOrder : pushFailedOrders) { // for (XhpcHistoryOrder xhpcHistoryOrder : pushFailedOrders) {
List<XhpcStatisticsTimeInterval> statisticTimeIntervalList = // List<XhpcStatisticsTimeInterval> statisticTimeIntervalList =
statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId()); // statisticTimeIntervalRepository.findByHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId());
xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList); // xhpcHistoryOrder.setXhpcStatisticsTimeIntervalList(statisticTimeIntervalList);
final boolean notify = notify(xhpcHistoryOrder, authSecretTokenOut, true); // final boolean notify = notify(xhpcHistoryOrder, authSecretTokenOut, true);
if (notify) { // if (notify) {
etPushFailedOrderRepository.deleteById(xhpcHistoryOrder.getHistoryOrderId()); // etPushFailedOrderRepository.deleteById(xhpcHistoryOrder.getHistoryOrderId());
} // }
} // }
} }
} }