1
This commit is contained in:
@@ -36,8 +36,6 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static java.lang.Thread.sleep;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Leo
|
* @author Leo
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@@ -201,7 +199,11 @@ public class JDUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 * * * * ?") // 每分钟执行一次
|
/**
|
||||||
|
* 扫描订单发送到微信
|
||||||
|
* 每分钟的30秒执行一次
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "30 * * * * ?")
|
||||||
public void sendOrderToWx() {
|
public void sendOrderToWx() {
|
||||||
int[] parm = {-1};
|
int[] parm = {-1};
|
||||||
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm);
|
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm);
|
||||||
@@ -214,7 +216,7 @@ public class JDUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指令
|
* 接收京粉指令指令
|
||||||
*/
|
*/
|
||||||
public void sendOrderToWxByOrderJD(String order) throws Exception {
|
public void sendOrderToWxByOrderJD(String order) throws Exception {
|
||||||
int[] parm = {-1};
|
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());
|
content.append("\r" + "违规佣金:").append(getStreamForWeiGui(yesterdayOrders).mapToDouble(orderRow -> orderRow.getEstimateCosPrice() * orderRow.getCommissionRate() * 0.01).sum());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "三日统计":{
|
case "三日统计": {
|
||||||
List<OrderRow> last3DaysOrders = filterOrdersByDate(orderRows, 3);
|
List<OrderRow> last3DaysOrders = filterOrdersByDate(orderRows, 3);
|
||||||
content.append("三日统计:\n");
|
content.append("三日统计:\n");
|
||||||
content.append("订单总数:").append(last3DaysOrders.size()).append("\r");
|
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};
|
int[] parm = {-1};
|
||||||
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm);
|
List<OrderRow> orderRows = orderRowRepository.findByValidCodeNotInOrderByOrderTimeDesc(parm);
|
||||||
|
|
||||||
@@ -472,8 +476,9 @@ public class JDUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手动调用 将订单发送到微信
|
||||||
|
*/
|
||||||
private void orderToWx(OrderRow orderRow, Boolean isAutoFlush) {
|
private void orderToWx(OrderRow orderRow, Boolean isAutoFlush) {
|
||||||
// 查询订单状态
|
// 查询订单状态
|
||||||
Integer newValidCode = orderRow.getValidCode();
|
Integer newValidCode = orderRow.getValidCode();
|
||||||
@@ -490,13 +495,15 @@ public class JDUtils {
|
|||||||
} else {
|
} else {
|
||||||
String content;
|
String content;
|
||||||
content = getFormattedOrderInfo(orderRow, Util.isEmpty(oldValidCode) ? -100 : Integer.parseInt(oldValidCode));
|
content = getFormattedOrderInfo(orderRow, Util.isEmpty(oldValidCode) ? -100 : Integer.parseInt(oldValidCode));
|
||||||
|
|
||||||
// 推送
|
// 推送
|
||||||
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content, 1, WXUtil.super_admin_wxid);
|
wxUtil.sendTextMessage(WXUtil.super_admin_wxid, content, 1, WXUtil.super_admin_wxid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将数据库订单转化成微信所需要文本
|
||||||
|
*/
|
||||||
public String getFormattedOrderInfo(OrderRow orderRow, Integer oldValidCode) {
|
public String getFormattedOrderInfo(OrderRow orderRow, Integer oldValidCode) {
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
ValidCodeConverter converter = new ValidCodeConverter();
|
ValidCodeConverter converter = new ValidCodeConverter();
|
||||||
@@ -627,7 +634,10 @@ public class JDUtils {
|
|||||||
return response.getGetResult().getData().getClickURL();
|
return response.getGetResult().getData().getClickURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拉取历史订单 2880 次请求
|
/**
|
||||||
|
* 每小时拉取过去两个月的订单
|
||||||
|
* 因为有的延迟发货,而接口只能拉取两个月前的数据
|
||||||
|
*/
|
||||||
@Scheduled(cron = "0 0 * * * ?")
|
@Scheduled(cron = "0 0 * * * ?")
|
||||||
public void fetchHistoricalOrders() throws Exception {
|
public void fetchHistoricalOrders() throws Exception {
|
||||||
// 从设定的开始日期到昨天的同一时间
|
// 从设定的开始日期到昨天的同一时间
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -211,7 +212,7 @@ public class WxMessageConsumer {
|
|||||||
return finallyUrl;
|
return finallyUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Async("threadPoolTaskExecutor")
|
@Async("threadPoolTaskExecutor")
|
||||||
public void consume(WxMessage wxMessage) throws Exception {
|
public void consume(WxMessage wxMessage) throws Exception {
|
||||||
//logger.info("接收到消息 : {}", wxMessage);
|
//logger.info("接收到消息 : {}", wxMessage);
|
||||||
if (wxMessage.getEvent() == null) {
|
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())) {
|
if (FromType.PRIVATE.getKey().equals(wxMessage.getEvent())) {
|
||||||
handlePrivateMessage(wxMessage);
|
handlePrivateMessage(wxMessage);
|
||||||
} else if (FromType.GROUP.getKey().equals(wxMessage.getEvent())) {
|
} else if (FromType.GROUP.getKey().equals(wxMessage.getEvent())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user