fix(一键成片):功能逻辑优化,模板管理等前后端功能实现
This commit is contained in:
+21
-3
@@ -1,10 +1,12 @@
|
|||||||
package com.central.device.mapper;
|
package com.central.device.mapper;
|
||||||
|
|
||||||
import com.central.device.model.AgeDevice;
|
|
||||||
import com.central.db.mapper.SuperMapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import com.central.db.mapper.SuperMapper;
|
||||||
|
import com.central.device.model.AgeDevice;
|
||||||
|
import com.central.device.model.vo.DistributionDataVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -24,4 +26,20 @@ public interface AgeDeviceMapper extends SuperMapper<AgeDevice> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<AgeDevice> findList(Page<AgeDevice> page, @Param("p") Map<String, Object> params);
|
List<AgeDevice> findList(Page<AgeDevice> page, @Param("p") Map<String, Object> params);
|
||||||
|
|
||||||
|
@Select("SELECT COUNT(*) FROM manage_device WHERE is_del = 0")
|
||||||
|
Long getTotalDevices();
|
||||||
|
|
||||||
|
@Select("SELECT COUNT(*) FROM manage_device WHERE is_del = 0 AND status = 1")
|
||||||
|
Long getOnlineDevices();
|
||||||
|
|
||||||
|
@Select({
|
||||||
|
"SELECT",
|
||||||
|
" device_type as type,",
|
||||||
|
" COUNT(*) as value",
|
||||||
|
"FROM manage_device",
|
||||||
|
"WHERE is_del = 0",
|
||||||
|
"GROUP BY device_type"
|
||||||
|
})
|
||||||
|
List<DistributionDataVO> getDeviceDistribution();
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-3
@@ -1,10 +1,11 @@
|
|||||||
package com.central.device.mapper;
|
package com.central.device.mapper;
|
||||||
|
|
||||||
import com.central.device.model.LineFile;
|
|
||||||
import com.central.db.mapper.SuperMapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import com.central.db.mapper.SuperMapper;
|
||||||
|
import com.central.device.model.LineFile;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -24,4 +25,10 @@ public interface LineFileMapper extends SuperMapper<LineFile> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<LineFile> findList(Page<LineFile> page, @Param("p") Map<String, Object> params);
|
List<LineFile> findList(Page<LineFile> page, @Param("p") Map<String, Object> params);
|
||||||
|
|
||||||
|
@Select("SELECT COUNT(*) FROM wayline_file WHERE is_del = 0")
|
||||||
|
Long getTotalWaylines();
|
||||||
|
|
||||||
|
@Select("SELECT COUNT(*) FROM wayline_file WHERE is_del = 0 AND last_use_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)")
|
||||||
|
Long getActiveWaylines();
|
||||||
}
|
}
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package com.central.device.model.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "分布数据")
|
||||||
|
public class DistributionDataVO {
|
||||||
|
@Schema(description = "类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@Schema(description = "数值")
|
||||||
|
private BigDecimal value;
|
||||||
|
}
|
||||||
@@ -123,6 +123,11 @@
|
|||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-webflux</artifactId>
|
<artifactId>spring-webflux</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>ice20201109</artifactId>
|
||||||
|
<version>1.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.central.order.config;
|
||||||
|
|
||||||
|
import com.aliyun.ice20201109.Client;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "aliyun.ims")
|
||||||
|
public class AliyunImsConfig {
|
||||||
|
private String endpoint;
|
||||||
|
private String accessKeyId;
|
||||||
|
private String accessKeySecret;
|
||||||
|
private String region;
|
||||||
|
private String projectName;
|
||||||
|
private String pipelineName;
|
||||||
|
private String templateId;
|
||||||
|
private String callbackUrl;
|
||||||
|
private String bucket;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Client imsClient() throws Exception {
|
||||||
|
Config config = new Config()
|
||||||
|
.setAccessKeyId(accessKeyId)
|
||||||
|
.setAccessKeySecret(accessKeySecret)
|
||||||
|
.setEndpoint(endpoint);
|
||||||
|
return new Client(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
package com.central.order.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑任务状态常量
|
||||||
|
*/
|
||||||
|
public interface EditTaskStatus {
|
||||||
|
/**
|
||||||
|
* 待处理
|
||||||
|
*/
|
||||||
|
int PENDING = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理中
|
||||||
|
*/
|
||||||
|
int PROCESSING = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理完成
|
||||||
|
*/
|
||||||
|
int COMPLETED = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理失败
|
||||||
|
*/
|
||||||
|
int FAILED = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为处理中状态
|
||||||
|
*/
|
||||||
|
static boolean isProcessing(Integer status) {
|
||||||
|
return PROCESSING == status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为完成状态
|
||||||
|
*/
|
||||||
|
static boolean isCompleted(Integer status) {
|
||||||
|
return COMPLETED == status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态描述
|
||||||
|
*/
|
||||||
|
static String getStatusDesc(Integer status) {
|
||||||
|
switch (status) {
|
||||||
|
case PENDING: return "待处理";
|
||||||
|
case PROCESSING: return "处理中";
|
||||||
|
case COMPLETED: return "已完成";
|
||||||
|
case FAILED: return "失败";
|
||||||
|
default: return "未知状态";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+119
-30
@@ -1,11 +1,12 @@
|
|||||||
package com.central.order.controller;
|
package com.central.order.controller;
|
||||||
|
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
|
import com.central.order.constants.EditTaskStatus;
|
||||||
|
import com.central.order.enums.OrderStatus;
|
||||||
import com.central.order.feign.FileCenterService;
|
import com.central.order.feign.FileCenterService;
|
||||||
import com.central.order.model.*;
|
import com.central.order.model.*;
|
||||||
import com.central.order.service.IOrderFileService;
|
import com.central.order.model.dto.CallbackDTO;
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.*;
|
||||||
import com.central.order.service.ITourismFileService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -13,10 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -36,47 +34,124 @@ public class AutoCutVideoController {
|
|||||||
@Value("${videos.edit-config.url}")
|
@Value("${videos.edit-config.url}")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
private final RestTemplate restTemplate;
|
@Value("${videos.edit-config.app-id}")
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
@Value("${videos.edit-config.callback-url}")
|
||||||
|
private String callbackUrl;
|
||||||
|
|
||||||
|
private RestTemplate restTemplate;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOrderService orderService;
|
private IOrderService orderService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private IEditTaskService editTaskService;
|
||||||
|
@Autowired
|
||||||
private IOrderFileService orderFileService;
|
private IOrderFileService orderFileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITourismFileService tourismFileService;
|
private ITourismFileService tourismFileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileCenterService fileCenterService;
|
private FileCenterService fileCenterService;
|
||||||
|
@Autowired
|
||||||
|
private IVideoEditService videoEditService;
|
||||||
|
|
||||||
@Operation(summary = "根据订单号生成视频")
|
@Operation(summary = "根据订单号生成视频")
|
||||||
@GetMapping("/generate/{orderNo}")
|
@PostMapping("/generate")
|
||||||
public Result generateVideo(@PathVariable String orderNo) {
|
public Result generateVideo(@RequestParam String orderNo) {
|
||||||
try {
|
try {
|
||||||
// 1. 获取订单信息
|
// 1. 验证订单状态
|
||||||
Order order = orderService.getOrderByNumber(orderNo);
|
Order order = orderService.getOrderByNumber(orderNo);
|
||||||
if (order == null) {
|
if (order == null || !OrderStatus.isValidForEdit(order.getOrderStatus())) {
|
||||||
return Result.failed("订单不存在");
|
return Result.failed("订单状态不允许生成视频");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 获取订单相关文件
|
// 2. 检查是否存在进行中的任务
|
||||||
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
EditTask existingTask = editTaskService.getTaskByOrderSn(orderNo);
|
||||||
|
if (existingTask != null && EditTaskStatus.isProcessing(existingTask.getStatus())) {
|
||||||
|
return Result.failed("已存在进行中的编辑任务");
|
||||||
|
}
|
||||||
|
|
||||||
// 3. 获取景区素材
|
// 3. 创建新任务
|
||||||
|
EditTask task = editTaskService.createTask(orderNo, order.getUserId());
|
||||||
|
|
||||||
|
// 4. 获取素材文件
|
||||||
|
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
||||||
List<TourismFile> tourismFiles = tourismFileService.getByTourismId(order.getTourismId());
|
List<TourismFile> tourismFiles = tourismFileService.getByTourismId(order.getTourismId());
|
||||||
|
|
||||||
// 4. 构建素材列表
|
// 5. 提交编辑任务
|
||||||
SourceDTO sourceDTO = buildSourceDTO(orderFiles, tourismFiles);
|
String jobId = videoEditService.submitEditTask(orderNo, orderFiles, tourismFiles);
|
||||||
|
|
||||||
// 5. 构建请求参数
|
// 6. 更新任务信息
|
||||||
RequestParamsEntity requestParams = buildRequestParams(order, sourceDTO);
|
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
||||||
|
|
||||||
// 6. 调用一键成片接口
|
return Result.succeed(jobId);
|
||||||
Object response = restTemplate.postForObject(url, requestParams, Object.class);
|
|
||||||
|
|
||||||
log.info("一键成片请求成功: orderNo={}, response={}", orderNo, response);
|
|
||||||
return Result.succeed(response);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("一键成片请求失败: orderNo={}", orderNo, e);
|
log.error("提交视频编辑任务失败: orderNo={}", orderNo, e);
|
||||||
return Result.failed("生成视频失败:" + e.getMessage());
|
return Result.failed("提交任务失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "智能剪辑回调接口")
|
||||||
|
@PostMapping("/callback")
|
||||||
|
public Result handleCallback(@RequestBody CallbackDTO callback) {
|
||||||
|
log.info("收到视频编辑回调: {}", callback);
|
||||||
|
try {
|
||||||
|
// 1. 验证回调信息
|
||||||
|
if (!isValidCallback(callback)) {
|
||||||
|
return Result.failed("无效的回调信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 获取任务信息
|
||||||
|
EditTask task = editTaskService.getTaskByJobId(callback.getJobId());
|
||||||
|
if (task == null) {
|
||||||
|
return Result.failed("未找到对应的任务");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 处理成功回调
|
||||||
|
if ("Success".equals(callback.getStatus())) {
|
||||||
|
// 更新任务状态
|
||||||
|
editTaskService.updateTaskStatus(
|
||||||
|
callback.getJobId(),
|
||||||
|
EditTaskStatus.COMPLETED,
|
||||||
|
callback.getResult()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 发送通知
|
||||||
|
notifyUser(task.getUserId().toString(), "视频制作完成");
|
||||||
|
}
|
||||||
|
// 4. 处理失败回调
|
||||||
|
else {
|
||||||
|
editTaskService.updateTaskStatus(
|
||||||
|
callback.getJobId(),
|
||||||
|
EditTaskStatus.FAILED,
|
||||||
|
callback.getErrorMessage()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 记录错误日志
|
||||||
|
log.error("视频编辑失败: jobId={}, error={}",
|
||||||
|
callback.getJobId(), callback.getErrorMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.succeed("回调处理成功");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("处理视频编辑回调失败", e);
|
||||||
|
return Result.failed("处理回调失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取任务状态")
|
||||||
|
@GetMapping("/task/status/{orderNo}")
|
||||||
|
public Result getTaskStatus(@PathVariable String orderNo) {
|
||||||
|
try {
|
||||||
|
EditTask task = editTaskService.getTaskByOrderSn(orderNo);
|
||||||
|
if (task == null) {
|
||||||
|
return Result.failed("未找到任务记录");
|
||||||
|
}
|
||||||
|
return Result.succeed(task);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取任务状态失败", e);
|
||||||
|
return Result.failed("获取任务状态失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,9 +207,9 @@ public class AutoCutVideoController {
|
|||||||
*/
|
*/
|
||||||
private RequestParamsEntity buildRequestParams(Order order, SourceDTO sourceDTO) {
|
private RequestParamsEntity buildRequestParams(Order order, SourceDTO sourceDTO) {
|
||||||
return RequestParamsEntity.builder()
|
return RequestParamsEntity.builder()
|
||||||
.appId("68c9ba9a92934623acdb6e84b4174f43") // 从配置文件获取
|
.appId(appId) // 使用配置文件中的appId
|
||||||
.taskId(order.getOrderNo()) // 使用订单号作为任务ID
|
.taskId(order.getOrderNo())
|
||||||
.callbackUrl("your-callback-url") // 从配置文件获取
|
.callbackUrl(callbackUrl) // 使用配置文件中的callbackUrl
|
||||||
.source(sourceDTO)
|
.source(sourceDTO)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@@ -157,4 +232,18 @@ public class AutoCutVideoController {
|
|||||||
|
|
||||||
return "other";
|
return "other";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String extractJobId(Object response) {
|
||||||
|
// Implementation of extractJobId method
|
||||||
|
return null; // Placeholder return, actual implementation needed
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidCallback(CallbackDTO callback) {
|
||||||
|
// Implementation of isValidCallback method
|
||||||
|
return false; // Placeholder return, actual implementation needed
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyUser(String userId, String message) {
|
||||||
|
// Implementation of notifyUser method
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -97,9 +97,6 @@ public class OrderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IProfitSharingService profitSharingService;
|
private IProfitSharingService profitSharingService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SettleInfo defaultSettleInfo; // 注入配置的SettleInfo
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
package com.central.order.controller;
|
||||||
|
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import com.central.order.model.VideoTemplate;
|
||||||
|
import com.central.order.service.IVideoTemplateService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/video/template")
|
||||||
|
@Tag(name = "视频模板管理")
|
||||||
|
public class VideoTemplateController {
|
||||||
|
|
||||||
|
private final IVideoTemplateService videoTemplateService;
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询模板")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<PageResult<VideoTemplate>> list(@RequestParam Map<String, Object> params) {
|
||||||
|
try {
|
||||||
|
PageResult<VideoTemplate> result = videoTemplateService.findList(params);
|
||||||
|
return Result.succeed(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询模板列表失败", e);
|
||||||
|
return Result.failed("查询失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加模板")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Boolean> save(@RequestBody VideoTemplate template) {
|
||||||
|
try {
|
||||||
|
boolean result = videoTemplateService.saveTemplate(template);
|
||||||
|
return Result.succeed(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("添加模板失败", e);
|
||||||
|
return Result.failed("添加失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新模板")
|
||||||
|
@PutMapping
|
||||||
|
public Result<Boolean> update(@RequestBody VideoTemplate template) {
|
||||||
|
try {
|
||||||
|
boolean result = videoTemplateService.updateTemplate(template);
|
||||||
|
return Result.succeed(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新模板失败", e);
|
||||||
|
return Result.failed("更新失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除模板")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result<Boolean> delete(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
boolean result = videoTemplateService.deleteTemplate(id);
|
||||||
|
return Result.succeed(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除模板失败", e);
|
||||||
|
return Result.failed("删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新模板状态")
|
||||||
|
@PutMapping("/{id}/status/{status}")
|
||||||
|
public Result<Boolean> updateStatus(@PathVariable Long id, @PathVariable Integer status) {
|
||||||
|
try {
|
||||||
|
boolean result = videoTemplateService.updateStatus(id, status);
|
||||||
|
return Result.succeed(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新模板状态失败", e);
|
||||||
|
return Result.failed("更新状态失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取可用模板")
|
||||||
|
@GetMapping("/active")
|
||||||
|
public Result<VideoTemplate> getActiveTemplate() {
|
||||||
|
try {
|
||||||
|
VideoTemplate template = videoTemplateService.getActiveTemplate();
|
||||||
|
return Result.succeed(template);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取可用模板失败", e);
|
||||||
|
return Result.failed("获取失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,4 +28,59 @@ public enum OrderStatus implements ZltEnum {
|
|||||||
private Integer id;
|
private Integer id;
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断订单状态是否允许编辑视频
|
||||||
|
* 只有设备执行完成的订单才能进行视频编辑
|
||||||
|
*/
|
||||||
|
public static boolean isValidForEdit(Integer status) {
|
||||||
|
return status != null && status.equals(COMPLETE.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID获取状态枚举
|
||||||
|
*/
|
||||||
|
public static OrderStatus fromId(Integer id) {
|
||||||
|
if (id == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (OrderStatus status : values()) {
|
||||||
|
if (status.getId().equals(id)) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态描述
|
||||||
|
*/
|
||||||
|
public static String getDesc(Integer id) {
|
||||||
|
OrderStatus status = fromId(id);
|
||||||
|
return status != null ? status.getContent() : "未知状态";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为最终状态
|
||||||
|
*/
|
||||||
|
public static boolean isFinalStatus(Integer status) {
|
||||||
|
return status != null && (
|
||||||
|
status.equals(CANCELED.getId()) ||
|
||||||
|
status.equals(UPLOADED.getId()) ||
|
||||||
|
status.equals(REFUNDED.getId()) ||
|
||||||
|
status.equals(REFUND_FAILED.getId())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否可以退款
|
||||||
|
*/
|
||||||
|
public static boolean canRefund(Integer status) {
|
||||||
|
return status != null && (
|
||||||
|
status.equals(PAID.getId()) ||
|
||||||
|
status.equals(DOING.getId()) ||
|
||||||
|
status.equals(COMPLETE.getId()) ||
|
||||||
|
status.equals(UPLOADING.getId()) ||
|
||||||
|
status.equals(UPLOADED.getId())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.central.order.mapper;
|
package com.central.order.mapper;
|
||||||
|
|
||||||
import com.central.order.model.vo.DistributionDataVO;
|
|
||||||
import com.central.order.model.vo.IncomeDataVO;
|
import com.central.order.model.vo.IncomeDataVO;
|
||||||
import com.central.order.model.vo.TourismRankingVO;
|
import com.central.order.model.vo.TourismRankingVO;
|
||||||
import com.central.order.model.vo.TrendDataVO;
|
import com.central.order.model.vo.TrendDataVO;
|
||||||
@@ -45,17 +44,7 @@ public interface DashboardMapper {
|
|||||||
})
|
})
|
||||||
Long getTodayIncome();
|
Long getTodayIncome();
|
||||||
|
|
||||||
@Select("SELECT COUNT(*) FROM device-center.wayline_file WHERE is_del = 0")
|
|
||||||
Long getTotalWaylines();
|
|
||||||
|
|
||||||
@Select("SELECT COUNT(*) FROM device-center.wayline_file WHERE is_del = 0 AND last_use_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)")
|
|
||||||
Long getActiveWaylines();
|
|
||||||
|
|
||||||
@Select("SELECT COUNT(*) FROM device-center.manage_device WHERE is_del = 0")
|
|
||||||
Long getTotalDevices();
|
|
||||||
|
|
||||||
@Select("SELECT COUNT(*) FROM device-center.manage_device WHERE is_del = 0 AND status = 1")
|
|
||||||
Long getOnlineDevices();
|
|
||||||
|
|
||||||
@Select({
|
@Select({
|
||||||
"SELECT",
|
"SELECT",
|
||||||
@@ -69,16 +58,6 @@ public interface DashboardMapper {
|
|||||||
})
|
})
|
||||||
List<TrendDataVO> getOrderTrend();
|
List<TrendDataVO> getOrderTrend();
|
||||||
|
|
||||||
@Select({
|
|
||||||
"SELECT",
|
|
||||||
" device_type as type,",
|
|
||||||
" COUNT(*) as value",
|
|
||||||
"FROM devices",
|
|
||||||
"WHERE is_del = 0",
|
|
||||||
"GROUP BY device_type"
|
|
||||||
})
|
|
||||||
List<DistributionDataVO> getDeviceDistribution();
|
|
||||||
|
|
||||||
@Select({
|
@Select({
|
||||||
"SELECT",
|
"SELECT",
|
||||||
" 'platform' as type,",
|
" 'platform' as type,",
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.central.order.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.central.order.model.EditTask;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频编辑任务Mapper接口
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface EditTaskMapper extends BaseMapper<EditTask> {
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.central.order.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.central.order.model.VideoTemplate;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface VideoTemplateMapper extends BaseMapper<VideoTemplate> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.central.order.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("edit_task")
|
||||||
|
public class EditTask {
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
private String orderSn;
|
||||||
|
private String jobId;
|
||||||
|
private String result;
|
||||||
|
|
||||||
|
@Schema(description = "状态:0-待处理 1-处理中 2-处理完成 3-处理失败")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
//租户ID
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
+3
-4
@@ -1,14 +1,13 @@
|
|||||||
package com.central.order.model;
|
package com.central.order.model;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.Getter;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一键成片请求参数实体类
|
* 一键成片请求参数实体类
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.central.order.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.central.common.model.SuperEntity;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("video_template")
|
||||||
|
@Schema(description = "视频模板")
|
||||||
|
public class VideoTemplate extends SuperEntity {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
@Schema(description = "主键ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "模板ID")
|
||||||
|
private String templateId;
|
||||||
|
|
||||||
|
@Schema(description = "模板名称")
|
||||||
|
private String templateName;
|
||||||
|
|
||||||
|
@Schema(description = "模板描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "状态:0-禁用 1-启用")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "模板配置JSON")
|
||||||
|
private String config;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Schema(description = "更新时间")
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@Schema(description = "租户ID")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
@Schema(description = "所属公司")
|
||||||
|
private String company;
|
||||||
|
|
||||||
|
@Schema(description = "是否删除:0-否 1-是")
|
||||||
|
private Integer isDel;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.central.order.model.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CallbackDTO {
|
||||||
|
private String jobId;
|
||||||
|
private String status; // SUCCESS, FAILED
|
||||||
|
private String result; // 处理结果,可能包含视频URL或错误信息
|
||||||
|
private String errorCode;
|
||||||
|
private String errorMessage;
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package com.central.order.model.dto;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class VideoEditRequest {
|
||||||
|
private List<MediaInfo> sources;
|
||||||
|
private OutputInfo output;
|
||||||
|
private String templateId;
|
||||||
|
private String projectName;
|
||||||
|
private String pipelineName;
|
||||||
|
private String callbackUrl;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public static class MediaInfo {
|
||||||
|
private String mediaUrl;
|
||||||
|
private String mediaType; // VIDEO, IMAGE, AUDIO
|
||||||
|
private Integer duration; // 持续时间(毫秒)
|
||||||
|
private String text; // 文本内容
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public static class OutputInfo {
|
||||||
|
private String outputName;
|
||||||
|
private String outputType; // MP4, MOV等
|
||||||
|
private Integer width;
|
||||||
|
private Integer height;
|
||||||
|
private String quality; // HD, SD等
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.central.order.model.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频编辑状态枚举
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum VideoEditStatus {
|
||||||
|
QUEUED("Queued", "排队中"),
|
||||||
|
RUNNING("Running", "处理中"),
|
||||||
|
SUCCESS("Success", "处理成功"),
|
||||||
|
FAIL("Fail", "处理失败"),
|
||||||
|
UNKNOWN("Unknown", "未知状态");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
VideoEditStatus(String code, String desc) {
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VideoEditStatus fromCode(String code) {
|
||||||
|
for (VideoEditStatus status : values()) {
|
||||||
|
if (status.getCode().equals(code)) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package com.central.order.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.central.order.model.EditTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频编辑任务服务接口
|
||||||
|
*/
|
||||||
|
public interface IEditTaskService extends IService<EditTask> {
|
||||||
|
/**
|
||||||
|
* 创建编辑任务
|
||||||
|
*
|
||||||
|
* @param orderSn 订单编号
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 任务实体
|
||||||
|
*/
|
||||||
|
EditTask createTask(String orderSn, Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新任务状态
|
||||||
|
*
|
||||||
|
* @param jobId 任务ID
|
||||||
|
* @param status 状态
|
||||||
|
* @param result 结果信息
|
||||||
|
* @return 是否更新成功
|
||||||
|
*/
|
||||||
|
boolean updateTaskStatus(String jobId, Integer status, String result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据任务ID获取任务
|
||||||
|
*
|
||||||
|
* @param jobId 任务ID
|
||||||
|
* @return 任务实体
|
||||||
|
*/
|
||||||
|
EditTask getTaskByJobId(String jobId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单号获取最新任务
|
||||||
|
*
|
||||||
|
* @param orderSn 订单编号
|
||||||
|
* @return 任务实体
|
||||||
|
*/
|
||||||
|
EditTask getTaskByOrderSn(String orderSn);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.central.order.service;
|
||||||
|
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
|
import com.central.order.model.TourismFile;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IMediaService {
|
||||||
|
/**
|
||||||
|
* 提交智能一键成片任务
|
||||||
|
*/
|
||||||
|
String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询任务状态
|
||||||
|
*/
|
||||||
|
String getTaskStatus(String jobId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务结果
|
||||||
|
*/
|
||||||
|
String getTaskResult(String jobId);
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package com.central.order.service;
|
||||||
|
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
|
import com.central.order.model.TourismFile;
|
||||||
|
import com.central.order.model.dto.VideoEditStatus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频编辑服务接口
|
||||||
|
*/
|
||||||
|
public interface IVideoEditService {
|
||||||
|
/**
|
||||||
|
* 提交编辑任务
|
||||||
|
*
|
||||||
|
* @param orderNo 订单号
|
||||||
|
* @param orderFiles 订单相关文件
|
||||||
|
* @param tourismFiles 景区相关文件
|
||||||
|
* @return 任务ID
|
||||||
|
*/
|
||||||
|
String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询编辑任务状态
|
||||||
|
*
|
||||||
|
* @param jobId 任务ID
|
||||||
|
* @return 任务状态
|
||||||
|
*/
|
||||||
|
VideoEditStatus queryEditStatus(String jobId);
|
||||||
|
}
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
package com.central.order.service;
|
||||||
|
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.ISuperService;
|
||||||
|
import com.central.order.model.VideoTemplate;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface IVideoTemplateService extends ISuperService<VideoTemplate> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询模板
|
||||||
|
*/
|
||||||
|
PageResult<VideoTemplate> findList(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加模板
|
||||||
|
*/
|
||||||
|
boolean saveTemplate(VideoTemplate template);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新模板
|
||||||
|
*/
|
||||||
|
boolean updateTemplate(VideoTemplate template);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除模板
|
||||||
|
*/
|
||||||
|
boolean deleteTemplate(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新模板状态
|
||||||
|
*/
|
||||||
|
boolean updateStatus(Long id, Integer status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取可用模板
|
||||||
|
*/
|
||||||
|
VideoTemplate getActiveTemplate();
|
||||||
|
}
|
||||||
+12
-62
@@ -22,23 +22,22 @@ public class DashboardServiceImpl implements IDashboardService {
|
|||||||
public DashboardStatisticsVO getDashboardStatistics() {
|
public DashboardStatisticsVO getDashboardStatistics() {
|
||||||
DashboardStatisticsVO statistics = new DashboardStatisticsVO();
|
DashboardStatisticsVO statistics = new DashboardStatisticsVO();
|
||||||
|
|
||||||
// 1. 获取订单统计
|
try {
|
||||||
statistics.setOrderStats(getOrderStatistics());
|
// 1. 获取订单统计
|
||||||
|
statistics.setOrderStats(getOrderStatistics());
|
||||||
|
|
||||||
// 2. 获取收入统计
|
// 2. 获取收入统计
|
||||||
statistics.setIncomeStats(getIncomeStatistics());
|
statistics.setIncomeStats(getIncomeStatistics());
|
||||||
|
|
||||||
// 3. 获取航线统计
|
// 5. 获取图表统计
|
||||||
// statistics.setWaylineStats(getWaylineStatistics());
|
statistics.setChartStats(getChartStatistics());
|
||||||
|
|
||||||
// 4. 获取设备统计
|
// 6. 获取景区排行
|
||||||
// statistics.setDeviceStats(getDeviceStatistics());
|
statistics.setTourismRanking(getTourismRanking());
|
||||||
|
|
||||||
// 5. 获取图表统计
|
} catch (Exception e) {
|
||||||
statistics.setChartStats(getChartStatistics());
|
log.error("获取仪表盘统计数据失败", e);
|
||||||
|
}
|
||||||
// 6. 获取景区排行
|
|
||||||
statistics.setTourismRanking(getTourismRanking());
|
|
||||||
|
|
||||||
return statistics;
|
return statistics;
|
||||||
}
|
}
|
||||||
@@ -100,52 +99,6 @@ public class DashboardServiceImpl implements IDashboardService {
|
|||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取航线统计
|
|
||||||
*/
|
|
||||||
private WaylineStatistics getWaylineStatistics() {
|
|
||||||
WaylineStatistics stats = new WaylineStatistics();
|
|
||||||
|
|
||||||
// 获取航线总数
|
|
||||||
stats.setTotalWaylines(dashboardMapper.getTotalWaylines());
|
|
||||||
|
|
||||||
// 获取活跃航线数
|
|
||||||
stats.setActiveWaylines(dashboardMapper.getActiveWaylines());
|
|
||||||
|
|
||||||
// 计算使用率
|
|
||||||
if (stats.getTotalWaylines() > 0) {
|
|
||||||
BigDecimal usage = new BigDecimal(stats.getActiveWaylines())
|
|
||||||
.divide(new BigDecimal(stats.getTotalWaylines()), 4, RoundingMode.HALF_UP)
|
|
||||||
.multiply(new BigDecimal(100));
|
|
||||||
stats.setWaylineUsage(usage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取设备统计
|
|
||||||
*/
|
|
||||||
private DeviceStatistics getDeviceStatistics() {
|
|
||||||
DeviceStatistics stats = new DeviceStatistics();
|
|
||||||
|
|
||||||
// 获取设备总数
|
|
||||||
stats.setTotalDevices(dashboardMapper.getTotalDevices());
|
|
||||||
|
|
||||||
// 获取在线设备数
|
|
||||||
stats.setOnlineDevices(dashboardMapper.getOnlineDevices());
|
|
||||||
|
|
||||||
// 计算在线率
|
|
||||||
if (stats.getTotalDevices() > 0) {
|
|
||||||
BigDecimal onlineRate = new BigDecimal(stats.getOnlineDevices())
|
|
||||||
.divide(new BigDecimal(stats.getTotalDevices()), 4, RoundingMode.HALF_UP)
|
|
||||||
.multiply(new BigDecimal(100));
|
|
||||||
stats.setDeviceOnlineRate(onlineRate);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取图表统计
|
* 获取图表统计
|
||||||
*/
|
*/
|
||||||
@@ -155,9 +108,6 @@ public class DashboardServiceImpl implements IDashboardService {
|
|||||||
// 获取订单趋势(最近7天)
|
// 获取订单趋势(最近7天)
|
||||||
stats.setOrderTrend(dashboardMapper.getOrderTrend());
|
stats.setOrderTrend(dashboardMapper.getOrderTrend());
|
||||||
|
|
||||||
// 获取设备分布
|
|
||||||
// stats.setDeviceDistribution(dashboardMapper.getDeviceDistribution());
|
|
||||||
|
|
||||||
// 获取收入构成
|
// 获取收入构成
|
||||||
stats.setIncomeData(dashboardMapper.getIncomeData());
|
stats.setIncomeData(dashboardMapper.getIncomeData());
|
||||||
|
|
||||||
|
|||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.central.common.exception.BusinessException;
|
||||||
|
import com.central.order.mapper.EditTaskMapper;
|
||||||
|
import com.central.order.model.EditTask;
|
||||||
|
import com.central.order.service.IEditTaskService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频编辑任务服务实现类
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class EditTaskServiceImpl extends ServiceImpl<EditTaskMapper, EditTask> implements IEditTaskService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public EditTask createTask(String orderSn, Long userId) {
|
||||||
|
try {
|
||||||
|
EditTask task = EditTask.builder()
|
||||||
|
.orderSn(orderSn)
|
||||||
|
.userId(userId)
|
||||||
|
.status(0) // 初始状态:待处理
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 保存任务
|
||||||
|
if (!save(task)) {
|
||||||
|
throw new BusinessException("创建任务失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
return task;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("创建编辑任务失败: orderSn={}, userId={}", orderSn, userId, e);
|
||||||
|
throw new BusinessException("创建任务失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean updateTaskStatus(String jobId, Integer status, String result) {
|
||||||
|
try {
|
||||||
|
return update(new LambdaUpdateWrapper<EditTask>()
|
||||||
|
.eq(EditTask::getJobId, jobId)
|
||||||
|
.set(EditTask::getStatus, status)
|
||||||
|
.set(EditTask::getResult, result)
|
||||||
|
.set(EditTask::getRemark, "状态更新时间:" + new Date()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新任务状态失败: jobId={}, status={}", jobId, status, e);
|
||||||
|
throw new BusinessException("更新任务状态失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EditTask getTaskByJobId(String jobId) {
|
||||||
|
try {
|
||||||
|
return getOne(new LambdaQueryWrapper<EditTask>()
|
||||||
|
.eq(EditTask::getJobId, jobId));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询任务失败: jobId={}", jobId, e);
|
||||||
|
throw new BusinessException("查询任务失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EditTask getTaskByOrderSn(String orderSn) {
|
||||||
|
try {
|
||||||
|
return getOne(new LambdaQueryWrapper<EditTask>()
|
||||||
|
.eq(EditTask::getOrderSn, orderSn)
|
||||||
|
.orderByDesc(EditTask::getId)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询订单任务失败: orderSn={}", orderSn, e);
|
||||||
|
throw new BusinessException("查询订单任务失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+151
@@ -0,0 +1,151 @@
|
|||||||
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.aliyun.ice20201109.Client;
|
||||||
|
import com.aliyun.ice20201109.models.*;
|
||||||
|
import com.central.common.exception.BusinessException;
|
||||||
|
import com.central.order.config.AliyunImsConfig;
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
|
import com.central.order.model.TourismFile;
|
||||||
|
import com.central.order.service.IMediaService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MediaServiceImpl implements IMediaService {
|
||||||
|
|
||||||
|
private final Client imsClient;
|
||||||
|
private final AliyunImsConfig imsConfig;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||||
|
try {
|
||||||
|
// 1. 构建媒体资源列表
|
||||||
|
List<String> mediaAssets = buildMediaAssets(orderFiles, tourismFiles);
|
||||||
|
|
||||||
|
// 2. 构建输出配置
|
||||||
|
String outputConfig = buildOutputConfig(orderNo);
|
||||||
|
|
||||||
|
// 3. 构建请求
|
||||||
|
SubmitBatchMediaProducingJobRequest request = new SubmitBatchMediaProducingJobRequest()
|
||||||
|
.setProject(imsConfig.getProjectName())
|
||||||
|
.setPipelineName(imsConfig.getPipelineName())
|
||||||
|
.setTemplateId(imsConfig.getTemplateId())
|
||||||
|
.setInputMediaAssets(mediaAssets)
|
||||||
|
.setOutputConfig(outputConfig)
|
||||||
|
.setCallbackUrl(imsConfig.getCallbackUrl());
|
||||||
|
|
||||||
|
// 4. 提交任务
|
||||||
|
SubmitBatchMediaProducingJobResponse response = imsClient.submitBatchMediaProducingJob(request);
|
||||||
|
|
||||||
|
if (response != null && response.getStatusCode() == 200) {
|
||||||
|
String jobId = response.getBody().getJobId();
|
||||||
|
log.info("提交智能一键成片任务成功: orderNo={}, jobId={}", orderNo, jobId);
|
||||||
|
return jobId;
|
||||||
|
} else {
|
||||||
|
throw new BusinessException("提交任务失败: " + (response != null ? response.getBody().getMessage() : "未知错误"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("提交智能一键成片任务失败: orderNo={}", orderNo, e);
|
||||||
|
throw new BusinessException("提交任务失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTaskStatus(String jobId) {
|
||||||
|
try {
|
||||||
|
GetBatchMediaProducingJobRequest request = new GetBatchMediaProducingJobRequest()
|
||||||
|
.setJobId(jobId)
|
||||||
|
.setProject(imsConfig.getProjectName());
|
||||||
|
|
||||||
|
GetBatchMediaProducingJobResponse response = imsClient.getBatchMediaProducingJob(request);
|
||||||
|
|
||||||
|
if (response != null && response.getBody() != null) {
|
||||||
|
return response.getBody().getStatus();
|
||||||
|
}
|
||||||
|
return "UNKNOWN";
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询任务状态失败: jobId={}", jobId, e);
|
||||||
|
throw new BusinessException("查询任务状态失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTaskResult(String jobId) {
|
||||||
|
try {
|
||||||
|
GetBatchMediaProducingJobRequest request = new GetBatchMediaProducingJobRequest()
|
||||||
|
.setJobId(jobId)
|
||||||
|
.setProject(imsConfig.getProjectName());
|
||||||
|
|
||||||
|
GetBatchMediaProducingJobResponse response = imsClient.getBatchMediaProducingJob(request);
|
||||||
|
|
||||||
|
if (response != null && response.getBody() != null) {
|
||||||
|
return response.getBody().getOutputUrl();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取任务结果失败: jobId={}", jobId, e);
|
||||||
|
throw new BusinessException("获取任务结果失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建媒体资源列表
|
||||||
|
*/
|
||||||
|
private List<String> buildMediaAssets(List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||||
|
List<String> assets = new ArrayList<>();
|
||||||
|
|
||||||
|
// 处理订单文件
|
||||||
|
if (orderFiles != null) {
|
||||||
|
for (OrderFile file : orderFiles) {
|
||||||
|
assets.add(String.format("{\"type\":\"%s\",\"url\":\"oss://%s/%s\"}",
|
||||||
|
getMediaType(file.getFileType()),
|
||||||
|
imsConfig.getBucket(),
|
||||||
|
file.getFilePath()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理景区文件
|
||||||
|
if (tourismFiles != null) {
|
||||||
|
for (TourismFile file : tourismFiles) {
|
||||||
|
assets.add(String.format("{\"type\":\"image\",\"url\":\"oss://%s/%s\"}",
|
||||||
|
imsConfig.getBucket(),
|
||||||
|
file.getImageUrl()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return assets;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建输出配置
|
||||||
|
*/
|
||||||
|
private String buildOutputConfig(String orderNo) {
|
||||||
|
return String.format(
|
||||||
|
"{\"resolution\":\"1080p\",\"bitrate\":\"5000kbps\",\"fileName\":\"%s_%s\"}",
|
||||||
|
orderNo,
|
||||||
|
System.currentTimeMillis()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取媒体类型
|
||||||
|
*/
|
||||||
|
private String getMediaType(String fileType) {
|
||||||
|
if (fileType == null) return "other";
|
||||||
|
if (fileType.startsWith("video/")) return "video";
|
||||||
|
if (fileType.startsWith("audio/")) return "audio";
|
||||||
|
if (fileType.startsWith("image/")) return "image";
|
||||||
|
return "other";
|
||||||
|
}
|
||||||
|
}
|
||||||
+56
@@ -0,0 +1,56 @@
|
|||||||
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.central.common.exception.BusinessException;
|
||||||
|
import com.central.order.constants.EditTaskStatus;
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
|
import com.central.order.model.TourismFile;
|
||||||
|
import com.central.order.model.dto.VideoEditStatus;
|
||||||
|
import com.central.order.service.IEditTaskService;
|
||||||
|
import com.central.order.service.IMediaService;
|
||||||
|
import com.central.order.service.IVideoEditService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频编辑服务实现类
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class VideoEditServiceImpl implements IVideoEditService {
|
||||||
|
|
||||||
|
private final IMediaService mediaService;
|
||||||
|
private final IEditTaskService editTaskService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||||
|
try {
|
||||||
|
// 提交智能一键成片任务
|
||||||
|
String jobId = mediaService.submitEditTask(orderNo, orderFiles, tourismFiles);
|
||||||
|
|
||||||
|
// 更新任务状态
|
||||||
|
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
||||||
|
|
||||||
|
return jobId;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("提交视频编辑任务失败: orderNo={}", orderNo, e);
|
||||||
|
throw new BusinessException("提交编辑任务失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VideoEditStatus queryEditStatus(String jobId) {
|
||||||
|
try {
|
||||||
|
String status = mediaService.getTaskStatus(jobId);
|
||||||
|
return VideoEditStatus.fromCode(status);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询任务状态失败: jobId={}", jobId, e);
|
||||||
|
throw new BusinessException("查询任务状态失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
|
import com.central.order.mapper.VideoTemplateMapper;
|
||||||
|
import com.central.order.model.VideoTemplate;
|
||||||
|
import com.central.order.service.IVideoTemplateService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class VideoTemplateServiceImpl extends SuperServiceImpl<VideoTemplateMapper, VideoTemplate> implements IVideoTemplateService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<VideoTemplate> findList(Map<String, Object> params) {
|
||||||
|
Page<VideoTemplate> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||||
|
|
||||||
|
LambdaQueryWrapper<VideoTemplate> wrapper = new LambdaQueryWrapper<VideoTemplate>()
|
||||||
|
.eq(VideoTemplate::getIsDel, 0)
|
||||||
|
.orderByDesc(VideoTemplate::getCreateTime);
|
||||||
|
|
||||||
|
Page<VideoTemplate> result = baseMapper.selectPage(page, wrapper);
|
||||||
|
return PageResult.<VideoTemplate>builder().data(result.getRecords()).count(result.getTotal()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean saveTemplate(VideoTemplate template) {
|
||||||
|
template.setCreateTime(new Date());
|
||||||
|
template.setUpdateTime(new Date());
|
||||||
|
template.setIsDel(0);
|
||||||
|
return save(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean updateTemplate(VideoTemplate template) {
|
||||||
|
template.setUpdateTime(new Date());
|
||||||
|
return updateById(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean deleteTemplate(Long id) {
|
||||||
|
VideoTemplate template = getById(id);
|
||||||
|
if (template != null) {
|
||||||
|
template.setIsDel(1);
|
||||||
|
template.setUpdateTime(new Date());
|
||||||
|
return updateById(template);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean updateStatus(Long id, Integer status) {
|
||||||
|
VideoTemplate template = getById(id);
|
||||||
|
if (template != null) {
|
||||||
|
template.setStatus(status);
|
||||||
|
template.setUpdateTime(new Date());
|
||||||
|
return updateById(template);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VideoTemplate getActiveTemplate() {
|
||||||
|
return getOne(new LambdaQueryWrapper<VideoTemplate>()
|
||||||
|
.eq(VideoTemplate::getStatus, 1)
|
||||||
|
.eq(VideoTemplate::getIsDel, 0)
|
||||||
|
.orderByDesc(VideoTemplate::getCreateTime)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,6 +75,18 @@ file:
|
|||||||
# password: ${zlt.datasource.password}
|
# password: ${zlt.datasource.password}
|
||||||
videos:
|
videos:
|
||||||
edit-config:
|
edit-config:
|
||||||
url: ${EDIT_SERVICE_URL:http://example.com/api/edit}
|
url: ${VIDEOS_EDIT_URL:http://example.com/api/edit}
|
||||||
app-id: ${EDIT_APP_ID:your-app-id}
|
app-id: ${VIDEOS_APP_ID:gcb4432dcc7e4e3a92063807f3e75d58}
|
||||||
callback-url: ${EDIT_CALLBACK_URL:http://your-domain/api/callback}
|
callback-url: ${VIDEOS_CALLBACK_URL:http://img.goflytec.com/api-order/auto/cut/callback}
|
||||||
|
|
||||||
|
aliyun:
|
||||||
|
ims:
|
||||||
|
endpoint: ice.cn-shanghai.aliyuncs.com
|
||||||
|
access-key-id: ${ALIYUN_ACCESS_KEY_ID}
|
||||||
|
access-key-secret: ${ALIYUN_ACCESS_KEY_SECRET}
|
||||||
|
region: cn-shanghai
|
||||||
|
project-name: ${IMS_PROJECT_NAME}
|
||||||
|
pipeline-name: ${IMS_PIPELINE_NAME}
|
||||||
|
template-id: ${IMS_TEMPLATE_ID}
|
||||||
|
callback-url: ${IMS_CALLBACK_URL}
|
||||||
|
bucket: ${OSS_BUCKET_NAME}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: user-center
|
name: user-center
|
||||||
cloud:
|
# cloud:
|
||||||
nacos:
|
# nacos:
|
||||||
discovery:
|
# discovery:
|
||||||
ip: 124.222.128.40
|
# ip: 124.222.128.40
|
||||||
# cloud:
|
# cloud:
|
||||||
# nacos:
|
# nacos:
|
||||||
# discovery:
|
# discovery:
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: uaa-server
|
name: uaa-server
|
||||||
cloud:
|
# cloud:
|
||||||
nacos:
|
# nacos:
|
||||||
discovery:
|
# discovery:
|
||||||
ip: 124.222.128.40
|
# ip: 124.222.128.40
|
||||||
|
|
||||||
encrypt:
|
encrypt:
|
||||||
key-store:
|
key-store:
|
||||||
|
|||||||
@@ -112,6 +112,10 @@
|
|||||||
path: '/orders/profit-sharing/statistics.html',
|
path: '/orders/profit-sharing/statistics.html',
|
||||||
component: './orders/ProfitSharing/Statistics',
|
component: './orders/ProfitSharing/Statistics',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/orders/videoTemplate.html',
|
||||||
|
component: './orders/VideoTemplate',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+150
@@ -0,0 +1,150 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormSelect,
|
||||||
|
ProFormText,
|
||||||
|
ProFormDigit,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
|
||||||
|
interface CreateFormProps {
|
||||||
|
visible: boolean;
|
||||||
|
onVisibleChange: (visible: boolean) => void;
|
||||||
|
onSubmit: (values: ORDERS.Qrcode) => Promise<boolean>;
|
||||||
|
templateOptions: any[];
|
||||||
|
tourismOptions: any[];
|
||||||
|
waylineOptions: any[];
|
||||||
|
deviceOptions: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreateForm: React.FC<CreateFormProps> = ({
|
||||||
|
visible,
|
||||||
|
onVisibleChange,
|
||||||
|
onSubmit,
|
||||||
|
templateOptions,
|
||||||
|
tourismOptions,
|
||||||
|
waylineOptions,
|
||||||
|
deviceOptions,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<ModalForm
|
||||||
|
title="新增二维码"
|
||||||
|
visible={visible}
|
||||||
|
onVisibleChange={onVisibleChange}
|
||||||
|
modalProps={{ destroyOnClose: true }}
|
||||||
|
onFinish={onSubmit}
|
||||||
|
>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="name"
|
||||||
|
label="名称"
|
||||||
|
rules={[{ required: true, message: '请输入名称' }]}
|
||||||
|
placeholder="请输入二维码名称"
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="tourismId"
|
||||||
|
label="景区"
|
||||||
|
options={tourismOptions}
|
||||||
|
rules={[{ required: true, message: '请选择景区' }]}
|
||||||
|
placeholder="请选择景区"
|
||||||
|
showSearch
|
||||||
|
fieldProps={{
|
||||||
|
loading: !tourismOptions.length,
|
||||||
|
filterOption: (input, option) =>
|
||||||
|
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="waylineId"
|
||||||
|
label="航线"
|
||||||
|
options={waylineOptions}
|
||||||
|
rules={[{ required: true, message: '请选择航线' }]}
|
||||||
|
placeholder="请选择航线"
|
||||||
|
showSearch
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="deviceSn"
|
||||||
|
label="设备"
|
||||||
|
options={deviceOptions}
|
||||||
|
rules={[{ required: true, message: '请选择设备' }]}
|
||||||
|
placeholder="请选择设备"
|
||||||
|
showSearch
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="price"
|
||||||
|
label="价格(分)"
|
||||||
|
rules={[{ required: true, message: '请输入价格' }]}
|
||||||
|
min={0}
|
||||||
|
placeholder="请输入价格"
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
options={[
|
||||||
|
{ label: '启用', value: 0 },
|
||||||
|
{ label: '未启用', value: 1 },
|
||||||
|
]}
|
||||||
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
|
placeholder="请选择状态"
|
||||||
|
initialValue={0}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="templateId"
|
||||||
|
label="视频模板"
|
||||||
|
options={templateOptions}
|
||||||
|
rules={[{ required: true, message: '请选择视频模板' }]}
|
||||||
|
placeholder="请选择视频模板"
|
||||||
|
showSearch
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="payeeType"
|
||||||
|
label="分账账号类型"
|
||||||
|
options={[
|
||||||
|
{ label: '商户ID', value: 'MERCHANT_ID' },
|
||||||
|
{ label: '个人openid', value: 'PERSONAL_OPENID' },
|
||||||
|
]}
|
||||||
|
placeholder="请选择分账账号类型"
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
width="md"
|
||||||
|
name="payeeAccount"
|
||||||
|
label="分账账号"
|
||||||
|
placeholder="请输入分账账号"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="profitRate"
|
||||||
|
label="分账比例(%)"
|
||||||
|
min={0}
|
||||||
|
max={100}
|
||||||
|
placeholder="请输入分账比例"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CreateForm;
|
||||||
+83
-81
@@ -1,3 +1,4 @@
|
|||||||
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
ModalForm,
|
ModalForm,
|
||||||
ProForm,
|
ProForm,
|
||||||
@@ -5,36 +6,31 @@ import {
|
|||||||
ProFormText,
|
ProFormText,
|
||||||
ProFormDigit,
|
ProFormDigit,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import React, { useEffect } from 'react';
|
|
||||||
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS } from '../index';
|
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS } from '../index';
|
||||||
|
import { Form, Space } from 'antd';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
export type UpdateFormProps = {
|
interface UpdateFormProps {
|
||||||
onSubmit: (values: ORDERS.Qrcode) => Promise<void>;
|
|
||||||
onVisibleChange: (visible: boolean) => void;
|
|
||||||
updateModalVisible: boolean;
|
updateModalVisible: boolean;
|
||||||
values: Partial<ORDERS.Qrcode>;
|
onVisibleChange: (visible: boolean) => void;
|
||||||
waylineOptions: any[];
|
onSubmit: (values: Partial<ORDERS.Qrcode>) => Promise<boolean>;
|
||||||
|
values?: ORDERS.Qrcode;
|
||||||
|
templateOptions: any[];
|
||||||
tourismOptions: any[];
|
tourismOptions: any[];
|
||||||
deviceOptions: any[]; // 添加设备选项属性
|
waylineOptions: any[];
|
||||||
};
|
deviceOptions: any[];
|
||||||
|
}
|
||||||
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
||||||
const {
|
|
||||||
updateModalVisible,
|
|
||||||
onVisibleChange,
|
|
||||||
onSubmit,
|
|
||||||
values,
|
|
||||||
waylineOptions,
|
|
||||||
tourismOptions,
|
|
||||||
deviceOptions, // 解构设备选项
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log('UpdateForm values:', values);
|
|
||||||
console.log('UpdateForm tourismOptions:', tourismOptions);
|
|
||||||
console.log('UpdateForm waylineOptions:', waylineOptions);
|
|
||||||
}, [values, tourismOptions, waylineOptions]);
|
|
||||||
|
|
||||||
|
const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||||
|
updateModalVisible,
|
||||||
|
onVisibleChange,
|
||||||
|
onSubmit,
|
||||||
|
values,
|
||||||
|
templateOptions,
|
||||||
|
tourismOptions,
|
||||||
|
waylineOptions,
|
||||||
|
deviceOptions,
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
title="修改二维码"
|
title="修改二维码"
|
||||||
@@ -49,20 +45,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
width="md"
|
width="md"
|
||||||
name="name"
|
name="name"
|
||||||
label="名称"
|
label="名称"
|
||||||
placeholder="请输入二维码名称"
|
|
||||||
rules={[{ required: true, message: '请输入名称' }]}
|
rules={[{ required: true, message: '请输入名称' }]}
|
||||||
/>
|
placeholder="请输入二维码名称"
|
||||||
<ProFormSelect
|
|
||||||
width="md"
|
|
||||||
name="waylineId"
|
|
||||||
label="航线"
|
|
||||||
options={waylineOptions}
|
|
||||||
rules={[{ required: true, message: '请选择航线' }]}
|
|
||||||
fieldProps={{
|
|
||||||
showSearch: true,
|
|
||||||
filterOption: (input, option) =>
|
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
width="md"
|
width="md"
|
||||||
@@ -70,81 +54,99 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|||||||
label="景区"
|
label="景区"
|
||||||
options={tourismOptions}
|
options={tourismOptions}
|
||||||
rules={[{ required: true, message: '请选择景区' }]}
|
rules={[{ required: true, message: '请选择景区' }]}
|
||||||
|
placeholder="请选择景区"
|
||||||
|
showSearch
|
||||||
fieldProps={{
|
fieldProps={{
|
||||||
loading: !tourismOptions.length,
|
loading: !tourismOptions.length,
|
||||||
showSearch: true,
|
|
||||||
filterOption: (input, option) =>
|
filterOption: (input, option) =>
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||||
notFoundContent: tourismOptions.length === 0 ? '暂无景区数据' : undefined,
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
width="md"
|
width="md"
|
||||||
name="price"
|
name="waylineId"
|
||||||
label="景点打卡价格"
|
label="航线"
|
||||||
rules={[{ required: true, message: '价格不能为空' }]}
|
options={waylineOptions}
|
||||||
|
rules={[{ required: true, message: '请选择航线' }]}
|
||||||
|
placeholder="请选择航线"
|
||||||
|
showSearch
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
width="md"
|
width="md"
|
||||||
name="deviceSn"
|
name="deviceSn"
|
||||||
label="设备编号"
|
label="设备"
|
||||||
options={deviceOptions}
|
options={deviceOptions}
|
||||||
rules={[{ required: true, message: '设备不能为空' }]}
|
rules={[{ required: true, message: '请选择设备' }]}
|
||||||
fieldProps={{
|
placeholder="请选择设备"
|
||||||
loading: !deviceOptions.length,
|
showSearch
|
||||||
showSearch: true,
|
/>
|
||||||
filterOption: (input, option) =>
|
</ProForm.Group>
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
|
||||||
notFoundContent: deviceOptions.length === 0 ? '暂无设备数据' : undefined,
|
<ProForm.Group>
|
||||||
}}
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="price"
|
||||||
|
label="价格(分)"
|
||||||
|
rules={[{ required: true, message: '请输入价格' }]}
|
||||||
|
min={0}
|
||||||
|
placeholder="请输入价格"
|
||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
width="md"
|
width="md"
|
||||||
name="status"
|
name="status"
|
||||||
label="状态"
|
label="状态"
|
||||||
options={STATUS_OPTIONS}
|
options={[
|
||||||
|
{ label: '启用', value: 0 },
|
||||||
|
{ label: '未启用', value: 1 },
|
||||||
|
]}
|
||||||
rules={[{ required: true, message: '请选择状态' }]}
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
|
placeholder="请选择状态"
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
<ProForm.Group title="分账配置">
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="templateId"
|
||||||
|
label="视频模板"
|
||||||
|
options={templateOptions}
|
||||||
|
rules={[{ required: true, message: '请选择视频模板' }]}
|
||||||
|
placeholder="请选择视频模板"
|
||||||
|
showSearch
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="payeeType"
|
||||||
|
label="分账账号类型"
|
||||||
|
options={[
|
||||||
|
{ label: '商户ID', value: 'MERCHANT_ID' },
|
||||||
|
{ label: '个人openid', value: 'PERSONAL_OPENID' },
|
||||||
|
]}
|
||||||
|
placeholder="请选择分账账号类型"
|
||||||
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
width="md"
|
width="md"
|
||||||
name="payeeAccount"
|
name="payeeAccount"
|
||||||
label="分账账号"
|
label="分账账号"
|
||||||
placeholder="请输入分账接收账号"
|
placeholder="请输入分账账号"
|
||||||
rules={[{ required: true, message: '请输入分账账号' }]}
|
|
||||||
/>
|
|
||||||
<ProFormSelect
|
|
||||||
width="md"
|
|
||||||
name="payeeType"
|
|
||||||
label="账号类型"
|
|
||||||
options={PAYEE_TYPE_OPTIONS}
|
|
||||||
rules={[{ required: true, message: '请选择账号类型' }]}
|
|
||||||
/>
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
<ProFormDigit
|
<ProFormDigit
|
||||||
width="md"
|
width="md"
|
||||||
name="profitRate"
|
name="profitRate"
|
||||||
label="分账比例"
|
label="分账比例(%)"
|
||||||
min={0}
|
min={0}
|
||||||
max={100}
|
max={100}
|
||||||
fieldProps={{
|
placeholder="请输入分账比例"
|
||||||
precision: 2,
|
|
||||||
suffix: '%',
|
|
||||||
}}
|
|
||||||
rules={[
|
|
||||||
{ required: true, message: '请输入分账比例' },
|
|
||||||
{ type: 'number', min: 0, max: 100, message: '比例必须在0-100之间' },
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
{values?.payeeStatus === 2 && (
|
|
||||||
<ProFormText
|
|
||||||
width="md"
|
|
||||||
name="payeeFailReason"
|
|
||||||
label="验证失败原因"
|
|
||||||
disabled
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
.formSection {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
|
||||||
|
.sectionTitle {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: rgba(0, 0, 0, 0.85);
|
||||||
|
margin-bottom: 16px;
|
||||||
|
padding-left: 8px;
|
||||||
|
border-left: 3px solid #1890ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:global {
|
||||||
|
.ant-form-item {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { deleteQrcode, qrcode, saveOrUpdateQrcode, getTourismList } from '@/services/orders/api';
|
import { deleteQrcode, qrcode, saveOrUpdateQrcode, getTourismList, getVideoTemplateList } from '@/services/orders/api';
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
import {
|
import {
|
||||||
@@ -16,6 +16,7 @@ import { Typography, Popconfirm, Space, message, Image, Button, Tag } from 'antd
|
|||||||
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
||||||
import UpdateForm from './components/UpdateForm';
|
import UpdateForm from './components/UpdateForm';
|
||||||
import { wayline, device } from '@/services/device/api';
|
import { wayline, device } from '@/services/device/api';
|
||||||
|
import CreateForm from './components/CreateForm';
|
||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
@@ -65,47 +66,6 @@ const handleApiRequest = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAdd = async (fields: ORDERS.Qrcode) => {
|
|
||||||
return handleApiRequest(
|
|
||||||
() => saveOrUpdateQrcode({ ...fields }),
|
|
||||||
'正在添加',
|
|
||||||
'添加成功'
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEdit = async (original: ORDERS.Qrcode, fields: Partial<ORDERS.Qrcode>) => {
|
|
||||||
return handleApiRequest(
|
|
||||||
() => saveOrUpdateQrcode({
|
|
||||||
id: original.id, // 保留原始ID
|
|
||||||
...fields // 只包含修改的字段
|
|
||||||
}),
|
|
||||||
'正在更新',
|
|
||||||
'修改成功'
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDelete = async (qrcode: ORDERS.Qrcode) => {
|
|
||||||
return handleApiRequest(
|
|
||||||
() => deleteQrcode(qrcode.id),
|
|
||||||
'正在删除',
|
|
||||||
'删除成功'
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 状态颜色映射
|
|
||||||
const statusColorMap = {
|
|
||||||
0: { color: 'green', text: '启用' },
|
|
||||||
1: { color: 'red', text: '未启用' },
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// 渲染状态标签
|
|
||||||
const renderStatus = (status: {} | null | undefined) => {
|
|
||||||
const statusInfo = statusColorMap[status] || { color: 'gray', text: '未知状态' };
|
|
||||||
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
const [params, setParams] = useState<Record<string, string | number>>({});
|
const [params, setParams] = useState<Record<string, string | number>>({});
|
||||||
@@ -115,8 +75,46 @@ const TableList: React.FC = () => {
|
|||||||
const [waylineOptions, setWaylineOptions] = useState<any[]>([]);
|
const [waylineOptions, setWaylineOptions] = useState<any[]>([]);
|
||||||
const [tourismOptions, setTourismOptions] = useState<any[]>([]);
|
const [tourismOptions, setTourismOptions] = useState<any[]>([]);
|
||||||
const [deviceOptions, setDeviceOptions] = useState<any[]>([]);
|
const [deviceOptions, setDeviceOptions] = useState<any[]>([]);
|
||||||
|
const [templateOptions, setTemplateOptions] = useState<any[]>([]);
|
||||||
const formRef = useRef();
|
const formRef = useRef();
|
||||||
|
|
||||||
|
// 将 renderStatus 函数移到组件内部
|
||||||
|
const renderStatus = (status: number) => {
|
||||||
|
const statusColorMap = {
|
||||||
|
0: { color: 'green', text: '启用' },
|
||||||
|
1: { color: 'red', text: '未启用' },
|
||||||
|
};
|
||||||
|
const statusInfo = statusColorMap[status] || { color: 'gray', text: '未知状态' };
|
||||||
|
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理添加
|
||||||
|
const handleAdd = async (fields: ORDERS.Qrcode) => {
|
||||||
|
const template = templateOptions.find(item => item.value === fields.templateId);
|
||||||
|
return handleApiRequest(
|
||||||
|
() => saveOrUpdateQrcode({
|
||||||
|
...fields,
|
||||||
|
templateName: template?.label,
|
||||||
|
}),
|
||||||
|
'正在添加',
|
||||||
|
'添加成功'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理编辑
|
||||||
|
const handleEdit = async (original: ORDERS.Qrcode, fields: Partial<ORDERS.Qrcode>) => {
|
||||||
|
const template = templateOptions.find(item => item.value === fields.templateId);
|
||||||
|
return handleApiRequest(
|
||||||
|
() => saveOrUpdateQrcode({
|
||||||
|
id: original.id,
|
||||||
|
...fields,
|
||||||
|
templateName: template?.label,
|
||||||
|
}),
|
||||||
|
'正在更新',
|
||||||
|
'修改成功'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleTableAction = useCallback(async (
|
const handleTableAction = useCallback(async (
|
||||||
action: 'add' | 'edit' | 'delete',
|
action: 'add' | 'edit' | 'delete',
|
||||||
record?: ORDERS.Qrcode,
|
record?: ORDERS.Qrcode,
|
||||||
@@ -144,7 +142,7 @@ const TableList: React.FC = () => {
|
|||||||
if (success && actionRef.current) {
|
if (success && actionRef.current) {
|
||||||
actionRef.current.reload();
|
actionRef.current.reload();
|
||||||
}
|
}
|
||||||
}, []);
|
}, [templateOptions]);
|
||||||
|
|
||||||
const fetchTourismList = useCallback(async () => {
|
const fetchTourismList = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -201,11 +199,32 @@ const TableList: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const fetchTemplateOptions = useCallback(async () => {
|
||||||
|
try {
|
||||||
|
const result = await getVideoTemplateList({
|
||||||
|
page: 1,
|
||||||
|
limit: 100,
|
||||||
|
status: 1, // 只获取启用的模板
|
||||||
|
});
|
||||||
|
if (result.data?.data) {
|
||||||
|
const options = result.data.data.map(item => ({
|
||||||
|
label: item.templateName,
|
||||||
|
value: item.templateId,
|
||||||
|
info: item,
|
||||||
|
}));
|
||||||
|
setTemplateOptions(options);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error('获取模板列表失败');
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchTourismList();
|
fetchTourismList();
|
||||||
fetchWaylineOptions();
|
fetchWaylineOptions();
|
||||||
fetchDeviceList();
|
fetchDeviceList();
|
||||||
}, [fetchTourismList, fetchWaylineOptions, fetchDeviceList]);
|
fetchTemplateOptions();
|
||||||
|
}, [fetchTourismList, fetchWaylineOptions, fetchDeviceList, fetchTemplateOptions]);
|
||||||
|
|
||||||
const columns: ProColumns<ORDERS.Qrcode>[] = [
|
const columns: ProColumns<ORDERS.Qrcode>[] = [
|
||||||
{
|
{
|
||||||
@@ -280,7 +299,7 @@ const TableList: React.FC = () => {
|
|||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
width: 80,
|
width: 80,
|
||||||
render: (status) => renderStatus(status),
|
render: (status) => renderStatus(status as number),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '分账账号',
|
title: '分账账号',
|
||||||
@@ -323,6 +342,16 @@ const TableList: React.FC = () => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '模板名称',
|
||||||
|
dataIndex: 'templateId',
|
||||||
|
width: 180,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (_, record) => {
|
||||||
|
const template = templateOptions.find(item => item.value === record.templateId);
|
||||||
|
return template?.label || '-';
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
dataIndex: 'createTime',
|
dataIndex: 'createTime',
|
||||||
@@ -421,121 +450,22 @@ const TableList: React.FC = () => {
|
|||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ModalForm
|
<CreateForm
|
||||||
title="添加二维码"
|
onSubmit={async (values) => handleTableAction('add', undefined, values)}
|
||||||
visible={createModalVisible}
|
|
||||||
onVisibleChange={(visible) => {
|
onVisibleChange={(visible) => {
|
||||||
handleModalVisible(visible);
|
handleModalVisible(visible);
|
||||||
if (visible) {
|
if (visible) {
|
||||||
fetchDeviceList();
|
fetchDeviceList();
|
||||||
fetchTourismList();
|
fetchTourismList();
|
||||||
|
fetchTemplateOptions();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
modalProps={{ destroyOnClose: true }}
|
visible={createModalVisible}
|
||||||
onFinish={async (values) => handleTableAction('add', undefined, values)}
|
templateOptions={templateOptions}
|
||||||
>
|
tourismOptions={tourismOptions}
|
||||||
<ProForm.Group>
|
waylineOptions={waylineOptions}
|
||||||
<ProFormText
|
deviceOptions={deviceOptions}
|
||||||
width="md"
|
/>
|
||||||
name="name"
|
|
||||||
label="名称"
|
|
||||||
placeholder="请输入二维码名称"
|
|
||||||
rules={[{ required: true, message: '请输入名称' }]}
|
|
||||||
/>
|
|
||||||
<ProFormSelect
|
|
||||||
width="md"
|
|
||||||
name="waylineId"
|
|
||||||
label="航线"
|
|
||||||
placeholder="请选择航线"
|
|
||||||
options={waylineOptions}
|
|
||||||
rules={[{ required: true, message: '请选择航线' }]}
|
|
||||||
fieldProps={{
|
|
||||||
loading: !waylineOptions.length,
|
|
||||||
showSearch: true,
|
|
||||||
filterOption: (input, option) =>
|
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<ProFormSelect
|
|
||||||
width="md"
|
|
||||||
name="tourismId"
|
|
||||||
label="景区"
|
|
||||||
placeholder="请选择景区"
|
|
||||||
options={tourismOptions}
|
|
||||||
rules={[{ required: true, message: '请选择景区' }]}
|
|
||||||
fieldProps={{
|
|
||||||
loading: !tourismOptions.length,
|
|
||||||
showSearch: true,
|
|
||||||
filterOption: (input, option) =>
|
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
|
||||||
notFoundContent: tourismOptions.length === 0 ? '暂无景区数据' : undefined,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<ProFormText
|
|
||||||
width="md"
|
|
||||||
name="price"
|
|
||||||
label="景点打卡价格"
|
|
||||||
placeholder="输入价格(单位:分)"
|
|
||||||
rules={[{ required: true, message: '价格不为空' }]}
|
|
||||||
/>
|
|
||||||
<ProFormSelect
|
|
||||||
width="md"
|
|
||||||
name="deviceSn"
|
|
||||||
label="设备编号"
|
|
||||||
placeholder="请选择设备"
|
|
||||||
options={deviceOptions}
|
|
||||||
rules={[{ required: true, message: '设备不能为空' }]}
|
|
||||||
fieldProps={{
|
|
||||||
loading: !deviceOptions.length,
|
|
||||||
showSearch: true,
|
|
||||||
filterOption: (input, option) =>
|
|
||||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
|
||||||
notFoundContent: deviceOptions.length === 0 ? '暂无设备数据' : undefined,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<ProFormSelect
|
|
||||||
width="md"
|
|
||||||
name="status"
|
|
||||||
label="状态"
|
|
||||||
placeholder="请选择状态"
|
|
||||||
options={STATUS_OPTIONS}
|
|
||||||
initialValue={0}
|
|
||||||
rules={[{ required: true, message: '请选择状态' }]}
|
|
||||||
/>
|
|
||||||
</ProForm.Group>
|
|
||||||
|
|
||||||
<ProForm.Group title="分账配置">
|
|
||||||
<ProFormText
|
|
||||||
width="md"
|
|
||||||
name="payeeAccount"
|
|
||||||
label="分账账号"
|
|
||||||
placeholder="请输入分账接收账号"
|
|
||||||
rules={[{ required: true, message: '请输入分账账号' }]}
|
|
||||||
/>
|
|
||||||
<ProFormSelect
|
|
||||||
width="md"
|
|
||||||
name="payeeType"
|
|
||||||
label="账号类型"
|
|
||||||
options={PAYEE_TYPE_OPTIONS}
|
|
||||||
rules={[{ required: true, message: '请选择账号类型' }]}
|
|
||||||
/>
|
|
||||||
<ProFormDigit
|
|
||||||
width="md"
|
|
||||||
name="profitRate"
|
|
||||||
label="分账比例"
|
|
||||||
min={0}
|
|
||||||
max={100}
|
|
||||||
fieldProps={{
|
|
||||||
precision: 2,
|
|
||||||
suffix: '%',
|
|
||||||
}}
|
|
||||||
rules={[
|
|
||||||
{ required: true, message: '请输入分账比例' },
|
|
||||||
{ type: 'number', min: 0, max: 100, message: '比例必须在0-100之间' },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</ProForm.Group>
|
|
||||||
</ModalForm>
|
|
||||||
<UpdateForm
|
<UpdateForm
|
||||||
onSubmit={async (values) => {
|
onSubmit={async (values) => {
|
||||||
return handleTableAction('edit', currentRow, values);
|
return handleTableAction('edit', currentRow, values);
|
||||||
@@ -545,6 +475,7 @@ const TableList: React.FC = () => {
|
|||||||
if (visible) {
|
if (visible) {
|
||||||
fetchDeviceList();
|
fetchDeviceList();
|
||||||
fetchTourismList();
|
fetchTourismList();
|
||||||
|
fetchTemplateOptions();
|
||||||
}
|
}
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
setCurrentRow(undefined);
|
setCurrentRow(undefined);
|
||||||
@@ -555,6 +486,7 @@ const TableList: React.FC = () => {
|
|||||||
waylineOptions={waylineOptions}
|
waylineOptions={waylineOptions}
|
||||||
tourismOptions={tourismOptions}
|
tourismOptions={tourismOptions}
|
||||||
deviceOptions={deviceOptions}
|
deviceOptions={deviceOptions}
|
||||||
|
templateOptions={templateOptions}
|
||||||
/>
|
/>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
+119
@@ -0,0 +1,119 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormText,
|
||||||
|
ProFormTextArea,
|
||||||
|
ProFormSelect,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { message } from 'antd';
|
||||||
|
import { saveVideoTemplate } from '@/services/orders/api';
|
||||||
|
import { STATUS_OPTIONS } from '../index';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
interface CreateFormProps {
|
||||||
|
visible: boolean;
|
||||||
|
onVisibleChange: (visible: boolean) => void;
|
||||||
|
onSuccess: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreateForm: React.FC<CreateFormProps> = (props) => {
|
||||||
|
const { visible, onVisibleChange, onSuccess } = props;
|
||||||
|
|
||||||
|
const handleAdd = async (values: ORDERS.VideoTemplate) => {
|
||||||
|
try {
|
||||||
|
const result = await saveVideoTemplate(values);
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('添加成功');
|
||||||
|
onSuccess();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
message.error(result.resp_msg || '添加失败');
|
||||||
|
return false;
|
||||||
|
} catch (error) {
|
||||||
|
message.error('添加失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalForm
|
||||||
|
title="新增视频模板"
|
||||||
|
width={800}
|
||||||
|
visible={visible}
|
||||||
|
onVisibleChange={onVisibleChange}
|
||||||
|
onFinish={handleAdd}
|
||||||
|
modalProps={{
|
||||||
|
destroyOnClose: true,
|
||||||
|
maskClosable: false,
|
||||||
|
className: styles.customModal,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProForm.Group title="基本信息" className={styles.formGroup}>
|
||||||
|
<ProFormText
|
||||||
|
name="templateId"
|
||||||
|
label="模板ID"
|
||||||
|
width="md"
|
||||||
|
placeholder="请输入模板ID"
|
||||||
|
rules={[{ required: true, message: '请输入模板ID' }]}
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
name="templateName"
|
||||||
|
label="模板名称"
|
||||||
|
width="md"
|
||||||
|
placeholder="请输入模板名称"
|
||||||
|
rules={[{ required: true, message: '请输入模板名称' }]}
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
width="md"
|
||||||
|
options={STATUS_OPTIONS}
|
||||||
|
initialValue={1}
|
||||||
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group title="详细配置" className={styles.formGroup}>
|
||||||
|
<ProFormTextArea
|
||||||
|
name="description"
|
||||||
|
label="模板描述"
|
||||||
|
width="xl"
|
||||||
|
placeholder="请输入模板描述"
|
||||||
|
fieldProps={{
|
||||||
|
rows: 4,
|
||||||
|
maxLength: 200,
|
||||||
|
showCount: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormTextArea
|
||||||
|
name="config"
|
||||||
|
label="模板配置"
|
||||||
|
width="xl"
|
||||||
|
placeholder="请输入JSON格式的模板配置"
|
||||||
|
fieldProps={{
|
||||||
|
rows: 8,
|
||||||
|
maxLength: 2000,
|
||||||
|
showCount: true,
|
||||||
|
}}
|
||||||
|
rules={[
|
||||||
|
{ required: true, message: '请输入模板配置' },
|
||||||
|
{
|
||||||
|
validator: async (_, value) => {
|
||||||
|
if (value) {
|
||||||
|
try {
|
||||||
|
JSON.parse(value);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error('请输入有效的JSON格式');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CreateForm;
|
||||||
+123
@@ -0,0 +1,123 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
ProForm,
|
||||||
|
ProFormText,
|
||||||
|
ProFormTextArea,
|
||||||
|
ProFormSelect,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { message } from 'antd';
|
||||||
|
import { updateVideoTemplate } from '@/services/orders/api';
|
||||||
|
import { STATUS_OPTIONS } from '../index';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
interface UpdateFormProps {
|
||||||
|
visible: boolean;
|
||||||
|
onVisibleChange: (visible: boolean) => void;
|
||||||
|
onSuccess: () => void;
|
||||||
|
values?: ORDERS.VideoTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||||
|
const { visible, onVisibleChange, onSuccess, values } = props;
|
||||||
|
|
||||||
|
const handleUpdate = async (formValues: ORDERS.VideoTemplate) => {
|
||||||
|
try {
|
||||||
|
const result = await updateVideoTemplate({
|
||||||
|
...formValues,
|
||||||
|
id: values?.id,
|
||||||
|
});
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('修改成功');
|
||||||
|
onSuccess();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
message.error(result.resp_msg || '修改失败');
|
||||||
|
return false;
|
||||||
|
} catch (error) {
|
||||||
|
message.error('修改失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalForm
|
||||||
|
title="编辑视频模板"
|
||||||
|
width={800}
|
||||||
|
visible={visible}
|
||||||
|
onVisibleChange={onVisibleChange}
|
||||||
|
onFinish={handleUpdate}
|
||||||
|
initialValues={values}
|
||||||
|
modalProps={{
|
||||||
|
destroyOnClose: true,
|
||||||
|
maskClosable: false,
|
||||||
|
className: styles.customModal,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ProForm.Group title="基本信息" className={styles.formGroup}>
|
||||||
|
<ProFormText
|
||||||
|
name="templateId"
|
||||||
|
label="模板ID"
|
||||||
|
width="md"
|
||||||
|
placeholder="请输入模板ID"
|
||||||
|
rules={[{ required: true, message: '请输入模板ID' }]}
|
||||||
|
/>
|
||||||
|
<ProFormText
|
||||||
|
name="templateName"
|
||||||
|
label="模板名称"
|
||||||
|
width="md"
|
||||||
|
placeholder="请输入模板名称"
|
||||||
|
rules={[{ required: true, message: '请输入模板名称' }]}
|
||||||
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="status"
|
||||||
|
label="状态"
|
||||||
|
width="md"
|
||||||
|
options={STATUS_OPTIONS}
|
||||||
|
rules={[{ required: true, message: '请选择状态' }]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group title="详细配置" className={styles.formGroup}>
|
||||||
|
<ProFormTextArea
|
||||||
|
name="description"
|
||||||
|
label="模板描述"
|
||||||
|
width="xl"
|
||||||
|
placeholder="请输入模板描述"
|
||||||
|
fieldProps={{
|
||||||
|
rows: 4,
|
||||||
|
maxLength: 200,
|
||||||
|
showCount: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ProFormTextArea
|
||||||
|
name="config"
|
||||||
|
label="模板配置"
|
||||||
|
width="xl"
|
||||||
|
placeholder="请输入JSON格式的模板配置"
|
||||||
|
fieldProps={{
|
||||||
|
rows: 8,
|
||||||
|
maxLength: 2000,
|
||||||
|
showCount: true,
|
||||||
|
}}
|
||||||
|
rules={[
|
||||||
|
{ required: true, message: '请输入模板配置' },
|
||||||
|
{
|
||||||
|
validator: async (_, value) => {
|
||||||
|
if (value) {
|
||||||
|
try {
|
||||||
|
JSON.parse(value);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error('请输入有效的JSON格式');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
</ModalForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UpdateForm;
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
.customModal {
|
||||||
|
:global {
|
||||||
|
.ant-modal-body {
|
||||||
|
padding: 24px 24px 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.formGroup {
|
||||||
|
:global {
|
||||||
|
.ant-form-group-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: rgba(0, 0, 0, 0.85);
|
||||||
|
line-height: 24px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-form-item {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-form-item-label {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
|
import {
|
||||||
|
ModalForm,
|
||||||
|
PageContainer,
|
||||||
|
ProForm,
|
||||||
|
ProFormText,
|
||||||
|
ProFormTextArea,
|
||||||
|
ProFormSelect,
|
||||||
|
ProTable,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { Button, message, Space, Tag, Typography, Modal } from 'antd';
|
||||||
|
import React, { useRef, useState } from 'react';
|
||||||
|
import { getVideoTemplateList, saveVideoTemplate, updateVideoTemplate, deleteVideoTemplate, updateVideoTemplateStatus } from '@/services/orders/api';
|
||||||
|
import CreateForm from './components/CreateForm';
|
||||||
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
export const STATUS_OPTIONS = [
|
||||||
|
{ label: '启用', value: 1 },
|
||||||
|
{ label: '禁用', value: 0 },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
const VideoTemplateList: React.FC = () => {
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
|
const [createModalVisible, setCreateModalVisible] = useState<boolean>(false);
|
||||||
|
const [updateModalVisible, setUpdateModalVisible] = useState<boolean>(false);
|
||||||
|
const [currentRow, setCurrentRow] = useState<ORDERS.VideoTemplate>();
|
||||||
|
|
||||||
|
// 处理API请求
|
||||||
|
const handleRequest = async (params: any) => {
|
||||||
|
const { current, pageSize, ...rest } = params;
|
||||||
|
const result = await getVideoTemplateList({
|
||||||
|
page: current,
|
||||||
|
limit: pageSize,
|
||||||
|
...rest,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
data: result.data?.data || [],
|
||||||
|
success: result.resp_code === 0,
|
||||||
|
total: result.data?.count || 0,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理删除
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确认删除',
|
||||||
|
content: '确定要删除该模板吗?',
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
const result = await deleteVideoTemplate(id);
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('删除成功');
|
||||||
|
actionRef.current?.reload();
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg || '删除失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error('删除失败');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理状态更新
|
||||||
|
const handleStatusChange = async (id: number, status: number) => {
|
||||||
|
try {
|
||||||
|
const result = await updateVideoTemplateStatus(id, status);
|
||||||
|
if (result.resp_code === 0) {
|
||||||
|
message.success('状态更新成功');
|
||||||
|
actionRef.current?.reload();
|
||||||
|
} else {
|
||||||
|
message.error(result.resp_msg || '状态更新失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error('状态更新失败');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns: ProColumns<ORDERS.VideoTemplate>[] = [
|
||||||
|
{
|
||||||
|
title: '模板ID',
|
||||||
|
dataIndex: 'templateId',
|
||||||
|
width: 180,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '模板名称',
|
||||||
|
dataIndex: 'templateName',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '描述',
|
||||||
|
dataIndex: 'description',
|
||||||
|
width: 200,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 100,
|
||||||
|
render: (_, record) => (
|
||||||
|
<Tag color={record.status === 1 ? 'success' : 'default'}>
|
||||||
|
{record.status === 1 ? '启用' : '禁用'}
|
||||||
|
</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
width: 180,
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
dataIndex: 'updateTime',
|
||||||
|
width: 180,
|
||||||
|
valueType: 'dateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 180,
|
||||||
|
fixed: 'right',
|
||||||
|
render: (_, record) => (
|
||||||
|
<Space>
|
||||||
|
<Link onClick={() => {
|
||||||
|
setCurrentRow(record);
|
||||||
|
setUpdateModalVisible(true);
|
||||||
|
}}>
|
||||||
|
编辑
|
||||||
|
</Link>
|
||||||
|
<Link onClick={() => handleStatusChange(record.id, record.status === 1 ? 0 : 1)}>
|
||||||
|
{record.status === 1 ? '禁用' : '启用'}
|
||||||
|
</Link>
|
||||||
|
<Link onClick={() => handleDelete(record.id)}>
|
||||||
|
删除
|
||||||
|
</Link>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageContainer>
|
||||||
|
<ProTable<ORDERS.VideoTemplate>
|
||||||
|
headerTitle="视频模板列表"
|
||||||
|
actionRef={actionRef}
|
||||||
|
rowKey="id"
|
||||||
|
search={{
|
||||||
|
labelWidth: 120,
|
||||||
|
defaultCollapsed: false,
|
||||||
|
}}
|
||||||
|
toolBarRender={() => [
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
key="create"
|
||||||
|
onClick={() => setCreateModalVisible(true)}
|
||||||
|
>
|
||||||
|
<PlusOutlined /> 新增模板
|
||||||
|
</Button>,
|
||||||
|
]}
|
||||||
|
request={handleRequest}
|
||||||
|
columns={columns}
|
||||||
|
pagination={{
|
||||||
|
pageSize: 10,
|
||||||
|
showQuickJumper: true,
|
||||||
|
showSizeChanger: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CreateForm
|
||||||
|
visible={createModalVisible}
|
||||||
|
onVisibleChange={setCreateModalVisible}
|
||||||
|
onSuccess={() => {
|
||||||
|
setCreateModalVisible(false);
|
||||||
|
actionRef.current?.reload();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<UpdateForm
|
||||||
|
visible={updateModalVisible}
|
||||||
|
onVisibleChange={(visible) => {
|
||||||
|
if (!visible) {
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
}
|
||||||
|
setUpdateModalVisible(visible);
|
||||||
|
}}
|
||||||
|
onSuccess={() => {
|
||||||
|
setUpdateModalVisible(false);
|
||||||
|
setCurrentRow(undefined);
|
||||||
|
actionRef.current?.reload();
|
||||||
|
}}
|
||||||
|
values={currentRow}
|
||||||
|
/>
|
||||||
|
</PageContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default VideoTemplateList;
|
||||||
@@ -217,3 +217,45 @@ export async function getProfitSharingStatistics(params: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取视频模板列表 */
|
||||||
|
export async function getVideoTemplateList(params: {
|
||||||
|
page: number;
|
||||||
|
limit: number;
|
||||||
|
[key: string]: any;
|
||||||
|
}) {
|
||||||
|
return request('/api-order/video/template/list', {
|
||||||
|
method: 'GET',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加视频模板 */
|
||||||
|
export async function saveVideoTemplate(data: ORDERS.VideoTemplate) {
|
||||||
|
return request('/api-order/video/template', {
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新视频模板 */
|
||||||
|
export async function updateVideoTemplate(data: ORDERS.VideoTemplate) {
|
||||||
|
return request('/api-order/video/template', {
|
||||||
|
method: 'PUT',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除视频模板 */
|
||||||
|
export async function deleteVideoTemplate(id: number) {
|
||||||
|
return request(`/api-order/video/template/${id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新视频模板状态 */
|
||||||
|
export async function updateVideoTemplateStatus(id: number, status: number) {
|
||||||
|
return request(`/api-order/video/template/${id}/status/${status}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ declare namespace ORDERS {
|
|||||||
profitRate?: number;
|
profitRate?: number;
|
||||||
payeeStatus?: number;
|
payeeStatus?: number;
|
||||||
payeeFailReason?: string;
|
payeeFailReason?: string;
|
||||||
|
templateId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type HomeCarousel = {
|
type HomeCarousel = {
|
||||||
@@ -167,6 +168,20 @@ declare namespace ORDERS {
|
|||||||
createTime: string;
|
createTime: string;
|
||||||
updateTime: string;
|
updateTime: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface VideoTemplate {
|
||||||
|
id: number;
|
||||||
|
templateId: string;
|
||||||
|
templateName: string;
|
||||||
|
description?: string;
|
||||||
|
status: number;
|
||||||
|
config: string;
|
||||||
|
createTime?: string;
|
||||||
|
updateTime?: string;
|
||||||
|
tenantId?: number;
|
||||||
|
company?: string;
|
||||||
|
isDel?: number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare namespace API {
|
declare namespace API {
|
||||||
|
|||||||
Reference in New Issue
Block a user