This commit is contained in:
2026-02-27 15:46:12 +08:00
parent a8ec1a5aa1
commit 63269dcb0b
58 changed files with 5806 additions and 1766 deletions

View File

@@ -34,6 +34,11 @@ type ServiceContext struct {
FeatureModel model.FeatureModel
ProductFeatureModel model.ProductFeatureModel
// 白名单相关模型
UserFeatureWhitelistModel model.UserFeatureWhitelistModel
WhitelistOrderModel model.WhitelistOrderModel
WhitelistOrderItemModel model.WhitelistOrderItemModel
// 订单相关模型
OrderModel model.OrderModel
OrderRefundModel model.OrderRefundModel
@@ -77,11 +82,14 @@ type ServiceContext struct {
GlobalNotificationsModel model.GlobalNotificationsModel
AuthorizationDocumentModel model.AuthorizationDocumentModel
// 第三方服务
TianyuanapiCallLogService *service.TianyuanapiCallLogService
// 服务
AlipayService *service.AliPayService
WechatPayService *service.WechatPayService
ApplePayService *service.ApplePayService
ApiRequestService *service.ApiRequestService
WhitelistService *service.WhitelistService
AsynqServer *asynq.Server
AsynqService *service.AsynqService
VerificationService *service.VerificationService
@@ -116,6 +124,11 @@ func NewServiceContext(c config.Config) *ServiceContext {
featureModel := model.NewFeatureModel(db, cacheConf)
productFeatureModel := model.NewProductFeatureModel(db, cacheConf)
// ============================== 白名单相关模型 ==============================
userFeatureWhitelistModel := model.NewUserFeatureWhitelistModel(db, cacheConf)
whitelistOrderModel := model.NewWhitelistOrderModel(db, cacheConf)
whitelistOrderItemModel := model.NewWhitelistOrderItemModel(db, cacheConf)
// ============================== 订单相关模型 ==============================
orderModel := model.NewOrderModel(db, cacheConf)
queryModel := model.NewQueryModel(db, cacheConf)
@@ -158,6 +171,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
globalNotificationsModel := model.NewGlobalNotificationsModel(db, cacheConf)
authorizationDocumentModel := model.NewAuthorizationDocumentModel(db, cacheConf)
tianyuanapiCallLogModel := model.NewTianyuanapiCallLogModel(db, cacheConf)
// ============================== 第三方服务初始化 ==============================
tianyuanapi, err := tianyuanapi.NewClient(tianyuanapi.Config{
AccessID: c.Tianyuanapi.AccessID,
@@ -173,7 +187,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
alipayService := service.NewAliPayService(c)
wechatPayService := service.NewWechatPayService(c, userAuthModel, service.InitTypeWxPayPubKeyPure)
applePayService := service.NewApplePayService(c)
apiRequestService := service.NewApiRequestService(c, featureModel, productFeatureModel, tianyuanapi)
tianyuanapiCallLogService := service.NewTianyuanapiCallLogService(tianyuanapiCallLogModel, featureModel)
whitelistService := service.NewWhitelistService(c, userFeatureWhitelistModel, whitelistOrderModel, whitelistOrderItemModel, queryModel, featureModel)
apiRequestService := service.NewApiRequestService(c, featureModel, productFeatureModel, userFeatureWhitelistModel, tianyuanapi, tianyuanapiCallLogService, whitelistService)
verificationService := service.NewVerificationService(c, tianyuanapi, apiRequestService)
asynqService := service.NewAsynqService(c)
agentService := service.NewAgentService(c, orderModel, agentModel, agentWalletModel,
@@ -215,6 +231,11 @@ func NewServiceContext(c config.Config) *ServiceContext {
FeatureModel: featureModel,
ProductFeatureModel: productFeatureModel,
// 白名单相关模型
UserFeatureWhitelistModel: userFeatureWhitelistModel,
WhitelistOrderModel: whitelistOrderModel,
WhitelistOrderItemModel: whitelistOrderItemModel,
// 订单相关模型
OrderModel: orderModel,
QueryModel: queryModel,
@@ -258,11 +279,15 @@ func NewServiceContext(c config.Config) *ServiceContext {
GlobalNotificationsModel: globalNotificationsModel,
AuthorizationDocumentModel: authorizationDocumentModel,
// 第三方服务
TianyuanapiCallLogService: tianyuanapiCallLogService,
// 服务
AlipayService: alipayService,
WechatPayService: wechatPayService,
ApplePayService: applePayService,
ApiRequestService: apiRequestService,
WhitelistService: whitelistService,
AsynqServer: asynqServer,
AsynqService: asynqService,
VerificationService: verificationService,