Documentation
¶
Overview ¶
Package adminorder implements the admin-side order management subdomain of the billing module. Only the module facade may reach it.
Index ¶
- type ActivationEnqueuer
- type DailyReport
- type DailyReportLine
- type Deps
- type Inventory
- type OrderCloser
- type Orders
- type PlanNameReader
- type Service
- func (s *Service) Create(ctx context.Context, req *dto.CreateOrderRequest) error
- func (s *Service) DailyReport(ctx context.Context, date time.Time) (*DailyReport, error)
- func (s *Service) List(ctx context.Context, req *dto.GetOrderListRequest) (*dto.GetOrderListResponse, error)
- func (s *Service) UpdateStatus(ctx context.Context, req *dto.UpdateOrderStatusRequest) error
- type Transactor
- type UserSubscriptionReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivationEnqueuer ¶
ActivationEnqueuer mirrors the facade's activation queue port.
type DailyReport ¶ added in v1.15.16
type DailyReport struct {
Date time.Time
Orders int64
Amount int64
ByPlan []DailyReportLine
ByMethod []DailyReportLine
}
DailyReport summarises the orders settled on one day. Amounts stay in minor units; formatting belongs to whoever renders the report.
type DailyReportLine ¶ added in v1.15.16
DailyReportLine is one plan or payment-method row of the daily report.
type Deps ¶ added in v1.21.0
type Deps struct {
Orders Orders
Payments gateway.MethodFinder
// Coupons resolves the coupon an administrator's order names; UserSubs
// the subscription a renewal or traffic reset applies to; Inventory
// holds the plan unit of a new subscription order. An order that needs
// one of them is refused when it is not configured.
Coupons pricing.CouponFinder
UserSubs UserSubscriptionReader
Inventory Inventory
Tx Transactor
Queue ActivationEnqueuer
// Plans resolves plan names for the daily report; optional so callers
// that only manage orders need not provide it.
Plans PlanNameReader
Closer OrderCloser
}
type Inventory ¶ added in v1.21.0
Inventory reserves a plan unit for a new subscription order, as the buyer's own purchase reserves it (ADR-001 step 2).
type OrderCloser ¶ added in v1.21.0
type OrderCloser interface {
CloseByAdmin(ctx context.Context, orderNo string, adminID int64) (bool, error)
}
OrderCloser is the checkout close flow shared with owner and expiry closes; it reports whether the call closed the order.
type Orders ¶ added in v1.21.0
type Orders interface {
FindOne(ctx context.Context, id int64) (*order.Order, error)
QueryOrderListByPage(ctx context.Context, page, size int, status uint8, user, subscribe int64, search string) (int64, []*order.Details, error)
QueryDailyReport(ctx context.Context, date time.Time) (*order.DailyReport, error)
}
Orders is the order persistence administration reads outside a transaction.
type PlanNameReader ¶ added in v1.15.16
type PlanNameReader interface {
FindOne(ctx context.Context, id int64) (*subscribe.Subscribe, error)
}
PlanNameReader is the read port onto the subscription domain's plan catalogue, used to label the daily report's plan breakdown.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) Create ¶
Create opens a pending order on an administrator's behalf under the rules a buyer's order follows: the type is one the activation knows, a renewal or traffic reset names the subscription it applies to, a coupon use and the plan unit of a new subscription are reserved while the order is pending, and the trade number is left for the gateway that collects the payment.
func (*Service) DailyReport ¶ added in v1.15.16
DailyReport totals a day's settled orders and resolves plan ids to names so the caller only has to format the result.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, req *dto.GetOrderListRequest) (*dto.GetOrderListResponse, error)
func (*Service) UpdateStatus ¶
UpdateStatus applies an administrator's decision on a pending order: mark it paid with the gateway's trade number, or close it.
type Transactor ¶
type Transactor interface {
InBillingTx(ctx context.Context, fn func(repository.BillingStore) error) error
}
Transactor mirrors the facade's billing-scoped transaction port.
type UserSubscriptionReader ¶ added in v1.21.0
type UserSubscriptionReader interface {
FindOneUserSubscribe(ctx context.Context, id int64) (*usersub.SubscribeDetails, error)
}
UserSubscriptionReader resolves the user subscription a renewal or traffic-reset order an administrator creates applies to.