2026-02-28 15:29:16 +08:00
|
|
|
package stock
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
|
|
|
"muyu-apiserver/gateway/internal/types"
|
|
|
|
|
"muyu-apiserver/rpc/inventory/pb"
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type GetStockSummaryLogic struct {
|
|
|
|
|
logx.Logger
|
|
|
|
|
ctx context.Context
|
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewGetStockSummaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStockSummaryLogic {
|
|
|
|
|
return &GetStockSummaryLogic{
|
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
|
ctx: ctx,
|
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *GetStockSummaryLogic) GetStockSummary() (resp *types.StockSummaryResp, err error) {
|
|
|
|
|
rpcResp, err := l.svcCtx.InventoryRpc.GetStockSummary(l.ctx, &pb.StockSummaryReq{})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &types.StockSummaryResp{
|
|
|
|
|
ProductCount: rpcResp.ProductCount,
|
|
|
|
|
TotalPieces: rpcResp.TotalPieces,
|
2026-06-14 15:24:02 +08:00
|
|
|
TotalPans: rpcResp.TotalPans,
|
|
|
|
|
TotalLengthM: rpcResp.TotalLengthM,
|
2026-02-28 15:29:16 +08:00
|
|
|
TotalSalesValue: rpcResp.TotalSalesValue,
|
|
|
|
|
}, nil
|
|
|
|
|
}
|