xuzhiheng 5 年之前
父节点
当前提交
016e7c852c

+ 12 - 10
src/jfw/modules/subscribepay/src/service/vipRenewUpgrade.go

@@ -127,18 +127,20 @@ func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
 			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 = endTime.AddDate(date_count, 0, 0)
+		//		} else if date_unit == 2 { //月
+		//			endTime = endTime.AddDate(0, date_count, 0)
+		//		}
+		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)
-			}
+			//			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{
 			area,

+ 27 - 9
src/web/templates/weixin/vipsubscribe/renew_pay.html

@@ -468,6 +468,8 @@
 			    ends = data.endtime;
 			    monthPrice = data.monthprice;
 			    yearPrice = data.yearprice;
+			    console.log(area)
+			    console.log(buyerclass)
 			    //
 			    var areaArr = [];
 			    var areaHtml = "";
@@ -524,19 +526,35 @@
 			    	dateHtml = start + " - " + end;
 			    	$(".item_validity .label_for").text(dateHtml);
 			    }
-			    if(cyclecount !== "" && cyclecount !== undefined){
+			    if(starts !== "" && ends !== ""){
+			    	let end = new Date(ends*1000).toLocaleDateString();
+			    	let endtime = end.split("/");
+			    	let endYear = Number(endtime[0]);
+			    	let endMonth = Number(endtime[1]);
+			    	let start = new Date(starts*1000).toLocaleDateString();
+			    	let starttime = start.split("/");
+			    	let startYear = Number(starttime[0]);
+			    	let startMonth = Number(starttime[1]);
 			    	let year = "";
 			    	let month = "";
-			    	if(cyclecount >= 12){
-			    		year = Math.floor(Number(cyclecount) / 12);
-			    		month = Number(cyclecount) - 12*year;
-			    	}else{
-			    		month = Number(cyclecount);
+			    	if(endYear > startYear){
+			    		if(endMonth > startMonth){
+		    				year = endYear - startYear;
+		    				month = endMonth - startMonth;
+			    		}else{
+		    				year = endYear - startYear-1;
+		    				month = 12+Number(endMonth)-startMonth;
+			    			if(year === 0){
+			    				year = "";
+			    			}
+			    		}
+			    	}else if(endYear === startYear){
+		    			month = endMonth - startMonth;
 			    	}
-			    	
-			    	if(year !== "" && month !=="" && month !== 0){
+			    	//
+			    	if(year !== "" && month !==""){
 			    		$(".item_cycle .label_for").text(year+"年"+month+"个月");
-			    	}else if(year !== ""&& (month ===""||month ===0)){
+			    	}else if(year !== ""&& month ===""){
 			    		$(".item_cycle .label_for").text(year+"年");
 			    	}else if(year === ""&& month !==""){
 			    		$(".item_cycle .label_for").text(month+"个月");