@@ -60,7 +60,7 @@ public interface FssPaccountPayRepo extends | |||
@Query(value = "select " + | |||
" DATE_FORMAT(insert_time, '%Y-%m-%d') as accountDate,agent_id as agentId , COUNT(1) as numberTotal ,SUM(receipt_Amt) as moneyTotal ,SUM(CASE WHEN `status` = 1 THEN receipt_Amt ELSE 0 END) as collectMoney ,0 as refundMoney " + | |||
" from fss_paccount_pay where Date(insert_time) = DATE_SUB(CURDATE(),INTERVAL 1 DAY) GROUP BY DATE_FORMAT(insert_time, '%Y-%m-%d'),agent_id ",nativeQuery = true ) | |||
List<Map<String,Object>> findCountTotal(); | |||
" from fss_paccount_pay where insert_time = ?1 GROUP BY DATE_FORMAT(insert_time, '%Y-%m-%d'),agent_id ",nativeQuery = true ) | |||
List<Map<String,Object>> findCountTotal(String yesterday); | |||
} |
@@ -16,8 +16,8 @@ public interface AflPaccountRefundCountRepo extends | |||
JpaRepository<AflPaccountRefundCount, String> , | |||
JpaSpecificationExecutor<AflPaccountRefundCount> { | |||
@Query(value = " SELECT COUNT(1) FROM AFL_PACCOUNT_REFUND_COUNT GROUP BY ACCOUNT_DATE having ACCOUNT_DATE = DATE_SUB(CURDATE(),INTERVAL 1 DAY) ",nativeQuery = true) | |||
Integer findByToDay(); | |||
@Query(value = " SELECT COUNT(1) FROM AFL_PACCOUNT_REFUND_COUNT GROUP BY ACCOUNT_DATE having ACCOUNT_DATE = ?1 ",nativeQuery = true) | |||
Integer findByToDay(String yesterday); | |||
@Query(" from AflPaccountRefundCount where agentId = ?1 and accountDate=?2") |
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service; | |||
import org.springframework.util.CollectionUtils; | |||
import javax.annotation.Resource; | |||
import java.time.LocalDate; | |||
import java.time.LocalDateTime; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@@ -83,12 +84,15 @@ public class FssPaccountPayServiceImpl implements FssPaccountPayService { | |||
@Override | |||
public void count() throws ServiceHandleException { | |||
Integer i= aflPaccountRefundCountRepo.findByToDay(); | |||
// 获取当前日期前一天的日期 | |||
LocalDate localDate = LocalDate.now().minusDays(1);//1代表提前多少天 | |||
String yesterday = localDate.toString(); | |||
Integer i= aflPaccountRefundCountRepo.findByToDay(yesterday); | |||
if (i!=null&&i>0){ | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("当前n+1天记录已存在"); | |||
} | |||
List<Map<String, Object>> countTotal = paccountPayRepo.findCountTotal(); | |||
List<Map<String, Object>> countTotal = paccountPayRepo.findCountTotal(yesterday+" 00:00:00"); | |||
List<AflPaccountRefundCount> list = new ArrayList<AflPaccountRefundCount>(); | |||
for (Map<String, Object> stringObjectMap : countTotal) { | |||
AflPaccountRefundCount aflPaccountRefundCount = new AflPaccountRefundCount(); |