Pārlūkot izejas kodu

Merge branch 'feature/v4.10.0' of https://jygit.jydev.jianyu360.cn/qmx/jy into feature/v4.10.0

wangshan 4 mēneši atpakaļ
vecāks
revīzija
241a87a5ba

+ 37 - 24
src/jfw/front/commonPayPc.go

@@ -1,14 +1,16 @@
 package front
 
 import (
-	"fmt"
-	"jy/src/jfw/config"
-	"strings"
-	"time"
+    "app.yhyue.com/moapp/jypkg/public"
+    "fmt"
+    "github.com/gogf/gf/v2/util/gconv"
+    "jy/src/jfw/config"
+    "strings"
+    "time"
 
-	qutil "app.yhyue.com/moapp/jybase/common"
+    qutil "app.yhyue.com/moapp/jybase/common"
 
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+    "app.yhyue.com/moapp/jybase/go-xweb/xweb"
 )
 
 type JyOrder struct {
@@ -23,13 +25,13 @@ func init() {
 	xweb.AddAction(&JyOrder{})
 }
 
-//pc端详情页
+// pc端详情页
 func (this *JyOrder) OrderDetail(orderType, orderCode string) {
 	this.T["orderId"] = orderCode
 	this.Render(fmt.Sprintf("/order/pc/%s/detail.html", orderType))
 }
 
-//pc端订单支付页
+// pc端订单支付页
 func (this *JyOrder) OrderPay(orderType, orderCode string) error {
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	if userId == "" {
@@ -41,25 +43,36 @@ func (this *JyOrder) OrderPay(orderType, orderCode string) error {
 	return this.Render("/order/pc/orderPay.html")
 }
 
-//pc支付成功页面
+// pc支付成功页面
 func (this *JyOrder) PaySuccess(orderType, orderCode string) error {
-	userId := qutil.ObjToString(this.GetSession("userId"))
-	if userId == "" {
-		return this.Redirect("/notin/page")
-	}
-	this.T["payway"] = qutil.If(strings.Index(this.GetString("payway"), "wx") > -1, "微信", "支付宝")
-	this.T["email"] = this.GetString("email")
-	if payTime, err := this.GetInt("payTime"); err == nil {
-		this.T["payTime"] = time.Unix(payTime, 0).Format("2006年01月02日")
-	}
-	this.T["price"] = this.GetString("price")
-	this.T["shareid"] = "10"
-	this.T["orderType"] = orderType
-	this.T["orderCode"] = orderCode
-	return this.Render("/order/pc/paySuccess.html")
+    userId := qutil.ObjToString(this.GetSession("userId"))
+    if userId == "" {
+        return this.Redirect("/notin/page")
+    }
+    this.T["payway"] = qutil.If(strings.Index(this.GetString("payway"), "wx") > -1, "微信", "支付宝")
+    this.T["email"] = this.GetString("email")
+    if payTime, err := this.GetInt("payTime"); err == nil {
+        this.T["payTime"] = time.Unix(payTime, 0).Format("2006年01月02日")
+    }
+    positionType := gconv.String(this.GetSession("positionType"))
+    this.T["price"] = this.GetString("price")
+    this.T["shareid"] = "10"
+    this.T["positionType"] = positionType
+    this.T["orderType"] = orderType
+    this.T["orderCode"] = orderCode
+    //订单详情查询
+    data := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
+        "order_code": orderCode,
+    }, "vip_type", "")
+    vipType := int64(0)
+    if data != nil && len(*data) > 0 {
+        vipType = gconv.Int64((*data)["vip_type"])
+    }
+    this.T["vipType"] = vipType
+    return this.Render("/order/pc/paySuccess.html")
 }
 
-//我的订单
+// 我的订单
 func (this *JyOrder) ToMyOrder() error {
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	if userId == "" {

+ 27 - 10
src/jfw/front/commonPayWx.go

@@ -3,7 +3,8 @@ package front
 import (
 	"errors"
 	"fmt"
-	"jy/src/jfw/config"
+    "github.com/gogf/gf/v2/util/gconv"
+    "jy/src/jfw/config"
 	"jy/src/jfw/wx"
 	"net/url"
 
@@ -83,15 +84,31 @@ func (w *WxPayCommon) PaySuccess(doType string) error {
 	w.T["title"] = "支付"
 	titleArr, exist := titleMap[doType]
 	if exist && t < len(titleArr) {
-		w.T["title"] = titleArr[t]
-	}
-	if doType == "dataexport" { //数据导出支付成功
-		return w.Render("/weixin/dataExport/dataExport_paySuccess.html", &w.T)
-	} else if doType == "subvip" { //vip订阅支付成功
-		return w.Render("/weixin/vipsubscribe/vip_pay_success.html")
-	}
-	w.T["doType"] = doType
-	return w.Render("/weixin/commonPay/paySuccess.html", &w.T)
+        w.T["title"] = titleArr[t]
+    }
+    productType := ""
+    if doType == "subvip" {
+        productType = "VIP订阅"
+    }
+    sessVal := w.Session().GetMultiple()
+    positionType := gconv.String(sessVal["positionType"])
+    w.T["productType"] = productType
+    w.T["positionType"] = positionType
+    data := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
+        "order_code": w.GetString("orderCode"),
+    }, "vip_type", "")
+    vipType := int64(0)
+    if data != nil && len(*data) > 0 {
+        vipType = gconv.Int64((*data)["vip_type"])
+    }
+    w.T["vipType"] = vipType
+    if doType == "dataexport" { //数据导出支付成功
+        return w.Render("/weixin/dataExport/dataExport_paySuccess.html", &w.T)
+    } else if doType == "subvip" { //vip订阅支付成功
+        return w.Render("/weixin/vipsubscribe/vip_pay_success.html")
+    }
+    w.T["doType"] = doType
+    return w.Render("/weixin/commonPay/paySuccess.html", &w.T)
 }
 
 func (w *WxPayCommon) ToMyWxOrder() error {

+ 47 - 0
src/jfw/front/singleLogin.go

@@ -1,7 +1,9 @@
 package front
 
 import (
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jy/src/jfw/config"
 	"jy/src/jfw/jyutil"
 	"log"
@@ -27,6 +29,7 @@ type SingleLogin struct {
 	singleLogin xweb.Mapper `xweb:"/swordfish/SingleLogin"` //微信登录中转
 	shortUrl    xweb.Mapper `xweb:"/stl/(.*)"`              //短地址跳转
 	keyPhrases  xweb.Mapper `xweb:"/kph/(.*)"`              //微信自动回复关键字组
+	vipGiftUrl  xweb.Mapper `xweb:"/vipGiftUrl/(.*)"`       //告知页面跳转链接
 }
 
 func init() {
@@ -39,6 +42,50 @@ const (
 	setPage = "/front/vipsubscribe/toSubVipSetPage?vSwitch=%s"
 )
 
+// 709vip赠送  告知页面跳转
+func (this *SingleLogin) VipGiftUrl(key string) error {
+	var redirectUrl = ""
+	isSubscribe := false
+	chatIdInt := gconv.Int64(encrypt.SE.Decode4HexByCheck(key))
+	isWxB := public.CheckWxBrowser(this.Request)
+	sess := this.Session().GetMultiple()
+	userId, _ := sess["userId"].(string)
+	openid := ""
+	log.Println("1111", key, chatIdInt, isWxB, userId)
+	if isWxB && userId == "" {
+		if this.GetString("state") == "wx" {
+			//微信跳回来的
+			if code := this.GetString("code"); code != "" {
+				openid = jyutil.Getopenid(code)
+				if CheckUserIsSubscribe(openid) {
+					FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
+					//生session后 重新获取一下
+					sess = this.Session().GetMultiple()
+					userId, _ = sess["userId"].(string)
+				}
+			}
+		} else {
+			//所有参数都不再使用,跳到微信验证用户
+			log.Println(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"))
+			return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"), 302)
+		}
+	}
+	if key != "" && chatIdInt > 0 {
+		openid = qutil.InterfaceToStr(this.GetSession("s_m_openid"))
+		//查看是否关注公众号
+		log.Println("VIP订阅赠送", key, chatIdInt, openid)
+		if openid == "" || (openid != "" && !CheckUserIsSubscribe(openid)) {
+			//没有关注  跳转关注页面
+		} else {
+			isSubscribe = true
+		}
+		redirectUrl = fmt.Sprintf("/jy_mobile/giving/share?isSubscribe=%v&giftId=%s", isSubscribe, key)
+	} else {
+		redirectUrl = "/swordfish/about"
+	}
+	return this.Redirect(redirectUrl)
+}
+
 // P506 关键词组 短地址跳转
 func (this *SingleLogin) KeyPhrases(key string) error {
 	defer qutil.Catch()

+ 19 - 0
src/jfw/modules/app/src/app/front/commonPay.go

@@ -1,8 +1,10 @@
 package front
 
 import (
+	"app.yhyue.com/moapp/jypkg/public"
 	"errors"
 	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"strings"
 
 	util "app.yhyue.com/moapp/jybase/common"
@@ -85,12 +87,29 @@ func (w *AppPayCommon) PaySuccess(doType string) error {
 	if exist && t < len(titleArr) {
 		w.T["title"] = titleArr[t]
 	}
+	productType := ""
+	if doType == "subvip" {
+		productType = "VIP订阅"
+	}
+	sessVal := w.Session().GetMultiple()
+	positionType := gconv.String(sessVal["positionType"])
+	w.T["productType"] = productType
+	w.T["positionType"] = positionType
+	data := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
+		"order_code": w.GetString("orderCode"),
+	}, "vip_type", "")
+	vipType := int64(0)
+	if data != nil && len(*data) > 0 {
+		vipType = gconv.Int64((*data)["vip_type"])
+	}
+	w.T["vipType"] = vipType
 	if doType == "dataexport" { //数据导出支付成功页面
 		return w.Render("/dataExport/dataExport_paySuccess.html", &w.T)
 	} else if doType == "subvip" { //vip订阅支付成功
 		return w.Render("/vipsubscribe/vip_pay_success.html")
 	}
 	w.T["doType"] = doType
+
 	return w.Render("/commonPay/paySuccess.html", &w.T)
 }
 

+ 0 - 2
src/jfw/modules/app/src/go.mod

@@ -14,8 +14,6 @@ require (
 	go.mongodb.org/mongo-driver v1.14.0
 )
 
-replace github.com/go-xorm/xorm v0.7.9 => gitea.com/xorm/xorm v0.7.9
-
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
 	app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230304035551-21bb1eedf547 // indirect

+ 37 - 2
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_pay_success.html

@@ -35,7 +35,18 @@
     /* .active-tip-group img {
         display: block;
     } */
-
+    .giving-tip{
+      width: 4.22rem;
+      padding: .12rem 0;
+      margin: .36rem auto 0;
+      border: 1px solid#2ABED1;
+      border-radius: .32rem;
+      text-align: center;
+      font-size: .28rem;
+      line-height: .4rem;
+      background: #fff;
+      color: #2ABED1;
+    }
   </style>
 </head>
 <body>
@@ -53,6 +64,7 @@
                     &yen;
                     <em></em>
                 </p>
+                <div class="giving-tip" style="display: none;" onclick="location.href='/jy_mobile/giving/friend'">将超级订阅赠送给好友</div>
             </div>
             <div class="info_box">
                 <div class="pay_mode">
@@ -96,7 +108,8 @@
 
   var title = {{.T.title}}
   var orderCode = {{.T.orderCode}}
-  console.log(orderCode)
+  var positionType = {{.T.positionType}}
+  var vipType = {{.T.vipType}}
 //   if (title.indexOf('超级订阅') !== -1) {
 //     getActiveInfo()
 //   }
@@ -280,7 +293,29 @@
             var money = t.split('').reverse().join('') + point + right;
             return money;
         }
+        getVipGiftConfig()
   })
+  function getVipGiftConfig() {
+    $.ajax({
+      url: '/subscribepay/vip/gift/configuration',
+      type: 'POST',
+      success: function(res) {
+          if(res && res.data) {
+            var startTime = res.data.startTime
+            var endTime = res.data.endTime
+            var isValidPeriod = startTime && endTime && parseInt(startTime) < parseInt(endTime)
+            var nowTime = Math.floor(Date.now() / 1000)
+            var isNewBuy = vipType != 1 && vipType != 2
+            var vipGiftPeriod = isValidPeriod && nowTime >= parseInt(startTime) && nowTime <= parseInt(endTime) && positionType === '0' && isNewBuy
+            if (vipGiftPeriod) {
+              $('.giving-tip').show()
+            } else {
+              $('.giving-tip').hide()
+            }
+          }
+      }
+    })
+  }
 </script>
 {{include "/common/baiducc.html"}}
 </html>

+ 2 - 0
src/jfw/modules/subscribepay/src/a/init.go

@@ -89,4 +89,6 @@ func init() {
 	//人脉通
 	xweb.AddRouter("/subscribepay", &service.Network{})
 	xweb.AddRouter("/subscribepay", &service.DocMember{})
+	//超级订阅赠送
+	xweb.AddRouter("/subscribepay", &service.VipGift{})
 }

+ 3 - 1
src/jfw/modules/subscribepay/src/config.json

@@ -231,5 +231,7 @@
   },
   "wxProceduresMoney": 0.54,
   "aliProceduresMoney": 0.6,
-  "corporateProceduresMoney": 0
+  "corporateProceduresMoney": 0,
+  "vipGiftStartTime": 1709827200,
+  "vipGiftEndTime":1709827200
 }

+ 2 - 0
src/jfw/modules/subscribepay/src/config/config.go

@@ -159,6 +159,8 @@ type config struct {
 	WxProceduresMoney        float64           `json:"wxProceduresMoney"`
 	AliProceduresMoney       float64           `json:"aliProceduresMoney"`
 	CorporateProceduresMoney float64           `json:"corporateProceduresMoney"`
+	VipGiftEndTime           int64             `json:"vipGiftEndTime"`
+	VipGiftStartTime         int64             `json:"vipGiftStartTime"`
 }
 
 type SiteMsgStruct struct {

+ 2 - 0
src/jfw/modules/subscribepay/src/filter/sessionfilter.go

@@ -26,6 +26,8 @@ func (l *sessionfilter) Do() bool {
 		strings.HasPrefix(rqu, "/jypay/invoice/submit") || //发票信息提交
 		strings.HasPrefix(rqu, "/jypay/invoice/query") || //发票信息查询
 		strings.HasPrefix(rqu, "/jypay/invoice/newReplace") || //扫码换票
+		strings.HasPrefix(rqu, "/subscribepay/vip/gift/informInfo") || //vip赠送告知页面
+		strings.HasPrefix(rqu, "/subscribepay/vip/gift/configuration") || //vip赠送配置页面
 		rqu == "/jypay/wx/getwxSdkSign" || rqu == "/jypay/user/company/association" ||
 		rqu == "/jypay/equityCode/submit" || rqu == "/jypay/equityCode/captcha" || rqu == "/jypay/getDomain" { //微信js调用参数
 		return true

+ 3 - 4
src/jfw/modules/subscribepay/src/main.go

@@ -4,18 +4,17 @@ import (
 	_ "jy/src/jfw/modules/subscribepay/src/a"
 	. "jy/src/jfw/modules/subscribepay/src/config"
 	_ "jy/src/jfw/modules/subscribepay/src/filter"
+	"jy/src/jfw/modules/subscribepay/src/timetask"
 	"log"
 	"net/http"
 	"net/rpc"
 
 	"app.yhyue.com/moapp/jybase/endless"
 
-	"jy/src/jfw/modules/subscribepay/src/rpcfollow"
-	_ "jy/src/jfw/modules/subscribepay/src/service"
-	"jy/src/jfw/modules/subscribepay/src/timetask"
-
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	"app.yhyue.com/moapp/jylog"
+	"jy/src/jfw/modules/subscribepay/src/rpcfollow"
+	_ "jy/src/jfw/modules/subscribepay/src/service"
 )
 
 func main() {

+ 390 - 0
src/jfw/modules/subscribepay/src/service/transferVipSub.go

@@ -0,0 +1,390 @@
+package service
+
+import (
+	. "app.yhyue.com/moapp/jybase/api"
+	qutil "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jybase/mongodb"
+	"app.yhyue.com/moapp/jybase/redis"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
+	"fmt"
+	"github.com/gogf/gf/v2/os/gtime"
+	"github.com/gogf/gf/v2/util/gconv"
+	"go.mongodb.org/mongo-driver/bson"
+	"jy/src/jfw/modules/subscribepay/src/config"
+	"jy/src/jfw/modules/subscribepay/src/util"
+	"log"
+	"time"
+)
+
+// 接收人信息
+type Received struct {
+	Uid        string
+	Phone      string
+	Duration   int
+	BPhone     string // 被赠 手机号
+	StartTime  string // 被赠 开始时间
+	EndTime    string // 被赠 结束时间
+	Itype      int    // 接收人 1: 续费,2: 新购
+	UpdateInfo map[string]interface{}
+}
+
+func (t *VipGift) GetSubDuration() {
+	userid := qutil.ObjToString(t.GetSession("mgoUserId"))
+	rData, errMsg := func() (interface{}, error) {
+		user, ok := util.MQFW.FindById("user", userid, bson.M{"i_vip_status": 1, "l_vip_endtime": 1, "l_vip_starttime": 1, "o_vipjy": 1})
+		if ok && len(*user) > 0 {
+			areacount := 0
+			if vip := gconv.Map((*user)["o_vipjy"]); vip != nil && vip["o_buyset"] != nil {
+				areacount = gconv.Int(gconv.Map(vip["o_buyset"])["areacount"])
+			}
+			if qutil.IntAll((*user)["i_vip_status"]) > 0 {
+				//startTime := qutil.Int64All((*user)["l_vip_starttime"])
+				endTime := qutil.Int64All((*user)["l_vip_endtime"])
+				dif, _ := difMouth(time.Now().Unix(), endTime)
+				return map[string]interface{}{
+					"gifted":    dif,
+					"areacount": areacount,
+				}, nil
+			}
+			return map[string]interface{}{
+				"gifted":    0,
+				"areacount": areacount,
+			}, nil
+		}
+		return nil, fmt.Errorf("未查询到身份信息")
+	}()
+	t.ServeJson(NewResult(rData, errMsg))
+}
+
+func (t *VipGift) GetInfoByPhone() {
+	userid := qutil.ObjToString(t.GetSession("mgoUserId"))
+	phone := t.GetString("phone")
+	rData, errMsg := func() (interface{}, error) {
+		giver := qutil.ObjToString(t.GetSession("phone"))
+		if giver == phone {
+			return map[string]interface{}{
+				"status": -3, // 送自己
+			}, nil
+		}
+		user, _ := util.MQFW.FindById("user", userid, bson.M{"i_vip_status": 1, "l_vip_endtime": 1, "l_vip_starttime": 1, "o_vipjy": 1})
+		if len(*user) > 0 {
+			status, areacount := 0, 0
+			if vip := gconv.Map((*user)["o_vipjy"]); vip != nil && vip["o_buyset"] != nil {
+				areacount = gconv.Int(gconv.Map(vip["o_buyset"])["areacount"])
+			}
+			query1 := bson.M{"$or": []interface{}{
+				bson.M{"s_phone": phone},
+				bson.M{"s_m_phone": phone},
+			}}
+			buser, _ := util.MQFW.FindOneByField("user", query1, bson.M{"i_vip_status": 1, "o_vipjy": 1, "o_jy": 1})
+			if len(*buser) > 0 {
+				if qutil.IntAll((*buser)["i_vip_status"]) > 0 {
+					b_areacount := 0
+					if vip := gconv.Map((*buser)["o_vipjy"]); vip != nil && vip["o_buyset"] != nil {
+						b_areacount = gconv.Int(gconv.Map(vip["o_buyset"])["areacount"])
+					}
+					if areacount == b_areacount {
+						status = 1
+					} else {
+						status = -2 // 订阅地区不一致
+					}
+				} else {
+					if ojy := gconv.Map((*buser)["o_jy"]); ojy != nil && ojy["i_ppstatus"] != nil {
+						if state := gconv.Int(ojy["i_ppstatus"]); state == 1 {
+							return map[string]interface{}{
+								"status": -4, // 省份订阅包用户
+							}, nil
+						}
+					} else {
+						status = 1
+					}
+				}
+			} else {
+				status = -1 // 账号未注册
+			}
+			return map[string]interface{}{
+				"status": status,
+			}, nil
+		}
+		return nil, fmt.Errorf("未查询到身份信息")
+	}()
+	t.ServeJson(NewResult(rData, errMsg))
+}
+
+func (t *VipGift) TransferSubDuration() {
+	userid := qutil.ObjToString(t.GetSession("mgoUserId"))
+	rData, errMsg := func() (interface{}, error) {
+		now := time.Now().Unix()
+		if now < config.Config.VipGiftStartTime && now > config.Config.VipGiftEndTime {
+			return nil, fmt.Errorf("不在活动时间范围内")
+		}
+		user, _ := util.MQFW.FindById("user", userid, bson.M{"i_vip_status": 1, "l_vip_endtime": 1, "l_vip_starttime": 1, "o_vipjy": 1})
+		if len(*user) > 0 {
+			// 1-1 验证个人身份 超级订阅时长
+			if qutil.IntAll((*user)["i_vip_status"]) > 0 {
+				//startTime := qutil.Int64All((*user)["l_vip_starttime"])
+				endTime := qutil.Int64All((*user)["l_vip_endtime"])
+				dif, sameDay := difMouth(time.Now().Unix(), endTime)
+				b_phones := gconv.Map(t.GetString("phones"))
+				num := 0
+				for k, v := range b_phones {
+					log.Println("TransferSubDuration---", "phone: ", k, " gift: ", v)
+					if !jy.PhoneReg.MatchString(k) {
+						return nil, fmt.Errorf("手机号格式异常")
+					}
+					num += gconv.Int(v)
+				}
+				if num == 0 {
+					return nil, fmt.Errorf("赠送时长异常")
+				}
+				if dif >= num {
+					err := transferByPhone(t, *user, b_phones, t.GetString("platform"), dif, sameDay)
+					if err != nil {
+						return nil, err
+					}
+					return nil, nil
+				}
+				return nil, fmt.Errorf("赠送时长大于当前用户可赠时长")
+			}
+			return nil, fmt.Errorf("当前赠送人没有超级订阅权限")
+		}
+		return nil, fmt.Errorf("未查询到身份信息")
+	}()
+	t.ServeJson(NewResult(rData, errMsg))
+}
+
+func difMouth(i1, i2 int64) (int, bool) {
+	st := time.Unix(i1, 0)
+	et := time.Unix(i2, 0)
+	y1, m1, d1 := st.Date()
+	y2, m2, d2 := et.Date()
+	difM := (y2-y1)*12 + int(m2-m1)
+	// 额外判断天数是否需要调整
+	if d1 == 31 && (d2 == 30 || d2 == 28) {
+		//
+	} else if d1 > d2 {
+		difM--
+	}
+	return difM, d1 == d2
+}
+
+// 1-2 验证手机号 未注册去注册
+// 2-1 赠送并验证 赠予时长
+func transferByPhone(t *VipGift, user, phones map[string]interface{}, platform string, dif int, sameDay bool) error {
+	userId := qutil.ObjToString(t.GetSession("mgoUserId"))
+	areacount := 0
+	if vip := gconv.Map(user["o_vipjy"]); vip != nil && vip["o_buyset"] != nil {
+		areacount = gconv.Int(gconv.Map(vip["o_buyset"])["areacount"])
+	}
+	i_vip_status := qutil.IntAll(user["i_vip_status"])
+	updateInfo := make(map[string]*Received)
+	num := 0 // 扣除
+	for k, v := range phones {
+		giver := qutil.ObjToString(t.GetSession("phone"))
+		if giver == k {
+			return fmt.Errorf("赠送人手机号与被赠送人手机号一致")
+		}
+		query1 := bson.M{"$or": []interface{}{
+			bson.M{"s_phone": k},
+			bson.M{"s_m_phone": k},
+		}}
+		buser, _ := util.MQFW.FindOneByField("user", query1, bson.M{"i_vip_status": 1, "o_vipjy": 1, "l_vip_endtime": 1, "l_vip_starttime": 1, "o_jy": 1})
+		var mgoUserId string
+		if len(*buser) == 0 {
+			// 新用户注册
+			mgoUserId, _ = regNewPhone(k, platform)
+		} else {
+			mgoUserId = mongodb.BsonIdToSId((*buser)["_id"])
+		}
+		received := &Received{
+			Uid:    userId,
+			Phone:  gconv.String(t.GetSession("phone")),
+			BPhone: k,
+		}
+		if qutil.IntAll((*buser)["i_vip_status"]) > 0 {
+			received.Itype = 1
+			b_areacount := 0
+			if vip := gconv.Map((*buser)["o_vipjy"]); vip != nil && vip["o_buyset"] != nil {
+				b_areacount = gconv.Int(gconv.Map(vip["o_buyset"])["areacount"])
+			}
+			if areacount == b_areacount {
+				num += gconv.Int(v)
+				dif -= gconv.Int(v)
+				if dif >= 0 {
+					updateVipInfo(*buser, gconv.Int(v), areacount, received)
+				} else {
+					return fmt.Errorf("赠予时长异常,赠送失败")
+				}
+			} else {
+				return fmt.Errorf("该手机号:%s超级订阅地区与赠送人不一致", k)
+			}
+		} else {
+			if len(*buser) > 0 {
+				if ojy := gconv.Map((*buser)["o_jy"]); ojy != nil && ojy["i_ppstatus"] != nil {
+					if status := gconv.Int(ojy["i_ppstatus"]); status == 1 {
+						return fmt.Errorf("省份订阅包用户不能被赠送")
+					}
+				}
+			}
+			received.Itype = 0
+			// 新用户和非超级订阅用户直接赠送
+			num += gconv.Int(v)
+			dif -= gconv.Int(v)
+			if dif >= 0 {
+				updateVipInfo(nil, gconv.Int(v), areacount, received)
+			} else {
+				return fmt.Errorf("赠予时长异常,赠送失败")
+			}
+		}
+		updateInfo[mgoUserId] = received
+	}
+	if len(updateInfo) == 0 && len(updateInfo) != len(phones) {
+		return fmt.Errorf("未知异常")
+	}
+	// 赠送人时长修改  赠送人vip结束时间-赠送月份 对比 当前时间
+	endTime := qutil.Int64All(user["l_vip_endtime"])
+	t1 := time.Unix(endTime, 0).Local()
+	newTime := t1.AddDate(0, -num, 0)
+
+	if (sameDay && dif == 0) || (newTime.Unix() <= time.Now().Unix()) {
+		if !util.Compatible.Update(userId, bson.M{"$set": map[string]interface{}{
+			"i_vip_status":     -i_vip_status,
+			"i_vip_expire_tip": 2,
+			"i_vip_subtips":    0,
+			"i_vip_fastimport": 0,
+			"l_vip_endtime":    newTime.Unix(),
+		},
+			"$unset": map[string]interface{}{
+				"i_vip_expire_tip_retry": "",
+			}}) {
+			return fmt.Errorf("更新异常:%s", userId)
+		}
+	} else {
+		if !util.Compatible.Update(userId, bson.M{"$set": map[string]interface{}{
+			"l_vip_endtime": newTime.Unix(),
+		}}) {
+			return fmt.Errorf("更新异常:%s", userId)
+		}
+	}
+	//else {
+	//    log.Println("sameDay: ", sameDay)
+	//    log.Println("dif: ", dif)
+	//    log.Println("newTime.Unix(): ", newTime.Unix())
+	//    return fmt.Errorf("赠予时长异常,赠送失败, %d", newTime.Unix())
+	//}
+	clearCache(userId) // 赠送人
+	for uid, info := range updateInfo {
+		info1 := gconv.Map(info.UpdateInfo)
+		// 被赠 更新
+		if util.Compatible.Update(uid, bson.M{"$set": info.UpdateInfo}) {
+			if info1["l_vip_starttime"] != nil {
+				// 新开
+				util.MergeKws(uid, 0, 0, 0)                //初始化vip订阅关键词
+				redis.Del("other", "p1_indexMessage_"+uid) //清除redis中vip状态
+			}
+			clearCache(uid)
+			record := map[string]interface{}{
+				"giftUserId":         mongodb.BsonIdToSId(user["_id"]),
+				"giftUserPhone":      info.Phone,
+				"createTime":         date.NowFormat(date.Date_Full_Layout),
+				"recipientUserId":    uid,
+				"recipientUserPhone": info.BPhone,
+				"duration":           info.Duration,
+				"vipStartTime":       info.StartTime,
+				"vipEndTime":         info.EndTime,
+				"areaCount":          areacount,
+				"itype":              info.Itype,
+			}
+			util.Mysql.Insert("vip_gift_records", record)
+		} else {
+			return fmt.Errorf("更新异常:%s, err: %s", uid, info1)
+		}
+	}
+	return nil
+}
+
+func regNewPhone(phone, platform string) (userid string, err error) {
+	userAddReq := pb.UserAddReq{
+		Appid: "10000",
+		Phone: phone,
+	}
+	now := time.Now()
+	mgoData := map[string]interface{}{
+		"i_appid":       2,
+		"s_phone":       phone,
+		"s_password":    "",
+		"l_registedate": now.Unix(),
+		"i_ts_guide":    2,
+		"o_jy": map[string]interface{}{
+			"i_apppush":    1,
+			"i_ratemode":   2,
+			"l_modifydate": now.Unix(),
+		},
+		"s_regsource": "vipgift",
+		"s_platform":  platform,
+	}
+	if resp := config.Middleground.UserCenter.UserAdd(userAddReq); resp != nil {
+		if resp.Data.Id > 0 {
+			mgoData["base_user_id"] = resp.Data.Id
+			uid := util.MQFW.Save("user", mgoData)
+			if uid != "" {
+				util.Mgo_log.Save("register_log", map[string]interface{}{
+					"userid":      uid,
+					"phone":       phone,
+					"way":         "phone",
+					"source":      "vipgift",
+					"create_time": gtime.Timestamp(),
+				})
+				return uid, nil
+			} else {
+				return "", fmt.Errorf("用户user表新增失败")
+			}
+		}
+	}
+	return "", fmt.Errorf("新手机号注册失败:%s", phone)
+}
+
+func updateVipInfo(buser map[string]interface{}, gift, areacount int, received *Received) {
+	updateMap := make(map[string]interface{})
+	if buser != nil {
+		// 被赠 续费
+		etTime := qutil.Int64All(buser["l_vip_endtime"])
+		endTime := util.GetDATE(0, gift, etTime)
+		updateMap["l_vip_endtime"] = endTime.Unix()
+		updateMap["i_vip_status"] = 2
+		updateMap["i_vip_expire_tip"] = 0
+		updateMap["o_vipjy.l_modifydate"] = time.Now().Unix()
+
+		received.Duration = gift
+		received.StartTime = date.FormatDateByInt64(&etTime, date.Date_Full_Layout)
+		received.EndTime = endTime.Format(date.Date_Full_Layout)
+	} else {
+		// 被赠 新开
+		startTime := time.Now().Unix()
+		endTime := util.GetDATE(0, gift, startTime)
+		updateMap["l_vip_starttime"] = startTime
+		updateMap["l_vip_endtime"] = endTime.Unix()
+		updateMap["i_vip_status"] = 2
+		updateMap["i_vip_expire_tip"] = 0
+		updateMap["o_vipjy.o_buyset"] = &map[string]interface{}{"buyerclasscount": -1, "areacount": areacount, "upgrade": 1, "newcitys": []string{}}
+		updateMap["o_vipjy.o_area"] = &map[string]interface{}{"北京": []string{}}
+		updateMap["o_vipjy.i_trial"] = -1
+
+		received.Duration = gift
+		received.StartTime = date.FormatDateByInt64(&startTime, date.Date_Full_Layout)
+		received.EndTime = endTime.Format(date.Date_Full_Layout)
+	}
+	received.UpdateInfo = updateMap
+}
+
+func clearCache(userId string) {
+	positionId := util.MongoIdToPositionId(userId)
+	jy.ClearBigVipUserPower(positionId)
+	config.Middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
+		PositionId: positionId,
+		AppId:      "10000",
+	})
+	config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
+}

+ 20 - 6
src/jfw/modules/subscribepay/src/service/userAccountInfo.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	jycaptcha "app.yhyue.com/moapp/jybase/captcha"
 	"bytes"
 	"context"
 	"database/sql"
@@ -20,7 +21,6 @@ import (
 	"github.com/gogf/gf/v2/util/gconv"
 
 	. "app.yhyue.com/moapp/jybase/api"
-	jycaptcha "app.yhyue.com/moapp/jybase/captcha"
 	qutil "app.yhyue.com/moapp/jybase/common"
 	. "app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/dchest/captcha"
@@ -261,11 +261,20 @@ func getAccountVipAttr(session *httpsession.Session, powerRes *pcc.CheckResp) (r
 			}
 		}
 
-		rData = append(rData, &VipDetail{Name: "超级订阅", EndTime: powerRes.Vip.GetEndTime(), Attr: g.Map{
-			"renew":   powerRes.Vip.Upgrade == 1 && buyed, //是否有购买订单
-			"upgrade": (powerRes.Vip.Upgrade == 0 || powerRes.Vip.Areacount != -1) && buyed,
-			"buyMsg":  buyMsg,
-		}})
+		if gconv.Int64(session.Get("positionType")) == 0 {
+			rData = append(rData, &VipDetail{Name: "超级订阅", EndTime: powerRes.Vip.GetEndTime(), Attr: g.Map{
+				"renew":   powerRes.Vip.Upgrade == 1,
+				"upgrade": powerRes.Vip.Upgrade == 0 || powerRes.Vip.Areacount != -1,
+				"buyMsg":  buyMsg,
+			}})
+		} else {
+			rData = append(rData, &VipDetail{Name: "超级订阅", EndTime: powerRes.Vip.GetEndTime(), Attr: g.Map{
+				"renew":   qutil.If(gconv.Int64(session.Get("positionType")) == 0, true, powerRes.Vip.Upgrade == 1 && buyed),
+				"upgrade": (powerRes.Vip.Upgrade == 0 || powerRes.Vip.Areacount != -1) && buyed,
+				"buyMsg":  buyMsg,
+			}})
+		}
+
 	}
 	if powerRes.Free.PpStatus > 0 && len(rData) == 0 {
 		rData = append(rData, &VipDetail{Name: "省份订阅包", EndTime: powerRes.Free.GetPpEndTime(), Attr: g.Map{
@@ -587,6 +596,7 @@ func (this *UserAccount) Authentication(doType string) {
 //       A账户已绑定微信,此微信必须与当前账户绑定的微信一致
 
 func (this *UserAccount) PhoneBind() {
+	log.Println("绑定手机号开始1")
 	sessVal := this.Session().GetMultiple()
 	userId, _ := sessVal["mgoUserId"].(string)
 	step, _ := this.GetInteger("step")
@@ -642,6 +652,7 @@ func (this *UserAccount) PhoneBind() {
 				return "", fmt.Errorf("获取账户信息异常")
 			}
 			exists, relationPhoneId, _ := jy.NewPhoneUtil(util.MQFW).BindPhoneIsOccupy(userId, unionid, phoneVerify)
+			log.Println("绑定手机号开始2", exists, relationPhoneId)
 			if exists { //再次校验是否使用
 				return nil, fmt.Errorf("手机号已被绑定")
 			}
@@ -722,6 +733,7 @@ func (this *UserAccount) PhoneBind() {
 					if jy.IsEmail(email) {
 						data["s_email"] = email
 					}
+					log.Println("绑定手机号开始3", relationPhoneId, data)
 					if util.Compatible.Update(relationPhoneId, map[string]interface{}{
 						"$set": data,
 					}) {
@@ -750,6 +762,8 @@ func (this *UserAccount) PhoneBind() {
 								}
 								backData[k] = v
 							}
+							log.Println("绑定手机号开始4", backData)
+
 							if util.MQFW.Save("user_merge", backData) != "" {
 								util.MQFW.Del("user", map[string]interface{}{"_id": mongodb.StringTOBsonId(userId)})
 								jy.CreateUserMerge(util.MQFW, util.Mysql, this.Session(), config.Middleground).FlushSession(relationPhoneId)

+ 138 - 0
src/jfw/modules/subscribepay/src/service/vipGift.go

@@ -0,0 +1,138 @@
+package service
+
+import (
+	. "app.yhyue.com/moapp/jybase/api"
+	qutil "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
+	"jy/src/jfw/modules/subscribepay/src/config"
+	"jy/src/jfw/modules/subscribepay/src/util"
+	"sort"
+	"time"
+)
+
+type VipGift struct {
+	*xweb.Action
+
+	getSubDuration      xweb.Mapper `xweb:"/vip/gift/getSubDuration"`      // 获取vip订阅时长
+	getInfoByPhone      xweb.Mapper `xweb:"/vip/gift/getInfoByPhone"`      // 根据手机号获取提示信息
+	transferSubDuration xweb.Mapper `xweb:"/vip/gift/transferSubDuration"` // 赠送订阅时长
+
+	list          xweb.Mapper `xweb:"/vip/gift/list"`          //赠送记录查询
+	configuration xweb.Mapper `xweb:"/vip/gift/configuration"` //赠送记录配置
+	informInfo    xweb.Mapper `xweb:"/vip/gift/informInfo"`    //告知页面数据
+}
+
+// 赠送记录查询
+func (t *VipGift) List() {
+	rData := map[string]interface{}{}
+	userId := qutil.ObjToString(t.GetSession("userId"))
+	giftType, _ := t.GetInt("giftType")
+	list := &[]map[string]interface{}{}
+	if giftType == 1 {
+		//赠送记录
+		list = util.Mysql.SelectBySql("select   * from   vip_gift_records  where   giftUserId=?   ORDER BY     createTime  desc   ", userId)
+	} else if giftType == 2 {
+		//接收记录
+		list = util.Mysql.SelectBySql("select   * from   vip_gift_records  where   recipientUserId=?   ORDER BY    createTime  desc   ", userId)
+	} else {
+		t.ServeJson(NewResult(rData, nil))
+	}
+	for i := range *list {
+		giftId := encrypt.SE.Encode2HexByCheck(gconv.String((*list)[i]["id"]))
+		(*list)[i]["id"] = giftId
+		(*list)[i]["urlLink"] = fmt.Sprintf("%s/vipGiftUrl/%s", config.Config.WebDomain, giftId)
+		(*list)[i]["qRCodeLink"] = fmt.Sprintf("%s/qr?url=/vipGiftUrl/%s", config.Config.WebDomain, giftId)
+		if giftType == 1 {
+			giftUserPhone := gconv.String((*list)[i]["giftUserPhone"])
+			(*list)[i]["giftUserPhone"] = string(giftUserPhone[0:3]) + "****" + string(giftUserPhone[len(giftUserPhone)-4:])
+		} else if giftType == 2 {
+			recipientUserPhone := gconv.String((*list)[i]["recipientUserPhone"])
+			(*list)[i]["recipientUserPhone"] = string(recipientUserPhone[0:3]) + "****" + string(recipientUserPhone[len(recipientUserPhone)-4:])
+		}
+	}
+	if len(*list) > 0 {
+		rData["list"] = groupAndSortByCreateTime(*list)
+	} else {
+		rData["list"] = []map[string]interface{}{}
+	}
+	t.ServeJson(NewResult(rData, nil))
+}
+func groupAndSortByCreateTime(list []map[string]interface{}) [][]map[string]interface{} {
+	// 1. 按日期分组
+	groups := make(map[string][]map[string]interface{})
+	for _, item := range list {
+		createTime, ok := item["createTime"].(string)
+		if !ok {
+			continue // 忽略无效的 createTime
+		}
+		groups[createTime] = append(groups[createTime], item)
+	}
+
+	// 2. 提取分组键并排序
+	var keys []string
+	for k := range groups {
+		keys = append(keys, k)
+	}
+	sort.Sort(sort.Reverse(sort.StringSlice(keys))) // 按日期降序排列
+	// 3. 对每个组内按时间排序(降序)
+	var result [][]map[string]interface{}
+	for _, key := range keys {
+		group := groups[key]
+		sort.Slice(group, func(i, j int) bool {
+			layout := "2006-01-02 15:04:05"
+			iCreateTime, err1 := time.Parse(layout, group[i]["createTime"].(string))
+			jCreateTime, err2 := time.Parse(layout, group[j]["createTime"].(string))
+			if err1 != nil || err2 != nil {
+				return false // 忽略解析错误,保持原顺序
+			}
+			return iCreateTime.After(jCreateTime) // 降序排序
+		})
+		result = append(result, group)
+	}
+
+	return result
+}
+
+// 赠送记录配置
+func (t *VipGift) Configuration() {
+	rData := map[string]interface{}{
+		"startTime": config.Config.VipGiftStartTime,
+		"endTime":   config.Config.VipGiftEndTime,
+	}
+	t.ServeJson(NewResult(rData, nil))
+}
+
+// 告知页面数据
+func (t *VipGift) InformInfo() {
+	giftId := t.GetString("giftId")
+	chatIdInt := gconv.Int64(encrypt.SE.Decode4HexByCheck(giftId))
+	data := util.Mysql.FindOne("vip_gift_records", map[string]interface{}{
+		"id": chatIdInt,
+	}, "giftUserPhone,createTime,recipientUserPhone,recipientUserId,duration,nickname,vipStartTime,vipEndTime,areacount,itype", "")
+	if data != nil && len(*data) > 0 {
+		giftUserPhone := gconv.String((*data)["giftUserPhone"])
+		(*data)["giftUserPhone"] = string(giftUserPhone[0:3]) + "****" + string(giftUserPhone[len(giftUserPhone)-4:])
+		(*data)["urlLink"] = fmt.Sprintf("%s/vipGiftUrl/%s", config.Config.WebDomain, giftId)
+		(*data)["qRCodeLink"] = fmt.Sprintf("%s/qr?url=/vipGiftUrl/%s", config.Config.WebDomain, giftId)
+		isBinding := false
+		isSame := false
+		//判断是否绑定手机号
+		phone := qutil.InterfaceToStr(t.GetSession("phone"))
+		if phone == "" {
+			//没有绑定手机号
+		} else {
+			isBinding = true
+			userId := qutil.ObjToString(t.GetSession("userId"))
+			recipientUserId := gconv.String((*data)["recipientUserId"])
+			if recipientUserId == userId {
+				isSame = true
+			}
+		}
+		(*data)["isBinding"] = isBinding
+		(*data)["isSame"] = isSame
+	}
+	t.ServeJson(NewResult(data, nil))
+}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
src/web/staticres/common-module/gift-friends-js/jy-gift-friends.mjs


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
src/web/staticres/common-module/gift-friends-js/jy-gift-friends.mjs.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
src/web/staticres/common-module/gift-friends-js/jy-gift-friends.umd.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
src/web/staticres/common-module/gift-friends-js/jy-gift-friends.umd.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 2 - 1
src/web/staticres/vipsubscribe/css/vip_pay_success.css


+ 88 - 1
src/web/templates/order/pc/paySuccess.html

@@ -20,6 +20,7 @@
     <link href="{{Msg "seo" "cdn"}}/css/pc.css?v={{Msg "seo" "version"}}" rel="stylesheet">
     <link rel="stylesheet" type="text/css"
           href="{{Msg "seo" "cdn"}}/pccss/public-nav-1200.css?v={{Msg "seo" "version"}}"/>
+          <link href="//cdn-common.jianyu360.com/cdn/lib/element-ui/2.15.13-rc/lib/theme-chalk/index.css" rel="stylesheet" />
     <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/public-nav.js?v={{Msg "seo" "version"}}23"></script>
   <style>
     .active-tip-group {
@@ -45,6 +46,19 @@
       /* display: block; */
       /* border-radius: 6px; */
     }
+    .gift_friends_btn {
+      margin-top: 16px;
+      text-align: center;
+    }
+    .gift_friends_btn button {
+      padding: 5px 36px;
+      background: #fff;
+      border: 1px solid #2ABED1;
+      border-radius: 16px;
+      color: #2ABED1;
+      font-size: 14px;
+      line-height: 22px;
+    }
   </style>
 </head>
 <body>
@@ -104,6 +118,11 @@
             {{else if eq .T.orderType "dataexport"}}
                 <p class="c_t_tips"> 我们会尽快将历史数据发送至{{.T.email}}邮箱,请稍后查阅。</p>
             {{end}}
+            {{if and (eq .T.orderType "subvip") (eq .T.positionType "0") (ne .T.vipType 1) (ne .T.vipType 2)}}
+              <div class="gift_friends_btn" v-if="isShowGift">
+                <button @click="openGiftFriendsDialog">将超级订阅赠送给好友</button>
+              </div>
+            {{end}}
         </div>
         <div class="c_bottom">
             <p class="order_item">
@@ -185,10 +204,15 @@
 {{include "/common/pcbottom.html"}}
 
 <script src='{{Msg "seo" "cdn"}}/common-module/public/js/utils.js?v={{Msg "seo" "version"}}'></script>
+<script src=//cdn-common.jianyu360.com/cdn/lib/vue/2.6.11/vue.min.js></script>
+<script src="//cdn-common.jianyu360.com/cdn/lib/element-ui/2.15.13-rc/lib/index.js"></script>
 <!-- 广告位加载 公共js方法 -->
 <script src="{{Msg "seo" "cdn"}}/common-module/message-tip/js/index.js?v={{Msg "seo" "version"}}"></script>
-
+<script src="{{Msg "seo" "cdn"}}/common-module/gift-friends-js/jy-gift-friends.umd.js?v={{Msg "seo" "version"}}"></script>
+<!-- <script src="{{Msg "seo" "cdn"}}/common-module/gift-friends-js/jy-gift-friends.mjs?v={{Msg "seo" "version"}}"></script> -->
 <script type="text/javascript">
+
+
     var myPageNavIsNormal = true;
     var orderType = {{.T.orderType}}
     console.dir(4444444)
@@ -241,6 +265,10 @@
 
     }
 
+    $('.gift_friends_btn>button').click(function () {
+      console.info(window.$GiftFriendsDialog, 'window.$GiftFriendsDialog')
+    })
+
 
     function getFilePackInfo () {
         $.ajax({
@@ -337,6 +365,7 @@
         })
         }
     });
+    
     // 格式化金钱的函数
     // s: 金额(number) 必传
     // n: 保留小数的位数(int:0-100)
@@ -430,6 +459,64 @@
       }
     }
 </script>
+<script>
+
+  // 引入GiftFriends送给朋友超级订阅插件
+  try {
+    Vue.use(GiftFriends.install);
+    Vue.use(GiftFriends.registryToast)
+  } catch (error) {
+    console.error(error)
+  }
+   var GiftFriendsDialogVm = new Vue({
+        delimiters: ['${', '}'],
+        el: '.pay_success',
+        data () {
+          return {
+            isShowGift: false,
+          }
+        },
+        created() {
+          this.fetchConfigTime()
+        },
+
+        methods: {
+          openGiftFriendsDialog() {
+            this.$GiftFriendsDialog({
+              props: {
+                visible: true
+              }
+            })
+          },
+          async fetchConfigTime() {
+            try {
+              const res = await  $.ajax({
+                url: '/subscribepay/vip/gift/configuration',
+                type: 'post'
+              })
+              console.info(res, 'res')
+              const { error_code: code, data } = res
+              if (code === 0) {
+                // 获取当前时间戳
+                const currentTime = Math.floor(Date.now() / 1000)
+                // 判断是否过期
+                const { startTime, endTime } = data
+                if (startTime < currentTime && currentTime < endTime) {
+                  this.isShowGift = true
+                }
+                else {
+                  this.isShowGift = false
+                }
+              }
+            } catch (error) {
+              
+            }
+           
+          },
+        }
+   })
+
+</script>
 
 {{include "/common/baiducc.html"}}
 </body>

+ 37 - 0
src/web/templates/weixin/vipsubscribe/vip_pay_success.html

@@ -30,6 +30,18 @@
     .mr0 {
       margin-right: 0!important;
     }
+    .giving-tip{
+      width: 4.22rem;
+      padding: .12rem 0;
+      margin: .36rem auto 0;
+      border: 1px solid#2ABED1;
+      border-radius: .32rem;
+      text-align: center;
+      font-size: .28rem;
+      line-height: .4rem;
+      background: #fff;
+      color: #2ABED1;
+    }
   </style>
 </head>
 <body>
@@ -42,6 +54,7 @@
                 &yen;
                 <em></em>
             </p>
+            <div class="giving-tip" style="display: none;" onclick="location.href='/jy_mobile/giving/friend'">将超级订阅赠送给好友</div>
         </div>
         <div class="info_box">
             <div class="pay_mode">
@@ -82,6 +95,8 @@
 <script>
   var title = {{.T.title}}
   var orderCode = {{.T.orderCode}}
+  var positionType = {{.T.positionType}}
+  var vipType = {{.T.vipType}}
 //   if (title.indexOf('超级订阅') !== -1) {
 //     // getActiveInfo()
 //   }
@@ -207,7 +222,29 @@
             var money = t.split('').reverse().join('') + point + right;
             return money;
         }
+        getVipGiftConfig()
+    })
+    function getVipGiftConfig() {
+    $.ajax({
+      url: '/subscribepay/vip/gift/configuration',
+      type: 'POST',
+      success: function(res) {
+          if(res && res.data) {
+            var startTime = res.data.startTime
+            var endTime = res.data.endTime
+            var isValidPeriod = startTime && endTime && parseInt(startTime) < parseInt(endTime)
+            var nowTime = Math.floor(Date.now() / 1000)
+            var isNewBuy = vipType != 1 && vipType != 2
+            var vipGiftPeriod = isValidPeriod && nowTime >= parseInt(startTime) && nowTime <= parseInt(endTime) && positionType === '0' && isNewBuy
+            if (vipGiftPeriod) {
+              $('.giving-tip').show()
+            } else {
+              $('.giving-tip').hide()
+            }
+          }
+      }
     })
+  }
 </script>
 {{include "/common/baiducc.html"}}
 </html>

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels