wangkaiyue 5 лет назад
Родитель
Сommit
fe6ccbd6cc

+ 8 - 6
src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go

@@ -321,7 +321,7 @@ func needUpgrade(newBuySet, oldBuySet *entity.SubvipBuySet) (bool, *entity.Subvi
 			c_1_diff := newCitysBuyOne - oldCitysBuyOne
 			c_2_diff := newCitysBuyTwo - oldCitysBuyTwo
 
-			log.Println(p_Diff, c_2_diff, c_1_diff)
+			//log.Println(p_Diff, c_2_diff, c_1_diff)
 
 			if p_Diff > 0 {
 				UpgradeBuyset.AreaCount = newBuySet.AreaCount
@@ -329,11 +329,13 @@ func needUpgrade(newBuySet, oldBuySet *entity.SubvipBuySet) (bool, *entity.Subvi
 
 			if p_Diff > 0 || p_Diff+c_2_diff > 0 || (p_Diff+c_2_diff == 0 && p_Diff > 1) || p_Diff+c_2_diff+c_1_diff > 0 || (p_Diff+c_2_diff+c_1_diff == 0 && c_2_diff > 1) {
 				//有多余未使用名额保留
-				if (p_Diff+c_2_diff+c_1_diff < 0 && c_1_diff < 0) {
-					c_1_diff = -(p_Diff + c_2_diff)
-				}
-				if (p_Diff+c_2_diff < 0 && c_2_diff < 0) {
-					c_2_diff = -p_Diff
+				if p_Diff+c_2_diff+c_1_diff < 0 {
+					if c_1_diff < 0 && p_Diff+c_2_diff >= 0 {
+						c_1_diff = -(p_Diff + c_2_diff)
+					}
+					if c_2_diff < 0 && p_Diff+c_1_diff >= 0 {
+						c_2_diff = -(p_Diff + c_1_diff)
+					}
 				}
 
 				//需要升级

+ 12 - 9
src/web/staticres/vipsubscribe/js/UpgradePrice.js

@@ -104,13 +104,16 @@ function needUpgrade(newBuyset, oldBuyset) {
 
             if (p_Diff > 0 || p_Diff + c_2_diff > 0 || (p_Diff + c_2_diff === 0 && p_Diff > 1) || p_Diff + c_2_diff + c_1_diff > 0 || (p_Diff + c_2_diff + c_1_diff === 0 && c_2_diff > 1)) {//需要升级
                 //有多余未使用名额保留
-                if (p_Diff + c_2_diff + c_1_diff < 0 && c_1_diff < 0) {
-                    c_1_diff = -(p_Diff + c_2_diff)
-                }
-                if (p_Diff + c_2_diff < 0 && c_2_diff < 0) {
-                    c_2_diff = -p_Diff
+                if (p_Diff + c_2_diff + c_1_diff < 0) {
+                    if (c_1_diff < 0 && p_Diff + c_2_diff >= 0) {
+                        c_1_diff = -(p_Diff + c_2_diff)
+                    }
+                    if (c_2_diff < 0 && p_Diff + c_1_diff >= 0) {
+                        c_2_diff = -(p_Diff + c_1_diff)
+                    }
                 }
 
+
                 AreaNeedUpgrade = true;
                 //计算升级后的buySet
                 if (p_Diff < 0) { //有剩余省份未使用
@@ -169,7 +172,7 @@ function needUpgrade(newBuyset, oldBuyset) {
                 var index_flag = 0;
                 for (; del_2_flag > 0 || del_1_flag > 0;) {
                     var valueFlag = UpgradeBuyset.citys[index_flag];
-                    console.log(del_2_flag, del_1_flag, UpgradeBuyset.citys);
+                    //console.log(del_2_flag, del_1_flag, UpgradeBuyset.citys);
                     if (del_2_flag > 0 && valueFlag === 2) {
                         //UpgradeBuyset.citys = append(UpgradeBuyset.citys[:index_flag], UpgradeBuyset.citys[index_flag+1:]...)
                         UpgradeBuyset.citys.splice(index_flag, 1);
@@ -330,13 +333,13 @@ function getSubPrice(oldBuyset, newBuyset, start, end) {
         newPrice = numAdd(newPrice, getsubVipOrderPriceBybuyset(newBuyset, [t[0], 1]))
     }
     //
-    console.log("old ", oldBuyset, " \n new ", newBuyset, " \n 相差", t[0], "年 ", t[1], "个月\n price:", newPrice, "-", beforePrice, "=", (newPrice * 1000 - beforePrice * 1000) / 1000);
-    return (newPrice * 1000 - beforePrice * 1000) / 1000
+    console.log("old ", oldBuyset, " \n new ", newBuyset, " \n 相差", t[0], "年 ", t[1], "个月\n price:", newPrice, "-", beforePrice, "=", (newPrice * 10000 - beforePrice * 10000) / 10000);
+    return (newPrice * 10000 - beforePrice * 10000) / 10000
 }
 
 //小数相加
 function numAdd(num1, num2) {
-    return (num1 * 1000 + num2 * 1000) / 1000
+    return (num1 * 10000 + num2 * 10000) / 10000
 }
 
 

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

@@ -228,6 +228,7 @@ function getMergeNewBuyset(buyset, price) {
 
 //根据购买设置 获取支付金额
 function getsubVipOrderPriceBybuyset(buyset, t, price) {
+    //console.log("getsubVipOrderPriceBybuyset",buyset, t)
     price = checkPrice(price);
     var vipbuyset = JSON.parse(JSON.stringify(buyset));
     if (t[0] > price.monthMaxCount && t[1] === 2) t[0] = 10;//月份十个月以上价格一样
@@ -267,6 +268,7 @@ function getsubVipOrderPriceBybuyset(buyset, t, price) {
         final_price += thisPrice;
     }
     final_price += vipbuyset.areacount * getSetMealPrice(1, vipbuyset.buyerclasscount, t[1], price) * t[0];
+    //console.log("getsubVipOrderPriceBybuyset-final_price",final_price)
     return final_price / 100
 }