diff --git a/zlt-business/order-center/sql/create_packages_table.sql b/zlt-business/order-center/sql/create_packages_table.sql index 454f66af..92b3110d 100644 --- a/zlt-business/order-center/sql/create_packages_table.sql +++ b/zlt-business/order-center/sql/create_packages_table.sql @@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS `packages` ( `vlog_count` INT DEFAULT 0 COMMENT 'Vlog数量', `video_count` INT DEFAULT 0 COMMENT '视频数量', `photo_count` INT DEFAULT 0 COMMENT '照片数量', + `tourism_file_ids` VARCHAR(2048) DEFAULT NULL COMMENT '景区素材ID集合(逗号分隔)', `tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID', `company` VARCHAR(128) DEFAULT NULL COMMENT '所属公司', `is_del` TINYINT(1) DEFAULT 0 COMMENT '是否删除 0-否 1-是', diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/QrCodeController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/QrCodeController.java index e14ed2af..04bbbf96 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/QrCodeController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/QrCodeController.java @@ -29,6 +29,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.Objects; +import java.util.stream.Collectors; /** * qrcode information @@ -89,7 +91,8 @@ public class QrCodeController { if (result.getResp_code() == 0){ Tourism tourism = tourismService.getTourismById(qrCode.getTourismId()); Assert.notNull(tourism, "请选择景区数据"); - qrCode.setTenantId(tourism.getTenantId()); + // qrCode.setTenantId(tourism.getTenantId()); + qrCode.setTenantId(qrCode.getTenantId()); qrCode.setCodeId(codeId); qrCode.setFilePath(result.getData().get("filePath").toString()); qrCode.setFileId(result.getData().get("fileId").toString()); @@ -221,6 +224,14 @@ public class QrCodeController { if (vlogCount != null) plan.setVlogCount(vlogCount); if (videoCount != null) plan.setVideoCount(videoCount); if (photoCount != null) plan.setPhotoCount(photoCount); + // 景区素材ID集合存储到套餐表 + if (body.getTourismFileIds() != null && !body.getTourismFileIds().isEmpty()) { + String idsStr = body.getTourismFileIds().stream() + .filter(Objects::nonNull) + .map(String::valueOf) + .collect(Collectors.joining(",")); + plan.setTourismFileIds(idsStr); + } packagePlanService.saveOrUpdate(plan); } diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/TourismFileController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/TourismFileController.java index f3ae755c..be28c4a2 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/TourismFileController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/TourismFileController.java @@ -4,6 +4,7 @@ import com.central.common.model.PageResult; import com.central.common.model.Result; import com.central.order.feign.FileCenterService; import com.central.order.model.TourismFile; +import com.central.order.model.vo.TourismFileGroupVO; import com.central.order.service.ITourismFileService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -18,10 +19,7 @@ import org.springframework.web.bind.annotation.*; import java.util.Map; /** - * Tourism File information - * - * @author lsl - * @date 2025-2-19 17:51:47 + * 景区资源文件控制器 */ @Slf4j @RestController @@ -37,25 +35,25 @@ public class TourismFileController { private FileCenterService fileCenterService; /** - * 列表 + * 列表(原接口,保留) */ @Operation(summary = "查询列表") @Parameters({ - @Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY), - @Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY) + @Parameter(name = "page", description = "分页起始位置", required = true, in = ParameterIn.QUERY), + @Parameter(name = "limit", description = "分页结束位置", required = true, in = ParameterIn.QUERY) }) @GetMapping public PageResult list(@RequestParam Map params) { PageResult pageResult = tourismFileService.findList(params); - if (pageResult.getCount()>0){ - for (TourismFile tourismFile: pageResult.getData()){ + if (pageResult.getCount() > 0) { + for (TourismFile tourismFile : pageResult.getData()) { tourismFile.setImageUrl(fileCenterService.getViewUrlByPath(tourismFile.getImageUrl())); } } return pageResult; } - @PostMapping() + @PostMapping public Result saveOrUpdate(@RequestBody TourismFile tourismFile) { return tourismFileService.saveOrUpdateTourismFile(tourismFile); } @@ -67,12 +65,46 @@ public class TourismFileController { if (tourismFile == null) { return Result.failed("暂无数据"); } - return Result.succeed(tourismFile,"获取成功"); + return Result.succeed(tourismFile, "获取成功"); } @DeleteMapping("/{id}") public Result delete(@PathVariable Long id) { tourismFileService.removeById(id); - return Result.succeed( "操作成功"); + return Result.succeed("操作成功"); } -} + + /** + * 新接口:按租户分组返回景区资源(以景区为组) + * 逻辑:先根据租户获取其及子租户下的所有景区,再根据景区获取资源文件 + * 注意:保留原 /tourism/files 接口不变 + */ + @Operation(summary = "按租户分组返回景区资源") + @GetMapping("/grouped/by-tenant") + public PageResult listGroupedByTenant(@RequestParam Map params) { + try { + return tourismFileService.findFilesGroupedByTenant(params); + } catch (Exception e) { + log.error("按租户分组查询景区资源失败", e); + return PageResult.builder().data(java.util.Collections.emptyList()).resp_code(1).count(0L).build(); + } + } + /** + * 按景区ID获取资源列表 + */ + @Operation(summary = "按景区ID获取资源列表") + @GetMapping("/byTourism/{tourismId}") + public Result listByTourismId(@PathVariable("tourismId") Long tourismId) { + java.util.List list = tourismFileService.getByTourismId(tourismId); + if (list != null) { + for (TourismFile f : list) { + try { + if (f != null && f.getImageUrl() != null) { + f.setImageUrl(fileCenterService.getViewUrlByPath(f.getImageUrl())); + } + } catch (Exception ignored) {} + } + } + return Result.succeed(list, "操作成功"); + } +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/VideoTemplateController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/VideoTemplateController.java index 70c14cd4..73b38cf5 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/VideoTemplateController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/VideoTemplateController.java @@ -92,4 +92,19 @@ public class VideoTemplateController { return Result.failed("获取失败"); } } -} \ No newline at end of file + + @Operation(summary = "根据模板ID(templateId)获取模板信息") + @GetMapping("/templateId/{templateId}") + public Result getByTemplateId(@PathVariable String templateId) { + try { + VideoTemplate template = videoTemplateService.lambdaQuery() + .eq(VideoTemplate::getTemplateId, templateId) + .last("limit 1") + .one(); + return Result.succeed(template); + } catch (Exception e) { + log.error("根据模板ID查询模板失败, templateId={}", templateId, e); + return Result.failed("查询失败"); + } + } +} diff --git a/zlt-business/order-center/src/main/java/com/central/order/mapper/TourismFileMapper.java b/zlt-business/order-center/src/main/java/com/central/order/mapper/TourismFileMapper.java index ebf01fec..cb2df135 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/mapper/TourismFileMapper.java +++ b/zlt-business/order-center/src/main/java/com/central/order/mapper/TourismFileMapper.java @@ -10,23 +10,23 @@ import java.util.List; import java.util.Map; /** - * Tourism File information - * - * @author lsl - * @date 2025-2-17 17:52:54 + * 景区资源文件 Mapper */ @Mapper public interface TourismFileMapper extends SuperMapper { /** - * 分页查询用户列表 - * - * @param page - * @param params - * @return + * 分页查询列表 */ List findList(Page page, @Param("p") Map params); - // ID查询 + /** 按景区ID查询 */ List getByTourismId(@Param("tourismId") Long tourismId); + /** + * 根据景区ID集合批量查询资源文件(可选过滤 type/status/description) + */ + List findByTourismIds(@Param("tourismIds") List tourismIds, + @Param("type") Integer type, + @Param("status") Integer status, + @Param("description") String description); } diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/PackagePlan.java b/zlt-business/order-center/src/main/java/com/central/order/model/PackagePlan.java index 201ea3da..9d142572 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/model/PackagePlan.java +++ b/zlt-business/order-center/src/main/java/com/central/order/model/PackagePlan.java @@ -33,6 +33,10 @@ public class PackagePlan extends SuperEntity { @Schema(description = "照片数量") private Integer photoCount; + @Schema(description = "景区素材ID集合(逗号分隔)") + private String tourismFileIds; + + @Schema(description = "租户ID") private String tenantId; @@ -49,4 +53,4 @@ public class PackagePlan extends SuperEntity { @Schema(description = "更新时间") @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; -} \ No newline at end of file +} diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/dto/QrcodeWithPlanDTO.java b/zlt-business/order-center/src/main/java/com/central/order/model/dto/QrcodeWithPlanDTO.java index ac81a882..5cb7ef35 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/model/dto/QrcodeWithPlanDTO.java +++ b/zlt-business/order-center/src/main/java/com/central/order/model/dto/QrcodeWithPlanDTO.java @@ -4,6 +4,8 @@ import com.central.order.model.QrCode; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.List; + @Data @Schema(description = "二维码与套餐创建/修改请求体") public class QrcodeWithPlanDTO { @@ -18,5 +20,8 @@ public class QrcodeWithPlanDTO { @Schema(description = "照片数量") private Integer photoCount; + + @Schema(description = "景区素材ID集合(ID 数组)") + private List tourismFileIds; } diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/TourismFileGroupVO.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/TourismFileGroupVO.java new file mode 100644 index 00000000..ccc72bdb --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/TourismFileGroupVO.java @@ -0,0 +1,18 @@ +package com.central.order.model.vo; + +import com.central.order.model.TourismFile; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "景区资源") +public class TourismFileGroupVO { + + private Long tourismId; + + private String tourismName; + + private List files; +} diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/ITourismFileService.java b/zlt-business/order-center/src/main/java/com/central/order/service/ITourismFileService.java index 8f784653..0fb26c5b 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/service/ITourismFileService.java +++ b/zlt-business/order-center/src/main/java/com/central/order/service/ITourismFileService.java @@ -4,37 +4,23 @@ import com.central.common.model.PageResult; import com.central.common.model.Result; import com.central.common.service.ISuperService; import com.central.order.model.TourismFile; +import com.central.order.model.vo.TourismFileGroupVO; import java.util.List; import java.util.Map; -/** - * Firmware file information - * - * @author lsl - * @date 2024-12-19 17:52:54 - */ + public interface ITourismFileService extends ISuperService { - /** - * 列表 - * @param params - * @return - */ + PageResult findList(Map params); - /** - * 创建 - * - * @param tourismFile - * @return - */ - Result saveOrUpdateTourismFile(TourismFile tourismFile) ; - /** - * id查询 - * @param id - * @return - */ + Result saveOrUpdateTourismFile(TourismFile tourismFile); + + List getByTourismId(Long id); + + + PageResult findFilesGroupedByTenant(Map params); } diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/impl/TourismFileServiceImpl.java b/zlt-business/order-center/src/main/java/com/central/order/service/impl/TourismFileServiceImpl.java index 8a53b5b9..fa402533 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/service/impl/TourismFileServiceImpl.java +++ b/zlt-business/order-center/src/main/java/com/central/order/service/impl/TourismFileServiceImpl.java @@ -4,42 +4,49 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.central.common.model.PageResult; import com.central.common.model.Result; import com.central.common.service.impl.SuperServiceImpl; +import com.central.order.feign.FileCenterService; import com.central.order.mapper.TourismFileMapper; +import com.central.order.mapper.TourismMapper; +import com.central.order.model.Tourism; import com.central.order.model.TourismFile; +import com.central.order.model.vo.TourismFileGroupVO; import com.central.order.service.ITourismFileService; +import com.central.order.service.ITourismService; +import com.central.common.feign.UserService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; + -/** - * Order information - * - * @author lsl - * @date 2024-12-19 17:52:54 - */ @Slf4j @Service public class TourismFileServiceImpl extends SuperServiceImpl implements ITourismFileService { + @Autowired + private TourismMapper tourismMapper; + @Autowired + private FileCenterService fileCenterService; + @Autowired + private UserService userCenterService; + /** - * 列表 - * @param params - * @return + * 鍒嗛〉鍒楄〃 */ @Override - public PageResult findList(Map params){ + public PageResult findList(Map params) { Page page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); - List list = baseMapper.findList(page, params); + List list = baseMapper.findList(page, params); return PageResult.builder().data(list).resp_code(0).count(page.getTotal()).build(); } @Override public Result saveOrUpdateTourismFile(TourismFile tourismFile) { boolean result = saveOrUpdate(tourismFile); - return result ? Result.succeed(tourismFile, "操作成功") : Result.failed("操作失败"); + return result ? Result.succeed(tourismFile, "成功") : Result.failed("失败"); } @Override @@ -47,4 +54,82 @@ public class TourismFileServiceImpl extends SuperServiceImpl findFilesGroupedByTenant(Map params) { + List result = new ArrayList<>(); + if (params == null) params = new HashMap<>(); + String tenantId = MapUtils.getString(params, "tenantId"); + Boolean includeChildren = MapUtils.getBoolean(params, "includeChildren", true); + Integer type = MapUtils.getInteger(params, "type", null); + Integer status = MapUtils.getInteger(params, "status", null); + String description = MapUtils.getString(params, "description", null); + Long filterTourismId = null; + try { filterTourismId = MapUtils.getLong(params, "tourismId", null); } catch (Exception ignored) {} + Integer pageNo = MapUtils.getInteger(params, "page", 1); + Integer pageSize = MapUtils.getInteger(params, "limit", 10); + + // 兼容:未显式传入租户,尝试从上下文获取当前查询租户 + if (tenantId == null || tenantId.isEmpty()) { + try { + tenantId = com.central.common.context.TenantQueryOverrideContext.getTenantId(); + if (tenantId == null || tenantId.isEmpty()) { + tenantId = com.central.common.context.LoginUserContextHolder.getCurrentTenantId(); + } + } catch (Exception e) { + log.warn("获取当前查询租户失败: {}", e.getMessage()); + } + } + if (tenantId == null || tenantId.isEmpty()) { + return PageResult.builder().data(result).resp_code(0).count(0L).build(); + } + + // 计算租户集合 + List tenantIds; + if (Boolean.FALSE.equals(includeChildren)) { + tenantIds = Collections.singletonList(tenantId); + } else { + tenantIds = userCenterService.getSonTenantIds(tenantId); + if (tenantIds == null || tenantIds.isEmpty()) { + tenantIds = Collections.singletonList(tenantId); + } + } + + // 构建分页查询景区 + com.baomidou.mybatisplus.extension.plugins.pagination.Page page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNo, pageSize); + Map p = new HashMap<>(); + p.put("tenantIds", tenantIds); + if (filterTourismId != null && filterTourismId > 0) { + p.put("tourismId", filterTourismId); + } + List tourisms = tourismMapper.findList(page, p); + long total = page.getTotal(); + if (tourisms == null || tourisms.isEmpty()) { + return PageResult.builder().data(result).resp_code(0).count(total).build(); + } + + // 批量查询资源文件(只查本页景区) + List pageTourismIds = tourisms.stream().map(Tourism::getId).collect(Collectors.toList()); + List files = baseMapper.findByTourismIds(pageTourismIds, type, status, description); + Map> grouped = files == null ? new HashMap<>() : files.stream().collect(Collectors.groupingBy(TourismFile::getTourismId)); + + for (Tourism t : tourisms) { + TourismFileGroupVO vo = new TourismFileGroupVO(); + vo.setTourismId(t.getId()); + vo.setTourismName(t.getTourismName()); + List list = grouped.getOrDefault(t.getId(), Collections.emptyList()); + // 转换 URL + List converted = new ArrayList<>(list.size()); + for (TourismFile f : list) { + if (f != null && f.getImageUrl() != null) { + try { f.setImageUrl(fileCenterService.getViewUrlByPath(f.getImageUrl())); } catch (Exception ignored) {} + } + converted.add(f); + } + vo.setFiles(converted); + result.add(vo); + } + + return PageResult.builder().data(result).resp_code(0).count(total).build(); + } } + diff --git a/zlt-business/order-center/src/main/resources/mapper/TourismFileMapper.xml b/zlt-business/order-center/src/main/resources/mapper/TourismFileMapper.xml index 3ad7728f..453dc6c1 100644 --- a/zlt-business/order-center/src/main/resources/mapper/TourismFileMapper.xml +++ b/zlt-business/order-center/src/main/resources/mapper/TourismFileMapper.xml @@ -1,4 +1,4 @@ - + @@ -12,4 +12,30 @@ + + + diff --git a/zlt-business/order-center/src/main/resources/mapper/TourismMapper.xml b/zlt-business/order-center/src/main/resources/mapper/TourismMapper.xml index 651499a2..1df4b60a 100644 --- a/zlt-business/order-center/src/main/resources/mapper/TourismMapper.xml +++ b/zlt-business/order-center/src/main/resources/mapper/TourismMapper.xml @@ -16,6 +16,9 @@ AND t.tenant_id = #{p.tenantId} + + AND t.tourism_name LIKE CONCAT('%', #{p.tourismName}, '%') + ORDER BY t.id DESC diff --git a/zlt-register/zlt-register.iml b/zlt-register/zlt-register.iml deleted file mode 100644 index 195579d4..00000000 --- a/zlt-register/zlt-register.iml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/zlt-web/react-web-next/config/routes.ts b/zlt-web/react-web-next/config/routes.ts index 3a62a4f9..7ddeba19 100644 --- a/zlt-web/react-web-next/config/routes.ts +++ b/zlt-web/react-web-next/config/routes.ts @@ -22,12 +22,10 @@ export default [ routes: [ { path: '/orders/order.html', component: '@/pages/orders/Order' }, { path: '/orders/orderFiles.html', component: '@/pages/orders/OrderFile' }, - { path: '/orders/qrcode.html', component: '@/pages/orders/Qrcode' }, { path: '/orders/tourism.html', component: '@/pages/orders/Tourism' }, { path: '/orders/tourismFile.html', component: '@/pages/orders/TourismFile' }, { path: '/orders/homeCarousel.html', component: '@/pages/orders/HomeCarousel' }, { path: '/orders/refund.html', component: '@/pages/orders/Refund' }, - { path: '/orders/statistics.html', component: '@/pages/orders/Statistics' }, { path: '/orders/profitSharing.html', component: '@/pages/orders/ProfitSharing' }, { path: '/orders/profit-sharing/statistics.html', component: '@/pages/orders/ProfitSharing/Statistics' }, { path: '/orders/videoTemplate.html', component: '@/pages/orders/VideoTemplate' }, diff --git a/zlt-web/react-web-next/src/components/ui/SearchBarPlus/index.tsx b/zlt-web/react-web-next/src/components/ui/SearchBarPlus/index.tsx index 3c7acd32..94bd5191 100644 --- a/zlt-web/react-web-next/src/components/ui/SearchBarPlus/index.tsx +++ b/zlt-web/react-web-next/src/components/ui/SearchBarPlus/index.tsx @@ -1,10 +1,11 @@ import React from 'react'; import { QueryFilter } from '@ant-design/pro-components'; +import { Button } from 'antd'; import TenantSelector from '@/components/ui/TenantSelector'; import { tenantApi } from '@/services/tenant'; export interface SearchBarPlusProps { - // QueryFilter 透传属性(常用) + // QueryFilter 常用属性 defaultCollapsed?: boolean; split?: boolean; span?: number | { xs?: number; sm?: number; md?: number; lg?: number; xl?: number; xxl?: number }; @@ -14,12 +15,14 @@ export interface SearchBarPlusProps { children?: React.ReactNode; // 是否显示租户筛选(默认显示) showTenant?: boolean; - // 租户变化回调:用于触发表格 reload 等 + // 租户变化回调:用于触发表格 reload onTenantChanged?: (tenantId: string, includeChildren: boolean) => void; // 租户筛选放置位置:start 放在最前,end 放在最后(默认 start) tenantPosition?: 'start' | 'end'; // 是否调用后端“切换查询租户”接口(默认不调用,避免跨页面副作用) useSwitchTenant?: boolean; + // 是否隐藏重置按钮(默认 false) + hideReset?: boolean; } const SearchBarPlus: React.FC = ({ @@ -33,6 +36,7 @@ const SearchBarPlus: React.FC = ({ onTenantChanged, tenantPosition = 'start', useSwitchTenant = false, + hideReset = false, }) => { const handleFinish = async (values: Record) => { try { @@ -52,6 +56,17 @@ const SearchBarPlus: React.FC = ({ span={span as any} form={form} onFinish={handleFinish} + submitter={ + hideReset + ? { + render: (props: any) => [ + , + ], + } + : undefined + } > {showTenant && tenantPosition === 'start' ? : null} {children} diff --git a/zlt-web/react-web-next/src/pages/orders/Qrcode/index.tsx b/zlt-web/react-web-next/src/pages/orders/Qrcode/index.tsx deleted file mode 100644 index c749bd68..00000000 --- a/zlt-web/react-web-next/src/pages/orders/Qrcode/index.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import React, { useState } from 'react'; -import { PageContainer, ProTable } from '@ant-design/pro-components'; -import { Popconfirm, Space, Tag, message } from 'antd'; -import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/components/ui'; -import { PlusOutlined } from '@ant-design/icons'; -import { ordersApi } from '@/services/orders'; -import QrcodeForm, { QrcodeItem } from './components/QrcodeForm'; - -const QrcodePage: React.FC = () => { - const [createOpen, setCreateOpen] = useState(false); - const [editOpen, setEditOpen] = useState(false); - const [current, setCurrent] = useState(undefined); - const [params, setParams] = useState>({}); - - const columns: any[] = [ - { dataIndex: 'index', valueType: 'indexBorder', width: 48 }, - { title: '名称', dataIndex: 'name' }, - { title: '链接', dataIndex: 'url', ellipsis: true }, - { title: '类型', dataIndex: 'type' }, - { title: '状态', dataIndex: 'status', render: (v: number) => {v === 1 ? '启用' : '禁用'} }, - { - title: '操作', key: 'action', - render: (_: any, record: QrcodeItem) => ( - - { setCurrent(record); setEditOpen(true); }}>编辑 - { - const hide = message.loading('删除中...'); - try { - await ordersApi.deleteQrcode(record.id!); - message.success('删除成功'); - } catch (e) { - message.error('删除失败'); - } finally { hide(); } - }}> - 删除 - - - ) - }, - ]; - - return ( - - { /* 仅触发表格刷新 */ }} - onFinish={async (values) => setParams(values)} - /> - } onClick={() => setCreateOpen(true)}>新增} /> - - - rowKey="id" - request={(p) => ordersApi.qrcodeList({ ...(p as any), ...params })} - columns={columns} - search={false} - pagination={{ showSizeChanger: true, showQuickJumper: true }} - /> - - - { - const hide = message.loading('保存中...'); - try { - await ordersApi.saveOrUpdateQrcode(values); - message.success('新增成功'); - return true; - } catch (e) { - message.error('保存失败'); - return false; - } finally { hide(); } - }} - /> - - { - const hide = message.loading('保存中...'); - try { - await ordersApi.saveOrUpdateQrcode({ ...(current as any), ...values }); - message.success('修改成功'); - return true; - } catch (e) { - message.error('修改失败'); - return false; - } finally { hide(); } - }} - /> - - ); -}; - -export default QrcodePage; - diff --git a/zlt-web/react-web-next/src/pages/orders/Statistics/index.tsx b/zlt-web/react-web-next/src/pages/orders/Statistics/index.tsx deleted file mode 100644 index b29049b6..00000000 --- a/zlt-web/react-web-next/src/pages/orders/Statistics/index.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { PageContainer } from '@ant-design/pro-components'; -import { Card, Col, Row, Statistic, DatePicker, Space, message, Form } from 'antd'; -import { SearchBarPlus } from '@/components/ui'; -import { ordersApi } from '@/services/orders'; - -const { RangePicker } = DatePicker; - -const StatisticsPage: React.FC = () => { - const [loading, setLoading] = useState(false); - const [stat, setStat] = useState({}); - const [range, setRange] = useState(); - - const load = async (p?: any) => { - setLoading(true); - try { - const res = await ordersApi.dashboard(p); - setStat(res?.data || res); - } catch (e) { - message.error('加载统计失败'); - } finally { setLoading(false); } - }; - - useEffect(() => { load(); }, []); - - return ( - - load(range)} - onFinish={async (values) => { - const v = (values as any)?.timeRange; - const base: any = {}; - if (v && v.length === 2) { - base.startTime = v[0]?.toISOString(); - base.endTime = v[1]?.toISOString(); - } - // 合并租户筛选参数 - const r = { ...values, ...base } as any; - delete r.timeRange; - setRange(r); - await load(r); - }} - > - - - - - - - - - - - - - ); -}; - -export default StatisticsPage; - diff --git a/zlt-web/react-web-next/src/pages/orders/Qrcode/components/QrcodeForm.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeItem.tsx similarity index 55% rename from zlt-web/react-web-next/src/pages/orders/Qrcode/components/QrcodeForm.tsx rename to zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeItem.tsx index c946bbc3..a8393d37 100644 --- a/zlt-web/react-web-next/src/pages/orders/Qrcode/components/QrcodeForm.tsx +++ b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeItem.tsx @@ -7,9 +7,30 @@ export interface QrcodeItem { type?: number; url?: string; status?: number; + // 以下为景区二维码列表中使用到的扩展字段(仅类型声明,不影响表单) + tourismId?: number; + codeId?: string; + waylineId?: string; + viewUrl?: string; + deviceSn?: string; + price?: number | string; + templateId?: string; + enableVideoEdit?: number; // 0: 否 1: 开启 + isTest?: number; // 0: 否 1: 是 + qrcodeType?: number; // 1: 游客下单 2: 定时巡查 其他: 其他 + showVideoEditOnly?: number; // 0: 否 1: 是 + materialCount?: number; + enableProfit?: number; // 0: 否 1: 是 + payeeAccount?: string; + payeeType?: 'MERCHANT_ID' | 'PERSONAL_OPENID' | string; + profitRate?: number; + appId?: string; + vlogCount?: number; + videoCount?: number; + photoCount?: number; + tourismFileIds?: number[]; } - -export interface QrcodeFormProps { + export interface QrcodeFormProps { open: boolean; title: string; initialValues?: Partial; @@ -30,9 +51,10 @@ const QrcodeForm: React.FC = ({ open, title, initialValues, onO - + ); }; -export default QrcodeForm; +export default QrcodeItem; + diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx new file mode 100644 index 00000000..4eb3bfaa --- /dev/null +++ b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeListModal.tsx @@ -0,0 +1,319 @@ +import React, { useMemo, useRef, useState } from 'react'; +import { Modal, Popconfirm, Space, Tag, message, Button } from 'antd'; +import { ProTable, type ActionType } from '@ant-design/pro-components'; +import { GradientButton } from '@/components/ui'; +import { PlusOutlined, CopyOutlined } from '@ant-design/icons'; +import { ordersApi } from '@/services/orders'; +import { QrcodeItem } from './QrcodeItem'; +import QrcodeTourismForm from './QrcodeTourismForm'; + +export interface QrcodeListModalProps { + open: boolean; + onOpenChange: (v: boolean) => void; + tourismId: number; + tourismName?: string; +} + +const QrcodeListModal: React.FC = ({ open, onOpenChange, tourismId, tourismName }) => { + const actionRef = useRef(); + const [createOpen, setCreateOpen] = useState(false); + const [editOpen, setEditOpen] = useState(false); + const [current, setCurrent] = useState(undefined); + const [previewOpen, setPreviewOpen] = useState(false); + const [previewImage, setPreviewImage] = useState(''); + + // 模板ID -> 模板名称(通过接口懒加载) +const templateNameMapRef = useRef>({}); + const templateInflightRef = useRef>>({}); + const [tplTick, setTplTick] = useState(0); // 用于触发渲染 +const title = useMemo(() => `打卡点二维码列表${tourismName ? `(${tourismName})` : ''}`, [tourismName]); + + const ensureTemplateName = (tplId?: string) => { + if (!tplId) return '-'; + const map = templateNameMapRef.current; + if (map[tplId]) return map[tplId]; + if (!templateInflightRef.current[tplId]) { + templateInflightRef.current[tplId] = ordersApi + .getVideoTemplateByTemplateId(tplId) + .then((tpl: any) => { + const name = tpl?.templateName || tpl?.name || '-'; + map[tplId] = name; + setTplTick((v) => v + 1); + }) + .catch(() => { + map[tplId] = '-'; + setTplTick((v) => v + 1); + }) + .finally(() => { + delete templateInflightRef.current[tplId]; + }); + } + return '-'; + }; + + const columns: any[] = [ + { dataIndex: 'index', valueType: 'indexBorder', width: 48 }, + { title: 'ID', dataIndex: 'id', width: 80 }, + { title: '名称', dataIndex: 'name', width: 140 }, + { + title: 'Code', + dataIndex: 'codeId', + width: 220, + render: (codeId: string) => { + if (!codeId) return '-'; + return ( +
+ {codeId} +
+ ); + }, + }, + { + title: '航线ID', + dataIndex: 'waylineId', + width: 220, + render: (waylineId: string) => { + if (!waylineId) return '-'; + return ( +
+ {waylineId} +
+ ); + }, + }, + { + title: '二维码', + dataIndex: 'viewUrl', + width: 100, + render: (url: string) => { + if (!url) return '-'; + return ( + 二维码 { + setPreviewImage(url); + setPreviewOpen(true); + }} + /> + ); + }, + }, + { title: '设备SN', dataIndex: 'deviceSn', width: 150 }, + { + title: '价格', + dataIndex: 'price', + width: 100, + render: (price: string | number) => { + if (!price && price !== 0) return '-'; + const priceNum = typeof price === 'string' ? parseFloat(price) : price; + if (Number.isNaN(priceNum)) return '-'; + return `¥${(priceNum / 100).toFixed(2)}`; + }, + }, + { + title: '状态', + dataIndex: 'status', + width: 90, + render: (v: number) => {v === 0 ? '启用' : '禁用'}, + }, + { + title: '模板名称', + dataIndex: 'templateId', + width: 160, + render: (tplId?: string) => ensureTemplateName(tplId), + }, + { + title: '一键成片', + dataIndex: 'enableVideoEdit', + width: 100, + render: (v: number) => {v === 1 ? '是' : '否'}, + }, + { + title: '测试二维码', + dataIndex: 'isTest', + width: 110, + render: (v: number) => {v === 1 ? '是' : '否'}, + }, + { + title: '二维码类型', + dataIndex: 'qrcodeType', + width: 120, + render: (v: number) => { + if (v === 1) return 游客扫码; + if (v === 2) return 临时扫码; + return 自定义; + }, + }, + { + title: '仅显示一键成片', + dataIndex: 'showVideoEditOnly', + width: 130, + render: (v: number) => {v === 1 ? '是' : '否'}, + }, + { title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 160 }, + { + title: '操作', + key: 'action', + width: 160, + fixed: 'right', + render: (_: any, record: QrcodeItem) => ( + + { + try { + const plans = await ordersApi.getPackagePlanByCode(record.codeId as any); + const plan: any = Array.isArray(plans) && plans.length > 0 ? plans[0] : {}; + const tourismFileIds = plan.tourismFileIds ? String(plan.tourismFileIds).split(',').filter(Boolean).map((x: any) => Number(x)) : []; + setCurrent({ ...record, vlogCount: plan.vlogCount, videoCount: plan.videoCount, photoCount: plan.photoCount, tourismFileIds }); + } catch { + setCurrent(record); + } + setEditOpen(true); +}} + > + 编辑 + + { + const hide = message.loading('正在删除...'); + try { + await ordersApi.deleteQrcode(record.id!); + message.success('删除成功'); + actionRef.current?.reload(); + } catch (e) { + message.error('删除失败'); + } finally { + hide(); + } + }} + > + 删除 + + + ), + }, + ]; + + return ( + <> + onOpenChange(false)} footer={null} width={1600} destroyOnClose> +
+ } onClick={() => setCreateOpen(true)}> + 新增 + +
+ + + rowKey="id" + actionRef={actionRef} + request={(p) => ordersApi.qrcodeListByTourism({ ...(p as any), tourismId })} + columns={columns} + search={false} + pagination={{ showSizeChanger: true, showQuickJumper: true }} + toolBarRender={false} + scroll={{ x: 1600 }} + /> +
+ + {/* 新增/编辑表单:仅在打开时才挂载,避免列表页触发内部副作用 */} + {createOpen && ( + { + const hide = message.loading('提交中...'); + try { + const { vlogCount, videoCount, photoCount, tourismFileIds, ...qrRest } = values as any; + await ordersApi.saveOrUpdateQrcodePlan({ + qrCode: { ...qrRest, tourismId }, + vlogCount, + videoCount, + photoCount, + tourismFileIds, + }); + message.success('修改成功'); + actionRef.current?.reload(); + return true; + } catch (e) { + message.error('修改失败'); + return false; + } finally { + hide(); + } + }} + defaultTourismId={tourismId} + /> + )} + + {editOpen && ( + { + const hide = message.loading('提交中...'); + try { + const merged: any = { ...(current as any), ...values }; + const { vlogCount, videoCount, photoCount, tourismFileIds, ...qrRest } = merged; + await ordersApi.saveOrUpdateQrcodePlan({ + qrCode: qrRest, + vlogCount, + videoCount, + photoCount, + tourismFileIds, + }); + message.success('修改成功'); + actionRef.current?.reload(); + return true; + } catch (e) { + message.error('修改失败'); + return false; + } finally { + hide(); + } + }} + defaultTourismId={tourismId} + initialValues={current} + /> + )} + + {/* 二维码预览 */} + setPreviewOpen(false)} footer={null} width={600} centered destroyOnClose> +
+ 二维码预览 +
+
+ + ); +}; + +export default QrcodeListModal; + + diff --git a/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeTourismForm.tsx b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeTourismForm.tsx new file mode 100644 index 00000000..20fcbc53 --- /dev/null +++ b/zlt-web/react-web-next/src/pages/orders/Tourism/components/QrcodeTourismForm.tsx @@ -0,0 +1,347 @@ +import React, { useEffect, useState } from 'react'; +import { ModalForm, ProForm, ProFormDigit, ProFormSelect, ProFormText } from '@ant-design/pro-components'; +import { ordersApi } from '@/services/orders'; +import { deviceApi } from '@/services/device'; +import { miniAppApi } from '@/services/miniapp'; +import type { QrcodeItem } from './QrcodeItem'; + +export interface QrcodeTourismFormProps { + open: boolean; + title: string; + initialValues?: Partial; + onOpenChange: (v: boolean) => void; + onFinish: (values: QrcodeItem) => Promise; + defaultTourismId?: number; +} + +const QrcodeTourismForm: React.FC = ({ open, title, initialValues, onOpenChange, onFinish, defaultTourismId }) => { + // 统一默认值,解决新增/编辑缺省字段问题 + const DEFAULTS: Partial = { + status: 0, // 状态:0=启用1=禁用 + enableVideoEdit: 0, // 是否开启一键成片:0=否 1=是 + isTest: 0, // 是否测试二维码:0=否 1=是 + qrcodeType: 1, // 二维码类型:1=游客扫码 2=临时扫码 3=自定义 + showVideoEditOnly: 0, // 是否仅显示一键成片:0=否 1=是 + materialCount: 1, + vlogCount: 0, + videoCount: 0, + photoCount: 0, + }; + + // 过滤 initialValues 中的 undefined,避免覆盖默认值 + const sanitizedInitial: Partial = initialValues + ? (Object.fromEntries(Object.entries(initialValues).filter(([, v]) => v !== undefined)) as any) + : {}; + + // 景区ID,用于素材查询 + const tourismIdForFetch = (sanitizedInitial as any)?.tourismId ?? defaultTourismId; + + // 景区素材 + const [tourismFiles, setTourismFiles] = useState([]); + + useEffect(() => { + // 仅在弹窗打开时才加载景区素材,避免在列表页无意义调用接口 + if (!open) return; + if (!tourismIdForFetch) { + setTourismFiles([]); + return; + } + let canceled = false; + (async () => { + try { + const { data = [] } = await ordersApi.tourismFileByTourism(tourismIdForFetch as any); + if (!canceled) setTourismFiles(Array.isArray(data) ? data : []); + } catch { + if (!canceled) setTourismFiles([]); + } + })(); + return () => { + canceled = true; + }; + }, [open, tourismIdForFetch]); + + // 景区素材类型字典(按业务提供) + const TYPE_LABEL: Record = { + 5: '视频', + 6: '首页 Banner', + 4: '展示图片', + 3: '景区详情', + 2: '景区小图展示', + 1: '活动', + }; + const typeName = (t: any) => TYPE_LABEL[Number(t)] || '其他'; + + return ( + + title={title} + visible={open} + onVisibleChange={onOpenChange} + onFinish={onFinish} + initialValues={(() => { + const init: any = { + ...DEFAULTS, + ...(sanitizedInitial as any), + tourismId: (sanitizedInitial as any)?.tourismId ?? defaultTourismId, + }; + const toNum = (v: any) => (typeof v === 'string' ? Number(v) : v); + ['status', 'enableVideoEdit', 'isTest', 'qrcodeType', 'showVideoEditOnly', 'materialCount', 'vlogCount', 'videoCount', 'photoCount'].forEach((k) => { + if (init[k] !== undefined) init[k] = toNum(init[k]); + }); + if (init.templateId !== undefined && init.templateId !== null) { + init.templateId = String(init.templateId); + } + return init as any; + })()} + modalProps={{ destroyOnClose: true }} + grid + rowProps={{ gutter: [16, 8] }} + layout="horizontal" + labelCol={{ flex: '120px' }} + wrapperCol={{ flex: 'auto' }} + labelAlign="left" + labelWrap + colProps={{ span: 12 }} + > + {/* 小程序商户(仅显示支持支付的类型)*/} + { + // 只取 type=PAY 的商户 + const { data = [] } = await miniAppApi.list({ page: 1, limit: 1000 }); + const filtered = (data || []).filter((m: any) => String(m?.type || '').toUpperCase() === 'PAY'); + return filtered.map((m: any) => ({ label: m.subMchName || m.tenantId, value: m.tenantId })); + }} + colProps={{ span: 12 }} + /> + + {/* 基本信息 */} + + + { + const { data = [] } = await deviceApi.wayline({ current: 1, pageSize: 1000 }); + return (data || []).map((w: any) => ({ label: w.name || w.waylineId, value: w.waylineId })); + }} + colProps={{ span: 12 }} + /> + + { + const { data = [] } = await deviceApi.deviceList({ page: 1, limit: 1000 }); + return (data || []).map((d: any) => ({ label: d.deviceName || d.deviceSn, value: d.deviceSn })); + }} + colProps={{ span: 12 }} + /> + + + + + + {/* 视频模板(可选) */} + { + try { + const api: any = ordersApi as any; + const resp = api.getVideoTemplateList ? await api.getVideoTemplateList({ current: 1, pageSize: 1000 }) : { data: [] }; + const { data = [] } = (resp || {}) as any; + return (data || []).map((t: any) => ({ label: t?.templateName || t?.name || String(t?.templateId ?? t?.id), value: String(t?.templateId ?? t?.id) })); + } catch { + return []; + } + }} + colProps={{ span: 12 }} + /> + + {/* 功能开关 */} + + + + + + {/* 统计 */} + + + + + + + {/* 注册一个隐藏字段以提交素材ID数组 */} +