pull/1121/head
梁宇奇 2025-05-14 20:49:34 +08:00
parent 6f4544774c
commit bd1abfc7ed
11 changed files with 204 additions and 9 deletions

View File

@ -7,6 +7,7 @@ import com.ruoyi.web.controller.xkt.vo.express.*;
import com.ruoyi.xkt.dto.express.ExpressFeeDTO;
import com.ruoyi.xkt.dto.express.ExpressRegionTreeNodeDTO;
import com.ruoyi.xkt.dto.express.ExpressStructAddressDTO;
import com.ruoyi.xkt.dto.express.ExpressTrackRecordDTO;
import com.ruoyi.xkt.service.IExpressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -15,7 +16,9 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author liangyq
@ -60,4 +63,13 @@ public class ExpressController extends XktBaseController {
return success(BeanUtil.toBean(dto, ExpressStructAddressVO.class));
}
@ApiOperation("查询物流轨迹")
@PostMapping("queryTrackRecord")
public R<Map<String, List<TrackRecordVO>>> queryTrackRecord(@Valid @RequestBody TrackRecordQueryVO vo) {
List<ExpressTrackRecordDTO> list = expressService.listTrackRecord(vo.getExpressWaybillNos());
Map<String, List<TrackRecordVO>> voMap = list.stream().map(o -> BeanUtil.toBean(o, TrackRecordVO.class))
.collect(Collectors.groupingBy(TrackRecordVO::getExpressWaybillNo));
return success(voMap);
}
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.web.controller.xkt.vo.express;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.Date;
import java.util.List;
/**
*
*
* @author liangyq
* @date 2025-05-14
**/
@ApiModel
@Data
public class TrackRecordQueryVO {
@NotEmpty(message = "物流运单号不能为空")
@ApiModelProperty(value = "物流运单号集合")
private List<String> expressWaybillNos;
}

View File

@ -0,0 +1,43 @@
package com.ruoyi.web.controller.xkt.vo.express;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
*
*
* @author liangyq
* @date 2025-04-01 11:57:52.599
**/
@ApiModel
@Data
public class TrackRecordVO {
/**
*
*/
@ApiModelProperty(value = "物流运单号")
private String expressWaybillNo;
/**
*
*/
@ApiModelProperty(value = "节点事件")
private String action;
/**
*
*/
@ApiModelProperty(value = "描述")
private String description;
/**
*
*/
@ApiModelProperty(value = "备注")
private String remark;
/**
*
*/
@ApiModelProperty(value = "时间")
private Date createTime;
}

View File

@ -401,6 +401,12 @@ public class StoreOrderInfoVO {
@ApiModelProperty(value = "商品尺码")
private Integer size;
@ApiModelProperty(value = "退货订单ID")
private Long refundOrderId;
@ApiModelProperty(value = "退货订单号")
private String refundOrderNo;
@ApiModelProperty(value = "退货订单明细ID")
private Long refundOrderDetailId;
@ -410,6 +416,18 @@ public class StoreOrderInfoVO {
@ApiModelProperty(value = "退货商品数量")
private Integer refundGoodsQuantity;
@ApiModelProperty(value = "退货原订单ID")
private Long originOrderId;
@ApiModelProperty(value = "退货原订单号")
private String originOrderNo;
@ApiModelProperty(value = "退货原订单明细状态[10:已取消 11:待付款 12:待发货 13:已发货 14:已完成 21:售后中 22:售后拒绝 23:平台介入 24:售后完成]")
private Integer originOrderDetailStatus;
@ApiModelProperty(value = "退货原商品数量")
private Integer originGoodsQuantity;
}
@ApiModel
@ -425,9 +443,15 @@ public class StoreOrderInfoVO {
@ApiModelProperty(value = "物流名称")
private String expressName;
@ApiModelProperty(value = "商品概要")
private String goodsSummary;
@ApiModelProperty(value = "记录")
private List<Record> records;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModel
@Data
public static class Record {

View File

@ -401,6 +401,12 @@ public class StoreOrderPageItemVO extends StoreOrderDTO {
@ApiModelProperty(value = "商品尺码")
private Integer size;
@ApiModelProperty(value = "退货订单ID")
private Long refundOrderId;
@ApiModelProperty(value = "退货订单号")
private String refundOrderNo;
@ApiModelProperty(value = "退货订单明细ID")
private Long refundOrderDetailId;
@ -409,5 +415,17 @@ public class StoreOrderPageItemVO extends StoreOrderDTO {
@ApiModelProperty(value = "退货商品数量")
private Integer refundGoodsQuantity;
@ApiModelProperty(value = "退货原订单ID")
private Long originOrderId;
@ApiModelProperty(value = "退货原订单号")
private String originOrderNo;
@ApiModelProperty(value = "退货原订单明细状态[10:已取消 11:待付款 12:待发货 13:已发货 14:已完成 21:售后中 22:售后拒绝 23:平台介入 24:售后完成]")
private Integer originOrderDetailStatus;
@ApiModelProperty(value = "退货原商品数量")
private Integer originGoodsQuantity;
}
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.xkt.dto.express;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
@ -24,8 +25,16 @@ public class ExpressTrackDTO {
*
*/
private String expressName;
/**
*
*/
private String goodsSummary;
/**
*
*/
private List<ExpressTrackRecordDTO> records;
/**
*
*/
private Date createTime;
}

View File

@ -15,9 +15,21 @@ public class StoreOrderDetailInfoDTO extends StoreOrderDetailDTO {
private String firstMainPicUrl;
private Long refundOrderId;
private String refundOrderNo;
private Long refundOrderDetailId;
private Integer refundOrderDetailStatus;
private Integer refundGoodsQuantity;
private Long originOrderId;
private String originOrderNo;
private Integer originOrderDetailStatus;
private Integer originGoodsQuantity;
}

View File

@ -1,6 +1,9 @@
package com.ruoyi.xkt.service;
import com.ruoyi.xkt.dto.order.StoreOrderOperationRecordAddDTO;
import com.ruoyi.xkt.dto.order.StoreOrderOperationRecordDTO;
import com.ruoyi.xkt.enums.EOrderAction;
import com.ruoyi.xkt.enums.EOrderTargetTypeAction;
import java.util.List;
@ -17,4 +20,14 @@ public interface IOperationRecordService {
*/
void addOrderOperationRecords(List<StoreOrderOperationRecordAddDTO> recordList);
/**
*
*
* @param targetId
* @param targetType
* @param action
* @return
*/
StoreOrderOperationRecordDTO getOneRecord(Long targetId, EOrderTargetTypeAction targetType, EOrderAction action);
}

View File

@ -2,8 +2,13 @@ package com.ruoyi.xkt.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.ruoyi.xkt.domain.StoreOrderOperationRecord;
import com.ruoyi.xkt.dto.order.StoreOrderOperationRecordAddDTO;
import com.ruoyi.xkt.dto.order.StoreOrderOperationRecordDTO;
import com.ruoyi.xkt.enums.EOrderAction;
import com.ruoyi.xkt.enums.EOrderTargetTypeAction;
import com.ruoyi.xkt.mapper.StoreOrderOperationRecordMapper;
import com.ruoyi.xkt.service.IOperationRecordService;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,4 +37,20 @@ public class OperationRecordServiceImpl implements IOperationRecordService {
storeOrderOperationRecordMapper.batchInsert(list);
}
@Override
public StoreOrderOperationRecordDTO getOneRecord(Long targetId, EOrderTargetTypeAction targetType,
EOrderAction action) {
if (targetId == null || targetType == null || action == null) {
return null;
}
PageHelper.startPage(1, 1, false);
List<StoreOrderOperationRecord> records = storeOrderOperationRecordMapper.selectList(
Wrappers.lambdaQuery(StoreOrderOperationRecord.class)
.eq(StoreOrderOperationRecord::getTargetId, targetId)
.eq(StoreOrderOperationRecord::getTargetType, targetType.getValue())
.eq(StoreOrderOperationRecord::getAction, action.getValue())
);
return BeanUtil.toBean(CollUtil.getFirst(records), StoreOrderOperationRecordDTO.class);
}
}

View File

@ -372,21 +372,31 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
//物流信息
Map<Long, String> expressNameMap = expressService.getAllExpressNameMap();
orderInfo.setExpressName(expressNameMap.get(order.getExpressId()));
Set<String> expressWaybillNos = detailInfos.stream()
Map<String, List<StoreOrderDetailInfoDTO>> expressWaybillGroupMap = detailInfos.stream()
.filter(o -> StrUtil.isNotEmpty(o.getExpressWaybillNo()))
.map(StoreOrderDetailDTO::getExpressWaybillNo)
.collect(Collectors.toSet());
Map<String, List<ExpressTrackRecordDTO>> trackRecordGroupMap = expressService.listTrackRecord(expressWaybillNos)
.collect(Collectors.groupingBy(StoreOrderDetailInfoDTO::getExpressWaybillNo));
Map<String, List<ExpressTrackRecordDTO>> trackRecordGroupMap = expressService.listTrackRecord(
expressWaybillGroupMap.keySet())
.stream()
.collect(Collectors.groupingBy(ExpressTrackRecordDTO::getExpressWaybillNo));
List<ExpressTrackDTO> expressTracks = new ArrayList<>(trackRecordGroupMap.size());
for (Map.Entry<String, List<ExpressTrackRecordDTO>> entry : trackRecordGroupMap.entrySet()) {
List<ExpressTrackDTO> expressTracks = new ArrayList<>(expressWaybillGroupMap.size());
for (Map.Entry<String, List<StoreOrderDetailInfoDTO>> entry : expressWaybillGroupMap.entrySet()) {
ExpressTrackDTO expressTrackDTO = new ExpressTrackDTO();
List<String> goodsSummaries = entry.getValue().stream()
.map(o -> StrUtil.concat(true, o.getProdArtNum(), ", ", o.getColorName(), ", ",
String.valueOf(o.getSize()))).collect(Collectors.toList());
//发货时间
Long detailId = CollUtil.getFirst(entry.getValue()).getId();
StoreOrderOperationRecordDTO shipRecord = operationRecordService.getOneRecord(detailId,
EOrderTargetTypeAction.ORDER_DETAIL, EOrderAction.SHIP);
expressTrackDTO.setCreateTime(Optional.ofNullable(shipRecord)
.map(StoreOrderOperationRecordDTO::getOperationTime).orElse(null));
Long expressId = CollUtil.getFirst(entry.getValue()).getExpressId();
expressTrackDTO.setExpressId(expressId);
expressTrackDTO.setExpressName(expressNameMap.get(expressId));
expressTrackDTO.setExpressWaybillNo(entry.getKey());
expressTrackDTO.setRecords(entry.getValue());
expressTrackDTO.setGoodsSummary(StrUtil.join("; ", goodsSummaries));
expressTrackDTO.setRecords(trackRecordGroupMap.get(entry.getKey()));
expressTracks.add(expressTrackDTO);
}
orderInfo.setExpressTracks(expressTracks);

View File

@ -5,12 +5,21 @@
<select id="listInfoByStoreOrderIds" resultType="com.ruoyi.xkt.dto.order.StoreOrderDetailInfoDTO">
SELECT
sod1.*,
sod2.store_order_id AS refund_order_id,
sod2.id AS refund_order_detail_id,
sod2.detail_status AS refund_order_detail_status,
sod2.goods_quantity AS refund_goods_quantity
sod2.goods_quantity AS refund_goods_quantity,
so2.order_no AS refund_order_no,
sod3.store_order_id AS origin_order_id,
sod3.detail_status AS origin_order_detail_status,
sod3.goods_quantity AS origin_goods_quantity,
so3.order_no AS origin_order_no
FROM
store_order_detail sod1
LEFT JOIN store_order_detail sod2 ON sod1.id = sod2.origin_order_detail_id AND sod2.del_flag = '0'
LEFT JOIN store_order_detail sod2 ON sod1.id = sod2.origin_order_detail_id
LEFT JOIN store_order so2 ON sod2.store_order_id = so2.id
LEFT JOIN store_order_detail sod3 ON sod1.origin_order_detail_id = sod3.id
LEFT JOIN store_order so3 ON sod3.store_order_id = so3.id
WHERE
sod1.del_flag = '0'
AND sod1.store_order_id IN