ccjgmwz 3 năm trước cách đây
mục cha
commit
f8828d683c

+ 127 - 118
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/AdminCheckQuartz.java

@@ -322,134 +322,143 @@ public class AdminCheckQuartz {
         return str;
     }
     public void dangOrderDeal(ShopAccount shopAccount, ShopOrder shopOrder) throws Exception {
-        /**
-         * 获取一下店铺的所有静态参数
-         */
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
-        SdkClient sdkClient = new SdkClient(shopAccount.getDangAppKey(),shopAccount.getDangAppSecret(),shopAccount.getDangSession(),shopAccount.getDangVersion());
-
-        OrderDetailsGetRequest ss = new OrderDetailsGetRequest();
-        OrderDetailsGet orderDetailsGet = new OrderDetailsGet();
-        orderDetailsGet.setO(shopOrder.getDangOrder());
-        ss.setOrderDetailsGet(orderDetailsGet);
-        OrderDetailsGetResponse resultt = null;
-        try {
-            resultt = sdkClient.excute(ss);
-        } catch (ApiException e) {
-            e.printStackTrace();
+        try{
+            /**
+             * 获取一下店铺的所有静态参数
+             */
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+            SdkClient sdkClient = new SdkClient(shopAccount.getDangAppKey(),shopAccount.getDangAppSecret(),shopAccount.getDangSession(),shopAccount.getDangVersion());
+
+            OrderDetailsGetRequest ss = new OrderDetailsGetRequest();
+            OrderDetailsGet orderDetailsGet = new OrderDetailsGet();
+            orderDetailsGet.setO(shopOrder.getDangOrder());
+            ss.setOrderDetailsGet(orderDetailsGet);
+            OrderDetailsGetResponse resultt = null;
+            try {
+                resultt = sdkClient.excute(ss);
+                if(resultt.getOrderID() == null){
+                    return;
+                }
+            } catch (ApiException e) {
+                e.printStackTrace();
 
-        }
+            }
 
-        /**
-         * 从当当获取订单内应当有的所有图书
-         */
-        OrderDetailsGetRequest odgr = new OrderDetailsGetRequest();
-        OrderDetailsGet ogg = new OrderDetailsGet();
-        ogg.setO(shopOrder.getDangOrder());
-        odgr.setOrderDetailsGet(ogg);
-        OrderDetailsGetResponse odgrp = null;
-        try {
-            odgrp = sdkClient.excute(odgr);
-        } catch (ApiException e) {
-            e.printStackTrace();
-        }
-        SdkClient jiemi = new SdkClient(shopAccount.getDangAppKey(),shopAccount.getDangAppSecret(),shopAccount.getDangSession(),shopAccount.getDangVersion());
-        OrdersContentDecryptRequest ordersContentDecryptRequest=new OrdersContentDecryptRequest();
+            /**
+             * 从当当获取订单内应当有的所有图书
+             */
+            OrderDetailsGetRequest odgr = new OrderDetailsGetRequest();
+            OrderDetailsGet ogg = new OrderDetailsGet();
+            ogg.setO(shopOrder.getDangOrder());
+            odgr.setOrderDetailsGet(ogg);
+            OrderDetailsGetResponse odgrp = null;
+            try {
+                odgrp = sdkClient.excute(odgr);
+            } catch (ApiException e) {
+                e.printStackTrace();
+            }
+            SdkClient jiemi = new SdkClient(shopAccount.getDangAppKey(),shopAccount.getDangAppSecret(),shopAccount.getDangSession(),shopAccount.getDangVersion());
+            OrdersContentDecryptRequest ordersContentDecryptRequest=new OrdersContentDecryptRequest();
 
-        List<EncryptDTO> encryptVOS = new ArrayList<EncryptDTO>();
+            List<EncryptDTO> encryptVOS = new ArrayList<EncryptDTO>();
 
-        EncryptDTO encryptVO1 = new EncryptDTO();
-        encryptVO1.setO(resultt.getOrderID().toString());
-        encryptVO1.setEncrypt_content(resultt.getEncrypt_content());
-        encryptVOS.add(encryptVO1);
+            EncryptDTO encryptVO1 = new EncryptDTO();
+            encryptVO1.setO(resultt.getOrderID().toString());
+            encryptVO1.setEncrypt_content(resultt.getEncrypt_content());
+            encryptVOS.add(encryptVO1);
 
-        ordersContentDecryptRequest.setO_cryptStr(JSON.toJSONString(encryptVOS));
-        OrdersContentDecryptResponse ordersContentDecryptResponse = null;
-        try {
-            ordersContentDecryptResponse=jiemi.excute(ordersContentDecryptRequest);
-        } catch (ApiException e) {
-            e.printStackTrace();
-        }
-        List<OrdersContentDecryptDTO> data = ordersContentDecryptResponse.getData();
-        CryptUserInfo cryptUserInfo = data.get(0).getCryptUserInfo();
-
-
-
-        OrderDetail o = (OrderDetail) XMLUtil.convertXmlStrToObject(OrderDetail.class, odgrp.getBody());
-        SendGoodsInfo sgi = new SendGoodsInfo();
-        sgi.setConsigneeAddr(cryptUserInfo.getConsigneeAddr());
-        sgi.setConsigneeMobileTel(cryptUserInfo.getConsigneeMobileTel());
-        sgi.setConsigneeTel(cryptUserInfo.getConsigneeTel());
-        sgi.setConsigneeName(cryptUserInfo.getConsigneeName());
-        o.setSendGoodsInfo(sgi);
-        List<com.iotechn.unimall.data.dto.shop.XmlObject.ItemInfo> itemInfo = o.getItemsList().getItemInfo();
-        /**
-         * 将多个图书拼接XML
-         */
-        String itemsStr = "";
-        for (com.iotechn.unimall.data.dto.shop.XmlObject.ItemInfo ii : itemInfo) {
-            Map<String, Object> hashMap = new HashMap<>();
-            hashMap.put("DANG_DANG_ITEM_ID", ii.getItemID());
-            hashMap.put("SHU_LIANG", ii.getOrderCount());
-            hashMap.put("PRODUCT_ID", ii.getProductItemId());
-            itemsStr += SendGood.processTemplate(SendGood.ONE_ITEM, hashMap);
-        }
+            ordersContentDecryptRequest.setO_cryptStr(JSON.toJSONString(encryptVOS));
+            OrdersContentDecryptResponse ordersContentDecryptResponse = null;
+            try {
+                ordersContentDecryptResponse=jiemi.excute(ordersContentDecryptRequest);
+            } catch (ApiException e) {
+                e.printStackTrace();
+            }
+            List<OrdersContentDecryptDTO> data = ordersContentDecryptResponse.getData();
+            CryptUserInfo cryptUserInfo = data.get(0).getCryptUserInfo();
+
+
+
+            OrderDetail o = (OrderDetail) XMLUtil.convertXmlStrToObject(OrderDetail.class, odgrp.getBody());
+            SendGoodsInfo sgi = new SendGoodsInfo();
+            sgi.setConsigneeAddr(cryptUserInfo.getConsigneeAddr());
+            sgi.setConsigneeMobileTel(cryptUserInfo.getConsigneeMobileTel());
+            sgi.setConsigneeTel(cryptUserInfo.getConsigneeTel());
+            sgi.setConsigneeName(cryptUserInfo.getConsigneeName());
+            o.setSendGoodsInfo(sgi);
+            List<com.iotechn.unimall.data.dto.shop.XmlObject.ItemInfo> itemInfo = o.getItemsList().getItemInfo();
+            /**
+             * 将多个图书拼接XML
+             */
+            String itemsStr = "";
+            for (com.iotechn.unimall.data.dto.shop.XmlObject.ItemInfo ii : itemInfo) {
+                Map<String, Object> hashMap = new HashMap<>();
+                hashMap.put("DANG_DANG_ITEM_ID", ii.getItemID());
+                hashMap.put("SHU_LIANG", ii.getOrderCount());
+                hashMap.put("PRODUCT_ID", ii.getProductItemId());
+                itemsStr += SendGood.processTemplate(SendGood.ONE_ITEM, hashMap);
+            }
 
 
-        /**
-         * 组成OrderInfo
-         */
-        Wrapper wrapper = new EntityWrapper();
-        wrapper.like("fuzi_name",shopOrder.getShippingComName());
-        List<ShopTran> list = shopTranMapper.selectList(wrapper);
-        if(list.size() == 0 ){
-            throw new Exception("物流公司不存在");
-        }
-        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
-        stringObjectHashMap.put("DANG_DANG_ORDER", shopOrder.getDangOrder());
-        stringObjectHashMap.put("KUAI_DI_GONG_SI", list.get(0).getName());
-        stringObjectHashMap.put("KUAI_DI_BIANMA", list.get(0).getCode1());
-        stringObjectHashMap.put("KUAI_DI_GONG_SI_DIAN_HUA", list.get(0).getPhone());
-        stringObjectHashMap.put("KUAI_DI_DAN_HAO", shopOrder.getShipmentNum());
-        stringObjectHashMap.put("SEND_ITEMS", itemsStr);
-
-        String orderListStr = SendGood.processTemplate(SendGood.ONE_ORDER, stringObjectHashMap);
-        HashMap<String, Object> tmplHash = new HashMap<>();
-        tmplHash.put("SEND_TIME", dateFormat.format(new Date()));
-        tmplHash.put("ORDER_LIST", orderListStr);
-
-        String xmlFileStr = SendGood.processTemplate(SendGood.TMPL, tmplHash);
-        System.out.println(xmlFileStr);
-        PrintWriter out = null;
-        try {
-            out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream("sendGoodNotPlat.xml"), "GBK")));
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
+            /**
+             * 组成OrderInfo
+             */
+            Wrapper wrapper = new EntityWrapper();
+            wrapper.like("fuzi_name",shopOrder.getShippingComName());
+            List<ShopTran> list = shopTranMapper.selectList(wrapper);
+            if(list.size() == 0 ){
+                throw new Exception("物流公司不存在");
+            }
+            HashMap<String, Object> stringObjectHashMap = new HashMap<>();
+            stringObjectHashMap.put("DANG_DANG_ORDER", shopOrder.getDangOrder());
+            stringObjectHashMap.put("KUAI_DI_GONG_SI", list.get(0).getName());
+            stringObjectHashMap.put("KUAI_DI_BIANMA", list.get(0).getCode1());
+            stringObjectHashMap.put("KUAI_DI_GONG_SI_DIAN_HUA", list.get(0).getPhone());
+            stringObjectHashMap.put("KUAI_DI_DAN_HAO", shopOrder.getShipmentNum());
+            stringObjectHashMap.put("SEND_ITEMS", itemsStr);
+
+            String orderListStr = SendGood.processTemplate(SendGood.ONE_ORDER, stringObjectHashMap);
+            HashMap<String, Object> tmplHash = new HashMap<>();
+            tmplHash.put("SEND_TIME", dateFormat.format(new Date()));
+            tmplHash.put("ORDER_LIST", orderListStr);
+
+            String xmlFileStr = SendGood.processTemplate(SendGood.TMPL, tmplHash);
+            System.out.println(xmlFileStr);
+            PrintWriter out = null;
+            try {
+                out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream("sendGoodNotPlat.xml"), "GBK")));
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+            out.write(xmlFileStr);
+            out.close();
+            System.out.println("XML文件创建成功!");
+
+
+            /**
+             * 发货!!
+             */
+            OrderGoodsSendRequest sendGoodsRequest = new OrderGoodsSendRequest();
+            sendGoodsRequest.setSendGoodsFile(new FileItem(new File("sendGoodNotPlat.xml")));
+            OrderGoodsSendResponse result = null;
+            try {
+                result = sdkClient.excute(sendGoodsRequest);
+            } catch (ApiException e) {
+                e.printStackTrace();
+            }
+            System.out.println(result.toString());
+            if(result.getResult().getOrdersList().get(0).getOrderOperCode() == 0 || result.getResult().getOrdersList().get(0).getOrderOperCode() == 605){
+                shopOrder.setDangOrderStatus("已发货");
+                shopOrderMapper.update(shopOrder,new EntityWrapper<ShopOrder>().eq("order_id",shopOrder.getOrderId()));
+            }
         }
-        out.write(xmlFileStr);
-        out.close();
-        System.out.println("XML文件创建成功!");
-
-
-        /**
-         * 发货!!
-         */
-        OrderGoodsSendRequest sendGoodsRequest = new OrderGoodsSendRequest();
-        sendGoodsRequest.setSendGoodsFile(new FileItem(new File("sendGoodNotPlat.xml")));
-        OrderGoodsSendResponse result = null;
-        try {
-            result = sdkClient.excute(sendGoodsRequest);
-        } catch (ApiException e) {
+        catch (Exception e){
             e.printStackTrace();
         }
-        System.out.println(result.toString());
-        if(result.getResult().getOrdersList().get(0).getOrderOperCode() == 0){
-            shopOrder.setDangOrderStatus("已发货");
-            shopOrderMapper.update(shopOrder,new EntityWrapper<ShopOrder>().eq("order_id",shopOrder.getOrderId()));
-        }
+
     }