2026-02-28 15:29:16 +08:00
|
|
|
package logic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2026-03-30 02:53:55 +00:00
|
|
|
"muyu-apiserver/pkg/tenantctx"
|
2026-02-28 15:29:16 +08:00
|
|
|
"muyu-apiserver/rpc/inventory/internal/svc"
|
|
|
|
|
"muyu-apiserver/rpc/inventory/pb"
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ListStockAdjustLogic struct {
|
|
|
|
|
ctx context.Context
|
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
|
logx.Logger
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewListStockAdjustLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListStockAdjustLogic {
|
|
|
|
|
return &ListStockAdjustLogic{
|
|
|
|
|
ctx: ctx,
|
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *ListStockAdjustLogic) ListStockAdjust(in *pb.ListStockAdjustReq) (*pb.ListStockAdjustResp, error) {
|
2026-03-30 02:53:55 +00:00
|
|
|
tenantId := tenantctx.ExtractTenantId(l.ctx)
|
|
|
|
|
list, total, err := l.svcCtx.StockAdjustModel.FindList(l.ctx, tenantId, in.Page, in.PageSize, in.AdjustNo, in.AdjustReason, in.Status, in.StartDate, in.EndDate)
|
2026-02-28 15:29:16 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pbList := make([]*pb.StockAdjustInfo, 0, len(list))
|
|
|
|
|
for _, a := range list {
|
|
|
|
|
pbList = append(pbList, &pb.StockAdjustInfo{
|
|
|
|
|
AdjustId: a.AdjustId,
|
|
|
|
|
AdjustNo: a.AdjustNo,
|
|
|
|
|
AdjustDate: a.AdjustDate.Format("2006-01-02"),
|
|
|
|
|
AdjustReason: a.AdjustReason,
|
|
|
|
|
Operator: a.Operator,
|
|
|
|
|
Approver: a.Approver,
|
|
|
|
|
Status: a.Status,
|
|
|
|
|
Remark: a.Remark.String,
|
|
|
|
|
CreatedAt: a.CreatedAt.Format("2006-01-02 15:04:05"),
|
|
|
|
|
UpdatedAt: a.UpdatedAt.Format("2006-01-02 15:04:05"),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &pb.ListStockAdjustResp{
|
|
|
|
|
Total: total,
|
|
|
|
|
List: pbList,
|
|
|
|
|
}, nil
|
|
|
|
|
}
|