1
This commit is contained in:
@@ -818,54 +818,19 @@ public class JDOrderController extends BaseController {
|
||||
*/
|
||||
private void sendEnterprisePushNotification(JDOrder order, String waybillNo, JSONObject logisticsData) {
|
||||
try {
|
||||
// 构建推送消息内容
|
||||
// 构建推送消息内容(只包含:型号、收货地址、运单号)
|
||||
StringBuilder pushContent = new StringBuilder();
|
||||
pushContent.append("物流信息获取成功\n");
|
||||
pushContent.append("订单号:").append(order.getOrderId() != null ? order.getOrderId() : "无").append("\n");
|
||||
pushContent.append("内部单号:").append(order.getRemark() != null ? order.getRemark() : "无").append("\n");
|
||||
pushContent.append("分销标识:").append(order.getDistributionMark() != null ? order.getDistributionMark() : "无").append("\n");
|
||||
pushContent.append("型号:").append(order.getModelNumber() != null ? order.getModelNumber() : "无").append("\n");
|
||||
pushContent.append("收货地址:").append(order.getAddress() != null ? order.getAddress() : "无").append("\n");
|
||||
pushContent.append("运单号:").append(waybillNo).append("\n");
|
||||
pushContent.append("物流链接:").append(order.getLogisticsLink() != null ? order.getLogisticsLink() : "无").append("\n");
|
||||
|
||||
// 提取物流跟踪信息
|
||||
JSONObject dataObj = logisticsData.getJSONObject("data");
|
||||
if (dataObj != null) {
|
||||
JSONArray trackingInfo = dataObj.getJSONArray("tracking_info");
|
||||
if (trackingInfo != null && trackingInfo.size() > 0) {
|
||||
pushContent.append("\n物流跟踪信息:\n");
|
||||
// 只显示最新的几条
|
||||
int maxItems = Math.min(3, trackingInfo.size());
|
||||
for (int i = 0; i < maxItems; i++) {
|
||||
JSONObject item = trackingInfo.getJSONObject(i);
|
||||
if (item != null) {
|
||||
String text = item.getString("text");
|
||||
String time = item.getString("time");
|
||||
if (text != null) {
|
||||
// 取第一行作为主要信息
|
||||
String[] lines = text.split("\n");
|
||||
if (lines.length > 0) {
|
||||
pushContent.append("- ").append(lines[0]);
|
||||
if (time != null && !time.trim().isEmpty()) {
|
||||
pushContent.append(" (").append(time).append(")");
|
||||
}
|
||||
pushContent.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trackingInfo.size() > maxItems) {
|
||||
pushContent.append("... 还有 ").append(trackingInfo.size() - maxItems).append(" 条跟踪信息\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 调用企业微信推送接口(参考WxtsUtil的实现)
|
||||
String pushUrl = "https://wxts.van333.cn/wx/send/jd";
|
||||
String pushUrl = "https://wxts.van333.cn/wx/send/pdd";
|
||||
String token = "super_token_b62190c26"; // 与WxtsUtil中的TOKEN保持一致
|
||||
JSONObject pushParam = new JSONObject();
|
||||
pushParam.put("title", "JD物流信息推送");
|
||||
String content = pushContent.toString().replaceAll("\\n", "<br>");
|
||||
String common = "192.168.8.88 (微信机器人), 信息 : ";
|
||||
String common = " ";
|
||||
content = common + content + "<br><br>";
|
||||
pushParam.put("text", content);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user