Jelajahi Sumber

Merge branch 'master' of http://git.ds-bay.com/project/kmall-pt-general

yangbo 4 tahun lalu
induk
melakukan
9feda3840d

+ 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));
         }
     }
 }

+ 8 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/StoreSmsConfigController.java

@@ -67,6 +67,10 @@ public class StoreSmsConfigController {
         if (entity!=null){
             return R.error("该门店已有配置,请在原基础上修改");
         }
+        if ("2".equals(storeSmsConfig.getIsEnable())){
+            storeSmsConfig.setSendEndTime(null);
+            storeSmsConfig.setSendStartTime(null);
+        }
         storeSmsConfig.setCreaterSn(ShiroUtils.getUserId().toString());
         storeSmsConfig.setCreateTime(new Date());
         storeSmsConfig.setModerSn(ShiroUtils.getUserId().toString());
@@ -84,6 +88,10 @@ public class StoreSmsConfigController {
     public R update(@RequestBody StoreSmsConfigEntity storeSmsConfig) {
         storeSmsConfig.setModerSn(ShiroUtils.getUserId().toString());
         storeSmsConfig.setModTime(new Date());
+        if ("2".equals(storeSmsConfig.getIsEnable())){
+            storeSmsConfig.setSendEndTime(null);
+            storeSmsConfig.setSendStartTime(null);
+        }
         storeSmsConfigService.update(storeSmsConfig);
 
         return R.ok();

+ 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();
             }
-        }
 
 
+        }
     }
 }

+ 2 - 2
kmall-admin/src/main/resources/mybatis/mapper/StoreSmsConfigDao.xml

@@ -143,8 +143,8 @@
 		<set>
 			<if test="storeId != null">`store_id` = #{storeId}, </if>
 			<if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
-			<if test="sendStartTime != null">`send_start_time` = #{sendStartTime}, </if>
-			<if test="sendEndTime != null">`send_end_time` = #{sendEndTime}, </if>
+			`send_start_time` = #{sendStartTime},
+			`send_end_time` = #{sendEndTime},
 			<if test="isValid != null">`is_valid` = #{isValid}, </if>
 			<if test="isEnable != null">`is_enable` = #{isEnable}, </if>
 			<if test="createrSn != null">`creater_sn` = #{createrSn}, </if>

+ 2 - 2
kmall-admin/src/main/webapp/WEB-INF/page/shop/storesmsconfig.html

@@ -64,10 +64,10 @@
             </Form-item>
 
             <Form-item label="发送开始时间" prop="sendStartTime">
-                <i-input  type='date' :disabled='storeSmsConfig.isEnable==2' v-model="storeSmsConfig.sendStartTime" placeholder="发送开始时间" style="width:160px;"/>
+                <i-input  type='date' :disabled='storeSmsConfig.isEnable==2 || storeSmsConfig.isEnable==1' v-model="storeSmsConfig.sendStartTime" placeholder="发送开始时间" style="width:160px;"/>
             </Form-item>
             <Form-item label="发送结束时间" prop="sendEndTime">
-                <i-input  type='date' :disabled='storeSmsConfig.isEnable==2' v-model="storeSmsConfig.sendEndTime" placeholder="发送结束时间" style="width:160px;"/>
+                <i-input  type='date' :disabled='storeSmsConfig.isEnable==2 || storeSmsConfig.isEnable==1' v-model="storeSmsConfig.sendEndTime" placeholder="发送结束时间" style="width:160px;"/>
             </Form-item>
 <!--            <Form-item label="是否启用" prop="isValid">-->
 <!--                <i-input v-model="storeSmsConfig.isValid" placeholder="是否启用"/>-->