wangkaiyue 5 ani în urmă
părinte
comite
0289fa5af1

+ 100 - 1
src/jfw/pay/vipSubscribePay.go

@@ -78,7 +78,7 @@ func (this *Order) CreateOrder() {
 			return &orderResult{false, errors.New("创建订单出错"), nil}
 		}
 		//计算价格
-		totalfee := 1
+		totalfee := getSubVipPrice(area, industry, date_count, date_unit)
 		//创建订单
 		tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "e", this.IP(), openId, "", totalfee)
 		if ret == nil || (*ret)["status"] != "1" {
@@ -218,3 +218,102 @@ func checkReqDate(dateStr string) (cyclecount, cycleunit int, err error) {
 	}
 	return -1, -1, errors.New(fmt.Sprintf("日期%s格式化出错", dateStr))
 }
+
+//计算价格
+func getSubVipPrice(area *map[string]interface{}, industry []string, count, unit int) int {
+	if len(*area) == 0 { //全国
+		if len(industry) == 1 {
+			return getSetMealPrice(0, 1, unit) * count //全国1行业套餐
+		} else if len(industry) == 0 {
+			return getSetMealPrice(0, 0, unit) * count //全国全行业套餐
+		} else {
+			return getSetMealPrice(0, len(industry), unit) * count //全国多行业套餐
+		}
+	}
+	final_price := 0 //最终价格
+	for _, tmp := range *area {
+		thisPrice := 0
+		citys := qutil.ObjArrToStringArr(tmp.([]interface{}))
+		if len(citys) > 0 { //市
+			if len(citys) == 1 { //单城市
+				thisPrice = getSetMealPrice(2, len(industry), unit) * count
+			} else { //多城市
+				if len(industry) == 0 || len(industry) == 1 { //多城市 单行业
+					thisPrice = len(citys) * getSetMealPrice(2, len(industry), unit) * count
+				} else { //多行业 多行业
+					if count > 10 && unit == 2 { //月份十个月以上价格一样
+						count = 10
+					}
+					industry_Price := 580 * len(industry)
+					if 580*len(industry) > 1800 {
+						industry_Price = 1800
+					}
+					city_Price := len(citys) * 580
+					if len(citys)*580 > 1180 {
+						city_Price = 1180
+					}
+					thisPrice = (industry_Price + city_Price) * count
+					if unit == 1 { //年的价格是月的价格10倍
+						thisPrice *= 10
+					}
+				}
+			}
+		} else { //省
+			thisPrice = getSetMealPrice(1, len(industry), unit) * count
+		}
+		final_price += thisPrice
+	}
+	return final_price
+}
+
+/*
+vip订阅 套餐价格
+c(city) 全国:0 省:1 市:2
+i(industry) 全行业:0 行业:1 其他:多个行业
+u(unit) 年:1 月:2
+*/
+func getSetMealPrice(c, i, u int) int {
+	t := u == 2 //是否是月单位
+	icount := 1 //行业个数
+	if i > 1 {
+		icount = i
+	}
+	switch c {
+	case 0:
+		if i == 0 {
+			if t {
+				return 38800 //1月全国全行业
+			}
+			return 388000 //1年全国全行业
+		} else {
+			if t {
+				return 11800 * icount //1月全国icount个行业
+			}
+			return 118000 * icount //1年全国icount个行业
+		}
+	case 1:
+		if i == 0 {
+			if t {
+				return 3800 //1月1省全行业
+			}
+			return 38000 //1年1省全行业
+		} else {
+			if t {
+				return 1180 * icount //1月1省icount个行业
+			}
+			return 11800 * icount //1年1省icount个行业
+		}
+	default:
+		if i == 0 {
+			if t {
+				return 1800 //1月1市全行业
+			}
+			return 18000 //1年1市全行业
+		} else {
+			if t {
+				return 580 * icount //1月1市icount个行业
+			}
+			return 5800 * icount //1年1市icount个行业
+		}
+	}
+}

+ 0 - 2
src/jfw/pay/weixin.go

@@ -264,8 +264,6 @@ func (p *WxPayAction) PayCallback() {
 					flag_2 = true
 				}
 				flag = flag_1 && flag_2
-			} else if strings.HasPrefix(ret["out_trade_no"], "b_") { //数据报告
-
 			} else {
 				flag = true
 			}

+ 20 - 26
src/web/staticres/vipsubscribe/js/common.js

@@ -12,14 +12,13 @@ function $DoPost(url,param={},callback,async=true){
 		async: async,
 		dataType: "json",
 		success: function(r){
+			callback(r)
 			if(r.error||r.errMsg){
 				var errTip = r.error||r.errMsg;
 				weui.toast(errTip,{
 		          duration: 2000,
 		          className: 'custom-toast',
 		        });
-			}else{
-				callback(r)
 			}
 		}
 	})
@@ -56,7 +55,7 @@ function getAreaClassArr(area){
     return [provinceArr,cityArr]
 }
 
-/* vip订阅
+/* vip订阅价格
 	area:地区 {}
 	industry:行业 []
 	time[count,unit] count:时间长度 unit 1:年 2:月
@@ -69,29 +68,24 @@ function getsubVipOrderPrice(area,industry,t){
 	if(area["全国"]){
 		if(industry.length==1) return getSetMealPrice(0,1,t[1])*t[0]/100 //全国1行业套餐
 		if(industry.length==0) return getSetMealPrice(0,0,t[1])*t[0]/100 //全国全行业套餐
-		return	getSetMealPrice(0,0,t[1])*t[0]/100 //全国多行业套餐
+		return	getSetMealPrice(0,industry.length,t[1]) * t[0] / 100 //全国多行业套餐
 	}
 	var final_price	= 0//最终价格
 	for(var i in area) {
-		let thisPrice = 0;	
-		let citys = area[i]
+		var thisPrice = 0;	
+		var citys = area[i]
 		if(citys.length>0){//市
 			if(citys.length==1){//单城市
 				thisPrice = getSetMealPrice(2,industry.length,t[1])*t[0];
 			}else{//多城市
 				if(industry.length==0||industry.length==1){//多城市 单行业
-					thisPrice = citys.length*getSetMealPrice(2,industry.length,t[1])*t[0];	
-				}else{//多行业 多行业
-					if(t[1]==2){//月
-						var industry_Price= 580*industry.length>1800?1800:580*industry.length;
-						var city_Price = citys.length*580>1180?1180:citys.length*580;
-						if(t[0]>10) t[0]=10 //月份十个月以上价格一样
-						thisPrice = (industry_Price + city_Price)*t[0];
-					}else{//年
-						var industry_Price= 5800*industry.length>18000?18000:5800*industry.length;
-						var city_Price = citys.length*5800>11800?11800:citys.length*5800;
-						thisPrice = (industry_Price + city_Price)*5800*t[0]/100;
-					}
+					thisPrice = citys.length * getSetMealPrice(2,industry.length,t[1]) * t[0];	
+				}else{//多城市 多行业
+					if(t[0]>10&&t[1]==2) t[0]=10 //月份十个月以上价格一样
+					var industry_Price= 580 * industry.length > 1800 ? 1800 : 580 * industry.length;
+					var city_Price = citys.length * 580 > 1180 ? 1180 : citys.length * 580;
+					thisPrice = (industry_Price + city_Price) * t[0];
+					if(t[1]==1) thisPrice *= 10 //年的价格是月价格的10倍
 				}
 			}
 		}else{//省
@@ -107,8 +101,8 @@ function getsubVipOrderPrice(area,industry,t){
 //i(industry) 全行业:0 行业:1 其他:多个行业
 //u(unit) 年:1 月:2
 function getSetMealPrice(c,i,u){
-	let t = u==2 //是否是月单位
-	let icount=1   //行业个数
+	var t = u==2 //是否是月单位
+	var icount=1   //行业个数
 	if(i>1){
 		icount=i;
 	}
@@ -118,24 +112,24 @@ function getSetMealPrice(c,i,u){
 			if(t)return 38800 //1月全国全行业
 			return 388000	//1年全国全行业
 		}else{
-			if(t)return 11800*icount //1月全国icount个行业
-			return 118000*icount	//1年全国icount个行业
+			if(t)return 11800 * icount //1月全国icount个行业
+			return 118000 * icount	//1年全国icount个行业
 		}
 	case 1:
 		if(i==0){
 			if(t)return 3800 //1月1省全行业
 			return 38000	//1年1省全行业
 		}else{
-			if(t)return 1180*icount //1月1省icount个行业
-			return 11800*icount	//1年1省icount个行业
+			if(t)return 1180 * icount //1月1省icount个行业
+			return 11800 * icount	//1年1省icount个行业
 		}
 	default:
 		if(i==0){
 			if(t)return 1800 //1月1市全行业
 			return 18000	//1年1市全行业
 		}else{
-			if(t)return 580*icount //1月1市icount个行业
-			return 5800*icount	//1年1市icount个行业
+			if(t)return 580 * icount //1月1市icount个行业
+			return 5800 * icount	//1年1市icount个行业
 		}
 	}
 }

+ 14 - 12
src/web/templates/weixin/vipsubscribe/vip_purchase.html

@@ -63,7 +63,7 @@
             </ul>
             <div class="pay_mode">
                 {{if not .T.isTrial }}
-                <div class="select_payment choose_item">
+                <div class="select_payment choose_item" disabled="disabled">
                     <a href="javascript:;">
                         <span class="label">支付方式</span>
                         <span class="info choose_way">微信支付</span>
@@ -237,7 +237,7 @@
                                 <p><img src="/vipsubscribe/image/weixin.png?v={{Msg "seo" "version"}}">微信支付</p>
                             </div>
                             <div class="weui-cell__hd">
-                                <input type="radio" class="weui-check" name="way" value="wx_js" id="wx" checked />
+                                <input type="radio" class="weui-check" name="way" value="微信支付" id="wx" checked />
                                 <i class="weui-icon-checked"></i>
                             </div>
                         </label>
@@ -246,7 +246,7 @@
                                 <p><img src="/vipsubscribe/image/zhifubao.png?v={{Msg "seo" "version"}}">支付宝支付</p>
                             </div>
                             <div class="weui-cell__hd">
-                                <input type="radio" class="weui-check" name="way" value="ali" id="zfb" />
+                                <input type="radio" class="weui-check" name="way" value="支付宝支付" id="zfb" />
                                 <i class="weui-icon-checked"></i>
                             </div>
                         </label>
@@ -597,11 +597,9 @@
             $("input").bind("input propertychange change", function (event) {
               checkOk();  
             });
-            var canpay=true;
+
             $('#payHandle').click(function () {
-                if(!canpay)return
-                canpay=false
-                setTimeout(function(){canpay=true},1000)
+                $("#payHandle").attr("disabled","disabled")
                 //支付请求
                 var area=purchase.areaSelect;
                 var industry=purchase.industrySelect;
@@ -613,14 +611,18 @@
                 }
                 {{if not .T.isTrial}}
                   //付费用户
-                  var payWay=$('input:radio[name="way"]:checked').val();
-                  var time=$(".info:eq(2)").val().trim();
-                  
-                  $DoPost("/front/vipsubscribe/createOrder",{"area":JSON.stringify(area),"industry":industry.join(","),"time":time,"payWay":payWay},function(r){
+                  var param={
+                    "area":JSON.stringify(area),
+                    "industry":industry.join(","),
+                    "time":$(".info:eq(2)").val().trim(),
+                    "payWay":"wx_js"
+                  }
+                  $DoPost("/front/vipsubscribe/createOrder",param,function(r){
                     if(r.success){
                       clearSessionStorage();
                       onBridgeReady(JSON.parse(r.data.res),r.data.code);
-                    }                    
+                    }
+                    $("#payHandle").removeAttr("disabled")                    
                   })
                 {{else}} 
                   //试用用户