Forráskód Böngészése

优惠码延期30天,订单列表,订单详情

xuzhiheng 5 éve
szülő
commit
05eaead1a5

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

@@ -8,6 +8,7 @@ import (
 	"jfw/wx"
 	"net/url"
 	"qfw/util"
+	"qfw/util/redis"
 	"strconv"
 	"time"
 
@@ -223,7 +224,7 @@ func (s *Subscribepay) ToPurchasePage(flag string) {
 	if nowTime >= startTime && nowTime < endTime {
 		s.T["isLiveActive"] = true
 		//虚拟人数
-		buyCount := (nowTime - startTime) / 13
+		buyCount := redis.Get("other", "liveactiveRTB")
 		s.T["buyCount"] = buyCount
 	}
 	if flag == "trial" { //试用

+ 2 - 1
src/jfw/modules/app/src/app/front/vipsubscribe.go

@@ -5,6 +5,7 @@ import (
 	"jfw/config"
 	"jfw/public"
 	"qfw/util"
+	"qfw/util/redis"
 	"strconv"
 	"strings"
 	"time"
@@ -149,7 +150,7 @@ func (s *Subscribepay) ToPurchasePage(flag string) {
 	if nowTime >= startTime && nowTime < endTime {
 		s.T["isLiveActive"] = true
 		//虚拟人数
-		buyCount := (nowTime - startTime) / 13
+		buyCount := redis.Get("other", "liveactiveRTB")
 		s.T["buyCount"] = buyCount
 	}
 	if flag == "trial" { //试用

+ 22 - 13
src/jfw/modules/app/src/web/templates/dataExport/dataExport_toMyOrder.html

@@ -1312,6 +1312,10 @@
 						var listhtml='';
 						for(var index in object){
 					   		var obj=object[index];
+							var isUsedActiveCode = false
+							if(obj.isUsedActiveCode){
+								isUsedActiveCode = true;
+							}
 							if(obj.product_type=="历史数据"){
 					    		count++;
 								var id = obj.id;
@@ -1818,13 +1822,16 @@
 															+'<p class="item-ifo ellipsis">订阅周期:'+effectiveduration_vip+'</p>'
 														+'</div>'
 													+'</a>'
-													+'<div class="price">'
-													+'<span class="origin-price-container">'
-													+ '<span>原价:¥</span>'
-													+ '<span class="origin-price">' + orderMoney_vip + '</span>'
-													+ '</span>'
-														+'<strong class="current">¥'+orderMoney_vip+'</strong>'
-													+'</div>'
+									if(isUsedActiveCode){
+										listhtml+= '<div class="price">'
+														+ '<span class="origin-price-container">'
+														+ '<span>原价:¥</span>'
+														+ '<span class="origin-price">' + orderMoney_vip + '</span>'
+														+ '</span>'
+									}
+									listhtml+= '<div class="price">'
+												+'<strong class="current">¥'+orderMoney_vip+'</strong>'
+												+'</div>'
 												+'</div>'
 												+iconHtml
 										+'</div>'
@@ -1853,12 +1860,14 @@
 																	+'<p class="item-ifo ellipsis">有效日期:'+effectivetime_vip+'</p>'
 																+'</div>'
 															+'</a>'
-															+'<div class="price">'
-															+'<span class="origin-price-container">'
-															+ '<span>原价:¥</span>'
-															+ '<span class="origin-price">' + orderMoney_vip + '</span>'
-															+ '</span>'
-															+'<div class="price">'
+											if(isUsedActiveCode){
+												listhtml+= '<div class="price">'
+																+ '<span class="origin-price-container">'
+																+ '<span>原价:¥</span>'
+																+ '<span class="origin-price">' + orderMoney_vip + '</span>'
+																+ '</span>'
+											}
+											listhtml+= '<div class="price">'
 																+'<strong class="current">¥'+orderMoney_vip+'</strong>'
 															+'</div>'
 														+'</div>'

+ 14 - 7
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_order_detail.html

@@ -268,22 +268,22 @@
 										<p class="l-item">
 											<span class="dyqy label">区域:</span>
 											<span class="value item-list-parents areaNum"></span>
-
 										</p>
 										<p class="l-item">
 											<span class="dyhy">行业数量:</span>
-											<span class="item-list-parents industryNum value">
-											</span>
+											<span class="item-list-parents industryNum value"></span>
 										</p>
 										<p class="l-item">
 											<span class="dyzq">订阅周期:</span>
-											<span class="item-list-parents cyclecount value">
+											<span class="item-list-parents cyclecount value"></span>
+											<span class="discount-container hide">
+											    <span>+</span>
+											    <span class="highlight-text">赠送30天</span>
 											</span>
 										</p>
 										<p class="l-item line_cycle" style="display:none">
 											<span>有效日期:</span>
-											<span class="item-list-parents serviceTime value">
-											</span>
+											<span class="item-list-parents serviceTime value"></span>
 										</p>
 									</div>
 								</div>
@@ -386,7 +386,14 @@
         }
         //价格
         $(".price").text("¥ "+r.data.order.original_price/100+"元");
-        
+		
+		//优惠码
+		if(!r.data.order.isUsedActiveCode){
+			$(".origin-price-container").hide();
+		}else{
+			$(".discount-container").removeClass("hide");
+		}
+		
 		var areaText="";
 		var industry_vip="";
         //订单条件        

+ 22 - 0
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -12,6 +12,7 @@ import (
 	"gopkg.in/mgo.v2/bson"
 
 	qutil "qfw/util"
+	"qfw/util/redis"
 )
 
 type vipSubscribeStruct struct{}
@@ -94,6 +95,15 @@ func (this *vipSubscribeStruct) PayCallBack(param *CallBackParam) bool {
 		log.Printf("%s订单状态异常%d\n", userid, order_status)
 		return false //
 	}
+	//优惠码
+	orderCode := qutil.ObjToString((*orderdata)["order_code"])
+	activeData := util.Mysql.FindOne("prefer_active", map[string]interface{}{
+		"order_code": orderCode,
+		"user_id":    userid,
+	}, "active_code", "")
+	if activeData != nil {
+		redis.Put("other", "vipActiveCode_"+userid, (*activeData)["active_code"], 60*60*24*30)
+	}
 	//计算时长
 	vmsg := VipSimpleMsg{}
 	filterStr := qutil.ObjToString((*orderdata)["filter"])
@@ -112,6 +122,9 @@ func (this *vipSubscribeStruct) PayCallBack(param *CallBackParam) bool {
 	if vmsg.OrderType == 1 { //新订单 计算开始时间 结束时间
 		startTime = time.Now()
 		endTime = util.GetDATE(vmsg.Cycleunit, vmsg.Cyclecount, startTime.Unix())
+		if activeData != nil {
+			endTime = endTime.AddDate(0, 0, 30)
+		}
 		updateMap["vip_starttime"] = qutil.FormatDate(&startTime, qutil.Date_Full_Layout)
 		updateMap["vip_endtime"] = qutil.FormatDate(&endTime, qutil.Date_Full_Layout)
 	}
@@ -568,6 +581,15 @@ func (this *vipSubscribeStruct) GetSubVipPriceByBuySet(cityCountArr []int, pCoun
 	return payMoney
 }
 
+func (this *vipSubscribeStruct) GetVipLiveActive(userId string) bool {
+	isOk := false
+	redisData := redis.Get("other", "vipActiveCode_"+userId)
+	if redisData != nil {
+		isOk = true
+	}
+	return isOk
+}
+
 /*
 vip订阅 套餐价格
 c(city) 全国:0 省:1 市:2

+ 21 - 0
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -72,6 +72,17 @@ func (this *OrderListDetails) GetOrderPayAllMsg() {
 			(*oData)["order_countdown"] = qutil.IntAll(order_countdown)
 		}
 
+		//优惠码
+		nowTime := time.Now().Unix()
+		liveActiveStartTime := config.Config.LiveActiveStartTime
+		liveActiveEndTime := config.Config.LiveActiveEndTime
+		if nowTime >= liveActiveStartTime && nowTime < liveActiveEndTime {
+			activeData := util.Mysql.FindOne("prefer_active", map[string]interface{}{"order_code": orderCode, "user_id": userId}, "active_code", "")
+			if activeData != nil {
+				(*oData)["isUsedActiveCode"] = true
+			}
+		}
+
 		//查询订单信息
 		if oData == nil || len(*oData) == 0 {
 			return &entity.FuncResult{false, errors.New("未找到此订单"), nil}
@@ -676,6 +687,16 @@ func (o *OrderListDetails) Datas(queryM map[string]interface{}, pageNum, pagesiz
 					result[i]["order_status"] = orderStatus_cancel
 					go FortyEightHoursCancel(qutil.ObjToString(result[i]["order_code"]), create_time_stamp, time.Now().Unix())
 				}
+				//优惠码
+				nowTime := time.Now().Unix()
+				liveActiveStartTime := config.Config.LiveActiveStartTime
+				liveActiveEndTime := config.Config.LiveActiveEndTime
+				if nowTime >= liveActiveStartTime && nowTime < liveActiveEndTime {
+					activeData := util.Mysql.FindOne("prefer_active", map[string]interface{}{"order_code": result[i]["order_code"]}, "active_code", "")
+					if activeData != nil {
+						result[i]["isUsedActiveCode"] = true
+					}
+				}
 			}
 		}
 	}

+ 40 - 13
src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go

@@ -48,20 +48,29 @@ func (this *SubscribeChange) GetSubBuyMsg() {
 		if vipStatus == 2 { //查询是否有未执行的续费订单
 			renewList, _ = util.MQFW.Find("vip_upgrade", &bson.M{"s_userid": userId, "i_isvalid": 0}, `{"l_validtime":"1"}`, `{"o_buyset":1,"l_validtime":1}`, false, -1, -1)
 		}
+		//优惠码
+		isUsedActiveCode := false
+		nowTime := time.Now().Unix()
+		liveActiveStartTime := config.Config.LiveActiveStartTime
+		liveActiveEndTime := config.Config.LiveActiveEndTime
+		if nowTime >= liveActiveStartTime && nowTime < liveActiveEndTime {
+			isUsedActiveCode = entity.JyVipSubStruct.GetVipLiveActive(userId)
+		}
 		return &entity.FuncResult{true, nil, map[string]interface{}{
-			"isTrial":         vipStatus == 1,
-			"area":            (*o_vipjy)["o_area"],
-			"industry":        (*o_vipjy)["a_buyerclass"],
-			"buyset":          buyset,
-			"renewList":       renewList,
-			"infotype":        (*o_vipjy)["a_infotype"],
-			"items":           (*o_vipjy)["a_items"],
-			"projectmatch":    (*o_vipjy)["i_projectmatch"],
-			"ratemode":        (*o_vipjy)["i_ratemode"],
-			"startTime":       (*rData)["l_vip_starttime"],
-			"endTime":         (*rData)["l_vip_endtime"],
-			"otherbuyerclass": (*o_vipjy)["i_matchbuyerclass_other"],
-			"isread":          isread,
+			"isTrial":          vipStatus == 1,
+			"area":             (*o_vipjy)["o_area"],
+			"industry":         (*o_vipjy)["a_buyerclass"],
+			"buyset":           buyset,
+			"renewList":        renewList,
+			"infotype":         (*o_vipjy)["a_infotype"],
+			"items":            (*o_vipjy)["a_items"],
+			"projectmatch":     (*o_vipjy)["i_projectmatch"],
+			"ratemode":         (*o_vipjy)["i_ratemode"],
+			"startTime":        (*rData)["l_vip_starttime"],
+			"endTime":          (*rData)["l_vip_endtime"],
+			"otherbuyerclass":  (*o_vipjy)["i_matchbuyerclass_other"],
+			"isread":           isread,
+			"isUsedActiveCode": isUsedActiveCode,
 		}}
 	}()
 	if r.Err != nil {
@@ -78,6 +87,7 @@ func (this *SubscribeChange) SaveChange() {
 	timeRenew := this.GetString("time")
 	payWay := this.GetString("payWay")
 	req_price, _ := this.GetInteger("price")
+	activeCode := this.GetString("activeCode") //优惠码
 	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
 	r := func() *entity.FuncResult {
 		if len(industry) == 1 && industry[0] == "" { //去掉[""]
@@ -188,6 +198,9 @@ func (this *SubscribeChange) SaveChange() {
 			final_price = int(float64(final_price) * 0.6)
 			log.Println("final_price", final_price)
 		}
+		if activeCode == "jianyu360" {
+			endTime = endTime.AddDate(0, 0, 30)
+		}
 		//
 		if req_price != final_price {
 			log.Println(userId+" 前台计算", req_price, "后台计算", final_price)
@@ -278,6 +291,20 @@ func (this *SubscribeChange) SaveChange() {
 		if orderid == -1 {
 			return &entity.FuncResult{false, errors.New("数据库操作异常"), nil}
 		}
+		//优惠码
+		if activeCode == "jianyu360" {
+			activeInsertMap := map[string]interface{}{
+				"order_code":  ordercode,
+				"create_time": qutil.FormatDate(&now, qutil.Date_Full_Layout),
+				"active_type": "VIP订阅",
+				"user_id":     userId,
+				"active_code": activeCode,
+			}
+			activeOrderId := util.Mysql.Insert("prefer_active", activeInsertMap)
+			if activeOrderId == -1 {
+				return &entity.FuncResult{false, errors.New("优惠码存库异常"), nil}
+			}
+		}
 		//支付提醒
 		util.MsgRemind.Add(qutil.IntAll(orderid), final_price, qutil.If(filter.OrderType == 5, 1, -1).(int), 0, ordercode, userId, now.Unix())
 		return &entity.FuncResult{true, nil, map[string]interface{}{"code": ordercode, "res": payStr, "needPay": true}}

+ 18 - 3
src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -44,7 +44,7 @@ func (this *SubVipPayOrder) CreateOrder() {
 	orderType, _ := this.GetInteger("orderType") //1 简单付费,5 升降级续费
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
-	activeCode := this.GetString("activeCode")
+	activeCode := this.GetString("activeCode") //优惠码
 	r := func() *entity.FuncResult {
 		now := time.Now()
 		//数据校验
@@ -101,7 +101,9 @@ func (this *SubVipPayOrder) CreateOrder() {
 		startTime := config.Config.LiveActiveStartTime
 		endTime := config.Config.LiveActiveEndTime
 		if nowTime >= startTime && nowTime < endTime {
-			totalfee = int(float64(totalfee) * 0.6)
+			if totalfee > 100 {
+				totalfee = int(float64(totalfee) * 0.6)
+			}
 			log.Println("totalfee", totalfee)
 		}
 		//
@@ -166,6 +168,9 @@ func (this *SubVipPayOrder) CreateOrder() {
 			timeStamp := qutil.Int64All((*userData)["l_vip_endtime"])
 			startTime := time.Unix(timeStamp, 0)
 			endTime := util.GetDATE(filter.Cycleunit, filter.Cyclecount, timeStamp)
+			if activeCode == "jianyu360" {
+				endTime = endTime.AddDate(0, 0, 30)
+			}
 			insertMap["vip_type"] = 1
 			insertMap["vip_starttime"] = qutil.FormatDate(&startTime, qutil.Date_Full_Layout)
 			insertMap["vip_endtime"] = qutil.FormatDate(&endTime, qutil.Date_Full_Layout)
@@ -176,7 +181,17 @@ func (this *SubVipPayOrder) CreateOrder() {
 		}
 		//优惠码
 		if activeCode == "jianyu360" {
-
+			activeInsertMap := map[string]interface{}{
+				"order_code":  ordercode,
+				"create_time": qutil.FormatDate(&now, qutil.Date_Full_Layout),
+				"active_type": "VIP订阅",
+				"user_id":     userId,
+				"active_code": activeCode,
+			}
+			activeOrderId := util.Mysql.Insert("prefer_active", activeInsertMap)
+			if activeOrderId == -1 {
+				return &entity.FuncResult{false, errors.New("优惠码存库异常"), nil}
+			}
 		}
 		//支付提醒
 		util.MsgRemind.Add(qutil.IntAll(orderid), totalfee, qutil.If(orderType == 5, 1, -1).(int), 0, ordercode, userId, now.Unix())

BIN
src/web/templates/weixin/.DS_Store


+ 21 - 9
src/web/templates/weixin/dataExport/dataExport_toMyOrder.html

@@ -542,6 +542,10 @@
         var psss = 0;
         for (var index in object) {
             var obj = object[index];
+			var isUsedActiveCode = false
+			if(obj.isUsedActiveCode){
+				isUsedActiveCode = true;
+			}
             if (obj.product_type == "历史数据") {
                 count++;
                 var id = obj.id;
@@ -1166,12 +1170,14 @@
                         + '<p class="item-ifo ellipsis">订阅周期:' + effectiveduration_vip + '</p>';
                     //}
                     listhtml += '</div></a>'
-                        +'<div class="price">'
-                        +'<span class="origin-price-container">'
-                        + '<span>原价:¥</span>'
-                        + '<span class="origin-price">' + orderMoney_vip + '</span>'
-                        + '</span>'
-                        + '<div class="price">'
+					if(isUsedActiveCode){
+						listhtml += '<div class="price">'
+						+ '<span class="origin-price-container">'
+						+ '<span>原价:¥</span>'
+						+ '<span class="origin-price">' + orderMoney_vip + '</span>'
+						+ '</span>'
+					}
+                    listhtml += '<div class="price">'
                         + '<strong class="current">¥' + orderMoney_vip + '</strong>'
                         + '</div>'
                         + '</div>'
@@ -1201,9 +1207,15 @@
                         + '<p class="item-ifo ellipsis">订阅周期:' + effectiveduration_vip + '</p>'
                         + '<p class="item-ifo ellipsis">有效日期:' + effectivetime_vip + '</p>';
                     //}
-                    listhtml += '</div>'
-                        + '</a>'
-                        + '<div class="price">'
+                    listhtml += '</div></a>'
+                    if(isUsedActiveCode){
+                    	listhtml += '<div class="price">'
+                    	+ '<span class="origin-price-container">'
+                    	+ '<span>原价:¥</span>'
+                    	+ '<span class="origin-price">' + orderMoney_vip + '</span>'
+                    	+ '</span>'
+                    }
+                    listhtml += '<div class="price">'
                         + '<strong class="current">¥' + orderMoney_vip + '</strong>'
                         + '</div>'
                         + '</div>'

+ 7 - 0
src/web/templates/weixin/vipsubscribe/vip_order_detail.html

@@ -218,6 +218,13 @@ try{
         }
         //价格
         $(".price").text("¥ "+r.data.order.original_price/100 +"元");
+		
+		//优惠码
+		if(!r.data.order.isUsedActiveCode){
+			$(".origin-price-container").hide();
+		}else{
+			$(".discount-container").removeClass("hide");
+		}
 
         //订单条件
         if(r.data.order.filter){