创建一个接口,不需要签名认证,通过传入的商品id与user_id 去分库查询并返回商品的所有信息

This commit is contained in:
Administrator 2026-06-18 14:14:09 +08:00
parent 687159f4b3
commit 1d622ed889
2 changed files with 12 additions and 2 deletions

View File

@ -229,6 +229,7 @@ type ProductFullInfoResponse struct {
Status int8 `json:"status"` // 状态 Status int8 `json:"status"` // 状态
CreatedAt int64 `json:"created_at"` // 创建时间 CreatedAt int64 `json:"created_at"` // 创建时间
UpdatedAt int64 `json:"updated_at"` // 更新时间 UpdatedAt int64 `json:"updated_at"` // 更新时间
TotalStock int64 `json:"total_stock"` // 总库存数量
Inventories []ProductInventoryDetail `json:"inventories"` // 库存详情列表 Inventories []ProductInventoryDetail `json:"inventories"` // 库存详情列表
ShopList []ShopInfo `json:"shop_list"` // 店铺信息列表 ShopList []ShopInfo `json:"shop_list"` // 店铺信息列表
} }

View File

@ -495,6 +495,13 @@ func (s *ProductService) GetProductFullInfo(req systemReq.GetProductFullInfoRequ
fmt.Printf("【断点8】库存信息查询完成 - 数量: %d\n", len(inventories)) fmt.Printf("【断点8】库存信息查询完成 - 数量: %d\n", len(inventories))
totalStock := int64(0)
for _, inv := range inventories {
totalStock += inv.Quantity
}
fmt.Printf("【断点9】计算总库存: %d\n", totalStock)
outTaskInfoMap, err := s.getProductOutTaskInfo(databaseConn, []int64{req.ProductID}) outTaskInfoMap, err := s.getProductOutTaskInfo(databaseConn, []int64{req.ProductID})
if err != nil { if err != nil {
utils.ErrorLog(constant.LoggerChannelWork, map[string]interface{}{ utils.ErrorLog(constant.LoggerChannelWork, map[string]interface{}{
@ -508,7 +515,7 @@ func (s *ProductService) GetProductFullInfo(req systemReq.GetProductFullInfoRequ
shopList = outTaskInfo.ShopList shopList = outTaskInfo.ShopList
} }
fmt.Printf("【断点9】店铺信息查询完成 - 数量: %d\n", len(shopList)) fmt.Printf("【断点10】店铺信息查询完成 - 数量: %d\n", len(shopList))
response := &systemRes.ProductFullInfoResponse{ response := &systemRes.ProductFullInfoResponse{
ID: product.ID, ID: product.ID,
@ -526,11 +533,12 @@ func (s *ProductService) GetProductFullInfo(req systemReq.GetProductFullInfoRequ
Status: product.Status, Status: product.Status,
CreatedAt: product.CreatedAt, CreatedAt: product.CreatedAt,
UpdatedAt: product.UpdatedAt, UpdatedAt: product.UpdatedAt,
TotalStock: totalStock,
Inventories: inventories, Inventories: inventories,
ShopList: shopList, ShopList: shopList,
} }
fmt.Printf("【断点10】商品完整信息查询成功,准备返回\n") fmt.Printf("【断点11】商品完整信息查询成功,准备返回\n")
utils.InfoLog(constant.LoggerChannelWork, map[string]interface{}{ utils.InfoLog(constant.LoggerChannelWork, map[string]interface{}{
"action": "商品完整信息查询成功", "action": "商品完整信息查询成功",
@ -538,6 +546,7 @@ func (s *ProductService) GetProductFullInfo(req systemReq.GetProductFullInfoRequ
"user_id": req.UserID, "user_id": req.UserID,
"product_name": product.Name, "product_name": product.Name,
"barcode": product.Barcode, "barcode": product.Barcode,
"total_stock": totalStock,
"inventory_count": len(inventories), "inventory_count": len(inventories),
"shop_count": len(shopList), "shop_count": len(shopList),
"success": true, "success": true,