fix(订单中心):首页统计优化,优惠券创建逻辑完善
This commit is contained in:
+77
-3
@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -1236,10 +1237,83 @@ public class CouponController {
|
||||
return buildErrorResponse(request, "0003", "订单项为空");
|
||||
}
|
||||
|
||||
// 创建优惠券(这里需要根据实际的优惠券创建逻辑来调整)
|
||||
// 创建优惠券
|
||||
String otaOrderId = "CTRIP_" + System.currentTimeMillis();
|
||||
// TODO: 实现具体的优惠券创建逻辑
|
||||
boolean success = true; // 临时设置为true,实际需要实现具体的创建逻辑
|
||||
|
||||
// 从订单信息中提取优惠券创建所需的数据
|
||||
boolean success = false;
|
||||
String userPhone = null;
|
||||
String ctripCouponId = null;
|
||||
String couponName = null;
|
||||
BigDecimal amount = null;
|
||||
BigDecimal minAmount = null;
|
||||
Integer discountRate = null;
|
||||
Date validStartTime = null;
|
||||
Date validEndTime = null;
|
||||
|
||||
try {
|
||||
// 从订单项中提取用户信息
|
||||
if (body.getItems() != null && !body.getItems().isEmpty()) {
|
||||
CtripOrderItem item = body.getItems().get(0);
|
||||
|
||||
// 提取乘客信息作为用户信息
|
||||
if (item.getPassengers() != null && !item.getPassengers().isEmpty()) {
|
||||
CtripPassenger passenger = item.getPassengers().get(0);
|
||||
userPhone = passenger.getMobile();
|
||||
log.info("从乘客信息中提取到用户手机号: {}", userPhone);
|
||||
}
|
||||
|
||||
// 提取联系人信息作为备选
|
||||
if (userPhone == null && body.getContacts() != null && !body.getContacts().isEmpty()) {
|
||||
CtripContact contact = body.getContacts().get(0);
|
||||
userPhone = contact.getMobile();
|
||||
log.info("从联系人信息中提取到用户手机号: {}", userPhone);
|
||||
}
|
||||
|
||||
// 生成携程优惠券ID
|
||||
ctripCouponId = "CTRIP_COUPON_" + System.currentTimeMillis() + "_" + (userPhone != null ? userPhone.hashCode() : "UNKNOWN");
|
||||
|
||||
// 设置优惠券基本信息
|
||||
couponName = "携程优惠券";
|
||||
amount = new BigDecimal("10.00"); // 默认优惠券面额10元
|
||||
minAmount = new BigDecimal("50.00"); // 默认使用门槛50元
|
||||
discountRate = null; // 满减券不使用折扣率
|
||||
|
||||
// 设置有效期(默认30天)
|
||||
Date now = new Date();
|
||||
validStartTime = now;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(now);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, 30);
|
||||
validEndTime = calendar.getTime();
|
||||
|
||||
log.info("准备创建携程优惠券 - userPhone: {}, ctripCouponId: {}, couponName: {}, amount: {}, minAmount: {}",
|
||||
userPhone, ctripCouponId, couponName, amount, minAmount);
|
||||
|
||||
// 调用优惠券服务创建优惠券
|
||||
if (userPhone != null) {
|
||||
success = couponService.createCouponFromCtrip(
|
||||
ctripCouponId, userPhone, couponName, 1, // 1表示满减券
|
||||
amount, minAmount, discountRate, validStartTime, validEndTime
|
||||
);
|
||||
|
||||
if (success) {
|
||||
log.info("携程优惠券创建成功 - ctripCouponId: {}, userPhone: {}", ctripCouponId, userPhone);
|
||||
} else {
|
||||
log.error("携程优惠券创建失败 - ctripCouponId: {}, userPhone: {}", ctripCouponId, userPhone);
|
||||
}
|
||||
} else {
|
||||
log.error("无法提取用户手机号,无法创建优惠券");
|
||||
return buildErrorResponse(request, "0006", "无法提取用户手机号");
|
||||
}
|
||||
} else {
|
||||
log.error("订单项为空,无法创建优惠券");
|
||||
return buildErrorResponse(request, "0007", "订单项为空");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("创建携程优惠券时发生异常: {}", e.getMessage(), e);
|
||||
return buildErrorResponse(request, "0008", "创建优惠券时发生异常: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (success) {
|
||||
log.info("携程优惠券创建成功,OTA订单ID: {}", otaOrderId);
|
||||
|
||||
+11
-2
@@ -897,8 +897,17 @@ public class OrderController {
|
||||
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));
|
||||
|
||||
// 视频缩略图使用图片的缩略图
|
||||
if (!imgList.isEmpty()) {
|
||||
// 使用第一张图片的缩略图作为视频缩略图
|
||||
String thumbnailUrl = imgList.get(0).get("viewUrl");
|
||||
videoMap.put("viewUrl", thumbnailUrl);
|
||||
} else {
|
||||
// 如果没有图片,则使用默认缩略图或空值
|
||||
videoMap.put("viewUrl", null);
|
||||
}
|
||||
|
||||
videoList.add(videoMap);
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
|
||||
+5
-3
@@ -21,6 +21,7 @@ public interface DashboardMapper {
|
||||
"<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)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -50,6 +51,7 @@ public interface DashboardMapper {
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND DATE(o.create_time) = CURDATE()",
|
||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -177,7 +179,7 @@ public interface DashboardMapper {
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status IN (1, 4, 3, 5)",
|
||||
"AND o.order_status IN (1, 3, 4, 7, 5)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -206,7 +208,7 @@ public interface DashboardMapper {
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status IN (1, 4, 3, 5)",
|
||||
"AND o.order_status IN (1, 3, 4, 7, 5)",
|
||||
"AND DATE(o.create_time) = CURDATE()",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
@@ -551,7 +553,7 @@ public interface DashboardMapper {
|
||||
" q.code_id as qrcodeId,",
|
||||
" COUNT(o.id) as orderCount",
|
||||
"FROM qrcodes q",
|
||||
"LEFT JOIN orders o ON q.code_id = o.code_id",
|
||||
"LEFT JOIN orders o ON q.code_id = o.code_id AND o.order_status = 3",
|
||||
"WHERE q.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
|
||||
Reference in New Issue
Block a user