Merge branch 'develop' of https://gitee.com/L-Shilin/go-fly-platform-services into feature_dzc
# Conflicts: # zlt-doc/TOURISM_WITH_DISTANCE_FIX.md # zlt-doc/优惠券管理功能说明.md # zlt-doc/微信平台证书配置说明.md # zlt-doc/携程优惠券对接接口文档.md # zlt-doc/服务商模式配置说明.md
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
package com.central.order.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 租户分配配置
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "tenant.allocation")
|
||||
public class TenantAllocationConfig {
|
||||
|
||||
/**
|
||||
* 是否启用租户分配功能
|
||||
*/
|
||||
private boolean enabled = false;
|
||||
|
||||
/**
|
||||
* 分配比例(景区:平台)
|
||||
*/
|
||||
private int allocationRatio = 10;
|
||||
|
||||
/**
|
||||
* 平台默认租户ID
|
||||
*/
|
||||
private String platformTenantId = "webApp";
|
||||
|
||||
/**
|
||||
* 是否启用调试模式
|
||||
*/
|
||||
private boolean debug = false;
|
||||
|
||||
/**
|
||||
* 是否强制使用平台租户(用于测试)
|
||||
*/
|
||||
private boolean forcePlatformTenant = false;
|
||||
}
|
||||
-1091
File diff suppressed because it is too large
Load Diff
+109
@@ -18,6 +18,8 @@ import java.util.Map;
|
||||
import java.util.List;
|
||||
import com.central.order.model.vo.FilterOptions;
|
||||
import com.central.order.mapper.DashboardMapper;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.common.model.PageResult;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -75,4 +77,111 @@ public class DashboardController {
|
||||
return Result.failed("获取二维码选项失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "测试时间参数传递")
|
||||
@GetMapping("/test-time-params")
|
||||
public Result<Map<String, Object>> testTimeParams(
|
||||
@Parameter(description = "景区ID") @RequestParam(required = false) Long tourismId,
|
||||
@Parameter(description = "二维码ID") @RequestParam(required = false) String qrcodeId,
|
||||
@Parameter(description = "设备编号") @RequestParam(required = false) String deviceSn,
|
||||
@Parameter(description = "开始时间") @RequestParam(required = false) String startTime,
|
||||
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime,
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tourismId", tourismId);
|
||||
params.put("qrcodeId", qrcodeId);
|
||||
params.put("deviceSn", deviceSn);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
|
||||
// 测试各个统计方法
|
||||
Long totalOrders = dashboardMapper.getTotalOrders(params);
|
||||
Long totalAmount = dashboardMapper.getTotalAmount(params);
|
||||
Long refundAmount = dashboardMapper.getRefundAmount(params);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("params", params);
|
||||
result.put("totalOrders", totalOrders);
|
||||
result.put("totalAmount", totalAmount);
|
||||
result.put("refundAmount", refundAmount);
|
||||
|
||||
return Result.succeed(result, "测试时间参数成功");
|
||||
} catch (Exception e) {
|
||||
log.error("测试时间参数失败", e);
|
||||
return Result.failed("测试失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "测试今日收款订单数计算")
|
||||
@GetMapping("/test-today-paid-orders")
|
||||
public Result<Map<String, Object>> testTodayPaidOrders(
|
||||
@Parameter(description = "景区ID") @RequestParam(required = false) Long tourismId,
|
||||
@Parameter(description = "二维码ID") @RequestParam(required = false) String qrcodeId,
|
||||
@Parameter(description = "设备编号") @RequestParam(required = false) String deviceSn,
|
||||
@Parameter(description = "开始时间") @RequestParam(required = false) String startTime,
|
||||
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime,
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tourismId", tourismId);
|
||||
params.put("qrcodeId", qrcodeId);
|
||||
params.put("deviceSn", deviceSn);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
|
||||
// 测试各个统计方法
|
||||
Long todayOrders = dashboardMapper.getTodayOrders(params);
|
||||
Long todayPaidOrders = dashboardMapper.getTodayPaidOrders(params);
|
||||
Long todayRefundedOrders = dashboardMapper.getTodayRefundedOrders(params);
|
||||
|
||||
// 手动计算验证
|
||||
Long manualCalculation = todayOrders - todayRefundedOrders;
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("params", params);
|
||||
result.put("todayOrders", todayOrders);
|
||||
result.put("todayPaidOrders", todayPaidOrders);
|
||||
result.put("todayRefundedOrders", todayRefundedOrders);
|
||||
result.put("manualCalculation", manualCalculation);
|
||||
result.put("currentDate", new java.util.Date());
|
||||
|
||||
return Result.succeed(result, "测试今日收款订单数计算成功");
|
||||
} catch (Exception e) {
|
||||
log.error("测试今日收款订单数计算失败", e);
|
||||
return Result.failed("测试失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取首页订单列表")
|
||||
@GetMapping("/orders")
|
||||
public Result<PageResult<Order>> getDashboardOrders(
|
||||
@Parameter(description = "景区ID") @RequestParam(required = false) Long tourismId,
|
||||
@Parameter(description = "二维码ID") @RequestParam(required = false) String qrcodeId,
|
||||
@Parameter(description = "设备编号") @RequestParam(required = false) String deviceSn,
|
||||
@Parameter(description = "开始时间") @RequestParam(required = false) String startTime,
|
||||
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime,
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes,
|
||||
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
|
||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "10") Integer limit) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tourismId", tourismId);
|
||||
params.put("qrcodeId", qrcodeId);
|
||||
params.put("deviceSn", deviceSn);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
params.put("page", page);
|
||||
params.put("limit", limit);
|
||||
|
||||
PageResult<Order> result = dashboardService.getDashboardOrders(params);
|
||||
return Result.succeed(result, "获取订单列表成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取订单列表失败", e);
|
||||
return Result.failed("获取订单列表失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+237
-29
@@ -42,6 +42,9 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Order information
|
||||
@@ -101,6 +104,9 @@ public class OrderController {
|
||||
|
||||
@Autowired
|
||||
private WxPayConfigFactory wxPayConfigFactory;
|
||||
|
||||
@Autowired
|
||||
private OrderTenantAllocationService orderTenantAllocationService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -213,11 +219,20 @@ public class OrderController {
|
||||
if (qrCode.getStatus().equals(CommonStatus.UNABLE.getId())){
|
||||
return Result.failed("该二维码已过期");
|
||||
}
|
||||
order.setTenantId(qrCode.getTenantId());
|
||||
|
||||
// 智能租户分配:根据二维码ID确定租户
|
||||
String determinedTenantId = orderTenantAllocationService.determineTenant(
|
||||
qrCode.getCodeId(), qrCode.getTenantId());
|
||||
order.setTenantId(determinedTenantId);
|
||||
|
||||
//设置订单所属tenantId
|
||||
order.setTourismId(qrCode.getTourismId());
|
||||
order.setDeviceSn(qrCode.getDeviceSn());
|
||||
order.setOrderAmount(qrCode.getPrice());
|
||||
|
||||
// 记录订单分配日志
|
||||
orderTenantAllocationService.incrementOrderCount(qrCode.getCodeId());
|
||||
|
||||
}else {
|
||||
Assert.notNull(qrCode,"二维码不存在");
|
||||
}
|
||||
@@ -349,7 +364,7 @@ public class OrderController {
|
||||
map.put("price",appendPriceStr(qrCode.getPrice()));
|
||||
//如果用户存在已支付订单,则查询当前排在第几
|
||||
if (order != null){
|
||||
Integer count = orderService.getOrderRankingByOrderId(order.getId(),qrCode.getTourismId());
|
||||
Integer count = orderService.getOrderRankingByOrderIdAndDevice(order.getId(), qrCode.getDeviceSn());
|
||||
map.put("count", count == 1 ? -1 : count-1 );
|
||||
map.put("time",Math.multiplyExact((count-1),DEVICE_EXEC_TIME));
|
||||
}else {
|
||||
@@ -369,7 +384,7 @@ public class OrderController {
|
||||
QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("price",appendPriceStr(qrCode.getPrice()));
|
||||
Integer count = orderService.getOrderRankingByOrderId(order.getId(),qrCode.getTourismId());
|
||||
Integer count = orderService.getOrderRankingByOrderIdAndDevice(order.getId(), qrCode.getDeviceSn());
|
||||
map.put("count", count == 1 ? -1 : count-1 );
|
||||
map.put("time",Math.multiplyExact((count-1),DEVICE_EXEC_TIME));
|
||||
return Result.succeed(map,"获取成功");
|
||||
@@ -386,7 +401,7 @@ public class OrderController {
|
||||
order.setCreatedTime(sdf.format(order.getCreateTime()));
|
||||
if(order.getOrderStatus().equals(OrderStatus.PAID.getId())){
|
||||
res.put("orderNo",order.getOrderNo());
|
||||
Integer count = orderService.getOrderRankingByOrderId(order.getId(),order.getTourismId());
|
||||
Integer count = orderService.getOrderRankingByOrderIdAndDevice(order.getId(), order.getDeviceSn());
|
||||
res.put("orderStatus",order.getOrderStatus());
|
||||
res.put("waitCount", count == 1 ? -1 : count-1 );
|
||||
res.put("waitTime",Math.multiplyExact((count-1),DEVICE_EXEC_TIME));
|
||||
@@ -659,7 +674,7 @@ public class OrderController {
|
||||
|
||||
// 如果是排队中的订单,添加排队信息
|
||||
if (OrderStatus.PAID.getId().equals(order.getOrderStatus())) {
|
||||
Integer ranking = orderService.getOrderRankingByOrderId(order.getId(), order.getTourismId());
|
||||
Integer ranking = orderService.getOrderRankingByOrderIdAndDevice(order.getId(), order.getDeviceSn());
|
||||
detailMap.put("queueCount", ranking == 1 ? -1 : ranking - 1);
|
||||
detailMap.put("estimatedTime", Math.multiplyExact((ranking - 1), DEVICE_EXEC_TIME));
|
||||
}
|
||||
@@ -726,14 +741,27 @@ public class OrderController {
|
||||
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
List<Map<String,String>> videoList = new ArrayList<>();
|
||||
for (OrderFile orderFile : videoFiles){
|
||||
for (int i = 0; i < videoFiles.size(); i++){
|
||||
OrderFile orderFile = videoFiles.get(i);
|
||||
Map<String,String> videoMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||
videoMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||
videoMap.put("contentType", orderFile.getFileType());
|
||||
videoMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path",orderFile.getFilePath());
|
||||
videoMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
|
||||
// 为视频生成缩略图URL - 使用对应的图片作为缩略图
|
||||
String thumbnailUrl = null;
|
||||
if (!imgList.isEmpty()) {
|
||||
if (i < imgList.size()) {
|
||||
// 使用对应索引的图片作为缩略图
|
||||
thumbnailUrl = imgList.get(i).get("viewUrl");
|
||||
} else {
|
||||
// 如果视频数量超过图片数量,使用最后一张图片作为缩略图
|
||||
thumbnailUrl = imgList.get(imgList.size() - 1).get("viewUrl");
|
||||
}
|
||||
}
|
||||
videoMap.put("viewUrl", thumbnailUrl);
|
||||
|
||||
videoList.add(videoMap);
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
@@ -818,7 +846,7 @@ public class OrderController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版:查询用户订单详情列表(含视频/图片/一键成片)
|
||||
* 新版:查询用户订单详情列表(含视频/图片/一键成片)- 性能优化版本
|
||||
*/
|
||||
@Operation(summary = "新版-查询用户订单详情列表(含视频/图片/一键成片)")
|
||||
@Parameters({
|
||||
@@ -832,6 +860,201 @@ public class OrderController {
|
||||
List<Integer> orderStatusList = List.of(OrderStatus.COMPLETE.getId(), OrderStatus.UPLOADING.getId(), OrderStatus.UPLOADED.getId());
|
||||
params.put("orderStatusList", orderStatusList);
|
||||
|
||||
PageResult<Order> result = orderService.findListByUser(params);
|
||||
if (result.getCount() > 0){
|
||||
List<Map> page = new ArrayList<>();
|
||||
|
||||
// 批量获取所有订单号
|
||||
List<String> orderNos = result.getData().stream()
|
||||
.map(Order::getOrderNo)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量获取所有文件信息
|
||||
Map<String, List<OrderFile>> orderFilesMap = orderFileService.getOrderFilesByOrderNos(orderNos);
|
||||
|
||||
// 批量获取所有景区信息
|
||||
Set<Long> tourismIds = result.getData().stream()
|
||||
.map(Order::getTourismId)
|
||||
.collect(Collectors.toSet());
|
||||
Map<Long, Tourism> tourismMap = tourismService.getTourismsByIds(tourismIds);
|
||||
|
||||
// 预计算所有文件路径的URL,避免重复调用
|
||||
Set<String> allFilePaths = new HashSet<>();
|
||||
orderFilesMap.values().forEach(files ->
|
||||
files.forEach(file -> allFilePaths.add(file.getFilePath())));
|
||||
|
||||
Map<String, String> fileUrlMap = new HashMap<>();
|
||||
Map<String, String> fileStyleUrlMap = new HashMap<>();
|
||||
|
||||
// 批量获取文件URL
|
||||
for (String filePath : allFilePaths) {
|
||||
String url = fileCenterService.getViewUrlByPath(filePath);
|
||||
fileUrlMap.put(filePath, url.replace(cdnOssUrl, cdnUrl));
|
||||
}
|
||||
|
||||
// 预计算样式URL(仅对图片文件)
|
||||
for (List<OrderFile> files : orderFilesMap.values()) {
|
||||
for (OrderFile file : files) {
|
||||
if ("image/jpeg".equals(file.getFileType()) || "image/jpg".equals(file.getFileType()) || "image/png".equals(file.getFileType())) {
|
||||
Map<String, String> styleParams = new HashMap<>();
|
||||
styleParams.put("path", file.getFilePath());
|
||||
styleParams.put("style", fileStyle);
|
||||
String styleUrl = fileCenterService.getViewUrlByPathStyle(styleParams);
|
||||
fileStyleUrlMap.put(file.getFilePath(), styleUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Order order : result.getData()){
|
||||
Map<String,Object> orderFileMap = new HashMap<>();
|
||||
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||
|
||||
// 从缓存获取景区信息
|
||||
Tourism tourism = tourismMap.get(order.getTourismId());
|
||||
orderFileMap.put("addr", tourism != null ? tourism.getTourismAddress() : "");
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
|
||||
// 从缓存获取文件列表
|
||||
List<OrderFile> allFiles = orderFilesMap.getOrDefault(order.getOrderNo(), new ArrayList<>());
|
||||
|
||||
// aiVideo - 使用缓存URL
|
||||
List<OrderFile> aiVideoFiles = allFiles.stream()
|
||||
.filter(f -> "ai_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
String aiVideoUrl = null;
|
||||
if (!aiVideoFiles.isEmpty()) {
|
||||
aiVideoUrl = fileUrlMap.get(aiVideoFiles.get(0).getFilePath());
|
||||
}
|
||||
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||
|
||||
// 图片素材 - 使用缓存URL
|
||||
List<OrderFile> imgFiles = allFiles.stream()
|
||||
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||
.toList();
|
||||
List<Map<String,String>> imgList = new ArrayList<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
for (OrderFile orderFile : imgFiles){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
imgMap.put("url", fileUrlMap.get(orderFile.getFilePath()));
|
||||
imgMap.put("contentType", orderFile.getFileType());
|
||||
imgMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path", orderFile.getFilePath());
|
||||
String viewUrl = fileCenterService.getViewUrlByPathStyle(fileMap);
|
||||
imgMap.put("viewUrl", viewUrl);
|
||||
imgList.add(imgMap);
|
||||
}
|
||||
orderFileMap.put("imgList", imgList);
|
||||
|
||||
// 视频素材 - 使用缓存URL
|
||||
List<OrderFile> videoFiles = allFiles.stream()
|
||||
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
List<Map<String,String>> videoList = new ArrayList<>();
|
||||
for (int i = 0; i < videoFiles.size(); i++){
|
||||
OrderFile orderFile = videoFiles.get(i);
|
||||
Map<String,String> videoMap = new HashMap<>();
|
||||
videoMap.put("url", fileUrlMap.get(orderFile.getFilePath()));
|
||||
videoMap.put("contentType", orderFile.getFileType());
|
||||
videoMap.put("path", orderFile.getFilePath());
|
||||
|
||||
// 为视频生成缩略图URL - 使用对应的图片作为缩略图
|
||||
String thumbnailUrl = null;
|
||||
if (!imgList.isEmpty() && i < imgList.size()) {
|
||||
// 使用对应索引的图片作为缩略图
|
||||
thumbnailUrl = imgList.get(i).get("viewUrl");
|
||||
} else if (!imgList.isEmpty()) {
|
||||
// 如果视频数量超过图片数量,使用第一张图片作为缩略图
|
||||
thumbnailUrl = imgList.get(0).get("viewUrl");
|
||||
}
|
||||
videoMap.put("viewUrl", thumbnailUrl);
|
||||
|
||||
videoList.add(videoMap);
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
|
||||
page.add(orderFileMap);
|
||||
}
|
||||
return PageResult.<Map>builder().data(page).resp_code(0).count(result.getCount()).build();
|
||||
}
|
||||
return new PageResult<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版:查询用户图片订单详情列表
|
||||
*/
|
||||
@Operation(summary = "新版-查询用户图片订单详情列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "fileType",description = "文件类型筛选",required = false,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "fileTag",description = "文件标签筛选",required = false,in=ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/user/images")
|
||||
public PageResult<Map> listImageOrdersByUser(@RequestParam Map<String, Object> params) {
|
||||
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||
params.put("userId", user.getId());
|
||||
List<Integer> orderStatusList = List.of(OrderStatus.COMPLETE.getId(), OrderStatus.UPLOADING.getId(), OrderStatus.UPLOADED.getId());
|
||||
params.put("orderStatusList", orderStatusList);
|
||||
|
||||
PageResult<Order> result = orderService.findListByUser(params);
|
||||
if (result.getCount() > 0){
|
||||
List<Map> page = new ArrayList<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
for(Order order : result.getData()){
|
||||
Map<String,Object> orderFileMap = new HashMap<>();
|
||||
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
|
||||
// 只查一次所有文件
|
||||
List<OrderFile> allFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo());
|
||||
|
||||
// 图片素材
|
||||
List<OrderFile> imgFiles = allFiles.stream()
|
||||
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||
.toList();
|
||||
List<Map<String,String>> imgList = new ArrayList<>();
|
||||
for (OrderFile orderFile : imgFiles){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||
imgMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||
imgMap.put("contentType", orderFile.getFileType());
|
||||
imgMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path",orderFile.getFilePath());
|
||||
imgMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
imgList.add(imgMap);
|
||||
}
|
||||
orderFileMap.put("imgList", imgList);
|
||||
|
||||
// 只返回有图片的订单
|
||||
if (!imgList.isEmpty()) {
|
||||
page.add(orderFileMap);
|
||||
}
|
||||
}
|
||||
return PageResult.<Map>builder().data(page).resp_code(0).count((long) page.size()).build();
|
||||
}
|
||||
return new PageResult<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版:查询用户视频订单详情列表
|
||||
*/
|
||||
@Operation(summary = "新版-查询用户视频订单详情列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "fileType",description = "文件类型筛选",required = false,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "fileTag",description = "文件标签筛选",required = false,in=ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/user/videos")
|
||||
public PageResult<Map> listVideoOrdersByUser(@RequestParam Map<String, Object> params) {
|
||||
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||
params.put("userId", user.getId());
|
||||
List<Integer> orderStatusList = List.of(OrderStatus.COMPLETE.getId(), OrderStatus.UPLOADING.getId(), OrderStatus.UPLOADED.getId());
|
||||
params.put("orderStatusList", orderStatusList);
|
||||
|
||||
PageResult<Order> result = orderService.findListByUser(params);
|
||||
if (result.getCount() > 0){
|
||||
List<Map> page = new ArrayList<>();
|
||||
@@ -852,28 +1075,10 @@ public class OrderController {
|
||||
.toList();
|
||||
String aiVideoUrl = null;
|
||||
if (!aiVideoFiles.isEmpty()) {
|
||||
// fileMap.put("path", aiVideoFiles.get(0).getFilePath());
|
||||
aiVideoUrl = fileCenterService.getViewUrlByPath(aiVideoFiles.get(0).getFilePath()).replace(cdnOssUrl, cdnUrl);
|
||||
}
|
||||
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||
|
||||
// 图片素材
|
||||
List<OrderFile> imgFiles = allFiles.stream()
|
||||
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||
.toList();
|
||||
List<Map<String,String>> imgList = new ArrayList<>();
|
||||
for (OrderFile orderFile : imgFiles){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||
imgMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||
imgMap.put("contentType", orderFile.getFileType());
|
||||
imgMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path",orderFile.getFilePath());
|
||||
imgMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||
imgList.add(imgMap);
|
||||
}
|
||||
orderFileMap.put("imgList", imgList);
|
||||
|
||||
// 视频素材
|
||||
List<OrderFile> videoFiles = allFiles.stream()
|
||||
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||
@@ -891,9 +1096,12 @@ public class OrderController {
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
|
||||
page.add(orderFileMap);
|
||||
// 只返回有视频的订单(包括aiVideo或raw_video)
|
||||
if (aiVideoUrl != null || !videoList.isEmpty()) {
|
||||
page.add(orderFileMap);
|
||||
}
|
||||
}
|
||||
return PageResult.<Map>builder().data(page).resp_code(0).count(result.getCount()).build();
|
||||
return PageResult.<Map>builder().data(page).resp_code(0).count((long) page.size()).build();
|
||||
}
|
||||
return new PageResult<>();
|
||||
}
|
||||
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.service.OrderTenantAllocationService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单租户分配测试控制器
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/order/tenant-allocation")
|
||||
@Tag(name = "订单租户分配测试")
|
||||
public class OrderTenantAllocationController {
|
||||
|
||||
@Autowired
|
||||
private OrderTenantAllocationService allocationService;
|
||||
|
||||
@Operation(summary = "测试租户分配逻辑")
|
||||
@GetMapping("/test")
|
||||
public Result<Map<String, Object>> testAllocationLogic(
|
||||
@Parameter(description = "用户ID") @RequestParam String userId,
|
||||
@Parameter(description = "二维码ID") @RequestParam String qrCodeId,
|
||||
@Parameter(description = "期望订单数量") @RequestParam(defaultValue = "100") int expectedCount) {
|
||||
|
||||
try {
|
||||
log.info("测试租户分配逻辑 - userId: {}, qrCodeId: {}, expectedCount: {}", userId, qrCodeId, expectedCount);
|
||||
|
||||
Map<String, Object> result = allocationService.validateAllocationLogic(qrCodeId, expectedCount);
|
||||
|
||||
// 添加分配示例
|
||||
Map<String, Object> allocationExample = allocationService.getAllocationStatistics(qrCodeId);
|
||||
result.put("allocationConfig", allocationExample);
|
||||
|
||||
log.info("租户分配逻辑测试完成");
|
||||
return Result.succeed(result, "分配逻辑验证完成");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("测试租户分配逻辑失败", e);
|
||||
return Result.failed("测试失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "模拟订单分配")
|
||||
@PostMapping("/simulate")
|
||||
public Result<Map<String, Object>> simulateOrderAllocation(
|
||||
@Parameter(description = "用户ID") @RequestParam String userId,
|
||||
@Parameter(description = "二维码ID") @RequestParam String qrCodeId,
|
||||
@Parameter(description = "模拟订单数量") @RequestParam(defaultValue = "22") int orderCount) {
|
||||
|
||||
try {
|
||||
log.info("模拟订单分配 - userId: {}, qrCodeId: {}, orderCount: {}", userId, qrCodeId, orderCount);
|
||||
|
||||
Map<String, Object> result = new java.util.HashMap<>();
|
||||
Map<String, Object> allocationDetails = new java.util.HashMap<>();
|
||||
|
||||
int scenicCount = 0;
|
||||
int platformCount = 0;
|
||||
|
||||
// 模拟订单分配过程
|
||||
for (int i = 0; i < orderCount; i++) {
|
||||
String tenantId = allocationService.determineTenant(qrCodeId, "scenic_tenant_" + qrCodeId);
|
||||
|
||||
if (tenantId.contains("platform")) {
|
||||
platformCount++;
|
||||
} else {
|
||||
scenicCount++;
|
||||
}
|
||||
|
||||
// 记录分配日志(模拟)
|
||||
allocationService.incrementOrderCount(qrCodeId);
|
||||
|
||||
allocationDetails.put("order_" + (i + 1), Map.of(
|
||||
"orderNumber", i + 1,
|
||||
"tenantId", tenantId,
|
||||
"tenantType", tenantId.contains("platform") ? "平台" : "景区"
|
||||
));
|
||||
}
|
||||
|
||||
result.put("totalOrders", orderCount);
|
||||
result.put("scenicOrders", scenicCount);
|
||||
result.put("platformOrders", platformCount);
|
||||
result.put("scenicPercentage", (double) scenicCount / orderCount * 100);
|
||||
result.put("platformPercentage", (double) platformCount / orderCount * 100);
|
||||
result.put("allocationDetails", allocationDetails);
|
||||
|
||||
log.info("模拟订单分配完成 - 总订单: {}, 景区订单: {}, 平台订单: {}", orderCount, scenicCount, platformCount);
|
||||
return Result.succeed(result, "模拟分配完成");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("模拟订单分配失败", e);
|
||||
return Result.failed("模拟失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取分配统计信息")
|
||||
@GetMapping("/statistics")
|
||||
public Result<Map<String, Object>> getAllocationStatistics(
|
||||
@Parameter(description = "二维码ID") @RequestParam String qrCodeId) {
|
||||
|
||||
try {
|
||||
log.info("获取分配统计信息 - qrCodeId: {}", qrCodeId);
|
||||
|
||||
Map<String, Object> result = allocationService.getAllocationStatistics(qrCodeId);
|
||||
|
||||
return Result.succeed(result, "获取统计信息成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取分配统计信息失败", e);
|
||||
return Result.failed("获取失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取详细诊断信息")
|
||||
@GetMapping("/diagnostics")
|
||||
public Result<Map<String, Object>> getDetailedDiagnostics(
|
||||
@Parameter(description = "二维码ID") @RequestParam String qrCodeId) {
|
||||
|
||||
try {
|
||||
log.info("获取详细诊断信息 - qrCodeId: {}", qrCodeId);
|
||||
|
||||
Map<String, Object> result = allocationService.getDetailedDiagnostics(qrCodeId);
|
||||
|
||||
return Result.succeed(result, "获取诊断信息成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取详细诊断信息失败", e);
|
||||
return Result.failed("获取失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "测试数据库查询")
|
||||
@GetMapping("/test-db")
|
||||
public Result<Map<String, Object>> testDatabaseQuery(
|
||||
@Parameter(description = "二维码ID") @RequestParam String qrCodeId) {
|
||||
|
||||
try {
|
||||
log.info("测试数据库查询 - qrCodeId: {}", qrCodeId);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
// 测试各种查询
|
||||
int totalOrders = allocationService.getOrderCountByQrCode(qrCodeId);
|
||||
result.put("totalOrders", totalOrders);
|
||||
|
||||
// 获取统计信息
|
||||
Map<String, Object> statistics = allocationService.getAllocationStatistics(qrCodeId);
|
||||
result.put("statistics", statistics);
|
||||
|
||||
// 获取诊断信息
|
||||
Map<String, Object> diagnostics = allocationService.getDetailedDiagnostics(qrCodeId);
|
||||
result.put("diagnostics", diagnostics);
|
||||
|
||||
return Result.succeed(result, "数据库查询测试完成");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("测试数据库查询失败", e);
|
||||
return Result.failed("测试失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.config.TenantAllocationConfig;
|
||||
import com.central.order.service.OrderTenantAllocationService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 租户分配配置管理控制器
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/tenant-allocation/config")
|
||||
@Tag(name = "租户分配配置管理")
|
||||
public class TenantAllocationConfigController {
|
||||
|
||||
@Autowired
|
||||
private TenantAllocationConfig config;
|
||||
|
||||
@Autowired
|
||||
private OrderTenantAllocationService allocationService;
|
||||
|
||||
@Operation(summary = "获取当前配置")
|
||||
@GetMapping("/current")
|
||||
public Result<Map<String, Object>> getCurrentConfig() {
|
||||
try {
|
||||
Map<String, Object> result = Map.of(
|
||||
"enabled", config.isEnabled(),
|
||||
"allocationRatio", config.getAllocationRatio(),
|
||||
"platformTenantId", config.getPlatformTenantId(),
|
||||
"debug", config.isDebug(),
|
||||
"forcePlatformTenant", config.isForcePlatformTenant()
|
||||
);
|
||||
|
||||
return Result.succeed(result, "获取配置成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取配置失败", e);
|
||||
return Result.failed("获取配置失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "更新配置")
|
||||
@PostMapping("/update")
|
||||
public Result<String> updateConfig(
|
||||
@Parameter(description = "是否启用") @RequestParam(required = false) Boolean enabled,
|
||||
@Parameter(description = "分配比例") @RequestParam(required = false) Integer allocationRatio,
|
||||
@Parameter(description = "平台租户ID") @RequestParam(required = false) String platformTenantId,
|
||||
@Parameter(description = "是否调试模式") @RequestParam(required = false) Boolean debug,
|
||||
@Parameter(description = "是否强制平台租户") @RequestParam(required = false) Boolean forcePlatformTenant) {
|
||||
|
||||
try {
|
||||
if (enabled != null) {
|
||||
config.setEnabled(enabled);
|
||||
log.info("更新配置 - enabled: {}", enabled);
|
||||
}
|
||||
|
||||
if (allocationRatio != null) {
|
||||
config.setAllocationRatio(allocationRatio);
|
||||
log.info("更新配置 - allocationRatio: {}", allocationRatio);
|
||||
}
|
||||
|
||||
if (platformTenantId != null) {
|
||||
config.setPlatformTenantId(platformTenantId);
|
||||
log.info("更新配置 - platformTenantId: {}", platformTenantId);
|
||||
}
|
||||
|
||||
if (debug != null) {
|
||||
config.setDebug(debug);
|
||||
log.info("更新配置 - debug: {}", debug);
|
||||
}
|
||||
|
||||
if (forcePlatformTenant != null) {
|
||||
config.setForcePlatformTenant(forcePlatformTenant);
|
||||
log.info("更新配置 - forcePlatformTenant: {}", forcePlatformTenant);
|
||||
}
|
||||
|
||||
return Result.succeed("配置更新成功");
|
||||
} catch (Exception e) {
|
||||
log.error("更新配置失败", e);
|
||||
return Result.failed("更新配置失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "启用租户分配功能")
|
||||
@PostMapping("/enable")
|
||||
public Result<String> enableAllocation() {
|
||||
try {
|
||||
config.setEnabled(true);
|
||||
log.info("启用租户分配功能");
|
||||
return Result.succeed("租户分配功能已启用");
|
||||
} catch (Exception e) {
|
||||
log.error("启用租户分配功能失败", e);
|
||||
return Result.failed("启用失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "禁用租户分配功能")
|
||||
@PostMapping("/disable")
|
||||
public Result<String> disableAllocation() {
|
||||
try {
|
||||
config.setEnabled(false);
|
||||
log.info("禁用租户分配功能");
|
||||
return Result.succeed("租户分配功能已禁用");
|
||||
} catch (Exception e) {
|
||||
log.error("禁用租户分配功能失败", e);
|
||||
return Result.failed("禁用失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "测试配置")
|
||||
@PostMapping("/test")
|
||||
public Result<Map<String, Object>> testConfig(
|
||||
@Parameter(description = "用户ID") @RequestParam String userId,
|
||||
@Parameter(description = "二维码ID") @RequestParam String qrCodeId,
|
||||
@Parameter(description = "测试订单数量") @RequestParam(defaultValue = "22") int testCount) {
|
||||
|
||||
try {
|
||||
log.info("测试配置 - userId: {}, qrCodeId: {}, testCount: {}", userId, qrCodeId, testCount);
|
||||
|
||||
// 获取当前配置
|
||||
Map<String, Object> currentConfig = Map.of(
|
||||
"enabled", config.isEnabled(),
|
||||
"allocationRatio", config.getAllocationRatio(),
|
||||
"platformTenantId", config.getPlatformTenantId(),
|
||||
"debug", config.isDebug(),
|
||||
"forcePlatformTenant", config.isForcePlatformTenant()
|
||||
);
|
||||
|
||||
// 测试分配逻辑
|
||||
Map<String, Object> testResult = allocationService.validateAllocationLogic(qrCodeId, testCount);
|
||||
|
||||
// 合并结果
|
||||
Map<String, Object> result = Map.of(
|
||||
"currentConfig", currentConfig,
|
||||
"testResult", testResult
|
||||
);
|
||||
|
||||
return Result.succeed(result, "配置测试完成");
|
||||
} catch (Exception e) {
|
||||
log.error("测试配置失败", e);
|
||||
return Result.failed("测试失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
package com.central.order.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 优惠券实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_coupon")
|
||||
public class Coupon implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 优惠券编号
|
||||
*/
|
||||
private String couponNo;
|
||||
|
||||
/**
|
||||
* 优惠券名称
|
||||
*/
|
||||
private String couponName;
|
||||
|
||||
/**
|
||||
* 优惠券类型:1-满减券,2-折扣券,3-免费券
|
||||
*/
|
||||
private Integer couponType;
|
||||
|
||||
/**
|
||||
* 优惠券面额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 使用门槛金额
|
||||
*/
|
||||
private BigDecimal minAmount;
|
||||
|
||||
/**
|
||||
* 折扣率(0-100,折扣券时使用)
|
||||
*/
|
||||
private Integer discountRate;
|
||||
|
||||
/**
|
||||
* 优惠券状态:0-未使用,1-已使用,2-已过期,3-已作废
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 用户手机号
|
||||
*/
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 来源:1-携程,2-高飞自建
|
||||
*/
|
||||
private Integer source;
|
||||
|
||||
/**
|
||||
* 携程优惠券ID(来源为携程时使用)
|
||||
*/
|
||||
private String ctripCouponId;
|
||||
|
||||
/**
|
||||
* 有效期开始时间
|
||||
*/
|
||||
private Date validStartTime;
|
||||
|
||||
/**
|
||||
* 有效期结束时间
|
||||
*/
|
||||
private Date validEndTime;
|
||||
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
private Date usedTime;
|
||||
|
||||
/**
|
||||
* 使用订单号
|
||||
*/
|
||||
private String usedOrderNo;
|
||||
|
||||
/**
|
||||
* 退券时间
|
||||
*/
|
||||
private Date cancelTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
+1
-1
@@ -160,7 +160,7 @@ public class OrderStatusChangeListener {
|
||||
|
||||
SysUser sysUser = userCenterService.findUserById(order.getUserId());
|
||||
// 2. 查询订单排队信息
|
||||
Integer queue = orderService.getOrderRankingByOrderId(order.getId(),tourism.getId());
|
||||
Integer queue = orderService.getOrderRankingByOrderIdAndDevice(order.getId(), order.getDeviceSn());
|
||||
|
||||
// 发送小程序订阅消息
|
||||
if (sysUser.getOpenId() != null) {
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.central.order.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.order.entity.Coupon;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CouponMapper extends BaseMapper<Coupon> {
|
||||
|
||||
/**
|
||||
* 分页查询优惠券列表
|
||||
*/
|
||||
IPage<Coupon> selectCouponPage(Page<Coupon> page, @Param("coupon") Coupon coupon);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户优惠券
|
||||
*/
|
||||
List<Coupon> selectByUserPhone(@Param("userPhone") String userPhone);
|
||||
|
||||
/**
|
||||
* 根据手机号查询可用优惠券
|
||||
*/
|
||||
List<Coupon> selectAvailableByUserPhone(@Param("userPhone") String userPhone);
|
||||
|
||||
/**
|
||||
* 根据携程优惠券ID查询
|
||||
*/
|
||||
Coupon selectByCtripCouponId(@Param("ctripCouponId") String ctripCouponId);
|
||||
|
||||
/**
|
||||
* 根据订单号查询使用的优惠券
|
||||
*/
|
||||
Coupon selectByUsedOrderNo(@Param("usedOrderNo") String usedOrderNo);
|
||||
|
||||
/**
|
||||
* 更新优惠券状态为已使用
|
||||
*/
|
||||
int updateCouponUsed(@Param("id") Long id, @Param("usedOrderNo") String usedOrderNo);
|
||||
|
||||
/**
|
||||
* 批量更新过期优惠券状态
|
||||
*/
|
||||
int updateExpiredCoupons();
|
||||
}
|
||||
+321
-185
@@ -17,10 +17,11 @@ public interface DashboardMapper {
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -45,11 +46,12 @@ public interface DashboardMapper {
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND DATE(o.create_time) = CURDATE()",
|
||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -68,11 +70,297 @@ public interface DashboardMapper {
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status = 8",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getRefundedOrders(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status = 8",
|
||||
"AND DATE(o.create_time) = CURDATE()",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTodayRefundedOrders(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" SUM(CASE WHEN o.order_status IN (1, 3, 4, 5, 7) THEN 1 ELSE 0 END) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTotalPaidOrders(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" SUM(CASE WHEN o.order_status IN (1, 3, 4, 5, 7) THEN 1 ELSE 0 END) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
" AND DATE(o.create_time) = CURDATE()",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTodayPaidOrders(@Param("p") Map<String, Object> params);
|
||||
|
||||
// 对账相关统计
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(o.order_amount), 0) as amount",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status IN (1, 3, 4, 5, 6, 7, 8, 9)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTotalAmount(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(o.order_amount), 0) as amount",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status = 8",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getRefundAmount(@Param("p") Map<String, Object> params);
|
||||
|
||||
// 图表数据
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" 'created' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" 'completed' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
" AND o.order_status = 3",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" 'refunded' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
" AND o.order_status = 8",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"ORDER BY date, type",
|
||||
"</script>"
|
||||
})
|
||||
List<TrendDataVO> getOrderTrend(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" q.name as qrcodeName,",
|
||||
" q.code_id as qrcodeId,",
|
||||
" COUNT(o.id) as orderCount",
|
||||
"FROM qrcodes q",
|
||||
"LEFT JOIN orders o ON q.code_id = o.code_id AND o.order_status IN (3, 7)",
|
||||
"WHERE q.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND q.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"GROUP BY q.code_id, q.name",
|
||||
"HAVING orderCount > 0",
|
||||
"ORDER BY orderCount DESC",
|
||||
"LIMIT 20",
|
||||
"</script>"
|
||||
})
|
||||
List<QrcodeOrderDataVO> getQrcodeOrderCount(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND DATE(o.create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)",
|
||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -91,7 +379,7 @@ public interface DashboardMapper {
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
@@ -115,148 +403,6 @@ public interface DashboardMapper {
|
||||
})
|
||||
Long getCompletedOrders(@Param("p") Map<String, Object> params);
|
||||
|
||||
// 对账相关统计
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(o.order_amount), 0) as amount",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND (o.order_status = 3 OR o.order_status = 8)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTotalAmount(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(os.platform_amount), 0)",
|
||||
"FROM order_statistics os",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getPlatformAmount(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(os.tourism_amount), 0)",
|
||||
"FROM order_statistics os",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getTourismAmount(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0) as amount",
|
||||
"FROM orders_refund r",
|
||||
"JOIN orders o ON r.order_no = o.order_no",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE r.status = 8",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND r.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND r.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
Long getRefundAmount(@Param("p") Map<String, Object> params);
|
||||
|
||||
// 图表数据
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" 'orders' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
" AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"ORDER BY date",
|
||||
"</script>"
|
||||
})
|
||||
List<TrendDataVO> getOrderTrend(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
@@ -276,7 +422,7 @@ public interface DashboardMapper {
|
||||
" COUNT(*) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
@@ -304,74 +450,77 @@ public interface DashboardMapper {
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" '平台分账' as type,",
|
||||
" COALESCE(SUM(os.platform_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
" COALESCE(SUM(CASE WHEN o.order_status IN (1, 3, 4, 5, 6, 7, 8, 9) THEN o.order_amount * 0.3 ELSE 0 END), 0) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '景区分账' as type,",
|
||||
" COALESCE(SUM(os.tourism_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
" COALESCE(SUM(CASE WHEN o.order_status IN (1, 3, 4, 5, 6, 7, 8, 9) THEN o.order_amount * 0.7 ELSE 0 END), 0) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '退款金额' as type,",
|
||||
" COALESCE(SUM(os.refund_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
" COALESCE(SUM(CASE WHEN o.order_status = 8 THEN o.order_amount ELSE 0 END), 0) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -395,17 +544,4 @@ public interface DashboardMapper {
|
||||
"</script>"
|
||||
})
|
||||
List<FilterOptions.OptionItem> getQrcodeOptions(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT DISTINCT device_sn as value, device_sn as label FROM qrcodes",
|
||||
"WHERE is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND is_test = 0",
|
||||
"</if>",
|
||||
"AND device_sn IS NOT NULL",
|
||||
"ORDER BY device_sn",
|
||||
"</script>"
|
||||
})
|
||||
List<FilterOptions.OptionItem> getDeviceOptions(@Param("p") Map<String, Object> params);
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,16 @@ public interface OrderMapper extends SuperMapper<Order> {
|
||||
"ORDER BY \n" +
|
||||
" pay_time;")
|
||||
List<OrderRanking> getOrderRanking1(@Param("tourismId") Long tourismId);
|
||||
|
||||
@Select("SELECT \n" +
|
||||
" id,\n" +
|
||||
" @rank := @rank + 1 as ranking\n" +
|
||||
"FROM \n" +
|
||||
" orders,\n" +
|
||||
" (SELECT @rank := 0) r\n" +
|
||||
"WHERE \n" +
|
||||
" order_status in(1,4,5,6) and device_sn = #{deviceSn} \n" +
|
||||
"ORDER BY \n" +
|
||||
" pay_time;")
|
||||
List<OrderRanking> getOrderRankingByDevice(@Param("deviceSn") String deviceSn);
|
||||
}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.central.order.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 租户分配数据库查询Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderTenantAllocationMapper {
|
||||
|
||||
/**
|
||||
* 获取指定二维码下的总订单数量
|
||||
* @param qrCodeId 二维码ID
|
||||
* @return 订单数量
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM orders WHERE code_id = #{qrCodeId} AND is_del = 0")
|
||||
int getOrderCountByQrCode(@Param("qrCodeId") String qrCodeId);
|
||||
|
||||
/**
|
||||
* 获取指定二维码下指定租户的订单数量
|
||||
* @param qrCodeId 二维码ID
|
||||
* @param tenantId 租户ID
|
||||
* @return 订单数量
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM orders WHERE code_id = #{qrCodeId} AND tenant_id = #{tenantId} AND is_del = 0")
|
||||
int getOrderCountByQrCodeAndTenant(@Param("qrCodeId") String qrCodeId, @Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 获取指定二维码下景区租户的订单数量
|
||||
* @param qrCodeId 二维码ID
|
||||
* @param scenicTenantId 景区租户ID
|
||||
* @return 订单数量
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM orders WHERE code_id = #{qrCodeId} AND tenant_id = #{scenicTenantId} AND is_del = 0")
|
||||
int getScenicOrderCount(@Param("qrCodeId") String qrCodeId, @Param("scenicTenantId") String scenicTenantId);
|
||||
|
||||
/**
|
||||
* 获取指定二维码下平台租户的订单数量
|
||||
* @param qrCodeId 二维码ID
|
||||
* @param platformTenantId 平台租户ID
|
||||
* @return 订单数量
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM orders WHERE code_id = #{qrCodeId} AND tenant_id = #{platformTenantId} AND is_del = 0")
|
||||
int getPlatformOrderCount(@Param("qrCodeId") String qrCodeId, @Param("platformTenantId") String platformTenantId);
|
||||
|
||||
/**
|
||||
* 获取指定二维码下的订单统计信息
|
||||
* @param qrCodeId 二维码ID
|
||||
* @return 统计信息Map
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"COUNT(*) as totalOrders, " +
|
||||
"SUM(CASE WHEN tenant_id = #{scenicTenantId} THEN 1 ELSE 0 END) as scenicOrders, " +
|
||||
"SUM(CASE WHEN tenant_id = #{platformTenantId} THEN 1 ELSE 0 END) as platformOrders " +
|
||||
"FROM orders " +
|
||||
"WHERE code_id = #{qrCodeId} AND is_del = 0")
|
||||
java.util.Map<String, Object> getOrderStatisticsByQrCode(
|
||||
@Param("qrCodeId") String qrCodeId,
|
||||
@Param("scenicTenantId") String scenicTenantId,
|
||||
@Param("platformTenantId") String platformTenantId);
|
||||
|
||||
/**
|
||||
* 获取指定二维码下最近的订单信息
|
||||
* @param qrCodeId 二维码ID
|
||||
* @param limit 限制数量
|
||||
* @return 订单列表
|
||||
*/
|
||||
@Select("SELECT id, order_no, user_id, tenant_id, order_amount, order_status, create_time " +
|
||||
"FROM orders " +
|
||||
"WHERE code_id = #{qrCodeId} AND is_del = 0 " +
|
||||
"ORDER BY create_time DESC " +
|
||||
"LIMIT #{limit}")
|
||||
java.util.List<java.util.Map<String, Object>> getRecentOrdersByQrCode(
|
||||
@Param("qrCodeId") String qrCodeId, @Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 获取指定二维码下指定时间范围内的订单数量
|
||||
* @param qrCodeId 二维码ID
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 订单数量
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM orders " +
|
||||
"WHERE code_id = #{qrCodeId} AND is_del = 0 " +
|
||||
"AND create_time >= #{startTime} AND create_time <= #{endTime}")
|
||||
int getOrderCountByQrCodeAndTimeRange(
|
||||
@Param("qrCodeId") String qrCodeId,
|
||||
@Param("startTime") java.util.Date startTime,
|
||||
@Param("endTime") java.util.Date endTime);
|
||||
}
|
||||
-190
@@ -1,190 +0,0 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单新订请求
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCreateOrderRequest {
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripHeader header;
|
||||
|
||||
/**
|
||||
* 请求体 - 可能是加密字符串或JSON对象
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private Object body; // 改为Object类型,支持字符串和对象两种格式
|
||||
|
||||
/**
|
||||
* 携程请求头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripHeader {
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime;
|
||||
@JsonProperty("accountId")
|
||||
private String accountId;
|
||||
@JsonProperty("sign")
|
||||
private String sign;
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName;
|
||||
@JsonProperty("version")
|
||||
private String version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripOrderBody {
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId;
|
||||
@JsonProperty("sequenceId")
|
||||
private String sequenceId;
|
||||
@JsonProperty("items")
|
||||
private List<CtripOrderItem> items;
|
||||
@JsonProperty("contacts")
|
||||
private List<CtripContact> contacts;
|
||||
@JsonProperty("confirmType")
|
||||
private Integer confirmType;
|
||||
@JsonProperty("locale")
|
||||
private String locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripOrderItem {
|
||||
@JsonProperty("passengers")
|
||||
private List<CtripPassenger> passengers;
|
||||
@JsonProperty("cost")
|
||||
private java.math.BigDecimal cost;
|
||||
@JsonProperty("quantity")
|
||||
private Integer quantity;
|
||||
@JsonProperty("salePrice")
|
||||
private java.math.BigDecimal salePrice;
|
||||
@JsonProperty("remark")
|
||||
private String remark;
|
||||
@JsonProperty("useEndDate")
|
||||
private String useEndDate;
|
||||
@JsonProperty("locale")
|
||||
private String locale;
|
||||
@JsonProperty("useStartDate")
|
||||
private String useStartDate;
|
||||
@JsonProperty("priceCurrency")
|
||||
private String priceCurrency;
|
||||
@JsonProperty("adjunctions")
|
||||
private List<String> adjunctions;
|
||||
@JsonProperty("price")
|
||||
private java.math.BigDecimal price;
|
||||
@JsonProperty("PLU")
|
||||
private String PLU;
|
||||
@JsonProperty("deposit")
|
||||
private Object deposit; // 改回Object类型,因为可能是对象
|
||||
@JsonProperty("distributionChannel")
|
||||
private String distributionChannel;
|
||||
@JsonProperty("costCurrency")
|
||||
private String costCurrency;
|
||||
@JsonProperty("salePriceCurrency")
|
||||
private String salePriceCurrency;
|
||||
@JsonProperty("expressDelivery")
|
||||
private CtripExpressDelivery expressDelivery;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程乘客信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripPassenger {
|
||||
@JsonProperty("cardIssuePlace")
|
||||
private String cardIssuePlace;
|
||||
@JsonProperty("lastName")
|
||||
private String lastName;
|
||||
@JsonProperty("cardIssueCountry")
|
||||
private String cardIssueCountry;
|
||||
@JsonProperty("shoeSize")
|
||||
private Integer shoeSize;
|
||||
@JsonProperty("gender")
|
||||
private String gender;
|
||||
@JsonProperty("cardIssueDate")
|
||||
private String cardIssueDate;
|
||||
@JsonProperty("intlCode")
|
||||
private String intlCode;
|
||||
@JsonProperty("nationalityName")
|
||||
private String nationalityName;
|
||||
@JsonProperty("mobile")
|
||||
private String mobile;
|
||||
@JsonProperty("cardType")
|
||||
private String cardType;
|
||||
@JsonProperty("weight")
|
||||
private Integer weight;
|
||||
@JsonProperty("myopiaDegreeL")
|
||||
private Integer myopiaDegreeL;
|
||||
@JsonProperty("birthDate")
|
||||
private String birthDate;
|
||||
@JsonProperty("cardNo")
|
||||
private String cardNo;
|
||||
@JsonProperty("ageType")
|
||||
private String ageType;
|
||||
@JsonProperty("myopiaDegreeR")
|
||||
private Integer myopiaDegreeR;
|
||||
@JsonProperty("firstName")
|
||||
private String firstName;
|
||||
@JsonProperty("birthPlace")
|
||||
private String birthPlace;
|
||||
@JsonProperty("nationalityCode")
|
||||
private String nationalityCode;
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@JsonProperty("passengerId")
|
||||
private String passengerId;
|
||||
@JsonProperty("cardValidDate")
|
||||
private String cardValidDate;
|
||||
@JsonProperty("height")
|
||||
private Integer height;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程联系人信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripContact {
|
||||
@JsonProperty("intlCode")
|
||||
private String intlCode;
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@JsonProperty("mobile")
|
||||
private String mobile;
|
||||
@JsonProperty("optionalMobile")
|
||||
private String optionalMobile;
|
||||
@JsonProperty("optionalIntlCode")
|
||||
private String optionalIntlCode;
|
||||
@JsonProperty("email")
|
||||
private String email;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程快递信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripExpressDelivery {
|
||||
@JsonProperty("type")
|
||||
private String type;
|
||||
}
|
||||
}
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单新订响应
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCreateOrderResponse {
|
||||
|
||||
/**
|
||||
* 返回头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripResponseHeader header;
|
||||
|
||||
/**
|
||||
* 处理结果返回码
|
||||
*/
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 处理结果返回信息
|
||||
*/
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage;
|
||||
|
||||
/**
|
||||
* 返回体
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private CtripResponseBody body;
|
||||
|
||||
/**
|
||||
* 携程返回头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseHeader {
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime;
|
||||
@JsonProperty("accountId")
|
||||
private String accountId;
|
||||
@JsonProperty("sign")
|
||||
private String sign;
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName;
|
||||
@JsonProperty("version")
|
||||
private String version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseBody {
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId;
|
||||
@JsonProperty("supplierOrderId")
|
||||
private String supplierOrderId;
|
||||
@JsonProperty("supplierConfirmType")
|
||||
private Integer supplierConfirmType;
|
||||
@JsonProperty("voucherSender")
|
||||
private Integer voucherSender;
|
||||
@JsonProperty("vouchers")
|
||||
private List<CtripVoucher> vouchers;
|
||||
@JsonProperty("orderExtendMessage")
|
||||
private String orderExtendMessage;
|
||||
@JsonProperty("items")
|
||||
private List<CtripResponseOrderItem> items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程凭证
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripVoucher {
|
||||
@JsonProperty("voucherType")
|
||||
private Integer voucherType;
|
||||
@JsonProperty("voucherContent")
|
||||
private String voucherContent;
|
||||
@JsonProperty("voucherUrl")
|
||||
private String voucherUrl;
|
||||
@JsonProperty("locale")
|
||||
private String locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回订单项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseOrderItem {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId;
|
||||
@JsonProperty("supplierItemId")
|
||||
private String supplierItemId;
|
||||
@JsonProperty("status")
|
||||
private Integer status;
|
||||
@JsonProperty("message")
|
||||
private String message;
|
||||
}
|
||||
}
|
||||
+3
@@ -16,4 +16,7 @@ public class ChartStatistics {
|
||||
|
||||
@Schema(description = "收入构成")
|
||||
private List<IncomeDataVO> incomeBreakdown;
|
||||
|
||||
@Schema(description = "二维码订单数量")
|
||||
private List<QrcodeOrderDataVO> qrcodeOrderCount;
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
@Schema(description = "首页统计数据VO")
|
||||
public class DashboardStatisticsVO {
|
||||
@Schema(description = "订单统计")
|
||||
private OrderStatistics orderStats;
|
||||
private OrderStatisticsVO orderStats;
|
||||
|
||||
@Schema(description = "图表统计")
|
||||
private ChartStatistics chartStats;
|
||||
|
||||
+16
-1
@@ -7,7 +7,7 @@ import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Schema(description = "订单统计")
|
||||
public class OrderStatistics {
|
||||
public class OrderStatisticsVO {
|
||||
@Schema(description = "总订单数")
|
||||
private Long totalOrders;
|
||||
|
||||
@@ -20,6 +20,21 @@ public class OrderStatistics {
|
||||
@Schema(description = "完成率")
|
||||
private BigDecimal completionRate;
|
||||
|
||||
@Schema(description = "退款订单数")
|
||||
private Long refundedOrders;
|
||||
|
||||
@Schema(description = "总完成订单数")
|
||||
private Long completedOrders;
|
||||
|
||||
@Schema(description = "总收款订单数")
|
||||
private Long totalPaidOrders;
|
||||
|
||||
@Schema(description = "今日收款订单数")
|
||||
private Long todayPaidOrders;
|
||||
|
||||
@Schema(description = "今日退款订单数")
|
||||
private Long todayRefundedOrders;
|
||||
|
||||
@Schema(description = "订单总金额(分)")
|
||||
private Long totalAmount;
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.central.order.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(description = "二维码订单数据")
|
||||
public class QrcodeOrderDataVO {
|
||||
@Schema(description = "二维码名称")
|
||||
private String qrcodeName;
|
||||
|
||||
@Schema(description = "二维码ID")
|
||||
private String qrcodeId;
|
||||
|
||||
@Schema(description = "订单数量")
|
||||
private Long orderCount;
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.central.order.entity.Coupon;
|
||||
import com.central.common.model.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 优惠券服务接口
|
||||
*/
|
||||
public interface ICouponService extends IService<Coupon> {
|
||||
|
||||
/**
|
||||
* 分页查询优惠券列表
|
||||
*/
|
||||
IPage<Coupon> getCouponPage(Page<Coupon> page, Coupon coupon);
|
||||
|
||||
/**
|
||||
* 查询优惠券列表(统一风格)
|
||||
*/
|
||||
PageResult<Coupon> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 创建优惠券
|
||||
*/
|
||||
boolean createCoupon(Coupon coupon);
|
||||
|
||||
/**
|
||||
* 更新优惠券
|
||||
*/
|
||||
boolean updateCoupon(Coupon coupon);
|
||||
|
||||
/**
|
||||
* 删除优惠券
|
||||
*/
|
||||
boolean deleteCoupon(Long id);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户优惠券
|
||||
*/
|
||||
List<Coupon> getCouponsByUserPhone(String userPhone);
|
||||
|
||||
/**
|
||||
* 根据手机号查询可用优惠券
|
||||
*/
|
||||
List<Coupon> getAvailableCouponsByUserPhone(String userPhone);
|
||||
|
||||
/**
|
||||
* 使用优惠券
|
||||
*/
|
||||
boolean useCoupon(Long couponId, String orderNo);
|
||||
|
||||
/**
|
||||
* 根据携程优惠券ID创建优惠券(携程接口调用)
|
||||
*/
|
||||
boolean createCouponFromCtrip(String ctripCouponId, String userPhone, String couponName,
|
||||
Integer couponType, java.math.BigDecimal amount,
|
||||
java.math.BigDecimal minAmount, Integer discountRate,
|
||||
java.util.Date validStartTime,
|
||||
java.util.Date validEndTime);
|
||||
|
||||
/**
|
||||
* 批量更新过期优惠券状态
|
||||
*/
|
||||
void updateExpiredCoupons();
|
||||
|
||||
/**
|
||||
* 核销携程优惠券
|
||||
*/
|
||||
boolean verifyCtripCoupon(String ctripCouponId, String orderNo);
|
||||
|
||||
/**
|
||||
* 校验手机号+携程券ID是否已存在
|
||||
*/
|
||||
boolean existsByUserPhoneAndCtripCouponId(String userPhone, String ctripCouponId);
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.central.order.service;
|
||||
|
||||
/**
|
||||
* 携程API服务接口
|
||||
*/
|
||||
public interface ICtripApiService {
|
||||
|
||||
/**
|
||||
* 核销携程优惠券
|
||||
* @param ctripCouponId 携程优惠券ID
|
||||
* @param orderNo 订单号
|
||||
* @return 是否核销成功
|
||||
*/
|
||||
boolean verifyCoupon(String ctripCouponId, String orderNo);
|
||||
|
||||
/**
|
||||
* 查询携程优惠券状态
|
||||
* @param ctripCouponId 携程优惠券ID
|
||||
* @return 优惠券状态
|
||||
*/
|
||||
String getCouponStatus(String ctripCouponId);
|
||||
}
|
||||
+9
-2
@@ -1,13 +1,20 @@
|
||||
package com.central.order.service;
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.order.model.vo.DashboardStatisticsVO;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.model.Order;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IDashboardService {
|
||||
/**
|
||||
* 获取首页统计数据
|
||||
* @param params 筛选参数
|
||||
*/
|
||||
DashboardStatisticsVO getDashboardStatistics(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取首页订单列表
|
||||
*/
|
||||
PageResult<Order> getDashboardOrders(Map<String, Object> params);
|
||||
}
|
||||
|
||||
+7
@@ -106,5 +106,12 @@ public interface IOrderFileService extends ISuperService<OrderFile> {
|
||||
* @return 订单文件资源
|
||||
*/
|
||||
OrderFile getOrderFileByFilePath(String filePath);
|
||||
|
||||
/**
|
||||
* 批量根据订单号查询订单文件资源
|
||||
* @param orderNos 订单号列表
|
||||
* @return 订单号到文件列表的映射
|
||||
*/
|
||||
Map<String, List<OrderFile>> getOrderFilesByOrderNos(List<String> orderNos);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,14 @@ public interface IOrderService extends ISuperService<Order> {
|
||||
|
||||
Integer getOrderRankingByOrderId(Long orderId,Long tourismId);
|
||||
|
||||
/**
|
||||
* 根据订单ID和设备SN获取订单排队位置
|
||||
* @param orderId 订单ID
|
||||
* @param deviceSn 设备SN
|
||||
* @return 排队位置
|
||||
*/
|
||||
Integer getOrderRankingByOrderIdAndDevice(Long orderId, String deviceSn);
|
||||
|
||||
/**
|
||||
* 自动更新订单完成状态
|
||||
*/
|
||||
|
||||
@@ -76,5 +76,12 @@ public interface ITourismService extends ISuperService<Tourism> {
|
||||
* @return 更新结果
|
||||
*/
|
||||
Result updateTourismLocation(Long id, BigDecimal longitude, BigDecimal latitude);
|
||||
|
||||
/**
|
||||
* 批量根据ID查询景区信息
|
||||
* @param ids 景区ID集合
|
||||
* @return 景区ID到景区信息的映射
|
||||
*/
|
||||
Map<Long, Tourism> getTourismsByIds(java.util.Set<Long> ids);
|
||||
}
|
||||
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单租户分配服务
|
||||
* 实现10:1的分配策略:前10单分配给景区租户,第11单分配给平台租户
|
||||
*/
|
||||
public interface OrderTenantAllocationService {
|
||||
|
||||
/**
|
||||
* 根据二维码ID确定订单归属租户
|
||||
* @param qrCodeId 二维码ID
|
||||
* @param scenicTenantId 景区租户ID(来自二维码)
|
||||
* @return 租户ID
|
||||
*/
|
||||
String determineTenant(String qrCodeId, String scenicTenantId);
|
||||
|
||||
/**
|
||||
* 获取该二维码下的总订单计数
|
||||
* @param qrCodeId 二维码ID
|
||||
* @return 订单计数
|
||||
*/
|
||||
int getOrderCountByQrCode(String qrCodeId);
|
||||
|
||||
/**
|
||||
* 记录订单分配日志
|
||||
* @param qrCodeId 二维码ID
|
||||
*/
|
||||
void incrementOrderCount(String qrCodeId);
|
||||
|
||||
/**
|
||||
* 获取分配统计信息
|
||||
* @param qrCodeId 二维码ID
|
||||
* @return 统计信息
|
||||
*/
|
||||
Map<String, Object> getAllocationStatistics(String qrCodeId);
|
||||
|
||||
/**
|
||||
* 获取详细的分配诊断信息
|
||||
* @param qrCodeId 二维码ID
|
||||
* @return 诊断信息
|
||||
*/
|
||||
Map<String, Object> getDetailedDiagnostics(String qrCodeId);
|
||||
|
||||
/**
|
||||
* 验证分配逻辑
|
||||
* @param qrCodeId 二维码ID
|
||||
* @param expectedCount 期望的订单数量
|
||||
* @return 验证结果
|
||||
*/
|
||||
Map<String, Object> validateAllocationLogic(String qrCodeId, int expectedCount);
|
||||
}
|
||||
-233
@@ -1,233 +0,0 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.central.order.entity.Coupon;
|
||||
import com.central.order.mapper.CouponMapper;
|
||||
import com.central.order.service.ICouponService;
|
||||
import com.central.order.service.ICtripApiService;
|
||||
import com.central.common.model.PageResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 优惠券服务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> implements ICouponService {
|
||||
|
||||
@Autowired
|
||||
private ICtripApiService ctripApiService;
|
||||
|
||||
@Override
|
||||
public IPage<Coupon> getCouponPage(Page<Coupon> page, Coupon coupon) {
|
||||
return baseMapper.selectCouponPage(page, coupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Coupon> findList(Map<String, Object> params) {
|
||||
// 获取分页参数
|
||||
Integer page = Integer.parseInt(params.getOrDefault("page", "1").toString());
|
||||
Integer limit = Integer.parseInt(params.getOrDefault("limit", "10").toString());
|
||||
|
||||
// 构建查询条件
|
||||
Coupon queryCoupon = new Coupon();
|
||||
if (params.get("couponName") != null) {
|
||||
queryCoupon.setCouponName(params.get("couponName").toString());
|
||||
}
|
||||
if (params.get("couponType") != null) {
|
||||
queryCoupon.setCouponType(Integer.parseInt(params.get("couponType").toString()));
|
||||
}
|
||||
if (params.get("status") != null) {
|
||||
queryCoupon.setStatus(Integer.parseInt(params.get("status").toString()));
|
||||
}
|
||||
if (params.get("userPhone") != null) {
|
||||
queryCoupon.setUserPhone(params.get("userPhone").toString());
|
||||
}
|
||||
if (params.get("source") != null) {
|
||||
queryCoupon.setSource(Integer.parseInt(params.get("source").toString()));
|
||||
}
|
||||
if (params.get("ctripCouponId") != null) {
|
||||
queryCoupon.setCtripCouponId(params.get("ctripCouponId").toString());
|
||||
}
|
||||
|
||||
// 执行分页查询
|
||||
Page<Coupon> pageParam = new Page<>(page, limit);
|
||||
IPage<Coupon> pageResult = baseMapper.selectCouponPage(pageParam, queryCoupon);
|
||||
|
||||
// 构建返回结果
|
||||
return PageResult.<Coupon>builder()
|
||||
.count(pageResult.getTotal())
|
||||
.resp_code(0)
|
||||
.data(pageResult.getRecords())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean createCoupon(Coupon coupon) {
|
||||
// 生成优惠券编号
|
||||
if (!StringUtils.hasText(coupon.getCouponNo())) {
|
||||
coupon.setCouponNo(generateCouponNo());
|
||||
}
|
||||
|
||||
// 设置默认值
|
||||
if (coupon.getStatus() == null) {
|
||||
coupon.setStatus(0); // 未使用
|
||||
}
|
||||
if (coupon.getCreateTime() == null) {
|
||||
coupon.setCreateTime(new Date());
|
||||
}
|
||||
if (coupon.getUpdateTime() == null) {
|
||||
coupon.setUpdateTime(new Date());
|
||||
}
|
||||
|
||||
return save(coupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateCoupon(Coupon coupon) {
|
||||
coupon.setUpdateTime(new Date());
|
||||
return updateById(coupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteCoupon(Long id) {
|
||||
return removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Coupon> getCouponsByUserPhone(String userPhone) {
|
||||
return baseMapper.selectByUserPhone(userPhone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Coupon> getAvailableCouponsByUserPhone(String userPhone) {
|
||||
return baseMapper.selectAvailableByUserPhone(userPhone);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean useCoupon(Long couponId, String orderNo) {
|
||||
Coupon coupon = getById(couponId);
|
||||
if (coupon == null) {
|
||||
log.error("优惠券不存在,couponId: {}", couponId);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coupon.getStatus() != 0) {
|
||||
log.error("优惠券状态不正确,couponId: {}, status: {}", couponId, coupon.getStatus());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coupon.getValidEndTime().before(new Date())) {
|
||||
log.error("优惠券已过期,couponId: {}", couponId);
|
||||
return false;
|
||||
}
|
||||
|
||||
return baseMapper.updateCouponUsed(couponId, orderNo) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean createCouponFromCtrip(String ctripCouponId, String userPhone, String couponName,
|
||||
Integer couponType, java.math.BigDecimal amount,
|
||||
java.math.BigDecimal minAmount, Integer discountRate,
|
||||
java.util.Date validStartTime,
|
||||
java.util.Date validEndTime) {
|
||||
|
||||
// 检查是否已存在该携程优惠券
|
||||
Coupon existingCoupon = baseMapper.selectByCtripCouponId(ctripCouponId);
|
||||
if (existingCoupon != null) {
|
||||
log.warn("携程优惠券已存在,ctripCouponId: {}", ctripCouponId);
|
||||
return true; // 已存在也算成功
|
||||
}
|
||||
|
||||
Coupon coupon = new Coupon();
|
||||
coupon.setCouponNo(generateCouponNo());
|
||||
coupon.setCouponName(couponName);
|
||||
coupon.setCouponType(couponType);
|
||||
coupon.setAmount(amount);
|
||||
coupon.setMinAmount(minAmount);
|
||||
coupon.setDiscountRate(discountRate);
|
||||
coupon.setStatus(0); // 未使用
|
||||
coupon.setUserPhone(userPhone);
|
||||
coupon.setSource(1); // 来源:携程
|
||||
coupon.setCtripCouponId(ctripCouponId);
|
||||
coupon.setValidStartTime(validStartTime);
|
||||
coupon.setValidEndTime(validEndTime);
|
||||
coupon.setCreateTime(new Date());
|
||||
coupon.setUpdateTime(new Date());
|
||||
coupon.setCreateBy("ctrip");
|
||||
coupon.setUpdateBy("ctrip");
|
||||
|
||||
return save(coupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateExpiredCoupons() {
|
||||
int count = baseMapper.updateExpiredCoupons();
|
||||
log.info("批量更新过期优惠券完成,更新数量: {}", count);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean verifyCtripCoupon(String ctripCouponId, String orderNo) {
|
||||
Coupon coupon = baseMapper.selectByCtripCouponId(ctripCouponId);
|
||||
if (coupon == null) {
|
||||
log.error("携程优惠券不存在,ctripCouponId: {}", ctripCouponId);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coupon.getStatus() != 0) {
|
||||
log.error("携程优惠券状态不正确,ctripCouponId: {}, status: {}", ctripCouponId, coupon.getStatus());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coupon.getValidEndTime().before(new Date())) {
|
||||
log.error("携程优惠券已过期,ctripCouponId: {}", ctripCouponId);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 调用携程核销接口
|
||||
boolean ctripVerifyResult = ctripApiService.verifyCoupon(ctripCouponId, orderNo);
|
||||
if (!ctripVerifyResult) {
|
||||
log.error("携程核销失败,ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 更新本地优惠券状态
|
||||
return baseMapper.updateCouponUsed(coupon.getId(), orderNo) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsByUserPhoneAndCtripCouponId(String userPhone, String ctripCouponId) {
|
||||
return lambdaQuery()
|
||||
.eq(Coupon::getUserPhone, userPhone)
|
||||
.eq(Coupon::getCtripCouponId, ctripCouponId)
|
||||
.count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成优惠券编号
|
||||
*/
|
||||
private String generateCouponNo() {
|
||||
return "CP" + System.currentTimeMillis() + UUID.randomUUID().toString().substring(0, 8).toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.central.order.service.ICtripApiService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 携程API服务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CtripApiServiceImpl implements ICtripApiService {
|
||||
|
||||
@Override
|
||||
public boolean verifyCoupon(String ctripCouponId, String orderNo) {
|
||||
// TODO: 实现具体的携程API调用逻辑
|
||||
// 这里需要根据携程的API文档实现具体的调用
|
||||
log.info("调用携程核销接口,ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo);
|
||||
|
||||
// 模拟API调用
|
||||
try {
|
||||
// 这里应该调用携程的核销API
|
||||
// 例如:HttpClient调用携程的核销接口
|
||||
|
||||
// 暂时返回true,实际需要根据API调用结果返回
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("携程核销接口调用失败", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCouponStatus(String ctripCouponId) {
|
||||
// TODO: 实现具体的携程API调用逻辑
|
||||
// 这里需要根据携程的API文档实现具体的调用
|
||||
log.info("调用携程查询优惠券状态接口,ctripCouponId: {}", ctripCouponId);
|
||||
|
||||
// 模拟API调用
|
||||
try {
|
||||
// 这里应该调用携程的查询API
|
||||
// 例如:HttpClient调用携程的查询接口
|
||||
|
||||
// 暂时返回"VALID",实际需要根据API调用结果返回
|
||||
return "VALID";
|
||||
} catch (Exception e) {
|
||||
log.error("携程查询优惠券状态接口调用失败", e);
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
}
|
||||
+92
-25
@@ -1,14 +1,18 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.mapper.DashboardMapper;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.vo.*;
|
||||
import com.central.order.service.IDashboardService;
|
||||
import com.central.order.service.IOrderService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -18,6 +22,7 @@ import java.util.Map;
|
||||
public class DashboardServiceImpl implements IDashboardService {
|
||||
|
||||
private final DashboardMapper dashboardMapper;
|
||||
private final IOrderService orderService;
|
||||
|
||||
@Override
|
||||
public DashboardStatisticsVO getDashboardStatistics(Map<String, Object> params) {
|
||||
@@ -40,11 +45,27 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
return statistics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Order> getDashboardOrders(Map<String, Object> params) {
|
||||
try {
|
||||
// 获取订单列表
|
||||
PageResult<Order> result = orderService.findList(params);
|
||||
|
||||
// 添加调试日志
|
||||
log.info("获取仪表盘订单列表 - 参数: {}, 结果数量: {}", params, result.getCount());
|
||||
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("获取仪表盘订单列表失败", e);
|
||||
return new PageResult<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单统计(包含对账数据)
|
||||
* 获取订单统计
|
||||
*/
|
||||
private OrderStatistics getOrderStatistics(Map<String, Object> params) {
|
||||
OrderStatistics stats = new OrderStatistics();
|
||||
private OrderStatisticsVO getOrderStatistics(Map<String, Object> params) {
|
||||
OrderStatisticsVO stats = new OrderStatisticsVO();
|
||||
|
||||
// 获取订单总数
|
||||
stats.setTotalOrders(dashboardMapper.getTotalOrders(params));
|
||||
@@ -69,17 +90,42 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
.multiply(new BigDecimal(100));
|
||||
stats.setCompletionRate(completionRate);
|
||||
}
|
||||
// 设置总完成订单数
|
||||
stats.setCompletedOrders(completedOrders);
|
||||
|
||||
// 获取对账相关数据 - 使用 orders 表的数据
|
||||
// 获取总收款订单数量
|
||||
Long totalPaidOrders = dashboardMapper.getTotalPaidOrders(params);
|
||||
stats.setTotalPaidOrders(totalPaidOrders);
|
||||
|
||||
// 添加调试日志
|
||||
log.info("总收款订单数统计 - 参数: {}, 结果: {}", params, totalPaidOrders);
|
||||
log.info("时间范围详情 - startTime: {}, endTime: {}", params.get("startTime"), params.get("endTime"));
|
||||
|
||||
// 获取今日收款订单数量
|
||||
Long todayPaidOrders = dashboardMapper.getTodayPaidOrders(params);
|
||||
stats.setTodayPaidOrders(todayPaidOrders);
|
||||
|
||||
// 添加调试日志
|
||||
log.info("今日收款订单数统计 - 参数: {}, 结果: {}", params, todayPaidOrders);
|
||||
|
||||
// 获取退款订单数量
|
||||
Long refundedOrders = dashboardMapper.getRefundedOrders(params);
|
||||
stats.setRefundedOrders(refundedOrders);
|
||||
|
||||
// 获取今日退款订单数量
|
||||
Long todayRefundedOrders = dashboardMapper.getTodayRefundedOrders(params);
|
||||
stats.setTodayRefundedOrders(todayRefundedOrders);
|
||||
|
||||
// 获取订单总金额
|
||||
Long totalAmount = dashboardMapper.getTotalAmount(params);
|
||||
Long refundAmount = dashboardMapper.getRefundAmount(params);
|
||||
|
||||
// 设置基础数据
|
||||
stats.setTotalAmount(totalAmount);
|
||||
|
||||
// 获取退款金额
|
||||
Long refundAmount = dashboardMapper.getRefundAmount(params);
|
||||
stats.setRefundAmount(refundAmount);
|
||||
|
||||
// 计算净收入 = 总金额 - 退款金额
|
||||
Long netIncome = (totalAmount != null ? totalAmount : 0) - (refundAmount != null ? refundAmount : 0);
|
||||
|
||||
// 计算净收入
|
||||
Long netIncome = (totalAmount != null ? totalAmount : 0L) - (refundAmount != null ? refundAmount : 0L);
|
||||
stats.setNetIncome(netIncome);
|
||||
|
||||
return stats;
|
||||
@@ -89,18 +135,41 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
* 获取图表统计
|
||||
*/
|
||||
private ChartStatistics getChartStatistics(Map<String, Object> params) {
|
||||
ChartStatistics stats = new ChartStatistics();
|
||||
|
||||
// 获取订单趋势(最近7天)
|
||||
stats.setOrderTrend(dashboardMapper.getOrderTrend(params));
|
||||
|
||||
// 获取订单状态分布
|
||||
stats.setOrderDistribution(dashboardMapper.getOrderDistribution(params));
|
||||
|
||||
// 获取收入构成
|
||||
stats.setIncomeBreakdown(dashboardMapper.getIncomeBreakdown(params));
|
||||
|
||||
return stats;
|
||||
ChartStatistics chartStats = new ChartStatistics();
|
||||
|
||||
try {
|
||||
// 获取订单趋势数据
|
||||
List<TrendDataVO> orderTrend = dashboardMapper.getOrderTrend(params);
|
||||
chartStats.setOrderTrend(orderTrend);
|
||||
|
||||
// 获取订单状态分布数据
|
||||
List<DistributionDataVO> orderDistribution = dashboardMapper.getOrderDistribution(params);
|
||||
chartStats.setOrderDistribution(orderDistribution);
|
||||
|
||||
// 获取收入构成数据
|
||||
List<IncomeDataVO> incomeBreakdown = dashboardMapper.getIncomeBreakdown(params);
|
||||
chartStats.setIncomeBreakdown(incomeBreakdown);
|
||||
|
||||
// 添加收入统计调试日志
|
||||
log.info("收入构成统计 - 参数: {}, 结果数量: {}", params, incomeBreakdown.size());
|
||||
for (IncomeDataVO item : incomeBreakdown) {
|
||||
log.info("收入构成 - 类型: {}, 金额: {}", item.getType(), item.getValue());
|
||||
}
|
||||
|
||||
// 获取二维码订单数量数据
|
||||
List<QrcodeOrderDataVO> qrcodeOrderCount = dashboardMapper.getQrcodeOrderCount(params);
|
||||
chartStats.setQrcodeOrderCount(qrcodeOrderCount);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取图表统计数据失败", e);
|
||||
// 设置空数据避免前端报错
|
||||
chartStats.setOrderTrend(new ArrayList<>());
|
||||
chartStats.setOrderDistribution(new ArrayList<>());
|
||||
chartStats.setIncomeBreakdown(new ArrayList<>());
|
||||
chartStats.setQrcodeOrderCount(new ArrayList<>());
|
||||
}
|
||||
|
||||
return chartStats;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,9 +183,7 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
|
||||
// 获取二维码列表
|
||||
options.setQrcodeList(dashboardMapper.getQrcodeOptions(params));
|
||||
|
||||
// 获取设备列表
|
||||
options.setDeviceList(dashboardMapper.getDeviceOptions(params));
|
||||
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
+25
@@ -12,8 +12,10 @@ import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Order information
|
||||
@@ -133,4 +135,27 @@ public class OrderFileServiceImpl extends SuperServiceImpl<OrderFileMapper, Orde
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<OrderFile>> getOrderFilesByOrderNos(List<String> orderNos) {
|
||||
try {
|
||||
log.debug("批量查询订单文件: orderNos={}", orderNos);
|
||||
if (orderNos == null || orderNos.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
// 查询所有文件
|
||||
List<OrderFile> allFiles = baseMapper.selectList(
|
||||
new QueryWrapper<OrderFile>()
|
||||
.in("order_no", orderNos)
|
||||
);
|
||||
|
||||
// 按订单号分组
|
||||
return allFiles.stream()
|
||||
.collect(Collectors.groupingBy(OrderFile::getOrderNo));
|
||||
} catch (Exception e) {
|
||||
log.error("批量查询订单文件失败: orderNos={}", orderNos, e);
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-4
@@ -86,8 +86,10 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
*/
|
||||
@Override
|
||||
public PageResult<Order> findList(Map<String, Object> params){
|
||||
log.info("查询订单列表,参数: {}", params);
|
||||
Page<Order> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||
List<Order> list = baseMapper.findList(page, params);
|
||||
log.info("查询结果数量: {}", list.size());
|
||||
for (Order order : list){
|
||||
SysUser user = userCenterService.findUserById(order.getUserId());
|
||||
if(Objects.nonNull(user)){
|
||||
@@ -128,10 +130,10 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
// 检查并处理订单超时逻辑,5分钟超时后自动取消
|
||||
@Override
|
||||
public void checkAndHandleOrderTimeout() {
|
||||
log.info("开始检查订单超时情况");
|
||||
log.debug("开始检查订单超时情况");
|
||||
|
||||
List<Order> orders = baseMapper.getOrdersByStatus(OrderStatus.UNPAID.getId());
|
||||
log.info("查询到 {} 个待支付订单", orders.size());
|
||||
log.debug("查询到 {} 个待支付订单", orders.size());
|
||||
|
||||
long currentTime = new Date().getTime();
|
||||
int timeoutCount = 0;
|
||||
@@ -140,7 +142,7 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
long elapsedTime = currentTime - order.getCreateTime().getTime();
|
||||
long elapsedMinutes = TimeUnit.MILLISECONDS.toMinutes(elapsedTime);
|
||||
|
||||
log.info("订单检查: orderNo={}, createTime={}, elapsedMinutes={}, userId={}, tourismId={}",
|
||||
log.debug("订单检查: orderNo={}, createTime={}, elapsedMinutes={}, userId={}, tourismId={}",
|
||||
order.getOrderNo(),
|
||||
order.getCreateTime(),
|
||||
elapsedMinutes,
|
||||
@@ -154,7 +156,7 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
}
|
||||
}
|
||||
|
||||
log.info("订单超时检查完成: 总订单数={}, 超时取消数={}", orders.size(), timeoutCount);
|
||||
log.debug("订单超时检查完成: 总订单数={}, 超时取消数={}", orders.size(), timeoutCount);
|
||||
}
|
||||
|
||||
// 获取所有处于排队状态的订单,用于后续按顺序处理
|
||||
@@ -299,6 +301,19 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getOrderRankingByOrderIdAndDevice(Long orderId, String deviceSn) {
|
||||
List<OrderRanking> result = orderMapper.getOrderRankingByDevice(deviceSn);
|
||||
if (!result.isEmpty()) {
|
||||
for (OrderRanking order : result) {
|
||||
if (order.getId().equals(orderId)) {
|
||||
return order.getRanking();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autoUpdateOrderStatusToComplete() {
|
||||
List<Order> orders = baseMapper.getOrdersByStatus(OrderStatus.DOING.getId());
|
||||
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.central.order.config.TenantAllocationConfig;
|
||||
import com.central.order.mapper.OrderTenantAllocationMapper;
|
||||
import com.central.order.model.QrCode;
|
||||
import com.central.order.service.IQrCodeService;
|
||||
import com.central.order.service.OrderTenantAllocationService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单租户分配服务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrderTenantAllocationServiceImpl implements OrderTenantAllocationService {
|
||||
|
||||
@Autowired
|
||||
private TenantAllocationConfig config;
|
||||
|
||||
@Autowired
|
||||
private OrderTenantAllocationMapper orderTenantAllocationMapper;
|
||||
|
||||
@Autowired
|
||||
private IQrCodeService qrCodeService;
|
||||
|
||||
// 分配比例:10单景区 + 1单平台
|
||||
private int allocationRatio = 10;
|
||||
private int cycleSize = 11; // allocationRatio + 1
|
||||
|
||||
@Override
|
||||
public String determineTenant(String qrCodeId, String scenicTenantId) {
|
||||
// 检查是否启用租户分配功能
|
||||
if (!config.isEnabled()) {
|
||||
log.debug("租户分配功能未启用,使用景区租户ID: {}", scenicTenantId);
|
||||
return scenicTenantId;
|
||||
}
|
||||
|
||||
// 检查是否强制使用平台租户(用于测试)
|
||||
if (config.isForcePlatformTenant()) {
|
||||
log.info("强制使用平台租户 - qrCodeId: {}", qrCodeId);
|
||||
return config.getPlatformTenantId();
|
||||
}
|
||||
|
||||
// 更新分配比例
|
||||
allocationRatio = config.getAllocationRatio();
|
||||
cycleSize = allocationRatio + 1;
|
||||
|
||||
int orderCount = getOrderCountByQrCode(qrCodeId);
|
||||
int remainder = orderCount % cycleSize; // 当前周期内的位置
|
||||
|
||||
if (remainder == allocationRatio) { // 第11单(索引10)
|
||||
String platformTenantId = getPlatformTenantId(qrCodeId);
|
||||
log.info("订单分配给平台租户 - qrCodeId: {}, orderCount: {}, tenantId: {}",
|
||||
qrCodeId, orderCount, platformTenantId);
|
||||
return platformTenantId;
|
||||
} else {
|
||||
log.info("订单分配给景区租户 - qrCodeId: {}, orderCount: {}, tenantId: {}",
|
||||
qrCodeId, orderCount, scenicTenantId);
|
||||
return scenicTenantId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrderCountByQrCode(String qrCodeId) {
|
||||
try {
|
||||
int count = orderTenantAllocationMapper.getOrderCountByQrCode(qrCodeId);
|
||||
log.debug("获取二维码订单计数 - qrCodeId: {}, count: {}", qrCodeId, count);
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
log.error("查询二维码订单计数失败 - qrCodeId: {}", qrCodeId, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementOrderCount(String qrCodeId) {
|
||||
// 订单计数通过实际创建订单时自动增加
|
||||
// 实际计数通过查询orders表获取,这里主要用于日志记录
|
||||
log.info("订单计数已更新 - qrCodeId: {}, 当前订单总数: {}", qrCodeId, getOrderCountByQrCode(qrCodeId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAllocationStatistics(String qrCodeId) {
|
||||
Map<String, Object> statistics = new HashMap<>();
|
||||
|
||||
try {
|
||||
// 更新分配比例
|
||||
allocationRatio = config.getAllocationRatio();
|
||||
cycleSize = allocationRatio + 1;
|
||||
|
||||
// 获取景区租户ID - 需要查询二维码表
|
||||
String scenicTenantId = getScenicTenantIdFromQrCode(qrCodeId);
|
||||
String platformTenantId = config.getPlatformTenantId();
|
||||
|
||||
// 从数据库查询统计信息
|
||||
Map<String, Object> dbStatistics = orderTenantAllocationMapper.getOrderStatisticsByQrCode(
|
||||
qrCodeId, scenicTenantId, platformTenantId);
|
||||
|
||||
// 获取最近的订单信息
|
||||
java.util.List<java.util.Map<String, Object>> recentOrders =
|
||||
orderTenantAllocationMapper.getRecentOrdersByQrCode(qrCodeId, 10);
|
||||
|
||||
// 组装统计信息
|
||||
statistics.put("qrCodeId", qrCodeId);
|
||||
statistics.put("allocationRatio", allocationRatio);
|
||||
statistics.put("cycleSize", cycleSize);
|
||||
statistics.put("enabled", config.isEnabled());
|
||||
statistics.put("platformTenantId", platformTenantId);
|
||||
statistics.put("scenicTenantId", scenicTenantId);
|
||||
|
||||
// 数据库统计信息
|
||||
if (dbStatistics != null) {
|
||||
statistics.put("totalOrders", dbStatistics.get("totalOrders"));
|
||||
statistics.put("scenicOrders", dbStatistics.get("scenicOrders"));
|
||||
statistics.put("platformOrders", dbStatistics.get("platformOrders"));
|
||||
|
||||
// 计算百分比
|
||||
Long totalOrders = (Long) dbStatistics.get("totalOrders");
|
||||
Long scenicOrders = (Long) dbStatistics.get("scenicOrders");
|
||||
Long platformOrders = (Long) dbStatistics.get("platformOrders");
|
||||
|
||||
if (totalOrders != null && totalOrders > 0) {
|
||||
statistics.put("scenicPercentage", (double) scenicOrders / totalOrders * 100);
|
||||
statistics.put("platformPercentage", (double) platformOrders / totalOrders * 100);
|
||||
} else {
|
||||
statistics.put("scenicPercentage", 0.0);
|
||||
statistics.put("platformPercentage", 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
// 最近订单信息
|
||||
statistics.put("recentOrders", recentOrders);
|
||||
|
||||
log.info("获取分配统计信息成功 - qrCodeId: {}, 总订单: {}, 景区订单: {}, 平台订单: {}",
|
||||
qrCodeId, statistics.get("totalOrders"), statistics.get("scenicOrders"), statistics.get("platformOrders"));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取分配统计信息失败 - qrCodeId: {}", qrCodeId, e);
|
||||
statistics.put("error", "查询失败:" + e.getMessage());
|
||||
}
|
||||
|
||||
return statistics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDetailedDiagnostics(String qrCodeId) {
|
||||
Map<String, Object> diagnostics = new HashMap<>();
|
||||
|
||||
try {
|
||||
// 获取景区租户ID - 从二维码表查询
|
||||
String scenicTenantId = getScenicTenantIdFromQrCode(qrCodeId);
|
||||
String platformTenantId = config.getPlatformTenantId();
|
||||
|
||||
// 查询各种统计数据
|
||||
int totalOrders = orderTenantAllocationMapper.getOrderCountByQrCode(qrCodeId);
|
||||
int scenicOrders = orderTenantAllocationMapper.getScenicOrderCount(qrCodeId, scenicTenantId);
|
||||
int platformOrders = orderTenantAllocationMapper.getPlatformOrderCount(qrCodeId, platformTenantId);
|
||||
|
||||
// 获取最近的订单详情
|
||||
java.util.List<java.util.Map<String, Object>> recentOrders =
|
||||
orderTenantAllocationMapper.getRecentOrdersByQrCode(qrCodeId, 20);
|
||||
|
||||
// 计算理论分配
|
||||
allocationRatio = config.getAllocationRatio();
|
||||
cycleSize = allocationRatio + 1;
|
||||
int expectedScenicOrders = 0;
|
||||
int expectedPlatformOrders = 0;
|
||||
|
||||
for (int i = 0; i < totalOrders; i++) {
|
||||
int remainder = i % cycleSize;
|
||||
if (remainder == allocationRatio) {
|
||||
expectedPlatformOrders++;
|
||||
} else {
|
||||
expectedScenicOrders++;
|
||||
}
|
||||
}
|
||||
|
||||
// 组装诊断信息
|
||||
diagnostics.put("qrCodeId", qrCodeId);
|
||||
diagnostics.put("scenicTenantId", scenicTenantId);
|
||||
diagnostics.put("platformTenantId", platformTenantId);
|
||||
diagnostics.put("allocationRatio", allocationRatio);
|
||||
diagnostics.put("cycleSize", cycleSize);
|
||||
diagnostics.put("enabled", config.isEnabled());
|
||||
|
||||
// 实际统计
|
||||
diagnostics.put("actualTotalOrders", totalOrders);
|
||||
diagnostics.put("actualScenicOrders", scenicOrders);
|
||||
diagnostics.put("actualPlatformOrders", platformOrders);
|
||||
|
||||
// 理论分配
|
||||
diagnostics.put("expectedScenicOrders", expectedScenicOrders);
|
||||
diagnostics.put("expectedPlatformOrders", expectedPlatformOrders);
|
||||
|
||||
// 差异分析
|
||||
diagnostics.put("scenicOrderDiff", scenicOrders - expectedScenicOrders);
|
||||
diagnostics.put("platformOrderDiff", platformOrders - expectedPlatformOrders);
|
||||
|
||||
// 百分比
|
||||
if (totalOrders > 0) {
|
||||
diagnostics.put("actualScenicPercentage", (double) scenicOrders / totalOrders * 100);
|
||||
diagnostics.put("actualPlatformPercentage", (double) platformOrders / totalOrders * 100);
|
||||
diagnostics.put("expectedScenicPercentage", (double) expectedScenicOrders / totalOrders * 100);
|
||||
diagnostics.put("expectedPlatformPercentage", (double) expectedPlatformOrders / totalOrders * 100);
|
||||
}
|
||||
|
||||
// 最近订单详情
|
||||
diagnostics.put("recentOrders", recentOrders);
|
||||
|
||||
// 分配状态
|
||||
int currentCount = getOrderCountByQrCode(qrCodeId);
|
||||
int remainder = currentCount % cycleSize;
|
||||
diagnostics.put("currentOrderCount", currentCount);
|
||||
diagnostics.put("currentRemainder", remainder);
|
||||
diagnostics.put("nextOrderShouldBePlatform", remainder == allocationRatio);
|
||||
|
||||
log.info("获取详细诊断信息成功 - qrCodeId: {}, 实际: 景区{}单/平台{}单, 理论: 景区{}单/平台{}单",
|
||||
qrCodeId, scenicOrders, platformOrders, expectedScenicOrders, expectedPlatformOrders);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取详细诊断信息失败 - qrCodeId: {}", qrCodeId, e);
|
||||
diagnostics.put("error", "查询失败:" + e.getMessage());
|
||||
}
|
||||
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> validateAllocationLogic(String qrCodeId, int expectedCount) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
// 更新分配比例
|
||||
allocationRatio = config.getAllocationRatio();
|
||||
cycleSize = allocationRatio + 1;
|
||||
|
||||
int scenicCount = 0;
|
||||
int platformCount = 0;
|
||||
|
||||
// 模拟验证分配逻辑
|
||||
for (int i = 0; i < expectedCount; i++) {
|
||||
int remainder = i % cycleSize;
|
||||
if (remainder == allocationRatio) {
|
||||
platformCount++;
|
||||
} else {
|
||||
scenicCount++;
|
||||
}
|
||||
}
|
||||
|
||||
result.put("expectedCount", expectedCount);
|
||||
result.put("scenicCount", scenicCount);
|
||||
result.put("platformCount", platformCount);
|
||||
result.put("scenicPercentage", (double) scenicCount / expectedCount * 100);
|
||||
result.put("platformPercentage", (double) platformCount / expectedCount * 100);
|
||||
result.put("allocationRatio", allocationRatio + ":1");
|
||||
result.put("enabled", config.isEnabled());
|
||||
result.put("platformTenantId", config.getPlatformTenantId());
|
||||
|
||||
log.info("分配逻辑验证完成 - 二维码: {}, 总订单: {}, 景区订单: {}, 平台订单: {}, 景区占比: {}%, 平台占比: {}%",
|
||||
qrCodeId, expectedCount, scenicCount, platformCount,
|
||||
result.get("scenicPercentage"), result.get("platformPercentage"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取景区租户ID
|
||||
*/
|
||||
private String getScenicTenantId(String qrCodeId) {
|
||||
// 这里应该查询二维码表获取租户ID
|
||||
// 但是由于在订单创建时已经获取了二维码信息,所以直接传入景区租户ID
|
||||
// 这个方法主要用于测试和诊断,实际使用时应该传入正确的景区租户ID
|
||||
log.warn("getScenicTenantId方法被调用,但应该直接使用传入的scenicTenantId参数");
|
||||
return qrCodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从二维码表获取景区租户ID
|
||||
*/
|
||||
private String getScenicTenantIdFromQrCode(String qrCodeId) {
|
||||
try {
|
||||
QrCode qrCode = qrCodeService.getByCodeId(qrCodeId);
|
||||
if (qrCode != null && qrCode.getTenantId() != null) {
|
||||
log.debug("从二维码表获取景区租户ID - qrCodeId: {}, tenantId: {}", qrCodeId, qrCode.getTenantId());
|
||||
return qrCode.getTenantId();
|
||||
} else {
|
||||
log.warn("二维码不存在或租户ID为空 - qrCodeId: {}", qrCodeId);
|
||||
return qrCodeId; // 降级处理
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("查询二维码租户ID失败 - qrCodeId: {}", qrCodeId, e);
|
||||
return qrCodeId; // 降级处理
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平台租户ID
|
||||
*/
|
||||
private String getPlatformTenantId(String qrCodeId) {
|
||||
// 使用配置中的平台租户ID
|
||||
return config.getPlatformTenantId();
|
||||
}
|
||||
}
|
||||
+2
@@ -30,8 +30,10 @@ public class QrCodeServiceImpl extends SuperServiceImpl<QrCodeMapper, QrCode> im
|
||||
*/
|
||||
@Override
|
||||
public PageResult<QrCode> findList(Map<String, Object> params){
|
||||
log.info("查询二维码列表,参数: {}", params);
|
||||
Page<QrCode> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||
List<QrCode> list = baseMapper.findList(page, params);
|
||||
log.info("查询结果数量: {}", list.size());
|
||||
return PageResult.<QrCode>builder().data(list).resp_code(0).count(page.getTotal()).build();
|
||||
}
|
||||
|
||||
|
||||
+25
@@ -17,8 +17,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 景区信息服务实现类
|
||||
@@ -172,4 +174,27 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Tourism> getTourismsByIds(java.util.Set<Long> ids) {
|
||||
try {
|
||||
log.debug("批量查询景区信息: ids={}", ids);
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
// 查询所有景区
|
||||
List<Tourism> tourisms = baseMapper.selectList(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<Tourism>()
|
||||
.in("id", ids)
|
||||
);
|
||||
|
||||
// 转换为Map
|
||||
return tourisms.stream()
|
||||
.collect(Collectors.toMap(Tourism::getId, tourism -> tourism));
|
||||
} catch (Exception e) {
|
||||
log.error("批量查询景区信息失败: ids={}", ids, e);
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package com.central.order.task;
|
||||
|
||||
import com.central.order.service.ICouponService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 优惠券过期定时任务
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CouponExpirationTask {
|
||||
|
||||
@Autowired
|
||||
private ICouponService couponService;
|
||||
|
||||
/**
|
||||
* 每天凌晨2点执行,批量更新过期优惠券状态
|
||||
*/
|
||||
@Scheduled(cron = "0 0 2 * * ?")
|
||||
public void updateExpiredCoupons() {
|
||||
log.info("开始执行优惠券过期状态更新任务");
|
||||
try {
|
||||
couponService.updateExpiredCoupons();
|
||||
log.info("优惠券过期状态更新任务执行完成");
|
||||
} catch (Exception e) {
|
||||
log.error("优惠券过期状态更新任务执行失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,315 +0,0 @@
|
||||
package com.central.order.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* 携程API解密工具类
|
||||
* 实现AES-128-CBC解密和MD5签名验证
|
||||
*
|
||||
* @author system
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CtripDecryptUtil {
|
||||
|
||||
@Value("${ctrip.aes.key:}")
|
||||
private String aesKey;
|
||||
|
||||
@Value("${ctrip.sign.key:}")
|
||||
private String signKey;
|
||||
|
||||
@Value("${ctrip.aes.iv:}")
|
||||
private String aesIv;
|
||||
|
||||
/**
|
||||
* AES-128-CBC解密(携程标准)
|
||||
*
|
||||
* @param encryptedData 携程自定义编码的加密数据
|
||||
* @return 解密后的原始数据
|
||||
*/
|
||||
public String decryptAES(String encryptedData) {
|
||||
try {
|
||||
if (encryptedData == null || encryptedData.isEmpty()) {
|
||||
log.warn("加密数据为空");
|
||||
return null;
|
||||
}
|
||||
|
||||
log.debug("开始解密携程数据,数据长度: {}", encryptedData.length());
|
||||
|
||||
// 使用携程自定义解码方法
|
||||
byte[] encryptedBytes = decodeBytes(encryptedData);
|
||||
log.debug("自定义解码成功,数据长度: {}", encryptedBytes.length);
|
||||
|
||||
// 检查数据长度
|
||||
if (encryptedBytes.length < 16) {
|
||||
log.error("加密数据长度不足,无法提取IV");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 提取IV(前16字节)
|
||||
byte[] iv = Arrays.copyOfRange(encryptedBytes, 0, 16);
|
||||
byte[] cipherData = Arrays.copyOfRange(encryptedBytes, 16, encryptedBytes.length);
|
||||
|
||||
log.debug("提取IV成功,IV长度: {}, 密文长度: {}", iv.length, cipherData.length);
|
||||
|
||||
// 使用UTF-8字节作为密钥和IV(携程标准)
|
||||
byte[] keyBytes = aesKey.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ivBytes = aesIv.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
log.debug("密钥长度: {}, IV长度: {}", keyBytes.length, ivBytes.length);
|
||||
|
||||
// 创建AES密钥
|
||||
SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES");
|
||||
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
|
||||
|
||||
// 创建解密器
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivSpec);
|
||||
|
||||
// 解密
|
||||
byte[] decryptedBytes = cipher.doFinal(cipherData);
|
||||
String decryptedData = new String(decryptedBytes, StandardCharsets.UTF_8);
|
||||
|
||||
log.info("AES解密成功,解密后数据长度: {}", decryptedData.length());
|
||||
|
||||
// 清理解密后的数据,移除可能的头部乱码
|
||||
String cleanedData = cleanDecryptedData(decryptedData);
|
||||
log.debug("清理后数据长度: {}", cleanedData.length());
|
||||
|
||||
return cleanedData;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("AES解密失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理解密后的数据,移除头部乱码
|
||||
*/
|
||||
private String cleanDecryptedData(String decryptedData) {
|
||||
if (decryptedData == null || decryptedData.isEmpty()) {
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
log.debug("原始解密数据前50个字符: {}",
|
||||
decryptedData.length() > 50 ? decryptedData.substring(0, 50) : decryptedData);
|
||||
|
||||
// 查找第一个 '{' 字符(JSON对象开始)
|
||||
int startIndex = decryptedData.indexOf('{');
|
||||
if (startIndex == -1) {
|
||||
// 如果没有找到 '{',查找第一个 '"' 字符
|
||||
startIndex = decryptedData.indexOf('"');
|
||||
}
|
||||
|
||||
if (startIndex == -1) {
|
||||
// 如果都没有找到,查找第一个字母或数字
|
||||
for (int i = 0; i < decryptedData.length(); i++) {
|
||||
char c = decryptedData.charAt(i);
|
||||
if (Character.isLetterOrDigit(c)) {
|
||||
startIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (startIndex > 0) {
|
||||
String cleanedData = decryptedData.substring(startIndex);
|
||||
log.debug("移除头部乱码,从位置 {} 开始,清理后数据前50个字符: {}",
|
||||
startIndex, cleanedData.length() > 50 ? cleanedData.substring(0, 50) : cleanedData);
|
||||
return cleanedData;
|
||||
}
|
||||
|
||||
log.debug("无需清理,数据前50个字符: {}",
|
||||
decryptedData.length() > 50 ? decryptedData.substring(0, 50) : decryptedData);
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程自定义解码方法(转字节数组)
|
||||
*
|
||||
* @param str 编码字符串
|
||||
* @return 字节数组
|
||||
*/
|
||||
private byte[] decodeBytes(String str) {
|
||||
byte[] bytes = new byte[str.length() / 2];
|
||||
for (int i = 0; i < str.length(); i += 2) {
|
||||
char c = str.charAt(i);
|
||||
bytes[i / 2] = (byte) ((c - 'a') << 4);
|
||||
c = str.charAt(i + 1);
|
||||
bytes[i / 2] += (c - 'a');
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程自定义编码方法(转16进制)
|
||||
*
|
||||
* @param bytes 字节数组
|
||||
* @return 编码字符串
|
||||
*/
|
||||
private String encodeBytes(byte[] bytes) {
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
strBuf.append((char) (((bytes[i] >> 4) & 0xF) + ((int) 'a')));
|
||||
strBuf.append((char) (((bytes[i]) & 0xF) + ((int) 'a')));
|
||||
}
|
||||
return strBuf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证MD5签名(携程标准)
|
||||
*
|
||||
* @param accountId 账号ID
|
||||
* @param serviceName 服务名称
|
||||
* @param requestTime 请求时间
|
||||
* @param body 请求体
|
||||
* @param version 版本
|
||||
* @param sign 签名
|
||||
* @return 验证结果
|
||||
*/
|
||||
public boolean verifySign(String accountId, String serviceName, String requestTime, String body, String version, String sign) {
|
||||
try {
|
||||
// 按携程标准拼接参数:accountId+serviceName+requestTime+body+version+signkey
|
||||
String signContent = accountId + serviceName + requestTime + body + version + signKey;
|
||||
log.debug("签名内容: {}", signContent);
|
||||
|
||||
// 计算MD5并转小写
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] md5Bytes = md.digest(signContent.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 转换为小写十六进制
|
||||
StringBuilder calculatedSign = new StringBuilder();
|
||||
for (byte b : md5Bytes) {
|
||||
calculatedSign.append(String.format("%02x", b & 0xff));
|
||||
}
|
||||
|
||||
String calculatedSignStr = calculatedSign.toString();
|
||||
log.debug("计算签名: {}, 接收签名: {}", calculatedSignStr, sign);
|
||||
|
||||
return calculatedSignStr.equalsIgnoreCase(sign);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("签名验证失败: {}", e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证MD5签名(兼容旧版本)
|
||||
*
|
||||
* @param params 请求参数
|
||||
* @param sign 签名
|
||||
* @return 验证结果
|
||||
*/
|
||||
public boolean verifySign(Map<String, String> params, String sign) {
|
||||
try {
|
||||
// 按字典序排序参数
|
||||
TreeMap<String, String> sortedParams = new TreeMap<>(params);
|
||||
|
||||
// 构建签名字符串
|
||||
StringBuilder signStr = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : sortedParams.entrySet()) {
|
||||
if (entry.getValue() != null && !entry.getValue().isEmpty()) {
|
||||
signStr.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
||||
}
|
||||
}
|
||||
|
||||
// 添加签名密钥
|
||||
signStr.append("key=").append(signKey);
|
||||
|
||||
String signContent = signStr.toString();
|
||||
log.debug("签名内容: {}", signContent);
|
||||
|
||||
// 计算MD5
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] md5Bytes = md.digest(signContent.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 转换为小写十六进制
|
||||
StringBuilder calculatedSign = new StringBuilder();
|
||||
for (byte b : md5Bytes) {
|
||||
calculatedSign.append(String.format("%02x", b & 0xff));
|
||||
}
|
||||
|
||||
String calculatedSignStr = calculatedSign.toString();
|
||||
log.debug("计算签名: {}, 接收签名: {}", calculatedSignStr, sign);
|
||||
|
||||
return calculatedSignStr.equalsIgnoreCase(sign);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("签名验证失败: {}", e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密携程请求体
|
||||
*
|
||||
* @param encryptedBody 加密的请求体
|
||||
* @return 解密后的JSON字符串
|
||||
*/
|
||||
public String decryptCtripBody(String encryptedBody) {
|
||||
if (encryptedBody == null || encryptedBody.isEmpty()) {
|
||||
log.warn("请求体为空");
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("开始解密携程请求体,数据长度: {}", encryptedBody.length());
|
||||
|
||||
// 尝试AES解密
|
||||
String decryptedData = decryptAES(encryptedBody);
|
||||
if (decryptedData != null) {
|
||||
log.info("携程请求体解密成功");
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
log.error("携程请求体解密失败");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查配置是否完整
|
||||
*/
|
||||
public boolean isConfigValid() {
|
||||
boolean valid = true;
|
||||
|
||||
if (aesKey == null || aesKey.isEmpty()) {
|
||||
log.error("携程AES密钥未配置");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (signKey == null || signKey.isEmpty()) {
|
||||
log.error("携程签名密钥未配置");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (aesIv == null || aesIv.isEmpty()) {
|
||||
log.error("携程AES IV未配置");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置信息(脱敏)
|
||||
*/
|
||||
public String getConfigInfo() {
|
||||
return String.format("AES密钥长度: %d, 签名密钥长度: %d, IV长度: %d",
|
||||
aesKey != null ? aesKey.length() : 0,
|
||||
signKey != null ? signKey.length() : 0,
|
||||
aesIv != null ? aesIv.length() : 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
# 租户分配配置示例
|
||||
tenant:
|
||||
allocation:
|
||||
# 是否启用租户分配功能
|
||||
enabled: false
|
||||
# 分配比例(景区:平台),默认10:1
|
||||
allocation-ratio: 10
|
||||
# 平台默认租户ID
|
||||
platform-tenant-id: "webApp"
|
||||
# 是否启用调试模式
|
||||
debug: false
|
||||
# 是否强制使用平台租户(用于测试)
|
||||
force-platform-tenant: false
|
||||
|
||||
# 配置说明:
|
||||
# 1. enabled: 控制是否启用智能租户分配功能
|
||||
# - true: 启用,订单会根据10:1比例分配给景区和平台租户
|
||||
# - false: 禁用,所有订单都分配给景区租户(原有逻辑)
|
||||
#
|
||||
# 2. allocation-ratio: 分配比例
|
||||
# - 10: 表示10单景区 + 1单平台
|
||||
# - 可以调整为其他比例,如5表示5单景区 + 1单平台
|
||||
#
|
||||
# 3. platform-tenant-id: 平台租户ID
|
||||
# - 默认值: "webApp"
|
||||
# - 分配给平台的订单会使用这个租户ID
|
||||
#
|
||||
# 4. debug: 调试模式
|
||||
# - true: 启用详细日志
|
||||
# - false: 正常日志级别
|
||||
#
|
||||
# 5. force-platform-tenant: 强制平台租户(测试用)
|
||||
# - true: 所有订单都分配给平台租户
|
||||
# - false: 正常分配逻辑
|
||||
@@ -9,7 +9,7 @@ spring:
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:/mapper/*Mapper.xml
|
||||
#实体扫描,多个package用逗号或者分号分隔
|
||||
typeAliasesPackage: com.central.device.model
|
||||
typeAliasesPackage: com.central.order.model
|
||||
# configuration:
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
global-config:
|
||||
@@ -87,7 +87,7 @@ tencent:
|
||||
file:
|
||||
oss-url: goflyapp.oss-cn-beijing.aliyuncs.com
|
||||
cdn-url: cdn.goflytec.com
|
||||
style: image/resize,m_mfit,w_218,h_160
|
||||
style: image/resize,m_mfit,w_218,h_288
|
||||
#审计日志
|
||||
# audit-log:
|
||||
# enabled: true
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
<?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.CouponMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.order.entity.Coupon">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="coupon_no" property="couponNo" jdbcType="VARCHAR"/>
|
||||
<result column="coupon_name" property="couponName" jdbcType="VARCHAR"/>
|
||||
<result column="coupon_type" property="couponType" jdbcType="INTEGER"/>
|
||||
<result column="amount" property="amount" jdbcType="DECIMAL"/>
|
||||
<result column="min_amount" property="minAmount" jdbcType="DECIMAL"/>
|
||||
<result column="discount_rate" property="discountRate" jdbcType="INTEGER"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="user_phone" property="userPhone" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userId" jdbcType="BIGINT"/>
|
||||
<result column="source" property="source" jdbcType="INTEGER"/>
|
||||
<result column="ctrip_coupon_id" property="ctripCouponId" jdbcType="VARCHAR"/>
|
||||
<result column="valid_start_time" property="validStartTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="valid_end_time" property="validEndTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="used_time" property="usedTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="used_order_no" property="usedOrderNo" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, coupon_no, coupon_name, coupon_type, amount, min_amount, discount_rate, status,
|
||||
user_phone, user_id, source, ctrip_coupon_id, valid_start_time, valid_end_time,
|
||||
used_time, used_order_no, create_time, update_time, create_by, update_by, remark, tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询优惠券列表 -->
|
||||
<select id="selectCouponPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
<where>
|
||||
<if test="coupon.couponName != null and coupon.couponName != ''">
|
||||
AND coupon_name LIKE CONCAT('%', #{coupon.couponName}, '%')
|
||||
</if>
|
||||
<if test="coupon.couponType != null">
|
||||
AND coupon_type = #{coupon.couponType}
|
||||
</if>
|
||||
<if test="coupon.status != null">
|
||||
AND status = #{coupon.status}
|
||||
</if>
|
||||
<if test="coupon.userPhone != null and coupon.userPhone != ''">
|
||||
AND user_phone = #{coupon.userPhone}
|
||||
</if>
|
||||
<if test="coupon.source != null">
|
||||
AND source = #{coupon.source}
|
||||
</if>
|
||||
<if test="coupon.ctripCouponId != null and coupon.ctripCouponId != ''">
|
||||
AND ctrip_coupon_id = #{coupon.ctripCouponId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据手机号查询用户优惠券 -->
|
||||
<select id="selectByUserPhone" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
WHERE user_phone = #{userPhone}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据手机号查询可用优惠券 -->
|
||||
<select id="selectAvailableByUserPhone" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
WHERE user_phone = #{userPhone}
|
||||
AND status = 0
|
||||
AND valid_start_time <= NOW()
|
||||
AND valid_end_time >= NOW()
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据携程优惠券ID查询 -->
|
||||
<select id="selectByCtripCouponId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
WHERE ctrip_coupon_id = #{ctripCouponId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据订单号查询使用的优惠券 -->
|
||||
<select id="selectByUsedOrderNo" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
WHERE used_order_no = #{usedOrderNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 更新优惠券状态为已使用 -->
|
||||
<update id="updateCouponUsed">
|
||||
UPDATE t_coupon
|
||||
SET status = 1,
|
||||
used_time = NOW(),
|
||||
used_order_no = #{usedOrderNo},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 批量更新过期优惠券状态 -->
|
||||
<update id="updateExpiredCoupons">
|
||||
UPDATE t_coupon
|
||||
SET status = 2,
|
||||
update_time = NOW()
|
||||
WHERE status = 0
|
||||
AND valid_end_time < NOW()
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -4,20 +4,33 @@
|
||||
<mapper namespace="com.central.order.mapper.OrderMapper">
|
||||
|
||||
<select id="findList" resultType="com.central.order.model.Order">
|
||||
select * from orders t
|
||||
SELECT o.*, t.tourism_name as tourismName
|
||||
FROM orders o
|
||||
LEFT JOIN tourisms t ON o.tourism_id = t.id
|
||||
<where>
|
||||
<if test="p.orderNo != null and p.orderNo != ''">
|
||||
AND t.order_no LIKE CONCAT('%', #{p.orderNo}, '%')
|
||||
</if>
|
||||
|
||||
<if test="p.deviceSn != null and p.deviceSn != ''">
|
||||
AND t.deviceSn LIKE CONCAT('%', #{p.deviceSn}, '%')
|
||||
AND o.order_no LIKE CONCAT('%', #{p.orderNo}, '%')
|
||||
</if>
|
||||
<if test="p.orderStatus != null">
|
||||
AND t.order_status = #{p.orderStatus}
|
||||
AND o.order_status = #{p.orderStatus}
|
||||
</if>
|
||||
<if test="p.tourismId != null">
|
||||
AND o.tourism_id = #{p.tourismId}
|
||||
</if>
|
||||
<if test="p.deviceSn != null and p.deviceSn != ''">
|
||||
AND o.device_sn LIKE CONCAT('%', #{p.deviceSn}, '%')
|
||||
</if>
|
||||
<if test="p.codeId != null and p.codeId != ''">
|
||||
AND o.code_id LIKE CONCAT('%', #{p.codeId}, '%')
|
||||
</if>
|
||||
<if test="p.userId != null and p.userId != ''">
|
||||
AND o.user_id LIKE CONCAT('%', #{p.userId}, '%')
|
||||
</if>
|
||||
<if test="p.mobile != null and p.mobile != ''">
|
||||
AND o.mobile LIKE CONCAT('%', #{p.mobile}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.id DESC
|
||||
ORDER BY o.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 动态获取参数采用备参 -->
|
||||
|
||||
@@ -4,7 +4,34 @@
|
||||
<mapper namespace="com.central.order.mapper.QrCodeMapper">
|
||||
|
||||
<select id="findList" resultType="com.central.order.model.QrCode">
|
||||
select * from qrcodes t
|
||||
SELECT * FROM qrcodes q
|
||||
<where>
|
||||
<if test="p.tourismId != null and p.tourismId != ''">
|
||||
AND q.tourism_id = #{p.tourismId}
|
||||
</if>
|
||||
<if test="p.waylineId != null and p.waylineId != ''">
|
||||
AND q.wayline_id = #{p.waylineId}
|
||||
</if>
|
||||
<if test="p.status != null">
|
||||
AND q.status = #{p.status}
|
||||
</if>
|
||||
<if test="p.isTest != null">
|
||||
AND q.is_test = #{p.isTest}
|
||||
</if>
|
||||
<if test="p.tenantId != null and p.tenantId != ''">
|
||||
AND q.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
<if test="p.name != null and p.name != ''">
|
||||
AND q.name LIKE CONCAT('%', #{p.name}, '%')
|
||||
</if>
|
||||
<if test="p.codeId != null and p.codeId != ''">
|
||||
AND q.code_id LIKE CONCAT('%', #{p.codeId}, '%')
|
||||
</if>
|
||||
<if test="p.deviceSn != null and p.deviceSn != ''">
|
||||
AND q.device_sn = #{p.deviceSn}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY q.create_time DESC
|
||||
</select>
|
||||
|
||||
<resultMap id="QrCodeResultMap" type="com.central.order.model.QrCode">
|
||||
|
||||
Reference in New Issue
Block a user