muyu-apiserver/rpc/purchase/internal/logic/getsupplierlogic.go
Chever John a25acdc5e4 chore: sync codebase with upstream
Pull latest changes from upstream/main (GitHub) including:
- Purchase RPC service (proto, server, logic, models)
- Gateway route updates for purchase endpoints
- SQL migration and config updates

Excludes deploy/bin/ pre-compiled arm64 binaries (builds use
multi-stage Dockerfiles targeting amd64).
2026-06-15 09:20:56 +08:00

42 lines
1.1 KiB
Go

package logic
import (
"context"
"fmt"
"muyu-apiserver/rpc/purchase/internal/svc"
"muyu-apiserver/rpc/purchase/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type GetSupplierLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetSupplierLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSupplierLogic {
return &GetSupplierLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
}
func (l *GetSupplierLogic) GetSupplier(in *pb.GetSupplierReq) (*pb.SupplierInfo, error) {
s, err := l.svcCtx.SupplierModel.FindOneBySupplierId(l.ctx, in.SupplierId)
if err != nil {
return nil, ErrSupplierNotFound
}
return &pb.SupplierInfo{
SupplierId: s.SupplierId,
SupplierName: s.SupplierName,
Phone: s.Phone,
PurchaseCount: s.PurchaseCount,
DeliveredQty: fmt.Sprintf("%.2f", s.DeliveredQty),
PayableAmount: fmt.Sprintf("%.2f", s.PayableAmount),
PaidAmount: fmt.Sprintf("%.2f", s.PaidAmount),
Status: s.Status,
Remark: s.Remark.String,
CreatedAt: s.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: s.UpdatedAt.Format("2006-01-02 15:04:05"),
}, nil
}