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).
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package stats
|
|
|
|
import (
|
|
"context"
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
"muyu-apiserver/gateway/internal/types"
|
|
"muyu-apiserver/rpc/purchase/purchaseservice"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetPurchaseStatsBySupplierLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetPurchaseStatsBySupplierLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPurchaseStatsBySupplierLogic {
|
|
return &GetPurchaseStatsBySupplierLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetPurchaseStatsBySupplierLogic) GetPurchaseStatsBySupplier(req *types.PurchaseStatsSummaryReq) (*types.PurchaseStatsBySupplierResp, error) {
|
|
resp, err := l.svcCtx.PurchaseRpc.GetPurchaseStatsBySupplier(l.ctx, &purchaseservice.PurchaseStatsSummaryReq{
|
|
StartDate: req.StartDate,
|
|
EndDate: req.EndDate,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
list := make([]types.PurchaseStatsBySupplierItem, 0, len(resp.List))
|
|
for _, s := range resp.List {
|
|
list = append(list, types.PurchaseStatsBySupplierItem{
|
|
SupplierId: s.SupplierId,
|
|
SupplierName: s.SupplierName,
|
|
OrderCount: s.OrderCount,
|
|
TotalAmount: s.PurchaseAmount,
|
|
PaidAmount: s.PaidAmount,
|
|
})
|
|
}
|
|
return &types.PurchaseStatsBySupplierResp{List: list}, nil
|
|
}
|