coupon

package
v0.0.0-...-2cd4ea5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coupon

type Coupon struct {
	eel.EntityBase
	Id             int
	UserId         int
	SourceType     string
	Code           string
	Status         string
	OrderBid       string
	ConsumedAt     time.Time
	DeductionMoney float64
	CreatedAt      time.Time

	//foreign key
	RuleId int //refer to rule
	Rule   *Rule
	// contains filtered or unexported fields
}

func NewCoupon

func NewCoupon(
	ctx context.Context,
	userId int,
	sourceType int,
	code string,
	status int,
	orderBid string,
	consumedAt string,
	ruleId int,
) *Coupon

工厂方法

func NewCouponFromModel

func NewCouponFromModel(ctx context.Context, model *m_coupon.Coupon) *Coupon

根据model构建对象

func NewCoupons

func NewCoupons(
	ctx context.Context,
	rule *Rule,
	userId int,
	count int,
	sourceType string,
) ([]*Coupon, error)

工厂方法

func (*Coupon) CheckValidity

func (this *Coupon) CheckValidity(user *account.User, poolProductIds []int) (bool, error)

func (*Coupon) GetDeductionMoney

func (this *Coupon) GetDeductionMoney(orderMoney int) (int, error)

func (*Coupon) GetRule

func (this *Coupon) GetRule() *Rule

func (*Coupon) GetStatus

func (this *Coupon) GetStatus(model *m_coupon.Coupon) string

GetStatus 状态

func (*Coupon) GetTargetPoolProductId

func (this *Coupon) GetTargetPoolProductId() int

func (*Coupon) IsForSingleProduct

func (this *Coupon) IsForSingleProduct() bool

func (*Coupon) Update

func (this *Coupon) Update(
	userId int,
	sourceType int,
	code string,
	status int,
	orderBid string,
	consumedAt string,
	ruleId int,
) error

Update 更新对象

func (*Coupon) UpdateStatus

func (this *Coupon) UpdateStatus(status string)

func (*Coupon) UseByOrder

func (this *Coupon) UseByOrder(order business.IOrder) error

type CouponRepository

type CouponRepository struct {
	eel.RepositoryBase
}

func NewCouponRepository

func NewCouponRepository(ctx context.Context) *CouponRepository

func (*CouponRepository) GetAllCouponsForCorp

func (this *CouponRepository) GetAllCouponsForCorp(corp business.ICorp, page *eel.PageInfo, filters eel.Map) ([]*Coupon, eel.INextPageInfo)

GetAllCouponsForCorp 获得所有Coupon对象集合

func (*CouponRepository) GetCoupon

func (this *CouponRepository) GetCoupon(id int) *Coupon

GetCoupon 根据id和corp获得Coupon对象

func (*CouponRepository) GetCouponByCode

func (this *CouponRepository) GetCouponByCode(code string) *Coupon

GetCoupon 根据code获得Coupon对象

func (*CouponRepository) GetCouponByCodeForUser

func (this *CouponRepository) GetCouponByCodeForUser(user business.IUser, code string) *Coupon

GetCouponByCodeForUser 根据code获得Coupon对象

func (*CouponRepository) GetCouponInCorp

func (this *CouponRepository) GetCouponInCorp(corp business.ICorp, id int) *Coupon

GetCouponInCorp 根据id和corp获得Coupon对象

func (*CouponRepository) GetCoupons

func (this *CouponRepository) GetCoupons(filters eel.Map, orderExprs ...string) []*Coupon

func (*CouponRepository) GetCouponsForUser

func (this *CouponRepository) GetCouponsForUser(user *account.User, page *eel.PageInfo, filters eel.Map) ([]*Coupon, eel.INextPageInfo)

GetCouponsForUser 获得启用的Coupon对象集合

func (*CouponRepository) GetCouponsForUserAndProducts

func (this *CouponRepository) GetCouponsForUserAndProducts(user *account.User, poolProducts []*product.PoolProduct) []*Coupon

GetCouponsForUserAndProducts 获得启用的Coupon对象集合

func (*CouponRepository) GetEnabledCouponsForCorp

func (this *CouponRepository) GetEnabledCouponsForCorp(rule *Rule, page *eel.PageInfo, filters eel.Map) ([]*Coupon, eel.INextPageInfo)

GetEnabledCouponsForCorp 获得启用的Coupon对象集合

func (*CouponRepository) GetPagedCoupons

func (this *CouponRepository) GetPagedCoupons(filters eel.Map, page *eel.PageInfo, orderExprs ...string) ([]*Coupon, eel.INextPageInfo)

type CouponService

type CouponService struct {
	eel.ServiceBase
}

func NewCouponService

func NewCouponService(ctx context.Context) *CouponService

func (*CouponService) Calculate

func (this *CouponService) Calculate(user *account.User, coupon *Coupon, couponInfo *params.CouponInfo, orderInfo *params.OrderInfo, products []*params.ProductInfo) (float64, error)

计算可抵扣的金额

func (*CouponService) Deliver

func (this *CouponService) Deliver(rule *Rule, userIds []int, countPerUser int, sourceType string) ([]*Coupon, error)

发放优惠券

func (*CouponService) DeliverOne

func (this *CouponService) DeliverOne(rule *Rule, userId int, sourceType string) (*Coupon, error)

func (*CouponService) DiscardCouponsByRules

func (this *CouponService) DiscardCouponsByRules(ruleIds []int)

func (*CouponService) RestoredCoupon

func (this *CouponService) RestoredCoupon(user *account.User, coupon *Coupon) error

恢复优惠券

type EncodeCouponService

type EncodeCouponService struct {
	eel.ServiceBase
}

func NewEncodeCouponService

func NewEncodeCouponService(ctx context.Context) *EncodeCouponService

func (*EncodeCouponService) Encode

func (this *EncodeCouponService) Encode(coupon *Coupon) *RCoupon

Encode 对单个实体对象进行编码

func (*EncodeCouponService) EncodeMany

func (this *EncodeCouponService) EncodeMany(coupons []*Coupon) []*RCoupon

EncodeMany 对实体对象进行批量编码

type EncodeRuleService

type EncodeRuleService struct {
	eel.ServiceBase
}

func NewEncodeRuleService

func NewEncodeRuleService(ctx context.Context) *EncodeRuleService

func (*EncodeRuleService) Encode

func (this *EncodeRuleService) Encode(rule *Rule) *RRule

Encode 对单个实体对象进行编码

func (*EncodeRuleService) EncodeMany

func (this *EncodeRuleService) EncodeMany(rules []*Rule) []*RRule

EncodeMany 对实体对象进行批量编码

type FillCouponService

type FillCouponService struct {
	eel.ServiceBase
}

func NewFillCouponService

func NewFillCouponService(ctx context.Context) *FillCouponService

func (*FillCouponService) Fill

func (this *FillCouponService) Fill(coupons []*Coupon, option eel.FillOption)

type FillRuleService

type FillRuleService struct {
	eel.ServiceBase
}

func NewFillRuleService

func NewFillRuleService(ctx context.Context) *FillRuleService

func (*FillRuleService) Fill

func (this *FillRuleService) Fill(rules []*Rule, option eel.FillOption)

type RCoupon

type RCoupon struct {
	Id             int     `json:"id"`
	UserId         int     `json:"user_id"`
	SourceType     string  `json:"source_type"`
	Code           string  `json:"code"`
	Status         string  `json:"status"`
	OrderBid       string  `json:"order_bid"`
	DeductionMoney float64 `json:"deduction_money"`
	ConsumedAt     string  `json:"consumed_at"`
	Rule           *RRule  `json:"rule"`
	CreatedAt      string  `json:"created_at"`
}

type RRule

type RRule struct {
	Id                int               `json:"id"`
	Name              string            `json:"name"`
	Count             int               `json:"count"`
	Desc              string            `json:"desc"`
	Remark            string            `json:"remark"`
	IsActive          bool              `json:"is_active"`
	IsDeleted         bool              `json:"is_deleted"`
	StartDate         string            `json:"start_date"`
	EndDate           string            `json:"end_date"`
	CreatedAt         string            `json:"created_at"`
	Status            string            `json:"status"`
	Conditions        []*RRuleCondition `json:"conditions"`
	RemainCouponCount int64             `json:"remain_coupon_count"`
	ReceiveStartDate  string            `json:"receive_start_date"`
	ReceiveEndDate    string            `json:"receive_end_date"`
	ReceiveStatus     string            `json:"receive_status"`
	CouponLinkUrl     string            `json:"coupon_link_url"`
}

type RRuleCondition

type RRuleCondition struct {
	Id        int              `json:"id"`
	Type      string           `json:"type"`
	Data      *simplejson.Json `json:"data"`
	CreatedAt string           `json:"created_at"`
}

type Rule

type Rule struct {
	eel.EntityBase
	Id                int
	CorpId            int
	Name              string
	Count             int
	Desc              string
	Remark            string
	IsActive          bool
	IsDeleted         bool
	StartDate         time.Time
	EndDate           time.Time
	CreatedAt         time.Time
	Status            string
	Conditions        []*RuleCondition
	RemainCouponCount int64
	ReceiveStartDate  time.Time
	ReceiveEndDate    time.Time
	ReceiveStatus     string
}

func NewRule

func NewRule(
	ctx context.Context,
	corp business.ICorp,
	name string,
	count int,
	desc string,
	remark string,
	startDate string,
	endDate string,
	receiveStartDate string,
	receiveEndDate string,
	conditions *simplejson.Json,
) *Rule

工厂方法

func NewRuleFromModel

func NewRuleFromModel(ctx context.Context, model *m_coupon.Rule) *Rule

根据model构建对象

func (*Rule) AddRuleCondition

func (this *Rule) AddRuleCondition(ruleCondition *RuleCondition)

AddRuleCondition 添加限制条件对象

func (*Rule) AdditionalCount

func (this *Rule) AdditionalCount(count int)

AdditionalCount 更新库存

func (*Rule) Disable

func (this *Rule) Disable()

Disable 禁用

func (*Rule) Enable

func (this *Rule) Enable()

Enable 启用

func (*Rule) GenerateCoupons

func (this *Rule) GenerateCoupons(userId int, count int, sourceType string) ([]*Coupon, error)

生成优惠券

func (*Rule) GetConditions

func (this *Rule) GetConditions() []*RuleCondition

func (*Rule) GetReceiveStatus

func (this *Rule) GetReceiveStatus() string

GetReceiveStatus 是否在可领的时间范围内

func (*Rule) GetRemainCouponCount

func (this *Rule) GetRemainCouponCount() int64

GetRemainCouponCount 剩余未领的张数

func (*Rule) GetStatus

func (this *Rule) GetStatus() string

GetStatus 状态

func (*Rule) Update

func (this *Rule) Update(
	name string,
	count int,
	desc string,
	remark string,
	startDate string,
	endDate string,
	receiveStartDate string,
	receiveEndDate string,
	conditions *simplejson.Json,
) error

Update 更新对象

func (*Rule) UpdateRemark

func (this *Rule) UpdateRemark(remark string)

func (*Rule) UpdateRuleConditions

func (this *Rule) UpdateRuleConditions(conditions *simplejson.Json)

UpdateRuleConditions 更新规则限制条件

type RuleCondition

type RuleCondition struct {
	eel.EntityBase
	Id        int
	Type      string
	Data      *simplejson.Json
	CreatedAt time.Time

	//foreign key
	RuleId int //refer to rule
}

func NewRuleConditionFromModel

func NewRuleConditionFromModel(ctx context.Context, model *m_coupon.RuleCondition) *RuleCondition

根据model构建对象

type RuleRepository

type RuleRepository struct {
	eel.RepositoryBase
}

func NewRuleRepository

func NewRuleRepository(ctx context.Context) *RuleRepository

func (*RuleRepository) GetAllRulesForCorp

func (this *RuleRepository) GetAllRulesForCorp(corp business.ICorp, page *eel.PageInfo, filters eel.Map) ([]*Rule, eel.INextPageInfo)

GetAllRulesForCorp 获得所有Rule对象集合

func (*RuleRepository) GetEnabledRules

func (this *RuleRepository) GetEnabledRules(page *eel.PageInfo, filters eel.Map) ([]*Rule, eel.INextPageInfo)

GetEnabledRules 获得启用的Rule对象集合

func (*RuleRepository) GetPagedRules

func (this *RuleRepository) GetPagedRules(filters eel.Map, page *eel.PageInfo, orderExprs ...string) ([]*Rule, eel.INextPageInfo)

func (*RuleRepository) GetRule

func (this *RuleRepository) GetRule(id int) *Rule

GetRule 根据id获得Rule对象

func (*RuleRepository) GetRuleByName

func (this *RuleRepository) GetRuleByName(name string) *Rule

GetRuleByName 根据name获得Rule对象

func (*RuleRepository) GetRuleInCorp

func (this *RuleRepository) GetRuleInCorp(corp business.ICorp, id int) *Rule

GetRuleInCorp 根据id和corp获得Rule对象

func (*RuleRepository) GetRules

func (this *RuleRepository) GetRules(filters eel.Map, orderExprs ...string) []*Rule

func (*RuleRepository) GetRulesForCorp

func (this *RuleRepository) GetRulesForCorp(corp business.ICorp, page *eel.PageInfo, filters eel.Map) ([]*Rule, eel.INextPageInfo)

GetRulesForCorp 获得启用的Rule对象集合

type RuleService

type RuleService struct {
	eel.ServiceBase
}

func NewRuleService

func NewRuleService(ctx context.Context) *RuleService

func (*RuleService) DeleteRuleById

func (this *RuleService) DeleteRuleById(id int) bool

DeleteRule 根据id删除Rule对象

func (*RuleService) DeleteRuleByIds

func (this *RuleService) DeleteRuleByIds(ids []int) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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