wangchuanjin 5 жил өмнө
parent
commit
bbb6314978

+ 0 - 66
src/qfw/util/jy/checksendmsg.go

@@ -1,66 +0,0 @@
-package jy
-
-import (
-	"fmt"
-	"log"
-	"net/url"
-	"qfw/util"
-	"qfw/util/redis"
-
-	//"strconv"
-	"strings"
-	"time"
-)
-
-var se *util.SimpleEncrypt = &util.SimpleEncrypt{Key: "topnet2015topnet2015"}
-var ActivityEndCode, ActivityStartCode int64
-var AC = &util.AES_CBC{
-	Key: "mGlAgnIBB8bx2nch",
-	Iv:  "1389461544135476",
-}
-
-//发短信,验证token
-func CheckSendMsg(token string) string {
-	if token == "" {
-		return ""
-	}
-	log.Println("短信解析前token", token)
-	key := fmt.Sprintf("smstoken_%s", token)
-	ok, e := redis.Exists("other", key)
-	if e != nil {
-		log.Println("redis中token error", e)
-		return ""
-	}
-	if ok {
-		log.Println("redis中token已存在", token)
-		return ""
-	}
-	token, e = url.QueryUnescape(token)
-	if e != nil {
-		log.Println("短信token QueryUnescape error", e)
-	}
-	v, err := AC.Decrypt(token)
-	if err != nil {
-		log.Println("短信token Decrypt error", err)
-		return ""
-	}
-	log.Println("短信解析后token", v)
-	vs := strings.Split(v, "_")
-	if len(vs) != 3 {
-		log.Println("短信token error", vs)
-		return ""
-	}
-	now := time.Now()
-	if !strings.HasPrefix(vs[1], util.FormatDate(&now, util.Date_yyyyMMdd)) {
-		log.Println("短信token date错误", vs)
-		return ""
-	}
-	if vs[2] != util.GetMd5String(fmt.Sprintf("%s&%s", vs[0], vs[1])) {
-		log.Println("短信token sing错误", vs)
-		return ""
-	}
-	if vs[0] != "" {
-		redis.Put("other", key, 1, 86400)
-	}
-	return vs[0]
-}

+ 0 - 299
src/qfw/util/jy/entnichepush.go

@@ -1,299 +0,0 @@
-package jy
-
-import (
-	"encoding/json"
-	"fmt"
-	"log"
-	. "qfw/util"
-	"qfw/util/elastic"
-	. "qfw/util/mongodb"
-	"qfw/util/mysql"
-	"qfw/util/redis"
-	"strings"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-var EntnichePush = &entnichePush{}
-
-type entnichePush struct {
-}
-
-//从pushcache_2_a中取
-func (e *entnichePush) GetTodayCache(entId, userId int) (*SubPush, error) {
-	pc_a, err := redis.GetNewBytes("pushcache_2_b", e.todayKey(entId, userId))
-	if err != nil {
-		return nil, err
-	}
-	if pc_a == nil {
-		return nil, nil
-	}
-	var p *SubPush
-	if err := json.Unmarshal(*pc_a, &p); err != nil {
-		return nil, err
-	}
-	return p, nil
-}
-
-//往pushcache_2_a中放
-func (e *entnichePush) PutTodayCache(entId, userId int, pc_a *SubPush) {
-	redis.Put("pushcache_2_b", e.todayKey(entId, userId), pc_a, threeDay)
-}
-
-//获取redis key
-func (e *entnichePush) todayKey(entId, userId int) string {
-	return fmt.Sprintf("entnichepush_%d_%d", entId, userId)
-}
-
-func (e *entnichePush) Datas(MQFW MongodbSim, PushMysql *mysql.Mysql, entId, userId int, pageNum int, selectTime, area string) (hasNextPage bool, result []*SubPushList) {
-	if pageNum < 1 {
-		pageNum = 1
-	}
-	now := NowFormat(Date_Short_Layout)
-	start := (pageNum - 1) * pageSize
-	end := start + pageSize
-	if now == selectTime && area == "" {
-		subPush, err := e.GetTodayCache(entId, userId)
-		if err != nil {
-			log.Println(userId, "GetTodayCache Error", err)
-		}
-		if err != nil || subPush == nil || subPush.Date != now || len(subPush.Datas) == 0 {
-			list := e.getDatasFromMysql(MQFW, PushMysql, entId, userId, pageNum, pageSize, selectTime, area, false)
-			subPush = &SubPush{
-				Date:  now,
-				Datas: list,
-			}
-			e.PutTodayCache(entId, userId, subPush)
-		}
-		length := len(subPush.Datas)
-		if end > length {
-			end = length
-		}
-		if start < length {
-			result = subPush.Datas[start:end]
-		}
-	} else if selectTime == "" && area == "" && pageNum <= 5 {
-		allCache, err := e.GetAllCache(entId, userId)
-		if err != nil {
-			log.Println(userId, "GetAllCache Error", err)
-		}
-		if err != nil || allCache == nil || len(allCache) == 0 {
-			allCache = e.getDatasFromMysql(MQFW, PushMysql, entId, userId, 1, AllSubPushCacheSize, selectTime, area, true)
-			e.PutAllCache(entId, userId, allCache)
-		}
-		length := len(allCache)
-		if end > length {
-			end = length
-		}
-		if start < length {
-			result = allCache[start:end]
-		}
-	} else {
-		result = e.getDatasFromMysql(MQFW, PushMysql, entId, userId, pageNum, pageSize, selectTime, area, true)
-	}
-	if result == nil {
-		result = []*SubPushList{}
-	}
-	hasNextPage = len(result) >= pageSize
-	return
-}
-func (e *entnichePush) getDatasFromMysql(MQFW MongodbSim, PushMysql *mysql.Mysql, entId, userId int, pageNum, myPageSize int, selectTime, area string, isLimit bool) (result []*SubPushList) {
-	findSQL := "select id,date,infoid,isvisit,matchkeys,type,1 as isvip from pushentniche where entid=" + fmt.Sprint(entId) + " and userid=" + fmt.Sprint(userId)
-	findStr := ""
-	if selectTime != "" {
-		startTime := selectTime + " 00:00:00"
-		endTime := selectTime + " 23:59:59"
-		st, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local)
-		et, _ := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local)
-		findStr += " and date < " + fmt.Sprint(et.Unix()) + " and date >= " + fmt.Sprint(st.Unix())
-	}
-	if area != "" {
-		findStr += " and area in ("
-		var _area = ""
-		for _, v := range strings.Split(area, ",") {
-			if v == "全部" {
-				continue
-			}
-			if _area != "" {
-				_area += ","
-			}
-			_area += fmt.Sprint(PushMapping.Area[v])
-		}
-		findStr += _area + ")"
-	}
-	start := (pageNum - 1) * myPageSize
-	findStr += " order by id desc"
-	if isLimit {
-		findStr += " limit " + fmt.Sprint(start) + "," + fmt.Sprint(myPageSize)
-	}
-	findSQL = findSQL + findStr
-	//log.Println("findsql:", findSQL)
-	list := PushMysql.SelectBySql(findSQL)
-	if len(*list) > 0 {
-		pushCas := e.GetJyPushs(*list)
-		result = e.GetInfoByIds(MQFW, pushCas)
-	} else {
-		result = []*SubPushList{}
-	}
-	return
-}
-
-//获取历史推送
-func (e *entnichePush) GetJyPushs(datas []map[string]interface{}) (pushCas []*PushCa) {
-	pushCas = []*PushCa{}
-	for _, v := range datas {
-		pushCas = append(pushCas, &PushCa{
-			Date:   Int64All(v["date"]),
-			InfoId: ObjToString(v["infoid"]),
-			Visit:  IntAll(v["isvisit"]),
-			Index:  Int64All(v["id"]),
-			Keys:   strings.Split(ObjToString(v["matchkeys"]), " "),
-			Type:   IntAll(v["type"]),
-			Isvip:  IntAll(v["isvip"]),
-		})
-	}
-	return
-}
-
-//根据id取内容
-func (e *entnichePush) GetInfoByIds(MQFW MongodbSim, pushCas []*PushCa) []*SubPushList {
-	array := make([]*SubPushList, len(pushCas))
-	if len(pushCas) == 0 {
-		return array
-	}
-	m := map[string]bool{}
-	ids := []string{}
-	for _, v := range pushCas {
-		if m[v.InfoId] {
-			continue
-		}
-		m[v.InfoId] = true
-		ids = append(ids, v.InfoId)
-	}
-	infos := map[string]map[string]interface{}{}
-	//redis
-
-	es_ids := []string{}
-	for _, v := range ids {
-		info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%d", v))
-		if info_i != nil {
-			info_m, _ := info_i.(map[string]interface{})
-			info_m["_id"] = v
-			infos[v] = info_m
-		} else {
-			es_ids = append(es_ids, v)
-		}
-	}
-	//	log.Println(es_ids)
-	//elasticsearch
-	if len(es_ids) > 0 {
-		list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
-		if list != nil {
-			for _, v := range *list {
-				_id := ObjToString(v["_id"])
-				infos[_id] = v
-			}
-		}
-	}
-	//mongodb bidding
-	mgo_ids := []primitive.ObjectID{}
-	for _, v := range es_ids {
-		if infos[v] == nil {
-			oid, _ := primitive.ObjectIDFromHex(v)
-			mgo_ids = append(mgo_ids, oid)
-		}
-	}
-	if len(mgo_ids) > 0 {
-		list, ok := MQFW.Find("bidding", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
-		if ok && *list != nil {
-			for _, v := range *list {
-				_id := BsonIdToSId(v["_id"])
-				v["_id"] = _id
-				infos[_id] = v
-			}
-		}
-	}
-	//mongodb bidding_back
-	mgo_back_ids := []primitive.ObjectID{}
-	for _, v := range mgo_ids {
-		if infos[BsonIdToSId(v)] == nil {
-			mgo_back_ids = append(mgo_back_ids, v)
-		}
-	}
-	if len(mgo_back_ids) > 0 {
-		list, ok := MQFW.Find("bidding_back", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
-		if ok && *list != nil {
-			for _, v := range *list {
-				_id := BsonIdToSId(v["_id"])
-				v["_id"] = _id
-				infos[_id] = v
-			}
-		}
-	}
-	//
-	for k, v := range pushCas {
-		info := infos[v.InfoId]
-		if info == nil {
-			info = map[string]interface{}{}
-		}
-		array[k] = SubscribePush.InfoFormat(v, &info)
-	}
-	return array
-}
-
-func (e *entnichePush) Visit(PushMysql *mysql.Mysql, entId, userId, id int) {
-	if id <= 0 {
-		return
-	}
-	PushMysql.UpdateOrDeleteBySql("update pushentniche set isvisit=1 where userid=? and id=?", userId, id)
-	todaySubPush, err := e.GetTodayCache(entId, userId)
-	if err == nil && todaySubPush != nil {
-		for _, v := range todaySubPush.Datas {
-			if v.Ca_index == Int64All(id) {
-				v.Ca_isvisit = 1
-				break
-			}
-		}
-		e.PutTodayCache(entId, userId, todaySubPush)
-	}
-	//
-	allSubPush, err := e.GetAllCache(entId, userId)
-	if err == nil && allSubPush != nil {
-		for _, v := range allSubPush {
-			if v.Ca_index == Int64All(id) {
-				v.Ca_isvisit = 1
-				break
-			}
-		}
-		e.PutAllCache(entId, userId, allSubPush)
-	}
-}
-
-//查看全部列表缓存
-func (e *entnichePush) allKey(entId, userId int) string {
-	return fmt.Sprintf("all_entnichepush_%d_%d", entId, userId)
-}
-
-func (e *entnichePush) PutAllCache(entId, userId int, datas []*SubPushList) {
-	redis.Put("pushcache_2_a", e.allKey(entId, userId), datas, threeDay)
-}
-
-func (e *entnichePush) GetAllCache(entId, userId int) ([]*SubPushList, error) {
-	return e.GetCache("pushcache_2_a", e.allKey(entId, userId))
-}
-
-func (e *entnichePush) GetCache(code, key string) ([]*SubPushList, error) {
-	pc_a, err := redis.GetNewBytes(code, key)
-	if err != nil {
-		return nil, err
-	}
-	if pc_a == nil {
-		return nil, nil
-	}
-	var p []*SubPushList
-	if err := json.Unmarshal(*pc_a, &p); err != nil {
-		return nil, err
-	}
-	return p, nil
-}

+ 0 - 89
src/qfw/util/jy/historypush.go

@@ -1,89 +0,0 @@
-package jy
-
-import (
-	"encoding/json"
-	"fmt"
-	"qfw/util/redis"
-)
-
-/*A缓存中存这个结构体,B缓存不存
- *B缓存初始化的时候,根据A缓存中改结构体type和count属性,判断查询半年内还是半年前年还是半年内+半年前的数据,减少查询次数
- *type==1,如果count==0,说明A缓存中正好500条数据,B缓存可以直接查半年前的数据
- *如果count>0,说明半年内的数据在A缓存中已经有了count条,B缓存取的时候要从count后面开始取
- *type==2,如果count==0,说明A缓存中正好500条数据,B缓存没有可以查询的数据
- *如果count>0,说明半年前的数据在A缓存中已经有了count条,B缓存取的时候要从count后面开始取
- *type==3,如果count==0,说明半年内+半年前的数据正好500条,B缓存没有可以查询的数据
- *如果count>0,说明半年前的数据在A缓存中已经有了count条,B缓存取的时候要从count后面开始取
- */
-type PushSub struct {
-	Type  int //数据构成:1 半年内 2 半年前 3 半年内+半年前
-	Count int
-	Infos []map[string]interface{} //该缓存的数据
-}
-
-var HistoryPush = &historyPush{}
-
-type historyPush struct{}
-
-//从pushcache_2_a中取
-func (h *historyPush) GetPushCache_A(userId string) (*PushSub, error) {
-	pc_a, err := redis.GetNewBytes("pushcache_2_a", h.redisKey(userId))
-	if err != nil {
-		return nil, err
-	}
-	if pc_a == nil {
-		return nil, nil
-	}
-	var p *PushSub
-	if err := json.Unmarshal(*pc_a, &p); err != nil {
-		return nil, err
-	}
-	return p, nil
-}
-
-//往pushcache_2_a中放
-func (h *historyPush) PutPushCache_A(userId string, pc_a *PushSub) {
-	if pc_a.Infos == nil || len(pc_a.Infos) == 0 {
-		return
-	}
-	redis.Put("pushcache_2_a", h.redisKey(userId), pc_a, threeDay)
-}
-
-//从pushcache_2_b中取
-func (h *historyPush) GetPushCache_B(userId string) ([]map[string]interface{}, error) {
-	pc_b, err := redis.GetNewBytes("pushcache_2_b", h.redisKey(userId))
-	if err != nil {
-		return nil, err
-	}
-	if pc_b == nil {
-		return nil, nil
-	}
-	var l []map[string]interface{}
-	if err := json.Unmarshal(*pc_b, &l); err != nil {
-		return nil, err
-	}
-	return l, nil
-}
-
-//往pushcache_2_b中放
-func (h *historyPush) PutPushCache_B(userId string, pc_b []map[string]interface{}) {
-	if pc_b == nil || len(pc_b) == 0 {
-		return
-	}
-	redis.Put("pushcache_2_b", h.redisKey(userId), pc_b, halfOfDay)
-}
-
-//获取redis key
-func (h *historyPush) redisKey(userId string) string {
-	return fmt.Sprintf("push_%s", userId)
-}
-
-func (h *historyPush) ClearPushCache(userId string) {
-	redis.Del("pushcache_2_a", h.redisKey(userId))
-	redis.Del("pushcache_2_b", h.redisKey(userId))
-}
-
-//历史推送记录中单条信息格式化
-func (h *historyPush) InfoFormat(p *PushCa, oldInfo *map[string]interface{}) *SubPushList {
-	return SubscribePush.InfoFormat(p, oldInfo)
-}

+ 0 - 199
src/qfw/util/jy/jy.go

@@ -1,199 +0,0 @@
-package jy
-
-import (
-	"encoding/json"
-	"fmt"
-	"io/ioutil"
-	"log"
-	"net/http"
-	"net/url"
-	"qfw/util"
-	"qfw/util/mail"
-	"qfw/util/sms"
-	"regexp"
-	"strings"
-	"time"
-
-	"github.com/go-xweb/httpsession"
-)
-
-//获取用户合并以前,合并以后的openid
-func GetOldOpenid(s_m_openid, a_m_openid, s_phone string, mergeorder interface{}) string {
-	a_mergeorder, _ := mergeorder.([]interface{})
-	openid := ""
-	if len(a_mergeorder) > 0 {
-		first, _ := a_mergeorder[0].(string)
-		if first == "s_m_openid" {
-			openid = s_m_openid
-		} else if first == "a_m_openid" {
-			openid = a_m_openid
-		} else if first == "s_phone" {
-			openid = s_phone
-		}
-	} else {
-		if s_m_openid != "" {
-			openid = s_m_openid
-		} else if a_m_openid != "" {
-			openid = a_m_openid
-		} else if s_phone != "" {
-			openid = s_phone
-		}
-	}
-	return openid
-}
-
-var MatchSpace = regexp.MustCompile("\\s+")
-var filterReg_3 = regexp.MustCompile("(项目|公告|公示)$")
-var filterReg_2 = regexp.MustCompile("^[)\\)>》】\\]}}〕,,;;::'\"“”。.\\??、/+=\\_—*&……\\^%$¥@!!`~·(\\(<《【\\[{{〔]+$")
-var filterReg_1 = regexp.MustCompile("^([0-9]{1,3}|[零一二三四五六七八九十]{1,2}|联系人?|电话|地址|编号|采购|政府采购|成交|更正|招标|中标|变更|结果)$")
-var filterReg = regexp.MustCompile("^[的人号时元万公告项目地址电话邮编日期联系招标中结果成交项目项目采购采购项目政府采购公告更正公告]+$")
-
-func FilteKey(k string) string {
-	k = strings.TrimSpace(k)
-	k = filterReg_3.ReplaceAllString(k, "")
-	k = filterReg_2.ReplaceAllString(k, "")
-	k = filterReg_1.ReplaceAllString(k, "")
-	k = filterReg.ReplaceAllString(k, "")
-	return k
-}
-
-//超过20个字,截断
-//返回截取后的字符串和截取掉中的前3个字
-func InterceptSearchKW(word string, isIntercept, isFilter bool) (b_word, a_word, s_word string) {
-	if isFilter {
-		word = FilteKey(word)
-	}
-	word = MatchSpace.ReplaceAllString(strings.TrimSpace(word), " ")
-	words := []rune(word)
-	if len(words) > 20 && isIntercept {
-		b_word = string(words[:20])
-		b_word = strings.TrimSpace(b_word)
-		if len(words) > 23 {
-			a_word = string(words[20:23])
-		} else {
-			a_word = string(words[20:])
-		}
-	} else {
-		b_word = word
-	}
-	a_word = strings.TrimSpace(a_word)
-	s_word = MatchSpace.ReplaceAllString(b_word, "+")
-	return
-}
-
-//
-func HttpEs(ques, analyzer, esAddress string) (res string) {
-	surl := esAddress + "/bidding/_analyze"
-	URL, _ := url.Parse(surl)
-	Q := URL.Query()
-	Q.Add("text", ques)
-	Q.Add("analyzer", analyzer)
-	URL.RawQuery = Q.Encode()
-	resp, err := http.Get(URL.String())
-	if err != nil {
-		log.Println("err1:")
-	} else {
-		result, err := ioutil.ReadAll(resp.Body)
-		if err == nil {
-			defer resp.Body.Close()
-			var resmap map[string]interface{}
-			json.Unmarshal(result, &resmap)
-			if resmap != nil {
-				tokens := util.ObjArrToMapArr(resmap["tokens"].([]interface{}))
-				for k, v := range tokens {
-					if FilteKey(util.ObjToString(v["token"])) != "" {
-						if k > 0 {
-							res += "+"
-						}
-						res += util.ObjToString(v["token"])
-					}
-				}
-			}
-		}
-	}
-	return
-}
-
-//发送邮箱验证码
-func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
-	html := fmt.Sprintf(`<div>
-		<div>
-			%s,您好!
-		</div>
-		<div style="padding: 20px 70px 10px 70px;">
-			<p>您正在进行绑定邮箱地址验证,请在邮件验证码输入框输入下方验证码:</p>
-			<span style="font-weight: bold;font-size: x-large;">%s</span>
-			<p>请勿向任何人泄露您收到的验证码。</p>
-			<p>如果您没有使用剑鱼标讯,请忽略此邮件。</p>
-			<p>此为系统邮件,请勿回复。</p>
-			<p>如有疑问,请联系客服 400-108-6670。</p>
-		</div>
-		<div>
-			<p>此致</p>
-			<p>剑鱼标讯</p>
-		</div>	
-	</div>`, to, code)
-
-	for k, v := range auth {
-		if mail.GSendMail("剑鱼标讯", to, "", "", "剑鱼标讯邮箱校验", html, "", "", v) {
-			log.Println(to, fmt.Sprintf("使用%s发送邮件成功", v.User))
-			return true
-		}
-		if k < len(auth)-1 {
-			log.Println(to, fmt.Sprintf("使用%s发送邮件失败!3s后使用其他邮箱尝试", v.User))
-		} else {
-			log.Println(to, fmt.Sprintf("使用%s发送邮件失败!", v.User))
-		}
-		time.Sleep(time.Second * 3)
-	}
-
-	return false
-}
-
-//根据模板发送短信,模板是运营商设定的。
-//第三个参数是可变参数,可以传入多个,但要和模板相匹配
-func SendSMS(tplcode /*模板代码*/, mobile /*手机号码*/ string, param map[string]string) {
-	tmp := []string{}
-	for k, v := range param {
-		tmp = append(tmp, "#"+k+"#="+v)
-	}
-	text := strings.Join(tmp, "&")
-	sms.SendSms(mobile, tplcode, text)
-}
-
-//发送验证码
-func SendPhoneIdentCode(phone string, session *httpsession.Session) bool {
-	lastSentTime := util.Int64All(session.Get("identCodeTime"))
-	//60秒之内不允许重复发
-	if lastSentTime > 0 && time.Now().Unix()-lastSentTime <= 60 {
-		return false
-	}
-	s_ranNum := util.GetRandom(6) //生成随机数
-	session.Set("identCodeValue", s_ranNum)
-	session.Set("identCodeKey", phone)
-	session.Set("identCodeTime", time.Now().Unix())
-	//发送短信
-	param := make(map[string]string)
-	param["code"] = s_ranNum
-	log.Println("短信验证码", phone, s_ranNum)
-	SendSMS("2828060", phone, param)
-	return true
-}
-
-//短信验证码校验
-func CheckPhoneIdent(session *httpsession.Session, code string) string {
-	identCodeValue, _ := session.Get("identCodeValue").(string)
-	if identCodeValue != "" && identCodeValue == code {
-		identCodeKey, _ := session.Get("identCodeKey").(string)
-		ClearPhoneIdentSession(session)
-		return identCodeKey
-	}
-	return ""
-}
-
-//删除短信验证码有关的session
-func ClearPhoneIdentSession(session *httpsession.Session) {
-	session.Del("identCodeValue")
-	session.Del("identCodeKey")
-	session.Del("identCodeTime")
-}

+ 0 - 65
src/qfw/util/jy/pushmapping.go

@@ -1,65 +0,0 @@
-package jy
-
-import (
-	"log"
-	"qfw/util"
-	"qfw/util/mysql"
-)
-
-var PushMapping = &pushMapping{}
-
-type pushMapping struct {
-	Area       map[string]int
-	City       map[string]int
-	Toptype    map[string]int
-	Subtype    map[string]int
-	Buyerclass map[string]int
-}
-
-func (p *pushMapping) Init(Mysql *mysql.Mysql) {
-	infotype := Mysql.SelectBySql("select id,type,name from infotype")
-	p.Toptype = map[string]int{}
-	p.Subtype = map[string]int{}
-	p.Buyerclass = map[string]int{}
-	for _, v := range *infotype {
-		id := util.IntAll(v["id"])
-		tp := util.IntAll(v["type"])
-		name := util.ObjToString(v["name"])
-		if tp == 1 {
-			p.Toptype[name] = id
-		} else if tp == 2 {
-			p.Subtype[name] = id
-		} else if tp == 3 {
-			p.Buyerclass[name] = id
-		}
-	}
-	if len(p.Toptype) == 0 {
-		log.Fatalln("PushMapping Toptype Init Error")
-	}
-	if len(p.Subtype) == 0 {
-		log.Fatalln("PushMapping Subtype Init Error")
-	}
-	if len(p.Buyerclass) == 0 {
-		log.Fatalln("PushMapping Buyerclass Init Error")
-	}
-	//
-	p.Area = map[string]int{}
-	p.City = map[string]int{}
-	province := Mysql.SelectBySql("select id,level,name from province")
-	for _, v := range *province {
-		id := util.IntAll(v["id"])
-		level := util.IntAll(v["level"])
-		name := util.ObjToString(v["name"])
-		if level == 1 {
-			p.Area[name] = id
-		} else if level == 2 {
-			p.City[name] = id
-		}
-	}
-	if len(p.Area) == 0 {
-		log.Fatalln("PushMapping Area Init Error")
-	}
-	if len(p.City) == 0 {
-		log.Fatalln("PushMapping City Init Error")
-	}
-}

+ 0 - 512
src/qfw/util/jy/subscribepush.go

@@ -1,512 +0,0 @@
-package jy
-
-import (
-	"encoding/json"
-	"fmt"
-	"log"
-	. "qfw/util"
-	"qfw/util/elastic"
-	. "qfw/util/mongodb"
-	"qfw/util/mysql"
-	"qfw/util/redis"
-	"strings"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-const (
-	threeDay  = 172800
-	halfOfDay = 43200
-)
-
-type SubPushList struct {
-	Id              string      `json:"_id"`
-	Title           string      `json:"title"`
-	Area            string      `json:"area"`
-	Buyerclass      string      `json:"buyerclass"`
-	Type            string      `json:"type"`
-	S_subscopeclass string      `json:"s_subscopeclass"`
-	Publishtime     int64       `json:"publishtime"`
-	Ca_index        int64       `json:"ca_index"`
-	Ca_date         int64       `json:"ca_date"`
-	Ca_isvisit      int         `json:"ca_isvisit"`
-	Ca_isvip        int         `json:"ca_isvip"`
-	Ca_type         int         `json:"ca_type"`
-	Matchkeys       []string    `json:"matchkeys"`
-	Budget          interface{} `json:"budget"`
-	Bidamount       interface{} `json:"bidamount"`
-}
-
-const (
-	pageSize            = 50
-	AllSubPushCacheSize = 250
-	query               = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget"],"from":0,"size":%d}`
-	mongodb_fields      = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "buyerclass":1,"budget":1,"bidamount":1}`
-)
-
-var Mysql_table = "pushsubscribe"
-
-//
-
-type SubPush struct {
-	Date  string
-	Datas []*SubPushList
-}
-
-type PushCa struct {
-	Date   int64
-	InfoId string
-	Visit  int
-	Index  int64
-	Keys   []string
-	Type   int
-	Isvip  int
-}
-
-var SubscribePush = &subscribePush{}
-
-type subscribePush struct {
-}
-
-//从pushcache_2_a中取
-func (h *subscribePush) GetTodayCache(userId string) (*SubPush, error) {
-	pc_a, err := redis.GetNewBytes("pushcache_2_b", h.todayKey(userId))
-	if err != nil {
-		return nil, err
-	}
-	if pc_a == nil {
-		return nil, nil
-	}
-	var p *SubPush
-	if err := json.Unmarshal(*pc_a, &p); err != nil {
-		return nil, err
-	}
-	return p, nil
-}
-
-//往pushcache_2_a中放
-func (h *subscribePush) PutTodayCache(userId string, pc_a *SubPush) {
-	redis.Put("pushcache_2_b", h.todayKey(userId), pc_a, threeDay)
-}
-
-//获取redis key
-func (s *subscribePush) todayKey(userId string) string {
-	return fmt.Sprintf("subpush_%s", userId)
-}
-
-//历史推送记录中单条信息格式化
-func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}) *SubPushList {
-	area := ObjToString((*info)["area"])
-	if area == "A" {
-		area = "全国"
-	}
-	industry := ObjToString((*info)["s_subscopeclass"])
-	scs := strings.Split(industry, ",")
-	if len(scs) > 0 {
-		industry = scs[0]
-		if industry != "" {
-			iss := strings.Split(industry, "_")
-			if len(iss) > 0 {
-				industry = iss[0]
-			}
-		}
-	}
-	infotype := ObjToString((*info)["subtype"])
-	if infotype == "" {
-		infotype = ObjToString((*info)["toptype"])
-	}
-	if infotype == "" {
-		infotype = ObjToString((*info)["type"])
-		if infotype == "tender" {
-			infotype = "招标"
-		} else if infotype == "bid" {
-			infotype = "中标"
-		}
-	}
-	_id := p.InfoId
-	if _id == "" {
-		_id = ObjToString((*info)["_id"])
-	}
-	return &SubPushList{
-		Id:              EncodeArticleId2ByCheck(_id),
-		Title:           ObjToString((*info)["title"]),
-		Area:            area,
-		Buyerclass:      ObjToString((*info)["buyerclass"]),
-		Type:            infotype,
-		S_subscopeclass: industry,
-		Publishtime:     Int64All((*info)["publishtime"]),
-		Ca_index:        p.Index,
-		Ca_date:         p.Date,
-		Ca_isvisit:      p.Visit,
-		Ca_isvip:        p.Isvip,
-		Ca_type:         p.Type,
-		Matchkeys:       p.Keys,
-		Budget:          (*info)["budget"],
-		Bidamount:       (*info)["bidamount"],
-	}
-}
-
-func (s *subscribePush) Datas(MQFW MongodbSim, PushMysql *mysql.Mysql, userId string, pageNum int, selectTime, area string) (hasNextPage bool, result []*SubPushList) {
-	if userId == "" {
-		return
-	}
-	if pageNum < 1 {
-		pageNum = 1
-	}
-	now := NowFormat(Date_Short_Layout)
-	start := (pageNum - 1) * pageSize
-	end := start + pageSize
-	if now == selectTime && area == "" {
-		subPush, err := s.GetTodayCache(userId)
-		if err != nil {
-			log.Println(userId, "GetTodayCache Error", err)
-		}
-		if err != nil || subPush == nil || subPush.Date != now || len(subPush.Datas) == 0 {
-			list := s.getDatasFromMysql(MQFW, PushMysql, userId, pageNum, pageSize, selectTime, area, false)
-			subPush = &SubPush{
-				Date:  now,
-				Datas: list,
-			}
-			s.PutTodayCache(userId, subPush)
-		}
-		length := len(subPush.Datas)
-		if end > length {
-			end = length
-		}
-		if start < length {
-			result = subPush.Datas[start:end]
-		}
-	} else if selectTime == "" && area == "" && pageNum <= 5 {
-		allCache, err := s.GetAllCache(userId)
-		if err != nil {
-			log.Println(userId, "GetAllCache Error", err)
-		}
-		if err != nil || allCache == nil || len(allCache) == 0 {
-			allCache = s.getDatasFromMysql(MQFW, PushMysql, userId, 1, AllSubPushCacheSize, selectTime, area, true)
-			s.PutAllCache(userId, allCache)
-		}
-		length := len(allCache)
-		if end > length {
-			end = length
-		}
-		if start < length {
-			result = allCache[start:end]
-		}
-	} else {
-		result = s.getDatasFromMysql(MQFW, PushMysql, userId, pageNum, pageSize, selectTime, area, true)
-	}
-	if result == nil {
-		result = []*SubPushList{}
-	}
-	hasNextPage = len(result) >= pageSize
-	return
-}
-func (s *subscribePush) getDatasFromMysql(MQFW MongodbSim, PushMysql *mysql.Mysql, userId string, pageNum, myPageSize int, selectTime, area string, isLimit bool) (result []*SubPushList) {
-	findSQL := "select id,date,infoid,isvisit,matchkeys,type,isvip from pushsubscribe where userid = '" + userId + "'"
-	findStr := ""
-	if selectTime != "" {
-		startTime := selectTime + " 00:00:00"
-		endTime := selectTime + " 23:59:59"
-		st, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local)
-		et, _ := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local)
-		findStr += " and date < " + fmt.Sprint(et.Unix()) + " and date >= " + fmt.Sprint(st.Unix())
-	}
-	if area != "" {
-		findStr += " and city in ("
-		var _area = ""
-		for _, v := range strings.Split(area, ",") {
-			if v == "全部" {
-				continue
-			}
-			if _area != "" {
-				_area += ","
-			}
-			_area += fmt.Sprint(PushMapping.City[v])
-		}
-		findStr += _area + ")"
-	}
-	start := (pageNum - 1) * myPageSize
-	findStr += " order by id desc"
-	if isLimit {
-		findStr += " limit " + fmt.Sprint(start) + "," + fmt.Sprint(myPageSize)
-	}
-	findSQL = findSQL + findStr
-	//	log.Println("findsql:", findSQL)
-	list := PushMysql.SelectBySql(findSQL)
-	if len(*list) > 0 {
-		pushCas := s.GetJyPushs(*list)
-		result = s.GetInfoByIds(MQFW, pushCas)
-	} else {
-		result = []*SubPushList{}
-	}
-	return
-}
-
-//获取历史推送
-func (s *subscribePush) GetJyPushs(datas []map[string]interface{}) (pushCas []*PushCa) {
-	pushCas = []*PushCa{}
-	for _, v := range datas {
-		pushCas = append(pushCas, &PushCa{
-			Date:   Int64All(v["date"]),
-			InfoId: ObjToString(v["infoid"]),
-			Visit:  IntAll(v["isvisit"]),
-			Index:  Int64All(v["id"]),
-			Keys:   strings.Split(ObjToString(v["matchkeys"]), " "),
-			Type:   IntAll(v["type"]),
-			Isvip:  IntAll(v["isvip"]),
-		})
-	}
-	return
-}
-
-//根据id取内容
-func (s *subscribePush) GetInfoByIds(MQFW MongodbSim, pushCas []*PushCa) []*SubPushList {
-	array := make([]*SubPushList, len(pushCas))
-	if len(pushCas) == 0 {
-		return array
-	}
-	m := map[string]bool{}
-	ids := []string{}
-	for _, v := range pushCas {
-		if m[v.InfoId] {
-			continue
-		}
-		m[v.InfoId] = true
-		ids = append(ids, v.InfoId)
-	}
-	infos := map[string]map[string]interface{}{}
-	//redis
-
-	es_ids := []string{}
-	for _, v := range ids {
-		info_i := redis.Get("pushcache_1", fmt.Sprintf("info_%s", v))
-		if info_i != nil {
-			info_m, _ := info_i.(map[string]interface{})
-			info_m["_id"] = v
-			infos[v] = info_m
-		} else {
-			es_ids = append(es_ids, v)
-		}
-	}
-	//	log.Println(es_ids)
-	//elasticsearch
-	if len(es_ids) > 0 {
-		list := elastic.Get("bidding", "bidding", fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
-		if list != nil {
-			for _, v := range *list {
-				_id := ObjToString(v["_id"])
-				infos[_id] = v
-			}
-		}
-	}
-	//mongodb bidding
-	mgo_ids := []primitive.ObjectID{}
-	for _, v := range es_ids {
-		if infos[v] == nil {
-			oid, _ := primitive.ObjectIDFromHex(v)
-			mgo_ids = append(mgo_ids, oid)
-		}
-	}
-	if len(mgo_ids) > 0 {
-		list, ok := MQFW.Find("bidding", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
-		if ok && *list != nil {
-			for _, v := range *list {
-				_id := BsonIdToSId(v["_id"])
-				v["_id"] = _id
-				infos[_id] = v
-			}
-		}
-	}
-	//mongodb bidding_back
-	mgo_back_ids := []primitive.ObjectID{}
-	for _, v := range mgo_ids {
-		if infos[BsonIdToSId(v)] == nil {
-			mgo_back_ids = append(mgo_back_ids, v)
-		}
-	}
-	if len(mgo_back_ids) > 0 {
-		list, ok := MQFW.Find("bidding_back", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
-		if ok && *list != nil {
-			for _, v := range *list {
-				_id := BsonIdToSId(v["_id"])
-				v["_id"] = _id
-				infos[_id] = v
-			}
-		}
-	}
-	//
-	for k, v := range pushCas {
-		info := infos[v.InfoId]
-		if info == nil {
-			info = map[string]interface{}{}
-		}
-		array[k] = s.InfoFormat(v, &info)
-	}
-	return array
-}
-
-//保存最近7天的数据到历史记录
-func (s *subscribePush) MakeHistoryDatas(MQFW MongodbSim, PushMysql *mysql.Mysql, userId string, PushView func(userid, allquery, field string, pageNum, pageSize int) (keys []interface{}, list *[]map[string]interface{})) (bool, []*SubPushList) {
-	log.Println("匹配最近7天数据", userId)
-	field := `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","buyerclass","budget","bidamount"`
-	allquery := `{"range":{"publishtime":{"gt":%s}}}`
-	allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
-	//allquery = ``
-	keys, list := PushView(userId, allquery, field, 1, 50)
-	if list == nil || len(*list) == 0 {
-		return true, nil
-	}
-	matchkeys := []string{}
-	for _, v := range keys {
-		matchkeys = append(matchkeys, strings.Join(ObjArrToStringArr(v.([]interface{})), "+"))
-	}
-	publishTitle := map[string]bool{}
-	now := time.Now().Unix()
-	var array []*SubPushList
-	for i := len(*list) - 1; i >= 0; i-- {
-		v := (*list)[i]
-		var myInsert = make(map[string]interface{})
-		title := strings.Replace(v["title"].(string), "\n", "", -1)
-		area_check := ObjToString(v["area"])
-		if area_check == "A" {
-			area_check = "全国"
-		}
-		if publishTitle[area_check+title] {
-			continue
-		} else {
-			publishTitle[area_check+title] = true
-		}
-		myInsert["userid"] = userId
-		_id := ObjToString(v["_id"])
-		myInsert["infoid"] = _id
-		redisKey := fmt.Sprintf("pushinfo_%s_%s", userId, _id)
-		if isExists, _ := redis.Exists("pushcache_2_a", redisKey); isExists {
-			continue
-		}
-		myInsert["date"] = now
-		myInsert["matchkeys"] = strings.Join(matchkeys, " ")
-		if area_check != "" {
-			if area_check == "全国" {
-				myInsert["area"] = 0
-			} else if area_mapping, ok := PushMapping.Area[area_check]; ok {
-				myInsert["area"] = area_mapping
-			}
-		}
-		if city_check := ObjToString(v["city"]); city_check != "" {
-			if city_mapping, ok := PushMapping.City[city_check]; ok {
-				myInsert["city"] = city_mapping
-			}
-		}
-		if subtype := ObjToString(v["subtype"]); subtype != "" {
-			if subtype_mapping, ok := PushMapping.Subtype[subtype]; ok {
-				myInsert["subtype"] = subtype_mapping
-			}
-		}
-		if toptype := ObjToString(v["toptype"]); toptype != "" {
-			if toptype_mapping, ok := PushMapping.Toptype[toptype]; ok {
-				myInsert["toptype"] = toptype_mapping
-			}
-		}
-		if buyerclass := ObjToString(v["buyerclass"]); buyerclass != "" {
-			if buyerclass_mapping, ok := PushMapping.Buyerclass[buyerclass]; ok {
-				myInsert["buyerclass"] = buyerclass_mapping
-			}
-		}
-		id := PushMysql.Insert("pushsubscribe", myInsert)
-		if id > 0 {
-			redis.Put("pushcache_2_a", redisKey, 1, 86400)
-		} else {
-			continue
-		}
-		array = append(array, s.InfoFormat(&PushCa{
-			InfoId: _id,
-			Date:   now,
-			Index:  id,
-			Keys:   matchkeys,
-		}, &v))
-	}
-	var resultList []*SubPushList
-	for i := len(array) - 1; i >= 0; i-- {
-		resultList = append(resultList, array[i])
-	}
-	return true, resultList
-}
-
-//获取用户信息
-func (s *subscribePush) UserInfo(MQFW MongodbSim, userId string) (*map[string]interface{}, int64) {
-	user, ok := MQFW.FindById("user", userId, `{"s_m_openid":1,"a_m_openid":1,"s_phone":1,"a_mergeorder":1,"o_jy":1,"l_firstpushtime":1,"i_vip_status":1,"l_vip_endtime":1,"o_vipjy":1}`)
-	if !ok || user == nil {
-		return nil, 0
-	}
-	return user, Int64All((*user)["l_firstpushtime"])
-}
-func (s *subscribePush) Visit(PushMysql *mysql.Mysql, userId string, id int) {
-	if userId == "" {
-		return
-	}
-	PushMysql.UpdateOrDeleteBySql("update pushsubscribe set isvisit=1 where userid=? and id=?", userId, id)
-	todaySubPush, err := s.GetTodayCache(userId)
-	if err == nil && todaySubPush != nil {
-		for _, v := range todaySubPush.Datas {
-			if v.Ca_index == Int64All(id) {
-				v.Ca_isvisit = 1
-				break
-			}
-		}
-		s.PutTodayCache(userId, todaySubPush)
-	}
-	//
-	allSubPush, err := s.GetAllCache(userId)
-	if err == nil && allSubPush != nil {
-		for _, v := range allSubPush {
-			if v.Ca_index == Int64All(id) {
-				v.Ca_isvisit = 1
-				break
-			}
-		}
-		s.PutAllCache(userId, allSubPush)
-	}
-}
-
-//查看全部列表缓存
-func (s *subscribePush) allKey(userId string) string {
-	return fmt.Sprintf("all_subpush_%s", userId)
-}
-
-func (s *subscribePush) PutAllCache(userId string, datas []*SubPushList) {
-	redis.Put("pushcache_2_a", s.allKey(userId), datas, threeDay)
-}
-
-func (s *subscribePush) GetAllCache(userId string) ([]*SubPushList, error) {
-	return s.GetCache("pushcache_2_a", s.allKey(userId))
-}
-
-//最近7天50条缓存
-func (s *subscribePush) sevenDayKey(userId string) string {
-	return fmt.Sprintf("7day_subpush_%s", userId)
-}
-
-func (s *subscribePush) PutSevenDayCache(userId string, datas []*SubPushList) {
-	redis.Put("pushcache_2_a", s.sevenDayKey(userId), datas, 7*24*60*60)
-}
-
-//从pushcache_2_a中取
-func (s *subscribePush) GetSevenDayCache(userId string) ([]*SubPushList, error) {
-	return s.GetCache("pushcache_2_a", s.sevenDayKey(userId))
-}
-
-func (s *subscribePush) GetCache(code, key string) ([]*SubPushList, error) {
-	pc_a, err := redis.GetNewBytes(code, key)
-	if err != nil {
-		return nil, err
-	}
-	if pc_a == nil {
-		return nil, nil
-	}
-	var p []*SubPushList
-	if err := json.Unmarshal(*pc_a, &p); err != nil {
-		return nil, err
-	}
-	return p, nil
-}

+ 0 - 205
src/qfw/util/jy/user_merge.go

@@ -1,205 +0,0 @@
-package jy
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"log"
-	qutil "qfw/util"
-	. "qfw/util/mongodb"
-	"qfw/util/redis"
-	"regexp"
-	"strings"
-	"time"
-
-	"github.com/go-xweb/httpsession"
-)
-
-var WxClientReg = regexp.MustCompile(`.*micromessenger.*`)
-var aboutTableRemove = []string{"pushspace", "pushspace_entniche", "pushspace_entniche_project", "pushspace_entniche_temp", "pushspace_entniche_wait", "pushspace_fail", "pushspace_project", "pushspace_statistic", "pushspace_temp", "pushspace_vip", "pushspace_fail"}
-
-//自动合并两个账户、其中一个为空(无订阅、无关注项目、无关注企业)
-func AutoMerge(mg MongodbSim, sess *httpsession.Session) (bool, error) {
-	userId := qutil.ObjToString(sess.Get("userId"))
-	if userId == "" {
-		return false, errors.New("未获取到userId")
-	}
-	thisUser, _ := mg.FindById("user", userId, nil)
-	if thisUser == nil || len(*thisUser) == 0 {
-		return false, errors.New("未获取到用户信息")
-	}
-	s_m_phone := qutil.ObjToString((*thisUser)["s_m_phone"])
-	s_phone := qutil.ObjToString((*thisUser)["s_phone"])
-	if s_phone == s_m_phone {
-		return true, nil
-	}
-	otherUser := &map[string]interface{}{}
-	if s_m_phone != "" {
-		otherUser, _ = mg.FindOneByField("user", map[string]interface{}{"i_appid": 2, "s_phone": s_m_phone, "s_m_phone": map[string]interface{}{"$ne": s_m_phone}}, nil)
-		if otherUser == nil || len(*otherUser) == 0 { //微信端合并 app端
-			return true, nil
-		}
-	} else {
-		otherUser, _ = mg.FindOneByField("user", map[string]interface{}{"i_appid": 2, "s_m_phone": s_phone, "s_phone": map[string]interface{}{"$ne": s_phone}}, nil)
-		if otherUser == nil || len(*otherUser) == 0 { //app端合并 微信端
-			return true, nil
-		}
-	}
-
-	thisNull, otherNull := func() (t, o bool) {
-		t, o = true, true
-		if checNullkeyset((*qutil.ObjToMap((*thisUser)["o_jy"]))["a_key"]) || (*thisUser)["o_vipjy"] != nil {
-			t = false
-		}
-		if checNullkeyset((*qutil.ObjToMap((*otherUser)["o_jy"]))["a_key"]) || (*otherUser)["o_vipjy"] != nil {
-			o = false
-		}
-		if !t && !o { //账户都不为空
-			return
-		}
-		if t {
-			id := BsonIdToSId((*thisUser)["_id"])
-			if mg.Count("jylab_followent", map[string]interface{}{"s_userid": id}) != 0 {
-				t = false
-			} else {
-				if mg.Count("follow_project", map[string]interface{}{"s_userid": id}) != 0 {
-					t = false
-				}
-			}
-		}
-		if o {
-			id := BsonIdToSId((*otherUser)["_id"])
-			if mg.Count("jylab_followent", map[string]interface{}{"s_userid": id}) != 0 {
-				o = false
-			} else {
-				if mg.Count("follow_project", map[string]interface{}{"s_userid": id}) != 0 {
-					o = false
-				}
-			}
-		}
-		return
-	}()
-
-	if !thisNull && !otherNull {
-		return true, nil
-	}
-	log.Println("null log", thisNull, otherNull)
-	//存在一个空账户
-	var finalUser, removeUser *map[string]interface{}
-	if thisNull {
-		finalUser = otherUser
-		removeUser = thisUser
-	} else {
-		finalUser = thisUser
-		removeUser = otherUser
-	}
-
-	if !MergeData(mg, finalUser, removeUser) {
-		return false, errors.New("数据库操作出错")
-	}
-	log.Printf("[%s,%s]账户自动合并 合并结果 %+v\n", BsonIdToSId((*finalUser)["_id"]), BsonIdToSId((*removeUser)["_id"]), finalUser)
-	go MoveUser(mg, removeUser)
-	FlushSession(sess, finalUser, true)
-	return true, nil
-}
-
-func checNullkeyset(a_key interface{}) bool {
-	if a_key == nil {
-		return false
-	}
-	arr, ok := a_key.([]interface{})
-	if ok && len(arr) > 0 {
-		return true
-	}
-	return false
-}
-
-func MergeData(mg MongodbSim, saveRes, otherRes *map[string]interface{}) bool {
-	saveResIsWx := qutil.ObjToString((*saveRes)["s_phone"]) == ""
-	for k, v := range *otherRes {
-		if _, ok := (*saveRes)[k]; !ok {
-			(*saveRes)[k] = v
-		} else if k == "s_unionid" { //s_unionid保留微信
-			if !saveResIsWx {
-				(*saveRes)[k] = (*otherRes)[k]
-			}
-		} else if k == "o_jy" || k == "o_vipjy" {
-			if saveResIsWx { //保留app推送开关设置
-				(*qutil.ObjToMap((*saveRes)[k]))["i_apppush"] = (*qutil.ObjToMap((*otherRes)[k]))["i_apppush"]
-			} else { //保留微信推送开关设置
-				(*qutil.ObjToMap((*saveRes)[k]))["i_wxpush"] = (*qutil.ObjToMap((*otherRes)[k]))["i_wxpush"]
-			}
-		}
-	}
-	(*saveRes)["i_ispush"] = 1
-	delete(*saveRes, "s_m_phone")
-	if !mg.UpdateById("user", BsonIdToSId((*saveRes)["_id"]), saveRes) {
-		return false
-	}
-	return true
-}
-
-func FlushSession(sess *httpsession.Session, userData *map[string]interface{}, isWx bool) {
-	sess.Set("userId", BsonIdToSId((*userData)["_id"]))
-	sess.Set("s_jpushid", (*userData)["s_jpushid"])
-	sess.Set("s_m_openid", (*userData)["s_m_openid"])
-	sess.Set("s_opushid", (*userData)["s_opushid"])
-	sess.Set("s_appponetype", (*userData)["s_appponetype"])
-	sess.Set("s_appversion", (*userData)["s_appversion"])
-	sess.Set("s_headimageurl", strings.Replace(qutil.ObjToString((*userData)["s_headimageurl"]), "http://", "https://", 1))
-	log.Println("isWx", isWx)
-	if phone := qutil.ObjToString((*userData)["s_phone"]); phone != "" && !isWx {
-		sess.Set("s_phone", phone)
-		phone = string(phone[0:3]) + "****" + string(phone[len(phone)-4:])
-		sess.Set("s_nickname", phone)
-	} else {
-		sess.Set("s_nickname", (*userData)["s_nickname"])
-	}
-}
-
-func MoveUser(mg MongodbSim, otherRes *map[string]interface{}) {
-	(*otherRes)["l_mergeData"] = time.Now().Unix()
-	userId := BsonIdToSId((*otherRes)["_id"])
-	(*otherRes)["s_userId"] = userId
-	if mg.Save("user_merge", otherRes) == "" {
-		log.Println("保存user_merge失败", otherRes)
-		return
-	}
-	if !mg.Del("user", map[string]interface{}{"_id": StringTOBsonId(userId)}) {
-		log.Println("删除user信息失败", otherRes)
-		return
-	}
-	redis.Put("session", fmt.Sprintf("usermerge_delete_%s", userId), 1, 7*24*60*60) //session最长期限7天
-	//删除mysql表相关数据
-	for _, tableName := range aboutTableRemove {
-		if !mg.Del(tableName, map[string]interface{}{"userid": userId}) {
-			log.Printf("用户合并删除相关数据出错:用户%s,表明%s\n", userId, tableName)
-		}
-	}
-}
-
-//生成签名,返回手机端
-func CreateAppSign(userid, rid string) string {
-	u := &struct {
-		CreateTime int64  `json:"createtime"`
-		OpenId     string `json:"openid"`
-		UserId     string `json:"userid"`
-		Rid        string `json:"rid"`
-		Sign       string `json:"sign"`
-		Type       int    `json:"type"`
-	}{
-		UserId:     userid,
-		Type:       2,
-		CreateTime: time.Now().Unix(),
-		Rid:        rid,
-	}
-	u.Sign = qutil.GetMd5String(fmt.Sprintf("createtime=%d&userid=%s&rid=%s&type=%d", u.CreateTime, u.UserId, u.Rid, u.Type))
-	b, err := json.Marshal(u)
-	if err != nil {
-		log.Println(err)
-	}
-	sign := string(b)
-	sign = se.EncodeString(sign)
-	sign = strings.Replace(sign, "+", "%2B", -1)
-	return sign
-}