Commit 26201524 by Joneq

完成上线

parent 31097b3a
......@@ -5,34 +5,52 @@ import (
"fmt"
"log"
"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) {
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))
if err != nil {
log.Fatalln(err)
}
return db
once.Do(func() {
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))
if err != nil {
log.Fatalln(err)
}
instance = db
})
return instance
}
func GetCmsDb()(*sqlx.DB) {
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))
if err != nil {
log.Fatalln(err)
}
return db
onceCms.Do(func() {
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))
if err != nil {
log.Fatalln(err)
}
instanceCms = db
})
return instanceCms
}
func GetLiexinDb()(*sqlx.DB) {
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))
if err != nil {
log.Fatalln(err)
}
return db
onceLiexin.Do(func() {
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))
if err != nil {
log.Fatalln(err)
}
instanceLiexin = db
})
return instanceLiexin
}
......@@ -47,6 +47,19 @@ func GetMemberUserInfo(memberId int) model.MemberAddUserData {
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{
......@@ -88,7 +101,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
if refer != ""{
refer = strings.Split(adtag,",")[0]
refer = strings.Split(refer,",")[0]
//如果是以上refer则为自营样片
if strings.Contains(refer,"sample") {
MemberUserInfo.Channel_source = 10
......@@ -96,7 +109,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
}
if ptag != "" {
ptag = strings.Split(adtag,",")[0]
ptag = strings.Split(ptag,",")[0]
MemberUserInfo.Ptag = strings.Split(ptag,",")[0]
switch ptag {
case "ptag=activity-140":
......@@ -124,6 +137,7 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
MemberUserInfo.Channel_source = 12//如果是以上ptag则为信用贷测评
break
}
SetTagSale(ptag,&MemberUserInfo)
}
if adtag != "" {
......@@ -135,6 +149,8 @@ func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
if adtag == "adtag=findchips" {
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