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.model.*;
|
||||
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.ITourismFileService;
|
||||
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.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -52,6 +57,9 @@ public class QrCodeController {
|
||||
|
||||
@Autowired
|
||||
private IOrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private IPackagePlanService packagePlanService;
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@@ -164,4 +172,58 @@ public class QrCodeController {
|
||||
map.put("tourismId",qrCode.getTourismId());
|
||||
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.lock.DistributedLock;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.SysUser;
|
||||
import com.central.common.service.impl.SuperServiceImpl;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
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);
|
||||
log.info("查询结果数量: {}", list.size());
|
||||
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());
|
||||
}
|
||||
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>
|
||||
Reference in New Issue
Block a user