更新依赖

This commit is contained in:
2025-09-15 23:18:00 +08:00
parent cee789f31d
commit a2fe0e73cd
2 changed files with 8 additions and 18 deletions

View File

@@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"gorm.io/gorm"
"log"
"os"
"os/signal"
@@ -14,6 +13,8 @@ import (
"toutoukan/model/good"
"toutoukan/model/usermodel/userOrder"
"gorm.io/gorm"
"github.com/apache/rocketmq-client-go/v2"
"github.com/apache/rocketmq-client-go/v2/consumer"
"github.com/apache/rocketmq-client-go/v2/primitive"
@@ -75,7 +76,7 @@ func main() {
}
log.Printf(
"收到消息: ID=%s, 订单ID=%s, 商品ID=%d, 用户ID=%d, 数量=%d",
"收到消息: ID=%s, 订单ID=%s, 商品ID=%s, 用户ID=%d, 数量=%d",
msg.MsgId, orderMsg.OrderID, orderMsg.GoodsID, orderMsg.UserID, orderMsg.Quantity,
)
@@ -114,7 +115,7 @@ func main() {
// 4. 判断库存是否充足(受影响行数=0表示库存不足
if affected == 0 {
tx.Rollback()
log.Printf("%s商品库存不足订单ID: %s商品GID: %d%s\n", colorYellow, orderMsg.OrderID, orderMsg.GoodsID, colorReset)
log.Printf("商品库存不足订单ID: %s商品GID: %s\n", orderMsg.OrderID, orderMsg.GoodsID)
return consumer.ConsumeSuccess, nil
}