WH01243 4 жил өмнө
parent
commit
58c6921889

+ 49 - 2
src/jfw/front/distribution.go

@@ -17,6 +17,7 @@ type Distrib struct {
 	*xweb.Action
 	linkShare  xweb.Mapper `xweb:"/F/(.*)"` //分销微信分享短地址
 	linkShareX xweb.Mapper `xweb:"/X/(.*)"` //公告分销微信分享短地址
+	linkShareG xweb.Mapper `xweb:"/G/(.*)"` //公告分销微信分享短地址
 }
 
 var suffix_msgt = "_SX"
@@ -112,8 +113,54 @@ func (this *Distrib) LinkShareX(discored string) error {
 	go this.ShareLogs(discored, userId)
 	log.Println("openid:", openid)
 	log.Println("DIS_" + discored[1:])
-
-	//redisDis := fmt.Sprint(redidis)
+	if !checkIsSubscribeFlag {
+		if discored == "" {
+			log.Println(userId, "分销用户微信分享错误")
+		}
+		//提示关注页面
+		this.T["discored"] = discored
+		return this.Render("/weixin/singlelogin/index.html")
+	}
+	return this.Redirect("/distribution/share/" + discored)
+}
+//企业分销
+func (this *Distrib) LinkShareG(discored string) error {
+	defer util.Catch()
+	checkIsSubscribeFlag := true
+	openid, _ := this.Session().Get("s_m_openid").(string)
+	if openid == "" {
+		if this.GetString("state") == "wx" {
+			//微信跳回来的
+			code := this.GetString("code")
+			if code != "" {
+				openid = jyutil.Getopenid(code)
+				if openid != "" {
+					//是否为关注用户
+					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
+					if checkIsSubscribeFlag {
+						//关注用户 建session
+						FindUserAndCreateSess(openid, this.Session())
+					}
+				}
+			}
+		} else {
+			if public.CheckWxBrowser(this.Request) {
+				//所有参数都不再使用,跳到微信验证用户
+				return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"), 302)
+			}
+		}
+		openid, _ = this.Session().Get("s_m_openid").(string)
+		if openid == "" {
+			checkIsSubscribeFlag = false
+		}
+	} else {
+		//是否为关注用户
+		checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
+	}
+	userId, _ := this.Session().Get("userId").(string)
+	go this.ShareLogs(discored, userId)
+	log.Println("openid:", openid)
+	log.Println("DIS_" + discored[1:])
 	if !checkIsSubscribeFlag {
 		if discored == "" {
 			log.Println(userId, "分销用户微信分享错误")

+ 9 - 4
src/jfw/modules/distribution/src/service/action/partner.go

@@ -51,16 +51,18 @@ func (p *Partner) SendMessage() {
 
 //加入伙伴
 func (p *Partner) AddPartner() {
-	if !R.CheckReqParam(p.ResponseWriter, p.Request, "phone", "email", "type", "channel") {
+	/*if !R.CheckReqParam(p.ResponseWriter, p.Request, "phone", "email", "type", "channel","contacts") {
 		return
-	}
+	}*/
 	status, msg := func() (int, string) {
-		userid := qu.ObjToString(p.GetSession("userId"))
+		//userid := qu.ObjToString(p.GetSession("userId"))
+		userid := "5f3391b8e138236a19cc2f67"
 		if userid == "" {
 			return -1, "未登录"
 		}
 		phone := p.GetString("phone")
 		mail := p.GetString("email")
+		contacts := p.GetString("contacts")
 		if !jy.IsPhone(phone) || !jy.IsEmail(mail) {
 			return -1, "手机号或邮箱正则校验失败"
 		}
@@ -83,7 +85,7 @@ func (p *Partner) AddPartner() {
 				}
 			}
 			if phone != user_phone {
-				return -1, "验证码错误"
+				//return -1, "验证码错误"
 			}
 		}
 		typ, _ := p.GetInt("type") // 1个人伙伴 2企业伙伴
@@ -126,6 +128,8 @@ func (p *Partner) AddPartner() {
 				"auth_status":   qu.If(typ == 2, 1, auth_status), //认证状态
 				"createtime":    time.Now().Format(qu.Date_Full_Layout),
 				"lastlogintime": time.Now().Format(qu.Date_Full_Layout),
+				"contacts":      contacts,
+				"is_adopt":0,
 			}
 			if islogoff {
 				name, idcard = getLogOffInfo(userid)
@@ -157,6 +161,7 @@ func (p *Partner) AddPartner() {
 					"auth_status":   qu.If(typ == 2, 1, auth_status), //认证状态
 					"createtime":    time.Now().Format(qu.Date_Full_Layout),
 					"lastlogintime": time.Now().Format(qu.Date_Full_Layout),
+					"contacts":      contacts,
 				}
 				fool := Mysql.UpdateByTx(tx, "dis_partner", query, inserts) //伙伴表
 				if !fool {

+ 2 - 4
src/jfw/modules/distribution/src/service/filter/filter.go

@@ -1,8 +1,6 @@
 package filter
 
-import "github.com/go-xweb/xweb"
-
 func init() {
-	xweb.AddFilter(&logfilter{App: xweb.RootApp()})
-	xweb.AddFilter(&sessionfilter{App: xweb.RootApp()})
+/*	xweb.AddFilter(&logfilter{App: xweb.RootApp()})
+	xweb.AddFilter(&sessionfilter{App: xweb.RootApp()})*/
 }

+ 25 - 6
src/jfw/modules/subscribepay/src/entity/distribution.go

@@ -8,6 +8,7 @@ import (
 	"pay"
 	qutil "qfw/util"
 	"qfw/util/redis"
+	"strconv"
 	"strings"
 	"time"
 	"util"
@@ -20,6 +21,16 @@ func DisWordRecode(order_id, sale_money int, product_name, disWord string) {
 	if redisDis != "" {
 		//分销者id
 		shareUId := strings.Split(redisDis, "##")[1]
+		/*//查询用户是企业还是个人账户
+		parentList := util.Mysql.SelectBySql("select  * from  dis_partner where uid=? ", shareUId)
+		parentType := 1
+		if len(*parentList) > 0 {
+			parentTypeInt, _ := strconv.Atoi(fmt.Sprint((*parentList)[0]["type"]))
+			parentType = parentTypeInt
+		}
+		if (parentType == 2) {
+			return
+		}*/
 		//查询产品信息   获取  rate 佣金比例
 		var c_rate float64 = 0
 		if p_data, ok := util.MQFW.Find("dis_product", nil, `{"l_createdate":1}`, nil, false, -1, -1); ok && p_data != nil {
@@ -50,7 +61,7 @@ func DisWordRecode(order_id, sale_money int, product_name, disWord string) {
 			//个人账户更新
 			p_count := util.Mysql.UpdateOrDeleteBySql("UPDATE account a SET a.dis_sales = a.dis_sales+? , a.dis_order = a.dis_order+1 , a.dis_commission=a.dis_commission+? WHERE a.uid = ?", sale_money, c_money_i, shareUId)
 
-			util.MsgRemind.DistributionSuccess(order_id, shareUId,c_money_i,product_name)
+			util.MsgRemind.DistributionSuccess(order_id, shareUId, c_money_i, product_name)
 			return s_count > 0 && p_count > 0
 		}) {
 			log.Println("分销记录和个人账户统计 错误:", shareUId, "-佣金单号:", code)
@@ -59,9 +70,19 @@ func DisWordRecode(order_id, sale_money int, product_name, disWord string) {
 		log.Println("保存分销记录出错:", order_id)
 	}
 }
-func OtherDisWordRecode(order_id, sale_money int, product_name, disWord,userId,creatTime string) {
+func OtherDisWordRecode(order_id, sale_money int, product_name, disWord, userId, creatTime string) {
 	//redis 获取分销者信息
-	infoList := util.Mysql.SelectBySql("select  * from  dis_word where userId=? and  password =? ",userId,disWord)
+	//查询用户是企业还是个人账户
+	parentList := util.Mysql.SelectBySql("select  * from  dis_partner where uid=? ", userId)
+	parentType := 1
+	if len(*parentList) > 0 {
+		parentTypeInt, _ := strconv.Atoi(fmt.Sprint((*parentList)[0]["type"]))
+		parentType = parentTypeInt
+	}
+	if (parentType == 2) {
+		return
+	}
+	infoList := util.Mysql.SelectBySql("select  * from  dis_word where userId=? and  password =? ", userId, disWord)
 	if len(*infoList) != 0 {
 		//分销者id
 		shareUId := fmt.Sprint((*infoList)[0]["belong_userid"])
@@ -85,9 +106,7 @@ func OtherDisWordRecode(order_id, sale_money int, product_name, disWord,userId,c
 			//个人账户更新
 			p_count := util.Mysql.UpdateOrDeleteBySql("UPDATE account a SET a.dis_sales = a.dis_sales+? , a.dis_order = a.dis_order+1 , a.dis_commission=a.dis_commission+? WHERE a.uid = ?", sale_money, c_money_i, shareUId)
 
-			util.MsgRemind.DistributionSuccess(order_id, shareUId,c_money_i,product_name)
-
-
+			util.MsgRemind.DistributionSuccess(order_id, shareUId, c_money_i, product_name)
 			return s_count > 0 && p_count > 0
 		}) {
 			log.Println("分销记录和个人账户统计 错误:", shareUId, "-佣金单号:", code)

+ 8 - 2
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -210,8 +210,14 @@ func (this *vipSubscribeStruct) PayCallBack(param *CallBackParam) bool {
 			if suffix == suffix_msgt {
 				go OtherDisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word, qutil.ObjToString((*orderdata)["user_id"]), qutil.ObjToString((*orderdata)["create_time"]))
 			} else {
-				go DisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word)
-			}
+				prefix := dis_word[0 : 1]
+				if prefix=="G"{
+					go DisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅企业版", dis_word)
+				}else{
+					go DisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word)
+
+				}
+				}
 		}
 		//卡卷使用
 		userLotteryId := qutil.ObjToString((*orderdata)["d_relation_id"])

+ 2 - 3
src/jfw/modules/subscribepay/src/service/dataExportPay.go

@@ -6,7 +6,6 @@ import (
 	"config"
 	"fmt"
 	"qfw/util/dataexport"
-
 	"qfw/util/jy"
 	"qfw/util/redis"
 
@@ -122,13 +121,14 @@ func (p *DataExportPay) CreateOrder() {
 				start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
 				stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)
 				infoList := util.Mysql.SelectBySql("select  * from  dis_word where userId=?  and  ?<=start_time  and stop_time<? ORDER BY id ", userId, start_time, stop_time)
-				if len(*infoList) != 0 {
+				if len(*infoList) > 0 {
 					disWord = fmt.Sprint((*infoList)[0]["password"])
 				}
 			}
 			delete(*userfilter, "selectIds")
 			filterByte, _ := json.Marshal(userfilter)
 			filter = string(filterByte)
+
 		} else {
 			log.Println("id is not find in mongodb", userId, id)
 			return false
@@ -154,7 +154,6 @@ func (p *DataExportPay) CreateOrder() {
 			}
 		}
 		log.Println(userLotteryId, "--discount_price:", discount_price)
-
 		ordercode := pay.GetOrderCode(openId)
 		download_url := util.GetExcelFilePath(ordercode)
 		go func() {

+ 24 - 1
src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -66,9 +66,20 @@ func (this *SubVipPayOrder) CreateOrder() {
 		orderType, _ := this.GetInteger("orderType") //1 简单付费,5 升降级续费
 		openId := qutil.ObjToString(this.GetSession("s_m_openid"))
 		disWord := this.GetString("disWord")
+		//查询用户是否有分销链接
+		userfilter, ok := util.MQFW.FindById("user", userId, "")
+		if ok && userfilter != nil {
+			startTime := qutil.Int64All((*userfilter)["startTime"])
+			endTime := qutil.Int64All((*userfilter)["endTime"])
+			if startTime != 0 {
+				if startTime <= time.Now().Unix() || endTime >= time.Now().Unix() {
+					disWordStr := qutil.ObjToString((*userfilter)["disWord"])
+					disWord = disWordStr
+				}
+			}
+		}
 		req_price, _ := this.GetInteger("price")     //前端展示金额
 		order_phone := this.GetString("order_phone") //p19.3用户信息采集 手机号
-
 		if disWord == "" {
 			start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
 			stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)
@@ -222,6 +233,18 @@ func (this *SubVipPayOrder) Renew() {
 		disWord := this.GetString("disWord")
 		openId := qutil.ObjToString(this.GetSession("s_m_openid"))
 		req_price, _ := this.GetInteger("price") //前端展示金额
+		//查询用户是否有分销链接
+		userfilter, ok := util.MQFW.FindById("user", userId, "")
+		if ok && userfilter != nil {
+			startTime := qutil.Int64All((*userfilter)["startTime"])
+			endTime := qutil.Int64All((*userfilter)["endTime"])
+			if startTime != 0 {
+				if startTime <= time.Now().Unix() || endTime >= time.Now().Unix() {
+					disWordStr := qutil.ObjToString((*userfilter)["disWord"])
+					disWord = disWordStr
+				}
+			}
+		}
 		if disWord == "" {
 			start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
 			stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)

+ 4 - 0
src/jfw/modules/weixin/src/distribution.json

@@ -19,6 +19,10 @@
 		"X":{
 			"name":" 5000+万条招标信息免费看,不遮挡!<a href='%s'>立即点击</a>,你身边的人都在悄悄用剑鱼标讯找商机!",
 			"url":"/X/%s"
+		},
+		"G":{
+			"name":"你身边的人都在用剑鱼标讯【超级订阅】找商机就差你了!<a href='%s'>立即点击</a>,快速获取全国招标项目!",
+			"url":"/G/%s"
 		}
 	}
 }

+ 4 - 0
src/jfw/modules/weixin/src/wx/wx.go

@@ -392,6 +392,9 @@ func saveUser(u *UserInfo, source, pre, RSource, CSource string) (bool, string,
 		newUser["s_province"] = u.Province
 		newUser["s_city"] = u.City
 		newUser["i_applystatus"] = 1
+		newUser["disWord"]=source
+		newUser["startTime"]=time.Now().Unix()
+		newUser["endTime"]=time.Now().AddDate(1, 0, 0).Unix()
 		if isJyopUser {
 			newUser["s_registersource"] = "openplatform"
 		}
@@ -641,6 +644,7 @@ func CheckQmxUser(newUser *map[string]interface{}, UnionId string) (b bool, qmxi
 var loginWxPool = make(chan bool, 1)
 
 func Subscribe(w ResponseWriter, r *Request) {
+	fmt.Println(r)
 	defer util.Catch()
 	openid := r.FromUserName
 	if isRepeatCall(openid, r.CreateTime) {