Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CnChunfeng
/
crm_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
26201524
authored
Apr 21, 2020
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完成上线
parent
31097b3a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
20 deletions
internal/dao/sqlx.go
internal/logic/member_user.go
internal/dao/sqlx.go
View file @
26201524
...
...
@@ -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
}
internal/logic/member_user.go
View file @
26201524
...
...
@@ -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
(
ad
tag
,
","
)[
0
]
ptag
=
strings
.
Split
(
p
tag
,
","
)[
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
)
}
//地址
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment