|
@@ -1,32 +1,35 @@
|
|
|
package com.qs.mp.web.controller.common;
|
|
|
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
-import cn.hutool.json.JSON;
|
|
|
-import cn.hutool.json.JSONArray;
|
|
|
-import cn.hutool.json.JSONConfig;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
+import cn.hutool.json.*;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.kuaidi100.sdk.api.AutoNum;
|
|
|
+import com.kuaidi100.sdk.api.QueryTrack;
|
|
|
import com.kuaidi100.sdk.core.IBaseClient;
|
|
|
import com.kuaidi100.sdk.pojo.HttpResult;
|
|
|
import com.kuaidi100.sdk.request.AutoNumReq;
|
|
|
+import com.kuaidi100.sdk.request.QueryTrackParam;
|
|
|
+import com.kuaidi100.sdk.request.QueryTrackReq;
|
|
|
+import com.kuaidi100.sdk.utils.SignUtils;
|
|
|
+import com.qs.mp.admin.domain.param.LogisticsQueryParam;
|
|
|
+import com.qs.mp.admin.domain.vo.LogisticsQueryVO;
|
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.common.domain.DeliveryCompany;
|
|
|
import com.qs.mp.common.service.IDeliveryCompanyService;
|
|
|
+import com.qs.mp.common.utils.MD5Util;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.time.Duration;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
@@ -54,6 +57,62 @@ public class LogisticsController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private IDeliveryCompanyService deliveryCompanyService;
|
|
|
|
|
|
+
|
|
|
+ @PostMapping("/query")
|
|
|
+ @ApiOperation("物流查询")
|
|
|
+ @ApiResponses(
|
|
|
+ @ApiResponse(code = 200, message = "成功", response = LogisticsQueryVO.class)
|
|
|
+ )
|
|
|
+ public AjaxResult query(@Validated @RequestBody LogisticsQueryParam logisticsQueryParam) {
|
|
|
+ // 查询物流公司信息
|
|
|
+ DeliveryCompany deliveryCompany = deliveryCompanyService.getOne(new LambdaQueryWrapper<DeliveryCompany>()
|
|
|
+ .select(DeliveryCompany::getCode)
|
|
|
+ .eq(DeliveryCompany::getDeliveryId, logisticsQueryParam.getDeliveryId()));
|
|
|
+
|
|
|
+ if (Objects.isNull(deliveryCompany)) {
|
|
|
+ throw new RuntimeException("物流公司不存在");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(deliveryCompany.getCode())) {
|
|
|
+ throw new RuntimeException("物流公司编码不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 封装物流请求参数
|
|
|
+ QueryTrackParam queryTrackParam = new QueryTrackParam();
|
|
|
+ // 快递公司编码
|
|
|
+ queryTrackParam.setCom(deliveryCompany.getCode());
|
|
|
+ // 物流单号
|
|
|
+ queryTrackParam.setNum(logisticsQueryParam.getDeliveryFlowId());
|
|
|
+ //1:开通行政区域解析功能以及物流轨迹增加物流状态名称
|
|
|
+ queryTrackParam.setResultv2("1");
|
|
|
+ String param = new Gson().toJson(queryTrackParam);
|
|
|
+
|
|
|
+ QueryTrackReq queryTrackReq = new QueryTrackReq();
|
|
|
+ queryTrackReq.setCustomer(customer);
|
|
|
+ queryTrackReq.setParam(param);
|
|
|
+ String sign = SignUtils.querySign(param ,key,customer);
|
|
|
+ queryTrackReq.setSign(sign);
|
|
|
+
|
|
|
+ IBaseClient baseClient = new QueryTrack();
|
|
|
+ try {
|
|
|
+ HttpResult execute = baseClient.execute(queryTrackReq);
|
|
|
+ String body = execute.getBody();
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(body);
|
|
|
+ String flag = jsonObject.getStr("result");
|
|
|
+ if (StringUtils.equals(flag, "false")) {
|
|
|
+ return AjaxResult.error(jsonObject.getStr("message"));
|
|
|
+ }
|
|
|
+ List<LogisticsQueryVO> data = JSONUtil.toList(jsonObject.getStr("data"), LogisticsQueryVO.class);
|
|
|
+ return AjaxResult.success(data);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@PostMapping("/autonumber/auto/{number}")
|
|
|
@ApiOperation("自动单号识别接口")
|
|
|
@ApiImplicitParams(
|