KuaidiCallBackService.java
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.huaheng.api.WAYBILLNO.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.pc.config.KDCertification.service.KDCertificationService;
import com.huaheng.pc.shipment.kuaidiHeader.domain.KuaidiHeader;
import com.huaheng.pc.shipment.kuaidiHeader.service.KuaidiHeaderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
@Service
public class KuaidiCallBackService {
private final static Logger logger = LoggerFactory.getLogger(KuaidiCallBackService.class);
@Resource
private KDCertificationService kdCertificationService;
@Autowired
private KuaidiHeaderService kuaidiHeaderService;
public void kuaidiCallback(JSONObject body, String warehouseCode) {
String json = JSON.toJSONString(body);
logger.info("获取快递单号:{}", json);
System.out.println(body);
String type = body.getString("type");
if (StringUtils.isNotEmpty(type)) {
if (type.equals("SEND")) {
JSONObject data = body.getJSONObject("data");
String number = data.getString("orderNum");
System.out.println(number);
}
if (type.equals("UPDATE")) {
JSONObject data = body.getJSONObject("data");
String number = data.getString("orderNum");
System.out.println(number);
}
if (type.equals("FILLEXPNUM")) {
JSONObject data = body.getJSONArray("data").getJSONObject(0);
String number = data.getString("orderNum");
System.out.println(number);
String dingdan = data.getString("kuaidinum");
LambdaQueryWrapper<KuaidiHeader> queryWrapper = Wrappers.lambdaQueryNoWarehouse();
queryWrapper.eq(KuaidiHeader::getKuaidiNum, number);
queryWrapper.last("limit 1");
KuaidiHeader kuaidiHeader = kuaidiHeaderService.getOne(queryWrapper);
if (kuaidiHeader != null) {
if (StringUtils.isNotEmpty(kuaidiHeader.getTrackCode())) {
kuaidiHeader.setTrackCode(dingdan + "," + kuaidiHeader.getTrackCode());
} else {
kuaidiHeader.setTrackCode(dingdan);
}
kuaidiHeader.setDeleted(true);
kuaidiHeader.setLastUpdated(new Date());
kuaidiHeaderService.updateById(kuaidiHeader);
}
System.out.println(dingdan);
}
} else {
}
}
}