1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package lock
- /**
- 用户消费接口
- */
- type Cost interface {
- deduction() //扣费(剩余量|账户余额)
- before() bool
- after()
- }
- type Deduction interface {
- }
- type LeftNumUserCost struct {
- AppID string
- ProductID int
- LeftNum int
- ProductType int
- DataNumLimitOneTimes int
- }
- type AccountBalanceUserCost struct {
- AppID string
- ProductID int
- AccountBalance int
- }
- func (l *LeftNumUserCost) deduction() {
- }
- func (l *LeftNumUserCost) 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 *LeftNumUserCost) after() {
- switch l.ProductType {
- case 0:
- case 1:
- }
- }
- func (a *AccountBalanceUserCost) deduction() {
- }
|