Преглед изворни кода

超级订阅订阅 计费清单

wangshan пре 4 година
родитељ
комит
765b4c55e7

+ 23 - 14
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_order_detail.js

@@ -13,6 +13,7 @@ $(function () {
 
     $DoPost("/subscribepay/orderListDetails/getOrderPayAllMsg", {"orderCode": orderCode}, function (r) {
         $("body").css("visibility", "");
+        var discount_price = 0;
         if (r.success) {
             if (r.data.order.order_status == -1) {
                 $(".nothing").show();
@@ -24,16 +25,16 @@ $(function () {
                 $(".prepayTime").text(r.data.order.create_time.replace("-", ".").replace("-", "."));
             }
             //产品类型
-            if (r.data.order.original_price == 0) {
+            if (r.data.order.order_money == 0) {
                 $(".productType").text("超级订阅(试用)");
             }
             //价格
-            $(".price").text("¥ " + formatMoney(parseFloat(r.data.order.original_price) / 100));
-            $(".totalPrice").text("¥ " + formatMoney(parseFloat(r.data.order.original_price) / 100) + "元");
+            $(".price").text("¥ " + formatMoney(parseFloat(r.data.order.order_money) / 100));
+            $(".totalPrice").text("¥ " + formatMoney(parseFloat(r.data.order.order_money) / 100) + "元");
             if (!r.data.order.isLiveActive) {
                 $(".origin-price-container").hide();
             } else {
-                var originPrice = (r.data.order.original_price / 100 / 0.6).toFixed(2);
+                var originPrice = (r.data.order.order_money / 100 / 0.6).toFixed(2);
                 $(".price-num").text(originPrice);
                 $(".bill-origin-price").css("display", "flex");
             }
@@ -255,7 +256,7 @@ $(function () {
                 } else if (filterObj.cycleunit == 3) {
                     $(".cyclecount").text(filterObj.cyclecount + "天")
                 }
-                if (r.data.order.original_price > 0) {
+                if (r.data.order.order_money > 0) {
                     vipType = 3
                 }
             }
@@ -270,11 +271,12 @@ $(function () {
             }
             if (r.data.order.order_status == 0) {
                 if (r.data.order.discount_price&&r.data.order.discount_price>0){
-                  var totalPrice = Number(r.data.order.discount_price)+Number(r.data.order.original_price);
+                  discount_price = r.data.order.discount_price;
+                  var totalPrice = Number(r.data.order.discount_price)+Number(r.data.order.order_money);
                   $(".totalPrice").text('¥'+ formatMoney(totalPrice / 100)+'元')
                   $(".discountPrice").text('-¥'+ formatMoney(parseFloat(r.data.order.discount_price) / 100)+'元')
                 }
-                $(".payPrice").text("¥ " + formatMoney(parseFloat(r.data.order.original_price) / 100) + "元");
+                $(".payPrice").text("¥ " + formatMoney(parseFloat(r.data.order.order_money) / 100) + "元");
                 //未支付
                 $("#card-header-bg").addClass("bg nopay-bg")
                 $("#pageTitle").addClass("status")
@@ -323,18 +325,19 @@ $(function () {
                 $(".j-footer").show().html(pay_now)
             } else if (r.data.order.order_status == 1) {
                 if (r.data.order.discount_price&&r.data.order.discount_price>0){
-                  var totalPrice = Number(r.data.order.discount_price)+Number(r.data.order.original_price);
+                  discount_price = r.data.order.discount_price;
+                  var totalPrice = Number(r.data.order.discount_price)+Number(r.data.order.order_money);
                   $(".totalPrice").text('¥'+ formatMoney(totalPrice / 100)+'元')
                   $(".discountPrice").text('-¥'+ formatMoney(parseFloat(r.data.order.discount_price) / 100)+'元')
                 }
-                $(".payPrice").text("¥ " + formatMoney(parseFloat(r.data.order.original_price) / 100) + "元");
+                $(".payPrice").text("¥ " + formatMoney(parseFloat(r.data.order.order_money) / 100) + "元");
                 $("#card-header-bg").addClass("bg finish-bg")
                 $("#pageTitle").addClass("status")
                 $("#pageTitle").text("已完成");
                 //支付时间
                 $(".line_paytime").css("display", "");
                 if (r.data.order.pay_time) $(".payTime").text(r.data.order.pay_time.replace("-", ".").replace("-", "."));
-                if (r.data.order.original_price == 0) {
+                if (r.data.order.order_money == 0) {
                     $(".line_paytime").css("display", "none");
                 }
 
@@ -419,7 +422,7 @@ $(function () {
                     "order_code": orderCode
                 },
                 success: function (data) {
-                    appendList(data.list, data.order_money);
+                    appendList(data.list, data.order_money,discount_price);
                 }
             });
             $(".valuationList").show();
@@ -552,7 +555,7 @@ $(function () {
 
     var total_price = 0;
 
-    function appendList(list, money) {
+    function appendList(list, money,discount_price) {
         var returnHtml = "";
         for (var i = 0; i < list.length; i++) {
             var showTime = ""
@@ -621,12 +624,18 @@ $(function () {
                     + '<div class="vp-type-text">' + typeName + '</div>'
                     + '</div>'
             }
-
+            var disHtml = ""
+            var price = list[i].price
+            if (discount_price>0&&i==0){
+              disHtml =  '<span class="footer-label disCount">已优惠:¥'+(discount_price / 100)+'</span>'
+              price = price - discount_price
+            }
             returnHtml += '</div>'
                 + '</div>'
                 + '<div class="item-footer">'
+                + disHtml
                 + '<span class="footer-label">小计:</span>'
-                + '<span class="footer-content text-title">¥' + (list[i].price / 100) + '</span>'
+                + '<span class="footer-content text-title">¥' + (price / 100) + '</span>'
                 + '</div>'
                 + '</li>'
 

+ 9 - 0
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_order_detail.html

@@ -25,6 +25,15 @@
   .j-footer {
     display: none;
   }
+  .disCount{
+    border: 1px solid rgba(251,72,61,0.10);
+    border-radius: 12px;
+    padding: .02rem .05rem;
+    background: rgba(251,72,61,0.10);
+    color: #FB483D;
+    font-size: .1rem !important;
+    margin-right: .2rem;
+  }
 </style>
 <body style="visibility:hidden">
     <div class="j-container" id="order_detail">

+ 1 - 1
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -67,7 +67,7 @@ func (this *OrderListDetails) GetOrderPayAllMsg() {
 			"order_code": orderCode,
 			//"order_status": 1,
 		}
-		oData := util.Mysql.FindOne(tableName_order, query, "id,order_code,prepay_time,create_time,pay_time,pay_way,original_price,applybill_status,out_trade_no,filter,product_type,order_status,applybill_type,applybill_taxnum,applybill_company,vip_starttime,vip_endtime,vip_type,discount_price,d_relation_id", "")
+		oData := util.Mysql.FindOne(tableName_order, query, "id,order_code,prepay_time,create_time,pay_time,pay_way,original_price,order_money,applybill_status,out_trade_no,filter,product_type,order_status,applybill_type,applybill_taxnum,applybill_company,vip_starttime,vip_endtime,vip_type,discount_price,d_relation_id", "")
 		//配置订单到期时间
 		order_countdown := config.Config.OrderCountdown //配置文件读取
 		activeData := util.Mysql.FindOne("prefer_active", map[string]interface{}{"order_code": orderCode, "user_id": userId}, "active_code", "")

+ 56 - 32
src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go

@@ -79,6 +79,11 @@ func (this *SubscribeChange) SaveChange() {
 	timeRenew := this.GetString("time")
 	req_price, _ := this.GetInteger("price")
 	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
+	//用户当前使用卡卷
+	userLotteryId := this.GetString("userLotteryId")
+	//卡卷信息的id
+	lotteryId := this.GetString("lotteryId")
+	discount_price := 0
 	r := func() *entity.FuncResult {
 		if len(industry) == 1 && industry[0] == "" { //去掉[""]
 			industry = []string{}
@@ -155,40 +160,57 @@ func (this *SubscribeChange) SaveChange() {
 					filter.GiveCycle = date_count
 				}
 			}
-		} else if !needUpgrade && needRenew { //只续费,不升级
-			//保存修改
-			if !entity.JyVipSubStruct.SubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), area, industry) {
-				return &entity.FuncResult{false, errors.New("保存修改出错"), nil}
+		} else {
+			full_price, reduce_price := 0, 0
+			if userLotteryId != "" && lotteryId != "" {
+				userLotteryId = qutil.SE.Decode4Hex(userLotteryId)
+				full_price, reduce_price = util.GetCouponInfo(userId, lotteryId, "超级订阅")
 			}
-			final_price = entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset.NewCitys, oldBuyset.AreaCount, oldBuyset.BuyerclassCount, date_count, date_unit, false)
-			filter.OrderType = 5
-			filter.NewBuyset = oldBuyset
-			log.Println("续费", final_price)
-			//生效时间
-			startTime = time.Unix(endUnix, 0)
-			endTime = util.GetDATE(filter.Cycleunit, filter.Cyclecount, endUnix)
-		} else { //升级
-			//升级(若存在续费,升级单子必须高于每个续费单子;否则不能升级)
-			totalPrice, subtotail := getUpgradeDetail(userId, upgradeBuyset, oldBuyset, endUnix, date_count, date_unit)
-			if totalPrice < 0 {
-				if totalPrice == -1 {
-					return &entity.FuncResult{false, errors.New("不能升级此状态"), nil}
-				} else {
-					return &entity.FuncResult{false, errors.New("查询续费订单出错"), nil}
+			if !needUpgrade && needRenew { //只续费,不升级
+				//保存修改
+				if !entity.JyVipSubStruct.SubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), area, industry) {
+					return &entity.FuncResult{false, errors.New("保存修改出错"), nil}
 				}
-			}
-			final_price = totalPrice
-			filter.OrderType = 3
-			filter.OldBuyset = oldBuyset
-			filter.NewBuyset = upgradeBuyset
-			filter.UpgradeSubtotail = subtotail
-
-			//生效时间
-			startTime = now
-			if needRenew {
+				final_price = entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset.NewCitys, oldBuyset.AreaCount, oldBuyset.BuyerclassCount, date_count, date_unit, false)
+				filter.OrderType = 5
+				filter.NewBuyset = oldBuyset
+				//卡卷使用
+				if reduce_price > 0 && full_price <= final_price {
+					final_price = final_price - reduce_price
+					discount_price = reduce_price
+				}
+				log.Println("续费", final_price)
+				//生效时间
+				startTime = time.Unix(endUnix, 0)
 				endTime = util.GetDATE(filter.Cycleunit, filter.Cyclecount, endUnix)
-			} else {
-				endTime = time.Unix(endUnix, 0)
+			} else { //升级
+				//升级(若存在续费,升级单子必须高于每个续费单子;否则不能升级)
+				totalPrice, subtotail := getUpgradeDetail(userId, upgradeBuyset, oldBuyset, endUnix, date_count, date_unit)
+				if totalPrice < 0 {
+					if totalPrice == -1 {
+						return &entity.FuncResult{false, errors.New("不能升级此状态"), nil}
+					} else {
+						return &entity.FuncResult{false, errors.New("查询续费订单出错"), nil}
+					}
+				}
+				//卡卷使用
+				if reduce_price > 0 && full_price <= totalPrice {
+					totalPrice = totalPrice - reduce_price
+					discount_price = reduce_price
+				}
+				final_price = totalPrice
+				filter.OrderType = 3
+				filter.OldBuyset = oldBuyset
+				filter.NewBuyset = upgradeBuyset
+				filter.UpgradeSubtotail = subtotail
+
+				//生效时间
+				startTime = now
+				if needRenew {
+					endTime = util.GetDATE(filter.Cycleunit, filter.Cyclecount, endUnix)
+				} else {
+					endTime = time.Unix(endUnix, 0)
+				}
 			}
 		}
 		log.Printf("是否需要升级%v,是否需要续费%v\n", needUpgrade, needRenew)
@@ -230,13 +252,15 @@ func (this *SubscribeChange) SaveChange() {
 			"order_code":     ordercode,
 			"product_type":   "VIP订阅",
 			"create_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
-			"original_price": final_price,
+			"original_price": final_price + discount_price, //原价
 			"filter_id":      "",
 			"user_id":        userId,
 			"filter":         string(filterStr), //筛选
 			"vip_endtime":    qutil.FormatDate(&endTime, qutil.Date_Full_Layout),
 			"vip_starttime":  qutil.FormatDate(&startTime, qutil.Date_Full_Layout),
 			"dis_word":       disWord,
+			"discount_price": discount_price,
+			"d_relation_id":  userLotteryId,
 			//"vip_type":       qutil.If(filter.OrderType == 5, 1, 2), //1:续费 2:升级
 		}
 		if filter.OrderType != 1 {

+ 32 - 14
src/web/templates/weixin/vipsubscribe/vip_order_detail.html

@@ -52,6 +52,15 @@
     .bill-origin-price .price-num {
         text-decoration: line-through;
     }
+    .disCount{
+      border: 1px solid rgba(251,72,61,0.10);
+      border-radius: 12px;
+      padding: .02rem .05rem;
+      background: rgba(251,72,61,0.10);
+      color: #FB483D;
+      font-size: .1rem !important;
+      margin-right: .2rem;
+    }
 </style>
 <body style="visibility:hidden">
 <div class="nothing" style="display:none;text-align: center;  padding-top: 2rem;">
@@ -202,6 +211,7 @@
         $DoPost("/subscribepay/orderListDetails/getOrderPayAllMsg", {"orderCode": orderCode}, function (r) {
             $("body").css("visibility", "");
             if (r.success) {
+                var discount_price = 0;
                 if (r.data.order.order_status == -1) {
                     $(".nothing").show();
                     $("#order_detail").hide();
@@ -211,12 +221,12 @@
                     $(".prepayTime").text(r.data.order.create_time.replace("-", ".").replace("-", "."));
                 }
                 //产品类型
-                if (r.data.order.original_price == 0) {
+                if (r.data.order.order_money == 0) {
                     $(".productType").text("超级订阅(试用)");
                 }
                 //价格
-                $(".price").text("¥ " + formatMoney(parseFloat(r.data.order.original_price) / 100));
-                $(".totalPrice").text("¥ " + formatMoney(parseFloat(r.data.order.original_price) / 100) + "元");
+                $(".price").text("¥ " + formatMoney(parseFloat(r.data.order.order_money) / 100));
+                $(".totalPrice").text("¥ " + formatMoney(parseFloat(r.data.order.order_money) / 100) + "元");
 
                 //优惠码
                 if (r.data.order.isUsedActiveCode) {
@@ -528,11 +538,12 @@
 
                 if (r.data.order.order_status == 0) {
                     if (r.data.order.discount_price&&r.data.order.discount_price>0){
-                      var totalPrice = Number(r.data.order.discount_price)+Number(r.data.order.original_price);
+                      discount_price = r.data.order.discount_price;
+                      var totalPrice = Number(r.data.order.discount_price)+Number(r.data.order.order_money);
                       $(".totalPrice").text('¥'+ formatMoney(totalPrice / 100)+'元')
                       $(".discountPrice").text('-¥'+ formatMoney(parseFloat(r.data.order.discount_price) / 100)+'元')
                     }
-                    $(".payPrice").text("¥ " + formatMoney(parseFloat(r.data.order.original_price) / 100) + "元");
+                    $(".payPrice").text("¥ " + formatMoney(parseFloat(r.data.order.order_money) / 100) + "元");
                     //未支付
                     $("#card-header-bg").addClass("bg nopay-bg")
                     $("#pageTitle").addClass("status")
@@ -585,7 +596,7 @@
                         //0试用用户、1续费、2升级、3购买
                         var vipType = 0
                         if (!r.data.order.vip_type) {
-                            if (r.data.order.original_price > 0) {
+                            if (r.data.order.order_money > 0) {
                                 vipType = 3
                             }
                         } else {
@@ -595,18 +606,19 @@
                     })
                 } else if (r.data.order.order_status == 1) {
                     if (r.data.order.discount_price&&r.data.order.discount_price>0){
-                      var totalPrice = Number(r.data.order.discount_price)+Number(r.data.order.original_price);
+                      discount_price = r.data.order.discount_price;
+                      var totalPrice = Number(r.data.order.discount_price)+Number(r.data.order.order_money);
                       $(".totalPrice").text('¥'+ formatMoney(totalPrice / 100)+'元')
                       $(".discountPrice").text('-¥'+ formatMoney(parseFloat(r.data.order.discount_price) / 100)+'元')
                     }
-                    $(".payPrice").text("¥ " + formatMoney(parseFloat(r.data.order.original_price) / 100) + "元");
+                    $(".payPrice").text("¥ " + formatMoney(parseFloat(r.data.order.order_money) / 100) + "元");
                     $("#card-header-bg").addClass("bg finish-bg")
                     $("#pageTitle").addClass("status")
                     $("#pageTitle").text("已完成");
                     //支付时间
                     $(".line_paytime").css("display", "");
                     if (r.data.order.pay_time) $(".payTime").text(r.data.order.pay_time.replace("-", ".").replace("-", "."));
-                    if (r.data.order.original_price == 0) {
+                    if (r.data.order.order_money == 0) {
                         $(".line_paytime").css("display", "none");
                     }
 
@@ -666,7 +678,7 @@
                         "order_code": orderCode
                     },
                     success: function (data) {
-                        appendList(data.list, data.order_money);
+                        appendList(data.list, data.order_money,discount_price);
                     }
                 });
 
@@ -689,7 +701,7 @@
 
 
             //
-            if ((r.data.order.original_price == 0) && (r.data.order.out_trade_no == "") && (r.data.order.vip_type == 2)) {
+            if ((r.data.order.order_money == 0) && (r.data.order.out_trade_no == "") && (r.data.order.vip_type == 2)) {
                 $(".line_transaction").hide();
                 $(".invoice").hide();
                 $(".line_payway").hide();
@@ -745,7 +757,7 @@
 
     var total_price = 0;
 
-    function appendList(list, money) {
+    function appendList(list, money,discount_price) {
         var returnHtml = "";
         for (var i = 0; i < list.length; i++) {
             var showTime = ""
@@ -815,12 +827,18 @@
                     + '<div class="vp-type-text">' + typeName + '</div>'
                     + '</div>'
             }
-
+            var disHtml = ""
+            var price = list[i].price
+            if (discount_price>0&&i==0){
+              disHtml =  '<span class="footer-label disCount">已优惠:¥'+(discount_price / 100)+'</span>'
+              price = price - discount_price
+            }
             returnHtml += '</div>'
                 + '</div>'
                 + '<div class="item-footer">'
+                + disHtml
                 + '<span class="footer-label">小计:</span>'
-                + '<span class="footer-content text-title">¥' + (list[i].price / 100) + '</span>'
+                + '<span class="footer-content text-title">¥' + (price / 100) + '</span>'
                 + '</div>'
                 + '</li>'