Эх сурвалжийг харах

Merge branch 'develop' of 192.168.3.17:zhanghongbo/qfw into develop

zhangjinkun@topnet.net.cn 9 жил өмнө
parent
commit
5223020469
72 өөрчлөгдсөн 2080 нэмэгдсэн , 1535 устгасан
  1. 2 0
      common/src/qfw/util/elastic/elasticutil.go
  2. 6 0
      common/src/qfw/util/elastic/elasticutil_test.go
  3. 28 0
      common/src/qfw/util/redis/redisutil.go
  4. 5 0
      common/src/qfw/util/redis/redisutil_test.go
  5. 6 0
      common/src/qfw/util/rpc/push.go
  6. 1 0
      core/src/config.json
  7. 66 4
      core/src/qfw/active/activemanage.go
  8. 1 0
      core/src/qfw/coreconfig/SysConfig.go
  9. 22 0
      core/src/qfw/coreutil/counterutil.go
  10. 13 0
      core/src/qfw/coreutil/counterutil_test.go
  11. 36 1
      core/src/qfw/front/index.go
  12. 2 1
      core/src/qfw/manage/auditing.go
  13. 23 0
      core/src/qfw/mobile/wxmenu.go
  14. 4 3
      core/src/qfw/search/search.go
  15. 51 0
      core/src/qfw/search/searchService.go
  16. 2 0
      core/src/qfw/yellowpage/yellowpage.go
  17. 13 3
      core/src/qfw/yellowpage/yellowpagemanager.go
  18. 1 1
      core/src/timetask.json
  19. 3 1
      core/src/web/staticres/css/dev-qfw.css
  20. 97 72
      core/src/web/staticres/css/entcommunity.css
  21. 70 6
      core/src/web/staticres/css/index-new.css
  22. 4 0
      core/src/web/staticres/css/qfw.css
  23. BIN
      core/src/web/staticres/fonts.zip
  24. BIN
      core/src/web/staticres/fonts/qimingxing.eot
  25. BIN
      core/src/web/staticres/fonts/qimingxing.svg
  26. BIN
      core/src/web/staticres/fonts/qimingxing.ttf
  27. BIN
      core/src/web/staticres/fonts/qimingxing.woff
  28. BIN
      core/src/web/staticres/images/activeimages/btn_end.png
  29. BIN
      core/src/web/staticres/images/entcommunity/qq.png
  30. BIN
      core/src/web/staticres/images/entcommunity/relation.png
  31. BIN
      core/src/web/staticres/images/entcommunity/triangle.png
  32. BIN
      core/src/web/staticres/images/u0115.png
  33. BIN
      core/src/web/staticres/images/u0116.png
  34. BIN
      core/src/web/staticres/images/u0117.png
  35. BIN
      core/src/web/staticres/images/u0118.png
  36. BIN
      core/src/web/staticres/images/u0119.png
  37. BIN
      core/src/web/staticres/images/u0120.png
  38. BIN
      core/src/web/staticres/images/u2181.png
  39. 73 752
      core/src/web/staticres/js/entportrait.js
  40. 18 18
      core/src/web/staticres/js/qfw.js
  41. 722 0
      core/src/web/staticres/js/relation.js
  42. 2 2
      core/src/web/staticres/wxswordfish/share.js
  43. 10 12
      core/src/web/templates/_err.html
  44. 22 16
      core/src/web/templates/active/luckdraw.html
  45. 9 0
      core/src/web/templates/common/errorhead.html
  46. 0 4
      core/src/web/templates/common/login.html
  47. 2 2
      core/src/web/templates/common/swordfishhead.html
  48. 1 1
      core/src/web/templates/common/top.html
  49. 122 1
      core/src/web/templates/index.html
  50. 133 80
      core/src/web/templates/yellowpage/enterpriseinfo.html
  51. 9 11
      core/src/web/templates/yellowpage/error.html
  52. 1 61
      push/src/config.json
  53. 13 0
      push/src/main.go
  54. 25 0
      push/src/qfw/push/bid/bid_test.go
  55. 9 208
      push/src/qfw/push/bid/bidpushjob.go
  56. 25 35
      push/src/qfw/push/cache.go
  57. 16 0
      push/src/qfw/push/dfa/interestanalysis_test.go
  58. 221 0
      push/src/qfw/push/dopush/dopush.go
  59. 36 0
      push/src/qfw/push/rpcpush/rpcpush.go
  60. 9 212
      push/src/qfw/push/tender/tenderpushjob.go
  61. 4 1
      push/src/qfw/push/weixincall.go
  62. 4 6
      weixin/src/config.json
  63. 10 0
      weixin/src/qfw/weixin/dao/logsdao.go
  64. 43 0
      weixin/src/qfw/weixin/dao/sharedao.go
  65. 2 7
      weixin/src/qfw/weixin/dao/userdao.go
  66. 9 1
      weixin/src/qfw/weixin/msgtxtchandler.go
  67. 46 0
      weixin/src/qfw/weixin/rpc/share.go
  68. 11 4
      weixin/src/qfw/weixin/subscribehandler.go
  69. 13 0
      weixin/src/qfw/weixin/txt_test.go
  70. 2 0
      weixin/src/qfw/weixin/weixinsdk.go
  71. 1 9
      weixin/src/qfw/weixinconfig/config_test.go
  72. 1 0
      weixin/src/qfw/weixinconfig/weixinconfig.go

+ 2 - 0
common/src/qfw/util/elastic/elasticutil.go

@@ -580,6 +580,8 @@ func ConverData(ent *map[string]interface{}) map[string]interface{} {
 	tmp2["OpScope"] = tmp["OpScope"]
 	tmp2["OpState"] = tmp["OpState"]
 	tmp2["s_submitid"] = tmp["s_submitid"]
+	tmp2["l_submittime"] = tmp["l_submittime"]
+	tmp2["s_submitname"] = tmp["s_submitname"]
 	//增加营业状态排序
 	if tmp2["OpState"] == "06" {
 		tmp2["OpSint"] = true

+ 6 - 0
common/src/qfw/util/elastic/elasticutil_test.go

@@ -183,3 +183,9 @@ func Test_date(t *testing.T) {
 	s := time.Now().UnixNano()
 	log.Println(s, time.Now().Unix(), fmt.Sprintf("%d", s)[4:12], 999999/60/60)
 }
+
+func Test_Getpage(t *testing.T) {
+	InitElasticSize("http://192.168.3.18:9800", 1)
+	data := *GetPage("enterprise", "enterprise", `{"s_action":"01"}`, `{"l_submittime":-1}`, `"EntName","l_submittime","_id"`, 0, 8)
+	log.Println("data:", data)
+}

+ 28 - 0
common/src/qfw/util/redis/redisutil.go

@@ -386,3 +386,31 @@ func DelByPattern(key string) {
 
 }
 **/
+//自增计数器
+func Incr(code, key string) int64 {
+	defer func() {
+		if r := recover(); r != nil {
+			log.Println("[E]", r)
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
+	conn := RedisPool[code].Get()
+	defer conn.Close()
+	ret, err := conn.Do("INCR", key)
+	if nil != err {
+		log.Println("redisutil-GetError", err)
+	} else {
+		if res, ok := ret.(int64); ok {
+			return res
+		} else {
+			return 0
+		}
+	}
+	return 0
+}

+ 5 - 0
common/src/qfw/util/redis/redisutil_test.go

@@ -56,3 +56,8 @@ func Test_other(t *testing.T) {
 	}
 	<-pools
 }
+
+func TestIncr(t *testing.T) {
+	InitRedis("sso=192.168.3.14:1379")
+	log.Println(Incr("sso", "user"))
+}

+ 6 - 0
common/src/qfw/util/rpc/push.go

@@ -0,0 +1,6 @@
+package rpc
+
+type PushData struct {
+	Mopenid  string
+	PushType map[string]string
+}

+ 1 - 0
core/src/config.json

@@ -29,6 +29,7 @@
     "chatServer": "127.0.0.1:83",
     "chatRpc": "127.0.0.1:88",
 	"creditRpc":"127.0.0.1:8765",
+	"pushRpc":"127.0.0.1:8766",
 	"domainName":"http://www.qimingxing.info"
 
 }

+ 66 - 4
core/src/qfw/active/activemanage.go

@@ -6,11 +6,14 @@ package active
 import (
 	"fmt"
 	"github.com/go-xweb/xweb"
+	"gopkg.in/mgo.v2/bson"
 	"math/rand"
 	. "qfw/coreconfig"
+	"qfw/coreutil"
 	mob "qfw/mobile"
 	. "qfw/util"
 	. "qfw/util/mongodb"
+	qrpc "qfw/util/rpc"
 	"strconv"
 	"time"
 )
@@ -26,13 +29,24 @@ func (a *Activemanage) Luckdraw(activecode, id string) error {
 	if activecode == "topcj" {
 		se := SimpleEncrypt{Key: "topnet2015topnet2015"}
 		openid := se.DecodeString(id)
+		f := FindOne("user", "{'s_m_openid':'"+openid+"'}")
+		username := (*f)["s_bindweixin"]
+		userid := (*f)["_id"]
+		if *f == nil {
+			a.T["flog"] = "B"
+			a.T["msg"] = "您的微信号无效!!"
+			return a.Render("/active/luckdraw.html", &a.T)
+		}
 		a.T["signature"] = mob.GetSignature(a.Url())
 		u := FindOne("winningrecord", "{'s_openid':'"+openid+"'}")
 		if *u != nil {
 			//a.T = *u
 			a.T["flog"] = "A"
+			a.T["msg"] = "小主莫贪心,每人只有一次抽奖机会呦!<br/><br/>  小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)"
 			return a.Render("/active/luckdraw.html", &a.T)
 		}
+		a.SetSession("username", username)
+		a.SetSession("userid", userid)
 		a.SetSession("openid", openid)
 		a.SetSession("s_actcode", activecode)
 		return a.Render("/active/luckdraw.html", &a.T)
@@ -44,22 +58,28 @@ func (a *Activemanage) Luckdraw(activecode, id string) error {
 //
 func (a *Activemanage) Getluckdraw() error {
 	flog := "F"
+	//提示语
+	msg := ""
 	id := ""
+	today := time.Now()
 	openid := a.GetSession("openid").(string)
 	s_actcode := a.GetSession("s_actcode").(string)
 	if openid == "" {
-		return a.Write(`{"flog":"` + flog + `"}`)
+		msg = "  小主你太长时间没点击开始抽奖了,重新进来吧!"
+		return a.Write(`{"flog":"` + flog + `","msg":"` + msg + `"}`)
 	} else {
 		u := FindOne("winningrecord", "{'s_openid':'"+openid+"'}")
 		if *u != nil {
 			flog = "A"
-			return a.Write(`{"flog":"` + flog + `"}`)
+			msg = "  小主莫贪心,每人只有一次抽奖机会呦!<br/><br/>  小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)"
+			return a.Write(`{"flog":"` + flog + `","msg":"` + msg + `"}`)
 		}
 	}
 	data := make(map[string]interface{})
 	data["s_openid"] = openid
 	data["s_actcode"] = s_actcode
 	i := getLuckDraw()
+
 	s_prize := getPrize(i)
 	data["s_prize"] = s_prize
 	data["l_timestamp"] = time.Now().Unix()
@@ -67,12 +87,54 @@ func (a *Activemanage) Getluckdraw() error {
 	enddate := LuckDraw.EndDate
 	if nowdate < enddate {
 		id = Save("winningrecord", data)
-		fmt.Println("nowdate:", nowdate, "enddate:", enddate, len(id))
 	}
 	if len(id) > 0 {
 		flog = "T"
 	}
-	return a.Write(`{"flog":"` + flog + `","prize":"` + s_prize + `","rotate":` + strconv.Itoa(int(i)) + `}`)
+	if i > 185 && i < 220 {
+		amount := 500 //红包金额以“元”为单位,微信红包以“分”为单位
+		bm := qrpc.BonusMsg{Mchbillno: fmt.Sprint(today.Unix()),
+			Sendname:    LuckDraw.Weixin["sendname"].(string),
+			Reopenid:    openid,
+			Totalamount: amount,
+			Totalnum:    1,
+			Wishing:     "企明星新年大抽奖",
+			Actname:     "企明星新年大抽奖",
+			Remark:      "欢迎参加企明星新年大抽奖活动!",
+		}
+		if coreutil.PayBonus(&bm) {
+			redpackage := make(bson.M)
+			redpackage["s_userid"] = a.GetSession("userid")
+			redpackage["s_username"] = a.GetSession("username")
+			redpackage["s_openid"] = openid
+			redpackage["i_amount"] = amount
+			redpackage["s_billno"] = bm.Mchbillno
+			redpackage["s_name"] = bm.Actname
+			redpackage["l_createdate"] = today.Unix()
+			redpackage["i_year"] = today.Year()
+			redpackage["i_month"] = today.Month()
+			redpackage["i_day"] = today.Day()
+			redpackage["s_actcode"] = s_actcode
+			Save("redpackage", redpackage)
+		}
+	}
+	if i > 185 && i < 220 {
+		msg = "  小主是真真的好运气,五元现金红包落入您囊中!<br/><br/>  小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)"
+	} else if (i > 275 && i < 310) || (i > 95 && i < 130) {
+		//时间判断,提醒不同
+		now := time.Now()
+		//不在工作时间
+		if now.Weekday() == 6 || now.Weekday() == 0 || (now.Hour() > 18 || now.Hour() < 9) {
+			//
+			msg = "  小主是真真的好运气," + s_prize + "落入您囊中!<br/>  请在微信留下您的联系方式(手机号或qq号),企明星客服会在下一个工作日9:00-17:00给小主回复哦!<br/>  小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)"
+		} else { //在工作时间
+			msg = "  小主是真真的好运气," + s_prize + "落入您囊中,请速速微信联系企明星确认领奖事宜!<br/><br/>  小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)"
+		}
+
+	} else { //不中奖
+		msg = "  小主不要桑心,这次没有中奖不代表什么,猴年依然会好运气爆棚滴~~<br/><br/>  小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)"
+	}
+	return a.Write(`{"flog":"` + flog + `","msg":"` + msg + `","rotate":` + strconv.Itoa(int(i)) + `}`)
 
 }
 

+ 1 - 0
core/src/qfw/coreconfig/SysConfig.go

@@ -22,6 +22,7 @@ type config struct {
 	MailFailureTime int         `json:"mailFailureTime"`
 	ChatServer      string      `json:"chatServer"`
 	ChatRpc         string      `json:"chatRpc"`
+	PushRpc         string      `json:"pushRpc"`
 	ElasticPoolSize int         `json:"elasticPoolSize"`
 	DomainName      string      `json:"domainName"`
 }

+ 22 - 0
core/src/qfw/coreutil/counterutil.go

@@ -0,0 +1,22 @@
+package coreutil
+
+import (
+	"qfw/util/redis"
+)
+
+//计数器
+const (
+	TYPE_INVITE = iota //邀请
+	TYPE_GIVE          //赠送积分
+)
+
+//基于Redis的计数器实现
+func GetShareId(businesstype int) uint32 {
+	var tmp int64
+	if businesstype == TYPE_INVITE {
+		tmp = redis.Incr("other", "invite_counter") + 3200000000
+	} else if businesstype == TYPE_GIVE {
+		tmp = redis.Incr("other", "give_counter") + 3200000000
+	}
+	return uint32(tmp)
+}

+ 13 - 0
core/src/qfw/coreutil/counterutil_test.go

@@ -0,0 +1,13 @@
+package coreutil
+
+import (
+	"log"
+	"qfw/util/redis"
+	"testing"
+)
+
+func TestCounter(t *testing.T) {
+	redis.InitRedis("other=192.168.3.14:1379")
+	log.Println("初始化缓存")
+	log.Println("id::", GetShareId(TYPE_INVITE))
+}

+ 36 - 1
core/src/qfw/front/index.go

@@ -56,13 +56,48 @@ func (i *Index) LoadIndex() error {
 		return i.SetBody([]byte(ret.(string)))
 	} else {
 		i.T["serviceClassify"] = coreconfig.ServiceClassify
+		//企业快报
 		querymap := map[string]string{
 			"perPage":     i.GetString("perPage"),
 			"currentPage": i.GetString("currentPage"),
 			"contentType": "qykb",
 			"query":       i.GetString("query")}
 		data, pagination := searhWebContent(querymap)
-		content, _ := i.Render4Cache("/index.html", &xweb.T{"data": data, "pagination": pagination})
+		//知识库
+		zkquerymap := map[string]string{
+			"perPage":     "8",
+			"currentPage": i.GetString("currentPage"),
+			"contentType": "zhsk",
+			"query":       i.GetString("query")}
+		zkdata, _ := searhWebContent(zkquerymap)
+		if zkdata != nil {
+			for _, v := range *zkdata {
+				release := v["releasetime"].(string)
+				v["releasetime"] = release[:4] + "." + release[5:7] + "." + release[8:10]
+			}
+		}
+		//认证企业
+		entquery := `{"i_identificationstatus":1,"i_freeze":{"$ne":2}}`
+		entdata := *Find("identification", entquery, []string{"-l_auditdate"}, `{"s_enterprisename":1,"l_auditdate":1,"s_enterpriseid":1}`, false, 0, 8)
+		if entdata != nil {
+			for _, v := range entdata {
+				auditdate := v["l_auditdate"].(int64)
+				v["l_auditdate"] = time.Unix(auditdate, 0).Format("2006.01.02")
+			}
+		}
+		//剑鱼最新消息
+		now := time.Now()
+		unix := time.Date(now.Year(), now.Month(), now.Day(), now.Hour()-2, now.Minute(), now.Second(), now.Nanosecond(), time.Local).Unix()
+		sfdata := *Find("bidding", M{"comeintime": M{"$lte": unix}}, `{"comeintime":-1}`, `{"title":1,"href":1,"publishtime":1}`, false, 0, 8)
+		if sfdata != nil {
+			for _, v := range sfdata {
+				publishtime := v["publishtime"].(int64)
+				//:= util.FormatDateWithObj(&data_2, util.Date_Short_Layout)
+				v["publishtime"] = time.Unix(publishtime, 0).Format("2006.01.02")
+			}
+		}
+		//
+		content, _ := i.Render4Cache("/index.html", &xweb.T{"data": data, "pagination": pagination, "zkdata": zkdata, "entdata": entdata, "sfdata": sfdata})
 		redis.Put("other", "/", string(content), 0) //设置首页缓存
 		return i.SetBody(content)
 	}

+ 2 - 1
core/src/qfw/manage/auditing.go

@@ -548,7 +548,7 @@ func (s *SystemManage) Updateaudit() error {
 				tm := fmt.Sprintf("%d", time.Now().Unix())
 				Update("enterprise", &map[string]interface{}{
 					"_id": ObjectIdHex(s_enterpriseid),
-				}, `{'$set':{'s_action':'`+s_action+`','s_avatar':'`+s_avatar+`','EntName':'`+s_enterprisename+`','RegNo':'`+s_id+`','s_submitid':'`+s_submitid+`','s_submitname':'`+s_submitname+`','l_timestamp':`+tm+`}}`, false, false)
+				}, `{'$set':{'s_action':'`+s_action+`','s_avatar':'`+s_avatar+`','EntName':'`+s_enterprisename+`','RegNo':'`+s_id+`','s_submitid':'`+s_submitid+`','s_submitname':'`+s_submitname+`','l_submittime':`+tm+`}}`, false, false)
 				elastic.UpdateEntDoc(s_enterpriseid)
 				if i_identificationtype == "5" {
 					per := FindOne("enterprise", M{"RegNo": s_id_new})
@@ -738,6 +738,7 @@ func (s *SystemManage) Updateaudit() error {
 				}
 				m.SaveMsg()
 			}
+			redis.Del("other", "/")
 			flag = "true"
 			msg = "审核成功!"
 			if (*f)["s_m_openid"] != nil {

+ 23 - 0
core/src/qfw/mobile/wxmenu.go

@@ -5,12 +5,14 @@ import (
 	"fmt"
 	"log"
 	"math/rand"
+	"net/rpc"
 	"qfw/coreconfig"
 	"qfw/coreutil"
 	"qfw/util"
 	"qfw/util/credit"
 	"qfw/util/mongodb"
 	"qfw/util/redis"
+	qrpc "qfw/util/rpc"
 	"runtime"
 	"time"
 )
@@ -134,6 +136,7 @@ func (m *Mobile) SwordfishPay() error {
 					i_credit := util.IntAll(user["i_credit"])
 					if i_credit > 0 {
 						isPay := map[string]interface{}{}
+						mapPush := map[string]string{}
 						for _, v := range types {
 							util.Try(func() {
 								obj_typei := user["o_msgset"].(map[string]interface{})[v]
@@ -157,6 +160,7 @@ func (m *Mobile) SwordfishPay() error {
 								}
 								if b_newopen { //进行扣费操作
 									isPay[v] = v
+									mapPush[v] = util.If(v == "bid", "中标", "招标").(string)
 								}
 							}, func(e interface{}) {
 								log.Println(e)
@@ -168,6 +172,25 @@ func (m *Mobile) SwordfishPay() error {
 								//先扣分,然后更新,然后返回结果
 								res["credit"] = i_credit
 								res["oprstatus"] = true
+								//初次提交积分时
+								//加上剑鱼是否推送过的逻辑判断
+								util.Try(func() {
+									//对用户进行推送
+									var repl int
+									clent, errs := rpc.DialHTTP("tcp", coreconfig.SysConfig.PushRpc)
+									defer clent.Close()
+									rpcData := qrpc.PushData{
+										Mopenid:  m.GetSession("s_m_openid").(string),
+										PushType: mapPush,
+									}
+									go clent.Call("PushInfo.PushMsg", &rpcData, &repl)
+									if errs == nil {
+										//修改剑鱼占位值
+
+									}
+								}, func(e interface{}) {
+									log.Println("给用户摄推送出错", e)
+								})
 							}
 						} else {
 							res["credit"] = i_credit

+ 4 - 3
core/src/qfw/search/search.go

@@ -9,9 +9,10 @@ import (
 
 type Search struct {
 	*xweb.Action
-	getEnterpriseList xweb.Mapper `xweb:"/search/enterprise/([^.]*)ent([^.]*).html"` //查询企业列表
-	sim               xweb.Mapper `xweb:"POST /search/sim"`                          //即时搜索
-	searchEntSer      xweb.Mapper `xweb:"/searchEntSer/(.*)"`                        //获取企业的服务列表
+	getEnterpriseList  xweb.Mapper `xweb:"/search/enterprise/([^.]*)ent([^.]*).html"` //查询企业列表
+	sim                xweb.Mapper `xweb:"POST /search/sim"`                          //即时搜索
+	searchEntSer       xweb.Mapper `xweb:"/searchEntSer/(.*)"`                        //获取企业的服务列表
+	findServiceByEntId xweb.Mapper `xweb:"/front/findServiceByEntId"`                 //获取企业的服务列表
 }
 
 func init() {

+ 51 - 0
core/src/qfw/search/searchService.go

@@ -78,6 +78,57 @@ func (search *Search) SearchEntSer(id string) error {
 	return nil
 }
 
+func (search *Search) FindServiceByEntId() error {
+	if search.Method() == "POST" {
+		id := search.GetString("entId")
+		limit, _ := search.GetInteger("pageSize")
+		currentPage, _ := search.GetInteger("currentPage")
+		start := (currentPage - 1) * limit
+		var count int64
+		//分页
+		mustnot := `{"term" : {"i_status" : 1 }}`
+		var fields, collection, query, tempstrquery string
+		collection = "service"
+		tempstrquery = `{"query_string":{"default_field": "s_enterpriseid","query":"` + id + `"}}`
+		servicequery := ""
+		if search.GetSession("entid") == nil || search.GetSession("entid").(string) != id {
+			servicequery = `,"must_not" : [` + mustnot + `]`
+		}
+		query = `{"query": {
+		    "bool": {
+			  "must":[` + tempstrquery + `]` + servicequery + `
+		    }
+		  }}`
+		//需要查到的字段信息
+		fields = `"_id","s_name","s_introduction","s_images","s_enterpriseid","s_isshow","i_status"`
+		if currentPage == 1 {
+			count = elastic.Count("service", collection, query)
+		}
+		//查询服务列表数据
+		result := elastic.Get("service", collection, `{"query":{"bool": {"must":[`+tempstrquery+`]`+servicequery+`}},
+		_source:[`+fields+`],
+		sort:{"l_createdate":"desc"},
+		from:`+fmt.Sprintf("%v", start)+`,
+		size:`+fmt.Sprintf("%v", limit)+`
+		}`)
+		for _, v := range *result {
+			b, _ := CheckAuth(v)
+			if b {
+				v["s_isEdit"] = "1"
+			} else {
+				v["s_isEdit"] = "0"
+			}
+			if IntAll(v["i_status"]) == 1 {
+				v["s_remove"] = 1
+			} else {
+				v["s_remove"] = 0
+			}
+		}
+		search.ServeJson(&map[string]interface{}{"list": result, "count": count})
+	}
+	return nil
+}
+
 //企业列表
 func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 	//必须是登录之后的已认证用户才可以进入企业社区

+ 2 - 0
core/src/qfw/yellowpage/yellowpage.go

@@ -15,6 +15,8 @@ type Yellowpage struct {
 	enterpriseInfo xweb.Mapper `xweb:"/enterprise/(\\w+).html"`
 	//根据企业注册号进入企业黄页
 	enterpriseInfoByRegNO xweb.Mapper `xweb:"/enterpriseInfoByRegNO/(\\w+).html"`
+	//获取关系网数据
+	getRelation xweb.Mapper `xweb:"/member/getRelation"`
 }
 
 func (yp *Yellowpage) EnterpriseInfoByRegNO(regNO string) error {

+ 13 - 3
core/src/qfw/yellowpage/yellowpagemanager.go

@@ -244,9 +244,18 @@ func isContainInQueryCache(querykey string, cache *list.List) bool {
 }
 
 func (yp *Yellowpage) GetRelation() error {
-	relation := makeRelation(yp.GetString("regNo"), yp.GetString("entName"))
-	if relation != nil {
-		yp.ServeJson(M{"relation": relation})
+	if util.IntAll(yp.GetSession("identWay")) == 1 {
+		regNo := yp.GetString("regNo")
+		entName := yp.GetString("entName")
+		if regNo == "" || entName == "" {
+			return nil
+		}
+		relation := makeRelation(regNo, entName)
+		if relation != nil {
+			yp.ServeJson(M{"flag": true, "relation": relation})
+		}
+	} else {
+		yp.ServeJson(M{"flag": false})
 	}
 	return nil
 }
@@ -283,6 +292,7 @@ func makeRelation(mnregno, mnname string) interface{} {
 
 	for el := ls.Front(); el != nil; el = el.Next() {
 		v, _ := el.Value.([]string)
+		log.Println(v)
 		//加投资人
 		if _, ok := node[v[1]]; !ok {
 			node[v[1]] = map[string]string{

+ 1 - 1
core/src/timetask.json

@@ -1 +1 @@
-{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-16 15:02:30"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-16 15:02:30"}},"marketisstart":true,"marketrate":300}
+{"comment":{"c_rate":720,"commentrate":900},"market":{"demand":{"attr":["i_hits","i_bids","i_status"],"timepoint":"2016-01-18 16:22:55"},"service":{"attr":["i_hits","i_sales","i_comments","i_score","i_appcounts"],"timepoint":"2016-01-18 16:22:55"}},"marketisstart":true,"marketrate":300}

+ 3 - 1
core/src/web/staticres/css/dev-qfw.css

@@ -4,6 +4,9 @@ body {
 	font-family: tahoma, arial, 'Hiragino Sans GB', 'Microsoft YaHei', 宋体, sans-serif;
 	color: #666;
 }
+.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6{
+	font-family: tahoma, arial, 'Hiragino Sans GB', 'Microsoft YaHei', 宋体, sans-serif;
+}
 table{
 	font-size: 14px;
 }
@@ -1000,7 +1003,6 @@ a{
 
 .a-com-ul-block {
 	width: 250px;
-	height:230px;
 }
 .a-com-ul-blocknew {
 	margin-left:1px;

+ 97 - 72
core/src/web/staticres/css/entcommunity.css

@@ -152,7 +152,6 @@ a:focus, a:hover{
 }
 .entinfo-page .b-com-head .b-com-last a{
 	color: blue;
-	margin-left: 10px;
 }
 .white_content {
 	display: none;
@@ -198,12 +197,12 @@ a:focus, a:hover{
 	width: 60px;
 	cursor: pointer;
 }
-.entinfo-tab{
+.ent-tab{
 	height: 50px;
 	background-color: #F6F8FA;
 	padding-left: 20px;
 }
-.entinfo-tab li{
+.ent-tab li{
 	padding: 0px 20px;
 	border-top-width: 3px;
 	height: 47px;
@@ -213,37 +212,21 @@ a:focus, a:hover{
 	border-right: 1px solid #FFFFFF;
 	font-weight: bold;
 }
-.entinfo-tab .entinfo-active{
+.ent-tab .ent-active{
 	border-top-color: #16a086;
 	background-color: #FFFFFF;
 	color: #16a086;
 	border-right-width: 0px
 }
-.entinfo-tab-content{
+.ent-tab-content{
 	margin-top: 10px;
 	background-color: #FFFFFF;
 	padding-top: 20px;
+	padding-bottom: 20px;
 }
 /********************企业画像**********************/
-.entinfo-basicinfo{
-	padding: 0px 20px;
-}
-.entinfo-basicinfo .b-com-title{
-	font-size: 18px;
-	padding-left: 5px;
-	border-bottom: 1px solid #DFE0E2;
-	padding-bottom: 10px;
-}
-.entinfo-basicinfo .b-com-title span{
-	color: #16a086;
-	margin-right: 5px;
-}
-.entinfo-basicinfo .b-com-title font{
-	font-size: 14px;
-	margin-left: 5px;
-}
 .entinfo-basicinfo .b-com-content{
-	padding: 90px 0px;
+	padding: 60px 0px;
 }
 .entinfo-basicinfo .entinfo-round{
 	border: 1px solid #DFE0E2;
@@ -257,7 +240,7 @@ a:focus, a:hover{
 	position: absolute;
 }
 .entinfo-basicinfo .entinfo-round>div:first-child{
-	top: 130px;
+	top: 100px;
 	left: 15px;
 	width: 320px;
 	padding-left: 50px;
@@ -266,10 +249,14 @@ a:focus, a:hover{
 	position: relative;
 	display: block;
 	width: 320px;
-	margin-bottom: 10px;
 	margin-left: -50px;
 	text-align: center;
 }
+.entinfo-basicinfo .entinfo-round>div:first-child>span>img{
+	width: 15px;
+	height: 11px;
+	margin: 5px 0px;
+}
 .entinfo-basicinfo .entinfo-round>div:first-child>span>div:first-child{
 	font-size: 18px;
 	font-weight: bold;
@@ -334,8 +321,8 @@ a:focus, a:hover{
 	text-align: right;
 }
 .entinfo-basicinfo .entinfo-estdate>img{
-	width: 30px;
-	height: 67px;
+	width: 34px;
+	height: 76.5px;
 	margin-top: -20px;
 	right: -35px !important;
 }
@@ -350,8 +337,8 @@ a:focus, a:hover{
 	text-align: right;
 }
 .entinfo-basicinfo .entinfo-regcap>img{
-	width: 40px;
-	height: 40px;
+	width: 36px;
+	height: 36.5px;
 }
 .entinfo-basicinfo .entinfo-regcap-round{
 	top: 120px;
@@ -378,8 +365,8 @@ a:focus, a:hover{
 	text-align: right;
 }
 .entinfo-basicinfo .entinfo-lerep>img{
-	width: 40px;
-	height: 42.5px;
+	width: 48px;
+	height: 51px;
 }
 .entinfo-basicinfo .entinfo-lerep-round{
 	top: 315px;
@@ -391,8 +378,8 @@ a:focus, a:hover{
 	top: 330px;
 }
 .entinfo-basicinfo .entinfo-entscale>img{
-	width: 40px;
-	height: 33px;
+	width: 50.5px;
+	height: 43.5px;
 	left: -45px;
 }
 .entinfo-basicinfo .entinfo-entscale-round{
@@ -405,8 +392,8 @@ a:focus, a:hover{
 	top: 225px
 }
 .entinfo-basicinfo .entinfo-regorgname>img{
-	width: 40px;
-	height: 51px;
+	width: 37px;
+	height: 48px;
 	left: -45px;
 }
 .entinfo-basicinfo .entinfo-regorgname-round{
@@ -419,8 +406,8 @@ a:focus, a:hover{
 	left: 380px;
 }
 .entinfo-basicinfo .entinfo-dom>img{
-	width: 30px;
-	height: 40px;
+	width: 33px;
+	height: 45px;
 	left: -35px;
 }
 .entinfo-basicinfo .entinfo-dom-round{
@@ -433,8 +420,8 @@ a:focus, a:hover{
 	top: -28px;
 }
 .entinfo-basicinfo .entinfo-operperiod>img{
-	width: 40px;
-	height: 40px;
+	width: 49.5px;
+	height: 49.5px;
 	left: -45px;
 }
 .entinfo-basicinfo .entinfo-operperiod-round{
@@ -442,28 +429,6 @@ a:focus, a:hover{
 	right: 100px;
 }
 /*股东信息*/
-.entinfo-shareholderinfo>div{
-	margin-bottom: 30px;
-}
-.entinfo-shareholderinfo>div{
-	font-size: 16px;
-	color: #16a086;
-}
-.entinfo-shareholderinfo>div>span{
-	background-color: #AEE7D6;
-	font-size: 14px;
-	margin-right: 10px;
-	display: inline-block;
-	line-height: 25px;
-	text-align: center;
-	width: 25px;
-	height: 25px;
-	color: #FFFFFF;
-}
-.entinfo-shareholderinfo ul{
-	padding-left: 50px;
-	padding-bottom: 60px;
-}
 .entinfo-shareholderinfo li{
 	margin-right: 40px;
 	margin-bottom: 20px;
@@ -487,11 +452,12 @@ a:focus, a:hover{
 }
 /********************关系网**********************/
 .entrelation{
-	
+	position: relative;
+	padding: 0px 20px;
 }
-.entrelation-legend{
-	float:left;
-	height:500px;
+.entrelation svg{
+	position: relative;
+	z-index: 1;
 }
 .legend-text-bg>div{
     position: absolute;
@@ -502,35 +468,35 @@ a:focus, a:hover{
     line-height: 25px;
     text-align: center;
 	margin-top: -3px;
-	z-index: -1;
 }
 .legend-text-bg>span{
 	position: relative;
 }
 /*全屏代码*/
-.entrelation-infovis .entrelation-controlls{
+.entrelation .entrelation-controlls{
 	position: absolute;
 	margin-top: 10px;
+	z-index: 2;
 }
-.entrelation-infovis .entrelation-controlls .entrelation-item{
+.entrelation .entrelation-controlls .entrelation-item{
 	border-radius: 2px;
 	box-shadow: 0 1px 4px rgba(0,0,0,0.3);
 	cursor: pointer;
 	margin-bottom: 8px;
 	float:left;
 }
-.entrelation-infovis .entrelation-controlls .entrelation-box{
+.entrelation .entrelation-controlls .entrelation-box{
 	padding:10px;
 	float:left;
 }
-.entrelation-infovis .entrelation-controlls .entrelation-box div{
+.entrelation .entrelation-controlls .entrelation-box div{
 	background: url(/images/view_icons.png) no-repeat;
 	width: 16px;
 	height: 16px;
 	opacity: 0.6;
 }
-:-moz-full-screen .entrelation-infovis,:-webkit-full-screen .entrelation-infovis,:-o-full-screen .entrelation-infovis,
-:-ms-full-screen .entrelation-infovis,:fullscreen .entrelation-infovis,:-ms-fullscreen .entrelation-infovis,:full-screen .entrelation-infovis{
+:-moz-full-screen .entrelation,:-webkit-full-screen .entrelation,:-o-full-screen .entrelation,
+:-ms-full-screen .entrelation,:fullscreen .entrelation,:-ms-fullscreen .entrelation,:full-screen .entrelation{
   width: 100%;
   height: 100%;
   background-color:#fff;
@@ -556,3 +522,62 @@ a:focus, a:hover{
 :full-screen {
 	background: #fff; 
 }
+.ent-findnull{
+	text-align: center;
+	padding: 50px 0px;
+}
+.entrelation-limit>div{
+	border-bottom: 1px solid #e5e6e9;
+	padding-top: 50px;
+	padding-bottom: 85px;
+}
+.entrelation-limit>img{
+	margin-top: 10px;
+}
+.entrelation-limit .btn{
+	margin-top: 20px;
+	width: 200px;
+}
+/************公用****************/
+.ent-layout-up{
+	padding: 0px 20px;
+}
+.ent-layout-up .b-com-title{
+	font-size: 18px;
+	padding-left: 5px;
+	border-bottom: 1px solid #DFE0E2;
+	padding-bottom: 10px;
+}
+.ent-layout-up .b-com-title span{
+	color: #16a086;
+	margin-right: 5px;
+}
+.ent-layout-up .b-com-title font{
+	font-size: 14px;
+	margin-left: 5px;
+}
+.ent-layout-up .b-com-content{
+	margin-top: 20px;
+}
+.ent-layout-down{
+	padding-top: 20px;
+}
+.ent-layout-down .b-com-content{
+	padding: 0px 25px;
+}
+.ent-layout-down .b-com-title{
+	margin-bottom: 30px;
+	font-size: 16px;
+	color: #16a086;
+}
+.ent-layout-down .b-com-title>span{
+	background-color: #AEE7D6;
+	font-size: 14px;
+	margin-right: 10px;
+	display: inline-block;
+	line-height: 25px;
+	text-align: center;
+	width: 25px;
+	height: 25px;
+	color: #FFFFFF;
+}

+ 70 - 6
core/src/web/staticres/css/index-new.css

@@ -195,7 +195,7 @@ a:focus, a:hover{
 	margin-right:8px;
 }
 .a-index  .index-new-xwzx-con .index-new-xwzx-title{
-	width:210px;
+	width:200px;
     font-weight: 700;
     font-size: 16px;
 	white-space:nowrap;
@@ -210,7 +210,7 @@ a:focus, a:hover{
 }
 .a-index  .index-new-xwzx-con .index-new-xwzx-content{
 	height:40px;
-	width:210px;
+	width:200px;
     font-family: '宋体 Regular', '宋体';
     font-size: 12px;
     color: #A0A0A0;
@@ -388,7 +388,7 @@ a:focus, a:hover{
 .index-new-wgw-nameent{
 	position:absolute; 
 	z-index:4; 
-	top:184px; 
+	top:199px; 
 	left:10px;
 }
 .index-new-rmfw-nameent a {
@@ -401,7 +401,7 @@ a:focus, a:hover{
 	top:163px; 
 	left:-1px;
 }
-.index-new-rmfw-bg1 span,.index-new-wgw-bg1 span{
+.index-new-rmfw-bg1 span{
 	border-top:3px solid #FF5A5F;
 	display:inline-block;
 	width:250px; 
@@ -411,6 +411,21 @@ a:focus, a:hover{
 	background-position:-1px -2px;
 	background-size: 252px 67px;
 }
+.index-new-wgw-bg1 span{
+	border-top:3px solid #FF5A5F;
+	display:inline-block;
+	width:250px; 
+	height:45px;
+	background-image:url(/images/u46.png);
+	background-repeat:no-repeat;
+	background-position:-1px -2px;
+	background-size: 252px 45px;	
+}
+.index-new-wgw-bg1 {
+	position: absolute;
+	top: 185px;
+	left: -1px;
+}
 .index-new-rmfw-remarktitle{
     font-size: 16px;
     color: #FFFFFF;
@@ -530,6 +545,55 @@ a:focus, a:hover{
 .fw-new-content .fw-new-zh span,.fw-new-content .fw-new-yzm span{
 	float:right;margin:10px -5px 0px 0px;
 }
-.fw-new-content .afterSendIdentCode{
-	
+.index-new-tg{
+	padding: 20px 30px;
+	margin-bottom:30px;
+}
+.index-new-tg .row{
+	border:1px solid #f0f0f0;
+}
+.index-new-tg-tb img{
+	width:40px;
+	height:39px;
+	margin-bottom:1px;
+}
+.index-new-tg-tb{
+	height:120px;
+	padding-right:0px;
+}
+.index-new-mingcheng div{
+	background-color:#FF5A5F;
+	color:#FFF;
+	padding:24px 6px;
+	height:120px;
+	width:40px; 
+	border:1px solid #FF5A5F;
+	font-size: 16px;
+}
+.index-new-tg-con ul li{
+	padding:5px;
+}    
+.index-new-tg-con>ul>li>span:nth-child(1){
+	display:inline-block;
+	margin-left: 45px;
+	margin-bottom: 8px;
+	width: 4px;
+	height: 4px;
+	border:1px solid #D1D1D1;
+	background-color:#D1D1D1;
+}
+.index-new-tg-con>ul>li>span:nth-child(2){
+	display:inline-block;
+	width:330px;
+	padding-left:10px;
+	padding-right: 10px;
+	color:#4E5051;
+	white-space: nowrap;
+	overflow: hidden;
+	text-overflow: ellipsis;
+}
+.index-new-tg-con>ul>li>span:nth-child(3){
+	font-family: '宋体 Regular', '宋体';
+	color:#A0A0A0;
+	font-size:12px;
 }

+ 4 - 0
core/src/web/staticres/css/qfw.css

@@ -953,6 +953,10 @@ span.highlight {
 	content: "\5F";
 }
 
+.rili:before{
+	content: "\60";
+}
+
 .icon-small {
 	font-size: 12px;
 }

BIN
core/src/web/staticres/fonts.zip


BIN
core/src/web/staticres/fonts/qimingxing.eot


BIN
core/src/web/staticres/fonts/qimingxing.svg


BIN
core/src/web/staticres/fonts/qimingxing.ttf


BIN
core/src/web/staticres/fonts/qimingxing.woff


BIN
core/src/web/staticres/images/activeimages/btn_end.png


BIN
core/src/web/staticres/images/entcommunity/qq.png


BIN
core/src/web/staticres/images/entcommunity/relation.png


BIN
core/src/web/staticres/images/entcommunity/triangle.png


BIN
core/src/web/staticres/images/u0115.png


BIN
core/src/web/staticres/images/u0116.png


BIN
core/src/web/staticres/images/u0117.png


BIN
core/src/web/staticres/images/u0118.png


BIN
core/src/web/staticres/images/u0119.png


BIN
core/src/web/staticres/images/u0120.png


BIN
core/src/web/staticres/images/u2181.png


+ 73 - 752
core/src/web/staticres/js/entportrait.js

@@ -1,25 +1,31 @@
 var entType = "企业";
+var relation = null;
+var serviceList = null;
 with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
 //解析服务列表
-$(function(){	
-	//重绘关系网
-	try{		
-	//	redraw();	
-	}catch(e){}
+$(function(){
 	//联系地址
-	if($chiancity){
-		setcxSelect();	
-		var pt=province?($("#provincesel option[value="+province+"]").text()):"";
-		var ct=city?($("#citysel option[value="+city+"]").text()):"";
-		var at=area?($("#areasel option[value="+area+"]").text()):"";
-		//设置地图上显示的位置
-		$("#location").attr("value",as1);
-		$("#cityname").attr("value",pt.trim()+ct.trim()+at.trim());		
-		//获取地图的经纬度
-		doOptions();
-		$("#city_china").text(pt+ct+at+as1);
-	}else{	
-		setcxSelect();
+	if(address){
+		loadJS("/js/jquery.cxselect.js",function(){
+			$('#city_china').cxSelect({
+				selects: ['province', 'city', 'area'],
+				required:0
+			});
+			$.cxSelect.setVal(province,city,area);
+			var pt=province?($("#provincesel option[value="+province+"]").text()):"";
+			var ct=city?($("#citysel option[value="+city+"]").text()):"";
+			var at=area?($("#areasel option[value="+area+"]").text()):"";
+			//设置地图上显示的位置
+			$("#location").attr("value",as1);
+			$("#cityname").attr("value",pt.trim()+ct.trim()+at.trim());		
+			//获取地图的经纬度
+			loadJS("http://api.map.baidu.com/getscript?v=2&ak=AFd8b176f363f23e6a23d516f4cfb742&services=&t=20150522093217",function(){
+				loadJS("/js/geocoder.js",function(){
+					doOptions();
+				});
+			});
+			$("#city_china").text(pt+ct+at+as1);
+		});
 	}
 	//隐藏地图
 	$("#fade").click(closeMap);
@@ -28,14 +34,19 @@ $(function(){
 		$(".bdsharebuttonbox").show();
 	});
 	//切换
-	$(".entinfo-tab>li").click(function(){
-		$(".entinfo-tab>li").removeClass("entinfo-active");
-		$(this).addClass("entinfo-active");
-		$(".entinfo-tab-content>div").addClass("hide");
-		$(".entinfo-tab-content>div:eq("+$(this).index()+")").removeClass("hide");
+	$(".ent-tab>li").click(function(){
+		$(".ent-tab>li").removeClass("ent-active");
+		$(this).addClass("ent-active");
+		$(".ent-tab-content>div").addClass("hide");
+		$(".ent-tab-content>div:eq("+$(this).index()+")").removeClass("hide");
+		if($(this).index() == 1){
+			initRelation();
+		}else if($(this).index() == 5 && serviceList == null){
+			//加载服务列表
+			serviceList = new ServiceList();
+		}
 	});
-	//加载服务列表
-	initServiceList();
+	new ServiceList();
 });
 //显示地图
 function showMap(){
@@ -51,699 +62,50 @@ function closeMap(){
 	document.getElementById('fade').style.display = 'none';
 	$("html,body").removeClass("overflow-hidden");
 }
-//关系网初始化
-function Relation(data){
-	this.zoomlevel = 1;
-	//关系网的设置
-	$("#entrelation-fullscreen").bind("click",initFullScreen);
-	var w = parseInt($("#entrelation").css("width").replace("px","")) - 80;
-	$("#entrelation-infovis").css("width",w+"px");
-	var h = $("#entrelation-infovis").height();
-	if($(".entrelation-controlls").length>0){
-		$(".entrelation-controlls").css({left:$("#entrelation").width()-$(".entrelation-controlls").width()-30});
-	}
-	//查找逻辑
-	var index=-1;
-	var reg = new RegExp(/(有限公司|有限责任公司|股份有限公司|总公司|分公司|公司|事务所|合伙企业)$|\(.*\)|\(.*\)/g);
-	/*var provinces = [];
-	$.ajax({
-		url: "/js/provinceData.min.json",
-		dataType: "json",
-		cache: true,
-		async: false,
-		success: function(json){
-			provinces = json;
-		}
-	});*/
-	var filterEntName = function(text){
-		this.allProvinces = "河南省、青海省、山西省、黑龙江省、安徽省、广西壮族自治区、西藏自治区";
-		this.commonReplace = function(t){
-			if(t.length > 1 && text.startWith(t)){
-				var textCopy = text.replace(new RegExp("^"+t),"");
-				if(textCopy.length > 2){
-					text = textCopy;
-				}
-				return true;
-			}
-			return false;
-		};
-		this.replaceStart = function(t,f){
-			var flag = false;
-			var minus = null;
-			if(this.commonReplace(t)){//替换省、市、县、区
-				return true;
-			}
-			if(f){//不替换
-				flag = false;
-			}else if(t.endWith("维吾尔自治区")){
-				flag = true;
-				minus = 6;
-			}else if(t.endWith("回族自治区") || t.endWith("壮族自治区") || t.endWith("特别行政区")){
-				flag = true;
-				minus = 5;
-			}else if(t.endWith("自治州") || t.endWith("自治县") || t.endWith("自治区")){
-				flag = true;
-				minus = 3;
-			}else if(t.endWith("地区")){
-				flag = true;
-				minus = 2;
-			}else if(t.endWith("省") || t.endWith("市") || t.endWith("区")){
-				flag = true;
-				minus = 1;
-			}
-			if(flag){
-				return this.commonReplace(t.substring(0,t.length-minus));
-			}
-			return false;
-		};
-		this.replaceCity = function(citys){
-			if(citys){
-				for(var c in citys){//市
-					var c_name = citys[c].n;
-					if(this.replaceStart(c_name)){
-						this.replaceAreas(citys[c].s);
-						return true;
-					}else if(this.replaceAreas(citys[c].s)){
-						return true;
-					}
-				}
-			}
-		};
-		this.replaceAreas = function(areas){
-			if(areas){
-				for(var a in areas){//县、区
-					var a_name = areas[a].n;
-					if(this.replaceStart(a_name,true)){
-						return true;
-					}
-				}
-			}
-		};
-		for(var p in provinces){//省
-			var p_name = provinces[p].n;
-			if(this.allProvinces.indexOf(p_name) == -1){
-				continue;
-			}
-			if(this.replaceStart(p_name)){
-				this.replaceCity(provinces[p].s);
-				break;
-			}else if(this.replaceCity(provinces[p].s)){
-				break;
-			}
-		}
-		return text;
-	}
-	for(var i=0;i<data.nodes.length;i++){
-		var nodeObj = data.nodes[i];
-		nodeObj.text = $.trim(nodeObj.text);
-		nodeObj.shortText = nodeObj.text;
-		if(nodeObj.type == "e" || nodeObj.type == "ce"){
-			var text = nodeObj.shortText;
-			if(text.length > 2){//先替换结尾
-				text = text.replace(reg,"");
-			}
-			if(text.length > 2){//再替换开头
-				//text = filterEntName(text);
-			}
-			if(text.length > 2){//小于两个字符不生效
-				nodeObj.shortText = text;
-			}
-			if(nodeObj.name==regno){//先找本企业位置
-				index=i;
-				nodeObj["regcap"] = (typeof(d1) == "undefined")?0:d1;
-				nodeObj["legcerno"] = legcerno;
-			}
-		}
-	}
-	/*********************************连线处理***********************************/
-	var minLink=-1,maxLink=-1;
-	for(var i=0;i<data.links.length;i++){
-		var linkObj = data.links[i];
-		if(linkObj.target==index && data.nodes[linkObj.source].name==legcerno){
-			//data.nodes[linkObj.source].type="cp";
-			linkObj.type = "cp"
-			linkObj.isLegal = 1;
-		}
-		//
-		data.nodes[linkObj.target]["istarget"] = 1;
-		if(data.nodes[linkObj.source].name == data.nodes[linkObj.target].invlegcerno || data.nodes[linkObj.source].name ==	data.nodes[linkObj.target].legcerno){
-			linkObj.isLegal = 1;
-		}
-		if(typeof(linkObj.invacconam) == "undefined"){
-			continue;
-		}
-		var invacconam = new Number(linkObj.invacconam);
-		if(minLink == -1 && maxLink == -1){
-			minLink = invacconam;
-			maxLink = invacconam;
-		}else if(invacconam > maxLink){
-			maxLink = invacconam; 
-		}else if(invacconam < minLink){
-			minLink = invacconam;
-		}
-	}
-	var getLineSectionArray = function(){
-		var countSection = 6;
-		var section = (maxLink - minLink) / countSection;
-		var sectionArr = [];
-		for(var i=2;i<=countSection;i++){
-			var minVal = minLink;
-			if(sectionArr.length > 0){
-				minVal = sectionArr[sectionArr.length - 1].maxVal;
-			}
-			var maxVal = minLink+section*i;
-			if(i == countSection){
-				maxVal += section;
-			}
-			var sectionObj = {linkVal:i,minVal:minVal,maxVal:maxVal};
-			sectionArr.push(sectionObj);
-		}
-		return sectionArr;
-	}
-	/////////////
-	var linkSectionArray = getLineSectionArray();
-	for(var i=0;i<data.links.length;i++){
-		var linksObj = data.links[i];
-		linksObj["linkVal"] = 2;
-		if(typeof(linkObj.invacconam) == "undefined"){
-			continue;
-		}
-		var invacconam = new Number(linksObj.invacconam);
-		for(var s in linkSectionArray){
-			var sectionObj = linkSectionArray[s];
-			if(invacconam >= sectionObj.minVal && invacconam < sectionObj.maxVal){
-				linksObj["linkVal"] = sectionObj.linkVal;
-				continue;
-			}
-		}
-	}
-	/*********************************节点处理***********************************/
-	var minNode=-1,maxNode=-1;
-	for(var i=0;i<data.nodes.length;i++){
-		var nodeObj = data.nodes[i];
-		if(nodeObj.type == "e" || nodeObj.type == "ce"){
-			var regcap = nodeObj.regcap;
-			if(minNode == -1 && maxNode == -1){
-				minNode = regcap;
-				maxNode = regcap;
-			}else if(regcap > maxNode){
-				maxNode = regcap; 
-			}else if(regcap < minNode){
-				minNode = regcap;
-			}
-		}
-	}
-	var getNodeSectionArray = function(){
-		var countSection = 7;
-		var section = (maxNode - minNode) / countSection;
-		var sectionArr = [];
-		for(var i=1;i<=countSection;i++){
-			var minVal = minNode;
-			if(sectionArr.length > 0){
-				minVal = sectionArr[sectionArr.length - 1].maxVal;
-			}
-			var maxVal = minNode+section*i;
-			if(i == countSection){
-				maxVal += section;
-			}
-			var sectionObj = {nodeVal:6+i,minVal:minVal,maxVal:maxVal};
-			sectionArr.push(sectionObj);
-		}
-		return sectionArr;
-	}
-	var nodeSectionArray = getNodeSectionArray();
-	for(var i=0;i<data.nodes.length;i++){
-		var nodeObj = data.nodes[i];
-		nodeObj["nodeVal"] = 7;
-		if(nodeObj.type == "e" || nodeObj.type == "ce"){
-			var invacconam = new Number(nodeObj.invacconam);
-			var regcap = new Number(nodeObj.regcap);
-			for(var s in nodeSectionArray){
-				var sectionObj = nodeSectionArray[s];
-				if(regcap >= sectionObj.minVal && regcap < sectionObj.maxVal){
-					nodeObj["nodeVal"] = sectionObj.nodeVal;
-					continue;
-				}
-			}
-		}
-	}
-	//屏蔽鼠标右点击事件
-	if(document.getElementById("entrelation-infovis")){
-		document.getElementById("entrelation-infovis").oncontextmenu=function(){return false;};
-	}
-	$("#entrelation-fullscreen").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));	
- 	//处理全屏
- 	function launchFullScreen(element) {
-	  	if(element){
-		  	if (element.requestFullscreen) {
-		      element.requestFullscreen();
-		    } else if (element.msRequestFullscreen) {
-		      element.msRequestFullscreen();
-		    } else if (element.mozRequestFullScreen) {
-		      element.mozRequestFullScreen();
-		    } else if (element.webkitRequestFullscreen) {
-				// 对 Chrome 特殊处理,
-		        // 参数 Element.ALLOW_KEYBOARD_INPUT 使全屏状态中可以键盘输入。
-		        if ( window.navigator.userAgent.toUpperCase().indexOf( 'CHROME' ) >= 0 ) {
-		              element.webkitRequestFullScreen( Element.ALLOW_KEYBOARD_INPUT );
-		        }else {
-					// Safari 浏览器中,如果方法内有参数,则 Fullscreen 功能不可用。
-		           element.webkitRequestFullScreen();
-		        }
-		    }
-	  	}
-	}
-	function cancelFullScreen() {
-		h = $("#entrelation-infovis").height();  
-		$("#entrelation-fullscreen").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));	
-		//force.linkDistance(120).charge(-200).size([w,h]).resume();
-		$("#entrelation-infovis").css({width:w,height:h});
-		//设置svg标签的宽度与高度
-		d3.select("svg").attr("width", w).attr("height", h);
-		$(".entrelation-controlls").css({left:$("#entrelation").width()-$(".entrelation-controlls").width()-30});
-	    if(document.exitFullscreen) {
-	      document.exitFullscreen();
-	    } else if (document.msExitFullscreen) {
-	      document.msExitFullscreen();
-	    } else if (document.mozCancelFullScreen) {
-	      document.mozCancelFullScreen();
-	    } else if (document.webkitExitFullscreen) {
-	      document.webkitExitFullscreen();
-	    }
-	}
-	$(document).on('webkitfullscreenchange mozfullscreenchange msfullscreenchange fullscreenchange', function(){
-	    if (!document.fullscreenElement &&    // alternative standard method
-	    !document.mozFullScreenElement && 
-	    !document.webkitFullscreenElement && 
-	    !document.msFullscreenElement ) {
-		//退出
-		cancelFullScreen();
-	});
-   	var infovisdiv = document.getElementById("entrelation-infovis");
-	document.onkeydown=function(event){
-        var e = event || window.event || arguments.callee.caller.arguments[0];
-        if(e && e.keyCode==122){
-			event.preventDefault?event.preventDefault():window.event.returnValue = false;
-			if(!!window.ActiveXObject || "ActiveXObject" in window){//ie下F11不能用,屏蔽掉
-				if($(".exit").length == 0){
-					return;
-				}
-			}
-			initFullScreen();
-        }else if(e && e.keyCode==27){
-			event.preventDefault?event.preventDefault():window.event.returnValue = false;
-			cancelFullScreen();
-		}
-    };  
-	function initFullScreen(){
-		var fullscreenElement =
-        document.fullscreenElement ||
-        document.mozFullScreenElement ||
-        document.webkitFullscreenElement ||
-		document.msFullscreenElement;
-	    $(".entrelation-fullscreen").toggleClass("exit");
-		if(!fullscreenElement || fullscreenElement==null){
-			redrawflag = true;
-			$("#entrelation-fullscreen").attr("title","退出全屏视图 (F11)");
-			launchFullScreen(infovisdiv);
-			var timeout = 100;
-			if(!!window.ActiveXObject || "ActiveXObject" in window){
-				timeout = 200;
-			}
-			setTimeout(function(){
-				if(force!=undefined){
-					//重绘
-					var w=document.body.clientWidth;
-					var h=document.body.clientHeight;
-					//if(w>1200){
-						//w= 1200
-					//}
-					$("#entrelation-infovis").css({width:w,height:h});
-					d3.select("svg").attr("width", w).attr("height", h);
-					$(".entrelation-controlls").css({left:w-$(".entrelation-controlls").width() - 70});
-					force.linkDistance(h).charge(-700).size([w,h]).resume();
-				}
-				
-			},timeout);
-		}else{
-			cancelFullScreen();
-		}
-	}
-	//计算点之间的距离
-	var chargeArray = [[0,10],[10,20],[20,30],[30,40],[40,50],[50,60],[60,70],[70,80],[80,90],[90,100],[100,110]];
-	var chargeVal = -1600;
-	var nodeCount = data.nodes.length;
-	for(var i in chargeArray){
-		if(nodeCount >= chargeArray[i][0] && nodeCount < chargeArray[i][1]){
-			chargeVal += i*100;
-			break;
-		}else if(i == chargeArray.length){
-			chargeVal += i*100;
-		}
-	}
-	var tick=function (e) {
-		lines.attr("d", function(d) {
-			var sy   = d.source.y,
-				x    = d.target.x,
-	            y    = d.target.y;
-			if(sy > y){
-				sy -= 12;
-			}else{
-				sy += 5;
-			}
-			var line = new geo.LineSegment(d.source.x, sy, x, y);
-			for (var e in d.target.edge) {
-	            var ix = line.intersect(d.target.edge[e].offset(x, y));
-	            if (ix.in1 && ix.in2) {
-	                x = ix.x;
-	                y = ix.y;
-	                break;
-	            }
-	        }
-	        var dx = x - d.source.x,
-		        dy = y - sy,
-		        dr = Math.sqrt(dx * dx + dy * dy),
-		        theta = Math.atan2(dy, dx) + Math.PI / 7.85,
-		        d90 = Math.PI / 2,
-		        dtxs = x - Math.cos(theta),
-		        dtys = y - Math.sin(theta);
-		    return "M" + d.source.x + "," + sy + "A" + dr + "," + dr + " 0 0 1," + x + "," + y + "A" + dr + "," + dr + " 0 0 0," + d.source.x + "," + sy + "M" + dtxs + "," + dtys +  "l" + (3.5 * Math.cos(d90 - theta) - 10 * Math.cos(theta)) + "," + (-3.5 * Math.sin(d90 - theta) - 10 * Math.sin(theta)) + "L" + (dtxs - 3.5 * Math.cos(d90 - theta) - 10 * Math.cos(theta)) + "," + (dtys + 3.5 * Math.sin(d90 - theta) - 10 * Math.sin(theta)) + "z";
-		});	
-		nodes.attr("transform", function(d) {
-			return "translate(" + d.x + "," + d.y + ")scale(" + zoomlevel+ ")";
-		});
+function b_afterLogin(flag){
+	if($(".ent-tab>li:eq(1)").hasClass("ent-active") && relation == null){
+		initRelation();
 	}
-	var force = d3.layout.force()
-	    .nodes(data.nodes)
-	    .links(data.links)
-	    .size([w, h])
-	    .linkDistance(function(p){
-			return Math.floor(Math.random()*60)+90;
-		})
-		.chargeDistance(600)
-	    .charge(chargeVal)
-		.linkStrength(1)
-		.on('tick',tick);
-	var dragstatus = false,
-	mouseoverstatus = false;
-	var drag = force.drag()
-		.on("dragstart",function(d,i){
-			d.fixed = true;    //拖拽开始后设定被拖拽对象为固定
-			d3.event.sourceEvent.stopPropagation(); // Prevent panning
-		})
-		.on("drag",function(d,i){
-			dragstatus = true;
-			mouseoverstatus = true;
-		})
-		.on("dragend",function(d,i){
-			mouseoverstatus = false;
-			setTimeout(function(){
-				dragstatus = false;
-			},500)
-		});
-	function zoomed() {
-		svg.attr("transform", 
-			"translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
-	}
-	//处理缩放
-	var zoom = d3.behavior.zoom().scaleExtent([0.4, 10]).on("zoom", zoomed);
-	var svg = d3.select("#entrelation-infovis").append("svg:svg")
-	    .attr("width", w)
-	    .attr("height", h)
-		.call(zoom)
-		.append("g");
-		
-	var lines = svg.append("svg:g")
-	    .selectAll("path")
-	    .data(force.links())
-	    .enter().append("path")
-		.style("fill", function(p){
-	    	return (p.type=="cp" || p.isLegal)?"#cd93d7":"#cecece";
-	    })
-		.style("stroke", function(p){
-	    	return (p.type=="cp" || p.isLegal)?"#cd93d7":"#cecece";
-	    })
-		.attr("stroke-width",function (e,i){
-			return e.linkVal;
-		});
-		lines.each(function (d,i){
-			var invacconam = new Number(d.invacconam);
-			if(invacconam > 0){
-				var lenInvacconam = (invacconam + "").length;
-				if(lenInvacconam > 4 && (invacconam + "").indexOf(".") > -1 && (lenInvacconam - (invacconam + "").indexOf(".")) > 4){
-					invacconam = (new Number(invacconam)).toFixed(4);
-				}
-				d3.select(this).append("title").text("投资金额:"+invacconam+"万元");
-			}
-		});
-	var nodes = svg.append("svg:g")
-	    .selectAll(".node")
-	    .data(force.nodes())
-	  	.enter()
-		.append("g")
-		.call(force.drag)
-		.attr('class', 'node')
-		.on('mouseover', function(d) {
-	        highlightObject(this,true);
-	    })
-	    .on('mouseout', function(d) {
-			highlightObject(this,false);
-	    })
-		.on("mousedown",function (e,i){
-			d3.event.preventDefault();
-			removeNode(this);
-		});
-	nodes.append("rect")
-		.attr("rx", 5)
-	    .attr("ry", 5)
-		.attr('height', 20)
-		.attr("fill", function(p){
-			if(p.type == "e" && (p.opstate == "11" || p.opstate == "07")){
-				return "#cecece";
-			}
-	    	return p.type=="p"?"#2196f3":p.type=="ce"?"#ff9800":"#cddc39";
-	    })
-		.attr("stroke", function(p){
-			if(p.type == "e" && (p.opstate == "11" || p.opstate == "07")){
-				return "#cecece";
-			}
-	    	return p.type=="p"?"#2196f3":p.type=="ce"?"#ff9800":"#cddc39";
-	    }).style("opacity",function(p){
-			if(p.type=="e" && (p.opstate != "11" || p.opstate != "07")){
-				return "0.5";
-			}
-			return "1";
-		});
-	nodes.each(function (d,i){
-		if(d.type == "ce" || d.type == "e"){
-			var title = "";
-			if(d.text != d.shortText){
-				title = d.text;
-			}
-			var regcap = d.regcap;
-			if(regcap > 0){
-				var lenRegcap = (regcap + "").length;
-				if(lenRegcap > 4 && (regcap + "").indexOf(".") > -1 && (lenRegcap - (regcap + "").indexOf(".")) > 4){
-					regcap = (new Number(regcap)).toFixed(4);
-				}
-				if(title != ""){
-					title += "\n";
-				}
-				title += "注册资本:"+regcap+"万元";
-			}
-			if(title != ""){
-				d3.select(this).append("title").text(title);
-			}
-		}
-	});
-	nodes.append('text')
-    .text(function(d){
-		return d.shortText;
-	})
-	.style("cursor",function (d,i){
-		if(d.type == "e"){
-			return "pointer";
-		}else{
-			return "auto";
-		}
-	})
-	.on("click",function (d,i){
-		if(!dragstatus && d.type == "e"){
-			window.open("/enterpriseInfoByRegNO/"+d.name+".html");
-		}
-	});
-	setTimeout(function() {
-	    nodes.each(function(d) {
-	        var node   = d3.select(this),
-	            text   = node.selectAll('text'),
-	            bounds = {},
-	            first  = true;
-				
-			text.each(function() {
-	            var box = this.getBBox();
-	            if (first || box.x < bounds.x1) {
-	                bounds.x1 = box.x;
-	            }
-	            if (first || box.y < bounds.y1) {
-	                bounds.y1 = box.y;
-	            }
-	            if (first || box.x + box.width > bounds.x2) {
-	                bounds.x2 = box.x + box.width;
-	            }
-	            if (first || box.y + box.height > bounds.y2) {
-	                bounds.y2 = box.y + box.height;
-	            }
-	            first = false;
-	        }).attr('text-anchor', 'middle');
-				
-	        var padding  = {"left":3,"right":3,"top":2,"bottom":2},
-	            margin   = {"left":3,"right":3,"top":2,"bottom":2},
-	            oldWidth = bounds.x2 - bounds.x1;
-	
-	        bounds.x1 -= oldWidth / 2;
-	        bounds.x2 -= oldWidth / 2;
-	
-	        bounds.x1 -= padding.left;
-	        bounds.y1 -= padding.top;
-	        bounds.x2 += padding.left + padding.right;
-	        bounds.y2 += padding.top  + padding.bottom;
-			
-			var width = bounds.x2 - bounds.x1;
-			var height = bounds.y2 - bounds.y1;
-	        node.select('rect')
-	            .attr('x', bounds.x1)
-	            .attr('y', bounds.y1)
-				//.attr('height', height)
-	            .attr('width', width);
-	            
-	        d.edge = {
-	            left   : new geo.LineSegment(bounds.x1, bounds.y1, bounds.x1, bounds.y2),
-	            right  : new geo.LineSegment(bounds.x2, bounds.y1, bounds.x2, bounds.y2),
-	            top    : new geo.LineSegment(bounds.x1, bounds.y1, bounds.x2, bounds.y1),
-	            bottom : new geo.LineSegment(bounds.x1, bounds.y2, bounds.x2, bounds.y2)
-	        };
-	    });
-	    force.start();
-	},10);
-	function highlightObject(obj,flag){
-		if(mouseoverstatus){
-			return;
-		}
-		if(!flag){
-			d3.selectAll(".node").each(function (){
-				d3.select(this).style("opacity","1");
-			});
-			d3.selectAll("path").each(function (){
-				d3.select(this).style("opacity","1");
-			});
-			return;
-		}
-		var name = obj.__data__.name;
-		d3.selectAll(".node").each(function (){
-			if(name != this.__data__.name){
-				d3.select(this).style("opacity","0.2");
-			}
-		});
-		d3.selectAll("path").each(function (){
-			var targetName = this.__data__.target.name;
-			var sourceName = this.__data__.source.name;
-			if(name != targetName && name != sourceName){
-				d3.select(this).style("opacity","0.2");
+}
+//加载关系网
+function initRelation(){
+	if(isLogined){
+		$.post("/member/getRelation",{regNo:regNo,entName:entName},function(r){
+			if(r.flag == false){
+				$("#entrelation-nologin").addClass("hide");
+				$("#entrelation-limit,#entrelation-noauthe").removeClass("hide");
+				$("#entrelation-infovis").hide();
+			}else if(r.flag == true && (typeof(r) == "undefined" || r == null || r == "")){
+				$("#entrelation-infovis").hide();
+				$("#entrelation-findnull").removeClass("hide");
 			}else{
-				d3.selectAll(".node").each(function (){
-					if(targetName == this.__data__.name || sourceName == this.__data__.name){
-						d3.select(this).style("opacity","1");
-					}
+				loadJS("/js/d3.v3.min.js",function(){
+					loadJS("/js/geometry.js",function(){
+						loadJS("/js/relation.js",function(){
+							$("#entrelation-limit").addClass("hide");
+							$(".entrelation").height(500);
+							relation = new Relation(legcerNo,regNo,r.relation);
+							relation.init();
+						});
+					});
 				});
 			}
 		});
+	}else{
+		$("#entrelation-limit,#entrelation-nologin").removeClass("hide");
 	}
-	function removeNode(obj){
-		if(d3.event.which != 3){
-			return;
-		}
-		highlightObject(obj,false);
-		d3.select(obj).remove();
-		var name = obj.__data__.name;
-		var removeAloneNode = function(removeNodeName){
-			var isRemoveAloneNode = true;
-			d3.selectAll("path").each(function (i){
-				if(removeNodeName == this.__data__.source.name || removeNodeName == this.__data__.target.name){
-					isRemoveAloneNode = false;
-					return true;
-				}
-			});
-			if(isRemoveAloneNode){
-				d3.selectAll("rect").each(function (){
-					if(this.__data__.name == removeNodeName){
-						d3.select(this).remove();
-						return true;
-					}
-				});
-				d3.selectAll("text").each(function (){
-					if(this.__data__.name == removeNodeName){
-						d3.select(this).remove();
-						return true;
-					}
-				});
-			}
-		}
-		d3.selectAll("path").each(function (){
-			if(name == this.__data__.target.name){
-				var fromNodeName = this.__data__.source.name;
-				d3.select(this).remove();
-				removeAloneNode(fromNodeName);
-			}else if(name == this.__data__.source.name){
-				var toNodeName = this.__data__.target.name;
-				d3.select(this).remove();
-				removeAloneNode(toNodeName);
-			}
-		});
-		d3.selectAll("rect").each(function (){
-			if(name == this.__data__.name){
-				d3.select(this).remove();
-			}
-		});
-		d3.selectAll("text").each(function (){
-			if(name == this.__data__.name){
-				d3.select(this).remove();
+}
+//服务列表
+function ServiceList(){
+	loadJS("/js/paging.js",function(){
+		paging = new Paging("serviceList","/front/findServiceByEntId",{entId:entId},6,function(r){
+			var html = '';
+			for(var i=0;i<r.length;i++){
+				
 			}
+			$("#serviceList").html(html);
 		});
-	}
-	var diagonal = d3.svg.diagonal().projection(function(d) { return [d.y, d.x]; });
-	/////////////重绘画布///////////////////
-	var redrawflag=false;
-	//重绘
-	function redraw(){
-		if(force!=undefined){
-			var w = parseInt($("#entrelation").css("width").replace("px","")) - 80;
-			var h = parseInt($("#entrelation").css("height").replace("px",""))-10;
-			d3.select("svg").attr("width", w).attr("height", h);
-			force.size([w,h]).resume();
-			$("#entrelation-infovis").css({width:w,height:h});
-			//
-			redrawflag=false;
-		}
-	}
-	$(window).resize(function(){
-		if(!redrawflag){
-		    //1秒后重绘
-			redrawflag=true;
-			setTimeout(redraw,1000);
-		}
-		firstresize=false;
 	});
-	///////////////////////关系网实例////////////////////////////
-	var htmls="<div style='position:absolute;' class='legend'>";
-	htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #ff9800;'></div><span style='margin-left: 20px;'>本企业</span></div>";
-	htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #cddc39;opacity:0.5;'></div><span style='margin-left: 12px;'>其他企业</span></div>";
-	htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #2196f3;'></div><span style='margin-left: 25px;'>个人</span></div>";
-	htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;margin-bottom: 10px;'><div style='background-color: #cecece;'></div><span style='margin-left: 5px;'>注吊销企业</span></div>";
-	htmls= htmls+ "<div><span style='font-size: 20px;font-weight: bold;color: #cecece;'>→</span><span style=''>投资关系(股东→企业)</span></div>";
-	htmls= htmls+ "<div><span style='font-size: 20px;font-weight: bold;color: #cd93d7;'>→</span><span style=''>法定代表人</span></div>";
-	htmls= htmls+ "<div style='margin:10px 0px;' class='hidden-sm hidden-xs'><span class='text-muted'>提示:点击鼠标右键可以删除不想看的节点。</span></div>";
-	htmls= htmls+"</div>"
-	$("#entrelation-legend").html(htmls);
 }
 
 
@@ -756,11 +118,6 @@ function Relation(data){
 
 
 
-
-
-
-
-
 /*
 function getCityN(code){
 	if(code){
@@ -1064,34 +421,7 @@ function clickservicename(id,isshow){
 		window.location.href="/market/showservice/"+id+".html"
 	}
 }
-function initServiceList(){	
-	$("#service_list").datatable({
-	   perPage: perPage
-	  ,showPagination:false
-	  ,checkbox:"" 
-	  ,checkboxHeader:false
-	  ,showHeader:false
-	  ,idField:"_id"
-	  ,classname:"table-hover"
-	  ,url: '/searchEntSer/' + $entid
-	  ,rowCallback: analyList,
-	   ajaxSuccess:function(res,o){	
-		if(!res || res === undefined || !res.data || res.data.length == 0) {
-			o.continueBody=false;
-			$("#loadMore").hide();
-			$("#service").hide();
-		}else{
-			$("#service").show();
-		}
-		//判断加载更多是否显示
-		if(res.totalRows>5){
-			$("#loadMore").show();
-		}else{
-			$("#loadMore").hide();
-		}
-	   }
-	});
-}
+
 
 
 //显示二维码图片
@@ -1128,7 +458,7 @@ function analyList(rowHtml, rowData) {
 }
 //加载更多
 function loadMore(){
-	$.post('/searchEntSer/'+$entid ,{currentPage:currentPage+1,perPage:perPage},function(data){
+	$.post('/searchEntSer/'+entId ,{currentPage:currentPage+1,perPage:perPage},function(data){
 		if(data){
 			var res=data["data"]
 			if(!res || res === undefined || res.length == 0) {
@@ -1149,13 +479,4 @@ function loadMore(){
 			$("#service_list table tbody").append(str);
 		}
 	})
-}
-
-//设置级联位置信息
-function setcxSelect(){
-	$('#city_china').cxSelect({
-		selects: ['province', 'city', 'area'],
-		required:0
-	});
-	$.cxSelect.setVal(province,city,area);	
 }

+ 18 - 18
core/src/web/staticres/js/qfw.js

@@ -413,24 +413,24 @@ function addCssByLink(url){
         doc.documentElement.appendChild(link);
 }
 //动态加载js
-function loadJS(url, success) {
-  var scripts=document.getElementsByTagName('script')
-  for(var i=0;i<scripts.length;i++){
-	if(scripts[i].src&&scripts[i].src.indexOf(url)>-1){
-		if(success) success();
-		return;
-	}
-  }
-  var domScript = document.createElement('script');
-  domScript.src = url;
-  success = success || function(){};
-  domScript.onload = domScript.onreadystatechange = function() {
-    if (!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState) {
-      success();
-      this.onload = this.onreadystatechange = null;
-      //this.parentNode.removeChild(this);
-    }
-  }
+function loadJS(url, success){
+  	var scripts=document.getElementsByTagName('script')
+	for(var i=0;i<scripts.length;i++){
+		if(scripts[i].src&&scripts[i].src.indexOf(url)>-1){
+			if(success) success();
+			return;
+		}
+  	}
+  	var domScript = document.createElement('script');
+  	domScript.src = url;
+  	success = success || function(){};
+  	domScript.onload = domScript.onreadystatechange = function() {
+	    if (!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState) {
+	      	success();
+	      	this.onload = this.onreadystatechange = null;
+	      	//this.parentNode.removeChild(this);
+	    }
+  	}
   document.getElementsByTagName('head')[0].appendChild(domScript);
 }
 //判断对象是否为空对象{}

+ 722 - 0
core/src/web/staticres/js/relation.js

@@ -0,0 +1,722 @@
+function Relation(legcerNo,regNo,data){
+	this.legcerNo = legcerNo;
+	this.regNo = regNo;
+	this.data = data;
+	this.zoomlevel = 1;
+	this.w = 0;
+	this.h = 0;
+	this.index = -1;
+	this.redrawflag = false;
+	this.infovisdiv = null;
+	this.svg = null;
+	this.force = null;
+	this.lines = null;
+	this.nodes = null;
+	this.mouseoverstatus = false;
+	this.chargeVal = -1600;
+}
+Relation.prototype.init = function(){
+	var thisClass = this;
+	$(function(){
+		$("#entrelation-fullscreen").bind("click",function(){
+			thisClass.initFullScreen();
+		});
+		thisClass.w = $("#entrelation").width();
+		thisClass.h = $("#entrelation").height();
+		$("#entrelation-infovis").width(thisClass.w).append(
+			'<div class="entrelation-controlls hidden-sm hidden-xs">'
+				+'<div class="entrelation-item">'
+					+'<div id="entrelation-fullscreen" class="entrelation-box" title_pos="left"><div class="entrelation-fullscreen"></div></div>'
+				+'</div>'
+			+'</div>'
+		);
+		if($(".entrelation-controlls").length>0){
+			$(".entrelation-controlls").css({left:$("#entrelation").width()-$(".entrelation-controlls").width()});
+		}
+	});
+	//处理全屏
+	$(document).on('webkitfullscreenchange mozfullscreenchange msfullscreenchange fullscreenchange', function(){
+	    if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement){
+			//退出
+			thisClass.cancelFullScreen();
+		}
+	});
+   	this.infovisdiv = document.getElementById("entrelation-infovis");
+	document.onkeydown=function(event){
+        var e = event || window.event || arguments.callee.caller.arguments[0];
+        if(e && e.keyCode==122){
+			event.preventDefault?event.preventDefault():window.event.returnValue = false;
+			if(!!window.ActiveXObject || "ActiveXObject" in window){//ie下F11不能用,屏蔽掉
+				if($(".exit").length == 0){
+					return;
+				}
+			}
+			thisClass.initFullScreen();
+        }else if(e && e.keyCode==27){
+			event.preventDefault?event.preventDefault():window.event.returnValue = false;
+			thisClass.cancelFullScreen();
+		}
+    };
+	$(window).resize(function(){
+		if(!thisClass.redrawflag){
+		    //1秒后重绘
+			thisClass.redrawflag=true;
+			setTimeout(thisClass.redraw,1000);
+		}
+		firstresize=false;
+	});
+	if(document.getElementById("entrelation-infovis")){
+		document.getElementById("entrelation-infovis").oncontextmenu=function(){return false;};
+	}
+	$("#entrelation-fullscreen").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));
+	///////////////////////关系网实例////////////////////////////
+	var htmls="<div style='position:absolute;top:0px;' class='legend'>";
+	htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #ff9800;'></div><span style='margin-left: 20px;'>本企业</span></div>";
+	htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #cddc39;opacity:0.5;'></div><span style='margin-left: 12px;'>其他企业</span></div>";
+	htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;'><div style='background-color: #2196f3;'></div><span style='margin-left: 25px;'>个人</span></div>";
+	htmls= htmls+ "<div class='legend-text-bg' style='margin-top: 10px;margin-bottom: 10px;'><div style='background-color: #cecece;'></div><span style='margin-left: 5px;'>注吊销企业</span></div>";
+	htmls= htmls+ "<div><span style='font-size: 20px;font-weight: bold;color: #cecece;'>→</span><span style=''>投资关系(股东→企业)</span></div>";
+	htmls= htmls+ "<div><span style='font-size: 20px;font-weight: bold;color: #cd93d7;'>→</span><span style=''>法定代表人</span></div>";
+	htmls= htmls+ "<div style='margin:10px 0px;' class='hidden-sm hidden-xs'><span class='text-muted'>提示:点击鼠标右键可以删除不想看的节点。</span></div>";
+	htmls= htmls+"</div>"
+	$("#entrelation").append(htmls);
+	this.dataProcess();
+	this.makeRelation();
+	this.redraw();
+}
+Relation.prototype.dataProcess = function(){
+	var reg = new RegExp(/(有限公司|有限责任公司|股份有限公司|总公司|分公司|公司|事务所|合伙企业)$|\(.*\)|\(.*\)/g);
+	/*var provinces = [];
+	$.ajax({
+		url: "/js/provinceData.min.json",
+		dataType: "json",
+		cache: true,
+		async: false,
+		success: function(json){
+			provinces = json;
+		}
+	});*/
+	for(var i=0;i<this.data.nodes.length;i++){
+		var nodeObj = this.data.nodes[i];
+		nodeObj.text = $.trim(nodeObj.text);
+		nodeObj.shortText = nodeObj.text;
+		if(nodeObj.type == "e" || nodeObj.type == "ce"){
+			var text = nodeObj.shortText;
+			if(text.length > 2){//先替换结尾
+				text = text.replace(reg,"");
+			}
+			if(text.length > 2){//再替换开头
+				//text = this.filterEntName(text);
+			}
+			if(text.length > 2){//小于两个字符不生效
+				nodeObj.shortText = text;
+			}
+			if(nodeObj.name == this.regno){//先找本企业位置
+				this.index = i;
+				nodeObj["regcap"] = (typeof(d1) == "undefined")?0:d1;
+				nodeObj["legcerno"] = this.legcerNo;
+			}
+		}
+	}
+	/*********************************连线处理***********************************/
+	var minLink=-1,maxLink=-1;
+	for(var i=0;i<this.data.links.length;i++){
+		var linkObj = this.data.links[i];
+		if(linkObj.target==this.index && this.data.nodes[linkObj.source].name==this.legcerNo){
+			//this.data.nodes[linkObj.source].type="cp";
+			linkObj.type = "cp"
+			linkObj.isLegal = 1;
+		}
+		//
+		this.data.nodes[linkObj.target]["istarget"] = 1;
+		if(this.data.nodes[linkObj.source].name == this.data.nodes[linkObj.target].invlegcerno || this.data.nodes[linkObj.source].name == this.data.nodes[linkObj.target].legcerno){
+			linkObj.isLegal = 1;
+		}
+		if(typeof(linkObj.invacconam) == "undefined"){
+			continue;
+		}
+		var invacconam = new Number(linkObj.invacconam);
+		if(minLink == -1 && maxLink == -1){
+			minLink = invacconam;
+			maxLink = invacconam;
+		}else if(invacconam > maxLink){
+			maxLink = invacconam; 
+		}else if(invacconam < minLink){
+			minLink = invacconam;
+		}
+	}
+	/////////////
+	var linkSectionArray = this.getLineSectionArray(minLink,maxLink);
+	for(var i=0;i<this.data.links.length;i++){
+		var linksObj = this.data.links[i];
+		linksObj["linkVal"] = 2;
+		if(typeof(linkObj.invacconam) == "undefined"){
+			continue;
+		}
+		var invacconam = new Number(linksObj.invacconam);
+		for(var s in linkSectionArray){
+			var sectionObj = linkSectionArray[s];
+			if(invacconam >= sectionObj.minVal && invacconam < sectionObj.maxVal){
+				linksObj["linkVal"] = sectionObj.linkVal;
+				continue;
+			}
+		}
+	}
+	/*********************************节点处理***********************************/
+	var minNode=-1,maxNode=-1;
+	for(var i=0;i<this.data.nodes.length;i++){
+		var nodeObj = this.data.nodes[i];
+		if(nodeObj.type == "e" || nodeObj.type == "ce"){
+			var regcap = nodeObj.regcap;
+			if(minNode == -1 && maxNode == -1){
+				minNode = regcap;
+				maxNode = regcap;
+			}else if(regcap > maxNode){
+				maxNode = regcap; 
+			}else if(regcap < minNode){
+				minNode = regcap;
+			}
+		}
+	}
+	var nodeSectionArray = this.getNodeSectionArray(minNode,maxNode);
+	for(var i=0;i<this.data.nodes.length;i++){
+		var nodeObj = this.data.nodes[i];
+		nodeObj["nodeVal"] = 7;
+		if(nodeObj.type == "e" || nodeObj.type == "ce"){
+			var invacconam = new Number(nodeObj.invacconam);
+			var regcap = new Number(nodeObj.regcap);
+			for(var s in nodeSectionArray){
+				var sectionObj = nodeSectionArray[s];
+				if(regcap >= sectionObj.minVal && regcap < sectionObj.maxVal){
+					nodeObj["nodeVal"] = sectionObj.nodeVal;
+					continue;
+				}
+			}
+		}
+	}
+	//计算点之间的距离
+	var chargeArray = [[0,10],[10,20],[20,30],[30,40],[40,50],[50,60],[60,70],[70,80],[80,90],[90,100],[100,110]];
+	var nodeCount = this.data.nodes.length;
+	for(var i in chargeArray){
+		if(nodeCount >= chargeArray[i][0] && nodeCount < chargeArray[i][1]){
+			this.chargeVal += i*100;
+			break;
+		}else if(i == chargeArray.length){
+			this.chargeVal += i*100;
+		}
+	}
+}
+Relation.prototype.filterEntName = function(text){
+	this.allProvinces = "河南省、青海省、山西省、黑龙江省、安徽省、广西壮族自治区、西藏自治区";
+	this.commonReplace = function(t){
+		if(t.length > 1 && text.startWith(t)){
+			var textCopy = text.replace(new RegExp("^"+t),"");
+			if(textCopy.length > 2){
+				text = textCopy;
+			}
+			return true;
+		}
+		return false;
+	};
+	this.replaceStart = function(t,f){
+		var flag = false;
+		var minus = null;
+		if(this.commonReplace(t)){//替换省、市、县、区
+			return true;
+		}
+		if(f){//不替换
+			flag = false;
+		}else if(t.endWith("维吾尔自治区")){
+			flag = true;
+			minus = 6;
+		}else if(t.endWith("回族自治区") || t.endWith("壮族自治区") || t.endWith("特别行政区")){
+			flag = true;
+			minus = 5;
+		}else if(t.endWith("自治州") || t.endWith("自治县") || t.endWith("自治区")){
+			flag = true;
+			minus = 3;
+		}else if(t.endWith("地区")){
+			flag = true;
+			minus = 2;
+		}else if(t.endWith("省") || t.endWith("市") || t.endWith("区")){
+			flag = true;
+			minus = 1;
+		}
+		if(flag){
+			return this.commonReplace(t.substring(0,t.length-minus));
+		}
+		return false;
+	};
+	this.replaceCity = function(citys){
+		if(citys){
+			for(var c in citys){//市
+				var c_name = citys[c].n;
+				if(this.replaceStart(c_name)){
+					this.replaceAreas(citys[c].s);
+					return true;
+				}else if(this.replaceAreas(citys[c].s)){
+					return true;
+				}
+			}
+		}
+	};
+	this.replaceAreas = function(areas){
+		if(areas){
+			for(var a in areas){//县、区
+				var a_name = areas[a].n;
+				if(this.replaceStart(a_name,true)){
+					return true;
+				}
+			}
+		}
+	};
+	for(var p in provinces){//省
+		var p_name = provinces[p].n;
+		if(this.allProvinces.indexOf(p_name) == -1){
+			continue;
+		}
+		if(this.replaceStart(p_name)){
+			this.replaceCity(provinces[p].s);
+			break;
+		}else if(this.replaceCity(provinces[p].s)){
+			break;
+		}
+	}
+	return text;
+}
+Relation.prototype.getLineSectionArray = function(minLink,maxLink){
+	var countSection = 6;
+	var section = (maxLink - minLink) / countSection;
+	var sectionArr = [];
+	for(var i=2;i<=countSection;i++){
+		var minVal = minLink;
+		if(sectionArr.length > 0){
+			minVal = sectionArr[sectionArr.length - 1].maxVal;
+		}
+		var maxVal = minLink+section*i;
+		if(i == countSection){
+			maxVal += section;
+		}
+		var sectionObj = {linkVal:i,minVal:minVal,maxVal:maxVal};
+		sectionArr.push(sectionObj);
+	}
+	return sectionArr;
+}
+Relation.prototype.getNodeSectionArray = function(minNode,maxNode){
+	var countSection = 7;
+	var section = (maxNode - minNode) / countSection;
+	var sectionArr = [];
+	for(var i=1;i<=countSection;i++){
+		var minVal = minNode;
+		if(sectionArr.length > 0){
+			minVal = sectionArr[sectionArr.length - 1].maxVal;
+		}
+		var maxVal = minNode+section*i;
+		if(i == countSection){
+			maxVal += section;
+		}
+		var sectionObj = {nodeVal:6+i,minVal:minVal,maxVal:maxVal};
+		sectionArr.push(sectionObj);
+	}
+	return sectionArr;
+}
+Relation.prototype.launchFullScreen = function(element) {
+  	if(element){
+	  	if (element.requestFullscreen) {
+	      element.requestFullscreen();
+	    } else if (element.msRequestFullscreen) {
+	      element.msRequestFullscreen();
+	    } else if (element.mozRequestFullScreen) {
+	      element.mozRequestFullScreen();
+	    } else if (element.webkitRequestFullscreen) {
+			// 对 Chrome 特殊处理,
+	        // 参数 Element.ALLOW_KEYBOARD_INPUT 使全屏状态中可以键盘输入。
+	        if ( window.navigator.userAgent.toUpperCase().indexOf( 'CHROME' ) >= 0 ) {
+	              element.webkitRequestFullScreen( Element.ALLOW_KEYBOARD_INPUT );
+	        }else {
+				// Safari 浏览器中,如果方法内有参数,则 Fullscreen 功能不可用。
+	           element.webkitRequestFullScreen();
+	        }
+	    }
+  	}
+}
+Relation.prototype.cancelFullScreen = function(){
+	this.h = $("#entrelation-infovis").height();  
+	$("#entrelation-fullscreen").attr("title","进入全屏视图"+((!!window.ActiveXObject || "ActiveXObject" in window)?"":" (F11)"));	
+	//force.linkDistance(120).charge(-200).size([w,h]).resume();
+	$("#entrelation-infovis").css({width:this.w,height:this.h});
+	//设置svg标签的宽度与高度
+	d3.select("svg").attr("width", this.w).attr("height", this.h);
+	$(".entrelation-controlls").css({left:$("#entrelation").width()-$(".entrelation-controlls").width()-30});
+    if(document.exitFullscreen) {
+      document.exitFullscreen();
+    } else if (document.msExitFullscreen) {
+      document.msExitFullscreen();
+    } else if (document.mozCancelFullScreen) {
+      document.mozCancelFullScreen();
+    } else if (document.webkitExitFullscreen) {
+      document.webkitExitFullscreen();
+    }
+}
+Relation.prototype.initFullScreen = function(){
+	var thisClass = this;
+	var fullscreenElement =
+       	document.fullscreenElement ||
+       	document.mozFullScreenElement ||
+       	document.webkitFullscreenElement ||
+		document.msFullscreenElement;
+    $(".entrelation-fullscreen").toggleClass("exit");
+	if(!fullscreenElement || fullscreenElement==null){
+		this.redrawflag = true;
+		$("#entrelation-fullscreen").attr("title","退出全屏视图 (F11)");
+		this.launchFullScreen(this.infovisdiv);
+		var timeout = 100;
+		if(!!window.ActiveXObject || "ActiveXObject" in window){
+			timeout = 200;
+		}
+		setTimeout(function(){
+			if(thisClass.force != null){
+				//重绘
+				var w=document.body.clientWidth;
+				var h=document.body.clientHeight;
+				//if(w>1200){
+					//w= 1200
+				//}
+				$("#entrelation-infovis").css({width:w,height:h});
+				d3.select("svg").attr("width", w).attr("height", h);
+				$(".entrelation-controlls").css({left:w-$(".entrelation-controlls").width() - 70});
+				thisClass.force.linkDistance(h).charge(-700).size([w,h]).resume();
+			}
+			
+		},timeout);
+	}else{
+		this.cancelFullScreen();
+	}
+}
+//重绘
+Relation.prototype.redraw = function(){
+	if(this.force != undefined){
+		d3.select("svg").attr("width",this.w).attr("height", this.h);
+		this.force.size([this.w,this.h]).resume();
+		$("#entrelation-infovis").css({width:this.w,height:this.h});
+		//
+		this.redrawflag = false;
+	}
+}
+Relation.prototype.removeNode = function(obj){
+	if(d3.event.which != 3){
+		return;
+	}
+	this.highlightObject(obj,false);
+	d3.select(obj).remove();
+	var name = obj.__data__.name;
+	var removeAloneNode = function(removeNodeName){
+		var isRemoveAloneNode = true;
+		d3.selectAll("path").each(function (i){
+			if(removeNodeName == this.__data__.source.name || removeNodeName == this.__data__.target.name){
+				isRemoveAloneNode = false;
+				return true;
+			}
+		});
+		if(isRemoveAloneNode){
+			d3.selectAll("rect").each(function (){
+				if(this.__data__.name == removeNodeName){
+					d3.select(this).remove();
+					return true;
+				}
+			});
+			d3.selectAll("text").each(function (){
+				if(this.__data__.name == removeNodeName){
+					d3.select(this).remove();
+					return true;
+				}
+			});
+		}
+	}
+	d3.selectAll("path").each(function (){
+		if(name == this.__data__.target.name){
+			var fromNodeName = this.__data__.source.name;
+			d3.select(this).remove();
+			removeAloneNode(fromNodeName);
+		}else if(name == this.__data__.source.name){
+			var toNodeName = this.__data__.target.name;
+			d3.select(this).remove();
+			removeAloneNode(toNodeName);
+		}
+	});
+	d3.selectAll("rect").each(function (){
+		if(name == this.__data__.name){
+			d3.select(this).remove();
+		}
+	});
+	d3.selectAll("text").each(function (){
+		if(name == this.__data__.name){
+			d3.select(this).remove();
+		}
+	});
+}
+Relation.prototype.tick = function(e){
+	var thisClass = this;
+	this.lines.attr("d", function(d){
+		var sy   = d.source.y,
+			x    = d.target.x,
+            y    = d.target.y;
+		if(sy > y){
+			sy -= 12;
+		}else{
+			sy += 5;
+		}
+		var line = new geo.LineSegment(d.source.x, sy, x, y);
+		for (var e in d.target.edge) {
+            var ix = line.intersect(d.target.edge[e].offset(x, y));
+            if (ix.in1 && ix.in2) {
+                x = ix.x;
+                y = ix.y;
+                break;
+            }
+        }
+        var dx = x - d.source.x,
+	        dy = y - sy,
+	        dr = Math.sqrt(dx * dx + dy * dy),
+	        theta = Math.atan2(dy, dx) + Math.PI / 7.85,
+	        d90 = Math.PI / 2,
+	        dtxs = x - Math.cos(theta),
+	        dtys = y - Math.sin(theta);
+	    return "M" + d.source.x + "," + sy + "A" + dr + "," + dr + " 0 0 1," + x + "," + y + "A" + dr + "," + dr + " 0 0 0," + d.source.x + "," + sy + "M" + dtxs + "," + dtys +  "l" + (3.5 * Math.cos(d90 - theta) - 10 * Math.cos(theta)) + "," + (-3.5 * Math.sin(d90 - theta) - 10 * Math.sin(theta)) + "L" + (dtxs - 3.5 * Math.cos(d90 - theta) - 10 * Math.cos(theta)) + "," + (dtys + 3.5 * Math.sin(d90 - theta) - 10 * Math.sin(theta)) + "z";
+	});	
+	this.nodes.attr("transform", function(d) {
+		return "translate(" + d.x + "," + d.y + ")scale(" + thisClass.zoomlevel+ ")";
+	});
+}
+Relation.prototype.zoomed = function() {
+	this.svg.attr("transform", 
+		"translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
+}
+Relation.prototype.highlightObject = function(obj,flag){
+	if(this.mouseoverstatus){
+		return;
+	}
+	if(!flag){
+		d3.selectAll(".node").each(function (){
+			d3.select(this).style("opacity","1");
+		});
+		d3.selectAll("path").each(function (){
+			d3.select(this).style("opacity","1");
+		});
+		return;
+	}
+	var name = obj.__data__.name;
+	d3.selectAll(".node").each(function (){
+		if(name != this.__data__.name){
+			d3.select(this).style("opacity","0.2");
+		}
+	});
+	d3.selectAll("path").each(function (){
+		var targetName = this.__data__.target.name;
+		var sourceName = this.__data__.source.name;
+		if(name != targetName && name != sourceName){
+			d3.select(this).style("opacity","0.2");
+		}else{
+			d3.selectAll(".node").each(function (){
+				if(targetName == this.__data__.name || sourceName == this.__data__.name){
+					d3.select(this).style("opacity","1");
+				}
+			});
+		}
+	});
+}
+Relation.prototype.makeRelation = function(){
+	var thisClass = this;
+	this.force = d3.layout.force()
+	    .nodes(this.data.nodes)
+	    .links(this.data.links)
+	    .size([this.w, this.h])
+	    .linkDistance(function(p){
+			return Math.floor(Math.random()*60)+90;
+		})
+		.chargeDistance(600)
+	    .charge(this.chargeVal)
+		.linkStrength(1)
+		.on('tick',function(){
+			thisClass.tick();
+		});
+	var dragstatus = false;
+	var drag = this.force.drag()
+		.on("dragstart",function(d,i){
+			d.fixed = true;    //拖拽开始后设定被拖拽对象为固定
+			d3.event.sourceEvent.stopPropagation(); // Prevent panning
+		})
+		.on("drag",function(d,i){
+			dragstatus = true;
+			thisClass.mouseoverstatus = true;
+		})
+		.on("dragend",function(d,i){
+			thisClass.mouseoverstatus = false;
+			setTimeout(function(){
+				dragstatus = false;
+			},500)
+		});
+	
+	//处理缩放
+	var zoom = d3.behavior.zoom().scaleExtent([0.4, 10]).on("zoom", function(){
+		thisClass.zoomed();
+	});
+	this.svg = d3.select("#entrelation-infovis").append("svg:svg")
+	    .attr("width", this.w)
+	    .attr("height", this.h)
+		.call(zoom)
+		.append("g");
+	this.lines = this.svg.append("svg:g")
+	    .selectAll("path")
+	    .data(this.force.links())
+	    .enter().append("path")
+		.style("fill", function(p){
+	    	return (p.type=="cp" || p.isLegal)?"#cd93d7":"#cecece";
+	    })
+		.style("stroke", function(p){
+	    	return (p.type=="cp" || p.isLegal)?"#cd93d7":"#cecece";
+	    })
+		.attr("stroke-width",function (e,i){
+			return e.linkVal;
+		});
+	this.lines.each(function (d,i){
+		var invacconam = new Number(d.invacconam);
+		if(invacconam > 0){
+			var lenInvacconam = (invacconam + "").length;
+			if(lenInvacconam > 4 && (invacconam + "").indexOf(".") > -1 && (lenInvacconam - (invacconam + "").indexOf(".")) > 4){
+				invacconam = (new Number(invacconam)).toFixed(4);
+			}
+			d3.select(this).append("title").text("投资金额:"+invacconam+"万元");
+		}
+	});
+	this.nodes = this.svg.append("svg:g")
+	    .selectAll(".node")
+	    .data(this.force.nodes())
+	  	.enter()
+		.append("g")
+		.call(this.force.drag)
+		.attr('class', 'node')
+		.on('mouseover', function(d) {
+	        thisClass.highlightObject(this,true);
+	    })
+	    .on('mouseout', function(d) {
+			thisClass.highlightObject(this,false);
+	    })
+		.on("mousedown",function (e,i){
+			d3.event.preventDefault();
+			thisClass.removeNode(this);
+		});
+	this.nodes.append("rect")
+		.attr("rx", 5)
+	    .attr("ry", 5)
+		.attr('height', 20)
+		.attr("fill", function(p){
+			if(p.type == "e" && (p.opstate == "11" || p.opstate == "07")){
+				return "#cecece";
+			}
+	    	return p.type=="p"?"#2196f3":p.type=="ce"?"#ff9800":"#cddc39";
+	    })
+		.attr("stroke", function(p){
+			if(p.type == "e" && (p.opstate == "11" || p.opstate == "07")){
+				return "#cecece";
+			}
+	    	return p.type=="p"?"#2196f3":p.type=="ce"?"#ff9800":"#cddc39";
+	    }).style("opacity",function(p){
+			if(p.type=="e" && (p.opstate != "11" || p.opstate != "07")){
+				return "0.5";
+			}
+			return "1";
+		});
+	this.nodes.each(function (d,i){
+		if(d.type == "ce" || d.type == "e"){
+			var title = "";
+			if(d.text != d.shortText){
+				title = d.text;
+			}
+			var regcap = d.regcap;
+			if(regcap > 0){
+				var lenRegcap = (regcap + "").length;
+				if(lenRegcap > 4 && (regcap + "").indexOf(".") > -1 && (lenRegcap - (regcap + "").indexOf(".")) > 4){
+					regcap = (new Number(regcap)).toFixed(4);
+				}
+				if(title != ""){
+					title += "\n";
+				}
+				title += "注册资本:"+regcap+"万元";
+			}
+			if(title != ""){
+				d3.select(this).append("title").text(title);
+			}
+		}
+	});
+	this.nodes.append('text')
+    .text(function(d){
+		return d.shortText;
+	})
+	.style("cursor",function (d,i){
+		if(d.type == "e"){
+			return "pointer";
+		}else{
+			return "auto";
+		}
+	})
+	.on("click",function (d,i){
+		if(!dragstatus && d.type == "e"){
+			window.open("/enterpriseInfoByRegNO/"+d.name+".html");
+		}
+	});
+	setTimeout(function() {
+	    thisClass.nodes.each(function(d) {
+	        var node   = d3.select(this),
+	            text   = node.selectAll('text'),
+	            bounds = {},
+	            first  = true;
+				
+			text.each(function() {
+	            var box = this.getBBox();
+	            if (first || box.x < bounds.x1) {
+	                bounds.x1 = box.x;
+	            }
+	            if (first || box.y < bounds.y1) {
+	                bounds.y1 = box.y;
+	            }
+	            if (first || box.x + box.width > bounds.x2) {
+	                bounds.x2 = box.x + box.width;
+	            }
+	            if (first || box.y + box.height > bounds.y2) {
+	                bounds.y2 = box.y + box.height;
+	            }
+	            first = false;
+	        }).attr('text-anchor', 'middle');
+				
+	        var padding  = {"left":3,"right":3,"top":2,"bottom":2},
+	            margin   = {"left":3,"right":3,"top":2,"bottom":2},
+	            oldWidth = bounds.x2 - bounds.x1;
+	
+	        bounds.x1 -= oldWidth / 2;
+	        bounds.x2 -= oldWidth / 2;
+	
+	        bounds.x1 -= padding.left;
+	        bounds.y1 -= padding.top;
+	        bounds.x2 += padding.left + padding.right;
+	        bounds.y2 += padding.top  + padding.bottom;
+			
+			var width = bounds.x2 - bounds.x1;
+			var height = bounds.y2 - bounds.y1;
+	        node.select('rect')
+	            .attr('x', bounds.x1)
+	            .attr('y', bounds.y1)
+				//.attr('height', height)
+	            .attr('width', width);
+	            
+	        d.edge = {
+	            left   : new geo.LineSegment(bounds.x1, bounds.y1, bounds.x1, bounds.y2),
+	            right  : new geo.LineSegment(bounds.x2, bounds.y1, bounds.x2, bounds.y2),
+	            top    : new geo.LineSegment(bounds.x1, bounds.y1, bounds.x2, bounds.y1),
+	            bottom : new geo.LineSegment(bounds.x1, bounds.y2, bounds.x2, bounds.y2)
+	        };
+	    });
+	   thisClass.force.start();
+	},10);
+	//var diagonal = d3.svg.diagonal().projection(function(d) { return [d.y, d.x]; });
+}

+ 2 - 2
core/src/web/staticres/wxswordfish/share.js

@@ -10,7 +10,7 @@ function initShare(signature){
 		});
 		wx.ready(function () {
 	        wx.onMenuShareTimeline({
-			    title: '剑鱼招标订阅免费用,关注即可抽取iPadmini。', // 分享标题
+			    title: '剑鱼招标订阅免费用,关注即可抽取iPad mini。', // 分享标题
 			    link: 'http://www.qimingxing.info/swordfish/share', // 分享链接
 			    imgUrl: 'http://www.qimingxing.info/wxswordfish/images/share-icon.png', // 分享图标
 			    success: function () { 
@@ -22,7 +22,7 @@ function initShare(signature){
 			});
 			
 			wx.onMenuShareAppMessage({
-			    title: '剑鱼招标订阅免费用,关注即可抽取iPadmini。', // 分享标题
+			    title: '剑鱼招标订阅免费用,关注即可抽取iPad mini。', // 分享标题
 			    desc: '关注微信并设置剑鱼关键词,全国招标信息统统推送给您!', // 分享描述
 			    link: 'http://www.qimingxing.info/swordfish/share', // 分享链接
 			    imgUrl: 'http://www.qimingxing.info/wxswordfish/images/share-icon.png', // 分享图标

+ 10 - 12
core/src/web/templates/_err.html

@@ -3,20 +3,18 @@
 	<title>企明星----网页错误</title>
 	{{include "/common/inc.html"}}
 	<body>
-	<div class="container-fluid">
-	<div class="row page-header" style="height:100px;margin:20px 0;">
-	 <a href="/"><img  src="/images/logo.png" class="header_logo"/></a>
-	</div>
-	<div class="row" style="margin:50px 0;">
-		<div class="col-lg-6 col-md-6 col-sm-6 " style="text-align:right">
-		 <img src="/images/404.png" width="200" height="275"/>
-		</div>
-		<div class="col-lg-6 col-md-6 col-sm-6 " style="padding-top: 50px;padding-bottom: 50px;">
-			<div style="padding-left: 55px;"><h4><strong class="text-muted">网络错误,页面找不到</strong></h4></div>
-			<div id="alink" class="text-center" style="width:300px;margin-top:30px;"><h4 style="display:inline-block;"><a href="{{.T.refer}}"><img s1="reload.png" s2="u170.png" src="/images/reload.png" style="width:18px;margin-right:5px;">刷新页面</a> | </h4><h4 style="display:inline-block"><a href="/"><img s1="home1.png" s2="home2.png" src="/images/home1.png" style="width:18px;margin-right:5px;">返回首页</a></h4></div>
+	{{include "/common/errorhead.html"}}
+	<div class="container-fluid b-content">
+		<div class="row" style="margin:50px 0;">
+			<div class="col-lg-6 col-md-6 col-sm-6" style="text-align:right">
+			 <img src="/images/404.png" width="200" height="275"/>
+			</div>
+			<div class="col-lg-6 col-md-6 col-sm-6" style="padding-top: 100px;padding-bottom: 50px;">
+				<div style="padding-left: 55px;"><h4><strong class="text-muted">网络错误,页面找不到</strong></h4></div>
+				<div id="alink" class="text-center" style="width:300px;margin-top:30px;"><h4 style="display:inline-block;"><a href="{{.T.refer}}"><img s1="reload.png" s2="u170.png" src="/images/reload.png" style="width:18px;margin-right:5px;">刷新页面</a> | </h4><h4 style="display:inline-block"><a href="/"><img s1="home1.png" s2="home2.png" src="/images/home1.png" style="width:18px;margin-right:5px;">返回首页</a></h4></div>
+			</div>
 		</div>
 	</div>
-	</div>
 	<script>
 	$(function(){
 		$("#alink a").hover(function(){

+ 22 - 16
core/src/web/templates/active/luckdraw.html

@@ -32,17 +32,23 @@
 </button>
 <!-- 模态框(Modal) -->
 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
-   aria-labelledby="myModalLabel" aria-hidden="true" style="margin-top: 25%;
-">
+   aria-labelledby="myModalLabel" aria-hidden="true" style="padding-top: 25%;">
    <div class="modal-dialog">
       <div class="modal-content">
+	
+         <div class="modal-header">
+            <button type="button" class="close" 
+               data-dismiss="modal" aria-hidden="true" style="width: 40px;height: 30px;">
+                  &times;
+            </button>
+            <h4 class="modal-title" id="myModalLabel">
+               企明星新年大抽奖
+            </h4>
+         </div>
          <div class="modal-body">
             
          </div>
          <div class="modal-footer">
-            <button type="button" class="btn btn-primary" 
-               data-dismiss="modal">关闭
-            </button>
          </div>
       </div><!-- /.modal-content -->
 </div><!-- /.modal -->
@@ -58,9 +64,13 @@
 $(function(){ 
     var flog = {{.T.flog}};
 	if (flog == "A"){
-		$(".modal-body").html("小主莫贪心,每人只有一次抽奖机会呦!<br/><br/>小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)")
+		$(".modal-body").html("{{.T.msg}}")
+		$(".modstart").click();
+		$("#btn_run").attr('disabled',true).css("cursor","pointer").css("background","url(/images/activeimages/btn_end.png) no-repeat").css("background-size","100% 100%");
+	}else if (flog == "B"){
+		$(".modal-body").html("{{.T.msg}}")
 		$(".modstart").click();
-		$("#btn_run").attr('disabled',true).css("cursor","pointer");
+		$("#btn_run").attr('disabled',true).css("cursor","pointer").css("background","url(/images/activeimages/btn_end.png) no-repeat").css("background-size","100% 100%");
 	}
      $("#btn_run").click(function(){
 		$("#btn_run").attr('disabled',true).css("cursor","default"); 
@@ -84,21 +94,17 @@ function lottery(){
 					easing: $.easing.easeOutSine, 
 					callback: function(){ 
 						//alert(obj.results); 
-						$("#btn_run").attr('disabled',true).css("cursor","pointer"); 
-						if (obj.prize == "谢谢参与"){
-							$(".modal-body").html("小主不要桑心,这次没有中奖不代表什么,猴年依然会好运气爆棚滴~~<br/><br/>小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)")
-							$(".modstart").click();
-						}else{
-							$(".modal-body").html("小主是真真的好运气,"+obj.prize+"落入您囊中,请速速微信联系企明星确认领奖事宜!<br/><br/>小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)")
+						$("#btn_run").attr('disabled',true).css("cursor","pointer").css("background","url(/images/activeimages/btn_end.png) no-repeat").css("background-size","100% 100%"); 
+							$(".modal-body").html(obj.msg)
 							$(".modstart").click();
-						}
+							$("#btn_run").attr('disabled',true).css("cursor","pointer").css("background","url(/images/activeimages/btn_end.png) no-repeat").css("background-size","100% 100%");
 					} 
 				});
 			}else if (obj.flog=="A"){
-				$(".modal-body").html("小主莫贪心,每人只有一次抽奖机会呦!<br/><br/>小主翻个牌子,动动小手分享活动,么么哒……(分享点击页面右上方···分享到朋友圈)")
+				$(".modal-body").html(obj.msg)
 				$(".modstart").click();
 			}else if (obj.flog=="F"){
-				$(".modal-body").html("小主来晚了,抽奖活动已过期!如果有疑问请联系企明星!")
+				$(".modal-body").html("  小主来晚了,抽奖活动已过期!如果有疑问请联系企明星!")
 				$(".modstart").click();
 			}
         } 

+ 9 - 0
core/src/web/templates/common/errorhead.html

@@ -0,0 +1,9 @@
+<div class="b-head">
+	{{include "/common/top.html"}}
+	<div class="b-nav">
+		<ul>
+			<li class="b-nav-logo"><a href="/"><img src="/images/logo.png" class="logo"></a></li>
+			<li class="pull-right b-loginStatus" id="b-loginStatus"></li>
+		</ul>
+	</div>
+</div>

+ 0 - 4
core/src/web/templates/common/login.html

@@ -57,7 +57,6 @@
 </style>
 <script src="/js/validform-min.js"></script>
 <script type="text/javascript">
-
 //打开登录窗口
 function loginModalShow(lbt){
 	$("#head-navbar").toggleClass("hidden-xs");
@@ -69,9 +68,6 @@ function loginModalShow(lbt){
 		}
 	}
 	if(lbt>7)loginBackType = lbt;
-
-
-
 	$("#wxPic").attr("src","");
 	$.post("/front/wxlogin/getNum",function(data){
 		if(data&&data.num){		

+ 2 - 2
core/src/web/templates/common/swordfishhead.html

@@ -18,8 +18,8 @@ function open_window(link){
 	}
 	window.open("/visit/redirect?url="+escape(link));
 }
-function b_loadTopCallBack(result){
-	if(isLogined){
+function b_afterLogin(flag,result){
+	if(flag){
 		//立即体验
 		$("#experience").click(function(){
 			window.location.href = "/member/swordfish/rssset";

+ 1 - 1
core/src/web/templates/common/top.html

@@ -103,7 +103,7 @@ function b_loadTop(){
 				$("body").append('{{include "/common/login.html"}}');
 			}
 			try{
-				b_loadTopCallBack(result);
+				b_afterLogin(isLogined,result);
 			}catch(e){}
 		},
 		error: function(e){

+ 122 - 1
core/src/web/templates/index.html

@@ -199,10 +199,131 @@
 			{{end}}
  			{{end}}
 		</div>
+		
+		<div class="index-new-tg index-new-bmzhsk">
+		<div class="row">
+		<div class="col-sm-1 index-new-tg-tb">
+		<ul>
+		<li>
+		<div class="bmzhsk"><img src="/images/u0115.png"/></div>
+		<div class="bmjy"><img src="/images/u0117.png"/></div>
+		<div class="bmrzqy"><img src="/images/u0119.png"/></div>
+		</li>
+		<li class="index-new-mingcheng"><div class="text-center" style="height: 119px;">知识库</div></li>
+		</ul>
+		</div>
+		<div class="col-sm-5 index-new-tg-con">
+		<ul>
+		{{range $k,$v:=.T.zkdata}}
+		{{ if lt $k 8}}
+		<li><span></span><span><a target="_blank" href="/front/webcontent/{{index $v "_id"}}.html"/>{{index $v "s_title"}}</a></span><span style="float:right;">{{if eq (index $v "releasetime") ""}}{{index $v "l_createdate"}}{{else}}{{index $v "releasetime"}}{{end}}</span></li>
+		{{if ge $k 3}}
+		{{if lt $k 4}}
+		</ul>
+		</div>
+		<div class="col-sm-1"></div>
+		<div class="col-sm-5 index-new-tg-con">
+		<ul>
+		{{end}}
+		{{end}}
+			
+		{{end}}
+		{{end}}
+		</ul>
+		</div>
+		</div>
+		</div>
+		
+		
+		<div class="index-new-tg index-new-bmjy hidden">
+		<div class="row">
+		<div class="col-sm-1 index-new-tg-tb">
+		<ul>
+		<li>
+		<div class="bmzhsk"><img src="/images/u0116.png"/></div>
+		<div class="bmjy"><img src="/images/u0118.png"/></div>
+		<div class="bmrzqy"><img src="/images/u0119.png"/></div>
+		</li>
+		<li class="index-new-mingcheng"><div class="text-center" style="padding-top: 35px;height: 119px;">剑鱼</div></li>
+		</ul>
+		</div>
+		<div class="col-sm-5 index-new-tg-con">
+		<ul>
+		{{range $k,$v:=.T.sfdata}}
+		{{ if lt $k 8}}
+		<li><span></span><span><a target="_blank" href="http://{{index $v "href"}}"/>{{index $v "title"}}</a></span><span style="float:right;">{{if (index $v "publishtime")}}{{index $v "publishtime"}}{{else}}------{{end}}</span></li>
+		{{if ge $k 3}}
+		{{if lt $k 4}}
+		</ul>
+		</div>
+		<div class="col-sm-1"></div>
+		<div class="col-sm-5 index-new-tg-con">
+		<ul>
+		{{end}}
+		{{end}}
+			
+		{{end}}
+		{{end}}
+		</ul>
+		</div>
+		</div>
+		</div>
+		
+		
+		<div class="index-new-tg index-new-bmrzqy hidden">
+		<div class="row">
+		<div class="col-sm-1 index-new-tg-tb">
+		<ul>
+		<li>
+		<div class="bmzhsk"><img src="/images/u0116.png"/></div>
+		<div class="bmjy"><img src="/images/u0117.png"/></div>
+		<div class="bmrzqy"><img src="/images/u0120.png"/></div>
+		</li>
+		<li class="index-new-mingcheng"><div class="text-center" style="padding-top: 15px;height: 119px;">认证企业</div></li>
+		</ul>
+		</div>
+		<div class="col-sm-5 index-new-tg-con">
+		<ul>
+		{{range $k,$v:=.T.entdata}}
+		{{ if lt $k 8}}
+		<li><span></span><span><a target="_blank" href="/enterprise/{{index $v "s_enterpriseid"}}.html"/>{{index $v "s_enterprisename"}}</a></span><span style="float:right;">{{if (index $v "l_auditdate")}}{{index $v "l_auditdate"}}{{else}}------{{end}}</span></li>
+		{{if ge $k 3}}
+		{{if lt $k 4}}
+		</ul>
+		</div>
+		<div class="col-sm-1"></div>
+		<div class="col-sm-5 index-new-tg-con">
+		<ul>
+		{{end}}
+		{{end}}
+			
+		{{end}}
+		{{end}}
+		</ul>
+		</div>
+		</div>
+		</div>
+		
 	</div>
+	
 </div>
 {{include "/common/bottom.html"}}
 <script>
+$(".bmzhsk").mouseover(function(){
+	$(".index-new-bmrzqy").addClass("hidden");
+	$(".index-new-bmjy").addClass("hidden");
+	$(".index-new-bmzhsk").removeClass("hidden");
+});
+$(".bmjy").mouseover(function(){
+	$(".index-new-bmrzqy").addClass("hidden");
+	$(".index-new-bmzhsk").addClass("hidden");
+	$(".index-new-bmjy").removeClass("hidden");
+});
+$(".bmrzqy").mouseover(function(){
+	$(".index-new-bmzhsk").addClass("hidden");
+	$(".index-new-bmjy").addClass("hidden");
+	$(".index-new-bmrzqy").removeClass("hidden");
+});
 function gomarket(code){
 	$("#c_fwtype").val(code);
 	$("form#searchForm").submit();
@@ -263,7 +384,7 @@ $(function(){
 	}else{
 		//活动处理
 		if(hasNewActive){
-			$(".a-index-hd").append('<img src="/images/activeimages/chjhd.png" onclick="window.open(\'/front/webactivitycontent/5697403b7e1eac37d5000001.html\')" class="cursor-pointer">');
+			$(".a-index-hd").append('<img src="/images/activeimages/chjhd.png" onclick="window.open(\'/front/webactivitycontent/56986e31af53740ecf000001.html\')" class="cursor-pointer">');
 			/*扫码送红包活动
 			$(".a-index-hd").append('<img src="/images/smshb.png" onclick="window.open(\'/p\')" class="cursor-pointer"><div class="smshb"><ul id="hd-smshb" class="text-center"></ul></div>');
 			$.post("/front/showAmount",null,function(r){

+ 133 - 80
core/src/web/templates/yellowpage/enterpriseinfo.html

@@ -6,9 +6,7 @@
 <meta name="Keywords" content="{{.T.res.EntName}},{{.T.res.EntName}}地址,{{.T.res.EntName}}怎么样"/>
 <meta name="Description" content="{{.T.res.OpScope}}"/>
 <link href="/css/entcommunity.css" rel="stylesheet">
-<script src="/js/geocoder.js"></script>
-<script type="text/javascript" src="http://api.map.baidu.com/getscript?v=2&ak=AFd8b176f363f23e6a23d516f4cfb742&services=&t=20150522093217"></script>  
-<script src="/js/jquery.cxselect.js"></script>
+<script src="/js/entportrait.js"></script>
 </head>
 <body class="entinfo-page">
 {{include "/common/enthead.html"}}
@@ -53,7 +51,23 @@
 			<div class="b-com-last">
 				{{if .T.res.s_persion}}<span class="glyphicon ren2"></span>{{.T.res.s_persion}}<span class="margin-r-15"></span>{{end}}
 				{{if .T.res.s_mobile}}<span class="glyphicon shouji"></span>{{.T.res.s_mobile}}<span class="margin-r-15"></span>{{end}}
-				{{if .T.res.s_qq}}<span class="glyphicon qq1"></span>{{.T.res.s_qq}}{{end}}
+				{{if .T.res.s_qq}}
+					<span class="glyphicon qq1"></span>
+					<script type="text/javascript">
+					    var online = new Array();
+					</script>
+					<script type= "text/javascript" src="http://webpresence.qq.com/getonline?Type=1&{{.T.res.s_qq}}:"></script>
+					<script type="text/javascript">
+						var imgSrc = "";
+				        if(online[0] == 1) {
+							imgSrc = "/images/entcommunity/qq_online.gif";
+				        }else{
+							imgSrc = "/images/qq_offline.gif";
+						}
+						imgSrc = "/images/entcommunity/qq.png";
+						document.write('<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin={{.T.res.s_qq}}&site=qq&menu=yes"><img src="'+imgSrc+'" alt="点击这里给我发消息" title="点击这里给我发消息" border="0" width="82" height="23.5"/></a>');
+					</script>
+				{{end}}
 				<br>
 				{{if .T.res.s_email}}
 					<span class="glyphicon youjian2"></span>{{.T.res.s_email}}<span class="margin-r-15"></span>
@@ -63,14 +77,14 @@
 				{{if .T.res.s_enturl}}<span class="glyphicon wangzhi1"></span>{{.T.res.s_enturl}}{{end}}
 				<br>
 				{{if or .T.res.i_province .T.res.i_city .T.res.i_area .T.res.s_address}}
-					<span class="glyphicon dizhi"></span>
+					<span class="glyphicon dizhi margin-0"></span>
 					<span id="city_china">
-						<select class="province cxselect select" id="provincesel" name="province" data-first-title="全国"></select>								
-						<select class="city cxselect select" id="citysel" name="city" data-first-title="选择市"></select>
-						<select class="area cxselect select" id="areasel" name="area" data-first-title="选择县"></select>
-						<input id="location" type="hidden">
-						<input id="cityname" type="hidden">
+						<select class="province cxselect select hide" id="provincesel" name="province" data-first-title="全国"></select>								
+						<select class="city cxselect select hide" id="citysel" name="city" data-first-title="选择市"></select>
+						<select class="area cxselect select hide" id="areasel" name="area" data-first-title="选择县"></select>
 					</span>
+					<input id="location" type="hidden">
+					<input id="cityname" type="hidden">
 					{{if .T.res.s_address}}
 					<a href="javascript:void(0)" onclick="showMap()">查看详细地图</a>
 					{{end}}
@@ -83,8 +97,8 @@
 		</div>
 	</div>
 	<!--切换-->
-	<ul class="entinfo-tab">
-		<li class="entinfo-active">企业画像</li>
+	<ul class="ent-tab">
+		<li class="ent-active">企业画像</li>
 		<li>关系网</li>
 		<li>公司简介</li>
 		<li>变更信息</li>
@@ -92,10 +106,10 @@
 		<li>产品服务信息</li>
 		<li class="border-r-0">招聘</li>
 	</ul>
-	<div class="entinfo-tab-content hide">
-		<div>
+	<div class="ent-tab-content">
+		<div class='hide'>
 			{{if .T.res.gs}}
-			<div class="entinfo-basicinfo">
+			<div class="entinfo-basicinfo ent-layout-up">
 				<div class="b-com-title">
 					<span class="glyphicon jianzhu"></span>基本信息
 					<font>(来源:<a href="http://gsxt.saic.gov.cn/" rel="nofollow" style="text-decoration: underline;color: #0099FF;">全国企业信用信息公示系统</a>)</font>
@@ -119,6 +133,7 @@
 									{{end}}
 									{{if .T.res.EntName}}{{.T.res.EntName}}{{end}}
 								</div>
+								<br><img src="/images/entcommunity/triangle.png">
 							</span>
 							<div><span>注册号</span><span>{{if .T.res.RegNo}}{{.T.res.RegNo}}{{end}}</span></div>
 							<div><span>行业</span><span>{{if .T.res.IndustryPhyName}}{{.T.res.IndustryPhyName}}{{end}}</span></div>
@@ -214,45 +229,110 @@
 					</div>
 				</div>
 			</div>
-			<div class="entinfo-shareholderinfo">
-				<div>
+			{{end}}
+			{{if .T.res.investor}}
+			<div class="entinfo-shareholderinfo ent-layout-down">
+				<div class="b-com-title">
 					<span><span class="bootstrap-glyphicon glyphicon-menu-right"></span></span>股东信息
 				</div>
-				{{if .T.res.investor}}
-				<ul>
-					{{range $k,$v := .T.res.investor}}
-					{{if $v.InvType}}
-					<li>
-						{{if eq $v.InvType "20" "21" "22"}}
-						<img src="/images/entcommunity/ziranren.png">
-						{{else}}
-						<img src="/images/entcommunity/faren.png">
+				<div class="b-com-content">
+					<ul>
+						{{range $k,$v := .T.res.investor}}
+						{{if $v.InvType}}
+						<li>
+							{{if eq $v.InvType "20" "21" "22"}}
+							<img src="/images/entcommunity/ziranren.png">
+							{{else}}
+							<img src="/images/entcommunity/faren.png">
+							{{end}}
+							<span><b>{{$v.InvTypeName}}</b></span>
+							<span>{{$v.Inv}}</span>
+						</li>
 						{{end}}
-						<span><b>{{$v.InvTypeName}}</b></span>
-						<span>{{$v.Inv}}</span>
-					</li>
-					{{end}}
-					{{end}}
-					<div class="clearfix"></div>
-				</ul>
-				{{end}}
+						{{end}}
+						<div class="clearfix"></div>
+					</ul>
+				</div>
+			</div>
+			{{end}}
+			{{if and (not .T.res.gs) (not .T.res.investor)}}
+			<div class="ent-findnull">
+				<img src="/images/findnull.png" class="b-findnull">
+				<h4>抱歉,未找到相关数据!</h4>
 			</div>
 			{{end}}
 		</div>
-		<div class="entrelation" id="entrelation">
-			<div id="entrelation-legend" class="entrelation-legend"></div>
-			<div class="entrelation-infovis">			
-				 <div class="entrelation-controlls hidden-sm hidden-xs">
-					<div class="entrelation-item">
-						<div id="entrelation-fullscreen" class="entrelation-box" title_pos="left"><div class="entrelation-fullscreen"></div></div>
-					</div>
+		<div class="entrelation hide" id="entrelation">
+			<div id="entrelation-infovis"></div>
+			<div id="entrelation-limit" class="hide entrelation-limit">
+				<div id="entrelation-nologin" class="hide text-center">
+					<img src="/images/findnull.png" class="b-findnull">
+					<h5>扫码登录认证后,即可查看企业股东信息,投资关系,公司关系脉络图等内容</h5>
+					<button class="btn btn-primary" onclick="loginModalShow();">扫码登录</button>
 				</div>
+				<div id="entrelation-noauthe" class="hide text-center">
+					<img src="/images/findnull.png" class="b-findnull">
+					<h5>认证后即可查看企业股东信息,投资关系,公司关系脉络图等内容</h5>
+					<a href="/member/accountset/index" class="btn btn-primary">认证</a>
+				</div>
+				<img src="/images/entcommunity/relation.png">
+			</div>
+			<div id="entrelation-findnull" class="entrelation-findnull hide">
+				<img src="/images/findnull.png" class="b-findnull">
+				<h4>抱歉,未找到相关数据!</h4>
+			</div>
+		</div>
+		<div class="hide">
+			<div class="ent-layout-up">
+				<div class="b-com-title">
+					<span class="glyphicon jianzhu"></span>公司简介
+				</div>
+				<div class="b-com-content"></div>
+			</div>
+			<div class="ent-layout-down">
+				{{if .T.res.OpScope}}
+				<div class="b-com-title">
+					<span><span class="bootstrap-glyphicon glyphicon-menu-right"></span></span>经营范围
+				</div>
+				<div class="b-com-content">{{.T.res.OpScope}}</div>
+				{{end}}
+				{{if .T.res.s_synopsis}}
+				<div class="b-com-title">
+					<span><span class="bootstrap-glyphicon glyphicon-menu-right"></span></span>公司介绍
+				</div>
+				<div class="b-com-content">{{.T.res.s_synopsis}}</div>
+				{{end}}
+			</div>
+		</div>
+		<div class="hide">
+		
+		</div>
+		<div class="hide">
+			<div class="ent-findnull">
+				<img src="/images/findnull.png" class="b-findnull">
+				<h4>抱歉,未找到相关数据!</h4>
+			</div>
+		</div>
+		<div class="hide">
+			<table class="table a-table" id="serviceList">
+				<tr id="tableTitle">
+					<td width="30%">我的预约</td>
+					<td width="30%" align="center">服务商名称</td>
+					<td width="20%" align="center">预约时间</td>
+					<td	width="10%" align="center">订单状态</td>
+					<td width="10%" align="center">操作</td>
+				</tr>
+				<tr>
+					<td colspan="5" class="text-center" id="myAppointmentPaging"></td>
+				</tr>
+			</table>
+		</div>
+		<div class="hide">
+			<div class="ent-findnull">
+				<img src="/images/findnull.png" class="b-findnull">
+				<h4>抱歉,未找到相关数据!</h4>
 			</div>
 		</div>
-		<div class="hide"></div>
-		<div class="hide"></div>
-		<div class="hide"></div>
-		<div class="hide"></div>
 	</div>
 </div>
 <!--显示地图信息-->
@@ -262,47 +342,20 @@
 {{include "/common/bottom.html"}}
 </body>
 <script type="text/javascript">
-
-
-var entsel="",btempwords,chf1,czb;
-
-//企业信息ID
- var id = {{.T.res._id}}
-//公式信息的变量
-var $gs = {{.T.res.gs}};
-//关系网上的变量
-var  $relationlen = "";
-
-//服务模板
-var template_content = "<tr><td><div class='row service_row'> "
-+"<div class='col-sm-1'><div style='width:120px; height:120px; background-color:#eee;'><img class='hidden-xs' src='${s_images}' style='width:120px;height:120px'></div></div>"
-+" <div class='col-sm-9'>"
-+"<div class='linebser service_des'><div class='servicename text-primary'><a class='text-primary' target='_blank' onclick='clickservicename(\"${_id}\",\"${s_isshow}\")'>${s_name}</a></div><div class='text-muted'>${s_introduction}</div></div>"
-+"</div></td><tr>"
-//关系网数据
-data= "";
-//注册号
-var regno="{{.T.res.RegNo}}";
-
-var legcerno = "{{.T.res.LegCerNO}}";
-var lerep="{{.T.res.LeRep}}";
+var entId = {{.T.res._id}};
+var regNo = {{.T.res.RegNo}};
+var legcerNo = {{.T.res.LegCerNO}};
+var entName = {{.T.res.EntName}};
 //联系地址
+//定义默认的郑州经纬度
+var ptlat=113.69884285509,  ptlng=34.791342526551;
 var province = {{.T.res.i_province}};
 var city = {{.T.res.i_city}};
 var area = {{.T.res.i_area}};
 var as1="{{.T.res.s_address}}";
-var $chiancity= false,$listent=false;
+var address=false,$listent=false;
 {{if or .T.res.i_province .T.res.i_city .T.res.i_area .T.res.s_address}}
-	$chiancity= true;
+	address = true;
 {{end}}
-
-var $resdata = {{.T.res.data}};
-var $entid = {{.T.res._id}};
-//定义默认的郑州经纬度
-var ptlat=113.69884285509,  ptlng=34.791342526551;
-var $res = {{.T.res}};
 </script>
-<script src="/js/entportrait.js"></script>
-<script src="/js/qfwtable.js"></script>
-
 </html>

+ 9 - 11
core/src/web/templates/yellowpage/error.html

@@ -3,19 +3,17 @@
 	<title>企明星----未收录</title>
 	{{include "/common/inc.html"}}
 	<body>
-	<div class="container-fluid">
-	<div class="row page-header" style="height:100px;margin:20px 0;">
-	 <a href="/"><img  src="/images/logo.png" class="header_logo"/></a>
-	</div>
-	<div class="row" style="margin:50px 0;">
-		<div class="col-lg-6 col-md-6 col-sm-6 " style="text-align:right">
-		 <img src="/images/findnull.png" class="b-findnull"/>
-		</div>
-		<div class="col-lg-6 col-md-6 col-sm-6 " style="padding-top: 70px;">
-			<div style="text-indent:20px;"><h4><strong class="text-muted">抱歉!企明星网站暂未收录该企业信息。</strong></h4></div>
+	{{include "/common/errorhead.html"}}
+	<div class="container-fluid b-content">
+		<div class="row" style="margin:50px 0;">
+			<div class="col-lg-6 col-md-6 col-sm-6" style="text-align:right">
+			 <img src="/images/findnull.png" class="b-findnull"/>
+			</div>
+			<div class="col-lg-6 col-md-6 col-sm-6" style="padding-top: 70px;">
+				<div style="text-indent:20px;"><h4><strong class="text-muted">抱歉!企明星网站暂未收录该企业信息。</strong></h4></div>
+			</div>
 		</div>
 	</div>
-	</div>
 	{{include "/common/bottom.html"}}
 	</body>
 </html>

+ 1 - 61
push/src/config.json

@@ -1,61 +1 @@
-{
-    "bid": {
-        "interval": 60,
-        "lastpushtime": "2015-10-10 10:10:10"
-    },
-    "bidStartTime": "2015-12-17 14:10:11",
-    "bidTitle": "亲!剑鱼为您速报最新鲜的中标信息啦",
-    "bidViewDomain": "192.168.3.132",
-    "durationMinutes": 1,
-    "fixPush": "oJULtwzXo6EFV1Ah-XeyRBimXGM8",
-    "mail_bid": "\u003cdiv\u003e%s\u003c/div\u003e,想了解更多信息,请访问http://www.qimingxing.info。",
-    "maxPushSize": 50,
-    "mgoAddr": "192.168.3.18:27080",
-    "mgoSize": 10,
-    "province": {
-        "上海": 9,
-        "云南": 25,
-        "内蒙古": 5,
-        "北京": 1,
-        "台湾": 32,
-        "吉林": 7,
-        "四川": 13,
-        "天津": 2,
-        "宁夏": 30,
-        "安徽": 12,
-        "山东": 15,
-        "山西": 4,
-        "广东": 19,
-        "广西": 20,
-        "新疆": 31,
-        "江苏": 10,
-        "江西": 14,
-        "河北": 3,
-        "河南": 16,
-        "浙江": 11,
-        "海南": 21,
-        "湖北": 17,
-        "湖南": 18,
-        "澳门": 34,
-        "甘肃": 28,
-        "福建": 13,
-        "西藏": 26,
-        "贵州": 24,
-        "辽宁": 6,
-        "重庆": 22,
-        "陕西": 27,
-        "青海": 29,
-        "香港": 33,
-        "黑龙江": 8
-    },
-    "smtpAddr": "smtp.exmail.qq.com",
-    "smtpFromUser": "企明星",
-    "smtpPort": 465,
-    "smtpPwd": "qy123456",
-    "smtpUser": "qyfw@topnet.net.cn",
-    "tenderStartTime": "2015-12-17 14:10:11",
-    "tenderTitle": "亲!剑鱼为您速报最新鲜的招标信息啦",
-    "weixinRpcServer": "127.0.0.1:82",
-    "weixin_bid": "\u003cdiv\u003e%s最新招标信息\u003c/div\u003e\u003cdiv\u003e%s\u003c/div\u003e",
-    "wxRpcRemark": "请到网站个人中心查看详细."
-}
+{"bid":{"interval":60,"lastpushtime":"2015-10-10 10:10:10"},"bidStartTime":"2015-12-30 17:28:48","bidTitle":"亲!剑鱼为您速报最新鲜的中标信息啦","bidViewDomain":"192.168.3.132","durationMinutes":10,"fixPush":"oJULtwzXo6EFV1Ah-XeyRBimXGM8","mail_bid":"\u003cdiv\u003e%s\u003c/div\u003e,想了解更多信息,请访问http://www.qimingxing.info。","maxPushSize":50,"mgoAddr":"192.168.3.18:27080","mgoSize":10,"province":{"上海":9,"云南":25,"内蒙古":5,"北京":1,"台湾":32,"吉林":7,"四川":13,"天津":2,"宁夏":30,"安徽":12,"山东":15,"山西":4,"广东":19,"广西":20,"新疆":31,"江苏":10,"江西":14,"河北":3,"河南":16,"浙江":11,"海南":21,"湖北":17,"湖南":18,"澳门":34,"甘肃":28,"福建":13,"西藏":26,"贵州":24,"辽宁":6,"重庆":22,"陕西":27,"青海":29,"香港":33,"黑龙江":8},"pushInfoScopeDays":30,"rpcPort":"8766","smtpAddr":"smtp.exmail.qq.com","smtpFromUser":"企明星","smtpPort":465,"smtpPwd":"qy123456","smtpUser":"qyfw@topnet.net.cn","tenderStartTime":"2015-12-30 17:28:48","tenderTitle":"亲!剑鱼为您速报最新鲜的招标信息啦","weixinRpcServer":"127.0.0.1:82","weixin_bid":"\u003cdiv\u003e%s最新招标信息\u003c/div\u003e\u003cdiv\u003e%s\u003c/div\u003e","wxRpcRemark":"请到网站个人中心查看详细."}

+ 13 - 0
push/src/main.go

@@ -4,8 +4,13 @@
 package main
 
 import (
+	"log"
+	"net"
+	"net/http"
+	"net/rpc"
 	"qfw/push"
 	"qfw/push/bid"
+	"qfw/push/rpcpush"
 	"qfw/push/tender"
 	"qfw/util"
 	"qfw/util/mongodb"
@@ -21,6 +26,7 @@ func init() {
 		push.City[k] = uint(v.(float64))
 	}
 	bid.MaxPushSize = util.IntAll(push.PushConfig["maxPushSize"])
+	rpcpush.PushInfoScopeDays = util.IntAll(push.PushConfig["pushInfoScopeDays"])
 	tender.MaxPushSize = bid.MaxPushSize
 	mongodb.InitMongodbPool(util.IntAll(push.PushConfig["mgoSize"]), push.PushConfig["mgoAddr"].(string), "qfw")
 }
@@ -50,6 +56,13 @@ func runJob() {
 //主应用,定时任务
 func main() {
 	go runJob()
+	crpc := new(rpcpush.PushInfo)
+	rpc.Register(crpc)
+	rpc.HandleHTTP()
+	port, _ := push.PushConfig["rpcPort"].(string)
+	l, _ := net.Listen("tcp", ":"+port)
+	go http.Serve(l, nil)
+	log.Println("启动推送系统", port)
 	flag := make(chan bool)
 	<-flag
 }

+ 25 - 0
push/src/qfw/push/bid/bid_test.go

@@ -4,9 +4,11 @@ import (
 	"fmt"
 	"log"
 	"math/rand"
+	"net/rpc"
 	"qfw/push"
 	"qfw/util"
 	"qfw/util/mongodb"
+	qrpc "qfw/util/rpc"
 	"strings"
 	"testing"
 	"time"
@@ -57,3 +59,26 @@ func Test_1(t *testing.T) {
 	a2 := push.GetChoiceCode(strings.Split("北京,河南,广东,山西,新疆", ",")...)
 	log.Println(a1, a2, a1&a2)
 }
+
+func Test_rpc(t *testing.T) {
+	log.Println("----------")
+	for i := 0; i < 30; i++ {
+		dd := qrpc.PushData{
+			Mopenid: "oJULtwzXo6EFV1Ah-XeyRBimXGM8",
+			PushType: map[string]string{
+				"tender": "招标",
+				"bid":    "中标",
+			},
+		}
+		var repl int
+		clent, _ := rpc.DialHTTP("tcp", "127.0.0.1:8766")
+		clent.Call("PushInfo.PushMsg", &dd, &repl)
+
+		log.Println(repl)
+		clent.Close()
+		time.Sleep(10 * time.Millisecond)
+	}
+
+	c := make(chan bool, 1)
+	<-c
+}

+ 9 - 208
push/src/qfw/push/bid/bidpushjob.go

@@ -9,223 +9,24 @@
 package bid
 
 import (
-	"container/list"
-	"fmt"
-	"log"
-	"math/rand"
 	"qfw/push"
-	"qfw/push/dfa"
+	"qfw/push/dopush"
 	"qfw/util"
-	"qfw/util/mongodb"
-	qrpc "qfw/util/rpc"
-	"runtime"
-	"strconv"
-	"strings"
 	"time"
 )
 
 type BidPushJob struct {
-	dfa *dfa.DFA
 }
 
-//构造用户兴趣词库
-func (b *BidPushJob) createUserInterestWord() {
-	b.dfa = &dfa.DFA{}
-	words := make([]string, 0)
-	for k, _ := range push.Cache {
-		words = append(words, k)
-	}
-	b.dfa.AddWord(words...)
-}
-
-var TITLEA string = "[中标信息]" //tender
 var MaxPushSize int
 
-//遍历查到的
-func (b *BidPushJob) eachAllBidInfo() {
-	defer func() {
-		if r := recover(); r != nil {
-			fmt.Println("推送开始[E]", r)
-		}
-	}()
-	session := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(session)
-	startTime := push.PushConfig["bidStartTime"].(string)
-	st, _ := time.ParseInLocation(util.Date_Full_Layout, startTime, time.Local)
-	q := `{"comeintime":{"$gt":` + fmt.Sprintf("%d", st.Unix()) + `},"type":"bid"}`
-	n, _ := session.DB("qfw").C("bidding").Find(mongodb.ObjToOth(q)).Count()
-	log.Println(q, "查询推送信息:", n, ",时间", startTime)
-	if n == 0 {
-		//没有查询到结果
-		return
-	}
-	query := session.DB("qfw").C("bidding").Find(mongodb.ObjToOth(q)).Sort("-publishtime").Iter()
-	userMap := &map[*push.MemberInterest]*list.List{}
-	for tmp := new(map[string]interface{}); query.Next(tmp); {
-		title := util.ObjToString((*tmp)["title"])
-		if title != "" {
-			//返回匹配到的词组
-			res := b.dfa.Analy(title)
-			if len(res) > 0 {
-				province := (*tmp)["area"].(string)
-				provinceVal := push.GetChoiceCode(province)
-				for _, v := range res {
-					//根据关键词返回用户指针
-					tw := push.Cache[v]
-					if tw != nil {
-						//遍历用户加入到此条信息上
-						for _, v2 := range *tw {
-							if v2.Province == "A" || v2.ProvinceVal&provinceVal > 0 {
-								s := (*userMap)[v2]
-								if s == nil {
-									//s = &map[*map[string]interface{}]bool{}
-									s = list.New()
-									(*userMap)[v2] = s
-								}
-								s.PushBack(tmp)
-							}
-						}
-					}
-				}
-			}
-		}
-		tmp = new(map[string]interface{})
-	}
-
-	now := time.Now()
-	nowtime := util.FormatDate(&now, util.Date_Full_Layout)
-	//更改开始时间
-	push.PushConfig["bidStartTime"] = nowtime
-	//date := util.FormatDate(&now, util.Date_Short_Layout)
-
-	for k, v := range *(userMap) {
-		kk := *k
-		vv := *v
-		time.Sleep(50 * time.Millisecond)
-		go send(&kk, &vv, now, nowtime)
-	}
-}
-
-func send(k *push.MemberInterest, v *list.List, now time.Time, nowtime string) {
-	defer func() {
-		if r := recover(); r != nil {
-			log.Println("[E]", r)
-			for skip := 1; ; skip++ {
-				_, file, line, ok := runtime.Caller(skip)
-				if !ok {
-					break
-				}
-				go log.Printf("%v,%v\n", file, line)
-			}
-		}
-	}()
-	//wxstr := ""
-	str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(k.Interest, ";"))
-
-	//发送内容组合
-	i := 0
-	lastInfoDate := int64(0)
-	firstTitle := ""
-	publishTimes := map[string]interface{}{}
-	for ks := v.Front(); ks != nil; ks = ks.Next() {
-		k2 := *(ks.Value.(*map[string]interface{}))
-		i++
-		if i == 1 {
-			firstTitle = strings.Replace(k2["title"].(string), "\n", "", -1)
-			lastInfoDate = k2["publishtime"].(int64)
-		}
-		str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' href='" + k2["href"].(string) + "'>" + strings.Replace(k2["title"].(string), "\n", "", -1) + "</a></div>"
-		publishTimes[strconv.Itoa(i)] = k2["publishtime"]
-
-		if i >= MaxPushSize {
-			//限制最大信息条数
-			break
-		}
-
-	}
-	TITLE := TITLEA + fmt.Sprintf("%d条,关键词(%s)", i, strings.Join(k.Interest, ";"))
-	WXTitle := fmt.Sprintf("%s《%s》%s", func() string {
-		minute := now.Unix() - lastInfoDate
-		if minute > -1 && minute < 61 {
-			return fmt.Sprintf("%d秒前发布的", minute)
-		} else {
-			minute = minute / 60
-			if minute > 121 {
-				return ""
-			} else {
-				if minute < 1 {
-					minute = 1
-				}
-				return fmt.Sprintf("%d分钟前发布的", minute)
-			}
-		}
-	}(), firstTitle, func() string {
-		if i == 1 {
-			return ""
-		} else {
-			return "等" + strconv.Itoa(i) + "条"
-		}
-	}())
-
-	//发送微信
-	if len(k.Openid) > 0 {
-		sendWeixin(k, TITLE, str, nowtime, "", now, "", WXTitle, publishTimes)
-	}
-
-}
-
-//推送微信
-func sendWeixin(k *push.MemberInterest, TITLE, str, nowtime, wxstr string, now time.Time, msgid, WXTitle string, publishTimes map[string]interface{}) {
-	defer func() {
-		if r := recover(); r != nil {
-			fmt.Println("发送微信[E]", r)
-		}
-	}()
-	time.Sleep(time.Millisecond * 100)
-	//详情存库
-	wxpush := map[string]interface{}{
-		"s_m_openid":    k.Openid,
-		"l_date":        now.Unix(),
-		"s_words":       k.Interest,
-		"s_email":       k.Email,
-		"s_uid":         k.Id,
-		"s_province":    k.Province,
-		"a_interest":    k.Interest,
-		"s_content":     str,
-		"s_type":        "bid",
-		"a_publishtime": publishTimes,
-		"i_size":        len(publishTimes),
-	}
-	wid := mongodb.Save("wxpush", &wxpush)
-	wxstr = "\n点击下方“详情”查看详细信息。\n以上中标信息,是剑鱼根据关键字“" + strings.Join(k.Interest, ";") + "”奋力查找并推送,如不合您心意,请猛戳企明星菜单“会员服务—剑鱼”进行修改。"
-
-	wxDate := ""
-	if k.InterestDate > 0 {
-		mt1 := interface{}(k.InterestDate)
-		wxDate = util.FormatDateWithObj(&mt1, util.Date_Full_Layout)
-	} else {
-		r := rand.New(rand.NewSource(time.Now().UnixNano()))
-		n1 := r.Int63n(9)
-		n2 := r.Int63n(7200)
-		wxDate = time.Now().Local().Add(time.Duration(-n2) * time.Second).Add(time.Duration(-n1*24) * time.Hour).Format(util.Date_Full_Layout)
-	}
-
-	push.SendWinXin(&qrpc.NotifyMsg{
-		Openid:  k.Openid,
-		Title:   push.PushConfig["bidTitle"].(string),
-		Remark:  wxstr,
-		Detail:  WXTitle,
-		Date:    wxDate,
-		Service: "剑鱼君",
-		Url:     push.PushConfig["bidViewDomain"].(string) + "/wxpush/bid/" + k.Openid + "/" + wid + "/a"})
-
-}
-
-//执行日常招标中标公告的消息推送
+//执行日常招标的消息推送
 func (b *BidPushJob) Execute() bool {
-	log.Println("开始执行中标任务:", push.PushConfig["bidStartTime"])
-	push.InitCache("bid")
-	b.createUserInterestWord()
-	b.eachAllBidInfo()
-	return false
+	pj := dopush.Pjob{
+		MaxPushSize: MaxPushSize,
+		Stype:       "bid",
+		StypeName:   "中标",
+	}
+	st, _ := time.ParseInLocation(util.Date_Full_Layout, push.PushConfig["bidStartTime"].(string), time.Local)
+	return pj.DoPush("", push.PushConfig["bidStartTime"].(string), 1, st.Unix())
 }

+ 25 - 35
push/src/qfw/push/cache.go

@@ -14,36 +14,32 @@ import (
 )
 
 type MemberInterest struct {
-	Id          string   //mongoid
-	Province    string   //省份
-	ProvinceVal uint64   //可选多个省份的处理
-	Interest    []string //用户兴趣
-	//Type     string   //兴趣类型
-	//SendMode     []string //发送方式
-	Unionid      string
+	Id           string   //mongoid
+	Province     string   //省份
+	ProvinceVal  uint64   //可选多个省份的处理
+	Interest     []string //用户兴趣
 	Openid       string
-	Email        string
 	InterestDate int64
 }
 
-var Cache map[string]*[]*MemberInterest //缓存
 //初始化缓存,在每次执行任务时调用,
-//加载用户数据到Cache中
-func InitCache(flag string) {
-	Cache = make(map[string]*[]*MemberInterest)
-	//TODO 查Mogo数据库
-	fixPush := util.ObjToString(PushConfig["fixPush"])
+func InitCache(flag, m_openid string) map[string]*[]*MemberInterest {
+	cache := make(map[string]*[]*MemberInterest)
 	q := map[string]interface{}{}
-	if len(fixPush) > 5 {
-		log.Println("推指定的人", fixPush)
-		q["s_m_openid"] = map[string]interface{}{
-			"$in": strings.Split(fixPush, ","),
-		}
+	if m_openid != "" {
+		q["s_m_openid"] = m_openid
 	} else {
-		q = map[string]interface{}{
-			"o_msgset." + flag: map[string]interface{}{
-				"$exists": true,
-			},
+		fixPush := util.ObjToString(PushConfig["fixPush"])
+		if len(fixPush) > 5 {
+			log.Println("推指定的人", fixPush)
+			q["s_m_openid"] = map[string]interface{}{
+				"$in": strings.Split(fixPush, ","),
+			}
+		} else {
+			q = map[string]interface{}{
+				"o_msgset." + flag + ".i_switchstatus": 1,
+				"o_msgset." + flag + ".i_status":       1,
+			}
 		}
 	}
 	session := mongodb.GetMgoConn()
@@ -52,9 +48,7 @@ func InitCache(flag string) {
 		"_id":                   1,
 		"o_msgset." + flag:      1,
 		"o_msgset.l_modifydate": 1,
-		"s_unionid":             1,
 		"s_m_openid":            1,
-		"s_email":               1,
 	}).Iter()
 	for tmp := make(map[string]interface{}); query.Next(tmp); {
 		util.Try(func() {
@@ -62,18 +56,14 @@ func InitCache(flag string) {
 			o_msgset := tmp["o_msgset"].(map[string]interface{})
 			flagModule := o_msgset[flag].(map[string]interface{})
 			a_key := util.ObjArrToStringArr(flagModule["a_key"].([]interface{}))
-			//a_mode := util.ObjArrToStringArr(flagModule["a_mode"].([]interface{}))
 			s_scope := util.ObjToString(flagModule["s_scope"])
 			if len(a_key) > 0 && len(s_scope) > 0 {
 				user := MemberInterest{
-					Id: _id,
-					//SendMode:    a_mode,
+					Id:          _id,
 					Province:    s_scope,
 					ProvinceVal: GetChoiceCode(strings.Split(s_scope, ",")...),
 					Interest:    a_key,
-					Unionid:     util.ObjToString(tmp["s_unionid"]),
 					Openid:      util.ObjToString(tmp["s_m_openid"]),
-					Email:       util.ObjToString(tmp["s_email"]),
 				}
 				date := o_msgset["l_modifydate"]
 				if date != nil {
@@ -83,12 +73,12 @@ func InitCache(flag string) {
 				}
 				for i := 0; i < len(a_key) && a_key[i] != ""; i++ {
 					var arr []*MemberInterest
-					if nil == Cache[a_key[i]] {
+					if nil == cache[a_key[i]] {
 						arr = make([]*MemberInterest, 0)
-						Cache[a_key[i]] = &arr
+						cache[a_key[i]] = &arr
 					} else {
-						arr = *Cache[a_key[i]]
-						Cache[a_key[i]] = &arr
+						arr = *cache[a_key[i]]
+						cache[a_key[i]] = &arr
 					}
 					arr = append(arr, &user)
 				}
@@ -97,8 +87,8 @@ func InitCache(flag string) {
 			log.Println(e)
 		})
 		tmp = make(map[string]interface{})
-		//log.Println(_id, o_msgset)
 	}
+	return cache
 }
 
 //各省份排序,最终会占某个2进制位

+ 16 - 0
push/src/qfw/push/dfa/interestanalysis_test.go

@@ -27,3 +27,19 @@ func TestAnaly(t *testing.T) {
 	//log.Println(d.Analy("这是胡锦涛写给江泽民的信啊。"))
 
 }
+
+func Test_Label(t *testing.T) {
+	log.Println("000----")
+
+	for _, v := range []int{1, 2, 3, 4, 5} {
+		log.Println(v)
+	L1:
+		for _, vv := range []string{"a", "b", "c", "d"} {
+			log.Println(vv)
+			if vv == "add" {
+				break L1
+			}
+		}
+	}
+	log.Println("111----")
+}

+ 221 - 0
push/src/qfw/push/dopush/dopush.go

@@ -0,0 +1,221 @@
+package dopush
+
+import (
+	"container/list"
+	"fmt"
+	"log"
+	"math/rand"
+	"qfw/push"
+	"qfw/push/dfa"
+	"qfw/util"
+	"qfw/util/mongodb"
+	qrpc "qfw/util/rpc"
+	"runtime"
+	"strconv"
+	"strings"
+	"time"
+)
+
+type Pjob struct {
+	Dfa         *dfa.DFA
+	Cache       *map[string]*[]*push.MemberInterest
+	MaxPushSize int
+	Stype       string
+	StypeName   string
+}
+
+//构造用户兴趣词库
+func (b *Pjob) CreateUserInterestWord() {
+	b.Dfa = &dfa.DFA{}
+	words := make([]string, 0)
+	for k, _ := range *b.Cache {
+		words = append(words, k)
+	}
+	b.Dfa.AddWord(words...)
+}
+
+func (p *Pjob) DoPush(mopenid, stime string, opr int, ltime int64) bool {
+	log.Println("开始执行任务:", p.StypeName, stime)
+	p.Cache = new(map[string]*[]*push.MemberInterest)
+	*p.Cache = push.InitCache(p.Stype, mopenid)
+	p.CreateUserInterestWord()
+	EachAllBidInfo(p.Stype, "["+p.StypeName+"信息]", p.StypeName, ltime, p.MaxPushSize, p.Dfa, p.Cache, opr)
+	return true
+}
+
+//遍历数据并执行推送操作
+func EachAllBidInfo(stype, TITLEA, ShortTitle string, lastTime int64, MaxPushSize int, dfas *dfa.DFA, cache *map[string]*[]*push.MemberInterest, pushType int) {
+	defer func() {
+		if r := recover(); r != nil {
+			fmt.Println("推送开始[E]", r)
+		}
+	}()
+	session := mongodb.GetMgoConn()
+	defer mongodb.DestoryMongoConn(session)
+	q := `{"comeintime":{"$gt":` + fmt.Sprintf("%d", lastTime) + `},"type":"` + stype + `"}`
+	n, _ := session.DB("qfw").C("bidding").Find(mongodb.ObjToOth(q)).Count()
+	if n == 0 {
+		log.Println("执行推送任务", stype, "没有数据。")
+		return
+	}
+	query := session.DB("qfw").C("bidding").Find(mongodb.ObjToOth(q)).Sort("-publishtime").Iter()
+	userMap := &map[*push.MemberInterest]*list.List{}
+	var returnLastTime interface{}
+L1:
+	for tmp := new(map[string]interface{}); query.Next(tmp); {
+		title := util.ObjToString((*tmp)["title"])
+		if title != "" {
+			//返回匹配到的词组
+			res := dfas.Analy(title)
+			if len(res) > 0 {
+				province := (*tmp)["area"].(string)
+				provinceVal := push.GetChoiceCode(province)
+				for _, v := range res {
+					//根据关键词返回用户指针
+					tw := (*cache)[v]
+					if tw != nil {
+						//遍历用户加入到此条信息上
+						for _, v2 := range *tw {
+							if v2.Province == "A" || v2.ProvinceVal&provinceVal > 0 {
+								s := (*userMap)[v2]
+								if s == nil {
+									s = list.New()
+									(*userMap)[v2] = s
+								}
+								s.PushBack(tmp)
+								if pushType == 2 && s.Len() > MaxPushSize {
+									break L1
+								}
+							}
+						}
+					}
+				}
+			}
+			if returnLastTime == nil {
+				returnLastTime = (*tmp)["comeintime"]
+			}
+		}
+		tmp = new(map[string]interface{})
+	}
+	now := time.Now()
+	if pushType == 1 && returnLastTime != nil {
+		push.PushConfig[stype+"StartTime"] = util.FormatDateWithObj(&returnLastTime, util.Date_Full_Layout)
+	}
+	for k, v := range *(userMap) {
+		kk := *k
+		vv := *v
+		time.Sleep(50 * time.Millisecond)
+		go Send(&kk, &vv, now, TITLEA, ShortTitle, stype, MaxPushSize)
+	}
+}
+
+//全局推送功能
+func Send(k *push.MemberInterest, v *list.List, now time.Time, TITLEA, ShortTitle, stype string, MaxPushSize int) {
+	defer func() {
+		if r := recover(); r != nil {
+			log.Println("[E]", r)
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
+	str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(k.Interest, ";"))
+	//发送内容组合
+	i := 0
+	lastInfoDate := int64(0)
+	firstTitle := ""
+	publishTimes := map[string]interface{}{}
+	for ks := v.Front(); ks != nil; ks = ks.Next() {
+		k2 := *(ks.Value.(*map[string]interface{}))
+		i++
+		if i == 1 {
+			firstTitle = strings.Replace(k2["title"].(string), "\n", "", -1)
+			lastInfoDate = k2["publishtime"].(int64)
+		}
+		str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' href='" + k2["href"].(string) + "'>" + strings.Replace(k2["title"].(string), "\n", "", -1) + "</a></div>"
+		publishTimes[strconv.Itoa(i)] = k2["publishtime"]
+		if i >= MaxPushSize {
+			//限制最大信息条数
+			break
+		}
+
+	}
+	TITLE := TITLEA + fmt.Sprintf("%d条,关键词(%s)", i, strings.Join(k.Interest, ";"))
+	WXTitle := fmt.Sprintf("%s《%s》%s", func() string {
+		minute := now.Unix() - lastInfoDate
+		if minute > -1 && minute < 61 {
+			return fmt.Sprintf("%d秒前发布的", minute)
+		} else {
+			minute = minute / 60
+			if minute > 121 {
+				return ""
+			} else {
+				if minute < 1 {
+					minute = 1
+				}
+				return fmt.Sprintf("%d分钟前发布的", minute)
+			}
+		}
+	}(), firstTitle, func() string {
+		if i == 1 {
+			return ""
+		} else {
+			return "等" + strconv.Itoa(i) + "条"
+		}
+	}())
+
+	//3、发送微信
+	if len(k.Openid) > 0 {
+		SendWeixin(k, TITLE, ShortTitle, str, stype, now, WXTitle, publishTimes)
+	}
+
+}
+
+//推送微信
+func SendWeixin(k *push.MemberInterest, TITLE, ShortTitle, str, stype string, now time.Time, WXTitle string, publishTimes map[string]interface{}) {
+	defer func() {
+		if r := recover(); r != nil {
+			fmt.Println("发送微信[E]", r)
+		}
+	}()
+	time.Sleep(time.Millisecond * 100)
+	//详情存库
+	wxpush := map[string]interface{}{
+		"s_m_openid":    k.Openid,
+		"l_date":        now.Unix(),
+		"s_words":       k.Interest,
+		"s_uid":         k.Id,
+		"s_province":    k.Province,
+		"a_interest":    k.Interest,
+		"s_content":     str,
+		"s_type":        stype,
+		"a_publishtime": publishTimes,
+		"i_size":        len(publishTimes),
+	}
+	wid := mongodb.Save("wxpush", &wxpush)
+	wxDate := ""
+	if k.InterestDate > 0 {
+		mt1 := interface{}(k.InterestDate)
+		wxDate = util.FormatDateWithObj(&mt1, util.Date_Full_Layout)
+	} else {
+		r := rand.New(rand.NewSource(time.Now().UnixNano()))
+		n1 := r.Int63n(9)
+		n2 := r.Int63n(7200)
+		wxDate = time.Now().Local().Add(time.Duration(-n2) * time.Second).Add(time.Duration(-n1*24) * time.Hour).Format(util.Date_Full_Layout)
+	}
+
+	wxstr := "\n点击下方“详情”查看详细信息。\n以上" + ShortTitle + "信息,是剑鱼根据关键字“" + strings.Join(k.Interest, ";") + "”奋力查找并推送,如不合您心意,请猛戳企明星菜单“会员服务—剑鱼”进行修改。"
+	push.SendWinXin(&qrpc.NotifyMsg{
+		Openid:  k.Openid,
+		Title:   push.PushConfig[stype+"Title"].(string),
+		Remark:  wxstr,
+		Detail:  WXTitle,
+		Date:    wxDate,
+		Service: "剑鱼君",
+		Url:     push.PushConfig["bidViewDomain"].(string) + "/wxpush/bid/" + k.Openid + "/" + wid + "/aa"})
+
+}

+ 36 - 0
push/src/qfw/push/rpcpush/rpcpush.go

@@ -0,0 +1,36 @@
+package rpcpush
+
+import (
+	"fmt"
+	"log"
+	"qfw/push/bid"
+	"qfw/push/dopush"
+	qrpc "qfw/util/rpc"
+	"time"
+)
+
+type PushInfo struct {
+}
+
+var PushInfoScopeDays int
+
+func (p *PushInfo) PushMsg(data *qrpc.PushData, Reply *int) error {
+	log.Println("dddddddd", data)
+	for k, v := range data.PushType {
+		//昨天到今天的数据
+		pj := dopush.Pjob{
+			MaxPushSize: bid.MaxPushSize,
+			Stype:       k,
+			StypeName:   v,
+		}
+		now := time.Now()
+		tom := time.Date(now.Year(), now.Month(), now.Day()-PushInfoScopeDays, 0, 0, 0, 0, time.Local)
+		b := pj.DoPush(data.Mopenid, fmt.Sprintf("%d days", PushInfoScopeDays), 2, tom.Unix())
+		if b {
+			*Reply = 1
+		} else {
+			*Reply = 0
+		}
+	}
+	return nil
+}

+ 9 - 212
push/src/qfw/push/tender/tenderpushjob.go

@@ -1,227 +1,24 @@
-/**
- *招标,中标公告的推送消息,在兴趣词分析上,存在一定的难度
- *现在采用DFA算法分析,兴趣词会构造Map结构,前期应该不会出问题。
- *后期需要改进(用户量达到5千以上)
- *可行策略:每日产生的新数据有限,大概不超过5000条,可以把标题全加到内存
- *        用户兴趣词分批次加入,每次加入3000个左右的用户的兴趣词,过滤
- *        今日产生的招标、中标数据,并完成推送,第二批载入后3000个用户的数据
- */
 package tender
 
 import (
-	"container/list"
-	"fmt"
-	"log"
-	"math/rand"
 	"qfw/push"
-	"qfw/push/dfa"
+	"qfw/push/dopush"
 	"qfw/util"
-	"qfw/util/mongodb"
-	qrpc "qfw/util/rpc"
-	"runtime"
-	"strconv"
-	"strings"
 	"time"
 )
 
 type TenderPushJob struct {
-	dfa *dfa.DFA
 }
 
-//构造用户兴趣词库
-func (b *TenderPushJob) createUserInterestWord() {
-	b.dfa = &dfa.DFA{}
-	words := make([]string, 0)
-	for k, _ := range push.Cache {
-		words = append(words, k)
-	}
-	b.dfa.AddWord(words...)
-}
-
-var TITLEA string = "[招标信息]" //tender
 var MaxPushSize int
 
-//遍历查到的
-func (b *TenderPushJob) eachAllBidInfo() {
-	defer func() {
-		if r := recover(); r != nil {
-			fmt.Println("推送开始[E]", r)
-		}
-	}()
-	session := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(session)
-	startTime := push.PushConfig["tenderStartTime"].(string)
-	st, _ := time.ParseInLocation(util.Date_Full_Layout, startTime, time.Local)
-	q := `{"comeintime":{"$gt":` + fmt.Sprintf("%d", st.Unix()) + `},"type":"tender"}`
-	n, _ := session.DB("qfw").C("bidding").Find(mongodb.ObjToOth(q)).Count()
-	log.Println(q, "查询推送信息:", n, ",时间", startTime)
-	if n == 0 {
-		//没有查询到结果
-		return
-	}
-	query := session.DB("qfw").C("bidding").Find(mongodb.ObjToOth(q)).Sort("-publishtime").Iter()
-	userMap := &map[*push.MemberInterest]*list.List{}
-	for tmp := new(map[string]interface{}); query.Next(tmp); {
-		title := util.ObjToString((*tmp)["title"])
-		if title != "" {
-			//返回匹配到的词组
-			res := b.dfa.Analy(title)
-			if len(res) > 0 {
-				province := (*tmp)["area"].(string)
-				provinceVal := push.GetChoiceCode(province)
-				for _, v := range res {
-					//根据关键词返回用户指针
-					tw := push.Cache[v]
-					if tw != nil {
-						//遍历用户加入到此条信息上
-						for _, v2 := range *tw {
-							if v2.Province == "A" || v2.ProvinceVal&provinceVal > 0 {
-								s := (*userMap)[v2]
-								if s == nil {
-									s = list.New()
-									(*userMap)[v2] = s
-								}
-								s.PushBack(tmp)
-							}
-						}
-					}
-				}
-			}
-		}
-		tmp = new(map[string]interface{})
-	}
-	now := time.Now()
-	nowtime := util.FormatDate(&now, util.Date_Full_Layout)
-	//更改开始时间
-	push.PushConfig["tenderStartTime"] = nowtime
-	//date := util.FormatDate(&now, util.Date_Short_Layout)
-	for k, v := range *(userMap) {
-		kk := *k
-		vv := *v
-
-		time.Sleep(50 * time.Millisecond)
-		go send(&kk, &vv, now, nowtime)
-	}
-}
-
-func send(k *push.MemberInterest, v *list.List, now time.Time, nowtime string) {
-	defer func() {
-		if r := recover(); r != nil {
-			log.Println("[E]", r)
-			for skip := 1; ; skip++ {
-				_, file, line, ok := runtime.Caller(skip)
-				if !ok {
-					break
-				}
-				go log.Printf("%v,%v\n", file, line)
-			}
-		}
-	}()
-
-	//wxstr := ""
-	str := fmt.Sprintf("<div>根据您设置的关键词(%s),给您推送以下信息:</div>", strings.Join(k.Interest, ";"))
-	//发送内容组合
-	i := 0
-	lastInfoDate := int64(0)
-	firstTitle := ""
-	publishTimes := map[string]interface{}{}
-	for ks := v.Front(); ks != nil; ks = ks.Next() {
-		k2 := *(ks.Value.(*map[string]interface{}))
-		i++
-		if i == 1 {
-			firstTitle = strings.Replace(k2["title"].(string), "\n", "", -1)
-			lastInfoDate = k2["publishtime"].(int64)
-		}
-		str += "<div class='tslist'><span class='xh'>" + fmt.Sprintf("%d", i) + ".</span><a class='bt' target='_blank' href='" + k2["href"].(string) + "'>" + strings.Replace(k2["title"].(string), "\n", "", -1) + "</a></div>"
-		publishTimes[strconv.Itoa(i)] = k2["publishtime"]
-		if i >= MaxPushSize {
-			//限制最大信息条数
-			break
-		}
-
-	}
-	TITLE := TITLEA + fmt.Sprintf("%d条,关键词(%s)", i, strings.Join(k.Interest, ";"))
-	WXTitle := fmt.Sprintf("%s《%s》%s", func() string {
-		minute := now.Unix() - lastInfoDate
-		if minute > -1 && minute < 61 {
-			return fmt.Sprintf("%d秒前发布的", minute)
-		} else {
-			minute = minute / 60
-			if minute > 121 {
-				return ""
-			} else {
-				if minute < 1 {
-					minute = 1
-				}
-				return fmt.Sprintf("%d分钟前发布的", minute)
-			}
-		}
-	}(), firstTitle, func() string {
-		if i == 1 {
-			return ""
-		} else {
-			return "等" + strconv.Itoa(i) + "条"
-		}
-	}())
-
-	//3、发送微信
-	if len(k.Openid) > 0 {
-		sendWeixin(k, TITLE, str, nowtime, "", now, "", WXTitle, publishTimes)
-	}
-
-}
-
-//推送微信
-func sendWeixin(k *push.MemberInterest, TITLE, str, nowtime, wxstr string, now time.Time, msgid, WXTitle string, publishTimes map[string]interface{}) {
-	defer func() {
-		if r := recover(); r != nil {
-			fmt.Println("发送微信[E]", r)
-		}
-	}()
-	time.Sleep(time.Millisecond * 100)
-	//详情存库
-	wxpush := map[string]interface{}{
-		"s_m_openid":    k.Openid,
-		"l_date":        now.Unix(),
-		"s_words":       k.Interest,
-		"s_email":       k.Email,
-		"s_uid":         k.Id,
-		"s_province":    k.Province,
-		"a_interest":    k.Interest,
-		"s_content":     str,
-		"s_type":        "tender",
-		"a_publishtime": publishTimes,
-		"i_size":        len(publishTimes),
-	}
-	wid := mongodb.Save("wxpush", &wxpush)
-	wxDate := ""
-	if k.InterestDate > 0 {
-		mt1 := interface{}(k.InterestDate)
-		wxDate = util.FormatDateWithObj(&mt1, util.Date_Full_Layout)
-	} else {
-		r := rand.New(rand.NewSource(time.Now().UnixNano()))
-		n1 := r.Int63n(9)
-		n2 := r.Int63n(7200)
-		wxDate = time.Now().Local().Add(time.Duration(-n2) * time.Second).Add(time.Duration(-n1*24) * time.Hour).Format(util.Date_Full_Layout)
-	}
-
-	wxstr = "\n点击下方“详情”查看详细信息。\n以上招标信息,是剑鱼根据关键字“" + strings.Join(k.Interest, ";") + "”奋力查找并推送,如不合您心意,请猛戳企明星菜单“会员服务—剑鱼”进行修改。"
-	push.SendWinXin(&qrpc.NotifyMsg{
-		Openid:  k.Openid,
-		Title:   push.PushConfig["tenderTitle"].(string),
-		Remark:  wxstr,
-		Detail:  WXTitle,
-		Date:    wxDate,
-		Service: "剑鱼君",
-		Url:     push.PushConfig["bidViewDomain"].(string) + "/wxpush/bid/" + k.Openid + "/" + wid + "/aa"})
-
-}
-
-//执行日常招标中标公告的消息推送
+//执行日常招标的消息推送
 func (b *TenderPushJob) Execute() bool {
-	log.Println("开始执行招标任务:", push.PushConfig["tenderStartTime"])
-	push.InitCache("tender")
-	b.createUserInterestWord()
-	b.eachAllBidInfo()
-	return false
+	pj := dopush.Pjob{
+		MaxPushSize: MaxPushSize,
+		Stype:       "tender",
+		StypeName:   "招标",
+	}
+	st, _ := time.ParseInLocation(util.Date_Full_Layout, push.PushConfig["tenderStartTime"].(string), time.Local)
+	return pj.DoPush("", push.PushConfig["tenderStartTime"].(string), 1, st.Unix())
 }

+ 4 - 1
push/src/qfw/push/weixincall.go

@@ -6,9 +6,10 @@ import (
 	"net/rpc"
 	"qfw/util"
 	qrpc "qfw/util/rpc"
+	"time"
 )
 
-var wxpool chan bool = make(chan bool, 50)
+var wxpool chan bool = make(chan bool, 30)
 
 //微信远程调用,实现模板发送消息
 func SendWinXin(p *qrpc.NotifyMsg) {
@@ -18,6 +19,7 @@ func SendWinXin(p *qrpc.NotifyMsg) {
 	}()
 	util.Try(func() {
 		client, err := rpc.DialHTTP("tcp", PushConfig["weixinRpcServer"].(string))
+		defer client.Close()
 		if err != nil {
 			log.Println(err.Error())
 			return
@@ -28,4 +30,5 @@ func SendWinXin(p *qrpc.NotifyMsg) {
 			log.Println(err.Error())
 		}
 	}, func(e interface{}) {})
+	time.Sleep(10 * time.Millisecond)
 }

+ 4 - 6
weixin/src/config.json

@@ -20,8 +20,7 @@
 	"entAuthTip":",请按向导进行操作。第1步(共2步):请输入完整的企业名称。\n(认证过程只涉及您所在企业的公开信息。除非事先获得您的授权,企明星不会将您的个人隐私信息公开或透露给第三方机构。输入q或Q,退出认证操作。)",
 	"perAuthTip":",请按向导进行操作。第1步(共2步):请输入商家名称。\n(除非事先获得您的授权,企明星不会将您的个人隐私信息公开或透露给第三方机构。输入q或Q,退出认证操作。)",
 	"othAuthTip":",请按向导进行操作。第1步(共2步):请输入完整的组织机构名称。\n(认证过程只涉及您所在机构的公开信息。除非事先获得您的授权,企明星不会将您的个人隐私信息公开或透露给第三方机构。输入q或Q,退出认证操作。)",
-	"oWelcomeTip":"您已成功注册企明星!\n企明星是一个为全国企业提供专业化服务的互联网平台。
-",
+	"oWelcomeTip":"您已成功注册企明星!\n企明星是一个为全国企业提供专业化服务的互联网平台。",
         "loginTip":"您已经成功登录企明星,请在电脑端操作。",
         "freezeTip":"您的帐号已经冻结,请联系管理员。",
         "messagetpl":{
@@ -29,11 +28,10 @@
                 "offLinemsgtplid":"ExIeyFfoDNVJXhRDq09JbsjH_zbEJCB6gw6rxcV7atw",
                 "msgnotifytplid":"b7iuAMiTCIolnPhTdueKBVYThEMf2D-Bh2M_9v3J-68",
                 "managernotifytplid":"dplgu5Q644vzPdqcPXY7RqgItS3eXACmU1XDl27CvTA"
-        },
-        "activity":{
+        },"activity":{
                 "activitycode":"topcj",
                 "title":"企明星新年抽奖活动进行中",
                 "picurl":"http://www.qimingxing.info/images/choujiang.png"
-        }
-
+        },"weixinautorpl":"小主的吩咐我们已经收到了,请留下您的联系方式(手机号或qq号),企明星客服会在下一个工作日9:00-17:00给小主回复哦!",
+		"creditRpc":"http://127.0.0.1:8765"
 }

+ 10 - 0
weixin/src/qfw/weixin/dao/logsdao.go

@@ -51,3 +51,13 @@ func FindWinningRecord(openid, activitycode string) bool {
 	ret := mongodb.FindOne("winningrecord", M{"s_openid": openid, "s_actcode": activitycode})
 	return ret != nil && len(*ret) > 0
 }
+
+//存微信的离线消息
+func SaveWeixinOfflineMessage(openid, msg string, timestamp int64) {
+	data := map[string]interface{}{
+		"s_openid":    openid,
+		"s_msg":       msg,
+		"l_timestamp": timestamp,
+	}
+	mongodb.Save("weixinoffline", &data)
+}

+ 43 - 0
weixin/src/qfw/weixin/dao/sharedao.go

@@ -0,0 +1,43 @@
+package dao
+
+//分享,邀请类dao
+import (
+	"fmt"
+	. "gopkg.in/mgo.v2/bson"
+	"qfw/util/credit"
+	. "qfw/util/mongodb"
+	"time"
+)
+
+//
+var sharelock chan bool = make(chan bool, 10)
+
+//保存用户邀请关系,走线程池
+func SaveInviteLink(shareid string, myopenid string) {
+	//先找邀请人信息
+	sharelock <- true
+	ret := FindOne("person_share", M{"i_shareid": shareid})
+	if *ret == nil {
+		<-sharelock
+		return
+	}
+	source_opendid := (*ret)["s_openid"]
+	data := map[string]interface{}{
+		"s_target_openid": myopenid,
+		"s_source_openid": source_opendid,
+		"l_timestamp":     time.Now().Unix(),
+		"i_shareid":       shareid,
+		"s_businesscode":  (*ret)["s_businesscode"],
+	}
+	Save("person_invitelink", data)
+	//取用户ID
+	ret = FindOne("user", M{"s_m_openid": source_opendid})
+	if *ret == nil {
+		<-sharelock
+		return
+	}
+	smid := fmt.Sprintf("%x", string(((*ret)["_id"]).(ObjectId)))
+	//积分处理,RPC
+	credit.InCreditB(smid, credit.C_TG, nil)
+	<-sharelock
+}

+ 2 - 7
weixin/src/qfw/weixin/dao/userdao.go

@@ -40,13 +40,8 @@ func AddUser(openid, unionid, bindweixin, userphoto string) (err error, flag int
 		}
 		data["i_identificationway"] = 0
 		data["s_m_openid"] = openid //微信手机端openid
-		if len(Save("user", data)) > 0 {
-			//注册送积分
-			m := FindOne("user", `{"s_m_openid":"`+openid+`"}`)
-			if m != nil {
-				id := fmt.Sprintf("%x", string((*m)["_id"].(ObjectId)))
-				credit.InCreditA(id, credit.A_ZC, 0)
-			}
+		if id := Save("user", data); len(id) > 0 {
+			go credit.InCreditA(id, credit.A_ZC, 0)
 			return nil, 1
 		} else {
 			return errors.New("保存用户失败"), 0

+ 9 - 1
weixin/src/qfw/weixin/msgtxtchandler.go

@@ -73,7 +73,15 @@ func MsgTxtHandler(w ResponseWriter, r *Request) {
 		}
 	} else {
 		//属于在线咨询,暂时直接中转到微信客服系统
-		w.Reply2CustomerService()
+		//w.Reply2CustomerService()
+		//"小主的吩咐我们已经收到了,请耐心等待或留下您的联系方式(手机号或qq号),企明星客服会在下一个工作日9:00-17:00给小主回复哦!"
+		now := time.Now()
+		if now.Weekday() == 6 || now.Weekday() == 0 || (now.Hour() > 17 || now.Hour() < 9) {
+			dao.SaveWeixinOfflineMessage(r.FromUserName, r.Content, now.Unix())
+			w.ReplyText(wf.SysConfig.WeixinAutoRpl)
+		} else {
+			w.Reply2CustomerService()
+		}
 	}
 }
 

+ 46 - 0
weixin/src/qfw/weixin/rpc/share.go

@@ -0,0 +1,46 @@
+package rpc
+
+import (
+	"encoding/json"
+	"fmt"
+	"github.com/SKatiyar/qr"
+	"log"
+	"qfw/util/redis"
+)
+
+/**生成分享二维码
+规则:自动生成二维码,存储并存储到redis中
+	开发在使用时,先查看redis,没有的话再调用此RPC方法
+	生成的二维码有效期为一个月
+**/
+func (wxrpc *WeiXinRpc) GetShareQR(shareid uint32, ret *string) (err error) {
+	//构造自定义消息文本
+	var msg struct {
+		Expire int    `json:"expire_seconds"`
+		Name   string `json:"action_name"`
+		Info   struct {
+			Scene struct {
+				Id uint32 `json:"scene_id"`
+			} `json:"scene"`
+		} `json:"action_info"`
+	}
+	msg.Expire = 2592000
+	msg.Name = "QR_SCENE"
+	msg.Info.Scene.Id = shareid
+	data, err := wxrpc.wx.PostCustomMsg("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=", &msg)
+	if err != nil {
+		*ret = "faile"
+		log.Println(err.Error())
+		return nil
+	}
+	tmp := map[string]interface{}{}
+	json.Unmarshal(data, &tmp)
+	url := tmp["url"].(string)
+	//生二维码
+	r, _ := qr.Encode(url, qr.L)
+	pngdat := r.PNG()
+	//存储到redis
+	redis.PutBytes("sso", fmt.Sprintf("p_share_%d", shareid), &pngdat, msg.Expire)
+	*ret = "ok"
+	return nil
+}

+ 11 - 4
weixin/src/qfw/weixin/subscribehandler.go

@@ -12,6 +12,7 @@ import (
 	"qfw/weixin/dao"
 	"qfw/weixinconfig"
 	"regexp"
+	"strings"
 	"time"
 )
 
@@ -37,6 +38,7 @@ func SubscribeHandler(w ResponseWriter, r *Request) {
 		bindweixin, _ = ret["nickname"].(string)
 		//取得用户头像
 		headimgurl, _ := ret["headimgurl"].(string)
+		log.Println("download userface :", headimgurl)
 		userphoto = downloadUserFace(headimgurl)
 	}
 	_, flag := dao.AddUser(openid, unionid, bindweixin, userphoto)
@@ -49,12 +51,15 @@ func SubscribeHandler(w ResponseWriter, r *Request) {
 	}
 
 	if digitreg.MatchString(source) {
-		//
-		//log.Println("user-key:", source)
 		dao.SaveSubscribeLogs(openid, unionid, bindweixin, "wangzhan", "subscribe")
 		if flag == 1 {
 			w.ReplyText(WELCOME_MSG) // 有新人关注,返回欢迎消息
 			redis.Put("sso", "new_"+source, openid, 900)
+			//TODO 处理分享(邀请)类的二维码,记录邀请关系
+			if strings.HasPrefix(source, "32") {
+				//shareid, _ := strconv.Atoi(source)
+				go dao.SaveInviteLink(source, r.FromUserName)
+			}
 		} else {
 			w.ReplyText(OWELCOME_MSG) // 有旧人关注,返回欢迎消息
 		}
@@ -90,8 +95,8 @@ func UnSubscribeHandler(w ResponseWriter, r *Request) {
 
 //扫描二维码事件处理
 func ScanHandler(w ResponseWriter, r *Request) {
-	//log.Println("扫码事件::", r.EventKey, r.Event)
-	//log.Println("user-key:", r.EventKey)
+	log.Println("扫码事件::", r.EventKey, r.Event)
+	log.Println("user-key:", r.EventKey)
 	w.ReplyText(weixinconfig.SysConfig.LoginTip)
 	DoLogin(r.EventKey, r.FromUserName)
 
@@ -119,6 +124,8 @@ func downloadUserFace(url string) string {
 		defer resp.Body.Close()
 		if err == nil {
 			io.Copy(fi, resp.Body)
+		} else {
+			log.Println("download userface err:", err.Error())
 		}
 	}, func(e interface{}) {})
 	return filename

+ 13 - 0
weixin/src/qfw/weixin/txt_test.go

@@ -0,0 +1,13 @@
+package weixin
+
+import (
+	"log"
+	"testing"
+	"time"
+)
+
+func TestWeek(t *testing.T) {
+	d := time.Now()
+	d = d.AddDate(0, 0, 2)
+	log.Println(d.Hour(), d.Weekday(), int(d.Weekday()), d.Weekday() == 5)
+}

+ 2 - 0
weixin/src/qfw/weixin/weixinsdk.go

@@ -1133,10 +1133,12 @@ func (rw responseWriter) GetUserBaseInfo(openid string) (map[string]interface{},
 func (w *Weixin) GetUserBaseInfo(openid string) (map[string]interface{}, error) {
 	bs, err := sendGetRequest(weixinUserInfo+"?openid="+openid+"&lang=zh_CN&access_token=", w.tokenChan)
 	if err == nil {
+		log.Println("get userinfo ", string(bs))
 		ret := map[string]interface{}{}
 		err = json.Unmarshal(bs, &ret)
 		return ret, err
 	} else {
+		log.Println("get userinfo err ", err.Error())
 		return nil, err
 	}
 }

+ 1 - 9
weixin/src/qfw/weixinconfig/config_test.go

@@ -1,16 +1,8 @@
 package weixinconfig
 
-import (
-	"log"
-
-	"qfw/util"
-	"testing"
-)
+import ()
 
 //初始化
 func TestReadConfig(t *testing.T) {
 
-	//读取配置
-	util.ReadConfig("../../config.json", &SysConfig)
-	log.Println(SysConfig)
 }

+ 1 - 0
weixin/src/qfw/weixinconfig/weixinconfig.go

@@ -29,6 +29,7 @@ type wxconfig struct {
 	LoginTip        string            `json:"loginTip"`
 	FreezeTip       string            `json:"freezeTip"`
 	Activity        map[string]string `json:"activity"` //活动配置
+	WeixinAutoRpl   string            `json:"weixinautorpl"`
 }
 
 //系统配置