Ver código fonte

新增数量

xuzhiheng 5 anos atrás
pai
commit
16f609d285

+ 9 - 7
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -54,13 +54,15 @@ type subVipPrice struct {
 //订单简单信息
 type VipSimpleMsg struct {
 	//Id         string                  `json:"_id"`        //mgo id
-	Area        *map[string]interface{} `json:"area"`        //地区
-	Industry    []string                `json:"industry"`    //行业
-	Addarea     *map[string]interface{} `json:"addarea"`     //新增地区
-	Addindustry []string                `json:"addindustry"` //新增行业
-	Cyclecount  int                     `json:"cyclecount"`  //日期数量
-	Cycleunit   int                     `json:"cycleunit"`   //日期单位
-	OrderType   int                     `json:"ordertype"`   //类型 1:订单 2:续费 3:立即升级 4:下月升级 5:即将到期(升降级)6:升级订单未生效再次升级
+	Area               *map[string]interface{} `json:"area"`               //地区
+	Industry           []string                `json:"industry"`           //行业
+	Addarea            *map[string]interface{} `json:"addarea"`            //新增订阅地区
+	Addindustry        []string                `json:"addindustry"`        //新增订阅行业
+	Addareacount       *map[string]interface{} `json:"addbuycount"`        //新增购买区域数量
+	Addbuyerclasscount int                     `json:"addbuyerclasscount"` //新增行业数量
+	Cyclecount         int                     `json:"cyclecount"`         //日期数量
+	Cycleunit          int                     `json:"cycleunit"`          //日期单位
+	OrderType          int                     `json:"ordertype"`          //类型 1:订单 2:续费 3:立即升级 4:下月升级 5:即将到期(升降级)6:升级订单未生效再次升级
 }
 
 //购买内容

+ 14 - 36
src/jfw/modules/subscribepay/src/service/vipRenewUpgrade.go

@@ -44,7 +44,6 @@ func (this *RenewUpgrade) GetBuyMsg() {
 		now := time.Unix(time.Now().Unix(), 0).Format("2006-01-02")
 		vipStatus := (*data)["i_vip_status"]
 		buyset := vipjy["o_buyset"]
-		//		isvalidOk := true
 
 		orderdata := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
 			"user_id":      userId,
@@ -114,12 +113,18 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 	allIndustry := strings.Split(this.GetString("allIndustry"), ",") //已购+新增行业
 	date := this.GetString("time")                                   //不延长时为空,正常为 年或月
 	payWay := this.GetString("payWay")                               //支付方式
-	log.Println("payWay", payWay)
-	//	effect := this.GetString("effect")         //升级 生效日期 立即生效-now  下月一号生效-下月一号的时间戳
-	pay_source := this.GetString("pay_source") //类型  续费-Renew or 升级-Upgrade
+	pay_source := this.GetString("pay_source")                       //类型  续费-Renew or 升级-Upgrade
+	addCount := this.GetString("addCount")
+	var vipBuyCount *map[string]interface{}
+	if addCount != "" {
+		vipBuyCount = qutil.ObjToMap(addCount) //新增购买区域数量
+	} else {
+		vipBuyCount = &map[string]interface{}{}
+	}
+	industryCount, _ := this.GetInteger("addIndustryCount")
+	log.Println("666", industryCount)
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
-	//	isvalidOk, _ := this.GetBool("isvalidOk")
 	r := func() *entity.FuncResult {
 		now := time.Now()
 		//数据校验
@@ -164,37 +169,15 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 		isRenew := true
 		if pay_source == "Upgrade" { //计算升级时间
 			isRenew = false
-			//			if effect == "now" { //立即生效
 			orderType = 3
 			startTime = time.Now()
-			//			} else { //下月生效
-			//				orderType = 4
-			//				startTime = time.Date(time.Now().Year(), time.Now().Month()+1, 1, 0, 0, 0, 0, time.Local)
-			//			}
-			//			if !isvalidOk {
-			//				orderType = 6
-			//			}
 		} else { //续费时间
 			orderType = 2 //续费操作
 			startTime = endTime
 		}
-		//		if date_unit == 1 { ///延长时间
-		//			endTime = endTime.AddDate(date_count, 0, 0)
-		//		} else if date_unit == 2 { //月
-		//			endTime = endTime.AddDate(0, date_count, 0)
-		//		}
 		if date_unit >= 1 {
 			endTime = util.GetDATE(date_unit, date_count, end)
 		}
-		//		if pay_source == "Renew" && now.Unix() > end { //到期后的续费从当前时间往后延长
-		//			startTime = now
-		//			//			if date_unit == 1 { ///延长时间
-		//			//				endTime = startTime.AddDate(date_count, 0, 0)
-		//			//			} else if date_unit == 2 { //月
-		//			//				endTime = startTime.AddDate(0, date_count, 0)
-		//			//			}
-		//			endTime = util.GetDATE(date_unit, date_count, startTime.Unix())
-		//		}
 		filter := entity.VipSimpleMsg{}
 		if pay_source == "Renew" {
 			vipjy := (*res)["o_vipjy"].(map[string]interface{})
@@ -203,6 +186,8 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 				qutil.ObjArrToStringArr(vipjy["a_buyerclass"].([]interface{})),
 				nil,
 				nil,
+				nil,
+				0,
 				date_count,
 				date_unit,
 				orderType,
@@ -213,6 +198,8 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 				allIndustry,
 				area,
 				industry,
+				vipBuyCount,
+				industryCount,
 				date_count,
 				date_unit,
 				orderType,
@@ -274,15 +261,6 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 				addIndustryY = entity.JyVipSubStruct.GetSubVipPrice(areas, industry, upgradeYear, 1)
 				addIndustryM = entity.JyVipSubStruct.GetSubVipPrice(areas, industry, upgradeMonth, 2)
 			}
-			//			addY := entity.JyVipSubStruct.GetSubVipPrice(area, industry, upgradeYear, 1)  //已购+新增,以年为单位的价格
-			//			addM := entity.JyVipSubStruct.GetSubVipPrice(area, industry, upgradeMonth, 2) //已购+新增,以月为单位的价格
-			//			addPrice := addM + addY                                                       //已购+新增总价格
-			//			log.Println("1", addPrice)
-			//			nowY := entity.JyVipSubStruct.GetSubVipPrice(areas, industrys, upgradeYear, 1)  //已购,以年为单位的价格
-			//			nowM := entity.JyVipSubStruct.GetSubVipPrice(areas, industrys, upgradeMonth, 2) //已购,以月为单位的价格
-			//			nowPrice := nowM + nowY                                                         //已购总价格
-			//			log.Println("2", nowPrice)
-			//			totalfee = addPrice - nowPrice //已购+新增的总价格 - 已购总价格 = 升级差价
 			totalfee = addAreaY + addAreaM + oldAreaY + oldAreaM + addIndustryY + addIndustryM
 			if date_unit == 1 { //升级中的延长时间
 				lengPrice := entity.JyVipSubStruct.GetSubVipPrice(allArea, allIndustry, date_count, 1) //单位为年的已购+新增延长时间价格

+ 2 - 0
src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -65,6 +65,8 @@ func (this *SubVipPayOrder) CreateOrder() {
 			industry,
 			nil,
 			nil,
+			nil,
+			0,
 			date_count,
 			date_unit,
 			orderType,

+ 2 - 0
src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go

@@ -286,6 +286,8 @@ func (this *TrialOrder) TrialPay() {
 			industry,
 			nil,
 			nil,
+			nil,
+			0,
 			date_count,
 			date_unit,
 			0,

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

@@ -700,8 +700,8 @@ $(function () {
 //      console.log(activeCityDetail)
 //      console.log(areaData)
 //      console.log(alreadyBuy)
-//      console.log(newlyAdded)
-        sessionStorage.vipSubSelectCity = newlyAdded.city
+        sessionStorage.vipAddCount = JSON.stringify(newlyAdded);
+        sessionStorage.vipSubSelectCity = newlyAdded.city;
         sessionStorage.vipSubSelectAreaUpgrade = JSON.stringify(activeCityDetail);
         sessionStorage.vipSubSelectAreaAdd = JSON.stringify(areaCount);
         history.go(-1);

+ 22 - 247
src/web/templates/weixin/vipsubscribe/vip_upgrade.html

@@ -798,38 +798,6 @@
 				areaHtml = "已新增 "+ vipSubSelectArea.province +" 个省级区域、"+ cityLen +" 个地市";
 				$("#area").attr("placeholder", areaHtml);
 			}
-//			var provinceArr = [];
-//			var cityArr = [];
-//			var isAll = "";
-//			$(".area-list").show();
-//			for (var province in vipSubSelectArea){
-//				if(vipSubSelectArea[province].length > 0){
-//					var citys = vipSubSelectArea[province];
-//					for (var i in citys){
-//						var city = citys[i];
-//						cityArr.push(city);
-//					}
-//				}else{
-//					provinceArr.push(province);
-//				}
-//				if(province === "全国"){
-//					isAll = "all";
-//				}
-//			}
-//			var provinceLen = provinceArr.length;
-//			var cityLen = cityArr.length;
-//			var areaHtml = "";
-//			if(isAll === ""){
-//				areaHtml = "已新增 "+ provinceLen +" 个省级区域、"+ cityLen +" 个地市";
-//				$("#area").attr("placeholder", areaHtml);
-//			}else{
-//				areaHtml = "已新增全国";
-//				$("#area").attr("placeholder", areaHtml);
-//			}
-//			if(provinceLen === 0 && cityLen === 0){
-//				areaHtml = "选择升级区域";
-//				$("#area").attr("placeholder", areaHtml);
-//			}
 	    }
 	    //新增行业
 	    if(sessionStorage.vipSubSelectIndustryAdd!==""&&sessionStorage.vipSubSelectIndustryAdd!==undefined){
@@ -858,40 +826,7 @@
 				$("#buyerclass").attr("placeholder", industryHtml);
 			}
 	    }
-	    //生效时间
-//	    if(sessionStorage.effectiveDate !== ""&&sessionStorage.effectiveDate!==undefined){
-//	    	var effective = sessionStorage.effectiveDate;
-//	    	var effectiveHtml = "";
-//	    	if(effective === "now"){
-//	    		effectiveHtml = "立即生效,需支付当月费用差价";
-//	    	}else if(effective === "notnow"){
-//	    		var effectiveName = new Date().getMonth()+2;
-//	    		if(effectiveName > 12){
-//	    			effectiveName = effectiveName - 12
-//	    		}
-//	    		effectiveHtml = effectiveName+"月1日生效";
-//	    	}
-//	    	$(".effective_name").each(function(){
-//	    		if($(this).text() === effectiveHtml){
-//	    			$(this).parent().next().find("input").prop("checked", true);
-//	    		}
-//	    	})
-//	    	$('#effect_date_name').html(effectiveHtml);
-//	    }
-//	    //支付方式
-//	    if(sessionStorage.payType!==""&&sessionStorage.payType!==undefined){
-//	    	var payType = sessionStorage.payType;
-//	    	var payHtml = "";
-//	    	if(payType === "wx"){
-//	    		payHtml = "微信支付";
-//	    	}else if(payType === "alipy"){
-//	    		payHtml = "支付宝支付";
-//	    	}
-//	    	$('input:radio[name="way"]').val(payHtml);
-//	    	$('input:radio[name="way"]').prop("checked", true);
-//	    	$("#payType").text(payHtml);
-//	    }
-
+		//
 		if(sessionStorage.upgrade_cyclecount!==undefined&&sessionStorage.upgrade_cycleunit!==undefined){
 	 		var cycleunit = sessionStorage.upgrade_cycleunit;
 	 		var cyclecount = sessionStorage.upgrade_cyclecount;
@@ -921,9 +856,6 @@
 	 		$('.choose_item.lengthen .info').text("不延长");
 	 		$(".computed_price").hide();
 	 	}
-	 	
-//	 	if(sessionStorage.vipSubSelectArea!==""&&sessionStorage.vipSubSelectArea!==undefined&&)
-	 	
 	 	//
 	 	var area = "";
 	    var buyerclass = "";
@@ -948,61 +880,6 @@
 			    starts = data.starttime;
 			    endTime = data.end;
 			    ends = data.endtime;
-//			    isvalidOk = data.isvalidOk;
-			    //
-//			    var provinceArr = [];
-//			    var cityArr = [];
-//			    var areaHtml = "";
-//			    var buyerclassArr = [];
-//			    var buyerclassHtml = "";
-		//	    var dateName = "";
-		//	    var dateHtml = "";
-//			    if (area !== "" && area !== undefined){
-//			    	for(var province in area){
-//			    		var citys = area[province]
-//		//	    		console.log(citys);
-//			    		if(citys.length===0){
-//			    			provinceArr.push(province);
-//			    		}else{
-//			    			for(var i in citys){
-//			    				cityArr.push(citys[i]);
-//			    			}
-//			    		}
-//			    	}
-//			    	var provinceLen = provinceArr.length;
-//			 		var cityLen = cityArr.length;
-//			    	areaHtml = "已购买"+provinceLen+"个省级区域/"+cityLen+"个市";
-//		//	    	$(".item_area .label_for").text(areaHtml);
-//					if(checkObj(area)){
-//						areaHtml = "已购买全国";
-//					}
-//			    	$('#area').attr("placeholder",areaHtml);
-//			    }
-//			    if(buyerclass !== "" && buyerclass !== undefined){
-//			    	for(var i in buyerclass){
-//			    		var industry = buyerclass[i];
-//			    		buyerclassArr.push(industry);
-//			    		buyerclassHtml = "已购买"+buyerclassArr.length+"个行业";
-//			    	}
-//		//	    	$(".item_industry .label_for").text(buyerclassHtml);
-//					if(checkObj(buyerclass)){
-//						buyerclassHtml = "已购买全行业";
-//					}
-//					$('#buyerclass').attr("placeholder",buyerclassHtml);
-//			    }
-//			    //
-//			    var nowDate = data.now.replace(/-/g, ".");
-//			    var a = nowDate+ " - " +endTime;
-//			    $(".nownow").text(nowDate+ " - " +endTime.replace(/-/g, "."))
-			    //
-//			    if(!isvalidOk){
-//			    	var effectiveName = new Date().getMonth()+2;
-//		    		if(effectiveName > 12){
-//		    			effectiveName = effectiveName - 12
-//		    		}
-//		    		effectiveHtml = effectiveName+"月1日生效";
-//		    		$("#effect_date_name").text(effectiveHtml);
-//			    }
 			}
         },false);
         //
@@ -1128,63 +1005,7 @@
 					}
 				}
 			}
-//			if(sessionStorage.vipSubSelectAreaUpgrade!==""&&sessionStorage.vipSubSelectAreaUpgrade!==undefined){
-//				var vipArea = JSON.parse(sessionStorage.vipSubSelectAreaUpgrade);
-//				if(area !== ""&&area !== undefined){
-//					for(let province in area){
-//			    		let citys = area[province];
-//			    		if(citys.length===0){
-//							areasArr[province] = [];
-//			    		}else{
-//			    			areasArr[province] = citys;
-//			    		}
-//			    	}
-//					for(let province in vipArea){
-//						let citys = vipArea[province];
-//						if(areasArr[province] === undefined){
-//							areasArr[province] = citys
-//						}else{
-//							let cityArr = [];
-//							for(let i in citys){
-//								cityArr.push(citys[i]);
-//							}
-//							for(let i in areasArr[province]){
-//								cityArr.push(areasArr[province][i]);
-//							}
-//							//
-//							for (var x = 0; x < cityArr.length; x++) {
-//					            for (var j =x+1; j <cityArr.length; ) {
-//					                if (cityArr[x] === cityArr[j]){
-//					                    cityArr.splice(j, 1);
-//					                }
-//					                else j++;
-//					            }
-//					       	}
-//							//
-//							areasArr[province] = cityArr;
-//						}
-//						if(province === "全国"){
-//							areasArr = {"全国":[]};
-//						}
-//					}
-//				}
-//				console.log($(".save_upgrade").attr("disabled"))
-//				if(buyCheck){
-//					$(".save_upgrade").removeAttr("disabled");
-//				}
-//			}else{
-//				if(area !== ""&&area !== undefined){
-//					for(let province in area){
-//			    		let citys = area[province];
-//			    		if(citys.length===0){
-//							areasArr[province] = [];
-//			    		}else{
-//			    			areasArr[province] = citys;
-//			    		}
-//			    	}
-//				}
-//			}
-
+			//
 			console.log("areasArr",areasArr)
 			if(sessionStorage.vipSubSelectIndustryAdd!==""&&sessionStorage.vipSubSelectIndustryAdd!==undefined){
 				var vipIndustry = JSON.parse(sessionStorage.vipSubSelectIndustryAdd);
@@ -1227,33 +1048,7 @@
 			    	}
 			    }
 			}
-			
-//			if(sessionStorage.vipSubSelectIndustryUpgrade!==""&&sessionStorage.vipSubSelectIndustryUpgrade!==undefined){
-//				var vipIndustry = JSON.parse(sessionStorage.vipSubSelectIndustryUpgrade);
-//				if(buyerclass!==""&&buyerclass!==undefined){
-//					for(let i in buyerclass){
-//			    		let industry = buyerclass[i];
-//			    		industrysArr.push(industry);
-//			        }
-//					for(let i in vipIndustry){
-//						let industry = vipIndustry[i];
-//						industrysArr.push(industry);
-//						if(industry === "全部行业"){
-//							industrysArr = ["全部行业"];
-//						}
-//					}
-//				}
-//				if(buyCheck){
-//					$(".save_upgrade").removeAttr("disabled");
-//				}
-//			}else{
-//				if(buyerclass!==""&&buyerclass!==undefined){
-//					for(let i in buyerclass){
-//			    		let industry = buyerclass[i];
-//			    		industrysArr.push(industry);
-//			    	}
-//			    }
-//			}
+			//
 			if(industrysArr !== null){
 				for (var x = 0; x < industrysArr.length; x++) {
 		            for (var j =x+1; j <industrysArr.length; ) {
@@ -1274,16 +1069,6 @@
 	       	}
 			
 			console.log("industrysArr",industrysArr);
-//			if(sessionStorage.effectiveDate !== ""&&sessionStorage.effectiveDate!==undefined){
-//				let eff = sessionStorage.effectiveDate;
-//				if(eff === "now"){
-//					effect = "now";
-//				}else{
-//					effect = "notnow";
-//				}
-//			}else{
-//				effect = "now";
-//			}
 			//
 			if(endYear === nowYear){
 				if(endMonth === nowMonth){
@@ -1319,14 +1104,6 @@
 			nowRenew = nowUpgrade;
 			console.log("monthold",nowUpgrade)
 			//
-//			if(effect === "notnow"){
-//				nowUpgrade = nowUpgrade -1;
-//			}
-//			if(nowUpgrade == 0){
-//				nowUpgrade = 1;
-//			}
-			
-			//
 			var nowUpgradeYear = 0;
 			if(nowUpgrade >= 12 && nowUpgrade < 24){
 				nowUpgradeYear = Math.floor(nowUpgrade / 12);
@@ -1449,9 +1226,6 @@
 				console.log("proprice",proPrice);
 				cPrice = (Number(cPrice) + Number(proPrice)).toFixed(1);
 			}
-//			if(effect === "notnow"){
-//				cPrice = cPrice -(completeMonth - oldMonthPrice);
-//			}
 			if(cPrice <= 0){
 				cPrice = 0;
 			}
@@ -1474,20 +1248,7 @@
         
         //
         $(".save_upgrade").on("click", function(){
-        	$(".save_upgrade").attr("disabled","disabled")
-//      	let effective = $("#effect_date_name").text();
-//      	var effect = "now";
-//      	if(effective !== "立即生效,需支付当月费用差价"){
-//				let nowMonth = new Date().getMonth()+1;
-//				let nowYear = new Date().getFullYear();
-//				let a = nowMonth +1;
-//      		if(a > 12){
-//      			a = a-12;
-//      			nowYear = nowYear +1;
-//      		}
-//      		let b = nowYear+"/"+a+"/1";
-//      		effect = new Date(b).getTime() /1000;
-//      	}
+        	$(".save_upgrade").attr("disabled","disabled");
         	//
         	let areas = areasArr;
         	let industrys = null;
@@ -1538,6 +1299,19 @@
             if(renew_time !== "不延长"){
             	times = $('.choose_item.lengthen .info').text();
             }
+            //
+            let vipCount = null;
+            if(sessionStorage.vipAddCount!==undefined&&sessionStorage.vipAddCount!==""){
+            	vipCount = JSON.stringify(JSON.parse(sessionStorage.vipAddCount));
+            }
+            let vipIndustry = 0
+            if(industrysArr!==null){
+            	if(industrysArr.length==1&&industrysArr[0]=="全部行业"){
+	                vipIndustry = -1;
+	            }else{
+	            	vipIndustry = industrysArr.length;
+	            }
+            }
             //
 	    	var param = {
 	    		"area": areas_arr,
@@ -1548,11 +1322,10 @@
 	    		"allArea": JSON.stringify(allAreaArr),
 	    		"allIndustry": allIndustryArr.join(","),
 	    		"payWay": "wx_js",
-//	    		"effect": effect,
 	    		"pay_source" : "Upgrade",
 	    		"time": times,
-//	    		"nowUp": Number(nowRenew),
-//	    		"isvalidOk" : isvalidOk,
+	    		"addCount":vipCount,
+	    		"addIndustryCount": vipIndustry,
 	    	}
 	    	console.log(param)
 	    	$DoPost("/subscribepay/renewUpgrade/renewUpgradeCreateOrder",param,function(r){
@@ -1572,7 +1345,9 @@
 	    	sessionStorage.removeItem("vipSubSelectAreaUpgrade");
 	    	sessionStorage.removeItem("vipSubSelectIndustryUpgrade");
 	    	sessionStorage.removeItem("vipSubSelectIndustryAdd");
-//	    	sessionStorage.removeItem("effectiveDate");
+	    	sessionStorage.removeItem("vipSubSelectAreaAdd");
+	    	sessionStorage.removeItem("vipAddCount");
+	    	sessionStorage.removeItem("vipSubSelectCity");
 	    	sessionStorage.removeItem("buyCheck");
 	    }