add 快递100查询订单信息
This commit is contained in:
+3
@@ -194,6 +194,9 @@ public class ShiroConfig {
|
||||
// 判断当前企业是否是内部企业
|
||||
filterChainDefinitionMap.put("/company/payCompanyManagement/getInternalEnterprise","anon");
|
||||
|
||||
// 快递100-快递信息
|
||||
filterChainDefinitionMap.put("/mail/postInfo/queryInfo","anon");
|
||||
|
||||
// 添加自己的过滤器并且取名为jwt
|
||||
Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
|
||||
//如果cloudServer为空 则说明是单体 需要加载跨域配置
|
||||
|
||||
@@ -61,5 +61,11 @@
|
||||
<artifactId>jero-cloud-feign-config</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<!--快递100api依赖-->
|
||||
<dependency>
|
||||
<groupId>com.github.kuaidi100-api</groupId>
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>1.0.11</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.jero.mail.controller;
|
||||
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.DictPoint;
|
||||
import com.jero.mail.param.QueryInfoParam;
|
||||
import com.jero.mail.service.IPostInfoService;
|
||||
import com.jero.mail.param.PostInfoQuery;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/23 14:37
|
||||
* @remarks: 快递100-快递信息
|
||||
*/
|
||||
@Api(tags="快递100-快递信息")
|
||||
@RestController
|
||||
@RequestMapping("/mail/postInfo")
|
||||
@Slf4j
|
||||
public class PostInfoController {
|
||||
|
||||
@Autowired
|
||||
private IPostInfoService postInfoService;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/23 14:49
|
||||
* @Remarks: 快递100-快递信息-查询
|
||||
*/
|
||||
@ApiOperation(value="快递100-快递信息-查询", notes="快递100-快递信息-查询")
|
||||
@GetMapping(value = "/queryInfo")
|
||||
@DictPoint
|
||||
public Result<QueryInfoParam> queryInfo(@Validated PostInfoQuery postInfoQuery) {
|
||||
return postInfoService.queryInfo(postInfoQuery);
|
||||
}
|
||||
|
||||
}
|
||||
+26
-23
@@ -79,29 +79,32 @@
|
||||
</select>
|
||||
|
||||
<select id="pageList" resultType="com.jero.mail.entity.PayMailBill">
|
||||
SELECT pmb.id,
|
||||
project_name as projectName,
|
||||
bill_no AS billNo,
|
||||
pmb.invoice_amount as invoiceAmount,
|
||||
principal_id ,
|
||||
su.phone as principal_phone,
|
||||
principal_name as principalName,
|
||||
charge_company_name as chargeCompanyName,
|
||||
contact_name as contactName,
|
||||
contact_mobile as contactMobile,
|
||||
post_status as postStatus,
|
||||
send_method as sendMethod ,
|
||||
pmbp.project_id as projectId,
|
||||
pmb.create_time,
|
||||
postal_code as postalCode,
|
||||
mailer,
|
||||
post_no as postNo,
|
||||
send_date as sendDate,
|
||||
contact_address as contactAddress,
|
||||
pmb.remark
|
||||
from pay_mail_bill pmb left join pay_mail_bill_project pmbp on(pmb.id=pmbp.bill_id) left join sys_user su on pmb.principal_id = su.id
|
||||
${ew.customSqlSegment}
|
||||
group by pmb.id ORDER BY pmb.post_status ASC,pmb.create_time DESC
|
||||
SELECT pmb.id,
|
||||
project_name as projectName,
|
||||
bill_no AS billNo,
|
||||
pmb.invoice_amount as invoiceAmount,
|
||||
principal_id,
|
||||
su.phone as principal_phone,
|
||||
principal_name as principalName,
|
||||
charge_company_name as chargeCompanyName,
|
||||
contact_name as contactName,
|
||||
contact_mobile as contactMobile,
|
||||
post_status as postStatus,
|
||||
send_method as sendMethod,
|
||||
pmbp.project_id as projectId,
|
||||
pmb.create_time,
|
||||
postal_code as postalCode,
|
||||
mailer,
|
||||
post_no as postNo,
|
||||
send_date as sendDate,
|
||||
contact_address as contactAddress,
|
||||
pmb.remark
|
||||
from pay_mail_bill pmb
|
||||
left join pay_mail_bill_project pmbp on (pmb.id = pmbp.bill_id)
|
||||
left join sys_user su on pmb.principal_id = su.id
|
||||
${ew.customSqlSegment}
|
||||
group by pmb.id
|
||||
ORDER BY pmb.post_status ASC, pmb.create_time DESC
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
+6
@@ -42,6 +42,9 @@ pc.contract_type='2'
|
||||
<if test="payMailContracrList.principalId !='' and payMailContracrList.principalId !=null">
|
||||
and pic.principal_id = #{payMailContracrList.principalId}
|
||||
</if>
|
||||
<if test="payMailContracrList.postNo !='' and payMailContracrList.postNo !=null">
|
||||
and pc.post_no = #{payMailContracrList.postNo}
|
||||
</if>
|
||||
</where>
|
||||
union all
|
||||
SELECT
|
||||
@@ -78,6 +81,9 @@ union all
|
||||
<if test="payMailContracrList.principalId !='' and payMailContracrList.principalId !=null">
|
||||
and psc.principal_id = #{payMailContracrList.principalId}
|
||||
</if>
|
||||
<if test="payMailContracrList.postNo !='' and payMailContracrList.postNo !=null">
|
||||
and pc.post_no = #{payMailContracrList.postNo}
|
||||
</if>
|
||||
</where>
|
||||
) pp
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.jero.mail.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/23 14:58
|
||||
* @remarks: 快递100-快递信息模型类
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("快递100-快递信息-查询参数")
|
||||
public class PostInfoQuery {
|
||||
@ApiModelProperty("查询的快递公司的编码(快递公司(1:EMS,2:顺丰))")
|
||||
@NotBlank(message = "查询的快递公司的编码不能为空")
|
||||
private String com;
|
||||
@ApiModelProperty("查询的快递单号")
|
||||
@NotBlank(message = "查询的快递单号不能为空")
|
||||
private String num;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jero.mail.param;
|
||||
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/24 8:52
|
||||
* @remarks:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("快递查询返回结果类")
|
||||
public class QueryInfoParam {
|
||||
@ApiModelProperty("消息体")
|
||||
private String message;
|
||||
@ApiModelProperty("快递单当前状态,默认为0在途,1揽收,2疑难,3签收,4退签,5派件,8清关,14拒签等10个基础物流状态")
|
||||
@Dict(dicCode = "post_state")
|
||||
private String state;
|
||||
@ApiModelProperty("通讯状态")
|
||||
private String status;
|
||||
@ApiModelProperty("快递单明细状态标记")
|
||||
private String condition;
|
||||
@ApiModelProperty("是否签收标记,0未签收,1已签收")
|
||||
@Dict(dicCode = "post_ischeck")
|
||||
private String ischeck;
|
||||
@ApiModelProperty("快递公司编码,一律用小写字母")
|
||||
private String com;
|
||||
@ApiModelProperty("单号")
|
||||
private String nu;
|
||||
@ApiModelProperty("最新查询结果,数组,包含多项,全量,倒序")
|
||||
private data[] data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jero.mail.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/24 8:57
|
||||
* @remarks:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("最新查询结果,数组,包含多项,全量,倒序(即时间最新的在最前)")
|
||||
public class data {
|
||||
@ApiModelProperty("内容")
|
||||
private String context;
|
||||
@ApiModelProperty("时间,原始格式")
|
||||
private String time;
|
||||
@ApiModelProperty("格式化后时间")
|
||||
private String ftime;
|
||||
@ApiModelProperty("本数据元对应的物流状态名称或者高级状态名称")
|
||||
private String status;
|
||||
@ApiModelProperty("本数据元对应的高级物流状态值")
|
||||
private String statusCode;
|
||||
@ApiModelProperty("本数据元对应的行政区域的编码")
|
||||
private String areaCode;
|
||||
@ApiModelProperty("本数据元对应的行政区域的名称")
|
||||
private String areaName;
|
||||
@ApiModelProperty("本数据元对应的行政区域经纬度")
|
||||
private String areaCenter;
|
||||
@ApiModelProperty("本数据元对应的快件当前地点")
|
||||
private String location;
|
||||
@ApiModelProperty("本数据元对应的行政区域拼音")
|
||||
private String areaPinYin;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jero.mail.service;
|
||||
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.mail.param.PostInfoQuery;
|
||||
import com.jero.mail.param.QueryInfoParam;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/23 14:41
|
||||
* @remarks: 快递100-快递信息
|
||||
*/
|
||||
public interface IPostInfoService {
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/23 14:49
|
||||
* @Remarks: 快递100-快递信息-查询
|
||||
*/
|
||||
Result<QueryInfoParam> queryInfo(PostInfoQuery postInfoQuery);
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
package com.jero.mail.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.mail.entity.PayMailBill;
|
||||
import com.jero.mail.entity.PayMailContracrList;
|
||||
import com.jero.mail.param.QueryInfoParam;
|
||||
import com.jero.mail.service.IPayMailBillService;
|
||||
import com.jero.mail.service.IPayMailContractService;
|
||||
import com.jero.mail.service.IPostInfoService;
|
||||
import com.jero.mail.param.PostInfoQuery;
|
||||
import com.kuaidi100.sdk.api.QueryTrack;
|
||||
import com.kuaidi100.sdk.core.IBaseClient;
|
||||
import com.kuaidi100.sdk.pojo.HttpResult;
|
||||
import com.kuaidi100.sdk.request.QueryTrackParam;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/23 14:41
|
||||
* @remarks: 快递100-快递信息
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PostInfoServiceImpl implements IPostInfoService {
|
||||
@Autowired
|
||||
private IPayMailBillService payMailBillService;
|
||||
@Autowired
|
||||
private IPayMailContractService payMailContractService;
|
||||
String key = PropertiesReader.get("key");
|
||||
String customer = PropertiesReader.get("customer");
|
||||
private static final String SF = "shunfeng"; // 顺丰
|
||||
private static final String EMS = "ems"; //EMS
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/23 14:49
|
||||
* @Remarks: 快递100-快递信息-查询
|
||||
*/
|
||||
@Override
|
||||
public Result<QueryInfoParam> queryInfo(PostInfoQuery postInfoQuery) {
|
||||
// 1.判断是否是邮寄管理中的数据
|
||||
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());
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private HttpResult sendReq(PostInfoQuery postInfoQuery) {
|
||||
QueryTrackReq queryTrackReq = new QueryTrackReq();
|
||||
QueryTrackParam queryTrackParam = new QueryTrackParam();
|
||||
setCom(postInfoQuery);
|
||||
queryTrackParam.setCom(postInfoQuery.getCom());
|
||||
queryTrackParam.setNum(postInfoQuery.getNum());
|
||||
String param = new Gson().toJson(queryTrackParam);
|
||||
|
||||
queryTrackReq.setParam(param);
|
||||
queryTrackReq.setCustomer(customer);
|
||||
queryTrackReq.setSign(SignUtils.querySign(param ,key,customer));
|
||||
|
||||
IBaseClient baseClient = new QueryTrack();
|
||||
try {
|
||||
HttpResult httpResult = baseClient.execute(queryTrackReq);
|
||||
log.info("快递100远程api调用返回结果:",httpResult);
|
||||
return httpResult;
|
||||
} catch (Exception e) {
|
||||
throw new JeroBootException("快递信息查询失败!");
|
||||
}
|
||||
}
|
||||
|
||||
private void setCom(PostInfoQuery postInfoQuery) {
|
||||
if ("1".equals(postInfoQuery.getCom())) {
|
||||
postInfoQuery.setCom(SF);
|
||||
} else if ("2".equals(postInfoQuery.getCom())) {
|
||||
postInfoQuery.setCom(EMS);
|
||||
} else {
|
||||
throw new JeroBootException("只能查询顺丰和EMS的快递信息!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/4/23 15:18
|
||||
* @Remarks: 判断是否是邮寄管理中的数据
|
||||
*/
|
||||
private void checkIsMySystem(PostInfoQuery postInfoQuery) {
|
||||
Page<PayMailContracrList> page1 = new Page<>(1, 1);
|
||||
PayMailContracrList payMailContracrList = new PayMailContracrList();
|
||||
payMailContracrList.setPostNo(postInfoQuery.getNum());
|
||||
IPage<PayMailContracrList> pageList1 = payMailContractService.pageContract(page1, payMailContracrList);
|
||||
int size1 = pageList1.getRecords().size();
|
||||
QueryWrapper<PayMailBill> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PayMailBill::getPostNo, postInfoQuery.getNum());
|
||||
Page<PayMailBill> page2 = new Page<>(1, 1);
|
||||
IPage<PayMailBill> pageList2 = payMailBillService.pageList(page2, queryWrapper);
|
||||
int size2 = pageList2.getRecords().size();
|
||||
if (size1 < 1 && size2 < 1) {
|
||||
throw new JeroBootException("只能查询“票据邮寄”和“合同邮寄”中的快递单号信息!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#快递100的基础账号信息,可以在这里获取
|
||||
# https://api.kuaidi100.com/manager/v2/myinfo/enterprise
|
||||
key = glrUQsMV4692
|
||||
customer = 580BE140491CA19C3FED37DB5845413E
|
||||
secret = 13ca4c7113dc4358ae4ef739ce5127b3
|
||||
userid = 0aca2a83308545af9299b83174d38ee8
|
||||
Reference in New Issue
Block a user