|
@@ -451,7 +451,9 @@ func (this *vipSubscribeStruct) GetSubVipPrice(area *map[string]interface{}, ind
|
|
|
log.Printf("进行折扣计算 折扣前金额%d\n", payMoney)
|
|
|
tmp := float64(payMoney) * SubVipPrice.Discount
|
|
|
if tmp < 1 {
|
|
|
- payMoney = 1
|
|
|
+ if tmp != 0 {
|
|
|
+ payMoney = 1
|
|
|
+ }
|
|
|
} else {
|
|
|
payMoney = int(tmp)
|
|
|
}
|
|
@@ -462,73 +464,58 @@ func (this *vipSubscribeStruct) GetSubVipPrice(area *map[string]interface{}, ind
|
|
|
|
|
|
//计算价格
|
|
|
func (this *vipSubscribeStruct) GetSubVipBuysetPrice(buyset *map[string]interface{}, count, unit int) int {
|
|
|
- payMoney := func() int {
|
|
|
-
|
|
|
- industryNum := qutil.IntAll((*buyset)["buyerclasscount"])
|
|
|
- //当行业数量大于最大值SubVipPrice.BuyerClassMaxCount 按照全行业计算
|
|
|
- // industryNum := len(industry)
|
|
|
- if industryNum > SubVipPrice.BuyerClassMaxCount {
|
|
|
- industryNum = 0
|
|
|
- }
|
|
|
- //计算地区数量
|
|
|
- pCount := qutil.IntAll((*buyset)["areacount"]) //省份数量
|
|
|
- // cityCountMap := map[string]int{} //购买省份中城市数量
|
|
|
-
|
|
|
- //当选择月份大于 按照全年计算
|
|
|
- if count > SubVipPrice.MonthMaxCount && unit == 2 { //月份十个月以上价格一样
|
|
|
- count = 10
|
|
|
- }
|
|
|
-
|
|
|
- if pCount == -1 { //计算全国套餐价格
|
|
|
- if industryNum == 1 {
|
|
|
- return getSetMealPrice(0, 1, unit) * count //全国1行业套餐
|
|
|
- } else if industryNum == 0 {
|
|
|
- return getSetMealPrice(0, 0, unit) * count //全国全行业套餐
|
|
|
- } else {
|
|
|
- return getSetMealPrice(0, industryNum, unit) * count //全国多行业套餐
|
|
|
- }
|
|
|
+ industryNum := qutil.IntAll((*buyset)["buyerclasscount"])
|
|
|
+ //当行业数量大于最大值SubVipPrice.BuyerClassMaxCount 按照全行业计算
|
|
|
+ // industryNum := len(industry)
|
|
|
+ if industryNum > SubVipPrice.BuyerClassMaxCount {
|
|
|
+ industryNum = 0
|
|
|
+ }
|
|
|
+ //计算地区数量
|
|
|
+ pCount := qutil.IntAll((*buyset)["areacount"]) //省份数量
|
|
|
+ // cityCountMap := map[string]int{} //购买省份中城市数量
|
|
|
+
|
|
|
+ //当选择月份大于 按照全年计算
|
|
|
+ if count > SubVipPrice.MonthMaxCount && unit == 2 { //月份十个月以上价格一样
|
|
|
+ count = 10
|
|
|
+ }
|
|
|
+
|
|
|
+ if pCount == -1 { //计算全国套餐价格
|
|
|
+ if industryNum == 1 {
|
|
|
+ return getSetMealPrice(0, 1, unit) * count //全国1行业套餐
|
|
|
+ } else if industryNum == 0 {
|
|
|
+ return getSetMealPrice(0, 0, unit) * count //全国全行业套餐
|
|
|
+ } else {
|
|
|
+ return getSetMealPrice(0, industryNum, unit) * count //全国多行业套餐
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //计算非全国套餐
|
|
|
- finalPrice := 0 //省份价格
|
|
|
- cityCountMap := qutil.ObjToMap((*buyset)["citys"])
|
|
|
- for _, cityCount := range *cityCountMap {
|
|
|
- thisPrice := 0
|
|
|
- // cityCount = qutil.IntAll(cityCount)
|
|
|
- if qutil.IntAll(cityCount) == 1 { //单城市
|
|
|
- thisPrice = getSetMealPrice(2, industryNum, unit) * count
|
|
|
- } else { //多城市
|
|
|
- if industryNum == 0 || industryNum == 1 { //多城市 单行业
|
|
|
- if qutil.IntAll(cityCount) > SubVipPrice.CityMaxCount {
|
|
|
- pCount++
|
|
|
- } else {
|
|
|
- thisPrice = qutil.IntAll(cityCount) * getSetMealPrice(2, industryNum, unit) * count
|
|
|
- }
|
|
|
- } else { //多城市 多行业
|
|
|
- if qutil.IntAll(cityCount) > SubVipPrice.CityMaxCount {
|
|
|
- pCount++
|
|
|
- } else {
|
|
|
- thisPrice = getSetMealPrice(2, industryNum, unit) * qutil.IntAll(cityCount) * count
|
|
|
- }
|
|
|
+ //计算非全国套餐
|
|
|
+ finalPrice := 0 //省份价格
|
|
|
+ cityCountMap := qutil.ObjToMap((*buyset)["citys"])
|
|
|
+ for _, cityCount := range *cityCountMap {
|
|
|
+ thisPrice := 0
|
|
|
+ // cityCount = qutil.IntAll(cityCount)
|
|
|
+ if qutil.IntAll(cityCount) == 1 { //单城市
|
|
|
+ thisPrice = getSetMealPrice(2, industryNum, unit) * count
|
|
|
+ } else { //多城市
|
|
|
+ if industryNum == 0 || industryNum == 1 { //多城市 单行业
|
|
|
+ if qutil.IntAll(cityCount) > SubVipPrice.CityMaxCount {
|
|
|
+ pCount++
|
|
|
+ } else {
|
|
|
+ thisPrice = qutil.IntAll(cityCount) * getSetMealPrice(2, industryNum, unit) * count
|
|
|
+ }
|
|
|
+ } else { //多城市 多行业
|
|
|
+ if qutil.IntAll(cityCount) > SubVipPrice.CityMaxCount {
|
|
|
+ pCount++
|
|
|
+ } else {
|
|
|
+ thisPrice = getSetMealPrice(2, industryNum, unit) * qutil.IntAll(cityCount) * count
|
|
|
}
|
|
|
}
|
|
|
- finalPrice += thisPrice
|
|
|
}
|
|
|
- finalPrice += pCount * getSetMealPrice(1, industryNum, unit) * count
|
|
|
- return finalPrice
|
|
|
- }()
|
|
|
- if SubVipPrice.Discount < 1 {
|
|
|
- //测试环境修改金额
|
|
|
- log.Printf("进行折扣计算 折扣前金额%d\n", payMoney)
|
|
|
- tmp := float64(payMoney) * SubVipPrice.Discount
|
|
|
- if tmp < 1 {
|
|
|
- payMoney = 1
|
|
|
- } else {
|
|
|
- payMoney = int(tmp)
|
|
|
- }
|
|
|
- log.Printf("进行折扣计算 折扣后金额%d\n", payMoney)
|
|
|
+ finalPrice += thisPrice
|
|
|
}
|
|
|
- return payMoney
|
|
|
+ finalPrice += pCount * getSetMealPrice(1, industryNum, unit) * count
|
|
|
+ return finalPrice
|
|
|
}
|
|
|
|
|
|
/*
|