瀏覽代碼

续费升级

xuzhiheng 5 年之前
父節點
當前提交
5738cc3fdd

+ 3 - 1
src/jfw/front/swordfish.go

@@ -2452,7 +2452,9 @@ func (f *Front) Historypush() error {
 		//VIP服务到期
 		vipSubtips := (*data)["i_vip_subtips"]
 		if vipSubtips == 0 {
-			return f.Redirect("/front/vipsubscribe/renewPage/exprie")
+			if mongodb.UpdateById("user", userId, bson.M{"$set": bson.M{"i_vip_subtips": 1}}) {
+				return f.Redirect("/front/vipsubscribe/renewPage/exprie")
+			}
 		}
 		//
 		o_jy, _ = (*data)["o_jy"].(map[string]interface{})

+ 2 - 0
src/jfw/front/vipsubscribe.go

@@ -150,6 +150,7 @@ func (s *Subscribepay) SubmitEditSub() {
 
 //升级订阅服务
 func (s *Subscribepay) ToUpgradePage() {
+	s.T["signature"] = wx.SignJSSDK(s.Site() + s.Url()) //微信支付准备参数
 	s.Render("/weixin/vipsubscribe/vip_upgrade.html")
 }
 
@@ -171,6 +172,7 @@ func (s *Subscribepay) RenewPage(sign string) {
 
 //服务续费(will:即将到期,exprie:已到期)
 func (s *Subscribepay) RenewPayPage() {
+	s.T["signature"] = wx.SignJSSDK(s.Site() + s.Url()) //微信支付准备参数
 	s.Render("/weixin/vipsubscribe/renew_pay.html")
 }
 

+ 169 - 24
src/jfw/modules/subscribepay/src/service/vipRenewUpgrade.go

@@ -1,9 +1,13 @@
 package service
 
 import (
+	"encoding/json"
 	"entity"
+	"errors"
 	"log"
 	qutil "qfw/util"
+	//	"strings"
+	"pay"
 	"strings"
 	"time"
 	"util"
@@ -15,8 +19,9 @@ import (
 //订阅升级修改相关接口
 type RenewUpgrade struct {
 	*xweb.Action
-	getBuyMsg            xweb.Mapper `xweb:"/renewUpgrade/getBuyMsg"`            //获取购买相关信息
-	getRenewUpgradePrice xweb.Mapper `xweb:"/renewUpgrade/getRenewUpgradePrice"` //获取价格
+	getBuyMsg               xweb.Mapper `xweb:"/renewUpgrade/getBuyMsg"`               //获取购买相关信息
+	getRenewUpgradePrice    xweb.Mapper `xweb:"/renewUpgrade/getRenewUpgradePrice"`    //获取价格
+	renewUpgradeCreateOrder xweb.Mapper `xweb:"/renewUpgrade/renewUpgradeCreateOrder"` //续费升级支付
 }
 
 //获取购买订阅相关信息
@@ -35,10 +40,10 @@ func (this *RenewUpgrade) GetBuyMsg() {
 		end := time.Unix(endtime, 0).Format("2006-01-02")
 		areaArr := qutil.ObjToMap(area)
 		buyerclassArr := qutil.ObjArrToStringArr(buyerclass.([]interface{}))
-		monthprice := entity.GetSubVipPrice(areaArr, buyerclassArr, 1, 2)
-		yearprice := entity.GetSubVipPrice(areaArr, buyerclassArr, 1, 1)
-		log.Println("month", float64(monthprice)/100)
-		log.Println("year", float64(yearprice)/100)
+		monthprice := entity.JyVipSubStruct.GetSubVipPrice(areaArr, buyerclassArr, 1, 2)
+		yearprice := entity.JyVipSubStruct.GetSubVipPrice(areaArr, buyerclassArr, 1, 1)
+		//		log.Println("month", float64(monthprice)/100)
+		//		log.Println("year", float64(yearprice)/100)
 		//
 		dataArr := map[string]interface{}{
 			"area":       area,
@@ -57,23 +62,163 @@ func (this *RenewUpgrade) GetBuyMsg() {
 }
 
 func (this *RenewUpgrade) GetRenewUpgradePrice() {
-	addArea := qutil.ObjToMap(this.GetString("addArea"))
-	addIndustry := strings.Split(this.GetString("addIndustry"), ",")
-	oldArea := qutil.ObjToMap(this.GetString("oldArea"))
-	oldIndustry := strings.Split(this.GetString("oldIndustry"), ",")
-	log.Println("area", addArea)
-	log.Println("industry", addIndustry)
-	log.Println("oldarea", oldArea)
-	log.Println("oldindustry", oldIndustry)
-	monthprice := entity.GetSubVipPrice(addArea, addIndustry, 1, 2)
-	yearprice := entity.GetSubVipPrice(addArea, addIndustry, 1, 1)
-	monthprices := float64(monthprice) / 100
-	yearprices := float64(yearprice) / 100
-	log.Println("monthprice", monthprices)
-	log.Println("yearprice", yearprices)
-	dataArr := map[string]interface{}{
-		"monthprice": monthprices,
-		"yearprice":  yearprices,
+	years, _ := this.GetInteger("nowUpgradeYear")
+	months, _ := this.GetInteger("nowUpgrade")
+	log.Println("years", years)
+	log.Println("months", months)
+	var price int
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	data, ok := util.MQFW.FindById("user", userId, nil)
+	if ok && len(*data) > 0 && *data != nil {
+		vipjy := (*data)["o_vipjy"].(map[string]interface{})
+		area := vipjy["o_area"]
+		buyerclass := vipjy["a_buyerclass"]
+
+		//
+		areaArr := qutil.ObjToMap(area)
+		buyerclassArr := qutil.ObjArrToStringArr(buyerclass.([]interface{}))
+		var completeMonth = 0
+		var completeYear = 0
+		if years >= 1 {
+			monthprice := entity.JyVipSubStruct.GetSubVipPrice(areaArr, buyerclassArr, months, 2)
+			yearprice := entity.JyVipSubStruct.GetSubVipPrice(areaArr, buyerclassArr, years, 1)
+			price = yearprice + monthprice
+			if monthprice == 0 {
+				completeMonth = ((yearprice / years) / 10)
+				completeYear = (yearprice / years)
+			} else {
+				completeMonth = (monthprice / months)
+				completeYear = ((monthprice / months) * 10)
+			}
+			log.Println("yearprice", yearprice)
+			log.Println("monthprice", monthprice)
+			log.Println("price", price)
+		} else {
+			price = entity.JyVipSubStruct.GetSubVipPrice(areaArr, buyerclassArr, months, 2)
+			completeMonth = (price / months)
+			completeYear = ((price / months) * 10)
+			log.Println("price111", price)
+		}
+		oldPrice := float32(price) / 100
+		log.Println("price", oldPrice)
+		log.Println("completeMonth", float32(completeMonth)/100)
+		log.Println("completeYear", float32(completeYear)/100)
+
+		dataArr := map[string]interface{}{
+			"oldprice":      oldPrice,
+			"oldyearprice":  float32(completeYear) / 100,
+			"oldmonthprice": float32(completeMonth) / 100,
+		}
+		this.ServeJson(dataArr)
+	}
+
+}
+
+//升级续费
+//创建订单返回支付串
+func (this *RenewUpgrade) RenewUpgradeCreateOrder() {
+	area := qutil.ObjToMap(this.GetString("area"))
+	industry := strings.Split(this.GetString("industry"), ",")
+	date := this.GetString("time")
+	payWay := this.GetString("payWay")
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
+	r := func() *entity.FuncResult {
+		now := time.Now()
+		//数据校验
+		if len(industry) == 1 { //去掉[""]
+			industry = []string{}
+		}
+		if !(payWay == "wx_js" || payWay == "wx_app" || payWay == "ali_app") {
+			return &entity.FuncResult{false, errors.New("未知支付"), nil}
+		}
+		date_count, date_unit, err := checkReqDate(date)
+		if err != nil {
+			return &entity.FuncResult{false, err, nil}
+		}
+		log.Println(area, industry, date, payWay)
+		//插入订单表
+		mog_id := util.MQFW.Save("subvip_select", map[string]interface{}{
+			"o_area":       area,     //地区(对象)
+			"a_industry":   industry, //行业(数组)
+			"s_userid":     userId,
+			"s_openid":     openId,
+			"i_cyclecount": date_count, //时长
+			"i_cycleunit":  date_unit,  //单位
+			"i_comeintime": now.Unix(),
+		})
+		if mog_id == "" {
+			return &entity.FuncResult{false, errors.New("创建订单出错"), nil}
+		}
+		//计算价格
+		//totalfee := entity.GetSubVipPrice(area, industry, date_count, date_unit)
+		totalfee := 1
+		//创建订单
+		tradeno, prepayid, payStr := "", "", ""
+
+		if payWay == "wx_js" { //微信js支付
+			var ret *map[string]string
+			tradeno, ret = pay.WxStruct.CreatePrepayOrder(pay.WX_SUBVIP_JSAPI, this.IP(), openId, "", totalfee)
+			if ret == nil || (*ret)["status"] != "1" {
+				errMsg := "创建微信订单出错"
+				if (*ret)["errcodedes"] != "" {
+					errMsg = (*ret)["errcodedes"]
+				} else if (*ret)["errcode"] != "" {
+					errMsg = (*ret)["errcode"]
+				}
+				return &entity.FuncResult{false, errors.New(errMsg), nil}
+			}
+			prepayid = qutil.ObjToString((*ret)["prepayid"])
+			payStr = pay.GetWxJsPayStr(prepayid)
+		} else if payWay == "wx_app" {
+			var ret *map[string]string
+			tradeno, ret = pay.WxStruct.CreatePrepayOrder(pay.WX_SUBVIP_JSAPI, this.IP(), openId, "", totalfee)
+			if ret == nil || (*ret)["status"] != "1" {
+				errMsg := "创建微信订单出错"
+				if (*ret)["errcodedes"] != "" {
+					errMsg = (*ret)["errcodedes"]
+				} else if (*ret)["errcode"] != "" {
+					errMsg = (*ret)["errcode"]
+				}
+				return &entity.FuncResult{false, errors.New(errMsg), nil}
+			}
+			prepayid = qutil.ObjToString((*ret)["prepayid"])
+			payStr = pay.WxStruct.GetAppWxPayStr(prepayid)
+		}
+		filter := entity.VipSimpleMsg{
+			mog_id,
+			area,
+			industry,
+			date_count,
+			date_unit,
+		}
+		filterStr, _ := json.Marshal(filter)
+		ordercode := pay.GetOrderCode(userId)
+		orderid := util.Mysql.Insert("dataexport_order", map[string]interface{}{
+			"order_money":    totalfee,
+			"order_status":   0,
+			"user_nickname":  qutil.ObjToString(this.GetSession("s_nickname")),
+			"user_openid":    openId,
+			"prepay_id":      prepayid,
+			"code_url":       payStr,
+			"out_trade_no":   tradeno,
+			"order_code":     ordercode,
+			"product_type":   "VIP订阅",
+			"create_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			"prepay_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			"original_price": totalfee,
+			"filter_id":      mog_id,
+			"pay_way":        payWay,
+			"user_id":        userId,
+			"filter":         string(filterStr), //筛选
+		})
+		if orderid == -1 {
+			return &entity.FuncResult{false, errors.New("数据库操作异常"), nil}
+		}
+		return &entity.FuncResult{true, nil, map[string]interface{}{"code": ordercode, "res": payStr}}
+	}()
+	if r.Err != nil {
+		log.Printf("%s CreateOrder err:%v\n", userId, r.Err.Error())
 	}
-	this.ServeJson(dataArr)
+	this.ServeJson(r.Format())
 }

+ 1 - 1
src/web/templates/weixin/vipsubscribe/choose_area_upgrade.html

@@ -16,7 +16,7 @@
 </head>
 <style type="text/css">
 	body,html {
-		height: 100%;
+		/*height: 100%;*/
 	}
 </style>
 <body>

+ 75 - 2
src/web/templates/weixin/vipsubscribe/renew_pay.html

@@ -98,7 +98,7 @@
             </div>
             <div class="form-btn">
                 <!-- 支付 -->
-                <button class="btn enter saveBtn" disabled>立即续费</button>
+                <button class="btn enter save_renew" disabled>立即续费</button>
             </div>
         </div>
 
@@ -199,6 +199,67 @@
     <script src="/vipsubscribe/js/common.js"></script>
     <script src="/vipsubscribe/js/fastclick.js?v={{Msg "seo" "version"}}"></script>
     <script src="https://res.wx.qq.com/open/libs/weuijs/1.1.4/weui.min.js?v={{Msg "seo" "version"}}"></script>
+    <script type="text/javascript">
+    	try{
+			var signature = {{.T.signature}};
+			var isConfigSuccess = true;
+			var id = {{.T._id}}
+			if(signature && signature.length == 4){
+			  	wx.config({
+			  	    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+			  	    appId: signature[0], // 必填,公众号的唯一标识
+			  	    timestamp:signature[1], // 必填,生成签名的时间戳
+			  	    nonceStr: signature[2], // 必填,生成签名的随机串
+			  	    signature: signature[3],// 必填,签名,见附录1
+			  	    jsApiList: ['chooseWXPay','hideAllNonBaseMenuItem'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+			  	});
+			  	wx.ready(function(){
+			  		if(!isConfigSuccess){
+			  			return;
+			  		}
+			  		wx.hideAllNonBaseMenuItem();
+			    });
+			  	wx.error(function(res){
+			  	    //config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
+			  		//alert(res);
+			  		isConfigSuccess = false;
+			  	});
+			}
+			//调用微信支付接口
+  			function onBridgeReady(res,ordercode){
+  			   	WeixinJSBridge.invoke('getBrandWCPayRequest',{
+		    		"appId": res["appId"],
+		          	"timeStamp": res["timestamp"],
+		          	"nonceStr": res["nonceStr"],
+		          	"package": res["prepayId"],
+		          	"signType": res["signType"],
+		         	"paySign": res["sign"]
+  				},
+  				function(r){
+				    if(r.err_msg == "get_brand_wcpay_request:ok"){
+						setTimeout(function(){
+							
+							window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
+						},500)
+					}else if(r.err_msg == "get_brand_wcpay_request:cancel"){               
+	                	alert("开发环境【支付跳转完成】")
+		                try{
+		  					window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
+		                }catch(e){
+		                  alert(e)
+		                }
+	  				}else{
+	                	weui.toast("系统异常,请稍微再试",{
+	                  		duration: 2000,
+	                  		className: 'custom-toast',
+	                	});
+	  				}
+  				});
+  			}   
+		}catch(e){
+		  console.log(e)
+		}
+    </script>
     <script>
         // 隐藏dialog选择框
         function hideDialog() {
@@ -374,7 +435,8 @@
             })
             $(".finally_price").html($(".computed_price").html());
             sessionStorage.renew_finally_price = $(".finally_price").html();
-        })
+            $(".save_renew").removeAttr("disabled");
+        });
         
         //
         var area = "";
@@ -494,8 +556,19 @@
 	 	}
 	    if(sessionStorage.renew_finally_price!==""&&sessionStorage.renew_finally_price!==undefined){
 	    	$(".finally_price").html(sessionStorage.renew_finally_price);
+	    	$(".save_renew").removeAttr("disabled");
 	    }
 	    
+	    //
+	    $(".save_renew").on("click", function(){
+	    	var param = {
+	    		"area": area,
+	    		"industry": buyerclass.toString(),
+	    		"time": $('.choose_item.select_cycle .info').attr('placeholder'),
+	    		"payWay":"wx_js"
+	    	}
+	    });
+	    
     </script>
 </body>
 

+ 266 - 40
src/web/templates/weixin/vipsubscribe/vip_upgrade.html

@@ -146,7 +146,7 @@
                 </p> 
             </div>
             <div class="form-btn">
-                <button class="btn enter" disabled>立即升级</button>
+                <button class="btn enter save_upgrade" disabled>立即升级</button>
             </div>
         </div>
 
@@ -294,6 +294,66 @@
     <script src="/vipsubscribe/js/fastclick.js?v={{Msg "seo" "version"}}"></script>
     <script src="/vipsubscribe/js/weui.min.js?v={{Msg "seo" "version"}}"></script>
     <script src="/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}"></script>
+    <script type="text/javascript">
+    	try{
+			var signature = {{.T.signature}};
+			var isConfigSuccess = true;
+			var id = {{.T._id}}
+			if(signature && signature.length == 4){
+			  	wx.config({
+			  	    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+			  	    appId: signature[0], // 必填,公众号的唯一标识
+			  	    timestamp:signature[1], // 必填,生成签名的时间戳
+			  	    nonceStr: signature[2], // 必填,生成签名的随机串
+			  	    signature: signature[3],// 必填,签名,见附录1
+			  	    jsApiList: ['chooseWXPay','hideAllNonBaseMenuItem'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+			  	});
+			  	wx.ready(function(){
+			  		if(!isConfigSuccess){
+			  			return;
+			  		}
+			  		wx.hideAllNonBaseMenuItem();
+			    });
+			  	wx.error(function(res){
+			  	    //config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
+			  		//alert(res);
+			  		isConfigSuccess = false;
+			  	});
+			}
+			//调用微信支付接口
+  			function onBridgeReady(res,ordercode){
+  			   	WeixinJSBridge.invoke('getBrandWCPayRequest',{
+		    		"appId": res["appId"],
+		          	"timeStamp": res["timestamp"],
+		          	"nonceStr": res["nonceStr"],
+		          	"package": res["prepayId"],
+		          	"signType": res["signType"],
+		         	"paySign": res["sign"]
+  				},
+  				function(r){
+				    if(r.err_msg == "get_brand_wcpay_request:ok"){
+						setTimeout(function(){
+							window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
+						},500)
+					}else if(r.err_msg == "get_brand_wcpay_request:cancel"){               
+	                	alert("开发环境【支付跳转完成】")
+		                try{
+		  					window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+ordercode);
+		                }catch(e){
+		                  alert(e)
+		                }
+	  				}else{
+	                	weui.toast("系统异常,请稍微再试",{
+	                  		duration: 2000,
+	                  		className: 'custom-toast',
+	                	});
+	  				}
+  				});
+  			}   
+		}catch(e){
+		  console.log(e)
+		}
+    </script>
     <script>
         // 当续费时间 + 当前已经买的时间超过36个月,给出提醒
 //      var overtimeWarning = `最长订阅周期不可超过3年<br />当前订阅周期:16个月`
@@ -331,13 +391,18 @@
         $('.choose_effect_date > a').click(function () {
             $('#effective_date').show(200);
         })
+        //
+		var effectiveName = new Date().getMonth()+2;
+		var effectiveNames = effectiveName+"月1日生效"
+		$(".effective_name.notnow").text(effectiveNames);
+		$('#nextMonth').val(effectiveNames);
         // 对生效日期方式选择的input绑定点击事件
         $('#effective_date input:radio[name="date"]').click(function () {
             var checkValue = $('input:radio[name="date"]:checked').val();
 //          console.log(checkValue);
             $('#effective_date').hide(200);
             var effective = "";
-            var effectiveName = new Date().getMonth()+1;
+            var effectiveName = new Date().getMonth()+2;
             var effectiveNames = effectiveName+"月1日生效"
             if(checkValue === "立即生效,需支付当月费用差价"){
             	effective = "now";
@@ -346,16 +411,12 @@
             }
             sessionStorage.effectiveDate = effective;
             $('#effect_date_name').html(checkValue);
+            window.location.reload();
         });
-        //
-		var effectiveName = new Date().getMonth()+1;
-		var effectiveNames = effectiveName+"月1日生效"
-		$(".effective_name.notnow").text(effectiveNames);
-		$('#nextMonth').val(effectiveNames);
+        
         
         // 选择周期
         $('.lengthen > a').click(function () {
-        	FinallyPrice();
             $('#time_cycle').show(200);
         })
         // 对订阅时间选择的 input绑定点击事件
@@ -421,7 +482,10 @@
                     .numboxStep;
             }
             $number.text(currentNum)
-            var price = (monthPrice * currentNum).toFixed(1);
+            if(currentNum >= 10){
+            	currentNum = 10;
+            }
+            var price = (completeMonth * currentNum).toFixed(1);
             $('.computed_price').html('¥' + price)
             var firstButton = $('#number_box_month button:first')
             var lastButton = $('#number_box_month button:last')
@@ -454,7 +518,7 @@
             $('#yearly').prop('checked', true);
             $("#monthly").prop('checked', false);
             // 渲染结果 保留一位小数
-            let result = (Number(id) * yearPrice).toFixed(1);
+            let result = (Number(id) * completeYear).toFixed(1);
             $('.computed_price').html('¥' + result)
         })
 
@@ -471,7 +535,10 @@
             } else {
                 $('#number_box_month button').removeAttr('disabled')
             }
-            let result = (Number(val) * monthPrice).toFixed(1);
+            if(Number(val)>=10){
+            	val = 10
+            }
+            let result = (Number(val) * completeMonth).toFixed(1);
             $('.computed_price').html('¥' + result)
 
         })
@@ -482,7 +549,7 @@
             let isChecked = $(this).is(':checked')
             // 按年订阅默认选择1年 
             let val = 1;
-            $('.computed_price').html('¥' + Number(val) * yearPrice)
+            $('.computed_price').html('¥' + Number(val) * completeYear)
             if (isChecked) {
                 $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
             }
@@ -517,8 +584,6 @@
             $('#time_cycle').hide(function () { 
                 $('.choose_item.lengthen .info').text(val)
             })
-            $(".finally_price").html($(".computed_price").html());
-            sessionStorage.renew_finally_price = $(".finally_price").html();
         })
         //新增区域
 	    if(sessionStorage.vipSubSelectArea!==""&&sessionStorage.vipSubSelectArea!==undefined){
@@ -551,8 +616,6 @@
 			if(provinceLen === 0 && cityLen === 0){
 				$(".area-list").hide();
 			}
-			var price = getsubVipOrderPrice(vipSubSelectArea,["行业"],[1,2])
-			console.log(price)
 	    }
 	    //新增行业
 	    if(sessionStorage.vipSubSelectIndustry!==""&&sessionStorage.vipSubSelectIndustry!==undefined){
@@ -573,8 +636,6 @@
 			}else{
 				$(".industry-list").text("已新增为 : 全部行业");
 			}
-			var price = getsubVipOrderPrice({"全":["”"]},vipSubSelectIndustry,[1,2])
-			console.log(price)
 	    }
 	    //生效时间
 	    if(sessionStorage.effectiveDate !== ""&&sessionStorage.effectiveDate!==undefined){
@@ -583,7 +644,7 @@
 	    	if(effective === "now"){
 	    		effectiveHtml = "立即生效,需支付当月费用差价";
 	    	}else if(effective === "notnow"){
-	    		var effectiveName = new Date().getMonth()+1;
+	    		var effectiveName = new Date().getMonth()+2;
 	    		effectiveHtml = effectiveName+"月1日生效";
 	    	}
 	    	$(".effective_name").each(function(){
@@ -685,7 +746,6 @@
 		//	    var dateName = "";
 		//	    var dateHtml = "";
 			    if (area !== "" && area !== undefined){
-			    	console.log(area)
 			    	for(var province in area){
 			    		var citys = area[province]
 		//	    		console.log(citys);
@@ -713,28 +773,194 @@
 			}
         },false);
         //
+        var completeMonth = 0;
+        var completeYear = 0;
+        var oldYearPrice = 0;
+        var oldMonthPrice = 0;
         function FinallyPrice(){
-//      	var oldArea = JSON.stringify(area);
-//      	var oldIndustry = buyerclass.toString();
-//      	var addArea = sessionStorage.vipSubSelectArea;
-//      	var addIndustry = JSON.parse(sessionStorage.vipSubSelectIndustry).toString();
-//      	
-//      	
-//      	
-//      	
-//      	param = {
-//      		"oldArea":oldArea,
-//      		"oldIndustry":oldIndustry,
-//      		"addArea":addArea,
-//      		"addIndustry":addIndustry
-//      	}
-//      	$DoPost("/subscribepay/renewUpgrade/getRenewUpgradePrice", param, function (r) {
-//      		if(r){
-//      			monthPrice = r.monthprice;
-//      			yearPrice = r.yearprice;
-//      		}
-//      	},false);
+        	var areasArr = {};
+	    	var industrysArr = [];
+	    	var nowUpgrade = "";
+			//
+			var nowDate = new Date().toLocaleDateString();
+			nowDate = nowDate.split("/");
+			var nowMonth = Number(nowDate[1]);
+			var nowYear = Number(nowDate[0]);
+			var nowDay = Number(nowDate[2]);
+			//
+			var endDate = new Date(endTime).toLocaleDateString();
+			endDate = endDate.split("/");
+			var endMonth = Number(endDate[1]);
+			var endYear = Number(endDate[0]);
+			var endDay = Number(endDate[2]);
+			var oldPrice = "";
+			var price = "";
+			var effect = "";
+			if(sessionStorage.vipSubSelectArea!==""&&sessionStorage.vipSubSelectArea!==undefined){
+				var vipArea = JSON.parse(sessionStorage.vipSubSelectArea);
+				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]);
+							}
+							areasArr[province] = cityArr;
+						}
+						if(province === "全国"){
+							areasArr = {"全国":[]};
+						}
+					}
+				}
+			}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.vipSubSelectIndustry!==""&&sessionStorage.vipSubSelectIndustry!==undefined){
+				var vipIndustry = JSON.parse(sessionStorage.vipSubSelectIndustry);
+				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 = ["全部行业"];
+						}
+					}
+				}
+			}else{
+				if(buyerclass!==""&&buyerclass!==undefined){
+					for(let i in buyerclass){
+			    		let industry = buyerclass[i];
+			    		industrysArr.push(industry);
+			    	}
+			    }
+			}
+			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){
+					nowUpgrade = 1;
+				}else{
+					if(endDay > nowDay){
+						nowUpgrade = endMonth - nowMonth +1;
+					}else{
+						nowUpgrade = endMonth - nowMonth;
+					}
+				}
+			}else{
+				if(endMonth === nowMonth){
+					if(endDay <= nowDay){
+						nowUpgrade = (endYear - nowYear) * 12;
+					}else{
+						nowUpgrade = (endYear - nowYear) * 12 +1;
+					}
+				}else if(endMonth > nowMonth){
+					if(endDay <= nowDay){
+						nowUpgrade = (endYear - nowYear) * 12 + (endMonth - nowMonth);
+					}else{
+						nowUpgrade = (endYear - nowYear) * 12 + (endMonth - nowMonth)+1;
+					}
+				}else{
+					if(endDay <= nowDay){
+						nowUpgrade = (endYear - nowYear-1) * 12 + (12-nowMonth+endMonth);
+					}else{
+						nowUpgrade = (endYear - nowYear-1) * 12 + (12-nowMonth+endMonth)+1;
+					}
+				}
+			}
+			console.log("monthold",nowUpgrade)
+			//
+			if(effect === "notnow"){
+				nowUpgrade = nowUpgrade -1;
+			}
+			//
+			var nowUpgradeYear = 0;
+			if(nowUpgrade >= 12){
+				nowUpgradeYear = Math.floor(nowUpgrade / 12);
+				nowUpgrade = nowUpgrade - 12;
+			}else if(nowUpgrade >= 24){
+				nowUpgradeYear = Math.floor(nowUpgrade / 12);
+				nowUpgrade = nowUpgrade - 24;
+			}
+			if(nowUpgrade >= 10){
+				nowUpgradeYear = nowUpgradeYear + 1;
+				nowUpgrade = 0;
+			}
+			console.log("year",nowUpgradeYear)
+			console.log("month",nowUpgrade)
+			$DoPost("/subscribepay/renewUpgrade/getRenewUpgradePrice", {"nowUpgradeYear":nowUpgradeYear,"nowUpgrade":nowUpgrade}, function (r) {
+				if(r){
+					oldPrice = r.oldprice;
+					oldYearPrice = r.oldyearprice;
+					oldMonthPrice = r.oldmonthprice;
+				}
+			},false);
+			if(nowUpgradeYear >= 1){
+				let yearprice = getsubVipOrderPrice(areasArr,industrysArr,[nowUpgradeYear,1]);
+				let monthprice = getsubVipOrderPrice(areasArr,industrysArr,[nowUpgrade,2]);
+				price = yearprice + monthprice;
+				if(monthprice === 0){
+					completeMonth = ((yearprice / nowUpgradeYear) / 10-oldMonthPrice).toFixed(1);
+					completeYear = (yearprice / nowUpgradeYear-oldYearPrice).toFixed(1);
+				}else{
+					completeMonth = (monthprice / nowUpgrade-oldMonthPrice).toFixed(1);
+					completeYear = ((monthprice / nowUpgrade)*10-oldYearPrice).toFixed(1);
+				}
+				console.log("yearprice",yearprice);
+				console.log("monthprice",monthprice);
+				console.log(">=1",price);
+			}else{
+				price = getsubVipOrderPrice(areasArr,industrysArr,[nowUpgrade,2]);
+				completeMonth = (price / nowUpgrade-oldMonthPrice).toFixed(1);
+				completeYear = ((price / nowUpgrade)*10-oldYearPrice).toFixed(1);
+				console.log("<1",price)
+			}
+			console.log("completeMonth",completeMonth)
+			console.log("completeYear",completeYear)
+			console.log("oldPrice", oldPrice);
+			var cPrice = (price - oldPrice).toFixed(1);
+			console.log(cPrice);
+			$(".finally_price").html("¥"+cPrice);
+			$(".save_upgrade").removeAttr('disabled');
         }
+        FinallyPrice();
     </script>
 </body>