|
@@ -172,89 +172,20 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
@Override
|
|
|
public String test(String param,String param1) throws Exception {
|
|
|
try{
|
|
|
- List<ShopAccount> listAccount = shopAccountMapper.selectList(new EntityWrapper<ShopAccount>().eq("delete_flag",0));
|
|
|
- for (ShopAccount shopAccount:listAccount
|
|
|
+ List<ShopOrder> shopOrders = shopOrderMapper.selectList(new EntityWrapper<ShopOrder>()
|
|
|
+ .eq("dang_order_status","未发货")
|
|
|
+ .eq("shipping_com",param)
|
|
|
+ .eq("order_status_name","卖家已发货"));
|
|
|
+ for (ShopOrder qqq:shopOrders
|
|
|
) {
|
|
|
- flushCookie(shopAccount);
|
|
|
- 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
|
|
|
- ) {
|
|
|
- //正则表达式,用于匹配非数字串,+号用于匹配出多个非数字串
|
|
|
- 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;
|
|
|
- }
|
|
|
- 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()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- throw e;
|
|
|
- }
|
|
|
- finally {
|
|
|
- response.close();
|
|
|
- httpClient.close();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ ShopAccount shopAccount = shopAccountMapper.selectById(qqq.getAccountId());
|
|
|
+ dangOrderDeal(shopAccount,qqq);
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception e){
|
|
|
+ catch (Exception e) {
|
|
|
ShopLog shopLog = new ShopLog();
|
|
|
shopLog.setGmtCreate(new Date());
|
|
|
- shopLog.setTitle("爬取定时任务异常");
|
|
|
+ shopLog.setTitle("同步定时任务异常");
|
|
|
shopLog.setContent(e.getMessage());
|
|
|
shopLogMapper.insert(shopLog);
|
|
|
e.printStackTrace();
|
|
@@ -351,15 +282,22 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
*/
|
|
|
Wrapper wrapper = new EntityWrapper();
|
|
|
wrapper.like("fuzi_name",shopOrder.getShippingComName());
|
|
|
+ wrapper.eq("delete_flag",0);
|
|
|
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());
|
|
|
+ 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);
|
|
|
|