51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
|
|
package check
|
||
|
|
|
||
|
|
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 UpdateStockCheckLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewUpdateStockCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStockCheckLogic {
|
||
|
|
return &UpdateStockCheckLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *UpdateStockCheckLogic) UpdateStockCheck(req *types.UpdateStockCheckReq) (resp *types.IdResp, err error) {
|
||
|
|
id := ctxdata.GetPathId(l.ctx)
|
||
|
|
|
||
|
|
details := make([]*pb.StockCheckDetailReq, 0, len(req.Details))
|
||
|
|
for _, d := range req.Details {
|
||
|
|
details = append(details, &pb.StockCheckDetailReq{
|
||
|
|
ProductId: d.ProductId,
|
||
|
|
ActualQuantity: d.ActualQuantity,
|
||
|
|
Remark: d.Remark,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
_, err = l.svcCtx.InventoryRpc.UpdateStockCheck(l.ctx, &pb.UpdateStockCheckReq{
|
||
|
|
CheckId: id,
|
||
|
|
Remark: req.Remark,
|
||
|
|
Details: details,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return &types.IdResp{Id: id}, nil
|
||
|
|
}
|