update 快递100查询订单信息-添加查询参数-手机号
This commit is contained in:
+26
-13
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.gson.Gson;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.PasswordUtil;
|
||||
import com.jero.mail.entity.PayMailBill;
|
||||
import com.jero.mail.entity.PayMailContracrList;
|
||||
import com.jero.mail.param.QueryInfoParam;
|
||||
@@ -21,6 +22,7 @@ import com.kuaidi100.sdk.request.QueryTrackReq;
|
||||
import com.kuaidi100.sdk.utils.PropertiesReader;
|
||||
import com.kuaidi100.sdk.utils.SignUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -49,26 +51,20 @@ public class PostInfoServiceImpl implements IPostInfoService {
|
||||
@Override
|
||||
public Result<QueryInfoParam> queryInfo(PostInfoQuery postInfoQuery) {
|
||||
// 1.判断是否是邮寄管理中的数据
|
||||
checkIsMySystem(postInfoQuery);
|
||||
String phone = checkIsMySystem(postInfoQuery);
|
||||
// 2.调用api
|
||||
HttpResult httpResult = sendReq(postInfoQuery);
|
||||
// 2.1.对body做处理
|
||||
QueryInfoParam infoParam = new Gson().fromJson(httpResult.getBody(), QueryInfoParam.class);
|
||||
// 3.返回
|
||||
Result<QueryInfoParam> result = new Result();
|
||||
result.setCode(httpResult.getStatus());
|
||||
result.setResult(infoParam);
|
||||
result.setMessage(infoParam.getMessage());
|
||||
Result<QueryInfoParam> result = sendReq(postInfoQuery, phone);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private HttpResult sendReq(PostInfoQuery postInfoQuery) {
|
||||
private Result<QueryInfoParam> sendReq(PostInfoQuery postInfoQuery, String phone) {
|
||||
QueryTrackReq queryTrackReq = new QueryTrackReq();
|
||||
QueryTrackParam queryTrackParam = new QueryTrackParam();
|
||||
setCom(postInfoQuery);
|
||||
queryTrackParam.setCom(postInfoQuery.getCom());
|
||||
queryTrackParam.setNum(postInfoQuery.getNum());
|
||||
queryTrackParam.setPhone(phone);
|
||||
queryTrackParam.setResultv2("4");
|
||||
String param = new Gson().toJson(queryTrackParam);
|
||||
|
||||
@@ -79,8 +75,15 @@ public class PostInfoServiceImpl implements IPostInfoService {
|
||||
IBaseClient baseClient = new QueryTrack();
|
||||
try {
|
||||
HttpResult httpResult = baseClient.execute(queryTrackReq);
|
||||
log.info("快递100远程api调用返回结果:",httpResult);
|
||||
return httpResult;
|
||||
// 2.1.对body做处理
|
||||
QueryInfoParam infoParam = new Gson().fromJson(httpResult.getBody(), QueryInfoParam.class);
|
||||
// 3.返回
|
||||
Result<QueryInfoParam> result = new Result();
|
||||
result.setCode(httpResult.getStatus());
|
||||
result.setResult(infoParam);
|
||||
result.setMessage(infoParam.getMessage());
|
||||
log.info("快递100远程api调用: {}", result.getMessage());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
throw new JeroBootException("快递信息查询失败!");
|
||||
}
|
||||
@@ -101,7 +104,7 @@ public class PostInfoServiceImpl implements IPostInfoService {
|
||||
* @Date: 2023/4/23 15:18
|
||||
* @Remarks: 判断是否是邮寄管理中的数据
|
||||
*/
|
||||
private void checkIsMySystem(PostInfoQuery postInfoQuery) {
|
||||
private String checkIsMySystem(PostInfoQuery postInfoQuery) {
|
||||
Page<PayMailContracrList> page1 = new Page<>(1, 1);
|
||||
PayMailContracrList payMailContracrList = new PayMailContracrList();
|
||||
payMailContracrList.setPostNo(postInfoQuery.getNum());
|
||||
@@ -112,8 +115,18 @@ public class PostInfoServiceImpl implements IPostInfoService {
|
||||
Page<PayMailBill> page2 = new Page<>(1, 1);
|
||||
IPage<PayMailBill> pageList2 = payMailBillService.pageList(page2, queryWrapper);
|
||||
int size2 = pageList2.getRecords().size();
|
||||
String phone;
|
||||
if (size1 < 1 && size2 < 1) {
|
||||
throw new JeroBootException("只能查询“票据邮寄”和“合同邮寄”中的快递单号信息!");
|
||||
} else if (size2 < 1) {
|
||||
phone = pageList1.getRecords().get(0).getPrincipalPhone();
|
||||
} else {
|
||||
phone = pageList2.getRecords().get(0).getPrincipalPhone();
|
||||
}
|
||||
if (StringUtils.isBlank(phone)) {
|
||||
throw new JeroBootException("该邮寄信息没有填写邮寄人电话!");
|
||||
}
|
||||
phone = PasswordUtil.decrypt(phone);
|
||||
return phone;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user