xuzhiheng 5 жил өмнө
parent
commit
ab26aae8fe

+ 49 - 62
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -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
 }
 
 /*

+ 20 - 9
src/jfw/modules/subscribepay/src/service/vipRenewUpgrade.go

@@ -117,14 +117,16 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 	//		industry = append(industry, "no")
 	//	}
 	// -------差价计算部分可注释-----
-	areas := qutil.ObjToMap(this.GetString("areas"))                 //已购买区域
-	industrys := strings.Split(this.GetString("industryarr"), ",")   //已购买行业
+	//	areas := qutil.ObjToMap(this.GetString("areas"))                 //已购买区域
+	//	industrys := strings.Split(this.GetString("industryarr"), ",")   //已购买行业
 	allBuyArea := qutil.ObjToMap(this.GetString("allBuyArea"))       //已购+新增区域
 	allIndustry := strings.Split(this.GetString("allIndustry"), ",") //已购+新增行业
 	date := this.GetString("time")                                   //不延长时为空,正常为 年或月
 	payWay := this.GetString("payWay")                               //支付方式
 	pay_source := this.GetString("pay_source")                       //类型  续费-Renew or 升级-Upgrade
 	addCount := this.GetString("addCount")
+	oldBuyset := qutil.ObjToMap(this.GetString("oldbuyset"))
+	log.Println("111", oldBuyset)
 	buyset := qutil.ObjToMap(this.GetString("buyset"))
 	log.Println("111", buyset)
 	var vipBuyCount *map[string]interface{}
@@ -144,9 +146,9 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 			industry = []string{}
 		}
 		//		}
-		if len(industrys) == 1 && industrys[0] == "" { //去掉[""]
-			industrys = []string{}
-		}
+		//		if len(industrys) == 1 && industrys[0] == "" { //去掉[""]
+		//			industrys = []string{}
+		//		}
 		if len(allIndustry) == 1 && allIndustry[0] == "" { //去掉[""]
 			allIndustry = []string{}
 		}
@@ -221,7 +223,8 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 		//计算价格
 		var totalfee int
 		if pay_source == "Renew" {
-			totalfee = entity.JyVipSubStruct.GetSubVipPrice(area, industry, date_count, date_unit)
+			//			totalfee = entity.JyVipSubStruct.GetSubVipPrice(area, industry, date_count, date_unit)
+			totalfee = entity.JyVipSubStruct.GetSubVipBuysetPrice(buyset, date_count, date_unit)
 		} else if pay_source == "Upgrade" {
 			upgradeYear, upgradeMonth := MaxUpgradeMonth(end) //获取最大升级月数
 			// -------差价计算可注释-----
@@ -272,8 +275,10 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 			//			totalfee = addAreaY + addAreaM + oldAreaY + oldAreaM + addIndustryY + addIndustryM
 			// --------升级价格交叉计算--------
 			// --------升级价格差价计算--------
-			oldPriceY := entity.JyVipSubStruct.GetSubVipPrice(areas, industrys, upgradeYear, 1)
-			oldPriceM := entity.JyVipSubStruct.GetSubVipPrice(areas, industrys, upgradeMonth, 2)
+			//			oldPriceY := entity.JyVipSubStruct.GetSubVipPrice(areas, industrys, upgradeYear, 1)
+			//			oldPriceM := entity.JyVipSubStruct.GetSubVipPrice(areas, industrys, upgradeMonth, 2)
+			oldPriceY := entity.JyVipSubStruct.GetSubVipBuysetPrice(oldBuyset, upgradeYear, 1)
+			oldPriceM := entity.JyVipSubStruct.GetSubVipBuysetPrice(oldBuyset, upgradeMonth, 2)
 			oldPrice := oldPriceY + oldPriceM
 			//			newPriceY := entity.JyVipSubStruct.GetSubVipPrice(allBuyArea, allIndustry, upgradeYear, 1)
 			//			newPriceM := entity.JyVipSubStruct.GetSubVipPrice(allBuyArea, allIndustry, upgradeMonth, 2)
@@ -292,7 +297,13 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 			}
 		}
 		log.Println("price", totalfee)
-		//		totalfee = 1
+		paymoneny := float64(totalfee) * 0.0000001
+		if paymoneny < 1 {
+			if totalfee != 0 {
+				totalfee = 1
+			}
+		}
+		log.Println("price", totalfee)
 
 		//创建订单
 		tradeno, prepayid, payStr := "", "", ""

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

@@ -138,7 +138,6 @@ function getsubVipOrderPriceBybuyset(buyset, t, price) {
             }, false)
         }
     }
-    console.log("buyset", JSON.stringify(buyset));
 	var vipbuyset = JSON.parse(JSON.stringify(buyset));
     //当省份数量大于price.ProvinceMaxCount 按照全国计算
     if (vipbuyset.areacount > price.provinceMaxCount) {
@@ -180,7 +179,6 @@ function getsubVipOrderPriceBybuyset(buyset, t, price) {
                     thisPrice = getSetMealPrice(2, vipbuyset.buyerclasscount, t[1], price) * vipbuyset.citys[i] * t[0];
                     // if (t[1] === 1) thisPrice *= 10 //年的价格是月价格的10倍
                 }
-
             }
         }
         final_price += thisPrice;

+ 16 - 16
src/web/staticres/vipsubscribe/js/updateArea.js

@@ -682,26 +682,26 @@ $(function () {
 		let selectedCityLength = $(dom).parent().find('.city.active:not([disabled])').length;
 		let disabledCityLength = $(dom).parent().find('.city[disabled]').length;
 		let cityLength = $(dom).parent().find('.city').length;
-		let dataCount = Number($(dom).parent().parent().attr("data-buy-city-count"));
-		if(dataCount === undefined){
-			dataCount = 0;
-		}else{
-			if(Number(dataCount) !== disabledCityLength){
-				if(disabledCityLength === 0){
-					dataCount = 0;
-				}else{
-					dataCount = dataCount - disabledCityLength;
-				}
-			}
-		}
-		let countShow = 0;
-		let showCount = selectedCityLength + dataCount;
+		// let dataCount = Number($(dom).parent().parent().attr("data-buy-city-count"));
+		// if(dataCount === undefined){
+		// 	dataCount = 0;
+		// }else{
+		// 	if(Number(dataCount) !== disabledCityLength){
+		// 		if(disabledCityLength === 0){
+		// 			dataCount = 0;
+		// 		}else{
+		// 			dataCount = dataCount - disabledCityLength;
+		// 		}
+		// 	}
+		// }
+		// let countShow = 0;
+		let showCounts = selectedCityLength + disabledCityLength;
 		// let showCount = selectedCityLength - dataCount;
-		if(showCount > 2){
+		if(showCounts > 2){
 			if(selectedCityLength === 0){
 				$(".tips_d_text").hide();
 			}else{
-				$(".tips_d_text").text("已选择"+showCount+"个市,建议购买“全省”");
+				$(".tips_d_text").text("已选择"+showCounts+"个市,建议购买“全省”");
 				$(".tips_d_text").show();
 			}
 		}else{

+ 1 - 0
src/web/templates/weixin/vipsubscribe/renew_pay.html

@@ -810,6 +810,7 @@
 	    	var param = {
 	    		"area": JSON.stringify(areas),
 	    		"industry": industrys.toString(),
+				"buyset": JSON.stringify(oldBuyset),
 	    		"time": $('.choose_item.select_cycle .info').val(),
 	    		"payWay":"wx_js",
 	    		"pay_source": "Renew",

+ 3 - 2
src/web/templates/weixin/vipsubscribe/vip_upgrade.html

@@ -1253,9 +1253,9 @@
 	    	var param = {
 	    		// "area": areas_arr,
 	    		// "industry": industryArr,
-	    		"areas": JSON.stringify(areaarr),
+	    		// "areas": JSON.stringify(areaarr),
 	    		// "areas_arr": areaArr,
-	    		"industryarr": industryarr.join(","),
+	    		// "industryarr": industryarr.join(","),
 	    		// "allArea": JSON.stringify(allAreaArr),
 	    		"allIndustry": allIndustryArr.join(","),
 	    		"allBuyArea": JSON.stringify(allArea),
@@ -1265,6 +1265,7 @@
 	    		"addCount":vipCount,
 	    		"addIndustryCount": vipIndustry,
 				"buyset":JSON.stringify(areaObj()),
+				"oldbuyset":JSON.stringify(oldBuyset),
 	    	}
 	    	console.log(param)
 	    	$DoPost("/subscribepay/renewUpgrade/renewUpgradeCreateOrder",param,function(r){