|
@@ -488,13 +488,30 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
log.info("根据开门记录创建订单 - activityId: {}, deviceId: {}, userId: {}",
|
|
log.info("根据开门记录创建订单 - activityId: {}, deviceId: {}, userId: {}",
|
|
|
activityId, record.getDeviceId(), record.getUserId());
|
|
activityId, record.getDeviceId(), record.getUserId());
|
|
|
|
|
|
|
|
|
|
+ // 提前从 Redis 读取支付分预授权信息,以便 INSERT 时直接写入
|
|
|
|
|
+ String payScoreOrderId = null;
|
|
|
|
|
+ String payScoreState = null;
|
|
|
|
|
+ String serviceId = null;
|
|
|
|
|
+ if (payScoreService != null) {
|
|
|
|
|
+ com.alibaba.fastjson2.JSONObject preAuth = ((com.haha.service.payment.payscore.impl.PayScoreServiceImpl) payScoreService)
|
|
|
|
|
+ .readPreAuthFromRedis(record.getDeviceId(), record.getUserId());
|
|
|
|
|
+ if (preAuth != null) {
|
|
|
|
|
+ payScoreOrderId = preAuth.getString("payScoreOrderId");
|
|
|
|
|
+ payScoreState = preAuth.getString("payScoreState");
|
|
|
|
|
+ serviceId = preAuth.getString("serviceId");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Order newOrder = orderService.createOrderFromRecognition(
|
|
Order newOrder = orderService.createOrderFromRecognition(
|
|
|
activityId,
|
|
activityId,
|
|
|
record.getDeviceId(),
|
|
record.getDeviceId(),
|
|
|
String.valueOf(record.getUserId()),
|
|
String.valueOf(record.getUserId()),
|
|
|
skuListStr,
|
|
skuListStr,
|
|
|
resourceInfoStr,
|
|
resourceInfoStr,
|
|
|
- confidence
|
|
|
|
|
|
|
+ confidence,
|
|
|
|
|
+ payScoreOrderId,
|
|
|
|
|
+ payScoreState,
|
|
|
|
|
+ serviceId
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
// 关联开门记录和订单
|
|
// 关联开门记录和订单
|
|
@@ -502,7 +519,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
doorRecordService.linkOrderId(activityId, newOrder.getId());
|
|
doorRecordService.linkOrderId(activityId, newOrder.getId());
|
|
|
log.info("订单创建成功并已关联开门记录 - orderId: {}", newOrder.getId());
|
|
log.info("订单创建成功并已关联开门记录 - orderId: {}", newOrder.getId());
|
|
|
|
|
|
|
|
- // 从 Redis 获取预创建的支付分信息并关联到订单(需确认模式)
|
|
|
|
|
|
|
+ // 清理 Redis 中的预授权信息(如果订单已有支付分信息,仅删 Redis;否则尝试补齐)
|
|
|
tryApplyPreAuthPayScore(newOrder);
|
|
tryApplyPreAuthPayScore(newOrder);
|
|
|
} else {
|
|
} else {
|
|
|
log.error("订单创建失败 - activityId: {}", activityId);
|
|
log.error("订单创建失败 - activityId: {}", activityId);
|
|
@@ -518,12 +535,11 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
if (order == null) {
|
|
if (order == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- // 已有支付分信息,无需重复关联
|
|
|
|
|
- if (order.getPayScoreOrderId() != null) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
if (payScoreService == null) {
|
|
if (payScoreService == null) {
|
|
|
- log.warn("[支付分配置] payScoreService 未注入,跳过关联 - orderId: {}", order.getId());
|
|
|
|
|
|
|
+ // 仅当订单缺少支付分信息时才打 WARN,已有则无需告警
|
|
|
|
|
+ if (order.getPayScoreOrderId() == null) {
|
|
|
|
|
+ log.warn("[支付分配置] payScoreService 未注入,跳过关联 - orderId: {}", order.getId());
|
|
|
|
|
+ }
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
@@ -1063,8 +1079,23 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
String resourceInfoStr = extractParam(recognizeResult, "resource_info");
|
|
String resourceInfoStr = extractParam(recognizeResult, "resource_info");
|
|
|
BigDecimal confidence = parseBigDecimal(recognizeResult.get("confidence"));
|
|
BigDecimal confidence = parseBigDecimal(recognizeResult.get("confidence"));
|
|
|
|
|
|
|
|
|
|
+ // 提前从 Redis 读取支付分预授权信息
|
|
|
|
|
+ String payScoreOrderId = null;
|
|
|
|
|
+ String payScoreState = null;
|
|
|
|
|
+ String serviceId = null;
|
|
|
|
|
+ if (payScoreService != null && deviceId != null && userId != null) {
|
|
|
|
|
+ com.alibaba.fastjson2.JSONObject preAuth = ((com.haha.service.payment.payscore.impl.PayScoreServiceImpl) payScoreService)
|
|
|
|
|
+ .readPreAuthFromRedis(deviceId, Long.parseLong(userId));
|
|
|
|
|
+ if (preAuth != null) {
|
|
|
|
|
+ payScoreOrderId = preAuth.getString("payScoreOrderId");
|
|
|
|
|
+ payScoreState = preAuth.getString("payScoreState");
|
|
|
|
|
+ serviceId = preAuth.getString("serviceId");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Order order = orderService.createOrderFromRecognition(
|
|
Order order = orderService.createOrderFromRecognition(
|
|
|
- activityId, deviceId, userId, skuListStr, resourceInfoStr, confidence);
|
|
|
|
|
|
|
+ activityId, deviceId, userId, skuListStr, resourceInfoStr, confidence,
|
|
|
|
|
+ payScoreOrderId, payScoreState, serviceId);
|
|
|
|
|
|
|
|
if (order != null) {
|
|
if (order != null) {
|
|
|
log.info("主动创建订单成功 - orderId: {}, activityId: {}", order.getId(), activityId);
|
|
log.info("主动创建订单成功 - orderId: {}, activityId: {}", order.getId(), activityId);
|