fix version 1

This commit is contained in:
2026-09-22 21:15:34 +08:00
parent 9f86366638
commit d63d7e8b3a
277 changed files with 9959 additions and 1514 deletions

View File

@@ -27,8 +27,12 @@ func Fetch(ctx context.Context, in *pb.CartGetRequest) (reply *pb.CartGetReply,
return nil, errcode.ErrInvalidArgument
}
}
// 查询购物车数据
err = impl.DBService.Where("cart_identity=? or passport_identity=?", in.GetCarIdentity(), auth.Identity).Find(&cart).Error
// 查询购物车数据:仅返回属于当前登录者的条目,cart_identity 只作附加过滤。
tx := impl.DBService.Where("passport_identity = ?", auth.Identity)
if in.GetCarIdentity() != "" {
tx = tx.Where("cart_identity = ?", in.GetCarIdentity())
}
err = tx.Find(&cart).Error
if err != nil {
printer.Error(err.Error())
@@ -39,29 +43,30 @@ func Fetch(ctx context.Context, in *pb.CartGetRequest) (reply *pb.CartGetReply,
product := models.Product{}
err := impl.DBService.Raw(`
SELECT
p.id, p.identity, p.title, p.cover_image, p.args, p.cost_price,
p.id, p.identity, p.title, p.cover_image, p.args,
( SELECT MIN(mps.price)
FROM product_spec ps
JOIN mall_product_spec mps ON ps.spec_id = mps.id
WHERE ps.product_identity = p.identity
) as sales_price FROM mall_product p WHERE p.identity = ?`, item.ProductIdentity).Scan(&product).Error
if err == nil {
da := &pb.CartItem{
Id: int64(item.ID),
ProductId: product.Id,
Title: product.Title,
ProductIdentity: product.Identity,
CoverImage: product.CoverImage,
SalesPrice: product.SalesPrice,
ProductArgs: item.ProductArgs,
UnitPrice: product.CostPrice,
TotalPrice: int64(item.Number) * product.SalesPrice,
Number: item.Number,
Identity: item.Identity,
}
result = append(result, da)
if err != nil {
printer.Error(err.Error())
return nil, errcode.ErrDB
}
da := &pb.CartItem{
Id: int64(item.ID),
ProductId: product.Id,
Title: product.Title,
ProductIdentity: product.Identity,
CoverImage: product.CoverImage,
SalesPrice: product.SalesPrice,
ProductArgs: item.ProductArgs,
UnitPrice: product.SalesPrice,
TotalPrice: int64(item.Number) * product.SalesPrice,
Number: item.Number,
Identity: item.Identity,
}
result = append(result, da)
}
return &pb.CartGetReply{