66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package adjust
|
|
|
|
import (
|
|
"context"
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
"muyu-apiserver/gateway/internal/types"
|
|
"muyu-apiserver/pkg/ctxdata"
|
|
"muyu-apiserver/rpc/inventory/pb"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetStockAdjustLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetStockAdjustLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStockAdjustLogic {
|
|
return &GetStockAdjustLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetStockAdjustLogic) GetStockAdjust() (resp *types.StockAdjustInfo, err error) {
|
|
id := ctxdata.GetPathId(l.ctx)
|
|
|
|
rpcResp, err := l.svcCtx.InventoryRpc.GetStockAdjust(l.ctx, &pb.GetStockAdjustReq{
|
|
AdjustId: id,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
details := make([]types.StockAdjustDetailInfo, 0, len(rpcResp.Details))
|
|
for _, d := range rpcResp.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,
|
|
})
|
|
}
|
|
|
|
return &types.StockAdjustInfo{
|
|
AdjustId: rpcResp.AdjustId,
|
|
AdjustNo: rpcResp.AdjustNo,
|
|
AdjustDate: rpcResp.AdjustDate,
|
|
AdjustReason: rpcResp.AdjustReason,
|
|
Operator: rpcResp.Operator,
|
|
Approver: rpcResp.Approver,
|
|
Status: rpcResp.Status,
|
|
Remark: rpcResp.Remark,
|
|
CreatedAt: rpcResp.CreatedAt,
|
|
UpdatedAt: rpcResp.UpdatedAt,
|
|
Details: details,
|
|
}, nil
|
|
}
|