service

package
v0.0.0-...-9d05754 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeductStockEventList       = "DeductStockEventList"
	DeductStockEventChannel    = "DeductStockEventChannel"
	PayOrderEventTimerDuration = 2 * time.Second
)
View Source
const (
	OrderStatusUnpaid = 0
	OrderStatusPaid   = 1
	OrderStatusRevoke = 2
)
View Source
const (
	ActivityPrefix                = "ActivityPrefix"
	PayOrderPersonTime            = "PayOrderPersonTime"            // 历史支付人次,一个人算一次
	PayOrderPersonTimeByTimestamp = "PayOrderPersonTimeByTimestamp" // 历史支付人次,一个人算一次,按照时间戳排序
	PayOrderPersonTimeEstimate    = "PayOrderPersonTimeEstimate"    // 历史支付人次,一个人算一次,有误差,占资源小
)

Variables

View Source
var (
	App = &Service{}
)

Functions

func DeductStockEventStartListen

func DeductStockEventStartListen(s *Service)

func StartHttpService

func StartHttpService() error

func StartService

func StartService() error

Types

type ClientConfig

type ClientConfig struct {
	UserServiceName  string `yaml:"userServiceName" json:"userServiceName"`
	GoodsServiceName string `yaml:"goodsServiceName" json:"goodsServiceName"`
}

type Config

type Config struct {
	Log        *LogConfig        `yaml:"log" json:"log"`
	Etcd       *EtcdConfig       `yaml:"etcd" json:"etcd"`
	Server     *ServerConfig     `yaml:"server" json:"server"`
	HttpServer *HttpServerConfig `yaml:"httpServer" json:"httpServer"`
	Database   *DatabaseConfig   `yaml:"database" json:"database"`
	Client     *ClientConfig     `yaml:"client" json:"client"`
	Redis      *RedisConfig      `yaml:"redis" json:"redis"`
	Kafka      *KafkaConfig      `yaml:"kafka" json:"kafka"`
	Nsq        *NsqConfig        `yaml:"nsq" json:"nsq"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Address    string `yaml:"address" json:"address"`
	Username   string `yaml:"username" json:"username"`
	Password   string `yaml:"password" json:"password"`
	DriverName string `yaml:"driverName" json:"driverName"`
	DbName     string `yaml:"dbName" json:"dbName"`
}

type EtcdConfig

type EtcdConfig struct {
	Endpoints []string `yaml:"endpoints" json:"endpoints"`
}

type HttpServer

type HttpServer struct {
	ServiceName string
	Port        string
}

func (*HttpServer) StartHttpServer

func (h *HttpServer) StartHttpServer(httpService *HttpService)

type HttpServerConfig

type HttpServerConfig struct {
	Port string `yaml:"port" json:"port"`
}

type HttpService

type HttpService struct {
	ServiceApp *Service
}

func (*HttpService) AddOrder

func (h *HttpService) AddOrder(reqData []byte) (interface{}, error)

func (*HttpService) DelOrder

func (h *HttpService) DelOrder(reqData []byte) (interface{}, error)

func (*HttpService) GetActivity

func (h *HttpService) GetActivity(reqData []byte) (interface{}, error)

func (*HttpService) GetOrder

func (h *HttpService) GetOrder(reqData []byte) (interface{}, error)

func (*HttpService) GetPayOrderPersonTime

func (h *HttpService) GetPayOrderPersonTime(reqData []byte) (interface{}, error)

func (*HttpService) PayOrder

func (h *HttpService) PayOrder(reqData []byte) (interface{}, error)

func (*HttpService) SetActivity

func (h *HttpService) SetActivity(reqData []byte) (interface{}, error)

type KafkaConfig

type KafkaConfig struct {
	Addrs []string `yaml:"addrs" json:"addrs"`
}

type LogConfig

type LogConfig struct {
	LogPath  string `yaml:"logPath" json:"logPath"`
	LogLevel string `yaml:"logLevel" json:"logLevel"`
}

type NsqConfig

type NsqConfig struct {
	LookupdAddrs []string `yaml:"lookupdAddrs" json:"lookupdAddrs"`
	NodeAddrs    []string `yaml:"nodeAddrs" json:"nodeAddrs"`
}

type RedisConfig

type RedisConfig struct {
	Address          string `yaml:"address" json:"address"`
	Password         string `yaml:"password" json:"password"`
	RedisLockTimeout int64  `yaml:"redisLockTimeout" json:"redisLockTimeout"`
}

type ServerConfig

type ServerConfig struct {
	Name string `yaml:"name" json:"name"`
	Port string `yaml:"port" json:"port"`
}

type Service

type Service struct {
	Config *Config

	RedisPool *redis.RedisPool

	GoodsServiceClient goodspb.GoodsServiceClient
	// contains filtered or unexported fields
}

func (*Service) AddOrder

增加订单并不会扣库存

func (*Service) DelOrder

func (*Service) GetActivity

func (*Service) GetOrder

func (*Service) PayOrder

后期优化 0.生成了订单但是没库存,直接撤销 1.支持实际支付

2.支付成功,扣库存失败(库存足),抛消息队列 3.支付成功,扣库存失败(没库存),直接撤销,退款

4.扣库存成功,修改支付状态失败,抛消息队列

func (*Service) SetActivity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL