feat_withplan_dto
This commit is contained in:
+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;
|
||||
}
|
||||
}
|
||||
|
||||
+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;
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.service.ISuperService;
|
||||
import com.central.order.model.PackagePlan;
|
||||
|
||||
@@ -17,5 +18,5 @@ public interface IPackagePlanService extends ISuperService<PackagePlan> {
|
||||
/**
|
||||
* 分页条件查询
|
||||
*/
|
||||
com.central.common.model.PageResult<PackagePlan> findList(java.util.Map<String, Object> params);
|
||||
PageResult<PackagePlan> findList(java.util.Map<String, Object> params);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user