mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:09:19 +08:00
feat: 店铺增加三侧操作和查看
This commit is contained in:
+117
@@ -0,0 +1,117 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.bi.orderstat.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.po.BiOrderStatFullCalcTaskPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.po.BiOrderStatIncCalcPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.vo.BiOrderStatFullCalcTaskVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.vo.BiOrderStatIncCalcStatusVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.service.BiOrderStatCalcTaskService;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.shop.mapper.ShopMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.shop.model.po.ShopPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BI 订单统计计算控制面查询与人工恢复。
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/bi/order-stat/calc")
|
||||||
|
public class BiOrderStatCalcController {
|
||||||
|
|
||||||
|
private final BiOrderStatCalcTaskService calcTaskService;
|
||||||
|
private final ShopMapper shopMapper;
|
||||||
|
private final CurrentUserContext currentUserContext;
|
||||||
|
|
||||||
|
public BiOrderStatCalcController(BiOrderStatCalcTaskService calcTaskService,
|
||||||
|
ShopMapper shopMapper,
|
||||||
|
CurrentUserContext currentUserContext) {
|
||||||
|
this.calcTaskService = calcTaskService;
|
||||||
|
this.shopMapper = shopMapper;
|
||||||
|
this.currentUserContext = currentUserContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/inc/status")
|
||||||
|
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
|
||||||
|
public ApiResponse<BiOrderStatIncCalcStatusVO> incStatus(@RequestParam Long shopId) {
|
||||||
|
ShopPO shop = requireOwnedShop(shopId);
|
||||||
|
return ApiResponse.success(toIncVo(shop.getId(), calcTaskService.findIncState(shop.getId())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/inc/resume")
|
||||||
|
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
|
||||||
|
public ApiResponse<BiOrderStatIncCalcStatusVO> resumeInc(@RequestParam Long shopId) {
|
||||||
|
ShopPO shop = requireOwnedShop(shopId);
|
||||||
|
BiOrderStatIncCalcPO state = calcTaskService.resumeInc(shop.getCompanyId(), shop.getId());
|
||||||
|
return ApiResponse.success("已恢复计算", toIncVo(shop.getId(), state));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/full-task/list")
|
||||||
|
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
|
||||||
|
public ApiResponse<List<BiOrderStatFullCalcTaskVO>> listFullTasks(
|
||||||
|
@RequestParam Long shopId,
|
||||||
|
@RequestParam(required = false, defaultValue = "20") Integer limit) {
|
||||||
|
ShopPO shop = requireOwnedShop(shopId);
|
||||||
|
List<BiOrderStatFullCalcTaskPO> tasks =
|
||||||
|
calcTaskService.listTasks(shop.getCompanyId(), shop.getId(),
|
||||||
|
limit == null ? 20 : limit);
|
||||||
|
return ApiResponse.success(tasks.stream().map(this::toTaskVo).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShopPO requireOwnedShop(Long shopId) {
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
ShopPO shop = shopMapper.selectOne(new LambdaQueryWrapper<ShopPO>()
|
||||||
|
.eq(ShopPO::getId, shopId)
|
||||||
|
.eq(ShopPO::getCompanyId, companyId)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
if (shop == null) {
|
||||||
|
throw new BusinessException("店铺不存在或无权访问");
|
||||||
|
}
|
||||||
|
return shop;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BiOrderStatIncCalcStatusVO toIncVo(Long shopId, BiOrderStatIncCalcPO state) {
|
||||||
|
if (state == null) {
|
||||||
|
return BiOrderStatIncCalcStatusVO.builder().shopId(shopId).build();
|
||||||
|
}
|
||||||
|
return BiOrderStatIncCalcStatusVO.builder()
|
||||||
|
.shopId(shopId)
|
||||||
|
.status(state.getStatus())
|
||||||
|
.lastSummary(state.getLastSummary())
|
||||||
|
.lastError(state.getLastError())
|
||||||
|
.lastSuccessTime(state.getLastSuccessTime())
|
||||||
|
.lastStatDate(state.getLastStatDate())
|
||||||
|
.lastAppliedOrderId(state.getLastAppliedOrderId())
|
||||||
|
.lastSkipped(state.getLastSkipped())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private BiOrderStatFullCalcTaskVO toTaskVo(BiOrderStatFullCalcTaskPO task) {
|
||||||
|
return BiOrderStatFullCalcTaskVO.builder()
|
||||||
|
.id(task.getId())
|
||||||
|
.shopId(task.getShopId())
|
||||||
|
.upstreamConvertTaskId(task.getUpstreamConvertTaskId())
|
||||||
|
.platformCode(task.getPlatformCode())
|
||||||
|
.dateFrom(task.getDateFrom())
|
||||||
|
.dateTo(task.getDateTo())
|
||||||
|
.currentDate(task.getCurrentDate())
|
||||||
|
.totalDays(task.getTotalDays())
|
||||||
|
.doneDays(task.getDoneDays())
|
||||||
|
.failedDays(task.getFailedDays())
|
||||||
|
.skippedDays(task.getSkippedDays())
|
||||||
|
.status(task.getStatus())
|
||||||
|
.lastError(task.getLastError())
|
||||||
|
.createTime(task.getCreateTime())
|
||||||
|
.finishTime(task.getFinishTime())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/** BI 全量计算任务摘要。 */
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BiOrderStatFullCalcTaskVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long shopId;
|
||||||
|
private Long upstreamConvertTaskId;
|
||||||
|
private String platformCode;
|
||||||
|
private LocalDate dateFrom;
|
||||||
|
private LocalDate dateTo;
|
||||||
|
private LocalDate currentDate;
|
||||||
|
private Integer totalDays;
|
||||||
|
private Integer doneDays;
|
||||||
|
private Integer failedDays;
|
||||||
|
private Integer skippedDays;
|
||||||
|
private String status;
|
||||||
|
private String lastError;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime finishTime;
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/** BI 增量计算店态(HTTP 展示)。 */
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BiOrderStatIncCalcStatusVO {
|
||||||
|
|
||||||
|
private Long shopId;
|
||||||
|
/** 1=正常 2=出错暂停 */
|
||||||
|
private Integer status;
|
||||||
|
private String lastSummary;
|
||||||
|
private String lastError;
|
||||||
|
private LocalDateTime lastSuccessTime;
|
||||||
|
private LocalDate lastStatDate;
|
||||||
|
private Long lastAppliedOrderId;
|
||||||
|
private Integer lastSkipped;
|
||||||
|
}
|
||||||
+34
@@ -24,6 +24,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,6 +163,39 @@ public class BiOrderStatCalcTaskService {
|
|||||||
incCalcMapper.updateById(state);
|
incCalcMapper.updateById(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 增量计算店态;shopId = ec_shop.id。 */
|
||||||
|
public BiOrderStatIncCalcPO findIncState(Long internalShopId) {
|
||||||
|
if (internalShopId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return incCalcMapper.selectOne(new LambdaQueryWrapper<BiOrderStatIncCalcPO>()
|
||||||
|
.eq(BiOrderStatIncCalcPO::getShopId, internalShopId)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 出错暂停后人工恢复。 */
|
||||||
|
public BiOrderStatIncCalcPO resumeInc(Long companyId, Long internalShopId) {
|
||||||
|
BiOrderStatIncCalcPO state = getOrCreateInc(companyId, internalShopId);
|
||||||
|
state.setStatus(BiOrderStatIncCalcPO.STATUS_OK);
|
||||||
|
state.setLastError(null);
|
||||||
|
state.setLastSummary("已恢复计算,等待后续消息");
|
||||||
|
incCalcMapper.updateById(state);
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 全量计算任务列表(内部店)。 */
|
||||||
|
public List<BiOrderStatFullCalcTaskPO> listTasks(Long companyId, Long internalShopId, int limit) {
|
||||||
|
if (companyId == null || internalShopId == null) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
int lim = Math.min(Math.max(limit, 1), 50);
|
||||||
|
return taskMapper.selectList(new LambdaQueryWrapper<BiOrderStatFullCalcTaskPO>()
|
||||||
|
.eq(BiOrderStatFullCalcTaskPO::getCompanyId, companyId)
|
||||||
|
.eq(BiOrderStatFullCalcTaskPO::getShopId, internalShopId)
|
||||||
|
.orderByDesc(BiOrderStatFullCalcTaskPO::getId)
|
||||||
|
.last("LIMIT " + lim));
|
||||||
|
}
|
||||||
|
|
||||||
private void publishFull(Long companyId, Long shopId, String platform, LocalDate day,
|
private void publishFull(Long companyId, Long shopId, String platform, LocalDate day,
|
||||||
String syncBatchId, Long calcTaskId, Long convertTaskId) {
|
String syncBatchId, Long calcTaskId, Long convertTaskId) {
|
||||||
BiFullCalcMessage msg = BiFullCalcMessage.builder()
|
BiFullCalcMessage msg = BiFullCalcMessage.builder()
|
||||||
|
|||||||
+100
@@ -0,0 +1,100 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.model.po.PddOrderFullConvertTaskPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.model.po.PddOrderIncConvertPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.model.vo.PddOrderConvertIncStatusVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.model.vo.PddOrderFullConvertTaskVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.service.PddOrderFullConvertTaskService;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.PddOrderSyncShopContext;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.service.PddOrderSyncContextResolver;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼多多订单转换控制面查询与人工恢复。
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/channel/pdd/order/convert")
|
||||||
|
public class PddOrderConvertController {
|
||||||
|
|
||||||
|
private final PddOrderFullConvertTaskService convertTaskService;
|
||||||
|
private final PddOrderSyncContextResolver contextResolver;
|
||||||
|
|
||||||
|
public PddOrderConvertController(PddOrderFullConvertTaskService convertTaskService,
|
||||||
|
PddOrderSyncContextResolver contextResolver) {
|
||||||
|
this.convertTaskService = convertTaskService;
|
||||||
|
this.contextResolver = contextResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/inc/status")
|
||||||
|
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
|
||||||
|
public ApiResponse<PddOrderConvertIncStatusVO> incStatus(@RequestParam Long shopId) {
|
||||||
|
PddOrderSyncShopContext ctx = contextResolver.resolveForCurrentCompany(shopId);
|
||||||
|
return ApiResponse.success(toIncVo(ctx.getInternalShopId(),
|
||||||
|
convertTaskService.findIncState(ctx.getShopId())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/inc/resume")
|
||||||
|
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
|
||||||
|
public ApiResponse<PddOrderConvertIncStatusVO> resumeInc(@RequestParam Long shopId) {
|
||||||
|
PddOrderSyncShopContext ctx = contextResolver.resolveForCurrentCompany(shopId);
|
||||||
|
PddOrderIncConvertPO state = convertTaskService.resumeInc(ctx.getShopId(), ctx.getCompanyId());
|
||||||
|
return ApiResponse.success("已恢复转换", toIncVo(ctx.getInternalShopId(), state));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/full-task/list")
|
||||||
|
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
|
||||||
|
public ApiResponse<List<PddOrderFullConvertTaskVO>> listFullTasks(
|
||||||
|
@RequestParam Long shopId,
|
||||||
|
@RequestParam(required = false, defaultValue = "20") Integer limit) {
|
||||||
|
PddOrderSyncShopContext ctx = contextResolver.resolveForCurrentCompany(shopId);
|
||||||
|
List<PddOrderFullConvertTaskPO> tasks =
|
||||||
|
convertTaskService.listTasks(ctx.getShopId(), ctx.getCompanyId(),
|
||||||
|
limit == null ? 20 : limit);
|
||||||
|
return ApiResponse.success(tasks.stream()
|
||||||
|
.map(t -> toTaskVo(ctx.getInternalShopId(), t))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PddOrderConvertIncStatusVO toIncVo(Long apiShopId, PddOrderIncConvertPO state) {
|
||||||
|
if (state == null) {
|
||||||
|
return PddOrderConvertIncStatusVO.builder().shopId(apiShopId).build();
|
||||||
|
}
|
||||||
|
return PddOrderConvertIncStatusVO.builder()
|
||||||
|
.shopId(apiShopId)
|
||||||
|
.status(state.getStatus())
|
||||||
|
.lastSummary(state.getLastSummary())
|
||||||
|
.lastError(state.getLastError())
|
||||||
|
.lastSuccessTime(state.getLastSuccessTime())
|
||||||
|
.lastCursorAt(state.getLastCursorAt())
|
||||||
|
.lastConvertedCount(state.getLastConvertedCount())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PddOrderFullConvertTaskVO toTaskVo(Long apiShopId, PddOrderFullConvertTaskPO task) {
|
||||||
|
return PddOrderFullConvertTaskVO.builder()
|
||||||
|
.id(task.getId())
|
||||||
|
.shopId(apiShopId)
|
||||||
|
.syncTaskId(task.getSyncTaskId())
|
||||||
|
.dateFrom(task.getDateFrom())
|
||||||
|
.dateTo(task.getDateTo())
|
||||||
|
.currentDate(task.getCurrentDate())
|
||||||
|
.totalDays(task.getTotalDays())
|
||||||
|
.doneDays(task.getDoneDays())
|
||||||
|
.failedDays(task.getFailedDays())
|
||||||
|
.skippedDays(task.getSkippedDays())
|
||||||
|
.status(task.getStatus())
|
||||||
|
.lastError(task.getLastError())
|
||||||
|
.createTime(task.getCreateTime())
|
||||||
|
.finishTime(task.getFinishTime())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.model.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/** 增量转换店态(HTTP 展示)。 */
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PddOrderConvertIncStatusVO {
|
||||||
|
|
||||||
|
private Long shopId;
|
||||||
|
/** 1=正常 2=出错暂停 */
|
||||||
|
private Integer status;
|
||||||
|
private String lastSummary;
|
||||||
|
private String lastError;
|
||||||
|
private LocalDateTime lastSuccessTime;
|
||||||
|
private LocalDateTime lastCursorAt;
|
||||||
|
private Integer lastConvertedCount;
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.model.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/** 全量转换任务摘要。 */
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PddOrderFullConvertTaskVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long shopId;
|
||||||
|
private Long syncTaskId;
|
||||||
|
private LocalDate dateFrom;
|
||||||
|
private LocalDate dateTo;
|
||||||
|
private LocalDate currentDate;
|
||||||
|
private Integer totalDays;
|
||||||
|
private Integer doneDays;
|
||||||
|
private Integer failedDays;
|
||||||
|
private Integer skippedDays;
|
||||||
|
private String status;
|
||||||
|
private String lastError;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime finishTime;
|
||||||
|
}
|
||||||
+33
@@ -209,6 +209,39 @@ public class PddOrderFullConvertTaskService {
|
|||||||
return convertTaskId == null ? null : taskMapper.selectById(convertTaskId);
|
return convertTaskId == null ? null : taskMapper.selectById(convertTaskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 增量转换店态;channelShopId = channel_pdd_shop.id。 */
|
||||||
|
public PddOrderIncConvertPO findIncState(Long channelShopId) {
|
||||||
|
if (channelShopId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return incConvertMapper.selectOne(new LambdaQueryWrapper<PddOrderIncConvertPO>()
|
||||||
|
.eq(PddOrderIncConvertPO::getShopId, channelShopId)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 出错暂停后人工恢复,允许后续 INC 继续消费。 */
|
||||||
|
public PddOrderIncConvertPO resumeInc(Long channelShopId, Long companyId) {
|
||||||
|
PddOrderIncConvertPO state = getOrCreateInc(channelShopId, companyId);
|
||||||
|
state.setStatus(PddOrderIncConvertPO.STATUS_OK);
|
||||||
|
state.setLastError(null);
|
||||||
|
state.setLastSummary("已恢复转换,等待后续消息");
|
||||||
|
incConvertMapper.updateById(state);
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 全量转换任务列表(渠道店)。 */
|
||||||
|
public List<PddOrderFullConvertTaskPO> listTasks(Long channelShopId, Long companyId, int limit) {
|
||||||
|
if (channelShopId == null || companyId == null) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
int lim = Math.min(Math.max(limit, 1), 50);
|
||||||
|
return taskMapper.selectList(new LambdaQueryWrapper<PddOrderFullConvertTaskPO>()
|
||||||
|
.eq(PddOrderFullConvertTaskPO::getCompanyId, companyId)
|
||||||
|
.eq(PddOrderFullConvertTaskPO::getShopId, channelShopId)
|
||||||
|
.orderByDesc(PddOrderFullConvertTaskPO::getId)
|
||||||
|
.last("LIMIT " + lim));
|
||||||
|
}
|
||||||
|
|
||||||
private PddOrderFullConvertTaskPO createForSyncTask(PddOrderFullSyncTaskPO syncTask) {
|
private PddOrderFullConvertTaskPO createForSyncTask(PddOrderFullSyncTaskPO syncTask) {
|
||||||
int totalDays = syncTask.getTotalDays() != null
|
int totalDays = syncTask.getTotalDays() != null
|
||||||
? syncTask.getTotalDays()
|
? syncTask.getTotalDays()
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管线单阶段店态(转换 / BI;同步侧全量成功时间也挂在 ShopStatus)。
|
||||||
|
* lastSuccessTime = 最近增量成功;lastFullSuccessTime = 最近一次 SUCCESS 全量 finish_time。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PddOrderPipelineIncStageVO {
|
||||||
|
|
||||||
|
/** 1=正常 2=出错暂停;无记录时为 null */
|
||||||
|
private Integer status;
|
||||||
|
/** 最后一次该阶段摘要 */
|
||||||
|
private String lastSummary;
|
||||||
|
/** 最近增量成功时间 */
|
||||||
|
private LocalDateTime lastSuccessTime;
|
||||||
|
/** 最近一次全量任务成功结束时间(status=SUCCESS 的 finish_time) */
|
||||||
|
private LocalDateTime lastFullSuccessTime;
|
||||||
|
}
|
||||||
+10
-1
@@ -5,6 +5,8 @@ import lombok.Builder;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -12,7 +14,14 @@ import lombok.NoArgsConstructor;
|
|||||||
public class PddOrderSyncShopStatusVO {
|
public class PddOrderSyncShopStatusVO {
|
||||||
|
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
/** 进行中优先,否则最近一次全量任务;无则为 null */
|
/** 进行中优先,否则最近一次全量任务;无则为 null(列表左侧进度用) */
|
||||||
private PddOrderFullSyncTaskVO fullTask;
|
private PddOrderFullSyncTaskVO fullTask;
|
||||||
|
/** 最近一次全量同步 SUCCESS 的 finish_time(与 fullTask 可能不是同一条) */
|
||||||
|
private LocalDateTime lastFullSyncSuccessTime;
|
||||||
|
/** 增量同步店态 */
|
||||||
private PddOrderIncrementalStatusVO incremental;
|
private PddOrderIncrementalStatusVO incremental;
|
||||||
|
/** 增量转换店态(含最近全量转换成功时间) */
|
||||||
|
private PddOrderPipelineIncStageVO convert;
|
||||||
|
/** 增量 BI 计算店态(含最近全量计算成功时间) */
|
||||||
|
private PddOrderPipelineIncStageVO calc;
|
||||||
}
|
}
|
||||||
|
|||||||
+146
@@ -8,6 +8,14 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.transaction.support.TransactionSynchronization;
|
import org.springframework.transaction.support.TransactionSynchronization;
|
||||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.mapper.BiOrderStatFullCalcTaskMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.mapper.BiOrderStatIncCalcMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.po.BiOrderStatFullCalcTaskPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.po.BiOrderStatIncCalcPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.mapper.PddOrderFullConvertTaskMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.mapper.PddOrderIncConvertMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.model.po.PddOrderFullConvertTaskPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.model.po.PddOrderIncConvertPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.service.PddOrderFullConvertTaskService;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.service.PddOrderFullConvertTaskService;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.config.PddOrderSyncProperties;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.config.PddOrderSyncProperties;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.mapper.PddOrderFullSyncTaskDayMapper;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.mapper.PddOrderFullSyncTaskDayMapper;
|
||||||
@@ -22,6 +30,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.po.PddOrde
|
|||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.vo.PddOrderFullSyncTaskVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.vo.PddOrderFullSyncTaskVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.vo.PddOrderIncrementalStatusVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.vo.PddOrderIncrementalStatusVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.vo.PddOrderPipelineIncStageVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.vo.PddOrderSyncShopStatusVO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.sync.model.vo.PddOrderSyncShopStatusVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.mapper.PddShopMapper;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.mapper.PddShopMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.model.po.PddShopPO;
|
import top.xyquan.ecomdmbbackend.modules.channel.pdd.shop.model.po.PddShopPO;
|
||||||
@@ -65,6 +74,10 @@ public class PddOrderFullSyncTaskService {
|
|||||||
private final CurrentUserContext currentUserContext;
|
private final CurrentUserContext currentUserContext;
|
||||||
private final PddOrderFullSyncProgressPublisher progressPublisher;
|
private final PddOrderFullSyncProgressPublisher progressPublisher;
|
||||||
private final PddOrderFullConvertTaskService fullConvertTaskService;
|
private final PddOrderFullConvertTaskService fullConvertTaskService;
|
||||||
|
private final PddOrderIncConvertMapper incConvertMapper;
|
||||||
|
private final PddOrderFullConvertTaskMapper fullConvertTaskMapper;
|
||||||
|
private final BiOrderStatIncCalcMapper biIncCalcMapper;
|
||||||
|
private final BiOrderStatFullCalcTaskMapper biFullCalcTaskMapper;
|
||||||
|
|
||||||
/** 全量任务可选日历天数(含起止日,对齐 POP「近三个月」) */
|
/** 全量任务可选日历天数(含起止日,对齐 POP「近三个月」) */
|
||||||
public static final int FULL_SYNC_MAX_CALENDAR_DAYS = 90;
|
public static final int FULL_SYNC_MAX_CALENDAR_DAYS = 90;
|
||||||
@@ -284,7 +297,15 @@ public class PddOrderFullSyncTaskService {
|
|||||||
Set<Long> channelIds = new HashSet<>(ecToChannel.values());
|
Set<Long> channelIds = new HashSet<>(ecToChannel.values());
|
||||||
|
|
||||||
Map<Long, PddOrderFullSyncTaskPO> latestByChannel = loadLatestTasksByShop(companyId, channelIds);
|
Map<Long, PddOrderFullSyncTaskPO> latestByChannel = loadLatestTasksByShop(companyId, channelIds);
|
||||||
|
Map<Long, LocalDateTime> lastFullSyncOkByChannel =
|
||||||
|
loadLastSuccessFinishByChannelShop(companyId, channelIds, false);
|
||||||
Map<Long, PddOrderIncSyncPO> incByChannel = loadIncStatesByShop(channelIds);
|
Map<Long, PddOrderIncSyncPO> incByChannel = loadIncStatesByShop(channelIds);
|
||||||
|
Map<Long, PddOrderIncConvertPO> convertByChannel = loadIncConvertByChannel(channelIds);
|
||||||
|
Map<Long, LocalDateTime> lastFullConvertOkByChannel =
|
||||||
|
loadLastSuccessFinishByChannelShop(companyId, channelIds, true);
|
||||||
|
Map<Long, BiOrderStatIncCalcPO> calcByEc = loadIncCalcByEcShop(owned);
|
||||||
|
Map<Long, LocalDateTime> lastFullCalcOkByEc =
|
||||||
|
loadLastSuccessFinishByEcShop(companyId, owned);
|
||||||
|
|
||||||
List<PddOrderSyncShopStatusVO> result = new ArrayList<>();
|
List<PddOrderSyncShopStatusVO> result = new ArrayList<>();
|
||||||
for (Long shopId : distinctIds) {
|
for (Long shopId : distinctIds) {
|
||||||
@@ -295,12 +316,23 @@ public class PddOrderFullSyncTaskService {
|
|||||||
PddShopPO channelShop = channelByEc.get(shopId);
|
PddShopPO channelShop = channelByEc.get(shopId);
|
||||||
PddOrderFullSyncTaskPO full = channelId == null ? null : latestByChannel.get(channelId);
|
PddOrderFullSyncTaskPO full = channelId == null ? null : latestByChannel.get(channelId);
|
||||||
PddOrderIncSyncPO inc = channelId == null ? null : incByChannel.get(channelId);
|
PddOrderIncSyncPO inc = channelId == null ? null : incByChannel.get(channelId);
|
||||||
|
PddOrderIncConvertPO convert = channelId == null ? null : convertByChannel.get(channelId);
|
||||||
|
BiOrderStatIncCalcPO calc = calcByEc.get(shopId);
|
||||||
boolean enabled = channelShop != null
|
boolean enabled = channelShop != null
|
||||||
&& Integer.valueOf(1).equals(channelShop.getOrderIncSyncEnabled());
|
&& Integer.valueOf(1).equals(channelShop.getOrderIncSyncEnabled());
|
||||||
result.add(PddOrderSyncShopStatusVO.builder()
|
result.add(PddOrderSyncShopStatusVO.builder()
|
||||||
.shopId(shopId)
|
.shopId(shopId)
|
||||||
.fullTask(full == null ? null : toVo(full, shopId))
|
.fullTask(full == null ? null : toVo(full, shopId))
|
||||||
|
.lastFullSyncSuccessTime(channelId == null ? null : lastFullSyncOkByChannel.get(channelId))
|
||||||
.incremental(toIncVo(shopId, enabled, inc))
|
.incremental(toIncVo(shopId, enabled, inc))
|
||||||
|
.convert(toPipelineStage(convert != null ? convert.getStatus() : null,
|
||||||
|
convert != null ? convert.getLastSummary() : null,
|
||||||
|
convert != null ? convert.getLastSuccessTime() : null,
|
||||||
|
channelId == null ? null : lastFullConvertOkByChannel.get(channelId)))
|
||||||
|
.calc(toPipelineStage(calc != null ? calc.getStatus() : null,
|
||||||
|
calc != null ? calc.getLastSummary() : null,
|
||||||
|
calc != null ? calc.getLastSuccessTime() : null,
|
||||||
|
lastFullCalcOkByEc.get(shopId)))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -425,6 +457,120 @@ public class PddOrderFullSyncTaskService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** key = channel_pdd_shop.id */
|
||||||
|
private Map<Long, PddOrderIncConvertPO> loadIncConvertByChannel(Set<Long> channelShopIds) {
|
||||||
|
Map<Long, PddOrderIncConvertPO> map = new HashMap<>();
|
||||||
|
if (channelShopIds == null || channelShopIds.isEmpty()) {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
List<PddOrderIncConvertPO> states = incConvertMapper.selectList(new LambdaQueryWrapper<PddOrderIncConvertPO>()
|
||||||
|
.in(PddOrderIncConvertPO::getShopId, channelShopIds));
|
||||||
|
for (PddOrderIncConvertPO state : states) {
|
||||||
|
if (state.getShopId() != null) {
|
||||||
|
map.putIfAbsent(state.getShopId(), state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** key = ec_shop.id */
|
||||||
|
private Map<Long, BiOrderStatIncCalcPO> loadIncCalcByEcShop(Set<Long> ecShopIds) {
|
||||||
|
Map<Long, BiOrderStatIncCalcPO> map = new HashMap<>();
|
||||||
|
if (ecShopIds == null || ecShopIds.isEmpty()) {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
List<BiOrderStatIncCalcPO> states = biIncCalcMapper.selectList(new LambdaQueryWrapper<BiOrderStatIncCalcPO>()
|
||||||
|
.in(BiOrderStatIncCalcPO::getShopId, ecShopIds));
|
||||||
|
for (BiOrderStatIncCalcPO state : states) {
|
||||||
|
if (state.getShopId() != null) {
|
||||||
|
map.putIfAbsent(state.getShopId(), state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PddOrderPipelineIncStageVO toPipelineStage(Integer status, String lastSummary,
|
||||||
|
LocalDateTime lastSuccessTime,
|
||||||
|
LocalDateTime lastFullSuccessTime) {
|
||||||
|
if (status == null
|
||||||
|
&& (lastSummary == null || lastSummary.isBlank())
|
||||||
|
&& lastSuccessTime == null
|
||||||
|
&& lastFullSuccessTime == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return PddOrderPipelineIncStageVO.builder()
|
||||||
|
.status(status)
|
||||||
|
.lastSummary(lastSummary)
|
||||||
|
.lastSuccessTime(lastSuccessTime)
|
||||||
|
.lastFullSuccessTime(lastFullSuccessTime)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道店维度:最近一次 SUCCESS 全量任务的 finish_time(同步 / 转换)。
|
||||||
|
*/
|
||||||
|
private Map<Long, LocalDateTime> loadLastSuccessFinishByChannelShop(
|
||||||
|
Long companyId, Set<Long> channelShopIds,
|
||||||
|
boolean convertTask) {
|
||||||
|
Map<Long, LocalDateTime> map = new HashMap<>();
|
||||||
|
if (channelShopIds == null || channelShopIds.isEmpty()) {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
if (convertTask) {
|
||||||
|
List<PddOrderFullConvertTaskPO> tasks = fullConvertTaskMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<PddOrderFullConvertTaskPO>()
|
||||||
|
.eq(PddOrderFullConvertTaskPO::getCompanyId, companyId)
|
||||||
|
.in(PddOrderFullConvertTaskPO::getShopId, channelShopIds)
|
||||||
|
.eq(PddOrderFullConvertTaskPO::getStatus, PddOrderFullConvertTaskPO.STATUS_SUCCESS)
|
||||||
|
.isNotNull(PddOrderFullConvertTaskPO::getFinishTime)
|
||||||
|
.orderByDesc(PddOrderFullConvertTaskPO::getFinishTime)
|
||||||
|
.orderByDesc(PddOrderFullConvertTaskPO::getId));
|
||||||
|
for (PddOrderFullConvertTaskPO task : tasks) {
|
||||||
|
if (task.getShopId() != null) {
|
||||||
|
map.putIfAbsent(task.getShopId(), task.getFinishTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
List<PddOrderFullSyncTaskPO> tasks = taskMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<PddOrderFullSyncTaskPO>()
|
||||||
|
.eq(PddOrderFullSyncTaskPO::getCompanyId, companyId)
|
||||||
|
.in(PddOrderFullSyncTaskPO::getShopId, channelShopIds)
|
||||||
|
.eq(PddOrderFullSyncTaskPO::getStatus, PddOrderFullSyncTaskPO.STATUS_SUCCESS)
|
||||||
|
.isNotNull(PddOrderFullSyncTaskPO::getFinishTime)
|
||||||
|
.orderByDesc(PddOrderFullSyncTaskPO::getFinishTime)
|
||||||
|
.orderByDesc(PddOrderFullSyncTaskPO::getId));
|
||||||
|
for (PddOrderFullSyncTaskPO task : tasks) {
|
||||||
|
if (task.getShopId() != null) {
|
||||||
|
map.putIfAbsent(task.getShopId(), task.getFinishTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 内部店维度:最近一次 SUCCESS 全量 BI 的 finish_time。 */
|
||||||
|
private Map<Long, LocalDateTime> loadLastSuccessFinishByEcShop(
|
||||||
|
Long companyId, Set<Long> ecShopIds) {
|
||||||
|
Map<Long, LocalDateTime> map = new HashMap<>();
|
||||||
|
if (ecShopIds == null || ecShopIds.isEmpty()) {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
List<BiOrderStatFullCalcTaskPO> tasks = biFullCalcTaskMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<BiOrderStatFullCalcTaskPO>()
|
||||||
|
.eq(BiOrderStatFullCalcTaskPO::getCompanyId, companyId)
|
||||||
|
.in(BiOrderStatFullCalcTaskPO::getShopId, ecShopIds)
|
||||||
|
.eq(BiOrderStatFullCalcTaskPO::getStatus, BiOrderStatFullCalcTaskPO.STATUS_SUCCESS)
|
||||||
|
.isNotNull(BiOrderStatFullCalcTaskPO::getFinishTime)
|
||||||
|
.orderByDesc(BiOrderStatFullCalcTaskPO::getFinishTime)
|
||||||
|
.orderByDesc(BiOrderStatFullCalcTaskPO::getId));
|
||||||
|
for (BiOrderStatFullCalcTaskPO task : tasks) {
|
||||||
|
if (task.getShopId() != null) {
|
||||||
|
map.putIfAbsent(task.getShopId(), task.getFinishTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
private PddOrderIncSyncPO findIncState(Long shopId) {
|
private PddOrderIncSyncPO findIncState(Long shopId) {
|
||||||
return incSyncMapper.selectOne(new LambdaQueryWrapper<PddOrderIncSyncPO>()
|
return incSyncMapper.selectOne(new LambdaQueryWrapper<PddOrderIncSyncPO>()
|
||||||
.eq(PddOrderIncSyncPO::getShopId, shopId)
|
.eq(PddOrderIncSyncPO::getShopId, shopId)
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import type { BiOrderStatCalcVO } from './types';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export async function getBiOrderStatIncCalcStatusApi(shopId: number) {
|
||||||
|
return requestClient.get<BiOrderStatCalcVO.IncStatus>(
|
||||||
|
'/bi/order-stat/calc/inc/status',
|
||||||
|
{ params: { shopId } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resumeBiOrderStatIncCalcApi(shopId: number) {
|
||||||
|
return requestClient.post<BiOrderStatCalcVO.IncStatus>(
|
||||||
|
'/bi/order-stat/calc/inc/resume',
|
||||||
|
undefined,
|
||||||
|
{ params: { shopId } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listBiOrderStatFullCalcTasksApi(
|
||||||
|
shopId: number,
|
||||||
|
limit = 20,
|
||||||
|
) {
|
||||||
|
return requestClient.get<BiOrderStatCalcVO.FullTask[]>(
|
||||||
|
'/bi/order-stat/calc/full-task/list',
|
||||||
|
{ params: { shopId, limit } },
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './apis';
|
||||||
|
export type * from './types';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export type * from './types.vo';
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
export namespace BiOrderStatCalcVO {
|
||||||
|
export interface IncStatus {
|
||||||
|
shopId: number;
|
||||||
|
status?: number;
|
||||||
|
lastSummary?: string;
|
||||||
|
lastError?: string;
|
||||||
|
lastSuccessTime?: string;
|
||||||
|
lastStatDate?: string;
|
||||||
|
lastAppliedOrderId?: number;
|
||||||
|
lastSkipped?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FullTask {
|
||||||
|
id: number;
|
||||||
|
shopId: number;
|
||||||
|
upstreamConvertTaskId?: number;
|
||||||
|
platformCode?: string;
|
||||||
|
dateFrom: string;
|
||||||
|
dateTo: string;
|
||||||
|
currentDate?: string;
|
||||||
|
totalDays: number;
|
||||||
|
doneDays: number;
|
||||||
|
failedDays: number;
|
||||||
|
skippedDays?: number;
|
||||||
|
status: string;
|
||||||
|
lastError?: string;
|
||||||
|
createTime?: string;
|
||||||
|
finishTime?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import type { PddOrderConvertVO } from './types';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export async function getPddOrderConvertIncStatusApi(shopId: number) {
|
||||||
|
return requestClient.get<PddOrderConvertVO.IncStatus>(
|
||||||
|
'/channel/pdd/order/convert/inc/status',
|
||||||
|
{ params: { shopId } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resumePddOrderConvertIncApi(shopId: number) {
|
||||||
|
return requestClient.post<PddOrderConvertVO.IncStatus>(
|
||||||
|
'/channel/pdd/order/convert/inc/resume',
|
||||||
|
undefined,
|
||||||
|
{ params: { shopId } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listPddOrderConvertFullTasksApi(
|
||||||
|
shopId: number,
|
||||||
|
limit = 20,
|
||||||
|
) {
|
||||||
|
return requestClient.get<PddOrderConvertVO.FullTask[]>(
|
||||||
|
'/channel/pdd/order/convert/full-task/list',
|
||||||
|
{ params: { shopId, limit } },
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './apis';
|
||||||
|
export type * from './types';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export type * from './types.vo';
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
export namespace PddOrderConvertVO {
|
||||||
|
export interface IncStatus {
|
||||||
|
shopId: number;
|
||||||
|
status?: number;
|
||||||
|
lastSummary?: string;
|
||||||
|
lastError?: string;
|
||||||
|
lastSuccessTime?: string;
|
||||||
|
lastCursorAt?: string;
|
||||||
|
lastConvertedCount?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FullTask {
|
||||||
|
id: number;
|
||||||
|
shopId: number;
|
||||||
|
syncTaskId?: number;
|
||||||
|
dateFrom: string;
|
||||||
|
dateTo: string;
|
||||||
|
currentDate?: string;
|
||||||
|
totalDays: number;
|
||||||
|
doneDays: number;
|
||||||
|
failedDays: number;
|
||||||
|
skippedDays?: number;
|
||||||
|
status: string;
|
||||||
|
lastError?: string;
|
||||||
|
createTime?: string;
|
||||||
|
finishTime?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,9 +42,22 @@ export namespace PddOrderSyncVO {
|
|||||||
health?: IncHealth;
|
health?: IncHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PipelineIncStage {
|
||||||
|
status?: number;
|
||||||
|
lastSummary?: string;
|
||||||
|
/** 最近增量成功 */
|
||||||
|
lastSuccessTime?: string;
|
||||||
|
/** 最近一次全量 SUCCESS 的 finish_time */
|
||||||
|
lastFullSuccessTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ShopStatus {
|
export interface ShopStatus {
|
||||||
shopId: number;
|
shopId: number;
|
||||||
fullTask?: null | FullTask;
|
fullTask?: null | FullTask;
|
||||||
|
/** 最近一次全量同步 SUCCESS 的 finish_time */
|
||||||
|
lastFullSyncSuccessTime?: string;
|
||||||
incremental?: IncrementalStatus;
|
incremental?: IncrementalStatus;
|
||||||
|
convert?: null | PipelineIncStage;
|
||||||
|
calc?: null | PipelineIncStage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+254
@@ -0,0 +1,254 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ShopVO } from '#/api/ec/shop/types';
|
||||||
|
import type { BiOrderStatCalcVO } from '#/api/bi/order-stat-calc';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Descriptions,
|
||||||
|
Empty,
|
||||||
|
List,
|
||||||
|
Modal,
|
||||||
|
Progress,
|
||||||
|
Space,
|
||||||
|
Tag,
|
||||||
|
Typography,
|
||||||
|
message,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getBiOrderStatIncCalcStatusApi,
|
||||||
|
listBiOrderStatFullCalcTasksApi,
|
||||||
|
resumeBiOrderStatIncCalcApi,
|
||||||
|
} from '#/api/bi/order-stat-calc';
|
||||||
|
|
||||||
|
defineOptions({ name: 'BiOrderStatCalcModal' });
|
||||||
|
|
||||||
|
const emit = defineEmits<{ success: [] }>();
|
||||||
|
|
||||||
|
const openFlag = ref(false);
|
||||||
|
const shop = ref<null | ShopVO.Info>(null);
|
||||||
|
const loading = ref(false);
|
||||||
|
const listLoading = ref(false);
|
||||||
|
const resuming = ref(false);
|
||||||
|
const incremental = ref<null | BiOrderStatCalcVO.IncStatus>(null);
|
||||||
|
const fullTasks = ref<BiOrderStatCalcVO.FullTask[]>([]);
|
||||||
|
|
||||||
|
const title = computed(() =>
|
||||||
|
shop.value ? `BI 计算 - ${shop.value.name}` : 'BI 计算',
|
||||||
|
);
|
||||||
|
|
||||||
|
const statusLabel = computed(() => {
|
||||||
|
const s = incremental.value?.status;
|
||||||
|
if (s === 2) return '出错暂停';
|
||||||
|
if (s === 1) return '正常';
|
||||||
|
return '未开始';
|
||||||
|
});
|
||||||
|
|
||||||
|
const statusColor = computed(() => {
|
||||||
|
const s = incremental.value?.status;
|
||||||
|
if (s === 2) return 'error';
|
||||||
|
if (s === 1) return 'success';
|
||||||
|
return 'default';
|
||||||
|
});
|
||||||
|
|
||||||
|
function formatTime(time?: null | string) {
|
||||||
|
if (!time) return '-';
|
||||||
|
const d = dayjs(time);
|
||||||
|
return d.isValid() ? d.format('YYYY-MM-DD HH:mm:ss') : '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusTag(status: string) {
|
||||||
|
const map: Record<string, { color: string; text: string }> = {
|
||||||
|
PENDING: { color: 'default', text: '等待中' },
|
||||||
|
RUNNING: { color: 'processing', text: '执行中' },
|
||||||
|
SUCCESS: { color: 'success', text: '成功' },
|
||||||
|
FAILED: { color: 'error', text: '失败' },
|
||||||
|
CANCELLED: { color: 'warning', text: '已取消' },
|
||||||
|
};
|
||||||
|
return map[status] || { color: 'default', text: status };
|
||||||
|
}
|
||||||
|
|
||||||
|
function taskProgressPercent(task: BiOrderStatCalcVO.FullTask) {
|
||||||
|
if (!task.totalDays) return 0;
|
||||||
|
return Math.min(100, Math.round((task.doneDays / task.totalDays) * 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadInc() {
|
||||||
|
if (!shop.value) return;
|
||||||
|
try {
|
||||||
|
incremental.value = await getBiOrderStatIncCalcStatusApi(shop.value.id);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载 BI 计算店态失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadFullTasks() {
|
||||||
|
if (!shop.value) return;
|
||||||
|
try {
|
||||||
|
listLoading.value = true;
|
||||||
|
fullTasks.value = await listBiOrderStatFullCalcTasksApi(shop.value.id, 30);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载全量计算任务失败:', error);
|
||||||
|
} finally {
|
||||||
|
listLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleResume() {
|
||||||
|
if (!shop.value) return;
|
||||||
|
try {
|
||||||
|
resuming.value = true;
|
||||||
|
incremental.value = await resumeBiOrderStatIncCalcApi(shop.value.id);
|
||||||
|
message.success('已恢复计算');
|
||||||
|
emit('success');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('恢复计算失败:', error);
|
||||||
|
message.error('恢复计算失败');
|
||||||
|
} finally {
|
||||||
|
resuming.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
openFlag.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function open(record: ShopVO.Info) {
|
||||||
|
shop.value = record;
|
||||||
|
incremental.value = null;
|
||||||
|
fullTasks.value = [];
|
||||||
|
openFlag.value = true;
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
await Promise.all([loadInc(), loadFullTasks()]);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open, close: handleClose });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal
|
||||||
|
v-model:open="openFlag"
|
||||||
|
:title="title"
|
||||||
|
:width="720"
|
||||||
|
:footer="null"
|
||||||
|
destroy-on-close
|
||||||
|
@cancel="handleClose"
|
||||||
|
>
|
||||||
|
<Space direction="vertical" :size="16" class="w-full">
|
||||||
|
<Card size="small">
|
||||||
|
<template #title>
|
||||||
|
<Space>
|
||||||
|
<span>增量计算</span>
|
||||||
|
<Tag :color="statusColor">{{ statusLabel }}</Tag>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
<template #extra>
|
||||||
|
<Button
|
||||||
|
v-if="incremental?.status === 2"
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
:loading="resuming"
|
||||||
|
@click="handleResume"
|
||||||
|
>
|
||||||
|
恢复运行
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<Space direction="vertical" :size="12" class="w-full">
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
将转换侧 delta 累加到 BI 日汇聚;出错暂停后需人工恢复。
|
||||||
|
</Typography.Text>
|
||||||
|
<Descriptions bordered size="small" :column="1">
|
||||||
|
<Descriptions.Item label="上次成功">
|
||||||
|
{{ formatTime(incremental?.lastSuccessTime) }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="最近统计日">
|
||||||
|
{{ incremental?.lastStatDate || '-' }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="最近订单">
|
||||||
|
{{
|
||||||
|
incremental?.lastAppliedOrderId
|
||||||
|
? `#${incremental.lastAppliedOrderId}`
|
||||||
|
: '-'
|
||||||
|
}}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
<Alert
|
||||||
|
v-if="incremental?.lastSummary"
|
||||||
|
:type="incremental?.status === 2 ? 'error' : 'info'"
|
||||||
|
show-icon
|
||||||
|
:message="incremental.lastSummary"
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card size="small" title="全量计算任务">
|
||||||
|
<template #extra>
|
||||||
|
<Button size="small" :loading="listLoading" @click="loadFullTasks">
|
||||||
|
刷新
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<List
|
||||||
|
v-if="fullTasks.length > 0"
|
||||||
|
:data-source="fullTasks"
|
||||||
|
:loading="listLoading"
|
||||||
|
item-layout="vertical"
|
||||||
|
size="small"
|
||||||
|
class="max-h-[40vh] overflow-y-auto"
|
||||||
|
>
|
||||||
|
<template #renderItem="{ item: task }">
|
||||||
|
<List.Item>
|
||||||
|
<List.Item.Meta>
|
||||||
|
<template #title>
|
||||||
|
<Space wrap>
|
||||||
|
<span>#{{ task.id }}</span>
|
||||||
|
<Tag :color="statusTag(task.status).color">
|
||||||
|
{{ statusTag(task.status).text }}
|
||||||
|
</Tag>
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
{{ task.doneDays }}/{{ task.totalDays }} 天
|
||||||
|
</Typography.Text>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
<template #description>
|
||||||
|
<div>区间 {{ task.dateFrom }} ~ {{ task.dateTo }}</div>
|
||||||
|
<div>
|
||||||
|
创建 {{ formatTime(task.createTime) }}
|
||||||
|
<template v-if="task.finishTime">
|
||||||
|
· 结束 {{ formatTime(task.finishTime) }}
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</List.Item.Meta>
|
||||||
|
<Progress
|
||||||
|
v-if="task.status === 'RUNNING' || task.status === 'SUCCESS'"
|
||||||
|
:percent="taskProgressPercent(task)"
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
<Alert
|
||||||
|
v-if="task.lastError"
|
||||||
|
class="mt-2"
|
||||||
|
type="error"
|
||||||
|
show-icon
|
||||||
|
:message="task.lastError"
|
||||||
|
/>
|
||||||
|
</List.Item>
|
||||||
|
</template>
|
||||||
|
</List>
|
||||||
|
<Empty
|
||||||
|
v-else
|
||||||
|
:image="Empty.PRESENTED_IMAGE_SIMPLE"
|
||||||
|
description="暂无全量计算任务"
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Space>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
+250
@@ -0,0 +1,250 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ShopVO } from '#/api/ec/shop/types';
|
||||||
|
import type { PddOrderConvertVO } from '#/api/channel/pdd/order-convert';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Descriptions,
|
||||||
|
Empty,
|
||||||
|
List,
|
||||||
|
Modal,
|
||||||
|
Progress,
|
||||||
|
Space,
|
||||||
|
Tag,
|
||||||
|
Typography,
|
||||||
|
message,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getPddOrderConvertIncStatusApi,
|
||||||
|
listPddOrderConvertFullTasksApi,
|
||||||
|
resumePddOrderConvertIncApi,
|
||||||
|
} from '#/api/channel/pdd/order-convert';
|
||||||
|
|
||||||
|
defineOptions({ name: 'PddOrderConvertModal' });
|
||||||
|
|
||||||
|
const emit = defineEmits<{ success: [] }>();
|
||||||
|
|
||||||
|
const openFlag = ref(false);
|
||||||
|
const shop = ref<null | ShopVO.Info>(null);
|
||||||
|
const loading = ref(false);
|
||||||
|
const listLoading = ref(false);
|
||||||
|
const resuming = ref(false);
|
||||||
|
const incremental = ref<null | PddOrderConvertVO.IncStatus>(null);
|
||||||
|
const fullTasks = ref<PddOrderConvertVO.FullTask[]>([]);
|
||||||
|
|
||||||
|
const title = computed(() =>
|
||||||
|
shop.value ? `订单转换 - ${shop.value.name}` : '订单转换',
|
||||||
|
);
|
||||||
|
|
||||||
|
const statusLabel = computed(() => {
|
||||||
|
const s = incremental.value?.status;
|
||||||
|
if (s === 2) return '出错暂停';
|
||||||
|
if (s === 1) return '正常';
|
||||||
|
return '未开始';
|
||||||
|
});
|
||||||
|
|
||||||
|
const statusColor = computed(() => {
|
||||||
|
const s = incremental.value?.status;
|
||||||
|
if (s === 2) return 'error';
|
||||||
|
if (s === 1) return 'success';
|
||||||
|
return 'default';
|
||||||
|
});
|
||||||
|
|
||||||
|
function formatTime(time?: null | string) {
|
||||||
|
if (!time) return '-';
|
||||||
|
const d = dayjs(time);
|
||||||
|
return d.isValid() ? d.format('YYYY-MM-DD HH:mm:ss') : '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusTag(status: string) {
|
||||||
|
const map: Record<string, { color: string; text: string }> = {
|
||||||
|
PENDING: { color: 'default', text: '等待中' },
|
||||||
|
RUNNING: { color: 'processing', text: '执行中' },
|
||||||
|
SUCCESS: { color: 'success', text: '成功' },
|
||||||
|
FAILED: { color: 'error', text: '失败' },
|
||||||
|
CANCELLED: { color: 'warning', text: '已取消' },
|
||||||
|
};
|
||||||
|
return map[status] || { color: 'default', text: status };
|
||||||
|
}
|
||||||
|
|
||||||
|
function taskProgressPercent(task: PddOrderConvertVO.FullTask) {
|
||||||
|
if (!task.totalDays) return 0;
|
||||||
|
return Math.min(100, Math.round((task.doneDays / task.totalDays) * 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadInc() {
|
||||||
|
if (!shop.value) return;
|
||||||
|
try {
|
||||||
|
incremental.value = await getPddOrderConvertIncStatusApi(shop.value.id);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载转换店态失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadFullTasks() {
|
||||||
|
if (!shop.value) return;
|
||||||
|
try {
|
||||||
|
listLoading.value = true;
|
||||||
|
fullTasks.value = await listPddOrderConvertFullTasksApi(shop.value.id, 30);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载全量转换任务失败:', error);
|
||||||
|
} finally {
|
||||||
|
listLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleResume() {
|
||||||
|
if (!shop.value) return;
|
||||||
|
try {
|
||||||
|
resuming.value = true;
|
||||||
|
incremental.value = await resumePddOrderConvertIncApi(shop.value.id);
|
||||||
|
message.success('已恢复转换');
|
||||||
|
emit('success');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('恢复转换失败:', error);
|
||||||
|
message.error('恢复转换失败');
|
||||||
|
} finally {
|
||||||
|
resuming.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
openFlag.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function open(record: ShopVO.Info) {
|
||||||
|
shop.value = record;
|
||||||
|
incremental.value = null;
|
||||||
|
fullTasks.value = [];
|
||||||
|
openFlag.value = true;
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
await Promise.all([loadInc(), loadFullTasks()]);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open, close: handleClose });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal
|
||||||
|
v-model:open="openFlag"
|
||||||
|
:title="title"
|
||||||
|
:width="720"
|
||||||
|
:footer="null"
|
||||||
|
destroy-on-close
|
||||||
|
@cancel="handleClose"
|
||||||
|
>
|
||||||
|
<Space direction="vertical" :size="16" class="w-full">
|
||||||
|
<Card size="small">
|
||||||
|
<template #title>
|
||||||
|
<Space>
|
||||||
|
<span>增量转换</span>
|
||||||
|
<Tag :color="statusColor">{{ statusLabel }}</Tag>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
<template #extra>
|
||||||
|
<Button
|
||||||
|
v-if="incremental?.status === 2"
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
:loading="resuming"
|
||||||
|
@click="handleResume"
|
||||||
|
>
|
||||||
|
恢复运行
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<Space direction="vertical" :size="12" class="w-full">
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
将渠道订单写入内部订单;出错暂停后需人工恢复才会继续消费。
|
||||||
|
</Typography.Text>
|
||||||
|
<Descriptions bordered size="small" :column="1">
|
||||||
|
<Descriptions.Item label="上次成功">
|
||||||
|
{{ formatTime(incremental?.lastSuccessTime) }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="转换游标">
|
||||||
|
{{ formatTime(incremental?.lastCursorAt) }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="最近批次单数">
|
||||||
|
{{ incremental?.lastConvertedCount ?? '-' }}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
<Alert
|
||||||
|
v-if="incremental?.lastSummary"
|
||||||
|
:type="incremental?.status === 2 ? 'error' : 'info'"
|
||||||
|
show-icon
|
||||||
|
:message="incremental.lastSummary"
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card size="small" title="全量转换任务">
|
||||||
|
<template #extra>
|
||||||
|
<Button size="small" :loading="listLoading" @click="loadFullTasks">
|
||||||
|
刷新
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<List
|
||||||
|
v-if="fullTasks.length > 0"
|
||||||
|
:data-source="fullTasks"
|
||||||
|
:loading="listLoading"
|
||||||
|
item-layout="vertical"
|
||||||
|
size="small"
|
||||||
|
class="max-h-[40vh] overflow-y-auto"
|
||||||
|
>
|
||||||
|
<template #renderItem="{ item: task }">
|
||||||
|
<List.Item>
|
||||||
|
<List.Item.Meta>
|
||||||
|
<template #title>
|
||||||
|
<Space wrap>
|
||||||
|
<span>#{{ task.id }}</span>
|
||||||
|
<Tag :color="statusTag(task.status).color">
|
||||||
|
{{ statusTag(task.status).text }}
|
||||||
|
</Tag>
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
{{ task.doneDays }}/{{ task.totalDays }} 天
|
||||||
|
</Typography.Text>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
<template #description>
|
||||||
|
<div>区间 {{ task.dateFrom }} ~ {{ task.dateTo }}</div>
|
||||||
|
<div>
|
||||||
|
创建 {{ formatTime(task.createTime) }}
|
||||||
|
<template v-if="task.finishTime">
|
||||||
|
· 结束 {{ formatTime(task.finishTime) }}
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</List.Item.Meta>
|
||||||
|
<Progress
|
||||||
|
v-if="task.status === 'RUNNING' || task.status === 'SUCCESS'"
|
||||||
|
:percent="taskProgressPercent(task)"
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
<Alert
|
||||||
|
v-if="task.lastError"
|
||||||
|
class="mt-2"
|
||||||
|
type="error"
|
||||||
|
show-icon
|
||||||
|
:message="task.lastError"
|
||||||
|
/>
|
||||||
|
</List.Item>
|
||||||
|
</template>
|
||||||
|
</List>
|
||||||
|
<Empty
|
||||||
|
v-else
|
||||||
|
:image="Empty.PRESENTED_IMAGE_SIMPLE"
|
||||||
|
description="暂无全量转换任务"
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Space>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
+9
-15
@@ -11,7 +11,6 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
Descriptions,
|
Descriptions,
|
||||||
Drawer,
|
|
||||||
Empty,
|
Empty,
|
||||||
Form,
|
Form,
|
||||||
List,
|
List,
|
||||||
@@ -39,7 +38,7 @@ import {
|
|||||||
import { RealtimeSseEvent } from '#/api/notify/sse';
|
import { RealtimeSseEvent } from '#/api/notify/sse';
|
||||||
import { useRealtimeStore } from '#/store';
|
import { useRealtimeStore } from '#/store';
|
||||||
|
|
||||||
defineOptions({ name: 'PddOrderSyncDrawer' });
|
defineOptions({ name: 'PddOrderSyncModal' });
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'success'): void;
|
(e: 'success'): void;
|
||||||
@@ -79,7 +78,7 @@ let pollTimer: null | ReturnType<typeof setInterval> = null;
|
|||||||
let unsubProgress: (() => void) | null = null;
|
let unsubProgress: (() => void) | null = null;
|
||||||
const terminalNotifiedTaskIds = new Set<number>();
|
const terminalNotifiedTaskIds = new Set<number>();
|
||||||
|
|
||||||
const drawerTitle = computed(() =>
|
const modalTitle = computed(() =>
|
||||||
shop.value ? `同步拼多多订单 - ${shop.value.name}` : '同步拼多多订单',
|
shop.value ? `同步拼多多订单 - ${shop.value.name}` : '同步拼多多订单',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -421,13 +420,14 @@ defineExpose({ open, close: handleClose });
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Drawer
|
<Modal
|
||||||
v-model:open="openFlag"
|
v-model:open="openFlag"
|
||||||
:title="drawerTitle"
|
:title="modalTitle"
|
||||||
width="600"
|
:width="720"
|
||||||
|
:footer="null"
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
:mask-closable="!hasActiveFullTask"
|
:mask-closable="!hasActiveFullTask"
|
||||||
@close="handleClose"
|
@cancel="handleClose"
|
||||||
>
|
>
|
||||||
<Space direction="vertical" :size="16" class="w-full">
|
<Space direction="vertical" :size="16" class="w-full">
|
||||||
<Card size="small">
|
<Card size="small">
|
||||||
@@ -500,7 +500,7 @@ defineExpose({ open, close: handleClose });
|
|||||||
:loading="listLoading"
|
:loading="listLoading"
|
||||||
item-layout="vertical"
|
item-layout="vertical"
|
||||||
size="small"
|
size="small"
|
||||||
class="max-h-[52vh] overflow-y-auto"
|
class="max-h-[40vh] overflow-y-auto"
|
||||||
>
|
>
|
||||||
<template #renderItem="{ item: task }">
|
<template #renderItem="{ item: task }">
|
||||||
<List.Item>
|
<List.Item>
|
||||||
@@ -580,13 +580,7 @@ defineExpose({ open, close: handleClose });
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Space>
|
</Space>
|
||||||
|
</Modal>
|
||||||
<template #footer>
|
|
||||||
<Space class="w-full justify-end">
|
|
||||||
<Button @click="handleClose">关闭</Button>
|
|
||||||
</Space>
|
|
||||||
</template>
|
|
||||||
</Drawer>
|
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
v-model:open="createModalOpen"
|
v-model:open="createModalOpen"
|
||||||
@@ -10,7 +10,7 @@ import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
import { Button, message, Popconfirm, Space, Steps, Tag } from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
@@ -23,7 +23,9 @@ import {
|
|||||||
getPlatformTagColor,
|
getPlatformTagColor,
|
||||||
} from '#/utils/platform-display';
|
} from '#/utils/platform-display';
|
||||||
|
|
||||||
import PddOrderSyncDrawer from './components/PddOrderSyncDrawer.vue';
|
import BiOrderStatCalcModal from './components/BiOrderStatCalcModal.vue';
|
||||||
|
import PddOrderConvertModal from './components/PddOrderConvertModal.vue';
|
||||||
|
import PddOrderSyncModal from './components/PddOrderSyncModal.vue';
|
||||||
import ShopFormModal from './components/ShopFormModal.vue';
|
import ShopFormModal from './components/ShopFormModal.vue';
|
||||||
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
import PddShopDetailModal from '#/views/channel/pdd/shop/components/PddShopDetailModal.vue';
|
||||||
|
|
||||||
@@ -37,11 +39,27 @@ const loading = ref(false);
|
|||||||
const authorizing = ref(false);
|
const authorizing = ref(false);
|
||||||
const shopFormModalRef = ref();
|
const shopFormModalRef = ref();
|
||||||
const pddShopDetailModalRef = ref();
|
const pddShopDetailModalRef = ref();
|
||||||
const pddOrderSyncDrawerRef = ref();
|
const pddOrderSyncModalRef = ref();
|
||||||
|
const pddOrderConvertModalRef = ref();
|
||||||
|
const biOrderStatCalcModalRef = ref();
|
||||||
|
|
||||||
/** shopId -> 同步摘要 */
|
/** shopId -> 同步/转换/计算摘要 */
|
||||||
const syncStatusMap = ref<Record<number, PddOrderSyncVO.ShopStatus>>({});
|
const syncStatusMap = ref<Record<number, PddOrderSyncVO.ShopStatus>>({});
|
||||||
|
|
||||||
|
/** 主行带店铺字段;次行用 shop 挂店铺,供 VXE data 使用(避免联合类型与 Data<T> 不兼容) */
|
||||||
|
type ShopListRow = Partial<ShopVO.Info> & {
|
||||||
|
_rowKey: string;
|
||||||
|
_rowType: 'main' | 'pipeline';
|
||||||
|
_shopIndex: number;
|
||||||
|
/** 主行:是否有管线次行(序号列 rowspan) */
|
||||||
|
_hasPipeline?: boolean;
|
||||||
|
id: number;
|
||||||
|
/** 次行必有;主行可不设 */
|
||||||
|
shop?: ShopVO.Info;
|
||||||
|
};
|
||||||
|
|
||||||
|
const COLUMN_COUNT = 8;
|
||||||
|
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
name: '',
|
name: '',
|
||||||
platformCode: undefined as string | undefined,
|
platformCode: undefined as string | undefined,
|
||||||
@@ -51,19 +69,46 @@ const platformOptions = ref<{ label: string; value: string }[]>([]);
|
|||||||
|
|
||||||
let authPollTimer: null | ReturnType<typeof setInterval> = null;
|
let authPollTimer: null | ReturnType<typeof setInterval> = null;
|
||||||
|
|
||||||
const gridOptions: VxeGridProps<any> = {
|
function toShopListRows(records: ShopVO.Info[]): ShopListRow[] {
|
||||||
|
const rows: ShopListRow[] = [];
|
||||||
|
records.forEach((shop, index) => {
|
||||||
|
const hasPipeline =
|
||||||
|
shop.platformCode === PLATFORM_CODE_PDD && Boolean(shop.pddShop);
|
||||||
|
rows.push({
|
||||||
|
...shop,
|
||||||
|
_rowKey: `${shop.id}-main`,
|
||||||
|
_rowType: 'main',
|
||||||
|
_shopIndex: index,
|
||||||
|
_hasPipeline: hasPipeline,
|
||||||
|
});
|
||||||
|
if (hasPipeline) {
|
||||||
|
rows.push({
|
||||||
|
_rowKey: `${shop.id}-pipeline`,
|
||||||
|
_rowType: 'pipeline',
|
||||||
|
_shopIndex: index,
|
||||||
|
id: shop.id,
|
||||||
|
shop,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gridOptions: VxeGridProps<ShopListRow> = {
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
type: 'seq' as const,
|
width: 64,
|
||||||
width: 80,
|
|
||||||
title: '序号',
|
title: '序号',
|
||||||
|
align: 'center' as const,
|
||||||
|
showOverflow: false,
|
||||||
|
slots: { default: 'seq' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Logo',
|
title: 'Logo',
|
||||||
width: 120,
|
width: 120,
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
showOverflow: false,
|
showOverflow: false,
|
||||||
slots: { default: 'logo' },
|
slots: { default: 'logoOrPipeline' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
@@ -77,6 +122,7 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
title: '平台',
|
title: '平台',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
|
slots: { default: 'platformName' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '外部店铺',
|
title: '外部店铺',
|
||||||
@@ -85,37 +131,53 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
showOverflow: false,
|
showOverflow: false,
|
||||||
slots: { default: 'externalShop' },
|
slots: { default: 'externalShop' },
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '订单同步',
|
|
||||||
minWidth: 200,
|
|
||||||
align: 'center' as const,
|
|
||||||
showOverflow: false,
|
|
||||||
slots: { default: 'orderSync' },
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
minWidth: 'auto',
|
minWidth: 'auto',
|
||||||
|
slots: { default: 'createTime' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'updateTime',
|
field: 'updateTime',
|
||||||
title: '更新时间',
|
title: '更新时间',
|
||||||
minWidth: 'auto',
|
minWidth: 'auto',
|
||||||
|
slots: { default: 'updateTime' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 320,
|
minWidth: 320,
|
||||||
fixed: 'right' as const,
|
|
||||||
showOverflow: false,
|
showOverflow: false,
|
||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
border: true,
|
border: true,
|
||||||
stripe: true,
|
stripe: false,
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
isHover: true,
|
isHover: true,
|
||||||
height: 88,
|
keyField: '_rowKey',
|
||||||
|
},
|
||||||
|
rowClassName: ({ row }) =>
|
||||||
|
row._rowType === 'pipeline' ? 'shop-row-pipeline' : 'shop-row-main',
|
||||||
|
spanMethod: ({ row, columnIndex }) => {
|
||||||
|
// 序号列:主行与管线次行纵向合并
|
||||||
|
if (columnIndex === 0) {
|
||||||
|
if (row._rowType === 'main' && row._hasPipeline) {
|
||||||
|
return { rowspan: 2, colspan: 1 };
|
||||||
|
}
|
||||||
|
if (row._rowType === 'pipeline') {
|
||||||
|
return { rowspan: 0, colspan: 0 };
|
||||||
|
}
|
||||||
|
return { rowspan: 1, colspan: 1 };
|
||||||
|
}
|
||||||
|
// 管线次行:从 Logo 起横向合并剩余列展示三阶段
|
||||||
|
if (row._rowType === 'pipeline') {
|
||||||
|
if (columnIndex === 1) {
|
||||||
|
return { rowspan: 1, colspan: COLUMN_COUNT - 1 };
|
||||||
|
}
|
||||||
|
return { rowspan: 0, colspan: 0 };
|
||||||
|
}
|
||||||
|
return { rowspan: 1, colspan: 1 };
|
||||||
},
|
},
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
size: 'small',
|
size: 'small',
|
||||||
@@ -162,9 +224,10 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
const data = await getShopPageApi(params);
|
const data = await getShopPageApi(params);
|
||||||
await loadSyncStatusForShops(data.records || []);
|
const records = data.records || [];
|
||||||
|
await loadSyncStatusForShops(records);
|
||||||
return {
|
return {
|
||||||
items: data.records,
|
items: toShopListRows(records),
|
||||||
total: data.total,
|
total: data.total,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -278,75 +341,156 @@ function formatRelative(time?: null | string) {
|
|||||||
return d.format('MM-DD');
|
return d.format('MM-DD');
|
||||||
}
|
}
|
||||||
|
|
||||||
function fullSyncLabel(status?: PddOrderSyncVO.ShopStatus) {
|
type PipelineTone = 'error' | 'idle' | 'off' | 'ok' | 'warn';
|
||||||
const task = status?.fullTask;
|
|
||||||
if (!task) return '-';
|
|
||||||
if (task.status === 'PENDING' || task.status === 'RUNNING') {
|
|
||||||
return `进行中 ${task.doneDays ?? 0}/${task.totalDays ?? 0}`;
|
|
||||||
}
|
|
||||||
if (task.status === 'FAILED') return '失败';
|
|
||||||
if (task.status === 'CANCELLED') return '已取消';
|
|
||||||
if (task.status === 'SUCCESS') {
|
|
||||||
const rel = formatRelative(task.finishTime);
|
|
||||||
return rel ? `已完成(${rel})` : '已完成';
|
|
||||||
}
|
|
||||||
return task.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fullSyncColor(status?: PddOrderSyncVO.ShopStatus) {
|
type PipelineStepView = {
|
||||||
const s = status?.fullTask?.status;
|
key: string;
|
||||||
if (s === 'RUNNING' || s === 'PENDING') return 'processing';
|
title: string;
|
||||||
if (s === 'FAILED') return 'error';
|
tone: PipelineTone;
|
||||||
if (s === 'SUCCESS') return 'success';
|
statusText: string;
|
||||||
if (s === 'CANCELLED') return 'default';
|
/** 全量 · 增量 两行时间 */
|
||||||
return 'default';
|
fullTimeText: string;
|
||||||
}
|
incTimeText: string;
|
||||||
|
stepStatus: 'error' | 'finish' | 'process' | 'wait';
|
||||||
|
};
|
||||||
|
|
||||||
function incSyncLabel(status?: PddOrderSyncVO.ShopStatus) {
|
function toneFromInc(status?: PddOrderSyncVO.ShopStatus): PipelineTone {
|
||||||
const inc = status?.incremental;
|
|
||||||
if (!inc) return '关';
|
|
||||||
const health = inc.health || (inc.enabled ? 'OK' : 'OFF');
|
|
||||||
const map: Record<string, string> = {
|
|
||||||
OFF: '关',
|
|
||||||
OK: '开·正常',
|
|
||||||
LAGGING: '开·滞后',
|
|
||||||
PAUSED: '开·暂停',
|
|
||||||
};
|
|
||||||
const base = map[health] || (inc.enabled ? '开' : '关');
|
|
||||||
const anchor = inc.lastSuccessTime || inc.lastCursorAt;
|
|
||||||
const rel = formatRelative(anchor);
|
|
||||||
return rel ? `${base} · ${rel}` : base;
|
|
||||||
}
|
|
||||||
|
|
||||||
function incSyncColor(status?: PddOrderSyncVO.ShopStatus) {
|
|
||||||
const health = status?.incremental?.health;
|
const health = status?.incremental?.health;
|
||||||
if (health === 'PAUSED') return 'error';
|
if (health === 'PAUSED') return 'error';
|
||||||
if (health === 'LAGGING') return 'warning';
|
if (health === 'LAGGING') return 'warn';
|
||||||
if (health === 'OK') return 'success';
|
if (health === 'OK') return 'ok';
|
||||||
return 'default';
|
if (health === 'OFF' || !status?.incremental?.enabled) return 'off';
|
||||||
|
return 'idle';
|
||||||
|
}
|
||||||
|
|
||||||
|
function toneFromStage(
|
||||||
|
summary?: string,
|
||||||
|
status?: number,
|
||||||
|
): PipelineTone {
|
||||||
|
if (status === 2 || (summary && (summary.includes('失败') || summary.includes('限流')))) {
|
||||||
|
return 'error';
|
||||||
|
}
|
||||||
|
if (summary) return 'ok';
|
||||||
|
return 'idle';
|
||||||
|
}
|
||||||
|
|
||||||
|
function toneLabel(tone: PipelineTone) {
|
||||||
|
const map: Record<PipelineTone, string> = {
|
||||||
|
ok: '正常',
|
||||||
|
warn: '滞后',
|
||||||
|
error: '异常',
|
||||||
|
off: '关闭',
|
||||||
|
idle: '未开始',
|
||||||
|
};
|
||||||
|
return map[tone];
|
||||||
|
}
|
||||||
|
|
||||||
|
function toneToStepStatus(
|
||||||
|
tone: PipelineTone,
|
||||||
|
): 'error' | 'finish' | 'process' | 'wait' {
|
||||||
|
if (tone === 'ok') return 'finish';
|
||||||
|
if (tone === 'error') return 'error';
|
||||||
|
if (tone === 'warn') return 'process';
|
||||||
|
return 'wait';
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatStageTime(time?: null | string) {
|
||||||
|
if (!time) return '-';
|
||||||
|
const rel = formatRelative(time);
|
||||||
|
return rel || '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 次行管线:同步 → 转换 → 计算(各侧全量/增量最近成功时间) */
|
||||||
|
function buildPipelineSteps(
|
||||||
|
status?: PddOrderSyncVO.ShopStatus,
|
||||||
|
): PipelineStepView[] {
|
||||||
|
const syncTone = toneFromInc(status);
|
||||||
|
const convertTone = toneFromStage(
|
||||||
|
status?.convert?.lastSummary,
|
||||||
|
status?.convert?.status,
|
||||||
|
);
|
||||||
|
const calcTone = toneFromStage(
|
||||||
|
status?.calc?.lastSummary,
|
||||||
|
status?.calc?.status,
|
||||||
|
);
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
key: 'sync',
|
||||||
|
title: '同步',
|
||||||
|
tone: syncTone,
|
||||||
|
statusText: toneLabel(syncTone),
|
||||||
|
fullTimeText: formatStageTime(status?.lastFullSyncSuccessTime),
|
||||||
|
incTimeText: formatStageTime(status?.incremental?.lastSuccessTime),
|
||||||
|
stepStatus: toneToStepStatus(syncTone),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'convert',
|
||||||
|
title: '转换',
|
||||||
|
tone: convertTone,
|
||||||
|
statusText: toneLabel(convertTone),
|
||||||
|
fullTimeText: formatStageTime(status?.convert?.lastFullSuccessTime),
|
||||||
|
incTimeText: formatStageTime(status?.convert?.lastSuccessTime),
|
||||||
|
stepStatus: toneToStepStatus(convertTone),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'calc',
|
||||||
|
title: '计算',
|
||||||
|
tone: calcTone,
|
||||||
|
statusText: toneLabel(calcTone),
|
||||||
|
fullTimeText: formatStageTime(status?.calc?.lastFullSuccessTime),
|
||||||
|
incTimeText: formatStageTime(status?.calc?.lastSuccessTime),
|
||||||
|
stepStatus: toneToStepStatus(calcTone),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPipelineRow(row: ShopListRow): boolean {
|
||||||
|
return row._rowType === 'pipeline';
|
||||||
|
}
|
||||||
|
|
||||||
|
type PipelineStageKey = 'calc' | 'convert' | 'sync';
|
||||||
|
|
||||||
|
function openPipelineStage(shop: ShopVO.Info, stage: PipelineStageKey) {
|
||||||
|
if (!hasExternalShop(shop)) {
|
||||||
|
message.warning('请先完成拼多多授权绑定');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stage === 'sync') {
|
||||||
|
pddOrderSyncModalRef.value?.open(shop);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stage === 'convert') {
|
||||||
|
pddOrderConvertModalRef.value?.open(shop);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
biOrderStatCalcModalRef.value?.open(shop);
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshTable() {
|
function refreshTable() {
|
||||||
gridApi?.reload();
|
gridApi?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPddShop(row: ShopVO.Info) {
|
function isPddShop(row: { platformCode?: string }) {
|
||||||
return row.platformCode === PLATFORM_CODE_PDD;
|
return row.platformCode === PLATFORM_CODE_PDD;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasExternalShop(row: ShopVO.Info) {
|
function hasExternalShop(row: { pddShop?: ShopVO.Info['pddShop'] }) {
|
||||||
return Boolean(row.pddShop);
|
return Boolean(row.pddShop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function asShopInfo(row: ShopListRow): ShopVO.Info {
|
||||||
|
return row as ShopVO.Info;
|
||||||
|
}
|
||||||
|
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
shopFormModalRef.value?.open(false);
|
shopFormModalRef.value?.open(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEdit(record: ShopVO.Info) {
|
function handleEdit(record: ShopListRow) {
|
||||||
shopFormModalRef.value?.open(true, record);
|
shopFormModalRef.value?.open(true, asShopInfo(record));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDelete(record: ShopVO.Info) {
|
async function handleDelete(record: ShopListRow) {
|
||||||
try {
|
try {
|
||||||
await deleteShopApi(record.id);
|
await deleteShopApi(record.id);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
@@ -361,7 +505,7 @@ function handleModalSuccess() {
|
|||||||
refreshTable();
|
refreshTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleViewExternalShop(record: ShopVO.Info) {
|
function handleViewExternalShop(record: ShopListRow) {
|
||||||
const pddShopId = record.pddShop?.id;
|
const pddShopId = record.pddShop?.id;
|
||||||
if (!pddShopId) {
|
if (!pddShopId) {
|
||||||
message.warning('暂无外部店铺详情,请先完成授权同步');
|
message.warning('暂无外部店铺详情,请先完成授权同步');
|
||||||
@@ -370,14 +514,6 @@ function handleViewExternalShop(record: ShopVO.Info) {
|
|||||||
pddShopDetailModalRef.value?.open(Number(pddShopId), record.name);
|
pddShopDetailModalRef.value?.open(Number(pddShopId), record.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSyncPddOrders(record: ShopVO.Info) {
|
|
||||||
if (!hasExternalShop(record)) {
|
|
||||||
message.warning('请先完成拼多多授权绑定后再同步订单');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pddOrderSyncDrawerRef.value?.open(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAuthPoll() {
|
function clearAuthPoll() {
|
||||||
if (authPollTimer) {
|
if (authPollTimer) {
|
||||||
clearInterval(authPollTimer);
|
clearInterval(authPollTimer);
|
||||||
@@ -385,7 +521,7 @@ function clearAuthPoll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleAuthorizePdd(record: ShopVO.Info) {
|
async function handleAuthorizePdd(record: ShopListRow) {
|
||||||
if (authorizing.value) return;
|
if (authorizing.value) return;
|
||||||
try {
|
try {
|
||||||
authorizing.value = true;
|
authorizing.value = true;
|
||||||
@@ -436,8 +572,55 @@ onUnmounted(() => {
|
|||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #logo="{ row }: { row: ShopVO.Info }">
|
<template #seq="{ row }: { row: ShopListRow }">
|
||||||
<div class="shop-logo-cell flex items-center justify-center">
|
<span v-if="!isPipelineRow(row)">{{ row._shopIndex + 1 }}</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #logoOrPipeline="{ row }: { row: ShopListRow }">
|
||||||
|
<div
|
||||||
|
v-if="isPipelineRow(row) && row.shop"
|
||||||
|
class="flex w-full items-center px-1 text-left"
|
||||||
|
>
|
||||||
|
<Steps size="small" class="shop-pipeline-steps min-w-0 flex-1">
|
||||||
|
<Steps.Step
|
||||||
|
v-for="step in buildPipelineSteps(syncStatusMap[row.shop.id])"
|
||||||
|
:key="step.key"
|
||||||
|
:status="step.stepStatus"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span
|
||||||
|
class="cursor-pointer hover:text-primary"
|
||||||
|
@click.stop="
|
||||||
|
openPipelineStage(
|
||||||
|
row.shop!,
|
||||||
|
step.key as PipelineStageKey,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ step.title }} · {{ step.statusText }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #description>
|
||||||
|
<div
|
||||||
|
class="cursor-pointer text-[11px] leading-tight text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||||
|
@click.stop="
|
||||||
|
openPipelineStage(
|
||||||
|
row.shop!,
|
||||||
|
step.key as PipelineStageKey,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div>全量 {{ step.fullTimeText }}</div>
|
||||||
|
<div>增量 {{ step.incTimeText }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Steps.Step>
|
||||||
|
</Steps>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="shop-logo-cell flex items-center justify-center"
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
v-if="row.logo"
|
v-if="row.logo"
|
||||||
:src="row.logo"
|
:src="row.logo"
|
||||||
@@ -453,12 +636,19 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #name="{ row }: { row: ShopVO.Info }">
|
<template #name="{ row }: { row: ShopListRow }">
|
||||||
<span>{{ row.name }}</span>
|
<span v-if="!isPipelineRow(row)">{{ row.name }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #externalShop="{ row }: { row: ShopVO.Info }">
|
<template #platformName="{ row }: { row: ShopListRow }">
|
||||||
<div v-if="isPddShop(row)" class="flex flex-col items-center gap-1">
|
<span v-if="!isPipelineRow(row)">{{ row.platformName }}</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #externalShop="{ row }: { row: ShopListRow }">
|
||||||
|
<div
|
||||||
|
v-if="!isPipelineRow(row) && isPddShop(row)"
|
||||||
|
class="flex flex-col items-center gap-1"
|
||||||
|
>
|
||||||
<Tag
|
<Tag
|
||||||
v-if="hasExternalShop(row)"
|
v-if="hasExternalShop(row)"
|
||||||
:color="getPlatformTagColor(row.platformCode)"
|
:color="getPlatformTagColor(row.platformCode)"
|
||||||
@@ -481,40 +671,19 @@ onUnmounted(() => {
|
|||||||
渠道店#{{ row.pddShop.id }}
|
渠道店#{{ row.pddShop.id }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else class="text-slate-400">-</span>
|
<span v-else-if="!isPipelineRow(row)" class="text-slate-400">-</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #orderSync="{ row }: { row: ShopVO.Info }">
|
<template #createTime="{ row }: { row: ShopListRow }">
|
||||||
<div
|
<span v-if="!isPipelineRow(row)">{{ row.createTime }}</span>
|
||||||
v-if="isPddShop(row) && hasExternalShop(row)"
|
|
||||||
class="inline-flex cursor-pointer flex-col items-center gap-1"
|
|
||||||
@click="handleSyncPddOrders(row)"
|
|
||||||
>
|
|
||||||
<div class="flex items-center gap-1 text-xs">
|
|
||||||
<span class="text-slate-500">全量</span>
|
|
||||||
<Tag :color="fullSyncColor(syncStatusMap[row.id])" class="!mr-0">
|
|
||||||
{{ fullSyncLabel(syncStatusMap[row.id]) }}
|
|
||||||
</Tag>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-1 text-xs">
|
|
||||||
<span class="text-slate-500">增量</span>
|
|
||||||
<Tag :color="incSyncColor(syncStatusMap[row.id])" class="!mr-0">
|
|
||||||
{{ incSyncLabel(syncStatusMap[row.id]) }}
|
|
||||||
</Tag>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<span v-else class="text-slate-400">-</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #action="{ row }: { row: ShopVO.Info }">
|
<template #updateTime="{ row }: { row: ShopListRow }">
|
||||||
<Space>
|
<span v-if="!isPipelineRow(row)">{{ row.updateTime }}</span>
|
||||||
<Button
|
</template>
|
||||||
v-if="isPddShop(row) && hasExternalShop(row)"
|
|
||||||
size="small"
|
<template #action="{ row }: { row: ShopListRow }">
|
||||||
@click="handleSyncPddOrders(row)"
|
<Space v-if="!isPipelineRow(row)">
|
||||||
>
|
|
||||||
同步订单
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
v-if="isPddShop(row)"
|
v-if="isPddShop(row)"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -538,7 +707,18 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
<ShopFormModal ref="shopFormModalRef" @success="handleModalSuccess" />
|
<ShopFormModal ref="shopFormModalRef" @success="handleModalSuccess" />
|
||||||
<PddShopDetailModal ref="pddShopDetailModalRef" />
|
<PddShopDetailModal ref="pddShopDetailModalRef" />
|
||||||
<PddOrderSyncDrawer ref="pddOrderSyncDrawerRef" @success="handleModalSuccess" />
|
<PddOrderSyncModal
|
||||||
|
ref="pddOrderSyncModalRef"
|
||||||
|
@success="handleModalSuccess"
|
||||||
|
/>
|
||||||
|
<PddOrderConvertModal
|
||||||
|
ref="pddOrderConvertModalRef"
|
||||||
|
@success="handleModalSuccess"
|
||||||
|
/>
|
||||||
|
<BiOrderStatCalcModal
|
||||||
|
ref="biOrderStatCalcModalRef"
|
||||||
|
@success="handleModalSuccess"
|
||||||
|
/>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -547,6 +727,48 @@ onUnmounted(() => {
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.shop-grid .shop-row-pipeline .vxe-body--column) {
|
||||||
|
border-top: none;
|
||||||
|
padding-block: 6px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Steps 默认 description max-width:140px 会挤换行,占满节点间空隙并单行省略 */
|
||||||
|
:deep(.shop-pipeline-steps.ant-steps) {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.shop-pipeline-steps .ant-steps-item-container) {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.shop-pipeline-steps .ant-steps-item-content) {
|
||||||
|
min-width: 0;
|
||||||
|
width: calc(100% - 24px);
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.shop-pipeline-steps .ant-steps-item-title) {
|
||||||
|
padding-inline-end: 8px !important;
|
||||||
|
font-size: 12px !important;
|
||||||
|
line-height: 22px !important;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.shop-pipeline-steps .ant-steps-item-title::after) {
|
||||||
|
top: 11px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.shop-pipeline-steps .ant-steps-item-description) {
|
||||||
|
max-width: none !important;
|
||||||
|
padding-inline-end: 12px;
|
||||||
|
margin-top: 0 !important;
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 12px !important;
|
||||||
|
line-height: 18px !important;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.shop-logo-cell {
|
.shop-logo-cell {
|
||||||
min-height: 64px;
|
min-height: 64px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user