|
@@ -35,6 +35,7 @@ import com.haha.service.DoorRecordService;
|
|
|
import com.haha.service.UserCouponService;
|
|
import com.haha.service.UserCouponService;
|
|
|
import com.haha.service.CouponTemplateService;
|
|
import com.haha.service.CouponTemplateService;
|
|
|
import com.haha.service.config.DeviceAlertProperties;
|
|
import com.haha.service.config.DeviceAlertProperties;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.haha.service.payment.payscore.PayScoreCreateRequest;
|
|
import com.haha.service.payment.payscore.PayScoreCreateRequest;
|
|
|
import com.haha.service.payment.payscore.PayScoreResult;
|
|
import com.haha.service.payment.payscore.PayScoreResult;
|
|
|
import com.haha.service.payment.payscore.PayScoreService;
|
|
import com.haha.service.payment.payscore.PayScoreService;
|
|
@@ -419,10 +420,10 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 设置订单类型(OUT-拿出/IN-放入)
|
|
|
|
|
|
|
+ // 设置订单类型(OUT-拿出/IN-放入)- 选择性更新,不覆盖 payScoreOrderId
|
|
|
if (recognizeType != null && !recognizeType.isEmpty()) {
|
|
if (recognizeType != null && !recognizeType.isEmpty()) {
|
|
|
order.setOrderType(recognizeType);
|
|
order.setOrderType(recognizeType);
|
|
|
- orderService.updateById(order);
|
|
|
|
|
|
|
+ orderService.lambdaUpdate().set(Order::getOrderType, recognizeType).eq(Order::getId, order.getId()).update();
|
|
|
log.info("订单类型设置成功 - orderId: {}, orderType: {}", order.getId(), recognizeType);
|
|
log.info("订单类型设置成功 - orderId: {}, orderType: {}", order.getId(), recognizeType);
|
|
|
|
|
|
|
|
// IN类型(异物放入)触发告警,提醒管理员审核
|
|
// IN类型(异物放入)触发告警,提醒管理员审核
|
|
@@ -798,18 +799,22 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
// 解析视频URL
|
|
// 解析视频URL
|
|
|
String videoUrl = parseVideoUrl(resourceInfoStr);
|
|
String videoUrl = parseVideoUrl(resourceInfoStr);
|
|
|
|
|
|
|
|
- // 更新订单信息:只更新商品列表和视频URL,不更新金额
|
|
|
|
|
|
|
+ // 选择性更新,只更新识别结果相关字段,不覆盖 payScoreOrderId/payChannel
|
|
|
|
|
+ LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.eq(Order::getId, order.getId());
|
|
|
|
|
+ updateWrapper.set(Order::getItems, skuListStr);
|
|
|
order.setItems(skuListStr);
|
|
order.setItems(skuListStr);
|
|
|
- // 注意:不更新totalAmount,保持为0,等待订单回调时更新
|
|
|
|
|
|
|
|
|
|
if (videoUrl != null) {
|
|
if (videoUrl != null) {
|
|
|
|
|
+ updateWrapper.set(Order::getVideoUrl, videoUrl);
|
|
|
order.setVideoUrl(videoUrl);
|
|
order.setVideoUrl(videoUrl);
|
|
|
}
|
|
}
|
|
|
if (confidence != null) {
|
|
if (confidence != null) {
|
|
|
|
|
+ updateWrapper.set(Order::getConfidence, confidence);
|
|
|
order.setConfidence(confidence);
|
|
order.setConfidence(confidence);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- boolean updated = orderService.updateById(order);
|
|
|
|
|
|
|
+ boolean updated = orderService.update(updateWrapper);
|
|
|
if (updated) {
|
|
if (updated) {
|
|
|
log.info("订单识别信息更新成功 - orderId: {}, 等待回调更新金额", order.getId());
|
|
log.info("订单识别信息更新成功 - orderId: {}, 等待回调更新金额", order.getId());
|
|
|
}
|
|
}
|
|
@@ -887,20 +892,25 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
private void updateOrderFromCallback(Order order, String orderId, String activityId,
|
|
private void updateOrderFromCallback(Order order, String orderId, String activityId,
|
|
|
Object orderMoney, String orderDetail,
|
|
Object orderMoney, String orderDetail,
|
|
|
String orderName, String orderGoodsStr) {
|
|
String orderName, String orderGoodsStr) {
|
|
|
- // 不覆盖本地订单号,哈哈 order_id 存入独立字段,用于后续 payStatus 同步
|
|
|
|
|
- order.setHahaOrderId(orderId);
|
|
|
|
|
- order.setActivityId(activityId);
|
|
|
|
|
|
|
+ // 使用选择性更新,只更新回调提供的字段,避免覆盖 payScoreOrderId/payChannel 等
|
|
|
|
|
+ LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.eq(Order::getId, order.getId());
|
|
|
|
|
+
|
|
|
|
|
+ updateWrapper.set(Order::getHahaOrderId, orderId);
|
|
|
|
|
+ updateWrapper.set(Order::getActivityId, activityId);
|
|
|
|
|
|
|
|
if (orderName != null && !orderName.isEmpty()) {
|
|
if (orderName != null && !orderName.isEmpty()) {
|
|
|
- order.setOrderName(orderName);
|
|
|
|
|
|
|
+ updateWrapper.set(Order::getOrderName, orderName);
|
|
|
// 根据订单名称判断订单类型:包含"放入"的为IN类型(异物放入),其他为OUT类型(正常消费)
|
|
// 根据订单名称判断订单类型:包含"放入"的为IN类型(异物放入),其他为OUT类型(正常消费)
|
|
|
if (orderName.contains("放入")) {
|
|
if (orderName.contains("放入")) {
|
|
|
|
|
+ updateWrapper.set(Order::getOrderType, OpenType.IN.getCode());
|
|
|
order.setOrderType(OpenType.IN.getCode());
|
|
order.setOrderType(OpenType.IN.getCode());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 如果订单类型仍为空,默认为OUT(正常消费)
|
|
// 如果订单类型仍为空,默认为OUT(正常消费)
|
|
|
if (order.getOrderType() == null || order.getOrderType().isEmpty()) {
|
|
if (order.getOrderType() == null || order.getOrderType().isEmpty()) {
|
|
|
|
|
+ updateWrapper.set(Order::getOrderType, OpenType.OUT.getCode());
|
|
|
order.setOrderType(OpenType.OUT.getCode());
|
|
order.setOrderType(OpenType.OUT.getCode());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -916,20 +926,23 @@ public class HahaCallbackServiceImpl implements HahaCallbackService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (orderDetail != null) {
|
|
if (orderDetail != null) {
|
|
|
|
|
+ updateWrapper.set(Order::getItems, orderDetail);
|
|
|
order.setItems(orderDetail);
|
|
order.setItems(orderDetail);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (orderMoney != null) {
|
|
if (orderMoney != null) {
|
|
|
// 设备端传来的金额是已经计算过营销活动优惠后的金额
|
|
// 设备端传来的金额是已经计算过营销活动优惠后的金额
|
|
|
BigDecimal totalAmount = new BigDecimal(orderMoney.toString());
|
|
BigDecimal totalAmount = new BigDecimal(orderMoney.toString());
|
|
|
- order.setTotalAmount(totalAmount);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ updateWrapper.set(Order::getTotalAmount, totalAmount);
|
|
|
// 初始化优惠金额和实付金额(后续会被processCouponDiscount更新)
|
|
// 初始化优惠金额和实付金额(后续会被processCouponDiscount更新)
|
|
|
|
|
+ updateWrapper.set(Order::getDiscountAmount, BigDecimal.ZERO);
|
|
|
|
|
+ updateWrapper.set(Order::getPaidAmount, totalAmount);
|
|
|
|
|
+ order.setTotalAmount(totalAmount);
|
|
|
order.setDiscountAmount(BigDecimal.ZERO);
|
|
order.setDiscountAmount(BigDecimal.ZERO);
|
|
|
order.setPaidAmount(totalAmount);
|
|
order.setPaidAmount(totalAmount);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- boolean updated = orderService.updateById(order);
|
|
|
|
|
|
|
+ boolean updated = orderService.update(updateWrapper);
|
|
|
if (updated) {
|
|
if (updated) {
|
|
|
log.info("订单信息更新成功: {}", orderId);
|
|
log.info("订单信息更新成功: {}", orderId);
|
|
|
|
|
|