Jelajahi Sumber

修改价格计算

wangkaiyue 5 tahun lalu
induk
melakukan
3588143213

+ 36 - 95
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -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

+ 1 - 1
src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go

@@ -116,7 +116,7 @@ func (t *TrialOrder) SendPhoneCaptcha() {
 		}
 		imgcode_sess := qutil.ObjToString(t.GetSession("subvip_trial_imgCode"))
 		if !captcha.VerifyString(imgcode_sess, imgcode_req) || imgcode_req == "" {
-			return false, "图形验证码不正确"
+			return false, "图形验证码错误"
 		}
 		//获取上次发送验证码时间
 		lastSend := qutil.Int64All(t.GetSession("subvip_trial_lastSend"))

+ 10 - 0
src/web/staticres/vipsubscribe/js/common.js

@@ -139,6 +139,16 @@ function getsubVipOrderPriceBybuyset(buyset, t, price) {
         }
     }
 	var vipbuyset = JSON.parse(JSON.stringify(buyset));
+	
+	if (!$.isEmptyObject(vipbuyset.citys)) {
+		for (var i in vipbuyset.citys) {
+			if(vipbuyset.citys[i]>price.cityMaxCount){
+				vipbuyset.areacount++
+				delete vipbuyset.citys[i]
+			}
+		}
+	}
+	
     //当省份数量大于price.ProvinceMaxCount 按照全国计算
     if (vipbuyset.areacount > price.provinceMaxCount) {
         vipbuyset.areacount = -1