1
This commit is contained in:
@@ -183,7 +183,15 @@ public class JDUtils {
|
|||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime lastMinute = now.minusMinutes(10).withSecond(0).withNano(0);
|
LocalDateTime lastMinute = now.minusMinutes(10).withSecond(0).withNano(0);
|
||||||
|
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(lastMinute, true, 1, true); // 真实代表实时订单
|
for (Map.Entry<String, WXUtil.SuperAdmin> entry : super_admins.entrySet()) {
|
||||||
|
//String wxid = entry.getKey();
|
||||||
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
|
String appKey = admin.getAppKey();
|
||||||
|
String secretKey = admin.getSecretKey();
|
||||||
|
if (Util.isAnyEmpty(appKey,secretKey)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(lastMinute, true, 1, true,appKey,secretKey); // 真实代表实时订单
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
|
|
||||||
int code = response.getQueryResult().getCode();
|
int code = response.getQueryResult().getCode();
|
||||||
@@ -202,6 +210,7 @@ public class JDUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,11 +241,19 @@ public class JDUtils {
|
|||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 */4 * * ?")
|
@Scheduled(cron = "0 0 */4 * * ?")
|
||||||
public void fetchHistoricalOrders3090() {
|
public void fetchHistoricalOrders3090() {
|
||||||
|
for (Map.Entry<String, WXUtil.SuperAdmin> entry : super_admins.entrySet()) {
|
||||||
fetchHistoricalOrders3090Do();
|
//String wxid = entry.getKey();
|
||||||
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
|
String appKey = admin.getAppKey();
|
||||||
|
String secretKey = admin.getSecretKey();
|
||||||
|
if (Util.isAnyEmpty(appKey,secretKey)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fetchHistoricalOrders3090Do(appKey, secretKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int fetchHistoricalOrders3090Do() {
|
private int fetchHistoricalOrders3090Do(String appKey,String secretKey) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
@@ -252,7 +269,7 @@ public class JDUtils {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// 30-60 天 ,非实时,非分钟
|
// 30-60 天 ,非实时,非分钟
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false);
|
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false,appKey,secretKey);
|
||||||
if (response != null && response.getQueryResult() != null) {
|
if (response != null && response.getQueryResult() != null) {
|
||||||
if (response.getQueryResult().getCode() == 200) {
|
if (response.getQueryResult().getCode() == 200) {
|
||||||
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
||||||
@@ -289,10 +306,19 @@ public class JDUtils {
|
|||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 * * * ?")
|
@Scheduled(cron = "0 0 * * * ?")
|
||||||
public void fetchHistoricalOrders1430() {
|
public void fetchHistoricalOrders1430() {
|
||||||
fetchHistoricalOrders1430Do();
|
for (Map.Entry<String, WXUtil.SuperAdmin> entry : super_admins.entrySet()) {
|
||||||
|
//String wxid = entry.getKey();
|
||||||
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
|
String appKey = admin.getAppKey();
|
||||||
|
String secretKey = admin.getSecretKey();
|
||||||
|
if (Util.isAnyEmpty(appKey,secretKey)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fetchHistoricalOrders1430Do(appKey, secretKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int fetchHistoricalOrders1430Do() {
|
private int fetchHistoricalOrders1430Do(String appKey,String secretKey) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
//logger.info("拉取历史订单---> , {} 点,{} 分", now.getHour(), now.getMinute());
|
//logger.info("拉取历史订单---> , {} 点,{} 分", now.getHour(), now.getMinute());
|
||||||
@@ -307,7 +333,7 @@ public class JDUtils {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// 14 - 30 天 ,非实时,非分钟
|
// 14 - 30 天 ,非实时,非分钟
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false);
|
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false,appKey,secretKey);
|
||||||
if (response != null && response.getQueryResult() != null) {
|
if (response != null && response.getQueryResult() != null) {
|
||||||
if (response.getQueryResult().getCode() == 200) {
|
if (response.getQueryResult().getCode() == 200) {
|
||||||
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
||||||
@@ -344,11 +370,19 @@ public class JDUtils {
|
|||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 * * * ?")
|
@Scheduled(cron = "0 0 * * * ?")
|
||||||
public void fetchHistoricalOrders0714() {
|
public void fetchHistoricalOrders0714() {
|
||||||
|
for (Map.Entry<String, WXUtil.SuperAdmin> entry : super_admins.entrySet()) {
|
||||||
fetchHistoricalOrders0714Do();
|
//String wxid = entry.getKey();
|
||||||
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
|
String appKey = admin.getAppKey();
|
||||||
|
String secretKey = admin.getSecretKey();
|
||||||
|
if (Util.isAnyEmpty(appKey,secretKey)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fetchHistoricalOrders0714Do(appKey, secretKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int fetchHistoricalOrders0714Do() {
|
private int fetchHistoricalOrders0714Do(String appKey,String secretKey) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
//logger.info("拉取历史订单---> , {} 点,{} 分", now.getHour(), now.getMinute());
|
//logger.info("拉取历史订单---> , {} 点,{} 分", now.getHour(), now.getMinute());
|
||||||
@@ -362,7 +396,7 @@ public class JDUtils {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// 7 - 14 天 ,非实时,非分钟
|
// 7 - 14 天 ,非实时,非分钟
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false);
|
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false,appKey,secretKey);
|
||||||
if (response != null && response.getQueryResult() != null) {
|
if (response != null && response.getQueryResult() != null) {
|
||||||
if (response.getQueryResult().getCode() == 200) {
|
if (response.getQueryResult().getCode() == 200) {
|
||||||
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
||||||
@@ -396,10 +430,19 @@ public class JDUtils {
|
|||||||
|
|
||||||
@Scheduled(cron = "0 * * * * ?")
|
@Scheduled(cron = "0 * * * * ?")
|
||||||
public void fetchHistoricalOrders0007() {
|
public void fetchHistoricalOrders0007() {
|
||||||
fetchHistoricalOrders0007Do();
|
for (Map.Entry<String, WXUtil.SuperAdmin> entry : super_admins.entrySet()) {
|
||||||
|
//String wxid = entry.getKey();
|
||||||
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
|
String appKey = admin.getAppKey();
|
||||||
|
String secretKey = admin.getSecretKey();
|
||||||
|
if (Util.isAnyEmpty(appKey,secretKey)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fetchHistoricalOrders0007Do(appKey, secretKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int fetchHistoricalOrders0007Do() {
|
private int fetchHistoricalOrders0007Do(String appKey,String secretKey) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
@@ -414,7 +457,7 @@ public class JDUtils {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// 0 - 7 天 ,非实时,非分钟
|
// 0 - 7 天 ,非实时,非分钟
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false);
|
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false,appKey,secretKey);
|
||||||
if (response != null && response.getQueryResult() != null) {
|
if (response != null && response.getQueryResult() != null) {
|
||||||
if (response.getQueryResult().getCode() == 200) {
|
if (response.getQueryResult().getCode() == 200) {
|
||||||
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
||||||
@@ -454,7 +497,7 @@ public class JDUtils {
|
|||||||
* page 分页页码
|
* page 分页页码
|
||||||
* isMinutes 是否是分钟级订单 分钟的每次加10分钟,小时每小时加1小时
|
* isMinutes 是否是分钟级订单 分钟的每次加10分钟,小时每小时加1小时
|
||||||
*/
|
*/
|
||||||
public synchronized UnionOpenOrderRowQueryResponse fetchOrdersForDateTime(LocalDateTime startTime, boolean isRealTime, Integer page, boolean isMinutes) {
|
public synchronized UnionOpenOrderRowQueryResponse fetchOrdersForDateTime(LocalDateTime startTime, boolean isRealTime, Integer page, boolean isMinutes,String appKey,String secretKey) {
|
||||||
|
|
||||||
LocalDateTime endTime = isMinutes ? startTime.plusMinutes(30) : startTime.plusHours(1);
|
LocalDateTime endTime = isMinutes ? startTime.plusMinutes(30) : startTime.plusHours(1);
|
||||||
String hourMinuteTag = isRealTime ? "minute" : "hour";
|
String hourMinuteTag = isRealTime ? "minute" : "hour";
|
||||||
@@ -471,7 +514,7 @@ public class JDUtils {
|
|||||||
|
|
||||||
// 调用 API 以拉取订单
|
// 调用 API 以拉取订单
|
||||||
try {
|
try {
|
||||||
UnionOpenOrderRowQueryResponse unionOpenOrderRowQueryResponse = getUnionOpenOrderRowQueryResponse(startTime, endTime, page);
|
UnionOpenOrderRowQueryResponse unionOpenOrderRowQueryResponse = getUnionOpenOrderRowQueryResponse(startTime, endTime, page,appKey,secretKey);
|
||||||
// 历史的订单才进行标记为已拉取,小时分钟的都进行拉取并且标记
|
// 历史的订单才进行标记为已拉取,小时分钟的都进行拉取并且标记
|
||||||
if (!isRealTime) {
|
if (!isRealTime) {
|
||||||
// 只有没有订单的才进行标记为已拉取
|
// 只有没有订单的才进行标记为已拉取
|
||||||
@@ -733,9 +776,14 @@ public class JDUtils {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
LocalDateTime startDate = LocalDateTime.now().minusDays(7).withMinute(0).withSecond(0).withNano(0);
|
LocalDateTime startDate = LocalDateTime.now().minusDays(7).withMinute(0).withSecond(0).withNano(0);
|
||||||
LocalDateTime lastHour = LocalDateTime.now().minusHours(1).withMinute(0).withSecond(0).withNano(0);
|
LocalDateTime lastHour = LocalDateTime.now().minusHours(1).withMinute(0).withSecond(0).withNano(0);
|
||||||
|
String appKey = superAdmin.getAppKey();
|
||||||
|
String secretKey = superAdmin.getSecretKey();
|
||||||
|
if (Util.isAnyEmpty(appKey,secretKey)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
while (!startDate.isEqual(lastHour)) {
|
while (!startDate.isEqual(lastHour)) {
|
||||||
startDate = startDate.plusHours(1);
|
startDate = startDate.plusHours(1);
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, 1, false);
|
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, 1, false,appKey,secretKey);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
|
|
||||||
int code = response.getQueryResult().getCode();
|
int code = response.getQueryResult().getCode();
|
||||||
@@ -918,14 +966,14 @@ public class JDUtils {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public UnionOpenOrderRowQueryResponse getUnionOpenOrderRowQueryResponse(LocalDateTime start, LocalDateTime end, Integer pageIndex) throws Exception {
|
public UnionOpenOrderRowQueryResponse getUnionOpenOrderRowQueryResponse(LocalDateTime start, LocalDateTime end, Integer pageIndex,String appKey,String secretKey) throws Exception {
|
||||||
String startTime = start.format(DATE_TIME_FORMATTER);
|
String startTime = start.format(DATE_TIME_FORMATTER);
|
||||||
String endTime = end.format(DATE_TIME_FORMATTER);
|
String endTime = end.format(DATE_TIME_FORMATTER);
|
||||||
// 模拟 API 调用
|
// 模拟 API 调用
|
||||||
//System.out.println("调用API - 从 " + startTime
|
//System.out.println("调用API - 从 " + startTime
|
||||||
// + " 到 " + endTime);
|
// + " 到 " + endTime);
|
||||||
// 实际的 API 调用逻辑应在这里进行
|
// 实际的 API 调用逻辑应在这里进行
|
||||||
JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, LPF_APP_KEY_WZ, LPF_SECRET_KEY_WZ);
|
JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, appKey, secretKey);
|
||||||
UnionOpenOrderRowQueryRequest request = new UnionOpenOrderRowQueryRequest();
|
UnionOpenOrderRowQueryRequest request = new UnionOpenOrderRowQueryRequest();
|
||||||
OrderRowReq orderReq = new OrderRowReq();
|
OrderRowReq orderReq = new OrderRowReq();
|
||||||
orderReq.setPageIndex(pageIndex);
|
orderReq.setPageIndex(pageIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user