|
@@ -166,87 +166,83 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String test(String param) throws Exception {
|
|
|
-
|
|
|
- List<ShopAccount> listAccount = shopAccountMapper.selectList(new EntityWrapper<ShopAccount>().eq("delete_flag",0));
|
|
|
- for (ShopAccount shopAccount:listAccount
|
|
|
- ) {
|
|
|
- flushCookie(shopAccount);
|
|
|
- CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
- HttpGet get = new HttpGet("https://shop.kongfz.com/buyer/order/index/?pageCurr=1&pageShow=9999&orderStatus=ShippedToReceipt");
|
|
|
- //这里可以设置请求参数,token等
|
|
|
- get.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36");
|
|
|
- get.addHeader("cookie",shopAccount.getFuziCookie());
|
|
|
-
|
|
|
- CloseableHttpResponse response = httpClient.execute(get);//执行获取响应
|
|
|
- try{
|
|
|
+ public String test(String param,String param1) throws Exception {
|
|
|
+ ShopAccount shopAccount = shopAccountMapper.selectById(param);
|
|
|
+ flushCookie(shopAccount);
|
|
|
+ CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
+ HttpGet get = new HttpGet("https://shop.kongfz.com/buyer/order/index/?pageCurr=1&pageShow=9999&orderId="+param1+"&orderStatus=ShippedToReceipt");
|
|
|
+ //这里可以设置请求参数,token等
|
|
|
+ get.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36");
|
|
|
+ get.addHeader("cookie",shopAccount.getFuziCookie());
|
|
|
+ get.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
|
+ CloseableHttpResponse response = httpClient.execute(get);//执行获取响应
|
|
|
+ try{
|
|
|
|
|
|
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){//根据状态码处理
|
|
|
- String strTmp= EntityUtils.toString(response.getEntity(),"UTF-8");
|
|
|
- //返回字符串
|
|
|
- String res = unicodeToString(strTmp);
|
|
|
- JSONObject datas = JSONObject.parseObject(res);//转换成JSON格式
|
|
|
- Boolean status = (Boolean) datas.get("status");//获取返回数据状态,get获取的字段需要根据提供的返回值去获取
|
|
|
- List<ShopOrder> data = JSONArray.parseArray(datas.get("data").toString(),ShopOrder.class);//"data"是根据返回值设定
|
|
|
- for (ShopOrder tmp: data
|
|
|
+ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){//根据状态码处理
|
|
|
+ String strTmp= EntityUtils.toString(response.getEntity(),"UTF-8");
|
|
|
+ //返回字符串
|
|
|
+ String res = unicodeToString(strTmp);
|
|
|
+ JSONObject datas = JSONObject.parseObject(res);//转换成JSON格式
|
|
|
+ Boolean status = (Boolean) datas.get("status");//获取返回数据状态,get获取的字段需要根据提供的返回值去获取
|
|
|
+ List<ShopOrder> data = JSONArray.parseArray(datas.get("data").toString(),ShopOrder.class);//"data"是根据返回值设定
|
|
|
+ for (ShopOrder tmp: data
|
|
|
+ ) {
|
|
|
+ //正则表达式,用于匹配非数字串,+号用于匹配出多个非数字串
|
|
|
+ String regEx="[^0-9]+";
|
|
|
+ Pattern pattern = Pattern.compile(regEx);
|
|
|
+ //用定义好的正则表达式拆分字符串,把字符串中的数字留出来
|
|
|
+ String[] cs = pattern.split(tmp.getRemarkText());
|
|
|
+ String dangOrder = "";
|
|
|
+ for (String str:cs
|
|
|
) {
|
|
|
- //正则表达式,用于匹配非数字串,+号用于匹配出多个非数字串
|
|
|
- String regEx="[^0-9]+";
|
|
|
- Pattern pattern = Pattern.compile(regEx);
|
|
|
- //用定义好的正则表达式拆分字符串,把字符串中的数字留出来
|
|
|
- String[] cs = pattern.split(tmp.getRemarkText());
|
|
|
- String dangOrder = "";
|
|
|
- for (String str:cs
|
|
|
- ) {
|
|
|
- if(dangOrder.length()>= 11){
|
|
|
- break;
|
|
|
- }
|
|
|
- dangOrder += str;
|
|
|
+ if(dangOrder.length()>= 11){
|
|
|
+ break;
|
|
|
}
|
|
|
- tmp.setDangOrder(dangOrder);
|
|
|
- tmp.setAccountId(shopAccount.getId());
|
|
|
- Long time = Long.parseLong(tmp.getShippingTime());
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
|
- String time1 = sdf.format(new Date(time * 1000));
|
|
|
- tmp.setShippingTime(time1);
|
|
|
- tmp.setDeleteFlag(0);
|
|
|
- tmp.setGmtUpdate(new Date());
|
|
|
- tmp.setGmtCreate(new Date());
|
|
|
- ShopOrder tt = new ShopOrder();
|
|
|
- tt.setOrderId(tmp.getOrderId());
|
|
|
- tt = shopOrderMapper.selectOne(tt);
|
|
|
- if(tt == null){
|
|
|
- shopOrderMapper.insert(tmp);
|
|
|
- }
|
|
|
- else{
|
|
|
- if(tt.getDangOrderStatus().equals("未发货")){
|
|
|
- shopOrderMapper.update(tmp,new EntityWrapper<ShopOrder>().eq("order_id",tt.getOrderId()));
|
|
|
- }
|
|
|
+ dangOrder += str;
|
|
|
+ }
|
|
|
+ tmp.setDangOrder(dangOrder);
|
|
|
+ tmp.setAccountId(shopAccount.getId());
|
|
|
+ Long time = Long.parseLong(tmp.getShippingTime());
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
|
+ String time1 = sdf.format(new Date(time * 1000));
|
|
|
+ tmp.setShippingTime(time1);
|
|
|
+ tmp.setDeleteFlag(0);
|
|
|
+ tmp.setGmtUpdate(new Date());
|
|
|
+ tmp.setGmtCreate(new Date());
|
|
|
+ ShopOrder tt = new ShopOrder();
|
|
|
+ tt.setOrderId(tmp.getOrderId());
|
|
|
+ tt = shopOrderMapper.selectOne(tt);
|
|
|
+ if(tt == null){
|
|
|
+ shopOrderMapper.insert(tmp);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if(tt.getDangOrderStatus().equals("未发货")){
|
|
|
+ shopOrderMapper.update(tmp,new EntityWrapper<ShopOrder>().eq("order_id",tt.getOrderId()));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- finally {
|
|
|
- response.close();
|
|
|
- httpClient.close();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- Wrapper wrapper1 = new EntityWrapper();
|
|
|
- wrapper1.eq("order_status_name","卖家已发货");
|
|
|
- wrapper1.eq("dang_order_status","未发货");
|
|
|
- wrapper1.orderBy("gmt_update",false);
|
|
|
- List<ShopOrder> list1 = shopOrderMapper.selectList(wrapper1);
|
|
|
- for (ShopOrder shopOrder: list1
|
|
|
- ) {
|
|
|
- ShopAccount shopAccount = shopAccountMapper.selectById(shopOrder.getAccountId());
|
|
|
- dangOrderDeal(shopAccount,shopOrder);
|
|
|
+ finally {
|
|
|
+ response.close();
|
|
|
+ httpClient.close();
|
|
|
}
|
|
|
+// Wrapper wrapper1 = new EntityWrapper();
|
|
|
+// wrapper1.eq("order_status_name","卖家已发货");
|
|
|
+// wrapper1.eq("dang_order_status","未发货");
|
|
|
+// wrapper1.orderBy("gmt_update",false);
|
|
|
+// List<ShopOrder> list1 = shopOrderMapper.selectList(wrapper1);
|
|
|
+// for (ShopOrder shopOrder: list1
|
|
|
+// ) {
|
|
|
+// ShopAccount shopAccount = shopAccountMapper.selectById(shopOrder.getAccountId());
|
|
|
+// dangOrderDeal(shopAccount,shopOrder);
|
|
|
+// }
|
|
|
return "";
|
|
|
|
|
|
}
|
|
@@ -267,6 +263,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
try {
|
|
|
resultt = sdkClient.excute(ss);
|
|
|
if(resultt.getOrderID() == null){
|
|
|
+ System.out.println("当当订单信息不存在:"+shopOrder.getDangOrder());
|
|
|
return;
|
|
|
}
|
|
|
} catch (ApiException e) {
|
|
@@ -337,7 +334,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
wrapper.like("fuzi_name",shopOrder.getShippingComName());
|
|
|
List<ShopTran> list = shopTranMapper.selectList(wrapper);
|
|
|
if(list.size() == 0 ){
|
|
|
- throw new Exception("物流公司不存在");
|
|
|
+ System.out.println("物流公司不存在:"+shopOrder.getShippingComName());
|
|
|
+ return;
|
|
|
}
|
|
|
HashMap<String, Object> stringObjectHashMap = new HashMap<>();
|
|
|
stringObjectHashMap.put("DANG_DANG_ORDER", shopOrder.getDangOrder());
|