42 lines
1.1 KiB
Go
42 lines
1.1 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 GetPurchaseStatsSummaryLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewGetPurchaseStatsSummaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPurchaseStatsSummaryLogic {
|
||
|
|
return &GetPurchaseStatsSummaryLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *GetPurchaseStatsSummaryLogic) GetPurchaseStatsSummary(req *types.PurchaseStatsSummaryReq) (*types.PurchaseStatsSummaryResp, error) {
|
||
|
|
resp, err := l.svcCtx.PurchaseRpc.GetPurchaseStatsSummary(l.ctx, &purchaseservice.PurchaseStatsSummaryReq{
|
||
|
|
StartDate: req.StartDate,
|
||
|
|
EndDate: req.EndDate,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return &types.PurchaseStatsSummaryResp{
|
||
|
|
TotalOrders: resp.OrderCount,
|
||
|
|
TotalAmount: resp.TotalPurchaseAmount,
|
||
|
|
TotalPaidAmount: resp.TotalPaidAmount,
|
||
|
|
UnpaidAmount: resp.TotalUnpaidAmount,
|
||
|
|
}, nil
|
||
|
|
}
|