1
This commit is contained in:
129
src/main/java/cn/van/business/config/SchedulerConfig.java
Normal file
129
src/main/java/cn/van/business/config/SchedulerConfig.java
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
package cn.van.business.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||||
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SchedulerConfig implements SchedulingConfigurer {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SchedulerConfig.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||||
|
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
|
||||||
|
|
||||||
|
taskRegistrar.setScheduler(new CustomScheduledExecutorService(scheduledExecutorService));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CustomScheduledExecutorService implements ScheduledExecutorService {
|
||||||
|
private final ScheduledExecutorService delegate;
|
||||||
|
|
||||||
|
public CustomScheduledExecutorService(ScheduledExecutorService delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
|
||||||
|
return delegate.schedule(wrap(command), delay, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
|
||||||
|
return delegate.scheduleAtFixedRate(wrap(command), initialDelay, period, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
|
||||||
|
return delegate.scheduleWithFixedDelay(wrap(command), initialDelay, delay, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Runnable wrap(Runnable command) {
|
||||||
|
return () -> {
|
||||||
|
try {
|
||||||
|
command.run();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Scheduled task error", e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delegate other methods to the delegate executor
|
||||||
|
@Override
|
||||||
|
public void shutdown() {
|
||||||
|
delegate.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Runnable> shutdownNow() {
|
||||||
|
return delegate.shutdownNow();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isShutdown() {
|
||||||
|
return delegate.isShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTerminated() {
|
||||||
|
return delegate.isTerminated();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
|
||||||
|
return delegate.awaitTermination(timeout, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> Future<T> submit(Callable<T> task) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> Future<T> submit(Runnable task, T result) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Future<?> submit(Runnable task) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> ScheduledFuture<T> schedule(Callable<T> callable, long delay, TimeUnit unit) {
|
||||||
|
return delegate.schedule(callable, delay, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(Runnable command) {
|
||||||
|
delegate.execute(wrap(command));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,8 +8,11 @@ import com.jd.open.api.sdk.DefaultJdClient;
|
|||||||
import com.jd.open.api.sdk.JdClient;
|
import com.jd.open.api.sdk.JdClient;
|
||||||
import com.jd.open.api.sdk.domain.kplunion.OrderService.request.query.OrderRowReq;
|
import com.jd.open.api.sdk.domain.kplunion.OrderService.request.query.OrderRowReq;
|
||||||
import com.jd.open.api.sdk.domain.kplunion.OrderService.response.query.OrderRowResp;
|
import com.jd.open.api.sdk.domain.kplunion.OrderService.response.query.OrderRowResp;
|
||||||
|
import com.jd.open.api.sdk.domain.kplunion.promotionbysubunioni.PromotionService.request.get.PromotionCodeReq;
|
||||||
import com.jd.open.api.sdk.request.kplunion.UnionOpenOrderRowQueryRequest;
|
import com.jd.open.api.sdk.request.kplunion.UnionOpenOrderRowQueryRequest;
|
||||||
|
import com.jd.open.api.sdk.request.kplunion.UnionOpenPromotionBysubunionidGetRequest;
|
||||||
import com.jd.open.api.sdk.response.kplunion.UnionOpenOrderRowQueryResponse;
|
import com.jd.open.api.sdk.response.kplunion.UnionOpenOrderRowQueryResponse;
|
||||||
|
import com.jd.open.api.sdk.response.kplunion.UnionOpenPromotionBysubunionidGetResponse;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -193,30 +196,30 @@ public class JDUtil {
|
|||||||
WXUtil.SuperAdmin admin = entry.getValue();
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
String appKey = admin.getAppKey();
|
String appKey = admin.getAppKey();
|
||||||
String secretKey = admin.getSecretKey();
|
String secretKey = admin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
logger.info("实时订单 {} ",appKey.substring(appKey.length()-4));
|
logger.info("实时订单 {} ", appKey.substring(appKey.length() - 4));
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(lastMinute, true, 1, true,appKey,secretKey); // 真实代表实时订单
|
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();
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
if (response.getQueryResult().getCode() == 200) {
|
if (response.getQueryResult().getCode() == 200) {
|
||||||
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
||||||
if (orderRowResps == null) {
|
if (orderRowResps == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (OrderRowResp orderRowResp : orderRowResps) {
|
for (OrderRowResp orderRowResp : orderRowResps) {
|
||||||
// 固化到数据库
|
// 固化到数据库
|
||||||
OrderRow orderRow = createOrderRow(orderRowResp);
|
OrderRow orderRow = createOrderRow(orderRowResp);
|
||||||
// 订单号不存在就保存,存在就更新订单状态
|
// 订单号不存在就保存,存在就更新订单状态
|
||||||
orderRowRepository.save(orderRow);
|
orderRowRepository.save(orderRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +230,7 @@ public class JDUtil {
|
|||||||
WXUtil.SuperAdmin admin = entry.getValue();
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
String appKey = admin.getAppKey();
|
String appKey = admin.getAppKey();
|
||||||
String secretKey = admin.getSecretKey();
|
String secretKey = admin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
@@ -236,12 +239,12 @@ public class JDUtil {
|
|||||||
LocalDateTime lastHour = now.truncatedTo(ChronoUnit.HOURS);
|
LocalDateTime lastHour = now.truncatedTo(ChronoUnit.HOURS);
|
||||||
LocalDateTime startDate = lastHour.minusMonths(12);
|
LocalDateTime startDate = lastHour.minusMonths(12);
|
||||||
|
|
||||||
logger.info("{} - {}" ,startDate,lastHour);
|
logger.info("{} - {}", startDate, lastHour);
|
||||||
|
|
||||||
while (!startDate.isEqual(lastHour)) {
|
while (!startDate.isEqual(lastHour)) {
|
||||||
|
|
||||||
test(startDate, appKey);
|
test(startDate, appKey);
|
||||||
logger.info("test {}",startDate);
|
logger.info("test {}", startDate);
|
||||||
|
|
||||||
|
|
||||||
startDate = startDate.plusHours(1);
|
startDate = startDate.plusHours(1);
|
||||||
@@ -283,14 +286,14 @@ public class JDUtil {
|
|||||||
WXUtil.SuperAdmin admin = entry.getValue();
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
String appKey = admin.getAppKey();
|
String appKey = admin.getAppKey();
|
||||||
String secretKey = admin.getSecretKey();
|
String secretKey = admin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fetchHistoricalOrders3090Do(appKey, secretKey);
|
fetchHistoricalOrders3090Do(appKey, secretKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int fetchHistoricalOrders3090Do(String appKey,String secretKey) {
|
private int fetchHistoricalOrders3090Do(String appKey, String secretKey) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
@@ -307,7 +310,7 @@ public class JDUtil {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// 30-60 天 ,非实时,非分钟
|
// 30-60 天 ,非实时,非分钟
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false,appKey,secretKey);
|
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();
|
||||||
@@ -349,14 +352,14 @@ public class JDUtil {
|
|||||||
WXUtil.SuperAdmin admin = entry.getValue();
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
String appKey = admin.getAppKey();
|
String appKey = admin.getAppKey();
|
||||||
String secretKey = admin.getSecretKey();
|
String secretKey = admin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fetchHistoricalOrders1430Do(appKey, secretKey);
|
fetchHistoricalOrders1430Do(appKey, secretKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int fetchHistoricalOrders1430Do(String appKey,String secretKey) {
|
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());
|
||||||
@@ -371,7 +374,7 @@ public class JDUtil {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// 14 - 30 天 ,非实时,非分钟
|
// 14 - 30 天 ,非实时,非分钟
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false,appKey,secretKey);
|
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();
|
||||||
@@ -413,14 +416,14 @@ public class JDUtil {
|
|||||||
WXUtil.SuperAdmin admin = entry.getValue();
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
String appKey = admin.getAppKey();
|
String appKey = admin.getAppKey();
|
||||||
String secretKey = admin.getSecretKey();
|
String secretKey = admin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fetchHistoricalOrders0714Do(appKey, secretKey);
|
fetchHistoricalOrders0714Do(appKey, secretKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int fetchHistoricalOrders0714Do(String appKey,String secretKey) {
|
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());
|
||||||
@@ -434,7 +437,7 @@ public class JDUtil {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// 7 - 14 天 ,非实时,非分钟
|
// 7 - 14 天 ,非实时,非分钟
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false,appKey,secretKey);
|
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();
|
||||||
@@ -473,14 +476,14 @@ public class JDUtil {
|
|||||||
WXUtil.SuperAdmin admin = entry.getValue();
|
WXUtil.SuperAdmin admin = entry.getValue();
|
||||||
String appKey = admin.getAppKey();
|
String appKey = admin.getAppKey();
|
||||||
String secretKey = admin.getSecretKey();
|
String secretKey = admin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fetchHistoricalOrders0007Do(appKey, secretKey);
|
fetchHistoricalOrders0007Do(appKey, secretKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int fetchHistoricalOrders0007Do(String appKey,String secretKey) {
|
private int fetchHistoricalOrders0007Do(String appKey, String secretKey) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
@@ -495,7 +498,7 @@ public class JDUtil {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// 0 - 7 天 ,非实时,非分钟
|
// 0 - 7 天 ,非实时,非分钟
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, pageIndex, false,appKey,secretKey);
|
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();
|
||||||
@@ -535,13 +538,13 @@ public class JDUtil {
|
|||||||
* page 分页页码
|
* page 分页页码
|
||||||
* isMinutes 是否是分钟级订单 分钟的每次加10分钟,小时每小时加1小时
|
* isMinutes 是否是分钟级订单 分钟的每次加10分钟,小时每小时加1小时
|
||||||
*/
|
*/
|
||||||
public UnionOpenOrderRowQueryResponse fetchOrdersForDateTime(LocalDateTime startTime, boolean isRealTime, Integer page, boolean isMinutes,String appKey,String secretKey) {
|
public UnionOpenOrderRowQueryResponse fetchOrdersForDateTime(LocalDateTime startTime, boolean isRealTime, Integer page, boolean isMinutes, String appKey, String secretKey) {
|
||||||
|
|
||||||
LocalDateTime endTime = isMinutes ? startTime.plusMinutes(10) : startTime.plusHours(1);
|
LocalDateTime endTime = isMinutes ? startTime.plusMinutes(10) : startTime.plusHours(1);
|
||||||
String hourMinuteTag = isRealTime ? "minute" : "hour";
|
String hourMinuteTag = isRealTime ? "minute" : "hour";
|
||||||
//String oldTimeTag = JD_REFRESH_TAG + startTime.format(DATE_TIME_FORMATTER);
|
//String oldTimeTag = JD_REFRESH_TAG + startTime.format(DATE_TIME_FORMATTER);
|
||||||
|
|
||||||
String newTimeTag = JD_REFRESH_TAG +appKey +":"+ startTime.format(DATE_TIME_FORMATTER);
|
String newTimeTag = JD_REFRESH_TAG + appKey + ":" + startTime.format(DATE_TIME_FORMATTER);
|
||||||
|
|
||||||
HashOperations<String, String, String> hashOps = redisTemplate.opsForHash();
|
HashOperations<String, String, String> hashOps = redisTemplate.opsForHash();
|
||||||
|
|
||||||
@@ -554,7 +557,7 @@ public class JDUtil {
|
|||||||
|
|
||||||
// 调用 API 以拉取订单
|
// 调用 API 以拉取订单
|
||||||
try {
|
try {
|
||||||
UnionOpenOrderRowQueryResponse unionOpenOrderRowQueryResponse = getUnionOpenOrderRowQueryResponse(startTime, endTime, page,appKey,secretKey);
|
UnionOpenOrderRowQueryResponse unionOpenOrderRowQueryResponse = getUnionOpenOrderRowQueryResponse(startTime, endTime, page, appKey, secretKey);
|
||||||
// 历史的订单才进行标记为已拉取,小时分钟的都进行拉取并且标记
|
// 历史的订单才进行标记为已拉取,小时分钟的都进行拉取并且标记
|
||||||
if (!isRealTime) {
|
if (!isRealTime) {
|
||||||
// 只有没有订单的才进行标记为已拉取
|
// 只有没有订单的才进行标记为已拉取
|
||||||
@@ -565,8 +568,8 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 打印方法调用和开始结束时间
|
// 打印方法调用和开始结束时间
|
||||||
if(isRealTime){
|
if (isRealTime) {
|
||||||
logger.info(" {} --- 拉取订单, 分钟还是秒 {} , 开始时间:{} --- 结束时间:{}", appKey.substring(appKey.length()-4) ,hourMinuteTag, startTime.format(DATE_TIME_FORMATTER), endTime.format(DATE_TIME_FORMATTER));
|
logger.info(" {} --- 拉取订单, 分钟还是秒 {} , 开始时间:{} --- 结束时间:{}", appKey.substring(appKey.length() - 4), hourMinuteTag, startTime.format(DATE_TIME_FORMATTER), endTime.format(DATE_TIME_FORMATTER));
|
||||||
}
|
}
|
||||||
|
|
||||||
return unionOpenOrderRowQueryResponse;
|
return unionOpenOrderRowQueryResponse;
|
||||||
@@ -576,9 +579,10 @@ public class JDUtil {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public synchronized void test(LocalDateTime startTime,String appKey){
|
|
||||||
|
public synchronized void test(LocalDateTime startTime, String appKey) {
|
||||||
String oldTimeTag = JD_REFRESH_TAG + startTime.format(DATE_TIME_FORMATTER);
|
String oldTimeTag = JD_REFRESH_TAG + startTime.format(DATE_TIME_FORMATTER);
|
||||||
String newTimeTag = JD_REFRESH_TAG +appKey +":"+ startTime.format(DATE_TIME_FORMATTER);
|
String newTimeTag = JD_REFRESH_TAG + appKey + ":" + startTime.format(DATE_TIME_FORMATTER);
|
||||||
|
|
||||||
|
|
||||||
HashOperations<String, String, String> hashOps = redisTemplate.opsForHash();
|
HashOperations<String, String, String> hashOps = redisTemplate.opsForHash();
|
||||||
@@ -597,7 +601,7 @@ public class JDUtil {
|
|||||||
/**
|
/**
|
||||||
* 接收京粉指令指令
|
* 接收京粉指令指令
|
||||||
*/
|
*/
|
||||||
public void sendOrderToWxByOrderJD(String order,String fromWxid) {
|
public void sendOrderToWxByOrderJD(String order, String fromWxid) {
|
||||||
int[] param = {-1};
|
int[] param = {-1};
|
||||||
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
||||||
String unionId = superAdmin.getUnionId();
|
String unionId = superAdmin.getUnionId();
|
||||||
@@ -638,7 +642,7 @@ public class JDUtil {
|
|||||||
content.append("京高级+订单号\r\"");
|
content.append("京高级+订单号\r\"");
|
||||||
content.append("京高级SKU+sku\\r\"");
|
content.append("京高级SKU+sku\\r\"");
|
||||||
break;
|
break;
|
||||||
case "测试指令":{
|
case "测试指令": {
|
||||||
//test01();
|
//test01();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -842,12 +846,12 @@ public class JDUtil {
|
|||||||
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 appKey = superAdmin.getAppKey();
|
||||||
String secretKey = superAdmin.getSecretKey();
|
String secretKey = superAdmin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (!startDate.isEqual(lastHour)) {
|
while (!startDate.isEqual(lastHour)) {
|
||||||
startDate = startDate.plusHours(1);
|
startDate = startDate.plusHours(1);
|
||||||
UnionOpenOrderRowQueryResponse response = fetchOrdersForDateTime(startDate, false, 1, false,appKey,secretKey);
|
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();
|
||||||
@@ -875,11 +879,11 @@ public class JDUtil {
|
|||||||
case "刷新3090": {
|
case "刷新3090": {
|
||||||
String appKey = superAdmin.getAppKey();
|
String appKey = superAdmin.getAppKey();
|
||||||
String secretKey = superAdmin.getSecretKey();
|
String secretKey = superAdmin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
int count = fetchHistoricalOrders3090Do(appKey,secretKey);
|
int count = fetchHistoricalOrders3090Do(appKey, secretKey);
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
content.append("订单行:").append(count).append(",耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r");
|
content.append("订单行:").append(count).append(",耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r");
|
||||||
break;
|
break;
|
||||||
@@ -888,11 +892,11 @@ public class JDUtil {
|
|||||||
case "刷新1430": {
|
case "刷新1430": {
|
||||||
String appKey = superAdmin.getAppKey();
|
String appKey = superAdmin.getAppKey();
|
||||||
String secretKey = superAdmin.getSecretKey();
|
String secretKey = superAdmin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
int count = fetchHistoricalOrders1430Do(appKey,secretKey);
|
int count = fetchHistoricalOrders1430Do(appKey, secretKey);
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
content.append("订单行:").append(count).append(",耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r");
|
content.append("订单行:").append(count).append(",耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r");
|
||||||
|
|
||||||
@@ -901,21 +905,21 @@ public class JDUtil {
|
|||||||
case "刷新0714": {
|
case "刷新0714": {
|
||||||
String appKey = superAdmin.getAppKey();
|
String appKey = superAdmin.getAppKey();
|
||||||
String secretKey = superAdmin.getSecretKey();
|
String secretKey = superAdmin.getSecretKey();
|
||||||
if (Util.isAnyEmpty(appKey,secretKey)){
|
if (Util.isAnyEmpty(appKey, secretKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
int count = fetchHistoricalOrders0714Do(appKey,secretKey);
|
int count = fetchHistoricalOrders0714Do(appKey, secretKey);
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
content.append("订单行:").append(count).append(",耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r");
|
content.append("订单行:").append(count).append(",耗时: ").append(time).append("ms, ").append((time) / 1000).append(" s\r");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sendOrderToWxByOrderJDAdvanced(order,fromWxid);
|
sendOrderToWxByOrderJDAdvanced(order, fromWxid);
|
||||||
}
|
}
|
||||||
if (content.length() > 0) {
|
if (content.length() > 0) {
|
||||||
wxUtil.sendTextMessage(fromWxid, content.toString(), 1,fromWxid);
|
wxUtil.sendTextMessage(fromWxid, content.toString(), 1, fromWxid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -924,7 +928,7 @@ public class JDUtil {
|
|||||||
* 接收京粉指令指令
|
* 接收京粉指令指令
|
||||||
* 高级菜单
|
* 高级菜单
|
||||||
*/
|
*/
|
||||||
public void sendOrderToWxByOrderJDAdvanced(String order,String fromWxid) {
|
public void sendOrderToWxByOrderJDAdvanced(String order, String fromWxid) {
|
||||||
int[] param = {-1};
|
int[] param = {-1};
|
||||||
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
||||||
String unionId = superAdmin.getUnionId();
|
String unionId = superAdmin.getUnionId();
|
||||||
@@ -1010,7 +1014,7 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
sendOrderToWxByOrderJD("菜单",fromWxid);
|
sendOrderToWxByOrderJD("菜单", fromWxid);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -1045,7 +1049,7 @@ public class JDUtil {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public UnionOpenOrderRowQueryResponse getUnionOpenOrderRowQueryResponse(LocalDateTime start, LocalDateTime end, Integer pageIndex,String appKey,String secretKey) 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 调用
|
||||||
@@ -1076,37 +1080,45 @@ public class JDUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 接口描述:通过商品链接、领券链接、活动链接获取普通推广链接或优惠券二合一推广链接
|
* 接口描述:通过商品链接、领券链接、活动链接获取普通推广链接或优惠券二合一推广链接
|
||||||
|
* jd.union.open.promotion.bysubunionid.get
|
||||||
*/
|
*/
|
||||||
//String transfer(String url) throws Exception {
|
String transfer(String url) throws Exception {
|
||||||
// JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, APP_KEY_DG, SECRET_KEY_DG);
|
JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, LPF_APP_KEY_DG, LPF_SECRET_KEY_DG);
|
||||||
// UnionOpenPromotionBysubunionidGetRequest getRequest = new UnionOpenPromotionBysubunionidGetRequest();
|
|
||||||
// getRequest.setVersion("1.0");
|
UnionOpenPromotionBysubunionidGetRequest request = new UnionOpenPromotionBysubunionidGetRequest();
|
||||||
// getRequest.setSignmethod("md5");
|
PromotionCodeReq promotionCodeReq = new PromotionCodeReq();
|
||||||
//
|
request.setPromotionCodeReq(promotionCodeReq);
|
||||||
// PromotionCodeReq promotionCodeReq = new PromotionCodeReq();
|
request.setVersion("1.0");
|
||||||
// promotionCodeReq.setMaterialId(url);
|
UnionOpenPromotionBysubunionidGetResponse response = client.execute(request);
|
||||||
// promotionCodeReq.setSiteId("4101191512");
|
|
||||||
// promotionCodeReq.setSceneId(2);
|
/**
|
||||||
// promotionCodeReq.setCommand(1);
|
* {
|
||||||
// promotionCodeReq.setProType(5);
|
* "jd_union_open_promotion_bysubunionid_get_responce": {
|
||||||
//
|
* "getResult": {
|
||||||
//
|
* "code": "200",
|
||||||
// getRequest.setPromotionCodeReq(promotionCodeReq);
|
* "data": {
|
||||||
// client.execute(getRequest);
|
* "clickURL": "https://union-click.jd.com/jdc?e=XXXXXX p=XXXXXXXXXXX",
|
||||||
//
|
* "weChatShortLink": "#小程序://京小街/****",
|
||||||
// String jsonString = JSON.toJSONString(response);
|
* "jShortCommand": "短口令",
|
||||||
// System.out.println(jsonString);
|
* "shortURL": "https://u.jd.com/XXXXX",
|
||||||
//
|
* "jCommand": "6.0复制整段话 http://JhT7V5wlKygHDK京口令内容#J6UFE5iMn***"
|
||||||
// System.out.println(request.getAppJsonParams());
|
* },
|
||||||
// System.out.println(request.getPromotionCodeReq());
|
* "message": "success"
|
||||||
//
|
* }
|
||||||
// System.out.println("--------");
|
* }
|
||||||
// System.out.println(response.getGetResult().getCode());
|
* }
|
||||||
// System.out.println(response.getGetResult().getMessage());
|
* */
|
||||||
// System.out.println(response.getGetResult().getData().getClickURL());
|
String result = "";
|
||||||
// System.out.println(response.getGetResult().getData().getJCommand());
|
if (Util.isNotEmpty(response)) {
|
||||||
// return response.getGetResult().getData().getClickURL();
|
if (response.getCode().equals("200")) {
|
||||||
//}
|
result = response.getGetResult().getData().getShortURL();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -288,16 +288,18 @@ public class WxMessageConsumer {
|
|||||||
}
|
}
|
||||||
// 只处理超管的消息
|
// 只处理超管的消息
|
||||||
String fromWxid = innerData.getFromWxid();
|
String fromWxid = innerData.getFromWxid();
|
||||||
WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
//WXUtil.SuperAdmin superAdmin = super_admins.get(fromWxid);
|
||||||
if (Util.isEmpty(superAdmin)){
|
//if (Util.isEmpty(superAdmin)){
|
||||||
logger.info("不是超管消息,不处理");
|
// logger.info("不是超管消息,不处理");
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
String msg = innerData.getMsg();
|
String msg = innerData.getMsg();
|
||||||
//美团 20-7 + https://i.meituan.com/mttouch/page/account?userId=3822095266&token=AgHdIkm2tAGHc9SQSiG7M8xCx1LbTue9D2HPOAun2eYl3ou7BeEw1uGrGZH-DxmEiUgsbA1v9SM4DQAAAAC6HAAAz0rTXmkB_CIHin08hCu68mFv5k6nUc2q6_CfZqEdBcngRK_xD8Sx5fE4rfdq-yAJ, msgbase64=576O5ZuiIDIwLTcgKyBodHRwczovL2kubWVpdHVhbi5jb20vbXR0b3VjaC9wYWdlL2FjY291bnQ/dXNlcklkPTM4MjIwOTUyNjYmdG9rZW49QWdIZElrbTJ0QUdIYzlTUVNpRzdNOHhDeDFMYlR1ZTlEMkhQT0F1bjJlWWwzb3U3QmVFdzF1R3JHWkgtRHhtRWlVZ3NiQTF2OVNNNERRQUFBQUM2SEFBQXowclRYbWtCX0NJSGluMDhoQ3U2OG1GdjVrNm5VYzJxNl9DZlpxRWRCY25nUktfeEQ4U3g1ZkU0cmZkcS15QUo=
|
|
||||||
if (msg.startsWith("转链")) {
|
/**
|
||||||
|
* 【京东】https://3.cn/2c-47ATm 「京东京造桌面抽屉式收纳盒」
|
||||||
|
* 点击链接直接打开
|
||||||
|
* */
|
||||||
|
if (msg.contains("【京东】")){
|
||||||
String wxid;
|
String wxid;
|
||||||
if (Objects.equals(event, fromGR)) {
|
if (Objects.equals(event, fromGR)) {
|
||||||
wxid = innerData.getFromWxid();
|
wxid = innerData.getFromWxid();
|
||||||
@@ -310,13 +312,13 @@ public class WxMessageConsumer {
|
|||||||
// 获取 100065976064
|
// 获取 100065976064
|
||||||
logger.info("处理转链消息");
|
logger.info("处理转链消息");
|
||||||
|
|
||||||
//String finallyUrl = getUrlStr(msg);
|
String finallyUrl = getUrlStr(msg);
|
||||||
//String finallyUrl = extractProductId(msg);
|
//String finallyUrl = extractProductId(msg);
|
||||||
//String finallyUrl = msg.substring(2);
|
//String finallyUrl = msg.substring(2);
|
||||||
//if (Util.isNotEmpty(finallyUrl)) {
|
if (Util.isNotEmpty(finallyUrl)) {
|
||||||
// String transferResultUrl = jdUtils.transfer(finallyUrl);
|
String transferResultUrl = jdUtils.transfer(finallyUrl);
|
||||||
// wxUtil.sendTextMessage(wxid, transferResultUrl, msgType, null);
|
wxUtil.sendTextMessage(wxid, transferResultUrl, msgType, null);
|
||||||
//}
|
}
|
||||||
} else if (msg.startsWith("京")) {
|
} else if (msg.startsWith("京")) {
|
||||||
jdUtils.sendOrderToWxByOrderJD(msg.replace("京", ""),fromWxid);
|
jdUtils.sendOrderToWxByOrderJD(msg.replace("京", ""),fromWxid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ spring:
|
|||||||
messages:
|
messages:
|
||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
basename: i18n/messages
|
basename: i18n/messages
|
||||||
|
task:
|
||||||
|
execution:
|
||||||
|
pool:
|
||||||
|
core-size: 32
|
||||||
|
|
||||||
# token配置
|
# token配置
|
||||||
token:
|
token:
|
||||||
|
|||||||
Reference in New Issue
Block a user