|
@@ -3,11 +3,19 @@ package com.iamberry.wechat.handles.mq;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.iamberry.wechat.core.entity.order.Order;
|
|
|
+import com.iamberry.wechat.tools.HttpClient431Util;
|
|
|
+import com.iamberry.wechat.tools.NameUtils;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -129,7 +137,59 @@ public class MQTask implements InitializingBean {
|
|
|
}
|
|
|
logger.info("------------task invoke success-----------");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据订单号拉取物流信息
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ //@Scheduled(cron = "0 0 */1 * * ?")//每小时执行一次
|
|
|
+ @Scheduled(cron = "0 0/2 * * * ?")//每2分钟执行一次
|
|
|
+ //@Scheduled(cron = "*/10 * * * * ?")
|
|
|
+ public void syncLgisticsInfoByOrderId() throws Exception {
|
|
|
+ System.out.println("---------------- 根据订单号拉取物流信息开始 ---------------");
|
|
|
+ logger.info("---------------- 根据订单号拉取物流信息开始 ---------------");
|
|
|
+ lock.lock();
|
|
|
+ List<Order> orderList = null;
|
|
|
+ String url = NameUtils.getConfig("rst_base_url");
|
|
|
+ String sdId = NameUtils.getConfig("sd_id");
|
|
|
+ Map<String, Object> orderData = new HashMap<String, Object>();
|
|
|
+ Map<String, String> requestData = new HashMap<String, String>();
|
|
|
+ com.fasterxml.jackson.databind.ObjectMapper mapper = new ObjectMapper();
|
|
|
+ try {
|
|
|
+ logger.info("---------------- selectProbationShopOrderList begin ---------------");
|
|
|
+ orderList = probationShopOrderService.selectProbationShopOrderList();
|
|
|
+ if(orderList != null && orderList.size() > 0){
|
|
|
+ for (Order order:orderList) {
|
|
|
+ String salesOrderid = order.getSalesOrderid();
|
|
|
+ orderData.put("orderId", salesOrderid);
|
|
|
+ orderData.put("sd_id", sdId);
|
|
|
+ requestData.put("app_act", "rst.trade.logistics.get");
|
|
|
+ String orderDataStr = mapper.writeValueAsString(orderData);
|
|
|
+ requestData.put("info", orderDataStr);
|
|
|
+ String result = HttpClient431Util.doPost(requestData, url);
|
|
|
+ result = StringEscapeUtils.unescapeJava(result); // unicode 编码
|
|
|
+ logger.info("拉取订单号为:" + order.getSalesOrderid() + "的订单,rst返回信息:" + result);
|
|
|
+ System.out.println("拉取订单号为:" + order.getSalesOrderid() + "的订单,rst返回信息:" + result);
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(result);
|
|
|
+ String msg = jsonObject.getString("msg");
|
|
|
+ logger.info("---------"+msg+"---------");
|
|
|
+ if ("seccess".equals(msg)) {
|
|
|
+ String salesPostFirm = jsonObject.getString("salesPostFirm");
|
|
|
+ String salesPostNum = jsonObject.getString("salesPostNum");
|
|
|
+ order.setSalesPostFirm(salesPostFirm);
|
|
|
+ order.setSalesPostNum(salesPostNum);
|
|
|
+ probationShopOrderService.updateProbationShopOrder(order);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("拉取订单异常",e.getMessage());
|
|
|
+ }finally {
|
|
|
+ lock.unlock();
|
|
|
+ }
|
|
|
+ logger.info("---------------- 根据订单号拉取物流信息结束 ---------------");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 订阅消息
|
|
|
*/
|