Browse Source

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

wangshan 9 years ago
parent
commit
c480477395

+ 20 - 9
common/src/main.go

@@ -39,23 +39,34 @@ func main() {
 		m = bson.M{"Area": os.Args[5]}
 		m = bson.M{"Area": os.Args[5]}
 	}
 	}
 	log.Printf("检索条件:%v", m)
 	log.Printf("检索条件:%v", m)
-	i := 0
 	var dbType = "web"
 	var dbType = "web"
 	if isEnterprise {
 	if isEnterprise {
 		dbType = "ecps"
 		dbType = "ecps"
 	}
 	}
-	count := Count(os.Args[4], dbType, "qfw", nil)
+	count := Count(os.Args[4], dbType, "qfw", dbType)
 	totalPages := ((count + N - 1) / N)
 	totalPages := ((count + N - 1) / N)
 	log.Println(util.If(isEnterprise, "公式库", "网站库"), os.Args[4], "表有", count, "条数据", "一共", totalPages, "页")
 	log.Println(util.If(isEnterprise, "公式库", "网站库"), os.Args[4], "表有", count, "条数据", "一共", totalPages, "页")
-	for i := 0; i < totalPages; i++ {
-		arr := Find(os.Args[4], dbType, "qfw", m, nil, nil, false, i*N, N)
-		if isEnterprise {
-			for a, v := range *arr {
-				(*arr)[a] = elastic.ConverData(&v)
+	sess := GetMgoConn(dbType)
+	defer DestoryMongoConn(dbType, sess)
+	query := sess.DB("qfw").C(os.Args[4]).Find(m).Iter()
+	arr := make([]map[string]interface{}, 0)
+	i := 0
+	for tmp := make(map[string]interface{}); query.Next(tmp); i++ {
+		if i >= 12690000 {
+			arr = append(arr, elastic.ConverData(&tmp))
+			if len(arr) == N {
+				elastic.BulkSave(os.Args[6], os.Args[7], &arr, true)
+				arr = make([]map[string]interface{}, 0)
 			}
 			}
 		}
 		}
-		elastic.BulkSave(os.Args[6], os.Args[7], arr, true)
-		log.Println("当前是第", i+1, "页")
+		if i%N == 0 {
+			log.Printf("当前索引位置:=%d \n", i)
+		}
+	}
+	log.Println("剩余.....", len(arr))
+	if len(arr) > 0 {
+		elastic.BulkSave(os.Args[6], os.Args[7], &arr, true)
+		arr = make([]map[string]interface{}, 0)
 	}
 	}
 	if isEnterprise {
 	if isEnterprise {
 		//生成带名片索引
 		//生成带名片索引

+ 3 - 3
core/src/qfw/member/service.go

@@ -168,9 +168,7 @@ func (yp *Service) Save() error {
 	}
 	}
 	if tempFlag {
 	if tempFlag {
 		//删除缓存信息
 		//删除缓存信息
-		if len(serviceid) == 0 {
-			redis.Del("enterprise", "enterpriseInfo_"+enterpriseid)
-		}
+		redis.Del("enterprise", "enterpriseInfo_"+util.ObjToString(yp.GetSession("entid")))
 		//将数据存到elastic中
 		//将数据存到elastic中
 		flag2 := elastic.UpdateNewDoc("service", "service", doc)
 		flag2 := elastic.UpdateNewDoc("service", "service", doc)
 		//Insertservicenames(enterpriseid)
 		//Insertservicenames(enterpriseid)
@@ -313,6 +311,7 @@ func (u *Service) Del() error {
 			//再删除elasticsearch中的数据
 			//再删除elasticsearch中的数据
 			flag2 := elastic.DelById(index, itype, id)
 			flag2 := elastic.DelById(index, itype, id)
 			if flag2 {
 			if flag2 {
+				redis.Del("enterprise", "enterpriseInfo_"+util.ObjToString(entid))
 				u.ServeJson(&map[string]interface{}{
 				u.ServeJson(&map[string]interface{}{
 					"msg": "删除服务成功!",
 					"msg": "删除服务成功!",
 				})
 				})
@@ -369,6 +368,7 @@ func (u *Service) Remove() error {
 				isUpdate := elastic.UpdateNewDoc(index, itype, mongodb.FindById("service", sid, nil))
 				isUpdate := elastic.UpdateNewDoc(index, itype, mongodb.FindById("service", sid, nil))
 
 
 				if isUpdate {
 				if isUpdate {
+					redis.Del("enterprise", "enterpriseInfo_"+util.ObjToString(entid))
 					u.ServeJson(&map[string]interface{}{
 					u.ServeJson(&map[string]interface{}{
 						"msg": "下架成功!",
 						"msg": "下架成功!",
 					})
 					})

+ 7 - 0
core/src/qfw/member/yellowpage.go

@@ -241,11 +241,18 @@ func (yp *Yellowpage) WxFollow() error {
 
 
 //关注企业
 //关注企业
 func (yp *Yellowpage) Follow() error {
 func (yp *Yellowpage) Follow() error {
+	defer util.Catch()
 	entId := yp.GetString("entId")
 	entId := yp.GetString("entId")
 	flag, _ := yp.GetBool("flag")
 	flag, _ := yp.GetBool("flag")
 	userId := yp.GetSession("userId").(string)
 	userId := yp.GetSession("userId").(string)
 	status := "n"
 	status := "n"
 	if flag {
 	if flag {
+		data := mongodb.FindOne("follow_enterprise", `{"s_userid":"`+userId+`","s_entid":"`+entId+`"}`)
+		if data != nil && len(*data) > 0 {
+			(*data)["s_followid"] = util.BsonIdToSId((*data)["_id"])
+			delete((*data), "_id")
+			mongodb.Save("follow_enterprise_back", data)
+		}
 		if mongodb.Del("follow_enterprise", `{"s_userid":"`+userId+`","s_entid":"`+entId+`"}`) {
 		if mongodb.Del("follow_enterprise", `{"s_userid":"`+userId+`","s_entid":"`+entId+`"}`) {
 			status = "y"
 			status = "y"
 		}
 		}

+ 13 - 12
core/src/qfw/searchmarket/service.go

@@ -50,22 +50,23 @@ func (s *Service) Slist() error {
 		start := (currentPage - 1) * limit
 		start := (currentPage - 1) * limit
 		var count int
 		var count int
 		var r []map[string]interface{}
 		var r []map[string]interface{}
+		query := `{"query": {
+		    "bool": {
+			  "must":[
+				{"term":{"s_enterpriseid":"` + id + `"}},
+				{"query_string": {"default_field": "s_isshow","query": "*3*"}}
+			  ],
+			  "must_not":[{"term":{"i_status":1}}]
+		    }
+		  }`
+		queryCount := query + "}"
+		queryList := query + `,"from":` + fmt.Sprintf("%v", start) + `,"size":` + fmt.Sprintf("%v", limit) + `,"sort":[{"l_createdate":"desc"}]}`
 		searchtype := "service"
 		searchtype := "service"
-		str := `{"prefix":{"s_enterpriseid":"` + id + `"}}`
-		var tempQuery = ""
-		tempQuery = `{"query": {
-	    "bool": {
-		  "must":[` + str + `],
-	      "minimum_should_match": 1
-	    }
-	  }}`
-		sort := `{"l_createdate":"desc"}`
 		if currentPage == 1 {
 		if currentPage == 1 {
-			count = int(elastic.Count(searchtype, searchtype, tempQuery))
+			count = int(elastic.Count(searchtype, searchtype, queryCount))
 		}
 		}
 		//
 		//
-		query := `{"query":{"term":{"s_enterpriseid":"` + id + `"}},"from":` + fmt.Sprintf("%v", start) + `,"size":` + fmt.Sprintf("%v", limit) + `,"sort":[` + sort + `]}`
-		r = *elastic.Get(searchtype, searchtype, query)
+		r = *elastic.Get(searchtype, searchtype, queryList)
 		s.ServeJson(M{"list": r, "count": count})
 		s.ServeJson(M{"list": r, "count": count})
 		return nil
 		return nil
 	}
 	}

+ 3 - 3
core/src/qfw/swordfish/swordfishmanage.go

@@ -101,7 +101,7 @@ func (s *SwordFish) Wxprotocol() error {
 
 
 //剑鱼微信查询页面
 //剑鱼微信查询页面
 func (s *SwordFish) Wxsearch() error {
 func (s *SwordFish) Wxsearch() error {
-	s.T["signature "] = mobile.GetSignature(s.Action)
+	s.T["signature"] = mobile.GetSignature(s.Action)
 	s.T["shareid"] = cutil.FindMyShareId("topjy", s.Session().Get("s_m_openid").(string))
 	s.T["shareid"] = cutil.FindMyShareId("topjy", s.Session().Get("s_m_openid").(string))
 	return s.Render("/swordfish/wxsearch.html")
 	return s.Render("/swordfish/wxsearch.html")
 }
 }
@@ -143,7 +143,7 @@ func (s *SwordFish) Wxsearchlist() error {
 		}
 		}
 	}
 	}
 	//搜索列表增加分享
 	//搜索列表增加分享
-	s.T["signature "] = mobile.GetSignature(s.Action)
+	s.T["signature"] = mobile.GetSignature(s.Action)
 	s.T["shareid"] = cutil.FindMyShareId("topjy", s.Session().Get("s_m_openid").(string))
 	s.T["shareid"] = cutil.FindMyShareId("topjy", s.Session().Get("s_m_openid").(string))
 	return s.Render("/swordfish/wxsearchlist.html", &s.T)
 	return s.Render("/swordfish/wxsearchlist.html", &s.T)
 }
 }
@@ -269,7 +269,7 @@ func getSwordFish(lasttime int64, sid string, res []map[string]interface{}, coun
 func (s *SwordFish) VisitRedirect() {
 func (s *SwordFish) VisitRedirect() {
 	sid := s.GetString("id")
 	sid := s.GetString("id")
 	surl := s.GetString("url")
 	surl := s.GetString("url")
-	s.T["signature "] = mobile.GetSignature(s.Action)
+	s.T["signature"] = mobile.GetSignature(s.Action)
 	s.T["shareid"] = cutil.FindMyShareId("topjy", s.Session().Get("s_m_openid").(string))
 	s.T["shareid"] = cutil.FindMyShareId("topjy", s.Session().Get("s_m_openid").(string))
 	if len(sid) > 5 {
 	if len(sid) > 5 {
 		obj := *mongodb.FindById("bidding", sid, `{"publishtime":1,"_id":0,"detail":1,"title":1}`)
 		obj := *mongodb.FindById("bidding", sid, `{"publishtime":1,"_id":0,"detail":1,"title":1}`)

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

@@ -215,6 +215,7 @@ func CommonEntInfo(yp *xweb.Action, id string, editFlag int, ismobile bool) erro
 		yp.T["copyright"] = FindOne("enterprise_copyright", `{"EntId":"`+id+`"}`)
 		yp.T["copyright"] = FindOne("enterprise_copyright", `{"EntId":"`+id+`"}`)
 		//编辑企业名片标识
 		//编辑企业名片标识
 		yp.T["editFlag"] = editFlag
 		yp.T["editFlag"] = editFlag
+		yp.T["lastService"] = getLastService(id)
 		//过滤企业名
 		//过滤企业名
 		if relflag && nodes != nil && len(*nodes) > 0 {
 		if relflag && nodes != nil && len(*nodes) > 0 {
 			go func() {
 			go func() {
@@ -233,7 +234,6 @@ func CommonEntInfo(yp *xweb.Action, id string, editFlag int, ismobile bool) erro
 			return yp.Render("/enterprise/detail.html", &yp.T)
 			return yp.Render("/enterprise/detail.html", &yp.T)
 		} else {
 		} else {
 			//服务数量
 			//服务数量
-			yp.T["serviceCount"] = getEntServiceCount(id)
 			var contentuser []byte
 			var contentuser []byte
 			var erruser error
 			var erruser error
 			if ismobile {
 			if ismobile {
@@ -530,13 +530,21 @@ func getDishonesty(legcerNo string, currentPage int) map[string]interface{} {
 }
 }
 
 
 //获取该企业的服务数量
 //获取该企业的服务数量
-func getEntServiceCount(id string) int64 {
+func getLastService(id string) string {
 	query := `{"query": {
 	query := `{"query": {
 		    "bool": {
 		    "bool": {
-			  "must":[{"query_string":{"default_field": "s_enterpriseid","query":"` + id + `"}}],"must_not" : [{"term" : {"i_status" : 1 }}]
+			  "must":[
+				  {"term":{"s_enterpriseid":"` + id + `"}},
+				  {"query_string": {"default_field": "s_isshow","query": "*3*"}}
+				],
+			  "must_not":[{"term":{"i_status":1}}]
 		    }
 		    }
-		  }}`
-	return elastic.Count("service", "service", query)
+		  },"from":0,"size":1,"sort":[{"l_createdate":"desc"}]}`
+	r := elastic.Get("service", "service", query)
+	if r != nil && len(*r) == 1 {
+		return util.ObjToString((*r)[0]["_id"])
+	}
+	return ""
 }
 }
 func checkAuth(obj map[string]interface{}) (b bool, err string) {
 func checkAuth(obj map[string]interface{}) (b bool, err string) {
 	if len(obj) > 0 {
 	if len(obj) > 0 {

+ 1 - 1
core/src/web/staticres/css/entcommunity.css

@@ -507,7 +507,7 @@ a:focus, a:hover{
     color: #fff !important;
     color: #fff !important;
 	font-size: 12px !important;
 	font-size: 12px !important;
 	left: 6px;
 	left: 6px;
-	top: 1.5px;
+	top: 1px;
 }
 }
 .ent-exception{
 .ent-exception{
 	padding: 0px 6px;
 	padding: 0px 6px;

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

@@ -705,7 +705,7 @@ var TipAssembly = {
 		this.timeout = setTimeout(function(){
 		this.timeout = setTimeout(function(){
 			thisClass.hide();
 			thisClass.hide();
 			thisClass.timeout = null;
 			thisClass.timeout = null;
-		},3000);
+		},1000);
 		$("body").append('<div class="tipAssembly" id="tipAssembly">'+text+'</div>');
 		$("body").append('<div class="tipAssembly" id="tipAssembly">'+text+'</div>');
 		if(typeof(css) != "undefined"){
 		if(typeof(css) != "undefined"){
 			$("#tipAssembly").css(css);
 			$("#tipAssembly").css(css);

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

@@ -222,7 +222,7 @@
 	</div>
 	</div>
 	</a>
 	</a>
 	<div class="list-group-item" id="personal">个人菜单</div>
 	<div class="list-group-item" id="personal">个人菜单</div>
-	<a class="list-group-item" onclick="window.location.href = '/member/swordfish/rssset'"><i class="glyphicon qmx-icon-jianyu"></i>剑鱼</a>
+	<a class="list-group-item" onclick="window.location.href = 'http://www.zhaobiao.info'"><i class="glyphicon qmx-icon-jianyu"></i>剑鱼</a>
 	
 	
 </div>
 </div>
 <!-- vipcreditModal -->
 <!-- vipcreditModal -->

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

@@ -2,7 +2,7 @@
 	<div>
 	<div>
 		<ul class="pull-right">
 		<ul class="pull-right">
 			<li><span class="img-circle b-com-first"><i class="glyphicon fuwushichang"></i></span><a href="/market/0/list.html">服务市场</a></li>
 			<li><span class="img-circle b-com-first"><i class="glyphicon fuwushichang"></i></span><a href="/market/0/list.html">服务市场</a></li>
-			<li><span class="img-circle b-com-second"><i class="glyphicon jianyu"></i></span><a href="/front/swordfish">剑鱼</a></li>
+			<li><span class="img-circle b-com-second"><i class="glyphicon jianyu"></i></span><a href="http://www.zhaobiao.info">剑鱼</a></li>
 			<li><span class="img-circle b-com-third"><i class="glyphicon qiyeshequ"></i></span><a href="/front/entCommunity.html">企业社区</a></li>
 			<li><span class="img-circle b-com-third"><i class="glyphicon qiyeshequ"></i></span><a href="/front/entCommunity.html">企业社区</a></li>
 			<li><span class="img-circle b-com-four"><i class="glyphicon weiguanwang1"></i></span><a href="/front/wsite.html">微官网</a></li>
 			<li><span class="img-circle b-com-four"><i class="glyphicon weiguanwang1"></i></span><a href="/front/wsite.html">微官网</a></li>
 			<li><span class="img-circle b-com-five"><i class="glyphicon zhengcefagui"></i></span><a href="/front/content_zcfg_list.html">政策法规</a></li>
 			<li><span class="img-circle b-com-five"><i class="glyphicon zhengcefagui"></i></span><a href="/front/content_zcfg_list.html">政策法规</a></li>

+ 2 - 2
core/src/web/templates/enterprise/detail.html

@@ -24,7 +24,7 @@
 			{{end}}
 			{{end}}
 		</div>
 		</div>
 		<div class="entinfo-cart{{if eq .T.editFlag 2}} entinfo-editcart{{end}}">
 		<div class="entinfo-cart{{if eq .T.editFlag 2}} entinfo-editcart{{end}}">
-			{{if eq .T.editFlag 1}}<a class="btn btn-primary btn-save" href="/member/enterprise/edit">编辑</a>{{end}}
+			{{if eq .T.editFlag 1}}<button class="btn btn-primary btn-save" onclick="window.location.href='/member/enterprise/edit'">编辑</button>{{end}}
 			{{if eq .T.editFlag 2}}<button id="editSave" class="btn btn-primary btn-save">保存</button>{{end}}
 			{{if eq .T.editFlag 2}}<button id="editSave" class="btn btn-primary btn-save">保存</button>{{end}}
 			<div class="b-com-first">
 			<div class="b-com-first">
 				<font class="b-com-title">{{if .T.res.EntName}}{{.T.res.EntName}}{{end}}</font>
 				<font class="b-com-title">{{if .T.res.EntName}}{{.T.res.EntName}}{{end}}</font>
@@ -74,7 +74,7 @@
 						{{end}}
 						{{end}}
 					{{end}}
 					{{end}}
 				{{end}}
 				{{end}}
-				{{if .T.serviceCount}}<a>服务信息<div class="servicelink"><i class="glyphicon qmx-icon-right"></i></div></a>{{end}}
+				{{if .T.lastService}}<a href="/market/detail/{{.T.lastService}}.html#moreservice">服务信息<div class="servicelink"><i class="glyphicon qmx-icon-right"></i></div></a>{{end}}
 			</div>
 			</div>
 			{{if eq .T.editFlag 2}}
 			{{if eq .T.editFlag 2}}
 			<form class="b-editEnt-form" id="editForm">
 			<form class="b-editEnt-form" id="editForm">

+ 33 - 16
core/src/web/templates/manage/tj.html

@@ -24,7 +24,7 @@
 				color:#ff5a5f;
 				color:#ff5a5f;
 			}
 			}
 			.counttab{
 			.counttab{
-				width:420px;
+				width:440px;
 				height:34px;
 				height:34px;
 				margin:30px 0px 30px 18px;
 				margin:30px 0px 30px 18px;
 				background-color:#F8F8F8;
 				background-color:#F8F8F8;
@@ -236,36 +236,53 @@
 						 title: "认证个人",
 						 title: "认证个人",
 						field: "personum",
 						field: "personum",
 						callback:function(ct,cd,val,k,m){
 						callback:function(ct,cd,val,k,m){
-							if (!cd){
-								return "-";
+							var enternum=ct.enternum;
+							var personum=ct.personum;
+							var organnum=ct.organnum;
+							if(!enternum){
+								enternum=0;
 							}
 							}
-							 return cd;
+							if(!personum){
+								personum=0;
+							}
+							if(!organnum){
+								organnum=0;
+							}
+							 return enternum+personum+organnum;
 						}
 						}
 					},
 					},
 					{
 					{
-						 title: "认证企业",
-						field: "enternum",
-						callback:function(ct,cd,val,k,m){
-							if (!cd){
-								return "-";
+						 title: "剑鱼订阅(总)",
+						field: "sfish",
+						callback:function(ct,cd,val,k,m){	
+							var sfish=ct.sfish;
+							var snfish=ct.snfish;
+							if(!sfish){
+								sfish=0;
 							}
 							}
-							 return cd;
+							if(!snfish){
+								snfish=0;
+							}
+							 return (sfish+snfish)+"人";
 						}
 						}
 					},
 					},
 					{
 					{
-						 title: "认证机构",
-						field: "organnum",
+						 title: "剑鱼订阅(旧)",
+						field: "sfish",
 						callback:function(ct,cd,val,k,m){
 						callback:function(ct,cd,val,k,m){
-							if (!cd){
+							 if(!cd){
 								return "-";
 								return "-";
 							}
 							}
-							 return cd;
+							 return cd+"人";
 						}
 						}
 					},
 					},
 					{
 					{
-						 title: "剑鱼订阅",
-						field: "sfish",
+						 title: "剑鱼订阅(新)",
+						field: "snfish",
 						callback:function(ct,cd,val,k,m){	
 						callback:function(ct,cd,val,k,m){	
+							if(!cd){
+								return "-";
+							}
 							 return cd+"人";
 							 return cd+"人";
 						}
 						}
 					},
 					},

+ 1 - 1
core/src/web/templates/member/mydemand.html

@@ -61,7 +61,7 @@
 			</div>
 			</div>
 			<div class="modal-footer">
 			<div class="modal-footer">
 				<button type="button" class="btn btn-primary u-btn" id="revokeReason-sure">确认</button>
 				<button type="button" class="btn btn-primary u-btn" id="revokeReason-sure">确认</button>
-				<button type="button" class="btn btn-btn-default u-btn" data-dismiss="modal">取消</button>
+				<button type="button" class="btn btn-default u-btn" data-dismiss="modal">取消</button>
 			</div>
 			</div>
 		</div>
 		</div>
 	</div>
 	</div>

+ 5 - 1
core/src/web/templates/service/detail.html

@@ -267,7 +267,7 @@
 			<a type="button" class="text-muted btnactive" style="margin-left:18px;border-left:1px solid #FFF;">服务详情</a>
 			<a type="button" class="text-muted btnactive" style="margin-left:18px;border-left:1px solid #FFF;">服务详情</a>
 			<a type="button" class="text-muted">服务评价({{.T.sinfo.i_comments}})</a>
 			<a type="button" class="text-muted">服务评价({{.T.sinfo.i_comments}})</a>
 			<a type="button" class="text-muted">预约记录({{.T.appcount}})</a>
 			<a type="button" class="text-muted">预约记录({{.T.appcount}})</a>
-			<a type="button" class="text-muted">更多服务</a>
+			<a type="button" class="text-muted" id="moreservice">更多服务</a>
 			{{end}}
 			{{end}}
 			
 			
 			{{if .T.status }}
 			{{if .T.status }}
@@ -529,6 +529,10 @@ $(function(){
 		$(".d_fwfl a").eq(1)[0].click();
 		$(".d_fwfl a").eq(1)[0].click();
 	}
 	}
 	setPrice();
 	setPrice();
+	//从企业社区的链接过来,自动显示服务列表
+	if(/\#moreservice$/.test(window.location.href)){
+		$(".d_fwfl a:last").click();
+	}
 });
 });
 
 
 var limit=0;
 var limit=0;

+ 78 - 21
weixin/src/qfw/weixin/distinguishwork.go

@@ -2,8 +2,13 @@
 package weixin
 package weixin
 
 
 import (
 import (
+	"bytes"
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
+	"github.com/disintegration/imaging"
+	"image"
+	"image/color"
+	"io"
 	"log"
 	"log"
 	"math/rand"
 	"math/rand"
 	util "mfw/util"
 	util "mfw/util"
@@ -11,7 +16,6 @@ import (
 	"net/rpc"
 	"net/rpc"
 	"os"
 	"os"
 	qfwutil "qfw/util"
 	qfwutil "qfw/util"
-	"qfw/util/image"
 	qrpc "qfw/util/rpc"
 	qrpc "qfw/util/rpc"
 	wf "qfw/weixinconfig"
 	wf "qfw/weixinconfig"
 	"sync"
 	"sync"
@@ -22,6 +26,11 @@ const (
 	status_rest      = 0 //闲时,没有任务
 	status_rest      = 0 //闲时,没有任务
 	status_working   = 1 //进入工作状态
 	status_working   = 1 //进入工作状态
 	status_waitReply = 2 //收到验证码,等待回复
 	status_waitReply = 2 //收到验证码,等待回复
+	//
+	white          = uint8(0xff)
+	bgImgName      = "background.jpg"
+	newsImagWidth  = 640
+	newsImagHeight = 320
 )
 )
 
 
 var workLock = new(sync.Mutex)
 var workLock = new(sync.Mutex)
@@ -34,6 +43,10 @@ var client *util.Client
 type DistinguishWork struct {
 type DistinguishWork struct {
 }
 }
 
 
+func init() {
+
+}
+
 func InitDgWork() {
 func InitDgWork() {
 	client, _ = util.StartClient(processevent, wf.SysConfig.Msgserver, []int{util.SERVICE_DISTINGUISH}, 20)
 	client, _ = util.StartClient(processevent, wf.SysConfig.Msgserver, []int{util.SERVICE_DISTINGUISH}, 20)
 	client.ResetMyName("识别验证码")
 	client.ResetMyName("识别验证码")
@@ -42,6 +55,7 @@ func processevent(p *util.Packet) {
 	event := int(p.Event)
 	event := int(p.Event)
 	switch event {
 	switch event {
 	case util.SERVICE_DISTINGUISH:
 	case util.SERVICE_DISTINGUISH:
+		defer util.Catch()
 		log.Println("------接收到消息的数据-----")
 		log.Println("------接收到消息的数据-----")
 		//写数据
 		//写数据
 		if ret := make(map[string]interface{}); json.Unmarshal(p.GetBusinessData(), &ret) == nil {
 		if ret := make(map[string]interface{}); json.Unmarshal(p.GetBusinessData(), &ret) == nil {
@@ -79,6 +93,7 @@ func processevent(p *util.Packet) {
 
 
 //开始工作,记录工作人的相关数
 //开始工作,记录工作人的相关数
 func (a *DistinguishWork) Start(openId string) {
 func (a *DistinguishWork) Start(openId string) {
+	defer util.Catch()
 	if client == nil {
 	if client == nil {
 		InitDgWork()
 		InitDgWork()
 	}
 	}
@@ -93,6 +108,7 @@ func (a *DistinguishWork) Start(openId string) {
 
 
 //结束工作,删除工作人
 //结束工作,删除工作人
 func (a *DistinguishWork) End(openId string) {
 func (a *DistinguishWork) End(openId string) {
+	defer util.Catch()
 	end(openId)
 	end(openId)
 }
 }
 
 
@@ -108,6 +124,7 @@ func end(openId string) {
 
 
 //判断该人是否是工作模式
 //判断该人是否是工作模式
 func (a *DistinguishWork) IsWorking(openId string) bool {
 func (a *DistinguishWork) IsWorking(openId string) bool {
+	defer util.Catch()
 	for _, v := range workers {
 	for _, v := range workers {
 		if v["openId"] == openId {
 		if v["openId"] == openId {
 			return true
 			return true
@@ -118,6 +135,7 @@ func (a *DistinguishWork) IsWorking(openId string) bool {
 
 
 //判断该人是否在等待回复
 //判断该人是否在等待回复
 func (a *DistinguishWork) IsWaitReply(openId string) bool {
 func (a *DistinguishWork) IsWaitReply(openId string) bool {
+	defer util.Catch()
 	for _, v := range workers {
 	for _, v := range workers {
 		if v["openId"] == openId {
 		if v["openId"] == openId {
 			return v["status"] == status_waitReply
 			return v["status"] == status_waitReply
@@ -138,6 +156,7 @@ func overtime(msgId string) {
 
 
 //回复验证码
 //回复验证码
 func (a *DistinguishWork) Reply(openId, content string) {
 func (a *DistinguishWork) Reply(openId, content string) {
+	defer util.Catch()
 	obj := workering[openId]
 	obj := workering[openId]
 	if obj == nil || len(obj) < 2 {
 	if obj == nil || len(obj) < 2 {
 		return
 		return
@@ -216,7 +235,6 @@ func worked(o map[string]interface{}) (string, map[string]interface{}, int) {
 		obj["imgName"] = name
 		obj["imgName"] = name
 	}
 	}
 	if name == "" || err != nil {
 	if name == "" || err != nil {
-		log.Println("生成验证码图片出错:", err)
 		return openId, obj, -2
 		return openId, obj, -2
 	}
 	}
 	workering[openId] = []string{msgId, from}
 	workering[openId] = []string{msgId, from}
@@ -313,40 +331,79 @@ func getWorker(obj map[string]interface{}) (openId string, object map[string]int
 //获取一个要识别的任务
 //获取一个要识别的任务
 func createImg(msgId string, img []byte) (string, error) {
 func createImg(msgId string, img []byte) (string, error) {
 	name := msgId + "-" + fmt.Sprint(time.Now().Unix()) + ".jpg"
 	name := msgId + "-" + fmt.Sprint(time.Now().Unix()) + ".jpg"
-	path := wf.SysConfig.Imgpath + "/upload/spider"
+	path := wf.SysConfig.Imgpath + "/upload/spider/"
 	fs, err := os.Open(path)
 	fs, err := os.Open(path)
 	if err != nil && os.MkdirAll(path, 0700) != nil {
 	if err != nil && os.MkdirAll(path, 0700) != nil {
 		log.Println("创建文件夹出错:", err)
 		log.Println("创建文件夹出错:", err)
 		return "", err
 		return "", err
 	}
 	}
 	defer fs.Close()
 	defer fs.Close()
-	file, err := os.Create(path + "/" + name)
+	err = processImg(path, name, bytes.NewBuffer(img), img)
 	if err != nil {
 	if err != nil {
-		log.Println("创建验证码图片出错:", err)
 		return "", err
 		return "", err
 	}
 	}
-	defer file.Close()
-	_, err = file.Write(img)
+	return name, nil
+}
+
+func processImg(path, name string, file io.Reader, img []byte) error {
+	b_image, err := imaging.Open(path + bgImgName)
 	if err != nil {
 	if err != nil {
-		log.Println("写入验证码图片出错:", err)
-		return "", err
+		b_newImg := imaging.New(newsImagWidth, newsImagHeight, color.NRGBA{white, white, white, white})
+		err = imaging.Save(b_newImg, path+bgImgName)
+		if err != nil {
+			log.Println("创建背景图片出错!", err)
+		}
+		b_image, err = imaging.Open(path + bgImgName)
+		if err != nil {
+			log.Println("重新打开背景图片出错!", err)
+		}
+	}
+	config, _, err := image.DecodeConfig(file)
+	if err != nil {
+		log.Println("获取图片config出错!", err)
+		return err
+	}
+	w := config.Width
+	h := config.Height
+	if w >= newsImagWidth {
+		return nil
 	}
 	}
-	newName, e := image.MakeResize(path+"/"+name, 640, 320, 100, 0)
-	if e == nil {
-		//删除老文件
-		file.Close()
-		if e = os.Remove(path + "/" + name); e != nil {
-			return newName, nil
+	f, err := os.Create(path + name)
+	if err != nil {
+		log.Println("创建图片出错!", err)
+		return err
+	}
+	_, err = f.Write(img)
+	if err != nil {
+		log.Println("写入图片出错!", err)
+		return err
+	}
+	f.Close()
+	_file, err := imaging.Open(path + name)
+	if err != nil {
+		log.Println("打开图片出错!", err)
+		return err
+	}
+	if h > newsImagHeight {
+		err = imaging.Save(imaging.Resize(_file, 0, newsImagHeight, imaging.Lanczos), path+name)
+		if err != nil {
+			log.Println("缩放图片出错!", err)
+			return err
+		}
+		_file, err = imaging.Open(path + name)
+		if err != nil {
+			log.Println("缩放之后重新打开图片出错!", err)
+			return err
 		}
 		}
-		os.Rename(path+"/"+newName, path+"/"+name)
 	}
 	}
-	return name, nil
+	err = imaging.Save(imaging.PasteCenter(b_image, _file), path+name)
+	if err != nil {
+		log.Println("合并之后创建图片出错:", err)
+		return err
+	}
+	return nil
 }
 }
 
 
-func Distinguishworkinit(w http.ResponseWriter, r *http.Request) {
-	var distinguishWork DistinguishWork
-	distinguishWork.Start("o8-2pwHj1s_tv3nnRxrH9cD2ngkk")
-}
 func Monitor(w http.ResponseWriter, r *http.Request) {
 func Monitor(w http.ResponseWriter, r *http.Request) {
 	var h_p, h_w, h_wa string
 	var h_p, h_w, h_wa string
 	for _, v := range workers {
 	for _, v := range workers {

+ 6 - 2
weixin/src/qfw/weixin/msgtxtchandler.go

@@ -109,14 +109,18 @@ func MsgTxtHandler(w ResponseWriter, r *Request) {
 		}})
 		}})
 	} else if r.Content == "开始识别验证码" { //进入人工识别验证码工作
 	} else if r.Content == "开始识别验证码" { //进入人工识别验证码工作
 		w.ReplyText(wf.SysConfig.DistinguishWork["in"].(string))
 		w.ReplyText(wf.SysConfig.DistinguishWork["in"].(string))
-		distinguishWork.Start(openid)
+		time.AfterFunc(2*time.Second, func() {
+			distinguishWork.Start(openid)
+		})
 	} else if distinguishWork.IsWorking(openid) { //人工识别验证码工作中。。。
 	} else if distinguishWork.IsWorking(openid) { //人工识别验证码工作中。。。
 		if r.Content == "结束识别验证码" {
 		if r.Content == "结束识别验证码" {
 			w.ReplyText(wf.SysConfig.DistinguishWork["out"].(string))
 			w.ReplyText(wf.SysConfig.DistinguishWork["out"].(string))
 			distinguishWork.End(openid)
 			distinguishWork.End(openid)
 		} else if distinguishWork.IsWaitReply(openid) {
 		} else if distinguishWork.IsWaitReply(openid) {
 			w.PostText(wf.SysConfig.DistinguishWork["reply"].(string))
 			w.PostText(wf.SysConfig.DistinguishWork["reply"].(string))
-			distinguishWork.Reply(openid, r.Content)
+			time.AfterFunc(1*time.Second, func() {
+				distinguishWork.Reply(openid, r.Content)
+			})
 		}
 		}
 	} else {
 	} else {
 		now := time.Now()
 		now := time.Now()