Bladeren bron

Merge branch 'dev1.4.1' of http://192.168.3.207:10080/qmx/datatag into dev1.4.1

fuwencai 4 jaren geleden
bovenliggende
commit
829ac07f96

+ 39 - 8
src/client/client.go

@@ -129,7 +129,7 @@ func (c *Client) CuserRuleCreate() {
 				data["entUserId"] = entUserId
 			}
 			data["entId"] = qu.IntAll(user["ent_id"])
-			data["appid"] = qu.ObjToString(user["app_id"])
+			data["appid"] = qu.ObjToString(user["appid"])
 			data["i_createtime"] = i_createtime
 			data["s_createuser"] = user["name"]
 			s_namekey := gopinyin.Convert(qu.ObjToString(data["s_name"]), false)
@@ -148,7 +148,7 @@ func (c *Client) CuserRuleCreate() {
 			} else {
 				data["entUserId"] = entUserId
 			}
-			data["appid"] = qu.ObjToString(user["app_id"])
+			data["appid"] = qu.ObjToString(user["appid"])
 			data["entId"] = qu.IntAll(user["ent_id"])
 			query := bson.M{
 				"_id": mongoutil.StringTOBsonId(id),
@@ -210,11 +210,42 @@ func (this *Client) DataPreview() {
 }
 
 func (this *Client) ExportLog() {
-	id, _ := this.GetInteger("id")
-	sql := fmt.Sprintf("select user_name,export_time,filter,export_num,deduct_num,user_id,download_url from entniche_export_log where user_id = %d", id)
-	exportLog := JyMysql.SelectBySql(sql)
-	if exportLog != nil && *exportLog != nil && len(*exportLog) > 0 {
-		this.T["exportLog"] = *exportLog
+	if this.Method() == "POST" {
+		id, _ := this.GetInteger("id")
+		start, _ := this.GetInteger("start")
+		limit, _ := this.GetInteger("length")
+		draw, _ := this.GetInteger("draw")
+		sqls := fmt.Sprintf("select count(1) from user_expend_record where user_id = %d", id)
+		count := JyMysql.CountBySql(sqls)
+		if count > 0 {
+			sql := fmt.Sprintf("select * from user_expend_record where user_id = %d order by id desc limit %d,%d", id, start, limit)
+			exportLog := JyMysql.SelectBySql(sql)
+			for _, v := range *exportLog {
+				data := JyMysql.FindOne("entniche_export_log", map[string]interface{}{"id": v["export_id"]}, "user_name,export_num,deduct_num,download_url", "")
+				if data != nil && *data != nil {
+					v["export_num"] = (*data)["export_num"]
+					v["deduct_num"] = (*data)["deduct_num"]
+					v["download_url"] = (*data)["download_url"]
+					v["user_name"] = (*data)["user_name"]
+				}
+			}
+			this.ServeJson(map[string]interface{}{
+				"draw":            draw,
+				"data":            *exportLog,
+				"recordsFiltered": count,
+				"recordsTotal":    count,
+			})
+		} else {
+			this.ServeJson(map[string]interface{}{
+				"draw":            draw,
+				"data":            nil,
+				"recordsFiltered": 0,
+				"recordsTotal":    0,
+			})
+		}
+	} else {
+		id, _ := this.GetInteger("id")
+		this.T["id"] = id
+		this.Render("client/exportLog.html", &this.T)
 	}
-	this.Render("client/exportLog.html", &this.T)
 }

+ 6 - 0
src/service/private_service.go

@@ -177,6 +177,7 @@ func (f *Private) Keydataoption(world string) {
 						v["id"] = infoid
 						v["jybxhref"] = v["s_jyhref"]
 						v["createtime"] = time.Now().Unix()
+						delete(v, "_id")
 						newIdArr = append(newIdArr, infoid)
 					}
 					infoArr = append(infoArr, v)
@@ -210,6 +211,11 @@ func (f *Private) Keydataoption(world string) {
 			log.Println("生成完成", xlsxUrl)
 			exportId := SaveExportLog2(entId, entUserId, len(infoArr), newCount, xlsxUrl, "1", filterStr)
 			DeductNum2(entId, newCount, entUserId, exportId)
+			go func() {
+				for k, _ := range infoArr {
+					MgoSave.Save(SaveUserMail, infoArr[k])
+				}
+			}()
 			res["xlsxUrl"] = xlsxUrl
 		}
 	}

+ 30 - 7
src/util/utiltag.go

@@ -73,6 +73,7 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
 	defer util.Catch()
 	ch := make(chan bool, 20)
 	wg := &sync.WaitGroup{}
+	arrsync := &sync.RWMutex{}
 	sdataid := util.ObjToString(tags["s_dataid"])
 	esquery := util.ObjToString(tags["s_esquery"])
 	clearKey := util.ObjToString(tags["s_globalclearkey"])
@@ -118,14 +119,17 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
 			go func(tmpHit *es.SearchHit) {
 				defer func() {
 					<-ch
+					arrsync.Unlock()
 					wg.Done()
 				}()
+				arrsync.Lock()
 				item := make(map[string]interface{})
 				if json.Unmarshal(*tmpHit.Source, &item) == nil {
 					item["appid"] = tags["appid"]
-					item["info_id"] = item["_id"]
+					info_id := util.ObjToString(item["_id"])
+					item["info_id"] = info_id
 					item["s_dataid"] = sdataid
-					item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", v.Id))
+					item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", info_id))
 					item["i_createtime"] = time.Now().Unix()
 					delete(item, "_id")
 					//清理词清空
@@ -198,9 +202,30 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
 					// 	ssavekeys = append(ssavekeys, k)
 					// }
 					matchKeys := GetMactchKey(maths, item)
-					if matchKeys != "" {
-						item["s_matchkey"] = matchKeys
-						// item["s_matchtype"] = strings.Join(matchType, ",")
+					if len(maths) > 0 {
+						if matchKeys != "" {
+							item["s_matchkey"] = matchKeys
+							// item["s_matchtype"] = strings.Join(matchType, ",")
+							findwinner := strings.TrimSpace(util.ObjToString(item["winner"]))
+							if findwinner != "" {
+								finddata := MgoEnps.FindOne(EnpsColl, bson.M{"company_name": findwinner})
+								if finddata != nil {
+									if legal_person := util.ObjToString(finddata["legal_person"]); legal_person != "" {
+										item["legal_person"] = legal_person
+									}
+									if email := util.ObjToString(finddata["company_email"]); email != "" {
+										item["company_email"] = email
+									}
+									if phone := util.ObjToString(finddata["company_phone"]); phone != "" {
+										item["company_phone"] = phone
+									}
+									item["qyk"] = finddata
+								}
+							}
+							datas = append(datas, item)
+							log.Println("id", item["info_id"])
+						}
+					} else {
 						findwinner := strings.TrimSpace(util.ObjToString(item["winner"]))
 						if findwinner != "" {
 							finddata := MgoEnps.FindOne(EnpsColl, bson.M{"company_name": findwinner})
@@ -219,8 +244,6 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
 						}
 						datas = append(datas, item)
 						log.Println("id", item["info_id"])
-					} else {
-						return
 					}
 				}
 			}(v)

+ 2 - 2
src/web/templates/client/cuser_rule_create.html

@@ -329,7 +329,7 @@
                                     <div class="form-group">
                                         <label class="col-sm-2 control-label">预览数据量</label>
                                         <div class="col-sm-3">
-                                            <input type="text" class="form-control" id="maxnum" placeholder="默认5000条"
+                                            <input type="text" class="form-control" id="maxnum" placeholder="默认100条"
                                                    value="">
                                         </div>
                                         <label class="col-sm-2 control-label ">高级字段包</label>
@@ -448,7 +448,7 @@
         "s_globaladdkeymatch": "",
         "s_globalnotkey": "",
         "s_globalnotkeymatch": "",
-        "i_maxnum": 1000,
+        "i_maxnum": 100,
         "i_starttime": 0,
         "i_endtime": 0,
         "i_extfieldstype": 2,

+ 19 - 7
src/web/templates/client/exportLog.html

@@ -35,6 +35,8 @@
                                             <th>导出时间</th>
                                             <th>导出条数</th>
                                             <th>新扣条数</th>
+                                            <th>导出前</th>
+                                            <th>导出后</th>
                                             <th>下载链接</th>
                                         </tr>
                                         </thead>
@@ -52,8 +54,7 @@
 {{include "com/footer.html"}}
 <script>
     // menuActive("/customer/list");
-    var exportLog = {{.T.exportLog}};
-    console.log(exportLog);
+    var ids = {{.T.id}};
     $('#back').attr("href", "javascript:history.go(-1)")
 
     $(document).ready(function () {
@@ -64,10 +65,15 @@
             "ordering": true,
             "info": true,
             "autoWidth": true,
+            "serverSide": true,
+            "ajax": {
+                "url": "/client/exportLog",
+                "type": "post",
+                "data": {"id": ids}
+            },
             "language": {
                 "url": "/dist/js/dataTables.chinese.lang"
             },
-            "data": exportLog,
             "fnDrawCallback": function () {
                 this.api().column(1).nodes().each(function (cell, i) {
                     cell.innerHTML = i + 1;
@@ -81,19 +87,25 @@
                 },
                 {"data": null, width: "5%"},
                 {
-                    "data": "user_name", width: "15%"
+                    "data": "user_name", width: "10%"
                 },
                 {
-                    "data": "export_time", width: "15%"
+                    "data": "create_at", width: "15%"
                 },
                 {
-                    "data": "export_num", width: "15%"
+                    "data": "export_num", width: "10%"
                 },
                 {
                     "data": "deduct_num", width: "15%"
                 },
                 {
-                    "data": "download_url", width: "15%", render: function (val) {
+                    "data": "before", width: "10%"
+                },
+                {
+                    "data": "after", width: "10%"
+                },
+                {
+                    "data": "download_url", width: "10%", render: function (val) {
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" href="'+ val +'" download>点击下载</a>&nbsp&nbsp'+
                         '</div>';