|
@@ -4,7 +4,53 @@ package lock
|
|
|
用户消费接口
|
|
|
*/
|
|
|
type Cost interface {
|
|
|
- balance() //余额判断
|
|
|
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() {
|
|
|
+
|
|
|
+}
|