Authored by tanling

付费鉴定and付费寄存 物流信息

... ... @@ -69,6 +69,18 @@ public class ExpressInfoController {
/**
* 付费鉴定 and 付费鉴定查看物流信息
* @param orderCode
* @return
*/
@RequestMapping(params = "method=ufo.order.appraiseExpressDetailInfo")
public ApiResponse queryAppraiseExpressDetailInfo(@RequestParam("orderCode") Long orderCode) {
ExpressInfoRespBo expressInfoRespBo = expressInfoService.queryAppraiseExpressDetailInfo(orderCode);
return new ApiResponse.ApiResponseBuilder().code(200).data(expressInfoRespBo).build();
}
/**
* 鉴定中心地址
* @param uid uid
* @return
... ...
... ... @@ -21,6 +21,14 @@ import java.util.Objects;
*/
public interface IExpressInfoService {
/**
* 付费鉴定 and 付费寄存 物流信息
* @param orderCode
* @return
*/
ExpressInfoRespBo queryAppraiseExpressDetailInfo(Long orderCode);
//保存调拨信息(不含物流数据)
void saveOperateTransferExpressInfo(Integer uid, Long orderCode, Integer expressType, EnumExpressDataType expressDataType, EnumExpressDataOperateTransferCode operateTransferCode);
... ...
package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.order.common.AppraiseOrderAttributes;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.utils.BuyerOrderUtils;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.Objects;
import java.util.function.Predicate;
@Setter
@Accessors(fluent = true)
public class AppraiseExpressStageBuilder {
/**
* 用户发货
*
* 1卖家发货 == 2平台鉴定 点亮1
*/
private static final int DEPOSIT_USER_DELIVERY = 1;
/**
* 平台确认收货
*
* 1卖家发货 == 2平台鉴定 点亮1
*/
private static final int DEPOSIT_PLATFORM_RECEIPT = 2;
/**
* 平台发货
*
* 1平台发货 == 2交易成功 点亮1
*/
private static final int DEPOSIT_PLATFORM_DELIVER = 3;
/**
* 7天自动确认收货
*
* 1平台发货 == 2交易成功 点亮2
*/
private static final int AUTO_CONFIRM_RECEIPT = 4;
final AppraiseOrder appraiseOrder;
public AppraiseExpressStageBuilder(AppraiseOrder appraiseOrder) {
this.appraiseOrder = appraiseOrder;
}
public int build() {
int status = appraiseOrder.getStatus();
if(appraiseOrder.getAttributes() == AppraiseOrderAttributes.PAID_DEPOSIT.getCode()){
// 父订单
if (Objects.isNull(appraiseOrder.getParentOrderCode())){
if (status == AppraiseOrderStatus.SELLER_SEND_OUT.getCode()){
return DEPOSIT_USER_DELIVERY;
}else if (status == AppraiseOrderStatus.PLATFORM_RECEIVE.getCode()
|| status == AppraiseOrderStatus.PLATFORM_CHECKING.getCode()
|| status == AppraiseOrderStatus.JUDGE_PASS.getCode()
|| status == AppraiseOrderStatus.CHECKING_FAKE.getCode()
|| status == AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode()
|| status == AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()){
return DEPOSIT_PLATFORM_RECEIPT;
}
}
// 子订单
else{
if (status == AppraiseOrderStatus.WAITING_RECEIVE.getCode()){
return DEPOSIT_PLATFORM_DELIVER;
}
}
}
// 没有点亮部分
return -1;
}
}
... ...
... ... @@ -130,7 +130,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
private UserProxyService userProxyService;
@Autowired
private AppraiseOrderService appraiseOrderService;
AppraiseOrderMapper appraiseOrderMapper;
@Autowired
private OrderCodeGenerator orderCodeGenerator;
... ... @@ -544,6 +544,131 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
return result;
}
/**
* 根据订单号以及物流类型返回 物流信息
* @param orderCode
* @param expressTypeList
* @return
*/
private List<ExpressInfoDetail> getExpressInfoDetailListByOrderCodeExpressType(long orderCode, List<Integer> expressTypeList){
// 物流信息列表
List<ExpressInfo> list = Lists.newArrayList();
expressTypeList.stream().forEach(expressType -> list.addAll(getExpressInfoList(orderCode, expressType)));
return list.stream().map(expressInfo -> covertToExpressInfoDetail(expressInfo)).collect(Collectors.toList());
}
/**
* 付费鉴定 and 付费寄存 物流信息
* @param orderCode
* @return
*/
public ExpressInfoRespBo queryAppraiseExpressDetailInfo(Long orderCode) {
ExpressInfoRespBo expressInfoRespBo = new ExpressInfoRespBo();
AppraiseOrder appraiseOrder = appraiseOrderMapper.selectByOrderCode(orderCode);
throwServiceExceptionIf(Objects.isNull(appraiseOrder), "订单不存在");
// 付费寄存 无点亮信息,只根据状态展示对应的物流信息
if (appraiseOrder.getAttributes() == AppraiseOrderAttributes.PAID_APPRAISE.getCode()){
// 用户发货, 待用户收货 只有这两个状态展示物流
throwServiceExceptionIf(appraiseOrder.getStatus() != AppraiseOrderStatus.SELLER_SEND_OUT.getCode()
&& appraiseOrder.getStatus() != AppraiseOrderStatus.WAITING_RECEIVE.getCode(), "不展示物流信息");
List<Integer> expressTypeList = Lists.newArrayList();
// 用户发货
if(appraiseOrder.getStatus() == AppraiseOrderStatus.SELLER_SEND_OUT.getCode()){
expressTypeList = Arrays.asList(EnumExpressType.EXPRESS_TYPE_1.getCode());
}else if(appraiseOrder.getStatus() == AppraiseOrderStatus.WAITING_RECEIVE.getCode()){
expressTypeList = Arrays.asList(EnumExpressType.EXPRESS_TYPE_2.getCode(),
EnumExpressType.EXPRESS_TYPE_3.getCode(),
EnumExpressType.EXPRESS_TYPE_REBACK.getCode());
}
// 物流单号信息
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
// 根据订单号and物流类型 返回物流信息
List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, expressTypeList);
expressInfoRespBo.setExpressInfoDetailTitle("");
expressInfoRespBo.setExpressInfoDetailList(expressInfoDetailList);
return expressInfoRespBo;
}else if(appraiseOrder.getAttributes() == AppraiseOrderAttributes.PAID_DEPOSIT.getCode()){
// 子订单的场合,点亮信息 + 物流信息(不区分阶段)
// 父订单的场合,点亮信息 + 物流信息(区分阶段)
boolean isSubOrder = Objects.nonNull(appraiseOrder.getParentOrderCode()) ? true : false;
// 点亮信息设置
expressInfoRespBo.setStage(new AppraiseExpressStageBuilder(appraiseOrder).build());
// 子订单
if (isSubOrder){
// 寄回物流
List<Integer> expressTypeList = Arrays.asList(EnumExpressType.EXPRESS_TYPE_2.getCode(),
EnumExpressType.EXPRESS_TYPE_3.getCode(),
EnumExpressType.EXPRESS_TYPE_REBACK.getCode());
// 物流单号信息
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
// 根据订单号and物流类型 返回物流信息
List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, expressTypeList);
expressInfoRespBo.setExpressInfoDetailTitle("");
expressInfoRespBo.setExpressInfoDetailList(expressInfoDetailList);
return expressInfoRespBo;
}
// 父订单
else{
List<Integer> expressTypeList = getAppraiseExpressType(appraiseOrder.getStatus());
if (CollectionUtils.isEmpty(expressTypeList)) {
LOGGER.info("{}, appraise expressTypeList is empty", orderCode);
return expressInfoRespBo;
}
// 物流单号信息
constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
// 其中是否包含了 鉴定中心内部调拨信息
if (expressTypeList.contains(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode())){
// 根据订单号and物流类型 返回物流信息
List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, Lists.newArrayList(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode()));
expressInfoRespBo.setJudgeExpressInfoDetailList(expressInfoDetailList);
expressInfoRespBo.setJudgeExpressInfoDetailTitle("平台鉴定");
}
// 根据订单号and物流类型 返回物流信息
List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, Lists.newArrayList(EnumExpressType.EXPRESS_TYPE_1.getCode()));
expressInfoRespBo.setSupplementExpressInfoDetailTitle("卖家发往平台");
expressInfoRespBo.setSupplementExpressInfoDetailList(expressInfoDetailList);
return expressInfoRespBo;
}
}
LOGGER.info("{}, result is {}", orderCode, JSON.toJSONString(expressInfoRespBo));
return expressInfoRespBo;
}
private void constructSupplementExpress(TabType actor, Long orderCode, Integer expressType, ExpressInfoRespBo expressInfoRespBo) {
if (EnumExpressType.EXPRESS_TYPE_2.getCode().intValue() == expressType.intValue()
|| EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode().intValue() == expressType.intValue()) {
... ... @@ -635,6 +760,30 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
/**
* 根据状态获取物流类型
* @param status
* @return
*/
private List<Integer> getAppraiseExpressType(Integer status) {
if (AppraiseOrderStatus.SELLER_SEND_OUT.getCode() == status) {
return Arrays.asList(EnumExpressType.EXPRESS_TYPE_1.getCode());
}
// 这些状态需要展示 平台鉴定
else if (AppraiseOrderStatus.PLATFORM_RECEIVE.getCode() == status
|| AppraiseOrderStatus.PLATFORM_CHECKING.getCode() == status
|| AppraiseOrderStatus.JUDGE_PASS.getCode() == status
|| AppraiseOrderStatus.WAITING_RECEIVE.getCode() == status
|| AppraiseOrderStatus.CHECKING_FAKE.getCode() == status
|| AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode() == status
|| AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode() == status) {
return Arrays.asList(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode(), EnumExpressType.EXPRESS_TYPE_1.getCode());
}
return null;
}
/* private Integer getCurrentExpressType4ExpressRecordAndSeller(Integer status){
Integer type ;
... ... @@ -840,6 +989,25 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
return "订单跟踪";
}
/**
* 响应结果类型转换
* @param expressInfo
* @return
*/
private ExpressInfoDetail covertToExpressInfoDetail(ExpressInfo expressInfo){
ExpressInfoDetail expressInfoDetail = new ExpressInfoDetail();
// 运单接收地
expressInfoDetail.setAcceptAddress(expressInfo.getAcceptAddress());
// 运单信息
expressInfoDetail.setAcceptRemark(expressInfo.getAcceptRemark());
expressInfoDetail.setCreateTimeStr(DateUtil.formatDate(expressInfo.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
expressInfoDetail.setState(expressInfo.getState());
expressInfoDetail.setExpressType(expressInfo.getExpressType().intValue());
return expressInfoDetail;
}
private void constructExpressInfo(TabType actor, List<ExpressInfo> expressInfoList, List<ExpressInfoDetail> detailList) {
if (CollectionUtils.isNotEmpty(expressInfoList)) {
... ...