Commit 25d14eb6 authored by shiyu's avatar shiyu

多场景物流信息查询

parent 4f92c358
......@@ -68,4 +68,9 @@ public interface CommConsts {
* 平台中转鉴定单前缀
*/
public final static String IDENTIFY_ORDER_PREFIX = "IE";
/**
* 平台收货地址
*/
public final static String SYSTEM_DEFAULT_ADDRESS = "换藏平台,13216703670,浙江省杭州市钱塘区2号大街海聚中心1幢1601";
}
......@@ -72,7 +72,7 @@ public class CommonEnum {
public enum LogisticsTypeEnum {
FROM(1, "藏家基础物流"),
FROM(1, "藏家寄出物流"),
DELIVERY(2, "平台发货物流"),
SEND_BACK(3, "平台退回物流"),
;
......@@ -105,7 +105,46 @@ public class CommonEnum {
}
/**
* 物流状态
*/
public enum LogisticsStateEnum {
NO_TRAIL(0, "暂无轨迹信息"),
COLLECTED(1, "已揽收"),
ON_THE_WAY(2, "在途中"),
SIGNED(3, "签收"),
PROBLEM(4, "问题件"),
FORWARD(5, "转寄"),
CUSTOMS_CLEARANCE(6, "清关"),
;
private int code;
private String des;
LogisticsStateEnum(int code, String des) {
this.code = code;
this.des = des;
}
public static String getNameByCode(int code) {
for (LogisticsStateEnum logisticsStateEnum : LogisticsStateEnum.values()) {
if (code == logisticsStateEnum.getCode()) {
return logisticsStateEnum.getDes();
}
}
return null;
}
public int getCode() {
return code;
}
public String getDes() {
return des;
}
}
public enum SourceEnum {
......
......@@ -6,6 +6,8 @@ import lombok.Data;
@Data
public class LogisticsRequestDto implements Entity {
private String distributionOrderId;
private String logisticsCode;
private String waybill;
......
package com.wwdz.ch.wx.api;
import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.consts.LogisticsEnum;
import com.wwdz.ch.core.entity.LogisticsInfo;
import com.wwdz.ch.core.entity.LogisticsRequestDto;
......@@ -78,6 +79,7 @@ public class LogisticsApi {
logisticsInfo.setWaybill(dto.getWaybill());
logisticsInfo.setTrailInfoList(trailInfoList);
logisticsInfo.setState(state);
logisticsInfo.setStateName(CommonEnum.LogisticsStateEnum.getNameByCode(Integer.parseInt(state)));
return Result.success(logisticsInfo);
}
return Result.failed();
......
package com.wwdz.ch.wx.impl.distribution;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.entity.LogisticsInfo;
import com.wwdz.ch.core.entity.LogisticsRequestDto;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.dao.distribution.IdentifyOrderDao;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.IdentifyOrder;
import com.wwdz.ch.wx.api.LogisticsApi;
import com.wwdz.ch.wx.service.distribution.LogisticsService;
import com.xxdxxs.utils.StringUtils;
......@@ -24,6 +28,9 @@ public class LogisticsServiceImpl implements LogisticsService {
@Autowired
DistributionOrderDao distributionOrderDao;
@Autowired
IdentifyOrderDao identifyOrderDao;
@Override
public Result findLogisticsInfo(String orderId) {
try {
......@@ -41,8 +48,9 @@ public class LogisticsServiceImpl implements LogisticsService {
logisticsInfo.setDistributionOrderId(orderId);
result.setData(logisticsInfo);
return result;
} else {
return Result.failed("暂未查询到物流信息");
}
return result;
} else {
return Result.failed("承运商信息为空");
}
......@@ -57,9 +65,39 @@ public class LogisticsServiceImpl implements LogisticsService {
@Override
public Result findLogisticsInfo(LogisticsRequestDto dto) {
try {
int type = dto.getType();
String logisticsCode = null;
String waybill = null;
String receiverInfo = null;
if (type == CommonEnum.LogisticsTypeEnum.FROM.getCode()) {
IdentifyOrder identifyOrder = identifyOrderDao.findByDistributionOrderId(dto.getDistributionOrderId());
logisticsCode = identifyOrder.getFromLogisticsCode();
waybill = identifyOrder.getFromWaybill();
receiverInfo = CommConsts.SYSTEM_DEFAULT_ADDRESS;
} else if (type == CommonEnum.LogisticsTypeEnum.DELIVERY.getCode()) {
DistributionOrder distributionOrder = distributionOrderDao.findById(dto.getDistributionOrderId());
logisticsCode = distributionOrder.getLogisticsCode();
waybill = distributionOrder.getWaybill();
receiverInfo = distributionOrder.getReceiverName() + "," + distributionOrder.getReceiverPhone() + "," + distributionOrder.getReceiverAddress();
} else if (type == CommonEnum.LogisticsTypeEnum.SEND_BACK.getCode()) {
IdentifyOrder identifyOrder = identifyOrderDao.findByDistributionOrderId(dto.getDistributionOrderId());
logisticsCode = identifyOrder.getOutLogisticsCode();
waybill = identifyOrder.getOutWaybill();
receiverInfo = identifyOrder.getReturnName() + "," + identifyOrder.getReturnPhone() + "," + identifyOrder.getReturnAddress();
}
LogisticsRequestDto logisticsRequestDto = new LogisticsRequestDto();
logisticsRequestDto.setLogisticsCode(logisticsCode);
logisticsRequestDto.setWaybill(waybill);
Result result = logisticsApi.findTrails(logisticsRequestDto);
if (result.getSuccess()) {
LogisticsInfo logisticsInfo = (LogisticsInfo) result.getData();
logisticsInfo.setReceiverInfo(receiverInfo);
logisticsInfo.setDistributionOrderId(dto.getDistributionOrderId());
result.setData(logisticsInfo);
return result;
} else {
return Result.failed("暂未查询到物流信息");
}
} catch (Exception e) {
logger.error("查询物流轨迹 error : {}", e);
}
......
......@@ -15,8 +15,7 @@ public interface LogisticsService {
/**
* 查询订单物流轨迹
* @param waybill
* @param type
* @param dto
* @return
*/
Result findLogisticsInfo(LogisticsRequestDto dto);
......
......@@ -144,10 +144,10 @@ public class DistributionOrderController {
return distributionOrderService.cancel(dto);
}
@ApiOperation(value = "发货")
@ApiOperation(value = "藏家发货")
@PostMapping("/delivery")
public Result delivery(@RequestBody DistributionOrderRequestDto dto) {
logger.info("发货,请求参数:{}", JSON.toJSONString(dto));
logger.info("藏家发货,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("distributionOrderId", "分销订单号").must().string()
.set("logisticsCode", "快递公司编码").must().string()
......
package com.wwdz.ch.wx.web.distribution;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.entity.LogisticsRequestDto;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto;
import com.wwdz.ch.wx.entity.request.SelfPageRequestDto;
......@@ -40,4 +41,18 @@ public class LogisticsController {
return logisticsService.findLogisticsInfo(dto.getDistributionOrderId());
}
@ApiOperation(value = "查询不同场景的物流轨迹")
@PostMapping("/findLogisticsInfoByType")
public Result findLogisticsInfoByType(@RequestBody LogisticsRequestDto dto) {
logger.info("查询不同场景的物流轨迹,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("distributionOrderId", "订单号").must().string()
.set("type", "场景类型").must().number()
.end();
if (!validator.isValid()) {
return Result.failed(validator.getErrorInfo());
}
return logisticsService.findLogisticsInfo(dto);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment