Documentation
¶
Index ¶
- Constants
- Variables
- func DeductStockEventStartListen(s *Service)
- func StartHttpService() error
- func StartService() error
- type ClientConfig
- type Config
- type DatabaseConfig
- type EtcdConfig
- type HttpServer
- type HttpServerConfig
- type HttpService
- func (h *HttpService) AddOrder(reqData []byte) (interface{}, error)
- func (h *HttpService) DelOrder(reqData []byte) (interface{}, error)
- func (h *HttpService) GetActivity(reqData []byte) (interface{}, error)
- func (h *HttpService) GetOrder(reqData []byte) (interface{}, error)
- func (h *HttpService) GetPayOrderPersonTime(reqData []byte) (interface{}, error)
- func (h *HttpService) PayOrder(reqData []byte) (interface{}, error)
- func (h *HttpService) SetActivity(reqData []byte) (interface{}, error)
- type KafkaConfig
- type LogConfig
- type NsqConfig
- type RedisConfig
- type ServerConfig
- type Service
- func (s *Service) AddOrder(ctx context.Context, req *proto.AddOrderRequest) (*proto.AddOrderResponse, error)
- func (s *Service) DelOrder(ctx context.Context, req *proto.DelOrderRequest) (*proto.DelOrderResponse, error)
- func (s *Service) GetActivity(ctx context.Context, req *proto.GetActivityRequest) (*proto.GetActivityResponse, error)
- func (s *Service) GetOrder(ctx context.Context, req *proto.GetOrderRequest) (*proto.GetOrderResponse, error)
- func (s *Service) GetPayOrderPersonTime(ctx context.Context, req *proto.GetPayOrderPersonTimeRequest) (*proto.GetPayOrderPersonTimeResponse, error)
- func (s *Service) PayOrder(ctx context.Context, req *proto.PayOrderRequest) (*proto.PayOrderResponse, error)
- func (s *Service) SetActivity(ctx context.Context, req *proto.SetActivityRequest) (*proto.SetActivityResponse, error)
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 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 EtcdConfig ¶
type EtcdConfig struct {
Endpoints []string `yaml:"endpoints" json:"endpoints"`
}
type HttpServer ¶
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 RedisConfig ¶
type ServerConfig ¶
type Service ¶
type Service struct { Config *Config RedisPool *redis.RedisPool GoodsServiceClient goodspb.GoodsServiceClient // contains filtered or unexported fields }
func (*Service) AddOrder ¶
func (s *Service) AddOrder(ctx context.Context, req *proto.AddOrderRequest) (*proto.AddOrderResponse, error)
增加订单并不会扣库存
func (*Service) DelOrder ¶
func (s *Service) DelOrder(ctx context.Context, req *proto.DelOrderRequest) (*proto.DelOrderResponse, error)
func (*Service) GetActivity ¶
func (s *Service) GetActivity(ctx context.Context, req *proto.GetActivityRequest) (*proto.GetActivityResponse, error)
func (*Service) GetOrder ¶
func (s *Service) GetOrder(ctx context.Context, req *proto.GetOrderRequest) (*proto.GetOrderResponse, error)
func (*Service) GetPayOrderPersonTime ¶
func (s *Service) GetPayOrderPersonTime(ctx context.Context, req *proto.GetPayOrderPersonTimeRequest) (*proto.GetPayOrderPersonTimeResponse, error)
func (*Service) PayOrder ¶
func (s *Service) PayOrder(ctx context.Context, req *proto.PayOrderRequest) (*proto.PayOrderResponse, error)
后期优化 0.生成了订单但是没库存,直接撤销 1.支持实际支付
2.支付成功,扣库存失败(库存足),抛消息队列 3.支付成功,扣库存失败(没库存),直接撤销,退款
4.扣库存成功,修改支付状态失败,抛消息队列
func (*Service) SetActivity ¶
func (s *Service) SetActivity(ctx context.Context, req *proto.SetActivityRequest) (*proto.SetActivityResponse, error)
Click to show internal directories.
Click to hide internal directories.