This commit is contained in:
Leo
2024-11-16 18:38:50 +08:00
parent 9d1a02ba18
commit f1d23bfe96
2 changed files with 24 additions and 13 deletions

View File

@@ -36,8 +36,6 @@ import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.lang.Thread.sleep;
/**
* @author Leo
* @version 1.0
@@ -201,7 +199,11 @@ public class JDUtils {
}
@Scheduled(cron = "0 * * * * ?") // 每分钟执行一次
/**
* 扫描订单发送到微信
* 每分钟的30秒执行一次
*/
@Scheduled(cron = "30 * * * * ?")
public void sendOrderToWx() {
int[] parm = {-1};
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm);
@@ -214,7 +216,7 @@ public class JDUtils {
}
/**
* 指令
* 接收京粉指令指令
*/
public void sendOrderToWxByOrderJD(String order) throws Exception {
int[] parm = {-1};
@@ -277,7 +279,7 @@ public class JDUtils {
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(yesterdayOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
break;
}
case "三日统计":{
case "三日统计": {
List<OrderRow> last3DaysOrders = filterOrdersByDate(orderRows, 3);
content.append("三日统计:\n");
content.append("订单总数:").append(last3DaysOrders.size()).append("\r");
@@ -425,10 +427,12 @@ public class JDUtils {
}
}
/**
* 接收京粉指令指令
* 高级菜单
* */
public void sendOrderToWxByOrderJDAdvanced (String order) throws Exception {
*/
public void sendOrderToWxByOrderJDAdvanced(String order) throws Exception {
int[] parm = {-1};
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm);
@@ -472,8 +476,9 @@ public class JDUtils {
}
}
/**
* 手动调用 将订单发送到微信
*/
private void orderToWx(OrderRow orderRow, Boolean isAutoFlush) {
// 查询订单状态
Integer newValidCode = orderRow.getValidCode();
@@ -490,13 +495,15 @@ public class JDUtils {
} else {
String content;
content = getFormattedOrderInfo(orderRow, Util.isEmpty(oldValidCode) ? -100 : Integer.parseInt(oldValidCode));
// 推送
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content, 1, WXUtil.super_admin_wxid);
}
}
/**
* 将数据库订单转化成微信所需要文本
*/
public String getFormattedOrderInfo(OrderRow orderRow, Integer oldValidCode) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ValidCodeConverter converter = new ValidCodeConverter();
@@ -627,7 +634,10 @@ public class JDUtils {
return response.getGetResult().getData().getClickURL();
}
// 拉取历史订单 2880 次请求
/**
* 每小时拉取过去两个月的订单
* 因为有的延迟发货,而接口只能拉取两个月前的数据
*/
@Scheduled(cron = "0 0 * * * ?")
public void fetchHistoricalOrders() throws Exception {
// 从设定的开始日期到昨天的同一时间

View File

@@ -11,6 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
@@ -211,7 +212,7 @@ public class WxMessageConsumer {
return finallyUrl;
}
//@Async("threadPoolTaskExecutor")
@Async("threadPoolTaskExecutor")
public void consume(WxMessage wxMessage) throws Exception {
//logger.info("接收到消息 : {}", wxMessage);
if (wxMessage.getEvent() == null) {
@@ -224,7 +225,7 @@ public class WxMessageConsumer {
* 转账需要对接会员系统
*
* */
WxMessage.DataSection data = wxMessage.getData();
//WxMessage.DataSection data = wxMessage.getData();
if (FromType.PRIVATE.getKey().equals(wxMessage.getEvent())) {
handlePrivateMessage(wxMessage);
} else if (FromType.GROUP.getKey().equals(wxMessage.getEvent())) {