package adjust 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 ListStockAdjustLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewListStockAdjustLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListStockAdjustLogic { return &ListStockAdjustLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *ListStockAdjustLogic) ListStockAdjust(req *types.ListStockAdjustReq) (resp *types.ListStockAdjustResp, err error) { rpcResp, err := l.svcCtx.InventoryRpc.ListStockAdjust(l.ctx, &pb.ListStockAdjustReq{ Page: req.Page, PageSize: req.PageSize, AdjustNo: req.AdjustNo, AdjustReason: req.AdjustReason, Status: req.Status, StartDate: req.StartDate, EndDate: req.EndDate, }) if err != nil { return nil, err } list := make([]types.StockAdjustInfo, 0, len(rpcResp.List)) for _, a := range rpcResp.List { details := make([]types.StockAdjustDetailInfo, 0, len(a.Details)) for _, d := range a.Details { details = append(details, types.StockAdjustDetailInfo{ DetailId: d.DetailId, AdjustId: d.AdjustId, ProductId: d.ProductId, ProductName: d.ProductName, BeforeQuantity: d.BeforeQuantity, AdjustQuantity: d.AdjustQuantity, AfterQuantity: d.AfterQuantity, Remark: d.Remark, }) } list = append(list, types.StockAdjustInfo{ AdjustId: a.AdjustId, AdjustNo: a.AdjustNo, AdjustDate: a.AdjustDate, AdjustReason: a.AdjustReason, Operator: a.Operator, Approver: a.Approver, Status: a.Status, Remark: a.Remark, CreatedAt: a.CreatedAt, UpdatedAt: a.UpdatedAt, Details: details, }) } return &types.ListStockAdjustResp{ Total: rpcResp.Total, List: list, }, nil }