Merge branch 'develop_temp' of gitee.com:L-Shilin/go-fly-platform-services into feature_lsl
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
-- 创建套餐表
|
||||||
|
-- 执行前请备份数据
|
||||||
|
|
||||||
|
USE `order-center`;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `packages` (
|
||||||
|
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
|
`code_id` VARCHAR(64) NOT NULL COMMENT '二维码编码(与qrcodes.code_id对应)',
|
||||||
|
`vlog_count` INT DEFAULT 0 COMMENT 'Vlog数量',
|
||||||
|
`video_count` INT DEFAULT 0 COMMENT '视频数量',
|
||||||
|
`photo_count` INT DEFAULT 0 COMMENT '照片数量',
|
||||||
|
`tenant_id` VARCHAR(64) DEFAULT NULL COMMENT '租户ID',
|
||||||
|
`company` VARCHAR(128) DEFAULT NULL COMMENT '所属公司',
|
||||||
|
`is_del` TINYINT(1) DEFAULT 0 COMMENT '是否删除 0-否 1-是',
|
||||||
|
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_code_id` (`code_id`),
|
||||||
|
KEY `idx_tenant_id` (`tenant_id`),
|
||||||
|
KEY `idx_create_time` (`create_time`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='套餐表';
|
||||||
|
|
||||||
+88
@@ -0,0 +1,88 @@
|
|||||||
|
package com.central.order.controller;
|
||||||
|
|
||||||
|
import com.central.common.context.TenantContextHolder;
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import com.central.order.model.PackagePlan;
|
||||||
|
import com.central.order.model.QrCode;
|
||||||
|
import com.central.order.service.IPackagePlanService;
|
||||||
|
import com.central.order.service.IQrCodeService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Tag(name = "套餐管理")
|
||||||
|
@RequestMapping("/package")
|
||||||
|
public class PackagePlanController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPackagePlanService packagePlanService;
|
||||||
|
@Autowired
|
||||||
|
private IQrCodeService qrCodeService;
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询套餐列表")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||||
|
})
|
||||||
|
@GetMapping
|
||||||
|
public PageResult list(@RequestParam Map<String, Object> params) {
|
||||||
|
return packagePlanService.findList(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "根据ID查询套餐")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public Result<PackagePlan> getById(@PathVariable("id") Long id) {
|
||||||
|
PackagePlan plan = packagePlanService.getById(id);
|
||||||
|
if (plan == null) {
|
||||||
|
return Result.failed("暂无数据");
|
||||||
|
}
|
||||||
|
return Result.succeed(plan, "获取成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "根据二维码编码获取套餐内容")
|
||||||
|
@GetMapping("/byCode/{codeId}")
|
||||||
|
public Result<List<PackagePlan>> getByCode(@PathVariable("codeId") String codeId) {
|
||||||
|
List<PackagePlan> list = packagePlanService.getByCodeId(codeId);
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return Result.succeed(list, "暂无数据");
|
||||||
|
}
|
||||||
|
return Result.succeed(list, "获取成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增或更新套餐")
|
||||||
|
@PostMapping
|
||||||
|
public Result<PackagePlan> saveOrUpdate(@RequestBody PackagePlan plan) {
|
||||||
|
if (plan.getId() == null) {
|
||||||
|
// 新增时补齐租户ID:优先取二维码的租户,否则用当前上下文租户
|
||||||
|
if (plan.getCodeId() != null) {
|
||||||
|
QrCode qr = qrCodeService.getByCodeId(plan.getCodeId());
|
||||||
|
if (qr != null) {
|
||||||
|
plan.setTenantId(qr.getTenantId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plan.getTenantId() == null) {
|
||||||
|
plan.setTenantId(TenantContextHolder.getTenant());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean ok = packagePlanService.saveOrUpdate(plan);
|
||||||
|
return ok ? Result.succeed(plan, "操作成功") : Result.failed("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "根据ID删除套餐")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result<String> delete(@PathVariable("id") Long id) {
|
||||||
|
boolean ok = packagePlanService.removeById(id);
|
||||||
|
return ok ? Result.succeed("删除成功") : Result.failed("删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
+62
@@ -5,6 +5,9 @@ import com.central.common.model.Result;
|
|||||||
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.IOrderService;
|
import com.central.order.service.IOrderService;
|
||||||
|
import com.central.order.service.IPackagePlanService;
|
||||||
|
import com.central.order.model.PackagePlan;
|
||||||
|
import com.central.order.model.dto.QrcodeWithPlanDTO;
|
||||||
import com.central.order.service.IQrCodeService;
|
import com.central.order.service.IQrCodeService;
|
||||||
import com.central.order.service.ITourismFileService;
|
import com.central.order.service.ITourismFileService;
|
||||||
import com.central.order.service.ITourismService;
|
import com.central.order.service.ITourismService;
|
||||||
@@ -13,10 +16,12 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -52,6 +57,9 @@ public class QrCodeController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOrderService orderService;
|
private IOrderService orderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPackagePlanService packagePlanService;
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
@@ -164,4 +172,58 @@ public class QrCodeController {
|
|||||||
map.put("tourismId",qrCode.getTourismId());
|
map.put("tourismId",qrCode.getTourismId());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "创建/修改二维码并同步套餐")
|
||||||
|
@PostMapping("/withPlan")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result<QrCode> saveOrUpdateQrcodeWithPlan(@RequestBody QrcodeWithPlanDTO body) throws Exception {
|
||||||
|
Assert.notNull(body, "请求体不能为空");
|
||||||
|
Assert.notNull(body.getQrCode(), "二维码参数不能为空");
|
||||||
|
|
||||||
|
QrCode qrCode = body.getQrCode();
|
||||||
|
Integer vlogCount = body.getVlogCount();
|
||||||
|
Integer videoCount = body.getVideoCount();
|
||||||
|
Integer photoCount = body.getPhotoCount();
|
||||||
|
|
||||||
|
// 先复用现有的创建/修改逻辑
|
||||||
|
Result<QrCode> result;
|
||||||
|
if (qrCode.getId() == null) {
|
||||||
|
String codeId = UUID.randomUUID().toString();
|
||||||
|
Result<Map> upload = fileCenterService.uploadQrCodeFile(codeId);
|
||||||
|
if (upload.getResp_code() != 0) {
|
||||||
|
return Result.failed("创建二维码文件失败");
|
||||||
|
}
|
||||||
|
Tourism tourism = tourismService.getTourismById(qrCode.getTourismId());
|
||||||
|
Assert.notNull(tourism, "请选择景区数据");
|
||||||
|
qrCode.setTenantId(tourism.getTenantId());
|
||||||
|
qrCode.setCodeId(codeId);
|
||||||
|
qrCode.setFilePath(upload.getData().get("filePath").toString());
|
||||||
|
qrCode.setFileId(upload.getData().get("fileId").toString());
|
||||||
|
if (qrCodeService.saveOrUpdate(qrCode)) {
|
||||||
|
result = Result.succeed(qrCode, "qrcode创建成功");
|
||||||
|
} else {
|
||||||
|
return Result.failed("qrcode创建失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qrCodeService.saveOrUpdate(qrCode);
|
||||||
|
result = Result.succeed(qrCode, "qrcode修改成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同步套餐:有则更新,无则创建
|
||||||
|
String codeId = qrCode.getCodeId();
|
||||||
|
if (codeId != null) {
|
||||||
|
List<PackagePlan> exists = packagePlanService.getByCodeId(codeId);
|
||||||
|
PackagePlan plan = exists != null && !exists.isEmpty() ? exists.get(0) : new PackagePlan();
|
||||||
|
plan.setCodeId(codeId);
|
||||||
|
if (plan.getTenantId() == null) {
|
||||||
|
plan.setTenantId(qrCode.getTenantId());
|
||||||
|
}
|
||||||
|
if (vlogCount != null) plan.setVlogCount(vlogCount);
|
||||||
|
if (videoCount != null) plan.setVideoCount(videoCount);
|
||||||
|
if (photoCount != null) plan.setPhotoCount(photoCount);
|
||||||
|
packagePlanService.saveOrUpdate(plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.central.order.mapper;
|
||||||
|
|
||||||
|
import com.central.db.mapper.SuperMapper;
|
||||||
|
import com.central.order.model.PackagePlan;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface PackagePlanMapper extends SuperMapper<PackagePlan> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据二维码编码查询套餐列表
|
||||||
|
*/
|
||||||
|
List<PackagePlan> findByCodeId(@Param("codeId") String codeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
List<PackagePlan> findList(Page<PackagePlan> page, @Param("p") Map<String, Object> params);
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.central.order.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
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("packages")
|
||||||
|
@Schema(description = "套餐配置")
|
||||||
|
public class PackagePlan extends SuperEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "二维码编码(codeId)")
|
||||||
|
private String codeId;
|
||||||
|
|
||||||
|
@Schema(description = "Vlog数量")
|
||||||
|
private Integer vlogCount;
|
||||||
|
|
||||||
|
@Schema(description = "视频数量")
|
||||||
|
private Integer videoCount;
|
||||||
|
|
||||||
|
@Schema(description = "照片数量")
|
||||||
|
private Integer photoCount;
|
||||||
|
|
||||||
|
@Schema(description = "租户ID")
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
@Schema(description = "所属公司")
|
||||||
|
private String company;
|
||||||
|
|
||||||
|
@Schema(description = "是否删除 0-否 1-是")
|
||||||
|
private Integer isDel;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Schema(description = "更新时间")
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.central.order.model.dto;
|
||||||
|
|
||||||
|
import com.central.order.model.QrCode;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "二维码与套餐创建/修改请求体")
|
||||||
|
public class QrcodeWithPlanDTO {
|
||||||
|
@Schema(description = "二维码实体")
|
||||||
|
private QrCode qrCode;
|
||||||
|
|
||||||
|
@Schema(description = "Vlog数量")
|
||||||
|
private Integer vlogCount;
|
||||||
|
|
||||||
|
@Schema(description = "视频数量")
|
||||||
|
private Integer videoCount;
|
||||||
|
|
||||||
|
@Schema(description = "照片数量")
|
||||||
|
private Integer photoCount;
|
||||||
|
}
|
||||||
|
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.central.order.service;
|
||||||
|
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.service.ISuperService;
|
||||||
|
import com.central.order.model.PackagePlan;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐服务
|
||||||
|
*/
|
||||||
|
public interface IPackagePlanService extends ISuperService<PackagePlan> {
|
||||||
|
/**
|
||||||
|
* 根据二维码编码查询套餐列表
|
||||||
|
*/
|
||||||
|
List<PackagePlan> getByCodeId(String codeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页条件查询
|
||||||
|
*/
|
||||||
|
PageResult<PackagePlan> findList(java.util.Map<String, Object> params);
|
||||||
|
}
|
||||||
+5
-1
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.central.common.context.TenantContextHolder;
|
import com.central.common.context.TenantContextHolder;
|
||||||
import com.central.common.lock.DistributedLock;
|
import com.central.common.lock.DistributedLock;
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
|
import com.central.common.model.SysUser;
|
||||||
import com.central.common.service.impl.SuperServiceImpl;
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
import com.central.order.enums.OrderStatus;
|
import com.central.order.enums.OrderStatus;
|
||||||
import com.central.order.event.OrderStatusChangeEvent;
|
import com.central.order.event.OrderStatusChangeEvent;
|
||||||
@@ -89,7 +90,10 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|||||||
List<Order> list = baseMapper.findList(page, params);
|
List<Order> list = baseMapper.findList(page, params);
|
||||||
log.info("查询结果数量: {}", list.size());
|
log.info("查询结果数量: {}", list.size());
|
||||||
for (Order order : list){
|
for (Order order : list){
|
||||||
order.setMobile(userCenterService.findUserById(order.getUserId()).getMobile());
|
SysUser user = userCenterService.findUserById(order.getUserId());
|
||||||
|
if (user != null){
|
||||||
|
order.setMobile(user.getMobile());
|
||||||
|
}
|
||||||
order.setTourismName(tourismMapper.selectById(order.getTourismId()).getTourismName());
|
order.setTourismName(tourismMapper.selectById(order.getTourismId()).getTourismName());
|
||||||
}
|
}
|
||||||
return PageResult.<Order>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
return PageResult.<Order>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
|
import com.central.order.mapper.PackagePlanMapper;
|
||||||
|
import com.central.order.model.PackagePlan;
|
||||||
|
import com.central.order.service.IPackagePlanService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.common.model.PageResult;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PackagePlanServiceImpl extends SuperServiceImpl<PackagePlanMapper, PackagePlan> implements IPackagePlanService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PackagePlan> getByCodeId(String codeId) {
|
||||||
|
return baseMapper.findByCodeId(codeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<PackagePlan> findList(Map<String, Object> params) {
|
||||||
|
Page<PackagePlan> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||||
|
List<PackagePlan> list = baseMapper.findList(page, params);
|
||||||
|
return PageResult.<PackagePlan>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.central.order.mapper.PackagePlanMapper">
|
||||||
|
|
||||||
|
<resultMap id="PackagePlanResultMap" type="com.central.order.model.PackagePlan">
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="findList" resultMap="PackagePlanResultMap">
|
||||||
|
SELECT *
|
||||||
|
FROM packages t
|
||||||
|
<where>
|
||||||
|
<if test="p.codeId != null and p.codeId != ''">
|
||||||
|
AND t.code_id = #{p.codeId}
|
||||||
|
</if>
|
||||||
|
<if test="p.isDel != null">
|
||||||
|
AND t.is_del = #{p.isDel}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
ORDER BY t.create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="findByCodeId" resultMap="PackagePlanResultMap">
|
||||||
|
SELECT *
|
||||||
|
FROM packages
|
||||||
|
WHERE code_id = #{codeId}
|
||||||
|
AND (is_del IS NULL OR is_del = 0)
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Binary file not shown.
@@ -238,6 +238,36 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
|
{/* 套餐配置 */}
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="vlogCount"
|
||||||
|
label="Vlog数量"
|
||||||
|
min={0}
|
||||||
|
initialValue={0}
|
||||||
|
placeholder="请输入Vlog数量"
|
||||||
|
/>
|
||||||
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="videoCount"
|
||||||
|
label="视频数量"
|
||||||
|
min={0}
|
||||||
|
initialValue={0}
|
||||||
|
placeholder="请输入视频数量"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="photoCount"
|
||||||
|
label="照片数量"
|
||||||
|
min={0}
|
||||||
|
initialValue={0}
|
||||||
|
placeholder="请输入照片数量"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -245,6 +245,33 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
|
{/* 套餐配置 */}
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="vlogCount"
|
||||||
|
label="Vlog数量"
|
||||||
|
min={0}
|
||||||
|
placeholder="请输入Vlog数量"
|
||||||
|
/>
|
||||||
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="videoCount"
|
||||||
|
label="视频数量"
|
||||||
|
min={0}
|
||||||
|
placeholder="请输入视频数量"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormDigit
|
||||||
|
width="md"
|
||||||
|
name="photoCount"
|
||||||
|
label="照片数量"
|
||||||
|
min={0}
|
||||||
|
placeholder="请输入照片数量"
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { deleteQrcode, qrcode, saveOrUpdateQrcode, getTourismList, getVideoTemplateList, getTenantList } from '@/services/orders/api';
|
import { deleteQrcode, qrcode, saveOrUpdateQrcodeWithPlan, getTourismList, getVideoTemplateList, getTenantList, getPackageByCode } 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 {
|
||||||
@@ -121,29 +121,55 @@ const TableList: React.FC = () => {
|
|||||||
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
|
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理添加
|
// 处理添加(先创建二维码,再创建套餐)
|
||||||
const handleAdd = async (fields: Partial<ORDERS.Qrcode>) => {
|
const handleAdd = async (fields: Partial<ORDERS.Qrcode>) => {
|
||||||
const template = templateOptions.find(item => item.value === fields.templateId);
|
const hide = message.loading('正在添加');
|
||||||
return handleApiRequest(
|
try {
|
||||||
() => saveOrUpdateQrcode({
|
const { vlogCount, videoCount, photoCount, ...qrcodePayload } = (fields || {}) as any;
|
||||||
...fields,
|
const res = await saveOrUpdateQrcodeWithPlan({
|
||||||
} as ORDERS.Qrcode),
|
qrCode: qrcodePayload as ORDERS.Qrcode,
|
||||||
'正在添加',
|
vlogCount: Number(vlogCount ?? 0),
|
||||||
'添加成功'
|
videoCount: Number(videoCount ?? 0),
|
||||||
);
|
photoCount: Number(photoCount ?? 0),
|
||||||
|
});
|
||||||
|
if (res.resp_code !== 0) {
|
||||||
|
message.error(res.resp_msg || '创建失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
message.success('添加成功');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
message.error('添加失败');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理编辑
|
// 处理编辑(更新二维码,同时新增/更新套餐)
|
||||||
const handleEdit = async (original: ORDERS.Qrcode, fields: Partial<ORDERS.Qrcode>) => {
|
const handleEdit = async (original: ORDERS.Qrcode, fields: Partial<ORDERS.Qrcode>) => {
|
||||||
const template = templateOptions.find(item => item.value === fields.templateId);
|
const hide = message.loading('正在更新');
|
||||||
return handleApiRequest(
|
try {
|
||||||
() => saveOrUpdateQrcode({
|
const { vlogCount, videoCount, photoCount, ...qrcodePayload } = (fields || {}) as any;
|
||||||
id: original.id,
|
const qrPayload = { id: original.id, codeId: original.codeId, ...(qrcodePayload as any) } as ORDERS.Qrcode;
|
||||||
...fields
|
const res = await saveOrUpdateQrcodeWithPlan({
|
||||||
}),
|
qrCode: qrPayload,
|
||||||
'正在更新',
|
vlogCount: vlogCount as number | undefined,
|
||||||
'修改成功'
|
videoCount: videoCount as number | undefined,
|
||||||
);
|
photoCount: photoCount as number | undefined,
|
||||||
|
});
|
||||||
|
if (res.resp_code !== 0) {
|
||||||
|
message.error(res.resp_msg || '更新失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
message.success('修改成功');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
message.error('修改失败');
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理删除
|
// 处理删除
|
||||||
@@ -525,8 +551,19 @@ const TableList: React.FC = () => {
|
|||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<Space>
|
<Space>
|
||||||
<Link
|
<Link
|
||||||
onClick={() => {
|
onClick={async () => {
|
||||||
setCurrentRow(record);
|
setCurrentRow(record);
|
||||||
|
try {
|
||||||
|
if (record?.codeId) {
|
||||||
|
const planRes = await getPackageByCode(record.codeId);
|
||||||
|
const plan = (planRes.resp_code === 0 && Array.isArray(planRes.data) && planRes.data.length > 0) ? planRes.data[0] : undefined;
|
||||||
|
if (plan) {
|
||||||
|
setCurrentRow(prev => ({ ...(prev as any), vlogCount: plan.vlogCount, videoCount: plan.videoCount, photoCount: plan.photoCount } as any));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// ignore preload error
|
||||||
|
}
|
||||||
handleUpdateModalVisible(true);
|
handleUpdateModalVisible(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -112,6 +112,34 @@ export async function saveOrUpdateQrcode(data: ORDERS.Qrcode): Promise<API.Resul
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 根据二维码编码获取套餐列表 */
|
||||||
|
export async function getPackageByCode(codeId: string): Promise<API.Result<ORDERS.PackagePlan[]>> {
|
||||||
|
return request<API.Result<ORDERS.PackagePlan[]>>(`/api-order/package/byCode/${codeId}`, {
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增或更新套餐 */
|
||||||
|
export async function saveOrUpdatePackagePlan(data: ORDERS.PackagePlan): Promise<API.Result<ORDERS.PackagePlan>> {
|
||||||
|
return request<API.Result<ORDERS.PackagePlan>>('/api-order/package', {
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 一次性创建/修改二维码及套餐 */
|
||||||
|
export async function saveOrUpdateQrcodeWithPlan(payload: {
|
||||||
|
qrCode: ORDERS.Qrcode;
|
||||||
|
vlogCount?: number;
|
||||||
|
videoCount?: number;
|
||||||
|
photoCount?: number;
|
||||||
|
}): Promise<API.Result<ORDERS.Qrcode>> {
|
||||||
|
return request<API.Result<ORDERS.Qrcode>>('/api-order/qrcode/withPlan', {
|
||||||
|
method: 'POST',
|
||||||
|
data: payload,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export async function homeCarousel(params?: { [key: string]: string | number }) {
|
export async function homeCarousel(params?: { [key: string]: string | number }) {
|
||||||
const { current, pageSize, ...rest } = params ?? {};
|
const { current, pageSize, ...rest } = params ?? {};
|
||||||
const result = await request<SYSTEM.Page<ORDERS.HomeCarousel>>('/api-order/home/carousel', {
|
const result = await request<SYSTEM.Page<ORDERS.HomeCarousel>>('/api-order/home/carousel', {
|
||||||
|
|||||||
@@ -248,6 +248,18 @@ declare namespace ORDERS {
|
|||||||
createTime: string;
|
createTime: string;
|
||||||
updateTime: string;
|
updateTime: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 套餐定义 */
|
||||||
|
type PackagePlan = {
|
||||||
|
id?: number;
|
||||||
|
codeId: string;
|
||||||
|
vlogCount?: number;
|
||||||
|
videoCount?: number;
|
||||||
|
photoCount?: number;
|
||||||
|
tenantId?: string;
|
||||||
|
createTime?: string;
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare namespace API {
|
declare namespace API {
|
||||||
|
|||||||
Reference in New Issue
Block a user