|
@@ -172,88 +172,89 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
@Override
|
|
@Override
|
|
public String test(String param,String param1) throws Exception {
|
|
public String test(String param,String param1) throws Exception {
|
|
try{
|
|
try{
|
|
- List<ShopOrder> shopOrders = shopOrderMapper.selectList(new EntityWrapper<ShopOrder>()
|
|
|
|
- .eq("dang_order_status","未发货").ne("shipping_com","京东快递")
|
|
|
|
- .ne("shipping_com","丰网速运")
|
|
|
|
- .eq("order_status_name","卖家已发货"));
|
|
|
|
- for (ShopOrder qqq:shopOrders
|
|
|
|
|
|
+ List<ShopAccount> listAccount = shopAccountMapper.selectList(new EntityWrapper<ShopAccount>().eq("delete_flag",0));
|
|
|
|
+ for (ShopAccount shopAccount:listAccount
|
|
) {
|
|
) {
|
|
- ShopAccount shopAccount = shopAccountMapper.selectById(qqq.getAccountId());
|
|
|
|
flushCookie(shopAccount);
|
|
flushCookie(shopAccount);
|
|
- CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
|
- HttpGet get = new HttpGet("https://shop.kongfz.com/buyer/order/index/?pageCurr=1&pageShow=9999&orderId="+qqq.getOrderId());
|
|
|
|
- //这里可以设置请求参数,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
|
|
|
|
- ) {
|
|
|
|
- //正则表达式,用于匹配非数字串,+号用于匹配出多个非数字串
|
|
|
|
- String regEx="[^0-9]+";
|
|
|
|
- Pattern pattern = Pattern.compile(regEx);
|
|
|
|
- //用定义好的正则表达式拆分字符串,把字符串中的数字留出来
|
|
|
|
- String[] cs = pattern.split(tmp.getRemarkText());
|
|
|
|
- String dangOrder = "";
|
|
|
|
- for (String str:cs
|
|
|
|
|
|
+ for(int i=1;i<=5;i++){
|
|
|
|
+ CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
|
+ HttpGet get = new HttpGet("https://shop.kongfz.com/buyer/order/index/?pageCurr="+i+"&pageShow=300&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{
|
|
|
|
+
|
|
|
|
+ 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"是根据返回值设定
|
|
|
|
+ if(data.size() == 0){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ for (ShopOrder tmp: data
|
|
) {
|
|
) {
|
|
- if(dangOrder.length()>= 11 || str.equals("*")){
|
|
|
|
- break;
|
|
|
|
|
|
+ //正则表达式,用于匹配非数字串,+号用于匹配出多个非数字串
|
|
|
|
+ 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 || str.equals("*")){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ dangOrder += str;
|
|
}
|
|
}
|
|
- 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());
|
|
|
|
- if(tmp.getShippingComName().equals("快递包裹")||tmp.getShippingComName().equals("挂号印刷品")){
|
|
|
|
- tmp.setShippingComName("中国邮政");
|
|
|
|
- }
|
|
|
|
- ShopOrder tt = new ShopOrder();
|
|
|
|
- tt.setOrderId(tmp.getOrderId());
|
|
|
|
- tt = shopOrderMapper.selectOne(tt);
|
|
|
|
- if(tt == null){
|
|
|
|
- shopOrderMapper.insert(tmp);
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- if(!tt.getDangOrder().equals(tmp.getDangOrder())||!tt.getShippingComName().equals(tmp.getShippingComName())){
|
|
|
|
- shopOrderMapper.update(tmp,new EntityWrapper<ShopOrder>().eq("order_id",tt.getOrderId()));
|
|
|
|
|
|
+ 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());
|
|
|
|
+ if(tmp.getShippingComName().equals("快递包裹")||tmp.getShippingComName().equals("挂号印刷品")){
|
|
|
|
+ tmp.setShippingComName("中国邮政");
|
|
|
|
+ }
|
|
|
|
+ ShopOrder tt = new ShopOrder();
|
|
|
|
+ tt.setOrderId(tmp.getOrderId());
|
|
|
|
+ tt = shopOrderMapper.selectOne(tt);
|
|
|
|
+ if(tt == null){
|
|
|
|
+ shopOrderMapper.insert(tmp);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ if(tt.getDangOrderStatus().equals("未发货")&&!tt.getDangOrder().equals(tmp.getDangOrder())){
|
|
|
|
+ shopOrderMapper.update(tmp,new EntityWrapper<ShopOrder>().eq("order_id",tt.getOrderId()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- dangOrderDeal(shopAccount,qqq);
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- throw e;
|
|
|
|
- }
|
|
|
|
- finally {
|
|
|
|
- response.close();
|
|
|
|
- httpClient.close();
|
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ finally {
|
|
|
|
+ response.close();
|
|
|
|
+ httpClient.close();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- catch (Exception e) {
|
|
|
|
|
|
+ catch (Exception e){
|
|
ShopLog shopLog = new ShopLog();
|
|
ShopLog shopLog = new ShopLog();
|
|
shopLog.setGmtCreate(new Date());
|
|
shopLog.setGmtCreate(new Date());
|
|
- shopLog.setTitle("同步定时任务异常");
|
|
|
|
|
|
+ shopLog.setTitle("爬取定时任务异常");
|
|
shopLog.setContent(e.getMessage());
|
|
shopLog.setContent(e.getMessage());
|
|
shopLogMapper.insert(shopLog);
|
|
shopLogMapper.insert(shopLog);
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -431,9 +432,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
try{
|
|
try{
|
|
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {//根据状态码处理
|
|
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {//根据状态码处理
|
|
String strTmp= EntityUtils.toString(response.getEntity(),"UTF-8");
|
|
String strTmp= EntityUtils.toString(response.getEntity(),"UTF-8");
|
|
- //返回字符串
|
|
|
|
- String res = unicodeToString(strTmp);
|
|
|
|
- JSONObject datas = JSONObject.parseObject(res);//转换成JSON格式
|
|
|
|
|
|
+ JSONObject datas = JSONObject.parseObject(strTmp);//转换成JSON格式
|
|
Boolean status = (Boolean) datas.get("status");//获取返回数据状态,get获取的字段需要根据提供的返回值去获取
|
|
Boolean status = (Boolean) datas.get("status");//获取返回数据状态,get获取的字段需要根据提供的返回值去获取
|
|
if(status){
|
|
if(status){
|
|
return;
|
|
return;
|