1
0
Преглед на файлове

xwh修改门店短信配置功能

xwh преди 4 години
родител
ревизия
bc723e449b

+ 39 - 32
kmall-admin/src/main/java/com/kmall/admin/Test.java

@@ -37,41 +37,48 @@ import java.util.*;
  */
 public class Test {
     public static void main(String[] args) {
-        Map<String, String> sParaTemp = new TreeMap<String, String>();
-        List<GoodsProductDto> goodsProductDtoList = new ArrayList<>();
-        GoodsProductDto dto = new GoodsProductDto();
-        dto.setMerchSn("mhbs990053989883052032");
-        goodsProductDtoList.add(dto);
-        PdProductDtoInfo pdProductDtoInfo = new PdProductDtoInfo();
-        pdProductDtoInfo.setPdProductDtoList(goodsProductDtoList);
-        sParaTemp.put("data", JSON.toJSONString(pdProductDtoInfo));
-        sParaTemp.put("merchId","mhbs990053989883052032");
-        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
-        sParaTemp.put("timestamp", timestamp);
-        //生成要请求给oms秘钥
-//        String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
-        String sign = OmsSign.sign(sParaTemp,"IxyIvP0sJqlUZinx");
-        sParaTemp.put("sign", sign);
-        //构建Request
-        String  url = "http://127.0.0.1:8680/al/product/addPdProductList";
-        Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
-        String s = JSON.toJSONString(sParaTemp);
-        // 同步访问,返回结果字符串
-        String responseString = null;
-        try {
+//        Map<String, String> sParaTemp = new TreeMap<String, String>();
+//        List<GoodsProductDto> goodsProductDtoList = new ArrayList<>();
+//        GoodsProductDto dto = new GoodsProductDto();
+//        dto.setMerchSn("mhbs990053989883052032");
+//        goodsProductDtoList.add(dto);
+//        PdProductDtoInfo pdProductDtoInfo = new PdProductDtoInfo();
+//        pdProductDtoInfo.setPdProductDtoList(goodsProductDtoList);
+//        sParaTemp.put("data", JSON.toJSONString(pdProductDtoInfo));
+//        sParaTemp.put("merchId","mhbs990053989883052032");
+//        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
+//        sParaTemp.put("timestamp", timestamp);
+//        //生成要请求给oms秘钥
+////        String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
+//        String sign = OmsSign.sign(sParaTemp,"IxyIvP0sJqlUZinx");
+//        sParaTemp.put("sign", sign);
+//        //构建Request
+//        String  url = "http://127.0.0.1:8680/al/product/addPdProductList";
+//        Request request = com.kmall.admin.utils.oms.OkHttpUtils.buildRequest(url, JSON.toJSONString(sParaTemp));
+//        String s = JSON.toJSONString(sParaTemp);
+//        // 同步访问,返回结果字符串
+//        String responseString = null;
+//        try {
+//
+//            responseString = com.kmall.admin.utils.oms.OkHttpUtils.post(request);
+//
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//
+//        //解析响应数据
+//        Gson gson = new Gson();
+//        ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
+//        if(result == null){
+//            String info = "解析响应数据Result失败";
+//            throw new RuntimeException(info);
+//        }
 
-            responseString = com.kmall.admin.utils.oms.OkHttpUtils.post(request);
 
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+        List<String> list = new ArrayList<>();
 
-        //解析响应数据
-        Gson gson = new Gson();
-        ResponseMessage result = gson.fromJson(responseString, ResponseMessage.class);
-        if(result == null){
-            String info = "解析响应数据Result失败";
-            throw new RuntimeException(info);
+        for (int i = 0; i < list.size(); i++) {
+            System.out.println(list.get(i));
         }
     }
 }

+ 29 - 28
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderProcessRecordServiceImpl.java

@@ -2,7 +2,6 @@ package com.kmall.admin.service.impl;
 
 import com.kmall.admin.dao.OrderDao;
 import com.kmall.admin.dao.OrderProcessRecordDao;
-import com.kmall.admin.dao.PickUpCodeDao;
 import com.kmall.admin.dao.StoreSmsConfigDao;
 import com.kmall.admin.entity.OrderEntity;
 import com.kmall.admin.entity.OrderProcessRecordEntity;
@@ -11,13 +10,13 @@ import com.kmall.admin.entity.StoreSmsConfigEntity;
 import com.kmall.admin.service.OrderProcessRecordService;
 import com.kmall.admin.service.PickUpCodeService;
 import com.kmall.api.util.SendMsgUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 
 /**
@@ -29,6 +28,8 @@ import java.util.concurrent.Executors;
  */
 @Service("orderProcessRecordService")
 public class OrderProcessRecordServiceImpl implements OrderProcessRecordService {
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
     @Autowired
     private OrderProcessRecordDao orderProcessRecordDao;
     @Autowired
@@ -41,6 +42,8 @@ public class OrderProcessRecordServiceImpl implements OrderProcessRecordService
     private OrderDao orderDao;
 
 
+
+
     @Override
     public OrderProcessRecordEntity queryObject(Integer id) {
         return orderProcessRecordDao.queryObject(id);
@@ -115,43 +118,41 @@ public class OrderProcessRecordServiceImpl implements OrderProcessRecordService
             }
 
             // 如果压根没配配置表,就说明全都不要发
-            if (tempSmsList==null || tempSmsList.size()==0 || storeSmsConfigEntities==null || storeSmsConfigEntities.size()==0){
-                recordList = new ArrayList<>();
+            if (tempSmsList == null || tempSmsList.size() == 0 || storeSmsConfigEntities == null || storeSmsConfigEntities.size() == 0) {
+                logger.info("清空recordList,方法结束");
+                return;
             }
 
 
-
-            for (OrderProcessRecordEntity orderProcessRecordEntity : recordList) {
+            for (int i = 0; i < recordList.size(); i++) {
+                OrderProcessRecordEntity orderProcessRecordEntity = recordList.get(i);
                 orderProcessRecordEntity.setCustomsSendSmsStatus("3");// 状态改成发送中
                 orderProcessRecordDao.update(orderProcessRecordEntity);
             }
-            for (OrderProcessRecordEntity orderProcessRecordEntity : recordList) {
+
+            logger.info("发送短信中,发送的有:"+recordList);
+            for (int i = 0; i < recordList.size(); i++) {
+                OrderProcessRecordEntity orderProcessRecordEntity = recordList.get(i);
                 String orderSn = orderProcessRecordEntity.getOrderSn();
                 // 查询
+                try {
+                    PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(orderSn);
+                    String sendTemplate = "【CW惠州门店】惠州港惠店 尊敬的CW会员,您在" + format.format(format.parse(pickUpCodeEntity.getPickUpCodeCreatetime())) + "购买的订单"
+                            + orderSn + ",取货码" + pickUpCodeEntity.getPickUpCodeSn() + ",已清关成功,感谢您的耐心等待。";
+                        SendMsgUtil.sendMsg(orderProcessRecordEntity.getPayMobile(), sendTemplate);
 
-                new Thread(()->{
-                    try {
-
-
-                        PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(orderSn);
-                        String sendTemplate = "【CW惠州门店】惠州港惠店 尊敬的CW会员,您在"+format.format(format.parse(pickUpCodeEntity.getPickUpCodeCreatetime()))+"购买的订单"
-                                + orderSn +",取货码"+pickUpCodeEntity.getPickUpCodeSn()+",已清关成功,感谢您的耐心等待。";
+                    System.out.println("send Suceess");
+                    orderProcessRecordEntity.setCustomsSendSmsStatus("1");//如果发送失败更新表
+                    orderProcessRecordDao.update(orderProcessRecordEntity);
+                }catch (Exception e){
+                    orderProcessRecordEntity.setCustomsSendSmsStatus("2");//如果发送失败更新表
+                    orderProcessRecordDao.update(orderProcessRecordEntity);
+                    e.printStackTrace();
+                }
 
-                        SendMsgUtil.sendMsg(orderProcessRecordEntity.getPayMobile(), sendTemplate);
-//                        System.out.println("=====================================");
-//                        System.out.println(sendTemplate);
-//                        System.out.println("=====================================");
-                        orderProcessRecordEntity.setCustomsSendSmsStatus("1");//如果发送失败更新表
-                        orderProcessRecordDao.update(orderProcessRecordEntity);
-                    }catch (Exception e){
-                        orderProcessRecordEntity.setCustomsSendSmsStatus("2");//如果发送失败更新表
-                        orderProcessRecordDao.update(orderProcessRecordEntity);
-                        e.printStackTrace();
-                    }
-                }).start();
             }
-        }
 
 
+        }
     }
 }