|
|
@@ -74,7 +74,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
|
|
|
@Override
|
|
|
public void handleMessage(Map<String, Object> params) {
|
|
|
- String notifyType = (String) params.get("notify_type");
|
|
|
+ String notifyType = extractParam(params, "notify_type");
|
|
|
if (notifyType == null || notifyType.isEmpty()) {
|
|
|
log.warn("消息回调缺少 notify_type 参数");
|
|
|
return;
|
|
|
@@ -108,11 +108,11 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void handleDeviceStatus(Map<String, Object> params) {
|
|
|
try {
|
|
|
- String activityId = (String) params.get("activity_id");
|
|
|
- String deviceId = (String) params.get("device_id");
|
|
|
- String doorStatus = (String) params.get("status");
|
|
|
- String openType = (String) params.get("open_type");
|
|
|
- String outUserId = (String) params.get("out_user_id");
|
|
|
+ String activityId = extractParam(params, "activity_id");
|
|
|
+ String deviceId = extractParam(params, "device_id");
|
|
|
+ String doorStatus = extractParam(params, "status");
|
|
|
+ String openType = extractParam(params, "open_type");
|
|
|
+ String outUserId = extractParam(params, "out_user_id");
|
|
|
|
|
|
log.info("开关门状态通知 - 设备: {}, 状态: {}, 类型: {}, 用户: {}",
|
|
|
deviceId, doorStatus, openType, outUserId);
|
|
|
@@ -126,8 +126,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
log.info("设备 {} 开门成功", deviceId);
|
|
|
break;
|
|
|
case CLOSED:
|
|
|
- log.info("设备 {} 关门成功,等待 AI 识别", deviceId);
|
|
|
- // 更新开门记录为已关门状态
|
|
|
+ log.info("设备 {} 关门成功,等待 AI 识别", deviceId);
|
|
|
if (activityId != null && !activityId.isEmpty()) {
|
|
|
doorRecordService.updateDoorClosed(activityId);
|
|
|
}
|
|
|
@@ -151,9 +150,8 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
@Override
|
|
|
public void handleOnlineStatus(Map<String, Object> params) {
|
|
|
try {
|
|
|
- String deviceId = (String) params.get("device_id");
|
|
|
- Object onlineObj = params.get("is_online");
|
|
|
- Integer isOnline = parseInteger(onlineObj);
|
|
|
+ String deviceId = extractParam(params, "device_id");
|
|
|
+ Integer isOnline = parseInteger(params.get("is_online"));
|
|
|
|
|
|
if (isOnline == null) {
|
|
|
log.warn("设备在线状态为空 - 设备: {}", deviceId);
|
|
|
@@ -173,9 +171,8 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
@Override
|
|
|
public void handleVoiceResult(Map<String, Object> params) {
|
|
|
try {
|
|
|
- String deviceId = (String) params.get("device_id");
|
|
|
- Object voiceObj = params.get("voice");
|
|
|
- Integer voice = parseInteger(voiceObj);
|
|
|
+ String deviceId = extractParam(params, "device_id");
|
|
|
+ Integer voice = parseInteger(params.get("voice"));
|
|
|
|
|
|
if (voice == null) {
|
|
|
log.warn("音量值为空 - 设备: {}", deviceId);
|
|
|
@@ -195,19 +192,18 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
@Override
|
|
|
public void handleNewProductAudit(Map<String, Object> params) {
|
|
|
try {
|
|
|
- String id = (String) params.get("id");
|
|
|
- Object statusObj = params.get("status");
|
|
|
- Integer status = parseInteger(statusObj);
|
|
|
- String name = (String) params.get("name");
|
|
|
- String code = (String) params.get("code");
|
|
|
- String barCode = (String) params.get("bar_code");
|
|
|
- String rejectReason = (String) params.get("reject_reason");
|
|
|
-
|
|
|
- log.info("新品审核结果 - ID: {}, 商品名: {}, 状态: {}, code: {}, barCode: {}",
|
|
|
+ String id = extractParam(params, "id");
|
|
|
+ Integer status = parseInteger(params.get("status"));
|
|
|
+ String name = extractParam(params, "name");
|
|
|
+ String code = extractParam(params, "code");
|
|
|
+ String barCode = extractParam(params, "bar_code");
|
|
|
+ String rejectReason = extractParam(params, "reject_reason");
|
|
|
+
|
|
|
+ log.info("新品审核结果 - ID: {}, 商品名: {}, 状态: {}, code: {}, barCode: {}",
|
|
|
id, name, status, code, barCode);
|
|
|
|
|
|
if (status != null && status == ProductAuditStatus.REJECTED.getCode()) {
|
|
|
- log.warn("新品 {} 被拒绝,原因: {}", name, rejectReason);
|
|
|
+ log.warn("新品 {} 被拒绝,原因: {}", name, rejectReason);
|
|
|
}
|
|
|
|
|
|
newProductApplyService.updateByCallback(id, status, code, rejectReason);
|
|
|
@@ -227,9 +223,9 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
private void syncProductToMerchant(String code, String name) {
|
|
|
try {
|
|
|
log.info("开始同步商品到商家商品库 - code: {}, name: {}", code, name);
|
|
|
-
|
|
|
+
|
|
|
boolean success = hahaClient.getGoodsApi().addToMerchant(code);
|
|
|
-
|
|
|
+
|
|
|
if (success) {
|
|
|
log.info("商品同步成功 - code: {}, name: {}", code, name);
|
|
|
} else {
|
|
|
@@ -270,86 +266,147 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void handleOrcResult(Map<String, Object> params) {
|
|
|
- try {
|
|
|
- String activityId = (String) params.get("activity_id");
|
|
|
- String deviceId = (String) params.get("device_id");
|
|
|
- String userId = (String) params.get("out_user_id");
|
|
|
- Integer nobuy = parseInteger(params.get("nobuy"));
|
|
|
- String resultStr = (String) params.get("result");
|
|
|
- String skuListStr = (String) params.get("sku_list");
|
|
|
- String resourceInfoStr = (String) params.get("resource_info");
|
|
|
-
|
|
|
- log.info("AI识别结果通知 - 设备: {}, 活动: {}, 是否消费: {}",
|
|
|
+ String activityId = extractParam(params, "activity_id");
|
|
|
+ String deviceId = extractParam(params, "device_id");
|
|
|
+ String userId = extractParam(params, "out_user_id");
|
|
|
+ Integer nobuy = parseInteger(params.get("nobuy"));
|
|
|
+ String resultStr = extractParam(params, "result");
|
|
|
+ String skuListStr = extractParam(params, "sku_list");
|
|
|
+ String resourceInfoStr = extractParam(params, "resource_info");
|
|
|
+
|
|
|
+ // 参数验证
|
|
|
+ if (!validateRequiredParams(activityId, deviceId, userId)) {
|
|
|
+ log.warn("AI识别结果通知缺少必要参数 - activityId: {}, deviceId: {}, userId: {}",
|
|
|
+ activityId, deviceId, userId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("AI识别结果通知 - 设备: {}, 活动: {}, 是否消费: {}",
|
|
|
deviceId, activityId, RecognizeConsumeType.isNoConsume(nobuy) ? "无消费" : "有消费");
|
|
|
|
|
|
+ try {
|
|
|
+ // 保存识别结果到Redis
|
|
|
saveRecognizeResultToRedis(activityId, params);
|
|
|
|
|
|
- // 判断是否消费
|
|
|
+ // 处理无消费场景
|
|
|
if (RecognizeConsumeType.isNoConsume(nobuy)) {
|
|
|
- log.info("用户打开柜门但未消费,无需创建订单");
|
|
|
- // 标记无消费记录
|
|
|
- doorRecordService.markNoConsume(activityId);
|
|
|
- // 更新关门状态
|
|
|
- doorRecordService.updateDoorClosed(activityId);
|
|
|
+ handleNoConsume(activityId);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 识别结果置信度
|
|
|
+ // 处理有消费场景
|
|
|
BigDecimal confidence = parseBigDecimal(params.get("confidence"));
|
|
|
-
|
|
|
- // 【修改】先尝试从开门记录获取信息创建订单
|
|
|
- Order existingOrder = orderService.getOrderByActivityId(activityId);
|
|
|
- if (existingOrder == null) {
|
|
|
- // 尝试从数据库获取开门记录并创建订单
|
|
|
- DoorRecord record = doorRecordService.getByActivityId(activityId);
|
|
|
- if (record != null) {
|
|
|
- log.info("根据开门记录创建订单 - activityId: {}, deviceId: {}, userId: {}",
|
|
|
- activityId, record.getDeviceId(), record.getUserId());
|
|
|
-
|
|
|
- existingOrder = orderService.createOrderFromRecognition(
|
|
|
- activityId,
|
|
|
- record.getDeviceId(),
|
|
|
- String.valueOf(record.getUserId()),
|
|
|
- skuListStr,
|
|
|
- resourceInfoStr,
|
|
|
- confidence
|
|
|
- );
|
|
|
-
|
|
|
- // 关联开门记录和订单
|
|
|
- if (existingOrder != null) {
|
|
|
- doorRecordService.linkOrderId(activityId, existingOrder.getId());
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.warn("未找到开门记录 - activityId: {}", activityId);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (existingOrder != null) {
|
|
|
- log.info("更新订单信息 - activityId: {}, orderId: {}", activityId, existingOrder.getId());
|
|
|
- updateOrderFromRecognition(existingOrder, skuListStr, resourceInfoStr, confidence, activityId);
|
|
|
- logRecognizeResultDetails(resultStr, skuListStr, resourceInfoStr);
|
|
|
-
|
|
|
- // 更新关门状态和关联订单
|
|
|
- doorRecordService.updateDoorClosed(activityId);
|
|
|
- }
|
|
|
+ handleConsume(activityId, deviceId, userId, skuListStr, resourceInfoStr, resultStr, confidence);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- log.error("处理AI识别结果通知失败", e);
|
|
|
+ log.error("处理AI识别结果通知失败 - activityId: {}, deviceId: {}", activityId, deviceId, e);
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提取字符串参数
|
|
|
+ */
|
|
|
+ private String extractParam(Map<String, Object> params, String key) {
|
|
|
+ Object value = params.get(key);
|
|
|
+ return value != null ? value.toString() : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证必要参数
|
|
|
+ */
|
|
|
+ private boolean validateRequiredParams(String activityId, String deviceId, String userId) {
|
|
|
+ return activityId != null && !activityId.isEmpty()
|
|
|
+ && deviceId != null && !deviceId.isEmpty()
|
|
|
+ && userId != null && !userId.isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理无消费场景
|
|
|
+ */
|
|
|
+ private void handleNoConsume(String activityId) {
|
|
|
+ log.info("用户打开柜门但未消费,无需创建订单 - activityId: {}", activityId);
|
|
|
+ doorRecordService.markNoConsume(activityId);
|
|
|
+ doorRecordService.updateDoorClosed(activityId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理有消费场景
|
|
|
+ */
|
|
|
+ private void handleConsume(String activityId, String deviceId, String userId,
|
|
|
+ String skuListStr, String resourceInfoStr, String resultStr,
|
|
|
+ BigDecimal confidence) {
|
|
|
+
|
|
|
+ // 获取或创建订单
|
|
|
+ Order order = getOrCreateOrder(activityId, deviceId, userId, skuListStr, resourceInfoStr, confidence);
|
|
|
+ if (order == null) {
|
|
|
+ log.warn("无法获取或创建订单 - activityId: {}", activityId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新订单信息
|
|
|
+ updateOrderFromRecognition(order, skuListStr, resourceInfoStr, confidence, activityId);
|
|
|
+ logRecognizeResultDetails(resultStr, skuListStr, resourceInfoStr);
|
|
|
+
|
|
|
+ // 更新关门状态
|
|
|
+ doorRecordService.updateDoorClosed(activityId);
|
|
|
+ log.info("AI识别结果处理完成 - activityId: {}, orderId: {}", activityId, order.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取或创建订单
|
|
|
+ */
|
|
|
+ private Order getOrCreateOrder(String activityId, String deviceId, String userId,
|
|
|
+ String skuListStr, String resourceInfoStr, BigDecimal confidence) {
|
|
|
+ // 先尝试从数据库获取已有订单
|
|
|
+ Order existingOrder = orderService.getOrderByActivityId(activityId);
|
|
|
+ if (existingOrder != null) {
|
|
|
+ log.info("找到已有订单 - activityId: {}, orderId: {}", activityId, existingOrder.getId());
|
|
|
+ return existingOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 尝试从开门记录创建订单
|
|
|
+ DoorRecord record = doorRecordService.getByActivityId(activityId);
|
|
|
+ if (record == null) {
|
|
|
+ log.warn("未找到开门记录 - activityId: {}", activityId);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("根据开门记录创建订单 - activityId: {}, deviceId: {}, userId: {}",
|
|
|
+ activityId, record.getDeviceId(), record.getUserId());
|
|
|
+
|
|
|
+ Order newOrder = orderService.createOrderFromRecognition(
|
|
|
+ activityId,
|
|
|
+ record.getDeviceId(),
|
|
|
+ String.valueOf(record.getUserId()),
|
|
|
+ skuListStr,
|
|
|
+ resourceInfoStr,
|
|
|
+ confidence
|
|
|
+ );
|
|
|
+
|
|
|
+ // 关联开门记录和订单
|
|
|
+ if (newOrder != null) {
|
|
|
+ doorRecordService.linkOrderId(activityId, newOrder.getId());
|
|
|
+ log.info("订单创建成功并已关联开门记录 - orderId: {}", newOrder.getId());
|
|
|
+ } else {
|
|
|
+ log.error("订单创建失败 - activityId: {}", activityId);
|
|
|
}
|
|
|
+
|
|
|
+ return newOrder;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void handleOrderCallback(Map<String, Object> params) {
|
|
|
try {
|
|
|
- String orderId = (String) params.get("order_id");
|
|
|
- String deviceId = (String) params.get("device_id");
|
|
|
- String activityId = (String) params.get("activity_id");
|
|
|
- String userId = (String) params.get("user_id");
|
|
|
+ String orderId = extractParam(params, "order_id");
|
|
|
+ String deviceId = extractParam(params, "device_id");
|
|
|
+ String activityId = extractParam(params, "activity_id");
|
|
|
+ String userId = extractParam(params, "user_id");
|
|
|
Object orderMoney = params.get("order_money");
|
|
|
- String orderDetail = (String) params.get("order_detail");
|
|
|
- String orderName = (String) params.get("order_name");
|
|
|
- String orderGoodsStr = (String) params.get("order_goods");
|
|
|
+ String orderDetail = extractParam(params, "order_detail");
|
|
|
+ String orderName = extractParam(params, "order_name");
|
|
|
+ String orderGoodsStr = extractParam(params, "order_goods");
|
|
|
|
|
|
log.info("订单信息 - 订单号: {}, 设备: {}, 活动: {}, 用户: {}, 金额: {}, 商品: {}",
|
|
|
orderId, deviceId, activityId, userId, orderMoney, orderName);
|
|
|
@@ -360,7 +417,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
}
|
|
|
|
|
|
if (localOrder == null && userId != null && deviceId != null) {
|
|
|
- log.info("订单不存在,主动查询识别结果 - activityId: {}", activityId);
|
|
|
+ log.info("订单不存在,主动查询识别结果 - activityId: {}", activityId);
|
|
|
localOrder = fetchRecognitionAndCreateOrder(activityId, deviceId, userId);
|
|
|
}
|
|
|
|
|
|
@@ -370,7 +427,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
}
|
|
|
|
|
|
if (orderId != null && orderId.equals(localOrder.getOrderNo())) {
|
|
|
- log.info("订单已处理过,跳过更新 - orderId: {}", orderId);
|
|
|
+ log.info("订单已处理过,跳过更新 - orderId: {}", orderId);
|
|
|
saveOrderInfoToRedis(localOrder, activityId, orderId, orderMoney, orderDetail);
|
|
|
return;
|
|
|
}
|
|
|
@@ -378,7 +435,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
updateOrderFromCallback(localOrder, orderId, activityId, orderMoney, orderDetail, orderName, orderGoodsStr);
|
|
|
saveOrderInfoToRedis(localOrder, activityId, orderId, orderMoney, orderDetail);
|
|
|
|
|
|
- // 处理支付分扣费(如果订单使用了支付分)
|
|
|
+ // 处理支付分扣费(如果订单使用了支付分)
|
|
|
processPayScorePayment(localOrder, orderMoney);
|
|
|
|
|
|
|
|
|
@@ -389,7 +446,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
|
|
|
@Override
|
|
|
public boolean validateSign(Map<String, Object> params) {
|
|
|
- String receivedSign = (String) params.get("sign");
|
|
|
+ String receivedSign = extractParam(params, "sign");
|
|
|
if (receivedSign == null || receivedSign.isEmpty()) {
|
|
|
log.warn("签名参数为空");
|
|
|
return false;
|
|
|
@@ -416,6 +473,11 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存识别结果到Redis
|
|
|
+ * @param activityId
|
|
|
+ * @param params
|
|
|
+ */
|
|
|
private void saveRecognizeResultToRedis(String activityId, Map<String, Object> params) {
|
|
|
try {
|
|
|
String resultKey = RECOGNIZE_RESULT_KEY + activityId;
|
|
|
@@ -436,6 +498,11 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存订单信息到Redis
|
|
|
+ * @param order
|
|
|
+ * @param activityId
|
|
|
+ */
|
|
|
private void saveOrderInfoToRedis(Order order, String activityId) {
|
|
|
try {
|
|
|
String orderKey = ORDER_INFO_KEY + activityId;
|
|
|
@@ -461,6 +528,14 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 订单信息保存到Redis
|
|
|
+ * @param order
|
|
|
+ * @param activityId
|
|
|
+ * @param orderId
|
|
|
+ * @param orderMoney
|
|
|
+ * @param orderDetail
|
|
|
+ */
|
|
|
private void saveOrderInfoToRedis(Order order, String activityId, String orderId, Object orderMoney, String orderDetail) {
|
|
|
try {
|
|
|
String orderKey = ORDER_INFO_KEY + activityId;
|
|
|
@@ -559,7 +634,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
private void saveOrderGoods(Long orderId, String orderNo, String activityId,
|
|
|
String orderGoodsStr, String deviceId, Long userId) {
|
|
|
if (orderGoodsStr == null || orderGoodsStr.isEmpty()) {
|
|
|
- log.info("订单商品信息为空,跳过保存");
|
|
|
+ log.info("订单商品信息为空,跳过保存");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -583,7 +658,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
goods.setCode(goodsJson.getString("code"));
|
|
|
goods.setBarCode(goodsJson.getString("bar_code"));
|
|
|
goods.setProductName(goodsJson.getString("product_name"));
|
|
|
- // 处理图片链接:如果已经是完整 URL 则保持不变,否则添加域名前缀
|
|
|
+ // 处理图片链接:如果已经是完整 URL 则保持不变,否则添加域名前缀
|
|
|
String picUrl = goodsJson.getString("pic");
|
|
|
goods.setPic(normalizeImageUrl(picUrl));
|
|
|
goods.setProductNum(goodsJson.getInteger("product_num"));
|
|
|
@@ -610,7 +685,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
|
|
|
/**
|
|
|
* 标准化图片 URL
|
|
|
- * 如果图片链接已经是完整的 URL(包含 http://或 https://),则保持不变
|
|
|
+ * 如果图片链接已经是完整的 URL(包含 http://或 https://),则保持不变
|
|
|
* 否则添加配置的图片域名前缀
|
|
|
*
|
|
|
* @param picUrl 原始图片链接
|
|
|
@@ -620,12 +695,12 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
if (picUrl == null || picUrl.isEmpty()) {
|
|
|
return picUrl;
|
|
|
}
|
|
|
-
|
|
|
- // 如果已经是完整的 URL(以 http://或 https://开头),则直接返回
|
|
|
+
|
|
|
+ // 如果已经是完整的 URL(以 http://或 https://开头),则直接返回
|
|
|
if (picUrl.startsWith("http://") || picUrl.startsWith("https://")) {
|
|
|
return picUrl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 否则添加域名前缀
|
|
|
return commonConfig.getImageDomainPrefix() + picUrl;
|
|
|
}
|
|
|
@@ -634,10 +709,9 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
try {
|
|
|
Map<String, Object> recognizeResult = hahaClient.getOrderApi().getRecognizeResult(null, activityId);
|
|
|
if (recognizeResult != null) {
|
|
|
- String skuListStr = (String) recognizeResult.get("sku_list");
|
|
|
- String resourceInfoStr = (String) recognizeResult.get("resource_info");
|
|
|
- Object confidenceObj = recognizeResult.get("confidence");
|
|
|
- BigDecimal confidence = confidenceObj != null ? new BigDecimal(confidenceObj.toString()) : null;
|
|
|
+ String skuListStr = extractParam(recognizeResult, "sku_list");
|
|
|
+ String resourceInfoStr = extractParam(recognizeResult, "resource_info");
|
|
|
+ BigDecimal confidence = parseBigDecimal(recognizeResult.get("confidence"));
|
|
|
|
|
|
Order order = orderService.createOrderFromRecognition(
|
|
|
activityId, deviceId, userId, skuListStr, resourceInfoStr, confidence);
|
|
|
@@ -749,7 +823,7 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
|
|
|
/**
|
|
|
* 处理支付分扣费
|
|
|
- * 如果订单使用了微信支付分,调用支付分完结接口进行扣费
|
|
|
+ * 如果订单使用了微信支付分,调用支付分完结接口进行扣费
|
|
|
*
|
|
|
* @param order 订单对象
|
|
|
* @param orderMoney 订单金额
|
|
|
@@ -757,26 +831,26 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
private void processPayScorePayment(Order order, Object orderMoney) {
|
|
|
// 检查是否为支付分订单
|
|
|
if (order.getPayChannel() == null || !PaymentChannel.WECHAT_PAYSCORE.getCode().equals(order.getPayChannel())) {
|
|
|
- log.debug("订单未使用支付分,跳过扣费 - orderId: {}, payChannel: {}",
|
|
|
+ log.debug("订单未使用支付分,跳过扣费 - orderId: {}, payChannel: {}",
|
|
|
order.getId(), order.getPayChannel());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 检查支付分服务是否可用
|
|
|
if (payScoreService == null) {
|
|
|
- log.warn("支付分服务未初始化,无法处理扣费 - orderId: {}", order.getId());
|
|
|
+ log.warn("支付分服务未初始化,无法处理扣费 - orderId: {}", order.getId());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 检查是否已创建支付分服务订单
|
|
|
if (order.getPayScoreOrderId() == null) {
|
|
|
- log.warn("订单未创建支付分服务订单,无法扣费 - orderId: {}", order.getId());
|
|
|
+ log.warn("订单未创建支付分服务订单,无法扣费 - orderId: {}", order.getId());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 检查订单状态,避免重复扣费
|
|
|
+ // 检查订单状态,避免重复扣费
|
|
|
if (PayScoreState.isFinished(order.getPayScoreState())) {
|
|
|
- log.info("订单已完结或已取消,跳过扣费 - orderId: {}, payScoreState: {}",
|
|
|
+ log.info("订单已完结或已取消,跳过扣费 - orderId: {}, payScoreState: {}",
|
|
|
order.getId(), order.getPayScoreState());
|
|
|
return;
|
|
|
}
|