|
@@ -12,6 +12,8 @@ import (
|
|
|
"strconv"
|
|
|
"time"
|
|
|
"util"
|
|
|
+
|
|
|
+ "github.com/shopspring/decimal"
|
|
|
)
|
|
|
|
|
|
//资源包
|
|
@@ -147,9 +149,15 @@ func (this *resoucePackStruct) Filter(product, userid, lotteryId, discountId str
|
|
|
rs.OrderMoney = rs.Price - reduce_price
|
|
|
} else {
|
|
|
//折扣
|
|
|
- disCount_int := int(math.Ceil(discount * 100))
|
|
|
- rs.DiscountPrice = rs.Price - rs.Price*disCount_int/1000
|
|
|
- rs.OrderMoney = rs.Price * disCount_int / 1000
|
|
|
+ // disCount_int := int(math.Ceil(discount * 100))
|
|
|
+ // rs.DiscountPrice = rs.Price - rs.Price*disCount_int/1000
|
|
|
+ // rs.OrderMoney = rs.Price * disCount_int / 1000
|
|
|
+
|
|
|
+ disCount_int := int(math.Ceil(discount * 1000)) //折扣
|
|
|
+ DiscountPrice := (float64)(rs.Price*(10000-disCount_int)) / 10000 //优惠金额
|
|
|
+ DiscountPrice_float, _ := decimal.NewFromFloat(DiscountPrice / 100).Round(2).Float64()
|
|
|
+ rs.DiscountPrice = int(decimal.NewFromFloat(DiscountPrice_float * 100).Round(2).IntPart()) //算出价格
|
|
|
+ rs.OrderMoney = rs.Price - int(rs.DiscountPrice) //优惠后价格
|
|
|
}
|
|
|
rs.UserLotteryId = userLotteryId
|
|
|
}
|