From 17caebabf7a6a529b7039c71e21e5a324e31ea20 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 27 九月 2024 16:23:42 +0800 Subject: [PATCH] 代理新功能完善 --- src/test/java/com/taoke/autopay/ClientTest.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/taoke/autopay/ClientTest.java b/src/test/java/com/taoke/autopay/ClientTest.java index 5aa4a84..1ccca1f 100644 --- a/src/test/java/com/taoke/autopay/ClientTest.java +++ b/src/test/java/com/taoke/autopay/ClientTest.java @@ -1,14 +1,16 @@ package com.taoke.autopay; import com.taoke.autopay.dao.ClientInfoMapper; +import com.taoke.autopay.dao.KeyOrderMapper; import com.taoke.autopay.entity.ClientInfo; +import com.taoke.autopay.entity.KeyOrder; import com.taoke.autopay.service.ClientInfoService; +import com.taoke.autopay.service.KeyOrderService; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import javax.annotation.Resource; -import java.util.Arrays; -import java.util.List; +import java.util.*; /** * @author hxh @@ -22,6 +24,9 @@ @Resource private ClientInfoService clientInfoService; + @Resource + private KeyOrderService keyOrderService; + @Test public void add(){ ClientInfoMapper.DaoQuery query = new ClientInfoMapper.DaoQuery(); @@ -30,4 +35,43 @@ List<ClientInfo> list = clientInfoService.list(query); } + + private Long getTargetClientId() { + List<Long> clientIds = clientInfoService.getRePayClientIds(); + if (clientIds != null && clientIds.size() > 0) { + // 鏌ヨ璁惧鏈墽琛岀殑鏁伴噺 + List<List<Long>> clist=new ArrayList<>(); + for (Long cuid : clientIds) { + KeyOrderMapper.DaoQuery daoQuery = new KeyOrderMapper.DaoQuery(); + daoQuery.distributeClientUid =cuid; + daoQuery.state = KeyOrder.STATE_NOT_PAY; + daoQuery.minCreateTime=new Date(System.currentTimeMillis() - 1000*60*30L); + long count = keyOrderService.count(daoQuery); + clist.add(Arrays.asList(new Long[]{cuid,count})); + } + clist.sort(new Comparator<List<Long>>() { + @Override + public int compare(List<Long> o1, List<Long> o2) { + return (int)(o1.get(1)-o2.get(1)); + } + }); + if(clist.size()>1) { + for (int i = 1; i < clist.size(); i++) { + if (clist.get(i).get(1).longValue() != clist.get(i - 1).get(1)) { + clist = clist.subList(0, i); + break; + } + } + } + Collections.shuffle(clist); + return clist.get(0).get(0); + } + return null; + } + + @Test + public void testTargetUid(){ + getTargetClientId(); + + } } -- Gitblit v1.8.0