|
@@ -370,44 +370,45 @@ func (this *vipSubscribeStruct) SaveSelectLog(userId, openId string, msg *VipSim
|
|
|
}
|
|
|
|
|
|
//计算价格
|
|
|
+// area具体省市名称
|
|
|
+//industry 具体行业
|
|
|
+//count 时间长度 unit 时间单位
|
|
|
func (this *vipSubscribeStruct) GetSubVipPrice(area *map[string]interface{}, industry []string, count, unit int) int {
|
|
|
+ industryNum := len(industry) //行业数量
|
|
|
+ pCount := -1 //省份数量
|
|
|
+ cityCountMap := map[string]int{} //购买省份中城市数量
|
|
|
+ if len(*area) > 0 {
|
|
|
+ pCount = 0
|
|
|
+ for k, v := range *area {
|
|
|
+ tmp := v.([]interface{})
|
|
|
+ if len(tmp) == 0 { //省份
|
|
|
+ pCount++
|
|
|
+ } else { //城市
|
|
|
+ cityCountMap[k] = len(tmp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this.GetSubVipPriceByBuySet(cityCountMap, pCount, industryNum, count, unit)
|
|
|
+}
|
|
|
+
|
|
|
+//cityCountMap 选择城市数量
|
|
|
+//pCount 选择省份数量 pCount:-1 (全国)
|
|
|
+//industryNum 选择行业数量
|
|
|
+//count 时间长度 unit 时间单位
|
|
|
+func (this *vipSubscribeStruct) GetSubVipPriceByBuySet(cityCountMap map[string]int, pCount, industryNum, count, unit int) int {
|
|
|
payMoney := func() int {
|
|
|
//当行业数量大于最大值SubVipPrice.BuyerClassMaxCount 按照全行业计算
|
|
|
- industryNum := len(industry)
|
|
|
if industryNum > SubVipPrice.BuyerClassMaxCount {
|
|
|
industryNum = 0
|
|
|
}
|
|
|
- //计算地区数量
|
|
|
- pCount := -1 //省份数量
|
|
|
- cityCountMap := map[string]int{} //购买省份中城市数量
|
|
|
-
|
|
|
- if len(*area) != 0 {
|
|
|
- pCount = 0
|
|
|
- for k, v := range *area {
|
|
|
- tmp := v.([]interface{})
|
|
|
- if len(tmp) == 0 { //省份
|
|
|
- pCount++
|
|
|
- } else { //城市
|
|
|
- //当城市数量大于最大值时,按照全省计算
|
|
|
- if len(tmp) > SubVipPrice.CityMaxCount {
|
|
|
- pCount++
|
|
|
- } else {
|
|
|
- cityCountMap[k] = len(tmp)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //当选择月份大于 按照全年计算
|
|
|
+ if count > SubVipPrice.MonthMaxCount && unit == 2 { //月份十个月以上价格一样
|
|
|
+ count = 10
|
|
|
}
|
|
|
-
|
|
|
//当省份数量大于SubVipPrice.ProvinceMaxCount 按照全国计算
|
|
|
if pCount > SubVipPrice.ProvinceMaxCount {
|
|
|
pCount = -1
|
|
|
}
|
|
|
-
|
|
|
- //当选择月份大于 按照全年计算
|
|
|
- if count > SubVipPrice.MonthMaxCount && unit == 2 { //月份十个月以上价格一样
|
|
|
- count = 10
|
|
|
- }
|
|
|
-
|
|
|
if pCount == -1 { //计算全国套餐价格
|
|
|
if industryNum == 1 {
|
|
|
return getSetMealPrice(0, 1, unit) * count //全国1行业套餐
|
|
@@ -417,9 +418,15 @@ func (this *vipSubscribeStruct) GetSubVipPrice(area *map[string]interface{}, ind
|
|
|
return getSetMealPrice(0, industryNum, unit) * count //全国多行业套餐
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//计算非全国套餐
|
|
|
- finalPrice := 0 //省份价格
|
|
|
+ finalPrice := 0
|
|
|
+ //城市选择过多时,转为省份
|
|
|
+ for cityName, cityCount := range cityCountMap {
|
|
|
+ if cityCount > SubVipPrice.CityMaxCount {
|
|
|
+ pCount++
|
|
|
+ delete(cityCountMap, cityName)
|
|
|
+ }
|
|
|
+ }
|
|
|
for _, cityCount := range cityCountMap {
|
|
|
thisPrice := 0
|
|
|
if cityCount == 1 { //单城市
|
|
@@ -428,16 +435,10 @@ func (this *vipSubscribeStruct) GetSubVipPrice(area *map[string]interface{}, ind
|
|
|
if industryNum == 0 || industryNum == 1 { //多城市 单行业
|
|
|
thisPrice = cityCount * getSetMealPrice(2, industryNum, unit) * count
|
|
|
} else { //多城市 多行业
|
|
|
- //industryPrice := SubVipPrice.BuyerClassPrice * industryNum
|
|
|
- //cityPrice := SubVipPrice.CityPrice * cityCount
|
|
|
- //thisPrice = (industryPrice + cityPrice) * count
|
|
|
if cityCount > SubVipPrice.CityMaxCount {
|
|
|
pCount++
|
|
|
} else {
|
|
|
thisPrice = getSetMealPrice(2, industryNum, unit) * cityCount * count
|
|
|
- // if unit == 1 { //年
|
|
|
- // thisPrice *= 10
|
|
|
- // }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -462,66 +463,6 @@ func (this *vipSubscribeStruct) GetSubVipPrice(area *map[string]interface{}, ind
|
|
|
return payMoney
|
|
|
}
|
|
|
|
|
|
-//计算价格
|
|
|
-func (this *vipSubscribeStruct) GetSubVipBuysetPrice(buyset *map[string]interface{}, count, unit int) int {
|
|
|
- industryNum := qutil.IntAll((*buyset)["buyerclasscount"])
|
|
|
- if industryNum == -1 {
|
|
|
- industryNum = 0
|
|
|
- }
|
|
|
- //当行业数量大于最大值SubVipPrice.BuyerClassMaxCount 按照全行业计算
|
|
|
- // industryNum := len(industry)
|
|
|
- if industryNum > SubVipPrice.BuyerClassMaxCount {
|
|
|
- industryNum = 0
|
|
|
- }
|
|
|
- //计算地区数量
|
|
|
- pCount := qutil.IntAll((*buyset)["areacount"]) //省份数量
|
|
|
- // cityCountMap := map[string]int{} //购买省份中城市数量
|
|
|
- //当省份数量大于SubVipPrice.ProvinceMaxCount 按照全国计算
|
|
|
- if pCount > SubVipPrice.ProvinceMaxCount {
|
|
|
- pCount = -1
|
|
|
- }
|
|
|
- //当选择月份大于 按照全年计算
|
|
|
- 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 += thisPrice
|
|
|
- }
|
|
|
- finalPrice += pCount * getSetMealPrice(1, industryNum, unit) * count
|
|
|
- return finalPrice
|
|
|
-}
|
|
|
-
|
|
|
/*
|
|
|
vip订阅 套餐价格
|
|
|
c(city) 全国:0 省:1 市:2
|