Authored by tanling

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

@@ -69,6 +69,18 @@ public class ExpressInfoController { @@ -69,6 +69,18 @@ public class ExpressInfoController {
69 69
70 70
71 /** 71 /**
  72 + * 付费鉴定 and 付费鉴定查看物流信息
  73 + * @param orderCode
  74 + * @return
  75 + */
  76 + @RequestMapping(params = "method=ufo.order.appraiseExpressDetailInfo")
  77 + public ApiResponse queryAppraiseExpressDetailInfo(@RequestParam("orderCode") Long orderCode) {
  78 + ExpressInfoRespBo expressInfoRespBo = expressInfoService.queryAppraiseExpressDetailInfo(orderCode);
  79 + return new ApiResponse.ApiResponseBuilder().code(200).data(expressInfoRespBo).build();
  80 + }
  81 +
  82 +
  83 + /**
72 * 鉴定中心地址 84 * 鉴定中心地址
73 * @param uid uid 85 * @param uid uid
74 * @return 86 * @return
@@ -21,6 +21,14 @@ import java.util.Objects; @@ -21,6 +21,14 @@ import java.util.Objects;
21 */ 21 */
22 public interface IExpressInfoService { 22 public interface IExpressInfoService {
23 23
  24 +
  25 + /**
  26 + * 付费鉴定 and 付费寄存 物流信息
  27 + * @param orderCode
  28 + * @return
  29 + */
  30 + ExpressInfoRespBo queryAppraiseExpressDetailInfo(Long orderCode);
  31 +
24 //保存调拨信息(不含物流数据) 32 //保存调拨信息(不含物流数据)
25 void saveOperateTransferExpressInfo(Integer uid, Long orderCode, Integer expressType, EnumExpressDataType expressDataType, EnumExpressDataOperateTransferCode operateTransferCode); 33 void saveOperateTransferExpressInfo(Integer uid, Long orderCode, Integer expressType, EnumExpressDataType expressDataType, EnumExpressDataOperateTransferCode operateTransferCode);
26 34
  1 +package com.yohoufo.order.service.impl;
  2 +
  3 +import com.yohobuy.ufo.model.order.common.AppraiseOrderAttributes;
  4 +import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
  5 +import com.yohobuy.ufo.model.order.common.OrderStatus;
  6 +import com.yohobuy.ufo.model.order.common.TabType;
  7 +import com.yohoufo.dal.order.model.AppraiseOrder;
  8 +import com.yohoufo.dal.order.model.BuyerOrder;
  9 +import com.yohoufo.order.utils.BuyerOrderUtils;
  10 +import lombok.Setter;
  11 +import lombok.experimental.Accessors;
  12 +
  13 +import java.util.Objects;
  14 +import java.util.function.Predicate;
  15 +
  16 +@Setter
  17 +@Accessors(fluent = true)
  18 +public class AppraiseExpressStageBuilder {
  19 +
  20 + /**
  21 + * 用户发货
  22 + *
  23 + * 1卖家发货 == 2平台鉴定 点亮1
  24 + */
  25 + private static final int DEPOSIT_USER_DELIVERY = 1;
  26 +
  27 + /**
  28 + * 平台确认收货
  29 + *
  30 + * 1卖家发货 == 2平台鉴定 点亮1
  31 + */
  32 + private static final int DEPOSIT_PLATFORM_RECEIPT = 2;
  33 +
  34 + /**
  35 + * 平台发货
  36 + *
  37 + * 1平台发货 == 2交易成功 点亮1
  38 + */
  39 + private static final int DEPOSIT_PLATFORM_DELIVER = 3;
  40 +
  41 + /**
  42 + * 7天自动确认收货
  43 + *
  44 + * 1平台发货 == 2交易成功 点亮2
  45 + */
  46 + private static final int AUTO_CONFIRM_RECEIPT = 4;
  47 +
  48 +
  49 + final AppraiseOrder appraiseOrder;
  50 +
  51 + public AppraiseExpressStageBuilder(AppraiseOrder appraiseOrder) {
  52 + this.appraiseOrder = appraiseOrder;
  53 + }
  54 +
  55 + public int build() {
  56 +
  57 + int status = appraiseOrder.getStatus();
  58 +
  59 + if(appraiseOrder.getAttributes() == AppraiseOrderAttributes.PAID_DEPOSIT.getCode()){
  60 +
  61 + // 父订单
  62 + if (Objects.isNull(appraiseOrder.getParentOrderCode())){
  63 + if (status == AppraiseOrderStatus.SELLER_SEND_OUT.getCode()){
  64 + return DEPOSIT_USER_DELIVERY;
  65 + }else if (status == AppraiseOrderStatus.PLATFORM_RECEIVE.getCode()
  66 + || status == AppraiseOrderStatus.PLATFORM_CHECKING.getCode()
  67 + || status == AppraiseOrderStatus.JUDGE_PASS.getCode()
  68 + || status == AppraiseOrderStatus.CHECKING_FAKE.getCode()
  69 + || status == AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode()
  70 + || status == AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()){
  71 + return DEPOSIT_PLATFORM_RECEIPT;
  72 + }
  73 +
  74 + }
  75 + // 子订单
  76 + else{
  77 +
  78 + if (status == AppraiseOrderStatus.WAITING_RECEIVE.getCode()){
  79 + return DEPOSIT_PLATFORM_DELIVER;
  80 + }
  81 +
  82 + }
  83 +
  84 + }
  85 +
  86 + // 没有点亮部分
  87 + return -1;
  88 +
  89 + }
  90 +
  91 +
  92 +}
@@ -130,7 +130,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -130,7 +130,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
130 private UserProxyService userProxyService; 130 private UserProxyService userProxyService;
131 131
132 @Autowired 132 @Autowired
133 - private AppraiseOrderService appraiseOrderService; 133 + AppraiseOrderMapper appraiseOrderMapper;
134 134
135 @Autowired 135 @Autowired
136 private OrderCodeGenerator orderCodeGenerator; 136 private OrderCodeGenerator orderCodeGenerator;
@@ -544,6 +544,131 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -544,6 +544,131 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
544 return result; 544 return result;
545 } 545 }
546 546
  547 +
  548 + /**
  549 + * 根据订单号以及物流类型返回 物流信息
  550 + * @param orderCode
  551 + * @param expressTypeList
  552 + * @return
  553 + */
  554 + private List<ExpressInfoDetail> getExpressInfoDetailListByOrderCodeExpressType(long orderCode, List<Integer> expressTypeList){
  555 +
  556 + // 物流信息列表
  557 + List<ExpressInfo> list = Lists.newArrayList();
  558 + expressTypeList.stream().forEach(expressType -> list.addAll(getExpressInfoList(orderCode, expressType)));
  559 +
  560 + return list.stream().map(expressInfo -> covertToExpressInfoDetail(expressInfo)).collect(Collectors.toList());
  561 +
  562 + }
  563 +
  564 +
  565 + /**
  566 + * 付费鉴定 and 付费寄存 物流信息
  567 + * @param orderCode
  568 + * @return
  569 + */
  570 + public ExpressInfoRespBo queryAppraiseExpressDetailInfo(Long orderCode) {
  571 +
  572 + ExpressInfoRespBo expressInfoRespBo = new ExpressInfoRespBo();
  573 +
  574 + AppraiseOrder appraiseOrder = appraiseOrderMapper.selectByOrderCode(orderCode);
  575 + throwServiceExceptionIf(Objects.isNull(appraiseOrder), "订单不存在");
  576 +
  577 +
  578 + // 付费寄存 无点亮信息,只根据状态展示对应的物流信息
  579 + if (appraiseOrder.getAttributes() == AppraiseOrderAttributes.PAID_APPRAISE.getCode()){
  580 +
  581 + // 用户发货, 待用户收货 只有这两个状态展示物流
  582 + throwServiceExceptionIf(appraiseOrder.getStatus() != AppraiseOrderStatus.SELLER_SEND_OUT.getCode()
  583 + && appraiseOrder.getStatus() != AppraiseOrderStatus.WAITING_RECEIVE.getCode(), "不展示物流信息");
  584 +
  585 + List<Integer> expressTypeList = Lists.newArrayList();
  586 + // 用户发货
  587 + if(appraiseOrder.getStatus() == AppraiseOrderStatus.SELLER_SEND_OUT.getCode()){
  588 + expressTypeList = Arrays.asList(EnumExpressType.EXPRESS_TYPE_1.getCode());
  589 + }else if(appraiseOrder.getStatus() == AppraiseOrderStatus.WAITING_RECEIVE.getCode()){
  590 + expressTypeList = Arrays.asList(EnumExpressType.EXPRESS_TYPE_2.getCode(),
  591 + EnumExpressType.EXPRESS_TYPE_3.getCode(),
  592 + EnumExpressType.EXPRESS_TYPE_REBACK.getCode());
  593 + }
  594 +
  595 + // 物流单号信息
  596 + constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
  597 +
  598 + // 根据订单号and物流类型 返回物流信息
  599 + List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, expressTypeList);
  600 +
  601 + expressInfoRespBo.setExpressInfoDetailTitle("");
  602 + expressInfoRespBo.setExpressInfoDetailList(expressInfoDetailList);
  603 +
  604 + return expressInfoRespBo;
  605 +
  606 + }else if(appraiseOrder.getAttributes() == AppraiseOrderAttributes.PAID_DEPOSIT.getCode()){
  607 +
  608 + // 子订单的场合,点亮信息 + 物流信息(不区分阶段)
  609 + // 父订单的场合,点亮信息 + 物流信息(区分阶段)
  610 + boolean isSubOrder = Objects.nonNull(appraiseOrder.getParentOrderCode()) ? true : false;
  611 +
  612 + // 点亮信息设置
  613 + expressInfoRespBo.setStage(new AppraiseExpressStageBuilder(appraiseOrder).build());
  614 +
  615 + // 子订单
  616 + if (isSubOrder){
  617 +
  618 + // 寄回物流
  619 + List<Integer> expressTypeList = Arrays.asList(EnumExpressType.EXPRESS_TYPE_2.getCode(),
  620 + EnumExpressType.EXPRESS_TYPE_3.getCode(),
  621 + EnumExpressType.EXPRESS_TYPE_REBACK.getCode());
  622 +
  623 + // 物流单号信息
  624 + constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
  625 +
  626 + // 根据订单号and物流类型 返回物流信息
  627 + List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, expressTypeList);
  628 +
  629 + expressInfoRespBo.setExpressInfoDetailTitle("");
  630 + expressInfoRespBo.setExpressInfoDetailList(expressInfoDetailList);
  631 +
  632 + return expressInfoRespBo;
  633 +
  634 + }
  635 + // 父订单
  636 + else{
  637 +
  638 + List<Integer> expressTypeList = getAppraiseExpressType(appraiseOrder.getStatus());
  639 + if (CollectionUtils.isEmpty(expressTypeList)) {
  640 + LOGGER.info("{}, appraise expressTypeList is empty", orderCode);
  641 + return expressInfoRespBo;
  642 + }
  643 +
  644 + // 物流单号信息
  645 + constructWayBillInfo(orderCode, expressTypeList, expressInfoRespBo);
  646 +
  647 + // 其中是否包含了 鉴定中心内部调拨信息
  648 + if (expressTypeList.contains(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode())){
  649 +
  650 + // 根据订单号and物流类型 返回物流信息
  651 + List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, Lists.newArrayList(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode()));
  652 +
  653 + expressInfoRespBo.setJudgeExpressInfoDetailList(expressInfoDetailList);
  654 + expressInfoRespBo.setJudgeExpressInfoDetailTitle("平台鉴定");
  655 + }
  656 +
  657 + // 根据订单号and物流类型 返回物流信息
  658 + List<ExpressInfoDetail> expressInfoDetailList = getExpressInfoDetailListByOrderCodeExpressType(orderCode, Lists.newArrayList(EnumExpressType.EXPRESS_TYPE_1.getCode()));
  659 +
  660 + expressInfoRespBo.setSupplementExpressInfoDetailTitle("卖家发往平台");
  661 + expressInfoRespBo.setSupplementExpressInfoDetailList(expressInfoDetailList);
  662 +
  663 + return expressInfoRespBo;
  664 +
  665 + }
  666 + }
  667 +
  668 + LOGGER.info("{}, result is {}", orderCode, JSON.toJSONString(expressInfoRespBo));
  669 + return expressInfoRespBo;
  670 + }
  671 +
547 private void constructSupplementExpress(TabType actor, Long orderCode, Integer expressType, ExpressInfoRespBo expressInfoRespBo) { 672 private void constructSupplementExpress(TabType actor, Long orderCode, Integer expressType, ExpressInfoRespBo expressInfoRespBo) {
548 if (EnumExpressType.EXPRESS_TYPE_2.getCode().intValue() == expressType.intValue() 673 if (EnumExpressType.EXPRESS_TYPE_2.getCode().intValue() == expressType.intValue()
549 || EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode().intValue() == expressType.intValue()) { 674 || EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode().intValue() == expressType.intValue()) {
@@ -635,6 +760,30 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -635,6 +760,30 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
635 760
636 } 761 }
637 762
  763 +
  764 + /**
  765 + * 根据状态获取物流类型
  766 + * @param status
  767 + * @return
  768 + */
  769 + private List<Integer> getAppraiseExpressType(Integer status) {
  770 + if (AppraiseOrderStatus.SELLER_SEND_OUT.getCode() == status) {
  771 + return Arrays.asList(EnumExpressType.EXPRESS_TYPE_1.getCode());
  772 + }
  773 + // 这些状态需要展示 平台鉴定
  774 + else if (AppraiseOrderStatus.PLATFORM_RECEIVE.getCode() == status
  775 + || AppraiseOrderStatus.PLATFORM_CHECKING.getCode() == status
  776 + || AppraiseOrderStatus.JUDGE_PASS.getCode() == status
  777 + || AppraiseOrderStatus.WAITING_RECEIVE.getCode() == status
  778 + || AppraiseOrderStatus.CHECKING_FAKE.getCode() == status
  779 + || AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode() == status
  780 + || AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode() == status) {
  781 + return Arrays.asList(EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER.getCode(), EnumExpressType.EXPRESS_TYPE_1.getCode());
  782 + }
  783 + return null;
  784 +
  785 + }
  786 +
638 /* private Integer getCurrentExpressType4ExpressRecordAndSeller(Integer status){ 787 /* private Integer getCurrentExpressType4ExpressRecordAndSeller(Integer status){
639 788
640 Integer type ; 789 Integer type ;
@@ -840,6 +989,25 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -840,6 +989,25 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
840 return "订单跟踪"; 989 return "订单跟踪";
841 } 990 }
842 991
  992 + /**
  993 + * 响应结果类型转换
  994 + * @param expressInfo
  995 + * @return
  996 + */
  997 + private ExpressInfoDetail covertToExpressInfoDetail(ExpressInfo expressInfo){
  998 + ExpressInfoDetail expressInfoDetail = new ExpressInfoDetail();
  999 +
  1000 + // 运单接收地
  1001 + expressInfoDetail.setAcceptAddress(expressInfo.getAcceptAddress());
  1002 + // 运单信息
  1003 + expressInfoDetail.setAcceptRemark(expressInfo.getAcceptRemark());
  1004 + expressInfoDetail.setCreateTimeStr(DateUtil.formatDate(expressInfo.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
  1005 +
  1006 + expressInfoDetail.setState(expressInfo.getState());
  1007 + expressInfoDetail.setExpressType(expressInfo.getExpressType().intValue());
  1008 +
  1009 + return expressInfoDetail;
  1010 + }
843 1011
844 private void constructExpressInfo(TabType actor, List<ExpressInfo> expressInfoList, List<ExpressInfoDetail> detailList) { 1012 private void constructExpressInfo(TabType actor, List<ExpressInfo> expressInfoList, List<ExpressInfoDetail> detailList) {
845 if (CollectionUtils.isNotEmpty(expressInfoList)) { 1013 if (CollectionUtils.isNotEmpty(expressInfoList)) {