- 新建 admin_pickups 表独立于 rental_orders,不污染订单状态机与财务统计口径 - 提号中/已完成/已取消三态:创建锁定账号,完成时给卖家钱包加可用余额并下架 listing,取消解锁账号 - 完成时 listing 置 completed,复用现有 listingLockedForOwnerMutation 拦截再上架 - 管理端提号管理页(列表/创建/完成/取消/可提号账号搜索)+ 卖家端提号记录页 - 财务仪表盘新增线下提号独立统计块,与正常订单口径分离 - 钱包流水 label、状态标签、菜单入口同步补齐 - 优化卖家服务悬浮菜单为一行四个,尺寸与配色对齐买家服务
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
package pickup
|
|
|
|
import (
|
|
"context"
|
|
|
|
"hfb_sys/backend/internal/auditlog"
|
|
)
|
|
|
|
type Service struct {
|
|
repo *Repository
|
|
}
|
|
|
|
func NewService(repo *Repository) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) Create(ctx context.Context, req CreateRequest, adminID uint64, meta auditlog.Meta) (*PickupDTO, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
if req.ListingID == 0 {
|
|
return nil, ErrListingUnavailable
|
|
}
|
|
return s.repo.Create(ctx, req, adminID, meta)
|
|
}
|
|
|
|
func (s *Service) Complete(ctx context.Context, pickupID uint64, req CompleteRequest, adminID uint64, meta auditlog.Meta) (*PickupDTO, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
if pickupID == 0 || req.SettleAmountCent <= 0 {
|
|
return nil, ErrInvalidAmount
|
|
}
|
|
return s.repo.Complete(ctx, pickupID, req, adminID, meta)
|
|
}
|
|
|
|
func (s *Service) Cancel(ctx context.Context, pickupID uint64, reason string, adminID uint64, meta auditlog.Meta) error {
|
|
if s.repo == nil {
|
|
return ErrDependencyUnavailable
|
|
}
|
|
if pickupID == 0 || reason == "" {
|
|
return ErrPickupNotPickingUp
|
|
}
|
|
return s.repo.Cancel(ctx, pickupID, reason, adminID, meta)
|
|
}
|
|
|
|
func (s *Service) FindByID(ctx context.Context, id uint64) (*PickupDTO, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
return s.repo.FindByID(ctx, id)
|
|
}
|
|
|
|
func (s *Service) ListAdmin(ctx context.Context, query AdminPickupQuery) (*PaginatedResult, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
return s.repo.ListAdmin(ctx, query)
|
|
}
|
|
|
|
func (s *Service) ListForSeller(ctx context.Context, ownerID uint64, query SellerPickupQuery) (*PaginatedResult, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
return s.repo.ListForSeller(ctx, ownerID, query)
|
|
}
|
|
|
|
func (s *Service) ListAvailableListings(ctx context.Context, keyword string, page, pageSize int) (*AvailableListingsResult, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
return s.repo.ListAvailableListings(ctx, keyword, page, pageSize)
|
|
}
|