|
@@ -181,8 +181,8 @@ func HasService(mysql *Mysql, userId string, params ...int) *MemberService {
|
|
|
}
|
|
|
args = append(args, args...)
|
|
|
args = append(args, userId, NowFormat(Date_Full_Layout))
|
|
|
- list := mysql.SelectBySql(`SELECT a.l_starttime,b.id from bigmember_service_user a
|
|
|
- INNER JOIN bigmember_service b on (((b.id in (`+strings.Join(ws, ",")+`) and a.s_serviceid=b.id) or (b.i_pid in (`+strings.Join(ws, ",")+`) and a.s_serviceid=b.i_pid)) and b.i_status=0 and a.s_userid=? and a.i_status=0 and a.l_endtime>?)`, args...)
|
|
|
+ list := mysql.SelectBySql(`SELECT a.l_starttime,b.id from jianyu.bigmember_service_user a
|
|
|
+ INNER JOIN jianyu.bigmember_service b on (((b.id in (`+strings.Join(ws, ",")+`) and a.s_serviceid=b.id) or (b.i_pid in (`+strings.Join(ws, ",")+`) and a.s_serviceid=b.i_pid)) and b.i_status=0 and a.s_userid=? and a.i_status=0 and a.l_endtime>?)`, args...)
|
|
|
ms := &MemberService{
|
|
|
Services: map[int]*memberService{},
|
|
|
}
|
|
@@ -443,9 +443,9 @@ func LoadEntProductUsers(m *Mysql, testUserIds []int) (map[string]*UserInfo, map
|
|
|
userMap := map[int]*UserInfo{}
|
|
|
entMap := map[int]*UserInfo{}
|
|
|
all := []*UserInfo{}
|
|
|
- query := `SELECT DISTINCT a.ent_id,IF(instr(a.product_type,'` + Ent_EmpowerMember + `')>0,'` + Ent_EmpowerMember + `','` + Ent_EmpowerVip + `') as product_type,c.phone,b.ent_user_id,d.name as ent_name,d.power_source,d.isNew from entniche_wait_empower a
|
|
|
- inner join entniche_power b on (a.end_time>? and b.status=1 and (a.product_type like '%` + Ent_EmpowerVip + `%' or a.product_type like '%` + Ent_EmpowerMember + `%') and a.id=b.wait_empower_id)
|
|
|
- inner join entniche_user c on (`
|
|
|
+ query := `SELECT DISTINCT a.ent_id,IF(instr(a.product_type,'` + Ent_EmpowerMember + `')>0,'` + Ent_EmpowerMember + `','` + Ent_EmpowerVip + `') as product_type,c.phone,b.ent_user_id,d.name as ent_name,d.power_source,d.isNew from jianyu.entniche_wait_empower a
|
|
|
+ inner join jianyu.entniche_power b on (a.end_time>? and b.status=1 and (a.product_type like '%` + Ent_EmpowerVip + `%' or a.product_type like '%` + Ent_EmpowerMember + `%') and a.id=b.wait_empower_id)
|
|
|
+ inner join jianyu.entniche_user c on (`
|
|
|
if len(testUserIds) > 0 {
|
|
|
array := []string{}
|
|
|
for _, v := range testUserIds {
|
|
@@ -454,7 +454,7 @@ func LoadEntProductUsers(m *Mysql, testUserIds []int) (map[string]*UserInfo, map
|
|
|
query += `c.id in (` + strings.Join(array, ",") + `) and `
|
|
|
}
|
|
|
query += `b.ent_user_id=c.id)
|
|
|
- inner join entniche_info d on (d.id=a.ent_id)`
|
|
|
+ inner join jianyu.entniche_info d on (d.id=a.ent_id)`
|
|
|
m.SelectByBath(200, func(l *[]map[string]interface{}) bool {
|
|
|
for _, v := range *l {
|
|
|
phone, _ := v["phone"].(string)
|
|
@@ -504,7 +504,7 @@ func LoadEntnicheUsers(m *Mysql) map[string]bool {
|
|
|
}
|
|
|
}
|
|
|
return true
|
|
|
- }, `SELECT b.phone from entniche_info a INNER JOIN entniche_user b on (a.status=1 and a.power_source is null and b.power=1 and a.id=b.ent_id)`)
|
|
|
+ }, `SELECT b.phone from jianyu.entniche_info a INNER JOIN jianyu.entniche_user b on (a.status=1 and a.power_source is null and b.power=1 and a.id=b.ent_id)`)
|
|
|
logger.Info("商机管理用户加载结束。。。", len(r))
|
|
|
return r
|
|
|
}
|
|
@@ -536,7 +536,7 @@ func GetPhone(u map[string]interface{}) string {
|
|
|
|
|
|
//
|
|
|
func GetAllByEntUserId(mgo *MongodbSim, msl *Mysql, entUserId int) *map[string]interface{} {
|
|
|
- entUsers := msl.SelectBySql(`select phone from entniche_user where id=?`, entUserId)
|
|
|
+ entUsers := msl.SelectBySql(`select phone from jianyu.entniche_user where id=?`, entUserId)
|
|
|
if entUsers == nil || len(*entUsers) == 0 {
|
|
|
logger.Info("entniche_user表中没有找到该企业用户", entUserId)
|
|
|
return nil
|
|
@@ -550,7 +550,7 @@ func GetAllByEntUserId(mgo *MongodbSim, msl *Mysql, entUserId int) *map[string]i
|
|
|
|
|
|
//
|
|
|
func GetAllByEntPositionId(mgo *MongodbSim, tidb, msl *Mysql, positionId int) *map[string]interface{} {
|
|
|
- position := tidb.SelectBySql(`select a.ent_id,b.phone from base_position a inner join base_user b on (a.id=? and a.user_id=b.id)`, positionId)
|
|
|
+ position := tidb.SelectBySql(`select a.ent_id,b.phone from base_service.base_position a inner join base_service.base_user b on (a.id=? and a.user_id=b.id)`, positionId)
|
|
|
if position == nil || len(*position) == 0 {
|
|
|
logger.Info("无效的职位id", position)
|
|
|
return nil
|
|
@@ -565,7 +565,7 @@ func GetAllByEntPositionId(mgo *MongodbSim, tidb, msl *Mysql, positionId int) *m
|
|
|
logger.Info("该职位id没有找到对应的手机号", position)
|
|
|
return nil
|
|
|
}
|
|
|
- entUsers := msl.SelectBySql(`select id from entniche_user where phone=? and ent_id=?`, phone, entId)
|
|
|
+ entUsers := msl.SelectBySql(`select id from jianyu.entniche_user where phone=? and ent_id=?`, phone, entId)
|
|
|
if entUsers == nil || len(*entUsers) == 0 {
|
|
|
logger.Info("entniche_user表中没有找到该企业用户", phone, entId)
|
|
|
return nil
|
|
@@ -672,15 +672,15 @@ func GetEntUserSubset(mgo *MongodbSim, entUserId, tp int) map[string]interface{}
|
|
|
|
|
|
//根据企业员工id获取身份信息
|
|
|
func IdentityByEntUserId(base, main *Mysql, entUserId int64) *IdentityInfo {
|
|
|
- ents := main.SelectBySql(`SELECT a.id,a.name,a.phone,a.ent_id,b.name as ent_name from entniche_user a inner join entniche_info b on (a.id=? and a.ent_id=b.id) limit 1`, entUserId)
|
|
|
+ ents := main.SelectBySql(`SELECT a.id,a.name,a.phone,a.ent_id,b.name as ent_name from jianyu.entniche_user a inner join jianyu.entniche_info b on (a.id=? and a.ent_id=b.id) limit 1`, entUserId)
|
|
|
if ents == nil || len(*ents) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
if entId := Int64All((*ents)[0]["ent_id"]); entId > 0 {
|
|
|
- list := base.SelectBySql(`SELECT a.id as position_id,c.person_id,a.person_name,a.account_id,a.type as position_type,d.id as user_id,b.id as ent_account_id from base_user d
|
|
|
- inner join base_position a on (d.phone=? and a.ent_id=? and a.type=1 and d.id=a.user_id)
|
|
|
- inner join base_account c on (c.ent_id=? and c.type=1 and a.account_id=c.id)
|
|
|
- inner join base_account b on (b.type=1 and b.person_id=0 and b.ent_id=?) limit 1`, ObjToString((*ents)[0]["phone"]), entId, entId, entId)
|
|
|
+ list := base.SelectBySql(`SELECT a.id as position_id,c.person_id,a.person_name,a.account_id,a.type as position_type,d.id as user_id,b.id as ent_account_id from base_service.base_user d
|
|
|
+ inner join base_service.base_position a on (d.phone=? and a.ent_id=? and a.type=1 and d.id=a.user_id)
|
|
|
+ inner join base_service.base_account c on (c.ent_id=? and c.type=1 and a.account_id=c.id)
|
|
|
+ inner join base_service.base_account b on (b.type=1 and b.person_id=0 and b.ent_id=?) limit 1`, ObjToString((*ents)[0]["phone"]), entId, entId, entId)
|
|
|
if list != nil && len(*list) == 1 {
|
|
|
identity := &IdentityInfo{
|
|
|
PersonId: Int64All((*list)[0]["person_id"]),
|
|
@@ -752,8 +752,8 @@ func GetPersonalIdentityByBaseUserId(base, main *Mysql, baseUserId int64) *Ident
|
|
|
if baseUserId == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
- list := base.SelectBySql(`select a.id as position_id , b.person_id ,a.type as position_type, a.account_id,a.person_name from base_position a
|
|
|
- inner join base_account b on (a.account_id=b.id and a.user_id=? and a.type=0) limit 1`, baseUserId)
|
|
|
+ list := base.SelectBySql(`select a.id as position_id , b.person_id ,a.type as position_type, a.account_id,a.person_name from base_service.base_position a
|
|
|
+ inner join base_service.base_account b on (a.account_id=b.id and a.user_id=? and a.type=0) limit 1`, baseUserId)
|
|
|
if list != nil && len(*list) == 1 {
|
|
|
identity := &IdentityInfo{
|
|
|
PersonId: Int64All((*list)[0]["person_id"]),
|
|
@@ -778,8 +778,8 @@ func GetPersonalIdentityByMgoId(base *Mysql, mgo *MongodbSim, userId string) *Id
|
|
|
return nil
|
|
|
}
|
|
|
baseUserId := util.Int64All((*data)["base_user_id"])
|
|
|
- list := base.SelectBySql(`select a.id as position_id , b.person_id ,a.type as position_type, a.account_id,a.person_name from base_position a
|
|
|
- inner join base_account b on (a.account_id=b.id and a.user_id=? and a.type=0) limit 1`, baseUserId)
|
|
|
+ list := base.SelectBySql(`select a.id as position_id , b.person_id ,a.type as position_type, a.account_id,a.person_name from base_service.base_position a
|
|
|
+ inner join base_service.base_account b on (a.account_id=b.id and a.user_id=? and a.type=0) limit 1`, baseUserId)
|
|
|
if list != nil && len(*list) == 1 {
|
|
|
identity := &IdentityInfo{
|
|
|
PersonId: Int64All((*list)[0]["person_id"]),
|
|
@@ -796,7 +796,7 @@ func GetPersonalIdentityByMgoId(base *Mysql, mgo *MongodbSim, userId string) *Id
|
|
|
|
|
|
//根据职位id获取用户信息
|
|
|
func GetUserInfoByPosition(base *Mysql, mgo *MongodbSim, id int64) *UserInfo {
|
|
|
- list := base.SelectBySql(`select user_id from base_position where id=?`, id)
|
|
|
+ list := base.SelectBySql(`select user_id from base_service.base_position where id=?`, id)
|
|
|
if list == nil || len(*list) == 0 {
|
|
|
return nil
|
|
|
}
|