Commit 26201524 by Joneq

完成上线

parent 31097b3a
...@@ -5,34 +5,52 @@ import ( ...@@ -5,34 +5,52 @@ import (
"fmt" "fmt"
"log" "log"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
"sync"
) )
var instance * sqlx.DB
var instanceCms * sqlx.DB
var instanceLiexin * sqlx.DB
var once sync.Once
var onceCms sync.Once
var onceLiexin sync.Once
func GetDb()(*sqlx.DB) { func GetDb()(*sqlx.DB) {
once.Do(func() {
dbConfig := configs.GetDBOne() dbConfig := configs.GetDBOne()
db, err := sqlx.Open(dbConfig.Engine, fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", dbConfig.User, dbConfig.Pass, dbConfig.Ip, dbConfig.Port, dbConfig.Table)) db, err := sqlx.Open(dbConfig.Engine, fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", dbConfig.User, dbConfig.Pass, dbConfig.Ip, dbConfig.Port, dbConfig.Table))
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
return db instance = db
})
return instance
} }
func GetCmsDb()(*sqlx.DB) { func GetCmsDb()(*sqlx.DB) {
onceCms.Do(func() {
dbConfig := configs.GetDBCms() dbConfig := configs.GetDBCms()
db, err := sqlx.Open(dbConfig.Engine, fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", dbConfig.User, dbConfig.Pass, dbConfig.Ip, dbConfig.Port, dbConfig.Table)) db, err := sqlx.Open(dbConfig.Engine, fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", dbConfig.User, dbConfig.Pass, dbConfig.Ip, dbConfig.Port, dbConfig.Table))
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
return db instanceCms = db
})
return instanceCms
} }
func GetLiexinDb()(*sqlx.DB) { func GetLiexinDb()(*sqlx.DB) {
onceLiexin.Do(func() {
dbConfig := configs.GetDBLiexin() dbConfig := configs.GetDBLiexin()
db, err := sqlx.Open(dbConfig.Engine, fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", dbConfig.User, dbConfig.Pass, dbConfig.Ip, dbConfig.Port, dbConfig.Table)) db, err := sqlx.Open(dbConfig.Engine, fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", dbConfig.User, dbConfig.Pass, dbConfig.Ip, dbConfig.Port, dbConfig.Table))
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
return db instanceLiexin = db
})
return instanceLiexin
} }
...@@ -47,6 +47,19 @@ func GetMemberUserInfo(memberId int) model.MemberAddUserData { ...@@ -47,6 +47,19 @@ func GetMemberUserInfo(memberId int) model.MemberAddUserData {
return MemberUserInfo return MemberUserInfo
} }
//查找对应tag得到的客服
func SetTagSale(tag string,memberInfo *model.MemberAddUserData){
//查找交易员
var saleId int
err := dao.GetDb().QueryRowx("select sale_id from lie_sale_tag where `is_del` = 0 and (`adtag` = ? or `ptag` = ?)",tag,tag).Scan(&saleId)
if err != nil {
service.WriteErr(err)
}
if saleId != 0 {
memberInfo.Sale_Id = saleId
}
}
//处理基本的原始数据 //处理基本的原始数据
func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
...@@ -88,7 +101,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{ ...@@ -88,7 +101,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
if refer != ""{ if refer != ""{
refer = strings.Split(adtag,",")[0] refer = strings.Split(refer,",")[0]
//如果是以上refer则为自营样片 //如果是以上refer则为自营样片
if strings.Contains(refer,"sample") { if strings.Contains(refer,"sample") {
MemberUserInfo.Channel_source = 10 MemberUserInfo.Channel_source = 10
...@@ -96,7 +109,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{ ...@@ -96,7 +109,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
} }
if ptag != "" { if ptag != "" {
ptag = strings.Split(adtag,",")[0] ptag = strings.Split(ptag,",")[0]
MemberUserInfo.Ptag = strings.Split(ptag,",")[0] MemberUserInfo.Ptag = strings.Split(ptag,",")[0]
switch ptag { switch ptag {
case "ptag=activity-140": case "ptag=activity-140":
...@@ -124,6 +137,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{ ...@@ -124,6 +137,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
MemberUserInfo.Channel_source = 12//如果是以上ptag则为信用贷测评 MemberUserInfo.Channel_source = 12//如果是以上ptag则为信用贷测评
break break
} }
SetTagSale(ptag,&MemberUserInfo)
} }
if adtag != "" { if adtag != "" {
...@@ -135,6 +149,8 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{ ...@@ -135,6 +149,8 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
if adtag == "adtag=findchips" { if adtag == "adtag=findchips" {
MemberUserInfo.Channel_source = 14//如果是以上adtagfindchips广告 MemberUserInfo.Channel_source = 14//如果是以上adtagfindchips广告
} }
SetTagSale(adtag,&MemberUserInfo)
} }
//地址 //地址
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment