|
@@ -1,36 +1,36 @@
|
|
package action
|
|
package action
|
|
|
|
|
|
import (
|
|
import (
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
- "database/sql"
|
|
|
|
- "encoding/base64"
|
|
|
|
- "fmt"
|
|
|
|
- . "jy/src/jfw/modules/distribution/src/service/config"
|
|
|
|
- . "jy/src/jfw/modules/distribution/src/service/public"
|
|
|
|
- "log"
|
|
|
|
- "strconv"
|
|
|
|
- "strings"
|
|
|
|
- "sync"
|
|
|
|
- "time"
|
|
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
+ "database/sql"
|
|
|
|
+ "encoding/base64"
|
|
|
|
+ "fmt"
|
|
|
|
+ . "jy/src/jfw/modules/distribution/src/service/config"
|
|
|
|
+ . "jy/src/jfw/modules/distribution/src/service/public"
|
|
|
|
+ "log"
|
|
|
|
+ "strconv"
|
|
|
|
+ "strings"
|
|
|
|
+ "sync"
|
|
|
|
+ "time"
|
|
|
|
|
|
- util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
- . "app.yhyue.com/moapp/jybase/date"
|
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
|
- "github.com/SKatiyar/qr"
|
|
|
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
+ . "app.yhyue.com/moapp/jybase/date"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
|
+ "github.com/SKatiyar/qr"
|
|
|
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
)
|
|
)
|
|
|
|
|
|
//分享接口
|
|
//分享接口
|
|
type Share struct {
|
|
type Share struct {
|
|
- *xweb.Action
|
|
|
|
- getWordShare xweb.Mapper `xweb:"/share/getWordShare"` //获取口令分享的口令
|
|
|
|
- getOtherWordShare xweb.Mapper `xweb:"/share/getOtherWordShare"` //第三方获取口令分享的口令
|
|
|
|
- getWordInfo xweb.Mapper `xweb:"/share/getWordInfo"` //根据口令获取口令信息
|
|
|
|
- linkShare xweb.Mapper `xweb:"/share/(.*)"` //链接分享获取用户信息
|
|
|
|
- productInfo xweb.Mapper `xweb:"/share/productInfo"` //产品信息
|
|
|
|
- shareLogs xweb.Mapper `xweb:"/share/shareLogs"` //分享记录日志
|
|
|
|
- shareLink xweb.Mapper `xweb:"/share/shareLink"` //分享链接获取
|
|
|
|
|
|
+ *xweb.Action
|
|
|
|
+ getWordShare xweb.Mapper `xweb:"/share/getWordShare"` //获取口令分享的口令
|
|
|
|
+ getOtherWordShare xweb.Mapper `xweb:"/share/getOtherWordShare"` //第三方获取口令分享的口令
|
|
|
|
+ getWordInfo xweb.Mapper `xweb:"/share/getWordInfo"` //根据口令获取口令信息
|
|
|
|
+ linkShare xweb.Mapper `xweb:"/share/(.*)"` //链接分享获取用户信息
|
|
|
|
+ productInfo xweb.Mapper `xweb:"/share/productInfo"` //产品信息
|
|
|
|
+ shareLogs xweb.Mapper `xweb:"/share/shareLogs"` //分享记录日志
|
|
|
|
+ shareLink xweb.Mapper `xweb:"/share/shareLink"` //分享链接获取
|
|
}
|
|
}
|
|
|
|
|
|
//1000:请求方式有误;1001:需要登录;1002:缺失参数;1003:无效参数;1004:没有权限
|
|
//1000:请求方式有误;1001:需要登录;1002:缺失参数;1003:无效参数;1004:没有权限
|
|
@@ -40,531 +40,531 @@ var suffix_msgt = "_SX"
|
|
|
|
|
|
//
|
|
//
|
|
func init() {
|
|
func init() {
|
|
- xweb.AddAction(&Share{})
|
|
|
|
|
|
+ xweb.AddAction(&Share{})
|
|
}
|
|
}
|
|
|
|
|
|
var METHOD = "POST"
|
|
var METHOD = "POST"
|
|
|
|
|
|
//所有产品信息 和 所属产品得个人分销统计
|
|
//所有产品信息 和 所属产品得个人分销统计
|
|
func (this *Share) ProductInfo() error {
|
|
func (this *Share) ProductInfo() error {
|
|
- defer util.Catch()
|
|
|
|
- res := map[string]interface{}{
|
|
|
|
- "error_code": error_code[0],
|
|
|
|
- "error_msg": error_msg[0],
|
|
|
|
- }
|
|
|
|
- if this.Method() == METHOD {
|
|
|
|
- res["error_msg"] = error_msg[1]
|
|
|
|
- res["error_code"] = error_code[1]
|
|
|
|
- userId, _ := this.Session().Get("userId").(string)
|
|
|
|
- if userId != "" {
|
|
|
|
- partner := Mysql.SelectBySql("SELECT type from dis_partner WHERE uid = ? ", userId)
|
|
|
|
- p_data, ok := MQFW.Find("dis_product", `{"s_status":1,"model":1}`, `{"l_createdate":1}`, nil, false, -1, -1)
|
|
|
|
- if (fmt.Sprint((*partner)[0]["type"])) == "2" {
|
|
|
|
- p_data, ok = MQFW.Find("dis_product", `{"s_status":1,"model":2}`, `{"l_createdate":1}`, nil, false, -1, -1)
|
|
|
|
- }
|
|
|
|
- if ok && p_data != nil {
|
|
|
|
- //个人累计数据
|
|
|
|
- dis_res := *Mysql.SelectBySql("SELECT DISTINCT a.product_name,SUM(a.sale_money) AS t_sale,SUM(a.commission) AS t_com,COUNT(a.product_name) AS t_count FROM dis_sale a WHERE a.uid = '" + userId + "' GROUP BY a.product_name")
|
|
|
|
- for key, v := range *p_data {
|
|
|
|
- delete(v, "_id")
|
|
|
|
- if v["s_name"] == "超级订阅企业版" {
|
|
|
|
- v["s_name"] = "超级订阅"
|
|
|
|
- (*p_data)[key]["s_name"] = "超级订阅"
|
|
|
|
- }
|
|
|
|
- for _, dv := range dis_res {
|
|
|
|
- if dv["product_name"] == v["s_name"].(string) {
|
|
|
|
- v["t_sale"] = util.IntAll(dv["t_sale"]) //销售金额
|
|
|
|
- v["t_com"] = util.IntAll(dv["t_com"]) //佣金金额
|
|
|
|
- v["t_count"] = util.IntAll(dv["t_count"]) //销售单数
|
|
|
|
- if util.IntAll(dv["t_count"]) > 0 {
|
|
|
|
- v["average"] = util.IntAll(dv["t_com"]) / util.IntAll(dv["t_count"]) //平均佣金
|
|
|
|
- }
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- res["data"] = *p_data
|
|
|
|
- } else {
|
|
|
|
- log.Println("查询产品信息报错")
|
|
|
|
- }
|
|
|
|
- res["error_msg"] = ""
|
|
|
|
- res["error_code"] = 0
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- this.ServeJson(res)
|
|
|
|
- return nil
|
|
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ res := map[string]interface{}{
|
|
|
|
+ "error_code": error_code[0],
|
|
|
|
+ "error_msg": error_msg[0],
|
|
|
|
+ }
|
|
|
|
+ if this.Method() == METHOD {
|
|
|
|
+ res["error_msg"] = error_msg[1]
|
|
|
|
+ res["error_code"] = error_code[1]
|
|
|
|
+ userId, _ := this.Session().Get("userId").(string)
|
|
|
|
+ if userId != "" {
|
|
|
|
+ partner := Mysql.SelectBySql("SELECT type from dis_partner WHERE uid = ? and type=2", userId)
|
|
|
|
+ p_data, ok := MQFW.Find("dis_product", `{"s_status":1,"model":1}`, `{"l_createdate":1}`, nil, false, -1, -1)
|
|
|
|
+ if (fmt.Sprint((*partner)[0]["type"])) == "2" {
|
|
|
|
+ p_data, ok = MQFW.Find("dis_product", `{"s_status":1,"model":2}`, `{"l_createdate":1}`, nil, false, -1, -1)
|
|
|
|
+ }
|
|
|
|
+ if ok && p_data != nil {
|
|
|
|
+ //个人累计数据
|
|
|
|
+ dis_res := *Mysql.SelectBySql("SELECT DISTINCT a.product_name,SUM(a.sale_money) AS t_sale,SUM(a.commission) AS t_com,COUNT(a.product_name) AS t_count FROM dis_sale a WHERE a.uid = '" + userId + "' GROUP BY a.product_name")
|
|
|
|
+ for key, v := range *p_data {
|
|
|
|
+ delete(v, "_id")
|
|
|
|
+ if v["s_name"] == "超级订阅企业版" {
|
|
|
|
+ v["s_name"] = "超级订阅"
|
|
|
|
+ (*p_data)[key]["s_name"] = "超级订阅"
|
|
|
|
+ }
|
|
|
|
+ for _, dv := range dis_res {
|
|
|
|
+ if dv["product_name"] == v["s_name"].(string) {
|
|
|
|
+ v["t_sale"] = util.IntAll(dv["t_sale"]) //销售金额
|
|
|
|
+ v["t_com"] = util.IntAll(dv["t_com"]) //佣金金额
|
|
|
|
+ v["t_count"] = util.IntAll(dv["t_count"]) //销售单数
|
|
|
|
+ if util.IntAll(dv["t_count"]) > 0 {
|
|
|
|
+ v["average"] = util.IntAll(dv["t_com"]) / util.IntAll(dv["t_count"]) //平均佣金
|
|
|
|
+ }
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ res["data"] = *p_data
|
|
|
|
+ } else {
|
|
|
|
+ log.Println("查询产品信息报错")
|
|
|
|
+ }
|
|
|
|
+ res["error_msg"] = ""
|
|
|
|
+ res["error_code"] = 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.ServeJson(res)
|
|
|
|
+ return nil
|
|
}
|
|
}
|
|
|
|
|
|
//微信自动回复 或者访问复制链接
|
|
//微信自动回复 或者访问复制链接
|
|
func (this *Share) LinkShare(discored string) error {
|
|
func (this *Share) LinkShare(discored string) error {
|
|
- defer util.Catch()
|
|
|
|
- openid, _ := this.Session().Get("s_m_openid").(string)
|
|
|
|
- //openid = "ocXeA0v5hueaCCGu_3Iva0br857s"
|
|
|
|
- //log.Println("微信自动回复 或者访问复制链接discored:", discored)
|
|
|
|
- disType := discored[:1]
|
|
|
|
- if openid == "" || discored == "" {
|
|
|
|
- /*if disType == "E" { //数据流量包
|
|
|
|
- return this.Redirect("/frontPage/flowpacket/free/data")
|
|
|
|
- } else if disType == "F" { //中标必听课
|
|
|
|
- return this.Redirect("/frontPage/coursepage/free/data")
|
|
|
|
- } else {
|
|
|
|
- //提示关注页面
|
|
|
|
- return this.Redirect("/")
|
|
|
|
- }*/
|
|
|
|
- //提示关注页面
|
|
|
|
- return this.Redirect("/")
|
|
|
|
- }
|
|
|
|
- userId, _ := this.Session().Get("userId").(string)
|
|
|
|
- url := ""
|
|
|
|
- fmt.Println(userId, openid, "user", `{"s_m_openid":"`+openid+`}`, `{"o_jy":1:"o_vipjy":1,"i_vip_status":1}`)
|
|
|
|
- if discored[len(discored)-4:len(discored)-2] == "GX" {
|
|
|
|
- if disType == "A" {
|
|
|
|
- user := jy.GetBigVipUserBaseMsg(this.Session(), *Middleground)
|
|
|
|
- log.Println(user)
|
|
|
|
- if user != nil {
|
|
|
|
- i_vip_status := user.VipStatus
|
|
|
|
- if i_vip_status > 0 {
|
|
|
|
- modular := util.ObjToMap(Sysconfig.Modular[discored[:1]])
|
|
|
|
- url = (*modular)["upgradeUrl"].(string)
|
|
|
|
- } else {
|
|
|
|
- modular := util.ObjToMap(Sysconfig.Modular[discored[:1]])
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if disType == "E" {
|
|
|
|
- //判断用户是否否买过数据流量包
|
|
|
|
- /*req, _ := http.NewRequest("GET", Sysconfig.SourceCenter+"/resources/findBalance?accountId="+userId, nil)
|
|
|
|
- fmt.Println(Sysconfig.SourceCenter + "/resources/findBalance?accountId=" + userId)
|
|
|
|
- res, _ := http.DefaultClient.Do(req)
|
|
|
|
- defer res.Body.Close()
|
|
|
|
- body, _ := ioutil.ReadAll(res.Body)
|
|
|
|
- dat := BalanceRes{}
|
|
|
|
- _ = json.Unmarshal([]byte(body), &dat)
|
|
|
|
- if dat.Data != nil && len(dat.Data) > 0 {
|
|
|
|
- //页面跳转至数据包筛选页面
|
|
|
|
- modular := util.ObjToMap(Sysconfig.Modular[disType])
|
|
|
|
- url = (*modular)["packetFilterUrl"].(string) + "?disWord=" + discored
|
|
|
|
- } else {
|
|
|
|
- //没有购买流量包,跳转至购买页面
|
|
|
|
- modular := util.ObjToMap(Sysconfig.Modular[disType])
|
|
|
|
- url = (*modular)["buyUrl"].(string) + "?disWord=" + discored
|
|
|
|
- }*/
|
|
|
|
- //新老用户打开链接跳转至购买界面
|
|
|
|
- modular := util.ObjToMap(Sysconfig.Modular[disType])
|
|
|
|
- url = (*modular)["buyUrl"].(string) + "?disWord=" + discored
|
|
|
|
- } else if disType == "F" {
|
|
|
|
- modular := util.ObjToMap(Sysconfig.Modular[disType])
|
|
|
|
- url = (*modular)["courselistUrl"].(string) + "?disWord=" + discored
|
|
|
|
- }
|
|
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ openid, _ := this.Session().Get("s_m_openid").(string)
|
|
|
|
+ //openid = "ocXeA0v5hueaCCGu_3Iva0br857s"
|
|
|
|
+ //log.Println("微信自动回复 或者访问复制链接discored:", discored)
|
|
|
|
+ disType := discored[:1]
|
|
|
|
+ if openid == "" || discored == "" {
|
|
|
|
+ /*if disType == "E" { //数据流量包
|
|
|
|
+ return this.Redirect("/frontPage/flowpacket/free/data")
|
|
|
|
+ } else if disType == "F" { //中标必听课
|
|
|
|
+ return this.Redirect("/frontPage/coursepage/free/data")
|
|
|
|
+ } else {
|
|
|
|
+ //提示关注页面
|
|
|
|
+ return this.Redirect("/")
|
|
|
|
+ }*/
|
|
|
|
+ //提示关注页面
|
|
|
|
+ return this.Redirect("/")
|
|
|
|
+ }
|
|
|
|
+ userId, _ := this.Session().Get("userId").(string)
|
|
|
|
+ url := ""
|
|
|
|
+ fmt.Println(userId, openid, "user", `{"s_m_openid":"`+openid+`}`, `{"o_jy":1:"o_vipjy":1,"i_vip_status":1}`)
|
|
|
|
+ if discored[len(discored)-4:len(discored)-2] == "GX" {
|
|
|
|
+ if disType == "A" {
|
|
|
|
+ user := jy.GetBigVipUserBaseMsg(this.Session(), *Middleground)
|
|
|
|
+ log.Println(user)
|
|
|
|
+ if user != nil {
|
|
|
|
+ i_vip_status := user.VipStatus
|
|
|
|
+ if i_vip_status > 0 {
|
|
|
|
+ modular := util.ObjToMap(Sysconfig.Modular[discored[:1]])
|
|
|
|
+ url = (*modular)["upgradeUrl"].(string)
|
|
|
|
+ } else {
|
|
|
|
+ modular := util.ObjToMap(Sysconfig.Modular[discored[:1]])
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if disType == "E" {
|
|
|
|
+ //判断用户是否否买过数据流量包
|
|
|
|
+ /*req, _ := http.NewRequest("GET", Sysconfig.SourceCenter+"/resources/findBalance?accountId="+userId, nil)
|
|
|
|
+ fmt.Println(Sysconfig.SourceCenter + "/resources/findBalance?accountId=" + userId)
|
|
|
|
+ res, _ := http.DefaultClient.Do(req)
|
|
|
|
+ defer res.Body.Close()
|
|
|
|
+ body, _ := ioutil.ReadAll(res.Body)
|
|
|
|
+ dat := BalanceRes{}
|
|
|
|
+ _ = json.Unmarshal([]byte(body), &dat)
|
|
|
|
+ if dat.Data != nil && len(dat.Data) > 0 {
|
|
|
|
+ //页面跳转至数据包筛选页面
|
|
|
|
+ modular := util.ObjToMap(Sysconfig.Modular[disType])
|
|
|
|
+ url = (*modular)["packetFilterUrl"].(string) + "?disWord=" + discored
|
|
|
|
+ } else {
|
|
|
|
+ //没有购买流量包,跳转至购买页面
|
|
|
|
+ modular := util.ObjToMap(Sysconfig.Modular[disType])
|
|
|
|
+ url = (*modular)["buyUrl"].(string) + "?disWord=" + discored
|
|
|
|
+ }*/
|
|
|
|
+ //新老用户打开链接跳转至购买界面
|
|
|
|
+ modular := util.ObjToMap(Sysconfig.Modular[disType])
|
|
|
|
+ url = (*modular)["buyUrl"].(string) + "?disWord=" + discored
|
|
|
|
+ } else if disType == "F" {
|
|
|
|
+ modular := util.ObjToMap(Sysconfig.Modular[disType])
|
|
|
|
+ url = (*modular)["courselistUrl"].(string) + "?disWord=" + discored
|
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
|
- _, url, _, _ = analyseWord(discored, userId, true)
|
|
|
|
- }
|
|
|
|
- log.Println("获取三级页面地址:", url)
|
|
|
|
- return this.Redirect(url)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ _, url, _, _ = analyseWord(discored, userId, true)
|
|
|
|
+ }
|
|
|
|
+ log.Println("获取三级页面地址:", url)
|
|
|
|
+ return this.Redirect(url)
|
|
}
|
|
}
|
|
|
|
|
|
//分析口令
|
|
//分析口令
|
|
func analyseWord(discored, userId string, isBuy bool) (name, url, appUrl, shareNickname string) {
|
|
func analyseWord(discored, userId string, isBuy bool) (name, url, appUrl, shareNickname string) {
|
|
- log.Println("分析口令传入参数", discored)
|
|
|
|
- //指令第一个字母
|
|
|
|
- encry := discored[:1]
|
|
|
|
- //模块 A:超级订阅 B:数据导出 C:数据报告等 D公告信息 _SX三天有效 E 数据流量包 F 中标必听课
|
|
|
|
- modular := util.ObjToMap(Sysconfig.Modular[encry])
|
|
|
|
- if modular != nil && (*modular)["name"] != nil {
|
|
|
|
- redisDis := redis.GetStr("other", "DIS_"+discored[1:])
|
|
|
|
- log.Println("redis:", redisDis)
|
|
|
|
- if redisDis == "" {
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
- } else {
|
|
|
|
- shareNickname = strings.Split(redisDis, "##")[0]
|
|
|
|
- suffix := discored[len(discored)-3 : len(discored)]
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- //公告三级页处理
|
|
|
|
- if suffix == suffix_msgt {
|
|
|
|
- effectiveTimeStr := strings.Split(redisDis, "##")[3]
|
|
|
|
- effectiveTime, _ := strconv.ParseInt(effectiveTimeStr, 10, 64)
|
|
|
|
- //是否计算佣金
|
|
|
|
- if time.Now().Unix() <= effectiveTime {
|
|
|
|
- url = strings.Split(redisDis, "##")[2] + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = strings.Split(redisDis, "##")[2] + "?disWord=" + discored //日志中转页
|
|
|
|
- } else {
|
|
|
|
- url = strings.Split(redisDis, "##")[2] //指令传输
|
|
|
|
- appUrl = strings.Split(redisDis, "##")[2] //日志中转页
|
|
|
|
- }
|
|
|
|
|
|
+ log.Println("分析口令传入参数", discored)
|
|
|
|
+ //指令第一个字母
|
|
|
|
+ encry := discored[:1]
|
|
|
|
+ //模块 A:超级订阅 B:数据导出 C:数据报告等 D公告信息 _SX三天有效 E 数据流量包 F 中标必听课
|
|
|
|
+ modular := util.ObjToMap(Sysconfig.Modular[encry])
|
|
|
|
+ if modular != nil && (*modular)["name"] != nil {
|
|
|
|
+ redisDis := redis.GetStr("other", "DIS_"+discored[1:])
|
|
|
|
+ log.Println("redis:", redisDis)
|
|
|
|
+ if redisDis == "" {
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
+ } else {
|
|
|
|
+ shareNickname = strings.Split(redisDis, "##")[0]
|
|
|
|
+ suffix := discored[len(discored)-3 : len(discored)]
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ //公告三级页处理
|
|
|
|
+ if suffix == suffix_msgt {
|
|
|
|
+ effectiveTimeStr := strings.Split(redisDis, "##")[3]
|
|
|
|
+ effectiveTime, _ := strconv.ParseInt(effectiveTimeStr, 10, 64)
|
|
|
|
+ //是否计算佣金
|
|
|
|
+ if time.Now().Unix() <= effectiveTime {
|
|
|
|
+ url = strings.Split(redisDis, "##")[2] + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = strings.Split(redisDis, "##")[2] + "?disWord=" + discored //日志中转页
|
|
|
|
+ } else {
|
|
|
|
+ url = strings.Split(redisDis, "##")[2] //指令传输
|
|
|
|
+ appUrl = strings.Split(redisDis, "##")[2] //日志中转页
|
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
|
- if encry == "A" {
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
- } else if encry == "E" {
|
|
|
|
- if isBuy {
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appPacketFilterUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
- } else {
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appBuyUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
- }
|
|
|
|
- } else if encry == "F" {
|
|
|
|
- if isBuy {
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["courselistUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
- } else {
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- /*//redis 获取分销者信息
|
|
|
|
- redisDis := redis.GetStr("other", "DIS_"+discored[1:])
|
|
|
|
- if redisDis != "" {
|
|
|
|
- //分销者昵称
|
|
|
|
- shareNickname = strings.Split(redisDis, "##")[0]
|
|
|
|
- }*/
|
|
|
|
- return name, url, appUrl, shareNickname
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if encry == "A" {
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
+ } else if encry == "E" {
|
|
|
|
+ if isBuy {
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appPacketFilterUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
+ } else {
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appBuyUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
+ }
|
|
|
|
+ } else if encry == "F" {
|
|
|
|
+ if isBuy {
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["courselistUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
+ } else {
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*//redis 获取分销者信息
|
|
|
|
+ redisDis := redis.GetStr("other", "DIS_"+discored[1:])
|
|
|
|
+ if redisDis != "" {
|
|
|
|
+ //分销者昵称
|
|
|
|
+ shareNickname = strings.Split(redisDis, "##")[0]
|
|
|
|
+ }*/
|
|
|
|
+ return name, url, appUrl, shareNickname
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
type Duration int64
|
|
type Duration int64
|
|
|
|
|
|
func TimeProcessing(hour interface{}, duration int) time.Time {
|
|
func TimeProcessing(hour interface{}, duration int) time.Time {
|
|
- todayZero, _ := time.ParseInLocation(Date_Full_Layout, fmt.Sprint(hour), time.Local)
|
|
|
|
- mm, _ := time.ParseDuration(fmt.Sprint(duration) + "m")
|
|
|
|
- t := todayZero.Add(mm)
|
|
|
|
- //t := todayZero.Add(time.Second * 89)
|
|
|
|
- return t
|
|
|
|
|
|
+ todayZero, _ := time.ParseInLocation(Date_Full_Layout, fmt.Sprint(hour), time.Local)
|
|
|
|
+ mm, _ := time.ParseDuration(fmt.Sprint(duration) + "m")
|
|
|
|
+ t := todayZero.Add(mm)
|
|
|
|
+ //t := todayZero.Add(time.Second * 89)
|
|
|
|
+ return t
|
|
}
|
|
}
|
|
|
|
|
|
//根据app客户端复制信息 返回对应信息
|
|
//根据app客户端复制信息 返回对应信息
|
|
func (this *Share) GetWordInfo() {
|
|
func (this *Share) GetWordInfo() {
|
|
- defer util.Catch()
|
|
|
|
- res := map[string]interface{}{
|
|
|
|
- "error_code": error_msg[0],
|
|
|
|
- "error_msg": error_msg[0],
|
|
|
|
- "data": map[string]interface{}{},
|
|
|
|
- }
|
|
|
|
- userId, _ := this.Session().Get("userId").(string)
|
|
|
|
- //userId := "5f5b174923d21d0624334fca"
|
|
|
|
- if this.Method() == METHOD {
|
|
|
|
- copyTxt := this.GetString("copyTxt")
|
|
|
|
- if strings.Contains(copyTxt, "复制") && strings.Contains(copyTxt, "剑鱼标讯APP") {
|
|
|
|
- ct_one := strings.Split(copyTxt, ":")[1]
|
|
|
|
- discored := strings.Split(ct_one, ",")[0]
|
|
|
|
- log.Println("口令:", discored)
|
|
|
|
- log.Println("分析", CopyInfo(discored, userId))
|
|
|
|
- if discored != "" {
|
|
|
|
- res["data"] = CopyInfo(discored, userId)
|
|
|
|
- res["error_code"] = 0
|
|
|
|
- res["error_msg"] = ""
|
|
|
|
- } else {
|
|
|
|
- res["error_msg"] = error_msg[2]
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- res["error_msg"] = error_msg[2]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- this.ServeJson(res)
|
|
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ res := map[string]interface{}{
|
|
|
|
+ "error_code": error_msg[0],
|
|
|
|
+ "error_msg": error_msg[0],
|
|
|
|
+ "data": map[string]interface{}{},
|
|
|
|
+ }
|
|
|
|
+ userId, _ := this.Session().Get("userId").(string)
|
|
|
|
+ //userId := "5f5b174923d21d0624334fca"
|
|
|
|
+ if this.Method() == METHOD {
|
|
|
|
+ copyTxt := this.GetString("copyTxt")
|
|
|
|
+ if strings.Contains(copyTxt, "复制") && strings.Contains(copyTxt, "剑鱼标讯APP") {
|
|
|
|
+ ct_one := strings.Split(copyTxt, ":")[1]
|
|
|
|
+ discored := strings.Split(ct_one, ",")[0]
|
|
|
|
+ log.Println("口令:", discored)
|
|
|
|
+ log.Println("分析", CopyInfo(discored, userId))
|
|
|
|
+ if discored != "" {
|
|
|
|
+ res["data"] = CopyInfo(discored, userId)
|
|
|
|
+ res["error_code"] = 0
|
|
|
|
+ res["error_msg"] = ""
|
|
|
|
+ } else {
|
|
|
|
+ res["error_msg"] = error_msg[2]
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ res["error_msg"] = error_msg[2]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.ServeJson(res)
|
|
}
|
|
}
|
|
|
|
|
|
//app 分析指令
|
|
//app 分析指令
|
|
func CopyInfo(discored, userId string) (res map[string]interface{}) {
|
|
func CopyInfo(discored, userId string) (res map[string]interface{}) {
|
|
- if discored != "" {
|
|
|
|
- log.Println(analyseWord(discored, userId, true))
|
|
|
|
- name, _, appUrl, shareNickname := analyseWord(discored, userId, true)
|
|
|
|
- imgUrl := Sysconfig.Modular["imgUrl"].(string)
|
|
|
|
- if p_data, ok := MQFW.Find("dis_product", nil, `{"l_createdate":1}`, nil, false, -1, -1); ok && p_data != nil {
|
|
|
|
- for _, v := range *p_data {
|
|
|
|
- if v["s_name"].(string) == name && v["s_img"].(string) != "" {
|
|
|
|
- imgUrl = v["s_img"].(string) //产品头像
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- suffix := discored[len(discored)-3 : len(discored)]
|
|
|
|
- if suffix == suffix_msgt {
|
|
|
|
- appUrl = "/jyapp" + appUrl
|
|
|
|
- }
|
|
|
|
- log.Println("需要打开页面地址:" + appUrl)
|
|
|
|
- res = map[string]interface{}{
|
|
|
|
- "title": fmt.Sprintf(Sysconfig.Modular["title"].(string), shareNickname), //标题
|
|
|
|
- "subTitle": fmt.Sprintf(Sysconfig.Modular["subTitle"].(string), name), //副标题
|
|
|
|
- "butTxt": Sysconfig.Modular["butTxt"].(string), //按钮文案
|
|
|
|
- "bottomTxt": Sysconfig.Modular["bottomTxt"].(string), //底部文案
|
|
|
|
- "appUrl": appUrl, //跳转链接
|
|
|
|
- "imgUrl": imgUrl + "?v=" + strconv.FormatInt(time.Now().Unix(), 10), //产品图片
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return
|
|
|
|
|
|
+ if discored != "" {
|
|
|
|
+ log.Println(analyseWord(discored, userId, true))
|
|
|
|
+ name, _, appUrl, shareNickname := analyseWord(discored, userId, true)
|
|
|
|
+ imgUrl := Sysconfig.Modular["imgUrl"].(string)
|
|
|
|
+ if p_data, ok := MQFW.Find("dis_product", nil, `{"l_createdate":1}`, nil, false, -1, -1); ok && p_data != nil {
|
|
|
|
+ for _, v := range *p_data {
|
|
|
|
+ if v["s_name"].(string) == name && v["s_img"].(string) != "" {
|
|
|
|
+ imgUrl = v["s_img"].(string) //产品头像
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ suffix := discored[len(discored)-3 : len(discored)]
|
|
|
|
+ if suffix == suffix_msgt {
|
|
|
|
+ appUrl = "/jyapp" + appUrl
|
|
|
|
+ }
|
|
|
|
+ log.Println("需要打开页面地址:" + appUrl)
|
|
|
|
+ res = map[string]interface{}{
|
|
|
|
+ "title": fmt.Sprintf(Sysconfig.Modular["title"].(string), shareNickname), //标题
|
|
|
|
+ "subTitle": fmt.Sprintf(Sysconfig.Modular["subTitle"].(string), name), //副标题
|
|
|
|
+ "butTxt": Sysconfig.Modular["butTxt"].(string), //按钮文案
|
|
|
|
+ "bottomTxt": Sysconfig.Modular["bottomTxt"].(string), //底部文案
|
|
|
|
+ "appUrl": appUrl, //跳转链接
|
|
|
|
+ "imgUrl": imgUrl + "?v=" + strconv.FormatInt(time.Now().Unix(), 10), //产品图片
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
//数据流量包、中标必听课分销 分析口令
|
|
//数据流量包、中标必听课分销 分析口令
|
|
func appAnalyseWord(discored, userId string, isBuy bool) (name, url, appUrl, shareNickname string) {
|
|
func appAnalyseWord(discored, userId string, isBuy bool) (name, url, appUrl, shareNickname string) {
|
|
- log.Println("分析口令传入参数", discored)
|
|
|
|
- //指令第一个字母
|
|
|
|
- encry := discored[:1]
|
|
|
|
- //模块 A:超级订阅 B:数据导出 C:数据报告等 D公告信息 _SX三天有效 E 数据流量包 F 中标必听课
|
|
|
|
- modular := util.ObjToMap(Sysconfig.Modular[encry])
|
|
|
|
- if modular != nil && (*modular)["name"] != nil {
|
|
|
|
- redisDis := redis.GetStr("other", "DIS_"+discored[1:])
|
|
|
|
- log.Println("redis:", redisDis)
|
|
|
|
- if redisDis == "" {
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
- } else {
|
|
|
|
- shareNickname = strings.Split(redisDis, "##")[0]
|
|
|
|
- suffix := discored[len(discored)-3 : len(discored)]
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- //公告三级页处理
|
|
|
|
- if suffix == suffix_msgt {
|
|
|
|
- effectiveTimeStr := strings.Split(redisDis, "##")[3]
|
|
|
|
- effectiveTime, _ := strconv.ParseInt(effectiveTimeStr, 10, 64)
|
|
|
|
- //是否计算佣金
|
|
|
|
- if time.Now().Unix() <= effectiveTime {
|
|
|
|
- url = strings.Split(redisDis, "##")[2] + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = strings.Split(redisDis, "##")[2] + "?disWord=" + discored //日志中转页
|
|
|
|
- } else {
|
|
|
|
- url = strings.Split(redisDis, "##")[2] //指令传输
|
|
|
|
- appUrl = strings.Split(redisDis, "##")[2] //日志中转页
|
|
|
|
- }
|
|
|
|
|
|
+ log.Println("分析口令传入参数", discored)
|
|
|
|
+ //指令第一个字母
|
|
|
|
+ encry := discored[:1]
|
|
|
|
+ //模块 A:超级订阅 B:数据导出 C:数据报告等 D公告信息 _SX三天有效 E 数据流量包 F 中标必听课
|
|
|
|
+ modular := util.ObjToMap(Sysconfig.Modular[encry])
|
|
|
|
+ if modular != nil && (*modular)["name"] != nil {
|
|
|
|
+ redisDis := redis.GetStr("other", "DIS_"+discored[1:])
|
|
|
|
+ log.Println("redis:", redisDis)
|
|
|
|
+ if redisDis == "" {
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
+ } else {
|
|
|
|
+ shareNickname = strings.Split(redisDis, "##")[0]
|
|
|
|
+ suffix := discored[len(discored)-3 : len(discored)]
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ //公告三级页处理
|
|
|
|
+ if suffix == suffix_msgt {
|
|
|
|
+ effectiveTimeStr := strings.Split(redisDis, "##")[3]
|
|
|
|
+ effectiveTime, _ := strconv.ParseInt(effectiveTimeStr, 10, 64)
|
|
|
|
+ //是否计算佣金
|
|
|
|
+ if time.Now().Unix() <= effectiveTime {
|
|
|
|
+ url = strings.Split(redisDis, "##")[2] + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = strings.Split(redisDis, "##")[2] + "?disWord=" + discored //日志中转页
|
|
|
|
+ } else {
|
|
|
|
+ url = strings.Split(redisDis, "##")[2] //指令传输
|
|
|
|
+ appUrl = strings.Split(redisDis, "##")[2] //日志中转页
|
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
|
- name = (*modular)["name"].(string)
|
|
|
|
- url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
- appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ name = (*modular)["name"].(string)
|
|
|
|
+ url = (*modular)["url"].(string) + "?disWord=" + discored //指令传输
|
|
|
|
+ appUrl = "/jyapp/distrib/redirectTo?appUrl=" + (*modular)["appUrl"].(string) + "?disWord=" + discored //日志中转页
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- /*//redis 获取分销者信息
|
|
|
|
- redisDis := redis.GetStr("other", "DIS_"+discored[1:])
|
|
|
|
- if redisDis != "" {
|
|
|
|
- //分销者昵称
|
|
|
|
- shareNickname = strings.Split(redisDis, "##")[0]
|
|
|
|
- }*/
|
|
|
|
- return name, url, appUrl, shareNickname
|
|
|
|
|
|
+ }
|
|
|
|
+ /*//redis 获取分销者信息
|
|
|
|
+ redisDis := redis.GetStr("other", "DIS_"+discored[1:])
|
|
|
|
+ if redisDis != "" {
|
|
|
|
+ //分销者昵称
|
|
|
|
+ shareNickname = strings.Split(redisDis, "##")[0]
|
|
|
|
+ }*/
|
|
|
|
+ return name, url, appUrl, shareNickname
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//第三方获取口令分享的口令信息
|
|
//第三方获取口令分享的口令信息
|
|
func (this *Share) GetOtherWordShare() {
|
|
func (this *Share) GetOtherWordShare() {
|
|
- defer util.Catch()
|
|
|
|
- res := map[string]interface{}{
|
|
|
|
- "error_code": error_code[0],
|
|
|
|
- "error_msg": error_msg[0],
|
|
|
|
- }
|
|
|
|
- if this.Method() == METHOD {
|
|
|
|
- //模块 A:超级订阅 B:数据导出 C:数据报告 X公告三级页等
|
|
|
|
- modular := this.GetString("modular")
|
|
|
|
- url := this.GetString("url")
|
|
|
|
- if modular != "" {
|
|
|
|
- userId, _ := this.GetSession("userId").(string)
|
|
|
|
- //userId := "123"
|
|
|
|
- partner_user := false
|
|
|
|
- if userId != "" {
|
|
|
|
- s_nickname, _ := this.GetSession("s_nickname").(string)
|
|
|
|
- //s_nickname := "232"
|
|
|
|
- if s_nickname == "" {
|
|
|
|
- s_nickname, _ = this.GetSession("app_name").(string)
|
|
|
|
- }
|
|
|
|
- //判断是否参与伙伴计划
|
|
|
|
- var insert_1, insert_3 int64
|
|
|
|
- partner_user = Mysql.CountBySql(`select count(*) from dis_partner where uid=?`, userId) > 0
|
|
|
|
- if Mysql.ExecTx("加入伙伴", func(tx *sql.Tx) bool {
|
|
|
|
- if !partner_user {
|
|
|
|
- insert := map[string]interface{}{
|
|
|
|
- "type": 3,
|
|
|
|
- "phone": 0,
|
|
|
|
- "email": 0,
|
|
|
|
- "channel": "微信",
|
|
|
|
- "uid": userId,
|
|
|
|
- "is_adopt": 1,
|
|
|
|
- "auth_status": 0, //认证状态
|
|
|
|
- "createtime": time.Now().Format(Date_Full_Layout),
|
|
|
|
- "lastlogintime": time.Now().Format(Date_Full_Layout),
|
|
|
|
- }
|
|
|
|
- insert_1 = Mysql.InsertByTx(tx, "dis_partner", insert) //伙伴表
|
|
|
|
- log.Println("插入伙伴计划", insert_1)
|
|
|
|
- partner_user = Mysql.CountBySql(`select count(*) from account where uid=?`, userId) > 0
|
|
|
|
- if !partner_user {
|
|
|
|
- insert_3 = Mysql.InsertByTx(tx, "account", map[string]interface{}{ //个人账户表
|
|
|
|
- "uid": userId,
|
|
|
|
- "money": 0,
|
|
|
|
- "dis_sales": 0,
|
|
|
|
- "dis_commission": 0,
|
|
|
|
- "dis_order": 0,
|
|
|
|
- })
|
|
|
|
- log.Println("插入账号表", insert_3)
|
|
|
|
- }
|
|
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ res := map[string]interface{}{
|
|
|
|
+ "error_code": error_code[0],
|
|
|
|
+ "error_msg": error_msg[0],
|
|
|
|
+ }
|
|
|
|
+ if this.Method() == METHOD {
|
|
|
|
+ //模块 A:超级订阅 B:数据导出 C:数据报告 X公告三级页等
|
|
|
|
+ modular := this.GetString("modular")
|
|
|
|
+ url := this.GetString("url")
|
|
|
|
+ if modular != "" {
|
|
|
|
+ userId, _ := this.GetSession("userId").(string)
|
|
|
|
+ //userId := "123"
|
|
|
|
+ partner_user := false
|
|
|
|
+ if userId != "" {
|
|
|
|
+ s_nickname, _ := this.GetSession("s_nickname").(string)
|
|
|
|
+ //s_nickname := "232"
|
|
|
|
+ if s_nickname == "" {
|
|
|
|
+ s_nickname, _ = this.GetSession("app_name").(string)
|
|
|
|
+ }
|
|
|
|
+ //判断是否参与伙伴计划
|
|
|
|
+ var insert_1, insert_3 int64
|
|
|
|
+ partner_user = Mysql.CountBySql(`select count(*) from dis_partner where uid=? and type=2`, userId) > 0
|
|
|
|
+ if Mysql.ExecTx("加入伙伴", func(tx *sql.Tx) bool {
|
|
|
|
+ if !partner_user {
|
|
|
|
+ insert := map[string]interface{}{
|
|
|
|
+ "type": 3,
|
|
|
|
+ "phone": 0,
|
|
|
|
+ "email": 0,
|
|
|
|
+ "channel": "微信",
|
|
|
|
+ "uid": userId,
|
|
|
|
+ "is_adopt": 1,
|
|
|
|
+ "auth_status": 0, //认证状态
|
|
|
|
+ "createtime": time.Now().Format(Date_Full_Layout),
|
|
|
|
+ "lastlogintime": time.Now().Format(Date_Full_Layout),
|
|
|
|
+ }
|
|
|
|
+ insert_1 = Mysql.InsertByTx(tx, "dis_partner", insert) //伙伴表
|
|
|
|
+ log.Println("插入伙伴计划", insert_1)
|
|
|
|
+ partner_user = Mysql.CountBySql(`select count(*) from account where uid=?`, userId) > 0
|
|
|
|
+ if !partner_user {
|
|
|
|
+ insert_3 = Mysql.InsertByTx(tx, "account", map[string]interface{}{ //个人账户表
|
|
|
|
+ "uid": userId,
|
|
|
|
+ "money": 0,
|
|
|
|
+ "dis_sales": 0,
|
|
|
|
+ "dis_commission": 0,
|
|
|
|
+ "dis_order": 0,
|
|
|
|
+ })
|
|
|
|
+ log.Println("插入账号表", insert_3)
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- word := VarLSCPool.GetJob()
|
|
|
|
- word += suffix_msgt
|
|
|
|
- //用户昵称存redis app粘贴时备用
|
|
|
|
- effectiveTime := time.Now().Unix() + int64(Sysconfig.TermValidity*60)
|
|
|
|
- url = strings.Replace(url, "/jyapp", "", 1)
|
|
|
|
- redis.Put("other", "DIS_"+word, s_nickname+"##"+userId+"##"+url+"##"+fmt.Sprint(effectiveTime), -1)
|
|
|
|
- log.Println("生成口号命令", userId)
|
|
|
|
- res["data"] = map[string]interface{}{
|
|
|
|
- "disWord": modular + word, //口令
|
|
|
|
- "shareLink": Sysconfig.Webdomain + "/X/" + modular + word, //微信分享链接
|
|
|
|
- "erUrl": "/jyapp/front/downloadJyApp/qrOther?discored=" + modular + word + "&title=公告信息",
|
|
|
|
- }
|
|
|
|
- res["error_code"] = 0
|
|
|
|
- res["error_msg"] = ""
|
|
|
|
- return insert_1 > 0 && insert_3 > -1
|
|
|
|
- }) {
|
|
|
|
|
|
+ }
|
|
|
|
+ word := VarLSCPool.GetJob()
|
|
|
|
+ word += suffix_msgt
|
|
|
|
+ //用户昵称存redis app粘贴时备用
|
|
|
|
+ effectiveTime := time.Now().Unix() + int64(Sysconfig.TermValidity*60)
|
|
|
|
+ url = strings.Replace(url, "/jyapp", "", 1)
|
|
|
|
+ redis.Put("other", "DIS_"+word, s_nickname+"##"+userId+"##"+url+"##"+fmt.Sprint(effectiveTime), -1)
|
|
|
|
+ log.Println("生成口号命令", userId)
|
|
|
|
+ res["data"] = map[string]interface{}{
|
|
|
|
+ "disWord": modular + word, //口令
|
|
|
|
+ "shareLink": Sysconfig.Webdomain + "/X/" + modular + word, //微信分享链接
|
|
|
|
+ "erUrl": "/jyapp/front/downloadJyApp/qrOther?discored=" + modular + word + "&title=公告信息",
|
|
|
|
+ }
|
|
|
|
+ res["error_code"] = 0
|
|
|
|
+ res["error_msg"] = ""
|
|
|
|
+ return insert_1 > 0 && insert_3 > -1
|
|
|
|
+ }) {
|
|
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- res["error_msg"] = error_msg[2]
|
|
|
|
- res["error_code"] = error_code[2]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- this.ServeJson(res)
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ res["error_msg"] = error_msg[2]
|
|
|
|
+ res["error_code"] = error_code[2]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.ServeJson(res)
|
|
}
|
|
}
|
|
|
|
|
|
//获取口令分享的口令信息
|
|
//获取口令分享的口令信息
|
|
func (this *Share) GetWordShare() {
|
|
func (this *Share) GetWordShare() {
|
|
- defer util.Catch()
|
|
|
|
- res := map[string]interface{}{
|
|
|
|
- "error_code": error_code[0],
|
|
|
|
- "error_msg": error_msg[0],
|
|
|
|
- }
|
|
|
|
- if this.Method() == METHOD {
|
|
|
|
- //模块 A:超级订阅 B:数据导出 C:数据报告等
|
|
|
|
- modular := this.GetString("modular")
|
|
|
|
- if modular != "" {
|
|
|
|
- userId, _ := this.GetSession("userId").(string)
|
|
|
|
- //userId := "5c89fead1c298a4d75fef39e"
|
|
|
|
- if userId != "" {
|
|
|
|
- s_nickname, _ := this.GetSession("s_nickname").(string)
|
|
|
|
- if s_nickname == "" {
|
|
|
|
- s_nickname, _ = this.GetSession("app_name").(string)
|
|
|
|
- }
|
|
|
|
- word := redis.GetStr("other", "DIS_"+userId)
|
|
|
|
- if word == "" {
|
|
|
|
- userData := Compatible.Select(userId, `{"s_disword":1}`)
|
|
|
|
- if (*userData)["s_disword"] != nil && util.ObjToString((*userData)["s_disword"]) != "" {
|
|
|
|
- word = util.ObjToString((*userData)["s_disword"])
|
|
|
|
- } else {
|
|
|
|
- word = VarLSCPool.GetJob()
|
|
|
|
- //用户昵称存redis app粘贴时备用
|
|
|
|
- redis.Put("other", "DIS_"+word, s_nickname+"##"+userId, -1)
|
|
|
|
- //用户信息绑定分享口令
|
|
|
|
- redis.Put("other", "DIS_"+userId, word, -1)
|
|
|
|
- ok := Compatible.Update(userId, map[string]interface{}{
|
|
|
|
- "$set": map[string]interface{}{
|
|
|
|
- "s_disword": word,
|
|
|
|
- },
|
|
|
|
- })
|
|
|
|
- if !ok {
|
|
|
|
- log.Println("保存 口令到user失败-", userId)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- res["data"] = map[string]interface{}{
|
|
|
|
- "disWord": modular + word, //口令
|
|
|
|
- "shareLink": Sysconfig.Webdomain + "/F/" + modular + word, //微信分享链接
|
|
|
|
- "erUrl": "/jyapp/getERCode/DIS_" + modular + word, //二维码地址
|
|
|
|
- }
|
|
|
|
- res["error_code"] = 0
|
|
|
|
- res["error_msg"] = ""
|
|
|
|
- } else {
|
|
|
|
- res["error_msg"] = error_msg[1]
|
|
|
|
- res["error_code"] = error_code[1]
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- res["error_msg"] = error_msg[2]
|
|
|
|
- res["error_code"] = error_code[2]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- this.ServeJson(res)
|
|
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ res := map[string]interface{}{
|
|
|
|
+ "error_code": error_code[0],
|
|
|
|
+ "error_msg": error_msg[0],
|
|
|
|
+ }
|
|
|
|
+ if this.Method() == METHOD {
|
|
|
|
+ //模块 A:超级订阅 B:数据导出 C:数据报告等
|
|
|
|
+ modular := this.GetString("modular")
|
|
|
|
+ if modular != "" {
|
|
|
|
+ userId, _ := this.GetSession("userId").(string)
|
|
|
|
+ //userId := "5c89fead1c298a4d75fef39e"
|
|
|
|
+ if userId != "" {
|
|
|
|
+ s_nickname, _ := this.GetSession("s_nickname").(string)
|
|
|
|
+ if s_nickname == "" {
|
|
|
|
+ s_nickname, _ = this.GetSession("app_name").(string)
|
|
|
|
+ }
|
|
|
|
+ word := redis.GetStr("other", "DIS_"+userId)
|
|
|
|
+ if word == "" {
|
|
|
|
+ userData := Compatible.Select(userId, `{"s_disword":1}`)
|
|
|
|
+ if (*userData)["s_disword"] != nil && util.ObjToString((*userData)["s_disword"]) != "" {
|
|
|
|
+ word = util.ObjToString((*userData)["s_disword"])
|
|
|
|
+ } else {
|
|
|
|
+ word = VarLSCPool.GetJob()
|
|
|
|
+ //用户昵称存redis app粘贴时备用
|
|
|
|
+ redis.Put("other", "DIS_"+word, s_nickname+"##"+userId, -1)
|
|
|
|
+ //用户信息绑定分享口令
|
|
|
|
+ redis.Put("other", "DIS_"+userId, word, -1)
|
|
|
|
+ ok := Compatible.Update(userId, map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{
|
|
|
|
+ "s_disword": word,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ if !ok {
|
|
|
|
+ log.Println("保存 口令到user失败-", userId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ res["data"] = map[string]interface{}{
|
|
|
|
+ "disWord": modular + word, //口令
|
|
|
|
+ "shareLink": Sysconfig.Webdomain + "/F/" + modular + word, //微信分享链接
|
|
|
|
+ "erUrl": "/jyapp/getERCode/DIS_" + modular + word, //二维码地址
|
|
|
|
+ }
|
|
|
|
+ res["error_code"] = 0
|
|
|
|
+ res["error_msg"] = ""
|
|
|
|
+ } else {
|
|
|
|
+ res["error_msg"] = error_msg[1]
|
|
|
|
+ res["error_code"] = error_code[1]
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ res["error_msg"] = error_msg[2]
|
|
|
|
+ res["error_code"] = error_code[2]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.ServeJson(res)
|
|
}
|
|
}
|
|
|
|
|
|
//type 1:超级订阅 2:数据导出 3:数据报告 4:中标必听课 5三级页
|
|
//type 1:超级订阅 2:数据导出 3:数据报告 4:中标必听课 5三级页
|
|
func (this *Share) ShareLogs() {
|
|
func (this *Share) ShareLogs() {
|
|
- userId, _ := this.GetSession("userId").(string)
|
|
|
|
- //userId := "5c89fead1c298a4d75fef39e"
|
|
|
|
- status, msg := func() (int, string) {
|
|
|
|
- typ, _ := this.GetInteger("product_type")
|
|
|
|
- product_type := ""
|
|
|
|
- if typ == 1 {
|
|
|
|
- product_type = "超级订阅"
|
|
|
|
- } else if typ == 2 {
|
|
|
|
- product_type = "数据导出"
|
|
|
|
- } else if typ == 3 {
|
|
|
|
- product_type = "数据报告"
|
|
|
|
- } else if typ == 4 {
|
|
|
|
- product_type = "中标必听课"
|
|
|
|
- } else {
|
|
|
|
- return -1, "product_type参数错误"
|
|
|
|
- }
|
|
|
|
- lock := &sync.Mutex{}
|
|
|
|
- lock.Lock()
|
|
|
|
- //count++
|
|
|
|
- MQFW.Update("dis_product", map[string]interface{}{
|
|
|
|
- "s_name": product_type,
|
|
|
|
- }, map[string]interface{}{
|
|
|
|
- "$set": map[string]interface{}{
|
|
|
|
- "l_timetamp": time.Now().Unix(),
|
|
|
|
- },
|
|
|
|
- "$inc": map[string]interface{}{
|
|
|
|
- "i_shareCount": 1,
|
|
|
|
- },
|
|
|
|
- }, false, false)
|
|
|
|
- lock.Unlock()
|
|
|
|
- //保存日志
|
|
|
|
- userid := util.If(userId == "", "", userId)
|
|
|
|
- logid := MQFW.Save("distribution_sharelog", map[string]interface{}{
|
|
|
|
- "userid": userid,
|
|
|
|
- "createtime": time.Now().Unix(),
|
|
|
|
- "url": this.Request.Referer(),
|
|
|
|
- "client": this.Header("User-Agent"),
|
|
|
|
- "product_type": typ,
|
|
|
|
- "action": this.GetString("act"),
|
|
|
|
- "password": this.GetString("password"),
|
|
|
|
- })
|
|
|
|
- if logid == "" {
|
|
|
|
- return -1, "保存分享日志出错"
|
|
|
|
- }
|
|
|
|
- return 1, ""
|
|
|
|
- }()
|
|
|
|
- if status != 1 {
|
|
|
|
- log.Println(this.GetSession("userId"), msg)
|
|
|
|
- }
|
|
|
|
|
|
+ userId, _ := this.GetSession("userId").(string)
|
|
|
|
+ //userId := "5c89fead1c298a4d75fef39e"
|
|
|
|
+ status, msg := func() (int, string) {
|
|
|
|
+ typ, _ := this.GetInteger("product_type")
|
|
|
|
+ product_type := ""
|
|
|
|
+ if typ == 1 {
|
|
|
|
+ product_type = "超级订阅"
|
|
|
|
+ } else if typ == 2 {
|
|
|
|
+ product_type = "数据导出"
|
|
|
|
+ } else if typ == 3 {
|
|
|
|
+ product_type = "数据报告"
|
|
|
|
+ } else if typ == 4 {
|
|
|
|
+ product_type = "中标必听课"
|
|
|
|
+ } else {
|
|
|
|
+ return -1, "product_type参数错误"
|
|
|
|
+ }
|
|
|
|
+ lock := &sync.Mutex{}
|
|
|
|
+ lock.Lock()
|
|
|
|
+ //count++
|
|
|
|
+ MQFW.Update("dis_product", map[string]interface{}{
|
|
|
|
+ "s_name": product_type,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{
|
|
|
|
+ "l_timetamp": time.Now().Unix(),
|
|
|
|
+ },
|
|
|
|
+ "$inc": map[string]interface{}{
|
|
|
|
+ "i_shareCount": 1,
|
|
|
|
+ },
|
|
|
|
+ }, false, false)
|
|
|
|
+ lock.Unlock()
|
|
|
|
+ //保存日志
|
|
|
|
+ userid := util.If(userId == "", "", userId)
|
|
|
|
+ logid := MQFW.Save("distribution_sharelog", map[string]interface{}{
|
|
|
|
+ "userid": userid,
|
|
|
|
+ "createtime": time.Now().Unix(),
|
|
|
|
+ "url": this.Request.Referer(),
|
|
|
|
+ "client": this.Header("User-Agent"),
|
|
|
|
+ "product_type": typ,
|
|
|
|
+ "action": this.GetString("act"),
|
|
|
|
+ "password": this.GetString("password"),
|
|
|
|
+ })
|
|
|
|
+ if logid == "" {
|
|
|
|
+ return -1, "保存分享日志出错"
|
|
|
|
+ }
|
|
|
|
+ return 1, ""
|
|
|
|
+ }()
|
|
|
|
+ if status != 1 {
|
|
|
|
+ log.Println(this.GetSession("userId"), msg)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
func (this *Share) ShareLink() {
|
|
func (this *Share) ShareLink() {
|
|
- res := map[string]interface{}{
|
|
|
|
- "error_code": error_code[0],
|
|
|
|
- "error_msg": error_msg[0],
|
|
|
|
- "data": "",
|
|
|
|
- }
|
|
|
|
- disWord := this.GetString("disWord")
|
|
|
|
- dis := disWord[:1]
|
|
|
|
- url := Sysconfig.Webdomain + "/G/" + disWord
|
|
|
|
- if dis == "E" {
|
|
|
|
- url = Sysconfig.Webdomain + "/E/" + disWord
|
|
|
|
- } else if dis == "F" {
|
|
|
|
- url = Sysconfig.Webdomain + "/F/" + disWord
|
|
|
|
- }
|
|
|
|
|
|
+ res := map[string]interface{}{
|
|
|
|
+ "error_code": error_code[0],
|
|
|
|
+ "error_msg": error_msg[0],
|
|
|
|
+ "data": "",
|
|
|
|
+ }
|
|
|
|
+ disWord := this.GetString("disWord")
|
|
|
|
+ dis := disWord[:1]
|
|
|
|
+ url := Sysconfig.Webdomain + "/G/" + disWord
|
|
|
|
+ if dis == "E" {
|
|
|
|
+ url = Sysconfig.Webdomain + "/E/" + disWord
|
|
|
|
+ } else if dis == "F" {
|
|
|
|
+ url = Sysconfig.Webdomain + "/F/" + disWord
|
|
|
|
+ }
|
|
|
|
|
|
- log.Println(url)
|
|
|
|
- r, _ := qr.Encode(url, qr.M)
|
|
|
|
- pngdat := r.PNG()
|
|
|
|
- res["error_code"] = 0
|
|
|
|
- res["error_msg"] = "二维码获取"
|
|
|
|
- res["data"] = base64.StdEncoding.EncodeToString(pngdat)
|
|
|
|
- this.ServeJson(res)
|
|
|
|
|
|
+ log.Println(url)
|
|
|
|
+ r, _ := qr.Encode(url, qr.M)
|
|
|
|
+ pngdat := r.PNG()
|
|
|
|
+ res["error_code"] = 0
|
|
|
|
+ res["error_msg"] = "二维码获取"
|
|
|
|
+ res["data"] = base64.StdEncoding.EncodeToString(pngdat)
|
|
|
|
+ this.ServeJson(res)
|
|
}
|
|
}
|