浏览代码

周六修改whd提交

wanghuidong 4 年之前
父节点
当前提交
4a6be163ec
共有 2 个文件被更改,包括 49 次插入3 次删除
  1. 2 2
      conf/dev/mysql.toml
  2. 47 1
      lock/interface.go

+ 2 - 2
conf/dev/mysql.toml

@@ -1,6 +1,6 @@
 driver_name = "mysql"
-#data_source_name = "root:Topnet123@tcp(192.168.3.11:3366)/sword_interface_service?charset=utf8mb4&parseTime=true&loc=Local"
-data_source_name = "root:Zxy@19860122@tcp(39.107.203.162:3336)/sword_interface_service?charset=utf8mb4&parseTime=true&loc=Local"
+data_source_name = "root:Topnet123@tcp(192.168.3.11:3366)/sword_interface_service?charset=utf8mb4&parseTime=true&loc=Local"
+#data_source_name = "root:Zxy@19860122@tcp(localhost:3306)/sword_interface_service?charset=utf8mb4&parseTime=true&loc=Local"
 max_open_conn = 20
 max_idle_conn = 10
 max_conn_life_time = 100

+ 47 - 1
lock/interface.go

@@ -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() {
+
+}