1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package lock
- /**
- 用户消费接口
- */
- type Cost interface {
- Deduction() //扣费(剩余量|账户余额)
- Before() bool
- After()
- }
- type LeftNumCost struct {
- AppID string
- ProductID int
- LeftNum int
- ProductType int
- DataNumLimitOneTimes int
- }
- type AccountBalanceCost struct {
- AppID string
- ProductID int
- AccountBalance int
- }
- func (l *LeftNumCost) Deduction() {
- }
- func (l *LeftNumCost) Before() bool {
- switch l.ProductType {
- case 0:
- //按次扣费的产品-判断left_num
- if l.LeftNum == 0 {
- return false
- }
- case 1:
- //按条扣费的产品-判断单次调用的limit
- if l.LeftNum < l.DataNumLimitOneTimes {
- return false
- }
- }
- return true
- }
- func (l *LeftNumCost) After() {
- switch l.ProductType {
- case 0:
- case 1:
- }
- }
- func (a *AccountBalanceCost) Deduction() {
- }
- func (a *AccountBalanceCost) Before() bool {
- }
- func (a *AccountBalanceCost) After() {
- }
|