|
@@ -60,22 +60,22 @@ func costByAccountBalance(getData func() ([]map[string]interface{}, int, error),
|
|
|
func beforeCheck(productType, unitPrice, dataLen int, userProduct *model.UserProduct) (bool, int) {
|
|
|
userAccount := &model.UserAccount{}
|
|
|
db.GetSFISDB().First(userAccount, &model.UserAccount{AppID: userProduct.AppID})
|
|
|
- money := 0
|
|
|
+ money := float64(0)
|
|
|
switch productType {
|
|
|
case 0:
|
|
|
- money = unitPrice
|
|
|
+ money = float64(unitPrice) / 10 * float64(userProduct.Discount)
|
|
|
//按次扣费-判断left_num
|
|
|
- if money > userAccount.Money {
|
|
|
- return false, money
|
|
|
+ if money > float64(userAccount.Money) {
|
|
|
+ return false, int(money)
|
|
|
}
|
|
|
case 1:
|
|
|
- money = unitPrice * dataLen
|
|
|
+ money = (float64(unitPrice) / 10 * float64(userProduct.Discount)) * float64(dataLen)
|
|
|
//按条扣费-判断单次调用的limit
|
|
|
- if money > userAccount.Money {
|
|
|
- return false, money
|
|
|
+ if money > float64(userAccount.Money) {
|
|
|
+ return false, int(money)
|
|
|
}
|
|
|
}
|
|
|
- return true, money
|
|
|
+ return true, int(money)
|
|
|
}
|
|
|
|
|
|
func afterCheck(dataLen, payMoney int, userProduct *model.UserProduct, statusCode int, param, ip string) (string, error) {
|