ソースを参照

Merge branch 'dev4.6.2.17' of http://192.168.3.207:8080/qmx/jy into dev4.6.2.17

zhangyuhan 3 年 前
コミット
29ecbd05c5

+ 11 - 3
src/jfw/modules/subscribepay/src/entity/resourcePackStruct.go

@@ -12,6 +12,8 @@ import (
 	"strconv"
 	"strconv"
 	"time"
 	"time"
 	"util"
 	"util"
+
+	"github.com/shopspring/decimal"
 )
 )
 
 
 //资源包
 //资源包
@@ -147,9 +149,15 @@ func (this *resoucePackStruct) Filter(product, userid, lotteryId, discountId str
 				rs.OrderMoney = rs.Price - reduce_price
 				rs.OrderMoney = rs.Price - reduce_price
 			} else {
 			} 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
 			rs.UserLotteryId = userLotteryId
 		}
 		}