!23 fix(订单中心):首页统计优化
Merge pull request !23 from Iamasoldier/feature_lsl
This commit is contained in:
+89
-20
@@ -19,6 +19,11 @@ import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.central.order.model.CtripCreateOrderRequest;
|
||||
import com.central.order.model.CtripCreateOrderRequest.CtripOrderBody;
|
||||
import com.central.order.model.CtripCreateOrderRequest.CtripOrderItem;
|
||||
import com.central.order.model.CtripCreateOrderRequest.CtripPassenger;
|
||||
import com.central.order.model.CtripCreateOrderRequest.CtripContact;
|
||||
|
||||
/**
|
||||
* 优惠券管理控制器
|
||||
@@ -121,29 +126,93 @@ public class CouponController {
|
||||
*/
|
||||
@Operation(summary = "携程创建优惠券接口")
|
||||
@PostMapping("/ctrip/create")
|
||||
public Result<Boolean> createCouponFromCtrip(
|
||||
@RequestParam String ctripCouponId,
|
||||
@RequestParam String userPhone,
|
||||
@RequestParam String couponName,
|
||||
@RequestParam Integer couponType,
|
||||
@RequestParam BigDecimal amount,
|
||||
@RequestParam(required = false) BigDecimal minAmount,
|
||||
@RequestParam(required = false) Integer discountRate,
|
||||
@RequestParam String validStartTime,
|
||||
@RequestParam String validEndTime) {
|
||||
// 幂等校验
|
||||
if (couponService.existsByUserPhoneAndCtripCouponId(userPhone, ctripCouponId)) {
|
||||
return Result.succeed(true);
|
||||
public Result<Boolean> createCouponFromCtripJson(@RequestBody CtripCreateOrderRequest request) {
|
||||
log.info("携程创建券请求:{}", request);
|
||||
|
||||
try {
|
||||
// 验证请求头
|
||||
if (request.getHeader() == null || request.getBody() == null) {
|
||||
return Result.failed("请求格式错误");
|
||||
}
|
||||
|
||||
// 从body中提取订单信息
|
||||
CtripOrderBody body = request.getBody();
|
||||
if (body.getItems() == null || body.getItems().isEmpty()) {
|
||||
return Result.failed("订单项不能为空");
|
||||
}
|
||||
|
||||
// 获取第一个订单项
|
||||
CtripOrderItem item = body.getItems().get(0);
|
||||
|
||||
// 获取乘客信息
|
||||
String userPhone = null;
|
||||
String userName = null;
|
||||
if (item.getPassengers() != null && !item.getPassengers().isEmpty()) {
|
||||
CtripPassenger passenger = item.getPassengers().get(0);
|
||||
userPhone = passenger.getMobile();
|
||||
userName = passenger.getName();
|
||||
}
|
||||
|
||||
// 获取联系人信息作为备选
|
||||
if (userPhone == null && body.getContacts() != null && !body.getContacts().isEmpty()) {
|
||||
CtripContact contact = body.getContacts().get(0);
|
||||
userPhone = contact.getMobile();
|
||||
userName = contact.getName();
|
||||
}
|
||||
|
||||
if (userPhone == null) {
|
||||
return Result.failed("无法获取用户手机号");
|
||||
}
|
||||
|
||||
// 构建优惠券信息
|
||||
String ctripCouponId = body.getOtaOrderId(); // 使用otaOrderId作为携程券ID
|
||||
String couponName = userName != null ? userName + "的携程优惠券" : "携程订单优惠券"; // 个性化名称
|
||||
Integer couponType = 1; // 默认类型:满减券
|
||||
BigDecimal amount = item.getSalePrice(); // 使用销售价格作为券面额
|
||||
BigDecimal minAmount = item.getPrice(); // 使用原价作为最低消费
|
||||
String validStartTime = item.getUseStartDate();
|
||||
String validEndTime = item.getUseEndDate();
|
||||
|
||||
// 幂等校验
|
||||
if (couponService.existsByUserPhoneAndCtripCouponId(userPhone, ctripCouponId)) {
|
||||
log.info("携程优惠券已存在,userPhone: {}, ctripCouponId: {}", userPhone, ctripCouponId);
|
||||
return Result.succeed(true);
|
||||
}
|
||||
|
||||
// 时间解析
|
||||
Date startTime = parseDate(validStartTime);
|
||||
Date endTime = parseDate(validEndTime);
|
||||
|
||||
// 验证时间
|
||||
if (startTime == null || endTime == null) {
|
||||
return Result.failed("时间格式错误");
|
||||
}
|
||||
|
||||
if (endTime.before(startTime)) {
|
||||
return Result.failed("结束时间不能早于开始时间");
|
||||
}
|
||||
|
||||
// 创建优惠券
|
||||
boolean result = couponService.createCouponFromCtrip(ctripCouponId, userPhone, couponName,
|
||||
couponType, amount, minAmount, null,
|
||||
startTime, endTime);
|
||||
|
||||
if (result) {
|
||||
log.info("携程优惠券创建成功,userPhone: {}, ctripCouponId: {}, amount: {}", userPhone, ctripCouponId, amount);
|
||||
return Result.succeed(true);
|
||||
} else {
|
||||
log.error("携程优惠券创建失败,userPhone: {}, ctripCouponId: {}", userPhone, ctripCouponId);
|
||||
return Result.failed("优惠券创建失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理携程创建券请求失败", e);
|
||||
return Result.failed("处理请求失败:" + e.getMessage());
|
||||
}
|
||||
// 时间解析
|
||||
Date startTime = parseDate(validStartTime);
|
||||
Date endTime = parseDate(validEndTime);
|
||||
boolean result = couponService.createCouponFromCtrip(ctripCouponId, userPhone, couponName,
|
||||
couponType, amount, minAmount, discountRate,
|
||||
startTime, endTime);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 携程取消优惠券接口
|
||||
*/
|
||||
|
||||
+28
-1
@@ -15,6 +15,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import com.central.order.model.vo.FilterOptions;
|
||||
import com.central.order.mapper.DashboardMapper;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -24,6 +27,7 @@ import java.util.Map;
|
||||
public class DashboardController {
|
||||
|
||||
private final IDashboardService dashboardService;
|
||||
private final DashboardMapper dashboardMapper;
|
||||
|
||||
@Operation(summary = "获取首页统计数据")
|
||||
@GetMapping("/statistics")
|
||||
@@ -32,7 +36,8 @@ public class DashboardController {
|
||||
@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) String endTime,
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tourismId", tourismId);
|
||||
@@ -40,6 +45,7 @@ public class DashboardController {
|
||||
params.put("deviceSn", deviceSn);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
|
||||
DashboardStatisticsVO statistics = dashboardService.getDashboardStatistics(params);
|
||||
return Result.succeed(statistics, "获取首页统计数据成功");
|
||||
@@ -48,4 +54,25 @@ public class DashboardController {
|
||||
return Result.failed("获取统计数据失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取二维码选项")
|
||||
@GetMapping("/qrcode/options")
|
||||
public Result<Map<String, Object>> getQrcodeOptions(
|
||||
@Parameter(description = "景区ID") @RequestParam(required = false) Long tourismId,
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tourismId", tourismId);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
|
||||
List<FilterOptions.OptionItem> qrcodeList = dashboardMapper.getQrcodeOptions(params);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("qrcodeList", qrcodeList);
|
||||
|
||||
return Result.succeed(result, "获取二维码选项成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取二维码选项失败", e);
|
||||
return Result.failed("获取二维码选项失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+109
-15
@@ -201,7 +201,7 @@ public class OrderController {
|
||||
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||
|
||||
order.setUserId(user.getId());
|
||||
order.setTenantId(TenantContextHolder.getTenant());
|
||||
|
||||
|
||||
List<Order> userOrderList = orderService.getOrderCountByStatusAndUser(user.getId(),OrderStatus.PAID.getId(),OrderStatus.UNPAID.getId());
|
||||
if (!userOrderList.isEmpty()){
|
||||
@@ -213,8 +213,8 @@ public class OrderController {
|
||||
if (qrCode.getStatus().equals(CommonStatus.UNABLE.getId())){
|
||||
return Result.failed("该二维码已过期");
|
||||
}
|
||||
order.setTenantId(qrCode.getTenantId());
|
||||
//设置订单所属tenantId
|
||||
TenantContextHolder.setTenant(qrCode.getTenantId());
|
||||
order.setTourismId(qrCode.getTourismId());
|
||||
order.setDeviceSn(qrCode.getDeviceSn());
|
||||
order.setOrderAmount(qrCode.getPrice());
|
||||
@@ -480,19 +480,29 @@ public class OrderController {
|
||||
@AuditLog(operation = "'机库更新订单完成状态:' + #payload")
|
||||
@PutMapping("/update")
|
||||
public Result<String> updateOrderStatusCompleted(@RequestBody Map payload) {
|
||||
Order order = orderService.getOrderByNumber(payload.get("orderNo").toString());
|
||||
Assert.notNull(order,"订单数据不能为空");
|
||||
if (order.getOrderStatus().equals(OrderStatus.DOING.getId())
|
||||
|| order.getOrderStatus().equals(OrderStatus.UPLOADED.getId())
|
||||
|| order.getOrderStatus().equals(OrderStatus.UPLOADING.getId())){
|
||||
order.setOrderStatus(OrderStatus.COMPLETE.getId());
|
||||
if (orderService.updateOrder(order)){
|
||||
return Result.succeed("更新成功");
|
||||
try {
|
||||
TenantContextHolder.setTenant("webApp");
|
||||
Order order = orderService.getOrderByNumber(payload.get("orderNo").toString());
|
||||
Assert.notNull(order,"订单数据不能为空");
|
||||
if (order.getOrderStatus().equals(OrderStatus.DOING.getId())
|
||||
|| order.getOrderStatus().equals(OrderStatus.UPLOADED.getId())
|
||||
|| order.getOrderStatus().equals(OrderStatus.UPLOADING.getId())){
|
||||
order.setOrderStatus(OrderStatus.COMPLETE.getId());
|
||||
log.info("更新订单时,租户ID:{}", TenantContextHolder.getTenant());
|
||||
if (orderService.updateOrder(order)){
|
||||
return Result.succeed("更新成功");
|
||||
}
|
||||
}else {
|
||||
return Result.failed("已更新");
|
||||
}
|
||||
}else {
|
||||
return Result.failed("已更新");
|
||||
return Result.failed("未查询到订单数据");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
TenantContextHolder.clear();
|
||||
}
|
||||
return Result.failed("未查询到订单数据");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Operation(summary = "取消订单")
|
||||
@@ -507,6 +517,21 @@ public class OrderController {
|
||||
return Result.failed("请重试");
|
||||
}
|
||||
|
||||
@Operation(summary = "删除订单(逻辑删除)")
|
||||
@DeleteMapping("/{orderNo}")
|
||||
public Result<String> deleteOrder(@PathVariable("orderNo") String orderNo) {
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
if (order == null) {
|
||||
return Result.failed("订单不存在");
|
||||
}
|
||||
order.setIsDel(1);
|
||||
boolean res = orderService.updateOrder(order);
|
||||
if (res) {
|
||||
return Result.succeed("删除成功");
|
||||
}
|
||||
return Result.failed("删除失败,请重试");
|
||||
}
|
||||
|
||||
@Operation(summary = "后台管理更新订单")
|
||||
@PostMapping("/update/order")
|
||||
public Result updateOrder(@RequestBody Order order) {
|
||||
@@ -647,6 +672,75 @@ public class OrderController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号查询订单素材
|
||||
*/
|
||||
@Operation(summary = "根据订单号查询订单素材")
|
||||
@GetMapping("/user/files/{orderNo}")
|
||||
public Result<Map<String, Object>> getOrderFilesByOrderNo(@PathVariable("orderNo") String orderNo) {
|
||||
// 校验订单是否存在
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
if (order == null) {
|
||||
return Result.failed("订单不存在");
|
||||
}
|
||||
|
||||
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(orderNo);
|
||||
|
||||
// aiVideo
|
||||
List<OrderFile> aiVideoFiles = allFiles.stream()
|
||||
.filter(f -> "ai_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
String aiVideoUrl = null;
|
||||
if (!aiVideoFiles.isEmpty()) {
|
||||
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<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
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()))
|
||||
.toList();
|
||||
List<Map<String,String>> videoList = new ArrayList<>();
|
||||
for (OrderFile orderFile : videoFiles){
|
||||
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));
|
||||
videoList.add(videoMap);
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
|
||||
return Result.succeed(orderFileMap, "查询成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将分的价格转换为元的str,方便前端显示
|
||||
* @param str
|
||||
@@ -758,8 +852,8 @@ public class OrderController {
|
||||
.toList();
|
||||
String aiVideoUrl = null;
|
||||
if (!aiVideoFiles.isEmpty()) {
|
||||
fileMap.put("path", aiVideoFiles.get(0).getFilePath());
|
||||
aiVideoUrl = fileCenterService.getViewUrlByPathStyle(fileMap);
|
||||
// fileMap.put("path", aiVideoFiles.get(0).getFilePath());
|
||||
aiVideoUrl = fileCenterService.getViewUrlByPath(aiVideoFiles.get(0).getFilePath()).replace(cdnOssUrl, cdnUrl);
|
||||
}
|
||||
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||
|
||||
|
||||
+11
@@ -1,6 +1,7 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.context.LoginUserContextHolder;
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
import com.central.common.model.*;
|
||||
import com.central.order.constants.EditTaskStatus;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
@@ -179,6 +180,7 @@ public class OrderFileController {
|
||||
@PostMapping("/path")
|
||||
public Result createOrderFileForPath(@RequestBody OrderFile orderFile) {
|
||||
try {
|
||||
TenantContextHolder.setTenant("webApp");
|
||||
if (orderFile == null || orderFile.getOrderNo() == null) {
|
||||
log.warn("参数为空,orderFile: {}", orderFile);
|
||||
return Result.failed(orderFile,"参数为空");
|
||||
@@ -247,6 +249,8 @@ public class OrderFileController {
|
||||
} catch (Exception e) {
|
||||
log.error("素材记录创建异常", e);
|
||||
return Result.failed(orderFile,"素材记录创建异常: " + e.getMessage());
|
||||
}finally {
|
||||
TenantContextHolder.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +290,13 @@ public class OrderFileController {
|
||||
log.info("二维码已开启一键成片功能,开始触发一键成片: orderNo={}, codeId={}",
|
||||
order.getOrderNo(), order.getCodeId());
|
||||
|
||||
// 检查是否存在进行中的编辑任务
|
||||
EditTask existingTask = editTaskService.getTaskByOrderSn(order.getOrderNo());
|
||||
if (existingTask != null && EditTaskStatus.isProcessing(existingTask.getStatus())) {
|
||||
log.info("已存在进行中的编辑任务: orderNo={}, taskId={}", order.getOrderNo(), existingTask.getId());
|
||||
return ;
|
||||
}
|
||||
|
||||
//触发一键成片
|
||||
// 1. 创建新任务
|
||||
EditTask task = editTaskService.createTask(order.getOrderNo(), order.getUserId());
|
||||
|
||||
+7
-1
@@ -1,5 +1,6 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.model.SysUser;
|
||||
@@ -9,12 +10,12 @@ import com.central.order.feign.UserCenterService;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.QrCode;
|
||||
import com.central.order.service.IOrderService;
|
||||
import com.central.order.service.IQrCodeService;
|
||||
import com.central.order.service.IRefundService;
|
||||
import com.central.order.service.IWxTemplateMessageService;
|
||||
import com.central.wechat.config.WxPayConfigFactory;
|
||||
import com.central.wechat.entity.WechatConfig;
|
||||
import com.central.wechat.feign.WechatConfigService;
|
||||
import com.central.order.service.IQrCodeService;
|
||||
import com.wechat.pay.java.service.refund.RefundService;
|
||||
import com.wechat.pay.java.service.refund.model.AmountReq;
|
||||
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
||||
@@ -116,6 +117,7 @@ public class RefundController {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result<com.central.order.model.Refund> approveOrder(@RequestBody com.central.order.model.Refund refund) {
|
||||
|
||||
log.info("审批退款单,订单号: {}, 退款单号: {}", refund.getOrderNo(), refund.getRefundNo());
|
||||
// 检查订单是否存在
|
||||
Order order = orderService.getOrderByNumber(refund.getOrderNo());
|
||||
Assert.notNull(order, "ORDER DATA不存在");
|
||||
@@ -145,6 +147,8 @@ public class RefundController {
|
||||
public Result<String> autoRefundProcess(@RequestBody Map payload) {
|
||||
String orderNo = payload.get("orderNo").toString();
|
||||
Assert.notNull(orderNo,"订单数据不能为空");
|
||||
//机库端触发异常后自动创建退款单,没有带请求头信息,因此没有租户ID @TODO
|
||||
TenantContextHolder.setTenant("webApp");
|
||||
log.info("收到自动退款请求,订单号: {}", orderNo);
|
||||
try {
|
||||
|
||||
@@ -214,6 +218,8 @@ public class RefundController {
|
||||
} catch (Exception e) {
|
||||
log.error("退款流程测试失败,订单号: {},异常: {}", orderNo, e.getMessage(), e);
|
||||
return Result.failed("退款流程测试失败:" + e.getMessage());
|
||||
}finally {
|
||||
TenantContextHolder.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+84
-2
@@ -6,6 +6,7 @@ import com.central.common.model.LoginAppUser;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.Tourism;
|
||||
import com.central.order.model.TourismWithDistance;
|
||||
import com.central.order.service.ITourismService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -18,17 +19,21 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Tourism information
|
||||
* 景区管理控制器
|
||||
*
|
||||
* @author lsl
|
||||
* @date 2024-12-19 17:51:47
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "Tourism管理")
|
||||
@Tag(name = "景区管理")
|
||||
@RequestMapping("/tourism")
|
||||
@RequiredArgsConstructor
|
||||
public class TourismController {
|
||||
@@ -91,4 +96,81 @@ public class TourismController {
|
||||
return Result.failed("获取景区设备列表失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询附近景区列表
|
||||
*/
|
||||
@Operation(summary = "查询附近景区列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "longitude", description = "经度", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "latitude", description = "纬度", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "radius", description = "搜索半径(公里),默认10km", required = false, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "limit", description = "返回数量限制,默认20个", required = false, in = ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/nearby")
|
||||
public Result<List<TourismWithDistance>> findNearbyTourisms(
|
||||
@RequestParam BigDecimal longitude,
|
||||
@RequestParam BigDecimal latitude,
|
||||
@RequestParam(required = false) Double radius,
|
||||
@RequestParam(required = false) Integer limit) {
|
||||
try {
|
||||
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}", longitude, latitude, radius, limit);
|
||||
List<TourismWithDistance> tourisms = tourismService.findNearbyTourisms(longitude, latitude, radius, limit);
|
||||
return Result.succeed(tourisms, "查询附近景区成功");
|
||||
} catch (Exception e) {
|
||||
log.error("查询附近景区失败", e);
|
||||
return Result.failed("查询附近景区失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度范围查询景区
|
||||
*/
|
||||
@Operation(summary = "根据经纬度范围查询景区")
|
||||
@Parameters({
|
||||
@Parameter(name = "minLongitude", description = "最小经度", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "maxLongitude", description = "最大经度", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "minLatitude", description = "最小纬度", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "maxLatitude", description = "最大纬度", required = true, in = ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/bounds")
|
||||
public Result<List<Tourism>> findTourismsByBounds(
|
||||
@RequestParam BigDecimal minLongitude,
|
||||
@RequestParam BigDecimal maxLongitude,
|
||||
@RequestParam BigDecimal minLatitude,
|
||||
@RequestParam BigDecimal maxLatitude) {
|
||||
try {
|
||||
log.info("根据经纬度范围查询景区,经度范围: [{}, {}], 纬度范围: [{}, {}]",
|
||||
minLongitude, maxLongitude, minLatitude, maxLatitude);
|
||||
List<Tourism> tourisms = tourismService.findTourismsByBounds(minLongitude, maxLongitude, minLatitude, maxLatitude);
|
||||
return Result.succeed(tourisms, "查询景区成功");
|
||||
} catch (Exception e) {
|
||||
log.error("根据经纬度范围查询景区失败", e);
|
||||
return Result.failed("查询景区失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新景区经纬度信息
|
||||
*/
|
||||
@Operation(summary = "更新景区经纬度信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "景区ID", required = true, in = ParameterIn.PATH),
|
||||
@Parameter(name = "longitude", description = "经度", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "latitude", description = "纬度", required = true, in = ParameterIn.QUERY)
|
||||
})
|
||||
@PutMapping("/{id}/location")
|
||||
public Result updateTourismLocation(
|
||||
@PathVariable Long id,
|
||||
@RequestParam BigDecimal longitude,
|
||||
@RequestParam BigDecimal latitude) {
|
||||
try {
|
||||
log.info("更新景区经纬度信息,景区ID: {}, 经度: {}, 纬度: {}", id, longitude, latitude);
|
||||
return tourismService.updateTourismLocation(id, longitude, latitude);
|
||||
} catch (Exception e) {
|
||||
log.error("更新景区经纬度信息失败", e);
|
||||
return Result.failed("更新景区经纬度信息失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-2
@@ -1,5 +1,6 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
import com.central.order.enums.RefundState;
|
||||
import com.central.order.model.Order;
|
||||
@@ -69,6 +70,8 @@ public class WxPayController {
|
||||
WechatConfig config = wechatConfigService.getConfigBySerialNumber(serial);
|
||||
Assert.notNull(config,"支付配置参数为空,请确认参数是否正确配置");
|
||||
String tenantId = config.getTenantId();
|
||||
log.info("订单支付回调租户ID设置,租户ID:{}", tenantId);
|
||||
TenantContextHolder.setTenant(tenantId);
|
||||
|
||||
// 创建通知解析器
|
||||
NotificationParser notificationParser;
|
||||
@@ -120,7 +123,7 @@ public class WxPayController {
|
||||
* 处理服务商模式下的支付结果
|
||||
*/
|
||||
private void handleSubMerchantPaymentResult(Transaction transaction, WechatConfig config) {
|
||||
|
||||
|
||||
log.info("处理服务商模式支付结果,子商户号:{}", config.getSubMchId());
|
||||
|
||||
String outTradeNo = transaction.getOutTradeNo();
|
||||
@@ -211,6 +214,8 @@ public class WxPayController {
|
||||
WechatConfig config = wechatConfigService.getConfigBySerialNumber(serial);
|
||||
Assert.notNull(config,"支付配置参数为空,请确认参数是否正确配置");
|
||||
String tenantId = config.getTenantId();
|
||||
log.info("订单退款回调租户ID设置,租户ID:{}", tenantId);
|
||||
TenantContextHolder.setTenant(tenantId);
|
||||
|
||||
// 创建通知解析器
|
||||
NotificationParser notificationParser;
|
||||
@@ -262,7 +267,7 @@ public class WxPayController {
|
||||
* 处理服务商模式下的退款结果
|
||||
*/
|
||||
private void handleSubMerchantRefundResult(RefundNotification notification, WechatConfig config) {
|
||||
|
||||
|
||||
log.info("处理服务商模式退款结果,子商户号:{}", config.getSubMchId());
|
||||
|
||||
// 获取退款通知中的关键信息
|
||||
|
||||
+160
-84
@@ -14,21 +14,26 @@ public interface DashboardMapper {
|
||||
// 基础订单统计(支持筛选)
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders WHERE is_del = 0",
|
||||
"SELECT COUNT(*) 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>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -36,15 +41,21 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders WHERE is_del = 0 AND DATE(create_time) = CURDATE()",
|
||||
"SELECT COUNT(*) 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 DATE(o.create_time) = CURDATE()",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -52,15 +63,21 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders WHERE is_del = 0 AND DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)",
|
||||
"SELECT COUNT(*) 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 DATE(o.create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -68,21 +85,27 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders WHERE is_del = 0 AND order_status = 3",
|
||||
"SELECT COUNT(*) 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",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -91,18 +114,22 @@ public interface DashboardMapper {
|
||||
// 对账相关统计
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(order_amount), 0)",
|
||||
"FROM orders",
|
||||
"WHERE is_del = 0",
|
||||
"AND (order_status = 3 OR order_status = 8)",
|
||||
"SELECT COALESCE(SUM(o.order_amount), 0)",
|
||||
"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 tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -110,23 +137,26 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(platform_amount), 0)",
|
||||
"FROM order_statistics",
|
||||
"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 tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -134,23 +164,26 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(tourism_amount), 0)",
|
||||
"FROM order_statistics",
|
||||
"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 tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
@@ -161,7 +194,11 @@ public interface DashboardMapper {
|
||||
"SELECT COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0)",
|
||||
"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>",
|
||||
@@ -179,22 +216,26 @@ public interface DashboardMapper {
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" DATE_FORMAT(create_time, '%Y-%m-%d') as date,",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" 'orders' as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders",
|
||||
"WHERE is_del = 0",
|
||||
" AND create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)",
|
||||
"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 tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')",
|
||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||
"ORDER BY date",
|
||||
"</script>"
|
||||
})
|
||||
@@ -203,7 +244,7 @@ public interface DashboardMapper {
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" CASE order_status",
|
||||
" CASE o.order_status",
|
||||
" WHEN 0 THEN '待支付'",
|
||||
" WHEN 1 THEN '已支付排队中'",
|
||||
" WHEN 2 THEN '已取消'",
|
||||
@@ -217,24 +258,28 @@ public interface DashboardMapper {
|
||||
" ELSE '其他'",
|
||||
" END as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM orders",
|
||||
"WHERE is_del = 0",
|
||||
"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>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND code_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"GROUP BY order_status",
|
||||
"GROUP BY o.order_status",
|
||||
"</script>"
|
||||
})
|
||||
List<DistributionDataVO> getOrderDistribution(@Param("p") Map<String, Object> params);
|
||||
@@ -243,77 +288,108 @@ public interface DashboardMapper {
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" '平台分账' as type,",
|
||||
" COALESCE(SUM(platform_amount), 0) as value",
|
||||
"FROM order_statistics",
|
||||
" COALESCE(SUM(os.platform_amount), 0) as value",
|
||||
"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 tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '景区分账' as type,",
|
||||
" COALESCE(SUM(tourism_amount), 0) as value",
|
||||
"FROM order_statistics",
|
||||
" COALESCE(SUM(os.tourism_amount), 0) as value",
|
||||
"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 tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '退款金额' as type,",
|
||||
" COALESCE(SUM(refund_amount), 0) as value",
|
||||
"FROM order_statistics",
|
||||
" COALESCE(SUM(os.refund_amount), 0) as value",
|
||||
"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 tourism_id = #{p.tourismId}",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND qrcode_id = #{p.qrcodeId}",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND device_sn = #{p.deviceSn}",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND create_time >= #{p.startTime}",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND create_time <= #{p.endTime}",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
List<IncomeDataVO> getIncomeBreakdown(@Param("p") Map<String, Object> params);
|
||||
|
||||
// 筛选选项
|
||||
@Select("SELECT id as value, tourism_name as label FROM tourisms WHERE is_del = 0 ORDER BY tourism_name")
|
||||
@Select("SELECT id as value, tourism_name as label FROM tourisms WHERE is_del = 0 ORDER BY create_time DESC")
|
||||
List<FilterOptions.OptionItem> getTourismOptions();
|
||||
|
||||
@Select("SELECT code_id as value, CONCAT(name, ' | ', device_sn) as label FROM qrcodes WHERE is_del = 0 ORDER BY name")
|
||||
List<FilterOptions.OptionItem> getQrcodeOptions();
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT code_id as value, name as label FROM qrcodes",
|
||||
"WHERE is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"ORDER BY create_time DESC",
|
||||
"</script>"
|
||||
})
|
||||
List<FilterOptions.OptionItem> getQrcodeOptions(@Param("p") Map<String, Object> params);
|
||||
|
||||
@Select("SELECT DISTINCT device_sn as value, device_sn as label FROM orders WHERE device_sn IS NOT NULL AND device_sn != '' ORDER BY device_sn")
|
||||
List<FilterOptions.OptionItem> getDeviceOptions();
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.central.order.mapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.db.mapper.SuperMapper;
|
||||
import com.central.order.model.Tourism;
|
||||
import com.central.order.model.TourismWithDistance;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -40,4 +42,34 @@ public interface TourismMapper extends SuperMapper<Tourism> {
|
||||
*/
|
||||
List<Map<String, Object>> getDevicesByTourismId(@Param("tourismId") Long tourismId);
|
||||
|
||||
/**
|
||||
* 查询附近景区列表
|
||||
* @param longitude 经度
|
||||
* @param latitude 纬度
|
||||
* @param radius 搜索半径(公里)
|
||||
* @param limit 返回数量限制
|
||||
* @return 附近景区列表(包含距离信息)
|
||||
*/
|
||||
List<TourismWithDistance> findNearbyTourisms(
|
||||
@Param("longitude") BigDecimal longitude,
|
||||
@Param("latitude") BigDecimal latitude,
|
||||
@Param("radius") Double radius,
|
||||
@Param("limit") Integer limit
|
||||
);
|
||||
|
||||
/**
|
||||
* 根据经纬度范围查询景区
|
||||
* @param minLongitude 最小经度
|
||||
* @param maxLongitude 最大经度
|
||||
* @param minLatitude 最小纬度
|
||||
* @param maxLatitude 最大纬度
|
||||
* @return 景区列表
|
||||
*/
|
||||
List<Tourism> findTourismsByBounds(
|
||||
@Param("minLongitude") BigDecimal minLongitude,
|
||||
@Param("maxLongitude") BigDecimal maxLongitude,
|
||||
@Param("minLatitude") BigDecimal minLatitude,
|
||||
@Param("maxLatitude") BigDecimal maxLatitude
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程创建订单请求
|
||||
*/
|
||||
@Data
|
||||
public class CtripCreateOrderRequest {
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
private CtripHeader header;
|
||||
|
||||
/**
|
||||
* 请求体
|
||||
*/
|
||||
private CtripOrderBody body;
|
||||
|
||||
/**
|
||||
* 携程请求头
|
||||
*/
|
||||
@Data
|
||||
public static class CtripHeader {
|
||||
private String requestTime;
|
||||
private String accountId;
|
||||
private String sign;
|
||||
private String serviceName;
|
||||
private String version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单体
|
||||
*/
|
||||
@Data
|
||||
public static class CtripOrderBody {
|
||||
private String otaOrderId;
|
||||
private String sequenceId;
|
||||
private List<CtripOrderItem> items;
|
||||
private List<CtripContact> contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单项
|
||||
*/
|
||||
@Data
|
||||
public static class CtripOrderItem {
|
||||
private List<CtripPassenger> passengers;
|
||||
private java.math.BigDecimal cost;
|
||||
private Integer quantity;
|
||||
private java.math.BigDecimal salePrice;
|
||||
private String remark;
|
||||
private String useEndDate;
|
||||
private String locale;
|
||||
private String useStartDate;
|
||||
private String priceCurrency;
|
||||
private List<Object> adjunctions;
|
||||
private java.math.BigDecimal price;
|
||||
private String PLU;
|
||||
private Object deposit;
|
||||
private String distributionChannel;
|
||||
private String costCurrency;
|
||||
private String salePriceCurrency;
|
||||
private CtripExpressDelivery expressDelivery;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程乘客信息
|
||||
*/
|
||||
@Data
|
||||
public static class CtripPassenger {
|
||||
private String cardIssuePlace;
|
||||
private String lastName;
|
||||
private String cardIssueCountry;
|
||||
private Integer shoeSize;
|
||||
private String gender;
|
||||
private String cardIssueDate;
|
||||
private String intlCode;
|
||||
private String nationalityName;
|
||||
private String mobile;
|
||||
private String cardType;
|
||||
private Integer weight;
|
||||
private Integer myopiaDegreeL;
|
||||
private String birthDate;
|
||||
private String cardNo;
|
||||
private String ageType;
|
||||
private Integer myopiaDegreeR;
|
||||
private String firstName;
|
||||
private String birthPlace;
|
||||
private String nationalityCode;
|
||||
private String name;
|
||||
private String passengerId;
|
||||
private String cardValidDate;
|
||||
private Integer height;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程联系人信息
|
||||
*/
|
||||
@Data
|
||||
public static class CtripContact {
|
||||
private String intlCode;
|
||||
private String name;
|
||||
private String mobile;
|
||||
private String optionalMobile;
|
||||
private String optionalIntlCode;
|
||||
private String email;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程快递信息
|
||||
*/
|
||||
@Data
|
||||
public static class CtripExpressDelivery {
|
||||
private String type;
|
||||
}
|
||||
}
|
||||
@@ -99,4 +99,10 @@ public class QrCode extends SuperEntity {
|
||||
@Schema(description = "素材数量")
|
||||
private Integer materialCount;
|
||||
|
||||
/**
|
||||
* 是否为测试二维码(0:否,1:是)
|
||||
*/
|
||||
@Schema(description = "是否为测试二维码")
|
||||
private Integer isTest;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Device information
|
||||
* 景区信息实体类
|
||||
*
|
||||
* @author lsl
|
||||
* @date 2024-12-19 17:51:47
|
||||
@@ -34,6 +35,16 @@ public class Tourism extends SuperEntity {
|
||||
private String tourismPhone;
|
||||
private String tourismEmail;
|
||||
|
||||
/**
|
||||
* 景区经度
|
||||
*/
|
||||
private BigDecimal longitude;
|
||||
|
||||
/**
|
||||
* 景区纬度
|
||||
*/
|
||||
private BigDecimal latitude;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 景区信息实体类(包含距离信息)
|
||||
* 用于查询附近景区时返回距离信息
|
||||
*
|
||||
* @author lsl
|
||||
* @date 2024-12-19 17:51:47
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TourismWithDistance extends Tourism {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 距离(公里)
|
||||
*/
|
||||
private BigDecimal distance;
|
||||
|
||||
/**
|
||||
* 距离描述(如:1.2km)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String distanceDesc;
|
||||
|
||||
/**
|
||||
* 景区订单展示图片URL
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String orderShowImageUrl;
|
||||
|
||||
/**
|
||||
* 获取距离描述
|
||||
* @return 距离描述字符串
|
||||
*/
|
||||
public String getDistanceDesc() {
|
||||
if (distance == null) {
|
||||
return "未知距离";
|
||||
}
|
||||
|
||||
if (distance.compareTo(BigDecimal.ONE) < 0) {
|
||||
// 小于1公里,显示为米
|
||||
int meters = distance.multiply(new BigDecimal("1000")).intValue();
|
||||
return meters + "m";
|
||||
} else {
|
||||
// 大于等于1公里,显示为公里
|
||||
return distance.setScale(1, BigDecimal.ROUND_HALF_UP) + "km";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置距离描述
|
||||
* @param distanceDesc 距离描述
|
||||
*/
|
||||
public void setDistanceDesc(String distanceDesc) {
|
||||
this.distanceDesc = distanceDesc;
|
||||
}
|
||||
}
|
||||
+13
-8
@@ -1,12 +1,15 @@
|
||||
package com.central.order.scheduler;
|
||||
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
import com.central.order.service.IOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
@@ -18,14 +21,16 @@ public class OrderScheduler {
|
||||
// 每隔一定时间(这里设置为每分钟检查一次,可根据实际情况调整)检查订单超时情况
|
||||
@Scheduled(fixedRate = 60 * 1000)
|
||||
public void checkOrderTimeout() {
|
||||
orderService.checkAndHandleOrderTimeout();
|
||||
log.debug("开始执行订单超时检查任务");
|
||||
try {
|
||||
TenantContextHolder.setTenant("webApp");
|
||||
orderService.checkAndHandleOrderTimeout();
|
||||
log.debug("订单超时检查任务执行完成");
|
||||
} catch (Exception e) {
|
||||
log.error("订单超时检查任务执行失败", e);
|
||||
} finally {
|
||||
TenantContextHolder.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// 每隔一定时间(这里设置为每分钟检查一次,可根据实际情况调整)检查是否存在未服务完成的订单
|
||||
// @Scheduled(fixedRate = 60 * 1000)
|
||||
public void processOrdersInQueue() {
|
||||
orderService.processOrdersInQueue();
|
||||
}
|
||||
@Scheduled(fixedRate = 2 * 60 * 1000)
|
||||
public void processOrdersCompleted() {}
|
||||
}
|
||||
|
||||
+34
-1
@@ -4,11 +4,14 @@ import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.service.ISuperService;
|
||||
import com.central.order.model.Tourism;
|
||||
import com.central.order.model.TourismWithDistance;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Firmware file information
|
||||
* 景区信息服务接口
|
||||
*
|
||||
* @author lsl
|
||||
* @date 2024-12-19 17:52:54
|
||||
@@ -43,5 +46,35 @@ public interface ITourismService extends ISuperService<Tourism> {
|
||||
* @return 设备列表
|
||||
*/
|
||||
java.util.List<java.util.Map<String, Object>> getDevicesByTourismId(Long tourismId);
|
||||
|
||||
/**
|
||||
* 查询附近景区列表
|
||||
* @param longitude 经度
|
||||
* @param latitude 纬度
|
||||
* @param radius 搜索半径(公里)
|
||||
* @param limit 返回数量限制
|
||||
* @return 附近景区列表(包含距离信息)
|
||||
*/
|
||||
List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit);
|
||||
|
||||
/**
|
||||
* 根据经纬度范围查询景区
|
||||
* @param minLongitude 最小经度
|
||||
* @param maxLongitude 最大经度
|
||||
* @param minLatitude 最小纬度
|
||||
* @param maxLatitude 最大纬度
|
||||
* @return 景区列表
|
||||
*/
|
||||
List<Tourism> findTourismsByBounds(BigDecimal minLongitude, BigDecimal maxLongitude,
|
||||
BigDecimal minLatitude, BigDecimal maxLatitude);
|
||||
|
||||
/**
|
||||
* 更新景区经纬度信息
|
||||
* @param id 景区ID
|
||||
* @param longitude 经度
|
||||
* @param latitude 纬度
|
||||
* @return 更新结果
|
||||
*/
|
||||
Result updateTourismLocation(Long id, BigDecimal longitude, BigDecimal latitude);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -31,7 +31,7 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
statistics.setChartStats(getChartStatistics(params));
|
||||
|
||||
// 3. 获取筛选选项
|
||||
statistics.setFilterOptions(getFilterOptions());
|
||||
statistics.setFilterOptions(getFilterOptions(params));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取仪表盘统计数据失败", e);
|
||||
@@ -102,17 +102,17 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
/**
|
||||
* 获取筛选选项
|
||||
*/
|
||||
private FilterOptions getFilterOptions() {
|
||||
private FilterOptions getFilterOptions(Map<String, Object> params) {
|
||||
FilterOptions options = new FilterOptions();
|
||||
|
||||
// 获取景区列表
|
||||
options.setTourismList(dashboardMapper.getTourismOptions());
|
||||
|
||||
// 获取二维码列表
|
||||
options.setQrcodeList(dashboardMapper.getQrcodeOptions());
|
||||
options.setQrcodeList(dashboardMapper.getQrcodeOptions(params));
|
||||
|
||||
// 获取设备列表
|
||||
options.setDeviceList(dashboardMapper.getDeviceOptions());
|
||||
options.setDeviceList(dashboardMapper.getDeviceOptions(params));
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
+5
@@ -187,6 +187,7 @@ public class MediaServiceImpl implements IMediaService {
|
||||
Map<String, String> clips = new HashMap<>();
|
||||
List<OrderFile> videoFiles = taskData.getVideoFiles();
|
||||
//@TODO 后期需要通过模板参数进行动态设置clips参数
|
||||
|
||||
clips.put("1", fileCenterService.getViewUrlByPath(videoFiles.get(4).getFilePath()));
|
||||
clips.put("2", fileCenterService.getViewUrlByPath(videoFiles.get(5).getFilePath()));
|
||||
clips.put("3", fileCenterService.getViewUrlByPath(videoFiles.get(6).getFilePath()));
|
||||
@@ -195,6 +196,10 @@ public class MediaServiceImpl implements IMediaService {
|
||||
clips.put("6", fileCenterService.getViewUrlByPath(videoFiles.get(2).getFilePath()));
|
||||
clips.put("7", fileCenterService.getViewUrlByPath(videoFiles.get(3).getFilePath()));
|
||||
|
||||
if (taskData.getVideoFiles().size() > 7) {
|
||||
clips.put("8", fileCenterService.getViewUrlByPath(videoFiles.get(7).getFilePath()));
|
||||
}
|
||||
|
||||
return JSON.toJSONString(clips);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("构建剪辑参数失败: " + e.getMessage());
|
||||
|
||||
+33
-7
@@ -3,14 +3,15 @@ package com.central.order.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
import com.central.common.lock.DistributedLock;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.SysUser;
|
||||
import com.central.common.service.impl.SuperServiceImpl;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
import com.central.order.event.OrderStatusChangeEvent;
|
||||
import com.central.order.feign.UserCenterService;
|
||||
import com.central.order.feign.FileCenterService;
|
||||
import com.central.order.feign.UserCenterService;
|
||||
import com.central.order.mapper.OrderFileMapper;
|
||||
import com.central.order.mapper.OrderMapper;
|
||||
import com.central.order.mapper.TourismFileMapper;
|
||||
@@ -127,14 +128,33 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
// 检查并处理订单超时逻辑,5分钟超时后自动取消
|
||||
@Override
|
||||
public void checkAndHandleOrderTimeout() {
|
||||
log.info("开始检查订单超时情况");
|
||||
|
||||
List<Order> orders = baseMapper.getOrdersByStatus(OrderStatus.UNPAID.getId());
|
||||
log.info("查询到 {} 个待支付订单", orders.size());
|
||||
|
||||
long currentTime = new Date().getTime();
|
||||
int timeoutCount = 0;
|
||||
|
||||
for (Order order : orders) {
|
||||
long elapsedTime = currentTime - order.getCreateTime().getTime();
|
||||
if (TimeUnit.MILLISECONDS.toMinutes(elapsedTime) >= 5) {
|
||||
long elapsedMinutes = TimeUnit.MILLISECONDS.toMinutes(elapsedTime);
|
||||
|
||||
log.info("订单检查: orderNo={}, createTime={}, elapsedMinutes={}, userId={}, tourismId={}",
|
||||
order.getOrderNo(),
|
||||
order.getCreateTime(),
|
||||
elapsedMinutes,
|
||||
order.getUserId(),
|
||||
order.getTourismId());
|
||||
|
||||
if (elapsedMinutes >= 5) {
|
||||
log.info("订单超时,准备取消: orderNo={}, elapsedMinutes={}", order.getOrderNo(), elapsedMinutes);
|
||||
baseMapper.updateOrderStatus(order.getId(), OrderStatus.CANCELED.getId());
|
||||
timeoutCount++;
|
||||
}
|
||||
}
|
||||
|
||||
log.info("订单超时检查完成: 总订单数={}, 超时取消数={}", orders.size(), timeoutCount);
|
||||
}
|
||||
|
||||
// 获取所有处于排队状态的订单,用于后续按顺序处理
|
||||
@@ -176,12 +196,18 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
@Override
|
||||
public boolean updateOrder(Order order) {
|
||||
try {
|
||||
|
||||
log.info("更新订单状态时租户ID: tenantId={}", TenantContextHolder.getTenant());
|
||||
|
||||
// 获取原订单信息
|
||||
Order oldOrder = getById(order.getId());
|
||||
boolean result = super.saveOrUpdateIdempotency(order, lock,
|
||||
ORDER_LOCK + order.getOrderNo(),
|
||||
new QueryWrapper<Order>().eq("order_no", order.getOrderNo()),
|
||||
"订单已存在");
|
||||
if (oldOrder == null) {
|
||||
log.error("订单不存在,无法更新: orderId={}", order.getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
// 使用updateById进行更新,避免INSERT操作
|
||||
boolean result = updateById(order);
|
||||
|
||||
// 如果更新成功且状态发生变化,发布事件
|
||||
if (result && !order.getOrderStatus().equals(oldOrder.getOrderStatus())) {
|
||||
@@ -206,7 +232,7 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("更新订单失败", e);
|
||||
log.error("更新订单失败: orderId={}, orderNo={}", order.getId(), order.getOrderNo(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
+121
-1
@@ -6,16 +6,22 @@ import com.central.common.model.Result;
|
||||
import com.central.common.service.impl.SuperServiceImpl;
|
||||
import com.central.order.mapper.TourismMapper;
|
||||
import com.central.order.model.Tourism;
|
||||
import com.central.order.model.TourismWithDistance;
|
||||
import com.central.order.model.TourismFile;
|
||||
import com.central.order.service.ITourismService;
|
||||
import com.central.order.service.ITourismFileService;
|
||||
import com.central.order.feign.FileCenterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Order information
|
||||
* 景区信息服务实现类
|
||||
*
|
||||
* @author lsl
|
||||
* @date 2024-12-19 17:52:54
|
||||
@@ -24,6 +30,12 @@ import java.util.Map;
|
||||
@Service
|
||||
public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism> implements ITourismService {
|
||||
|
||||
@Autowired
|
||||
private ITourismFileService tourismFileService;
|
||||
|
||||
@Autowired
|
||||
private FileCenterService fileCenterService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param params
|
||||
@@ -52,4 +64,112 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
||||
return baseMapper.getDevicesByTourismId(tourismId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit) {
|
||||
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}", longitude, latitude, radius, limit);
|
||||
|
||||
// 参数验证
|
||||
if (longitude == null || latitude == null) {
|
||||
log.warn("经纬度参数不能为空");
|
||||
return List.of();
|
||||
}
|
||||
|
||||
if (radius == null || radius <= 0) {
|
||||
radius = 1000.0; // 默认10公里
|
||||
}
|
||||
|
||||
if (limit == null || limit <= 0) {
|
||||
limit = 20; // 默认返回20个
|
||||
}
|
||||
|
||||
List<TourismWithDistance> tourisms = baseMapper.findNearbyTourisms(longitude, latitude, radius, limit);
|
||||
log.info("查询到附近景区数量: {}", tourisms.size());
|
||||
|
||||
// 为每个景区添加订单展示图片
|
||||
for (TourismWithDistance tourism : tourisms) {
|
||||
try {
|
||||
// 查询景区的订单展示图片(type=6)
|
||||
List<TourismFile> tourismFiles = tourismFileService.getByTourismId(tourism.getId());
|
||||
if (tourismFiles != null && !tourismFiles.isEmpty()) {
|
||||
// 查找订单展示图(type=6)
|
||||
TourismFile orderShowFile = tourismFiles.stream()
|
||||
.filter(file -> file.getType() == 6)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (orderShowFile != null && orderShowFile.getImageUrl() != null) {
|
||||
// 获取图片的完整URL
|
||||
String imageUrl = fileCenterService.getViewUrlByPath(orderShowFile.getImageUrl());
|
||||
tourism.setOrderShowImageUrl(imageUrl);
|
||||
log.debug("景区 {} 设置订单展示图片: {}", tourism.getTourismName(), imageUrl);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("获取景区 {} 订单展示图片失败: {}", tourism.getTourismName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return tourisms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tourism> findTourismsByBounds(BigDecimal minLongitude, BigDecimal maxLongitude,
|
||||
BigDecimal minLatitude, BigDecimal maxLatitude) {
|
||||
log.info("根据经纬度范围查询景区,经度范围: [{}, {}], 纬度范围: [{}, {}]",
|
||||
minLongitude, maxLongitude, minLatitude, maxLatitude);
|
||||
|
||||
// 参数验证
|
||||
if (minLongitude == null || maxLongitude == null || minLatitude == null || maxLatitude == null) {
|
||||
log.warn("经纬度范围参数不能为空");
|
||||
return List.of();
|
||||
}
|
||||
|
||||
List<Tourism> tourisms = baseMapper.findTourismsByBounds(minLongitude, maxLongitude, minLatitude, maxLatitude);
|
||||
log.info("查询到景区数量: {}", tourisms.size());
|
||||
|
||||
return tourisms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateTourismLocation(Long id, BigDecimal longitude, BigDecimal latitude) {
|
||||
log.info("更新景区经纬度信息,景区ID: {}, 经度: {}, 纬度: {}", id, longitude, latitude);
|
||||
|
||||
// 参数验证
|
||||
if (id == null) {
|
||||
return Result.failed("景区ID不能为空");
|
||||
}
|
||||
|
||||
if (longitude == null || latitude == null) {
|
||||
return Result.failed("经纬度不能为空");
|
||||
}
|
||||
|
||||
// 验证经纬度范围
|
||||
if (longitude.compareTo(BigDecimal.valueOf(-180)) < 0 || longitude.compareTo(BigDecimal.valueOf(180)) > 0) {
|
||||
return Result.failed("经度范围应在-180到180之间");
|
||||
}
|
||||
|
||||
if (latitude.compareTo(BigDecimal.valueOf(-90)) < 0 || latitude.compareTo(BigDecimal.valueOf(90)) > 0) {
|
||||
return Result.failed("纬度范围应在-90到90之间");
|
||||
}
|
||||
|
||||
// 查询景区是否存在
|
||||
Tourism tourism = getById(id);
|
||||
if (tourism == null) {
|
||||
return Result.failed("景区不存在");
|
||||
}
|
||||
|
||||
// 更新经纬度
|
||||
tourism.setLongitude(longitude);
|
||||
tourism.setLatitude(latitude);
|
||||
|
||||
boolean result = updateById(tourism);
|
||||
if (result) {
|
||||
log.info("景区经纬度更新成功,景区ID: {}", id);
|
||||
return Result.succeed(tourism, "经纬度更新成功");
|
||||
} else {
|
||||
log.error("景区经纬度更新失败,景区ID: {}", id);
|
||||
return Result.failed("经纬度更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ knife4j:
|
||||
zlt:
|
||||
#多租户配置
|
||||
tenant:
|
||||
enable: false
|
||||
enable: true
|
||||
ignoreTables:
|
||||
- edit_task
|
||||
- home_carousel
|
||||
@@ -40,16 +40,13 @@ zlt:
|
||||
- profit_sharing
|
||||
- order_statistics
|
||||
ignoreSqls:
|
||||
# 查询全部列表
|
||||
# - com.central.order.mapper.OrderMapper.findList
|
||||
# 获取某个订单
|
||||
# - com.central.order.mapper.OrderMapper.getOrderByNumber
|
||||
noIgnoreSqls:
|
||||
- com.central.order.mapper.OrderMapper.findList
|
||||
- com.central.order.mapper.TourismMapper.findList
|
||||
- com.central.order.mapper.OrderFileMapper.findList
|
||||
- com.central.order.mapper.QrCodeMapper.findList
|
||||
- com.central.order.mapper.QrCodeMapper.save
|
||||
# 移除所有ignoreSqls配置,让所有SQL都经过租户过滤处理
|
||||
# 这样webApp租户的特殊处理逻辑才能生效
|
||||
# 该接口是白名单接口查询中的逻辑,来例如:机库直接创建数据没有携带租户ID
|
||||
- com.central.order.mapper.OrderMapper.getOrderByNumber
|
||||
- com.central.order.mapper.OrderMapper.getOrdersByStatus
|
||||
# update和delete类型的操作mybatisPlus不支持,原因是数据隔离级别
|
||||
# - com.central.order.mapper.OrderMapper.updateOrderStatus
|
||||
# 微信支付商户号
|
||||
tencent:
|
||||
merchantId: ${zlt.wxpay.merchantId}
|
||||
@@ -88,7 +85,7 @@ tencent:
|
||||
file:
|
||||
oss-url: goflyapp.oss-cn-beijing.aliyuncs.com
|
||||
cdn-url: cdn.goflytec.com
|
||||
style: image/resize,m_mfit,w_300,h_250
|
||||
style: image/resize,m_mfit,w_218,h_160
|
||||
#审计日志
|
||||
# audit-log:
|
||||
# enabled: true
|
||||
@@ -140,4 +137,4 @@ cdn:
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.central.order.controller.OrderFileController: DEBUG
|
||||
com.central.order.controller.OrderFileController: DEBUG
|
||||
|
||||
@@ -4,10 +4,10 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: order-center
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# ip: 81.70.164.178
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 81.70.164.178
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<!-- 动态获取参数采用备参 -->
|
||||
<select id="findListByUser" resultType="com.central.order.model.Order">
|
||||
select id,order_no,tourism_id,device_sn,workspace_id,code_id,user_id,order_amount,order_status,create_time,update_time from orders t WHERE t.user_id = #{param2.userId}
|
||||
and t.is_del = 0
|
||||
<if test="param2.orderStatusList != null and param2.orderStatusList.size() > 0">
|
||||
and t.order_status in
|
||||
<foreach collection="param2.orderStatusList" item="status" open="(" separator="," close=")">
|
||||
|
||||
@@ -36,4 +36,42 @@
|
||||
AND t.is_del = 0
|
||||
ORDER BY q.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询附近景区列表 -->
|
||||
<select id="findNearbyTourisms" resultType="com.central.order.model.TourismWithDistance">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
*,
|
||||
(
|
||||
6371 * acos(
|
||||
cos(radians(#{latitude})) *
|
||||
cos(radians(latitude)) *
|
||||
cos(radians(longitude) - radians(#{longitude})) +
|
||||
sin(radians(#{latitude})) *
|
||||
sin(radians(latitude))
|
||||
)
|
||||
) AS distance
|
||||
FROM tourisms
|
||||
WHERE is_del = 0
|
||||
AND status = 1
|
||||
AND longitude IS NOT NULL
|
||||
AND latitude IS NOT NULL
|
||||
HAVING distance <= #{radius}
|
||||
ORDER BY distance ASC
|
||||
]]>
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据经纬度范围查询景区 -->
|
||||
<select id="findTourismsByBounds" resultType="com.central.order.model.Tourism">
|
||||
SELECT * FROM tourisms
|
||||
WHERE is_del = 0
|
||||
AND status = 1
|
||||
AND longitude BETWEEN #{minLongitude} AND #{maxLongitude}
|
||||
AND latitude BETWEEN #{minLatitude} AND #{maxLatitude}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user