|
@@ -168,168 +168,6 @@ public class MyApplicationLisenter implements ApplicationListener<ContextRefresh
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- public void dangOrderDeal(ShopAccount shopAccount, ShopOrder shopOrder) throws Exception {
|
|
|
- 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) {
|
|
|
- ShopLog shopLog = new ShopLog();
|
|
|
- shopLog.setGmtCreate(new Date());
|
|
|
- shopLog.setTitle("当当订单编号错误");
|
|
|
- shopLog.setContent("店铺:" + shopAccount.getDangName() + ",孔网订单:" + shopOrder.getOrderId() + ",当当订单:" + shopOrder.getDangOrder());
|
|
|
- shopLogMapper.insert(shopLog);
|
|
|
- return;
|
|
|
- }
|
|
|
- } catch (ApiException e) {
|
|
|
- throw e;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 从当当获取订单内应当有的所有图书
|
|
|
- */
|
|
|
- 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) {
|
|
|
- throw e;
|
|
|
- }
|
|
|
- SdkClient jiemi = new SdkClient(shopAccount.getDangAppKey(), shopAccount.getDangAppSecret(), shopAccount.getDangSession(), shopAccount.getDangVersion());
|
|
|
- OrdersContentDecryptRequest ordersContentDecryptRequest = new OrdersContentDecryptRequest();
|
|
|
-
|
|
|
- List<EncryptDTO> encryptVOS = new ArrayList<EncryptDTO>();
|
|
|
-
|
|
|
- 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) {
|
|
|
- throw e;
|
|
|
- }
|
|
|
- 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());
|
|
|
- wrapper.eq("delete_flag", 0);
|
|
|
- List<ShopTran> list = shopTranMapper.selectList(wrapper);
|
|
|
- HashMap<String, Object> stringObjectHashMap = new HashMap<>();
|
|
|
- stringObjectHashMap.put("DANG_DANG_ORDER", shopOrder.getDangOrder());
|
|
|
- if (list.size() == 0) {
|
|
|
-// throw new Exception("物流公司不存在");
|
|
|
- System.out.println("物流公司不存在");
|
|
|
- stringObjectHashMap.put("KUAI_DI_GONG_SI", "99999");
|
|
|
- stringObjectHashMap.put("KUAI_DI_BIANMA", "99999");
|
|
|
- stringObjectHashMap.put("KUAI_DI_GONG_SI_DIAN_HUA", "99999");
|
|
|
- } else {
|
|
|
- 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 (Exception e) {
|
|
|
- throw e;
|
|
|
- }
|
|
|
- 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) {
|
|
|
- throw e;
|
|
|
- }
|
|
|
- System.out.println(result.toString());
|
|
|
- if (result.getResult().getOrdersList().get(0).getOrderOperCode() == 0 || result.getResult().getOrdersList().get(0).getOrderOperCode() == 605) {
|
|
|
- ShopLog shopLog = new ShopLog();
|
|
|
- shopLog.setGmtCreate(new Date());
|
|
|
- shopLog.setTitle("当当订单发货成功");
|
|
|
- shopLog.setContent("店铺:" + shopAccount.getDangName() + ",孔网订单:" + shopOrder.getOrderId() + ",当当订单:" + shopOrder.getDangOrder());
|
|
|
- shopLogMapper.insert(shopLog);
|
|
|
- shopOrder.setDangOrderStatus("已发货");
|
|
|
- shopOrderMapper.update(shopOrder, new EntityWrapper<ShopOrder>().eq("order_id", shopOrder.getOrderId()));
|
|
|
- } else {
|
|
|
- ShopLog shopLog = new ShopLog();
|
|
|
- shopLog.setGmtCreate(new Date());
|
|
|
- shopLog.setTitle("当当订单发货失败");
|
|
|
- shopLog.setContent("店铺:" + shopAccount.getDangName() + ",孔网订单:" + shopOrder.getOrderId() + ",当当订单:" + shopOrder.getDangOrder() + ",快递:" + shopOrder.getShippingComName());
|
|
|
- shopLogMapper.insert(shopLog);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- ShopLog shopLog = new ShopLog();
|
|
|
- shopLog.setGmtCreate(new Date());
|
|
|
- shopLog.setTitle("当当发货异常");
|
|
|
- shopLog.setContent(e.getMessage());
|
|
|
- shopLogMapper.insert(shopLog);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
public void flushCookie(ShopAccount shopAccount) {
|
|
|
try {
|
|
|
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|