Bladeren bron

Merge branch 'master' of http://192.168.3.207:10080/group3/SwordFish_Interface_Service

fuwencai 4 jaren geleden
bovenliggende
commit
f3f02a55ba
5 gewijzigde bestanden met toevoegingen van 259 en 25 verwijderingen
  1. 64 5
      service/projectDetail.go
  2. 78 5
      service/projects.go
  3. 1 1
      static/templates/login.html
  4. 28 14
      static/templates/userRecharge.html
  5. 88 0
      sword_base/utils/stringutil.go

+ 64 - 5
service/projectDetail.go

@@ -5,6 +5,7 @@ import (
 	"sfbase/core"
 	"sfbase/utils"
 	"sfis/db"
+	"strings"
 )
 
 var SE = utils.SimpleEncrypt{Key: "topJYBX2019"}
@@ -12,7 +13,7 @@ var SE = utils.SimpleEncrypt{Key: "topJYBX2019"}
 func ProjectDetailData(id string) (data []map[string]interface{}, httpStatus int, err error) {
 	httpStatus = 200
 	_query := `{"query":{"bool":{"must":[{"term":{"id":"%s"}}],"must_not":[],"should":[]}},"_source":[%s]}`
-	fields := `"_id","s_winner","projectname","projectcode","buyer","buyertel","buyerperson","jgtime","zbtime","bidamount","budget","buyerclass","area","city","sourceinfourl"`
+	fields := `"_id","s_winner","projectname","projectcode","buyer","buyertel","buyerperson","jgtime","zbtime","bidamount","budget","buyerclass","area","city","bidstatus","package1","list"`
 	query := fmt.Sprintf(_query, id, fields)
 	INDEX := core.GetStringConf("es.project.index")
 	TYPE := core.GetStringConf("es.project.itype")
@@ -21,10 +22,68 @@ func ProjectDetailData(id string) (data []map[string]interface{}, httpStatus int
 		return nil, 200, err
 	}
 	if infos != nil && len(*infos) > 0 {
-		data = *infos
-		for _, val := range data {
-			val["project_id"] = SE.EncodeString(utils.ObjToString(val["_id"]))
-			delete(val, "_id")
+		for _, i := range *infos {
+			if i["list"] != nil {
+				bidStatusStr := "中标、成交、流标、废标、合同"
+				subStr := "中标、成交、合同"
+				subStrs := "招标、邀标、询价、竞谈、竞价、单一"
+				publish := int64(0)
+				if listArr, ok := i["list"].([]interface{}); ok {
+					if utils.ObjToString(i["bidstatus"]) == "招标" {
+						for _, v := range listArr {
+							if vs, oks := v.(map[string]interface{}); oks {
+								if strings.Contains(subStrs, utils.ObjToString(vs["subrtype"])) {
+									publishs := publish
+									publish = utils.Int64All(vs["publishtime"])
+									if publishs > publish {
+										publish = publishs
+									}
+								}
+							}
+						}
+					} else if strings.Contains(bidStatusStr, utils.ObjToString(i["bidstatus"])) {
+						for _, v := range listArr {
+							if vs, oks := v.(map[string]interface{}); oks {
+								if strings.Contains(subStr, utils.ObjToString(vs["subrtype"])) {
+									publishs := publish
+									publish = utils.Int64All(vs["publishtime"])
+									if publishs > publish {
+										publish = publishs
+									}
+								}
+							}
+						}
+					}
+					for _, v := range listArr {
+						if vs, oks := v.(map[string]interface{}); oks {
+							publishs := utils.Int64All(vs["publishtime"])
+							if publishs == publish {
+								i["url"] = vs["href"]
+								infoid := utils.ObjToString(vs["infoid"])
+								i["jyUrl"] = `https://www.jianyu360.com/article/content/` + utils.CommonEncodeArticle("content", infoid) + `.html`
+							}
+						}
+					}
+				}
+			}
+			dataMap := map[string]interface{}{
+				"projectId":   SE.EncodeString(utils.ObjToString(i["_id"])),
+				"projectName": i["projectname"],
+				"winner":      i["s_winner"],
+				"projectCode": i["projectcode"],
+				"buyer":       i["buyer"],
+				"buyerPerson": i["buyerperson"],
+				"buyerTel":    i["buyertel"],
+				"buyerClass":  i["buyerclass"],
+				"tenderDate":  i["zbtime"],
+				"bidDate":     i["jgtime"],
+				"bidAmount":   i["bidamount"],
+				"budget":      i["budget"],
+				"province":    i["area"],
+				"city":        i["city"],
+				"package":     i["package1"],
+			}
+			data = append(data, dataMap)
 		}
 	}
 	return data, httpStatus, nil

+ 78 - 5
service/projects.go

@@ -9,6 +9,7 @@ import (
 	"sfbase/utils"
 	"sfis/db"
 	"sfis/model"
+
 	"strconv"
 	"strings"
 	"time"
@@ -19,7 +20,7 @@ import (
 var (
 	pjt_count    = 100
 	pjt_field    = `"_id","jgtime","zbtime","projectname","buyer","buyerclass"`
-	pjt_fields   = `"_id","area","city","bidamount","budget","zbtime","jgtime","projectname","projectcode","s_winner","buyer","buyerclass","buyerperson","buyertel","sourceinfourl"`
+	pjt_fields   = `"_id","area","city","bidamount","budget","zbtime","jgtime","projectname","projectcode","s_winner","buyer","buyerclass","buyerperson","buyertel","package1","list","bidstatus"`
 	pjt_sort     = `{"jgtime":-1}`
 	query        = `{"query": {"bool": {"must":[%s],"should":[%s],"minimum_should_match": 1}}}`
 	query_string = `{"constant_score": {"boost": 2,"query": {"match_phrase": {"projectname.pname": {"analyzer": "my_ngram","query": "%s","slop": 6}}}}},{"multi_match": {"query": "%s","fields": ["projectname.pname"],"analyzer": "ik","minimum_should_match": "100%%"}}`
@@ -86,10 +87,82 @@ func ProjectListData(productId int, appid, projectName, winner, times string, is
 		err = errors.New("查询失败")
 		return
 	} else if repl != nil && len(*repl) > 0 {
-		data = *repl
-		for _, i := range data {
-			i["project_id"] = SE.EncodeString(utils.ObjToString(i["_id"]))
-			delete(i, "_id")
+		for _, i := range *repl {
+			if isDetail {
+				if i["list"] != nil {
+					bidStatusStr := "中标、成交、流标、废标、合同"
+					subStr := "中标、成交、合同"
+					subStrs := "招标、邀标、询价、竞谈、竞价、单一"
+					publish := int64(0)
+					if listArr, ok := i["list"].([]interface{}); ok {
+						if utils.ObjToString(i["bidstatus"]) == "招标" {
+							for _, v := range listArr {
+								if vs, oks := v.(map[string]interface{}); oks {
+									if strings.Contains(subStrs, utils.ObjToString(vs["subrtype"])) {
+										publishs := publish
+										publish = utils.Int64All(vs["publishtime"])
+										if publishs > publish {
+											publish = publishs
+										}
+									}
+								}
+							}
+						} else if strings.Contains(bidStatusStr, utils.ObjToString(i["bidstatus"])) {
+							for _, v := range listArr {
+								if vs, oks := v.(map[string]interface{}); oks {
+									if strings.Contains(subStr, utils.ObjToString(vs["subrtype"])) {
+										publishs := publish
+										publish = utils.Int64All(vs["publishtime"])
+										if publishs > publish {
+											publish = publishs
+										}
+									}
+								}
+							}
+						}
+						for _, v := range listArr {
+							if vs, oks := v.(map[string]interface{}); oks {
+								publishs := utils.Int64All(vs["publishtime"])
+								if publishs == publish {
+									i["url"] = vs["href"]
+									infoid := utils.ObjToString(vs["infoid"])
+									i["jyUrl"] = `https://www.jianyu360.com/article/content/` + utils.CommonEncodeArticle("content", infoid) + `.html`
+								}
+							}
+						}
+					}
+				}
+				dataMap := map[string]interface{}{
+					"projectId":   SE.EncodeString(utils.ObjToString(i["_id"])),
+					"projectName": i["projectname"],
+					"winner":      i["s_winner"],
+					"projectCode": i["projectcode"],
+					"buyer":       i["buyer"],
+					"buyerPerson": i["buyerperson"],
+					"buyerTel":    i["buyertel"],
+					"buyerClass":  i["buyerclass"],
+					"tenderDate":  i["zbtime"],
+					"bidDate":     i["jgtime"],
+					"bidAmount":   i["bidamount"],
+					"budget":      i["budget"],
+					"province":    i["area"],
+					"city":        i["city"],
+					"package":     i["package1"],
+					"url":         i["url"],
+					"jyUrl":       i["jyUrl"],
+				}
+				data = append(data, dataMap)
+			} else {
+				dataMap := map[string]interface{}{
+					"projectId":   SE.EncodeString(utils.ObjToString(i["_id"])),
+					"projectName": i["projectname"],
+					"buyer":       i["buyer"],
+					"buyerClass":  i["buyerclass"],
+					"tenderDate":  i["zbtime"],
+					"bidDate":     i["jgtime"],
+				}
+				data = append(data, dataMap)
+			}
 		}
 	}
 	return

+ 1 - 1
static/templates/login.html

@@ -80,7 +80,7 @@
                                 str += '<td style="width: 100px">' + item.phone + '</td>';
 
                                 str += '<td style="width: 100px">' + item.money + '</td>';
-                                str += '<td class="handle" style="width: 100px"><a href="/page/userRecharge">充值</a><a href="/page/chooseProductPage">购买产品</a><a href="/page/interfaceListPage">测试接口</a></td>';
+                                str += '<td class="handle" style="width: 100px"><a href="/page/userRecharge?id='+ item.app_id +'">充值</a><a href="/page/chooseProductPage">购买产品</a><a href="/page/interfaceListPage">测试接口</a></td>';
                                 str += '</tr>';
                             }
                             $('.box').html(str);

+ 28 - 14
static/templates/userRecharge.html

@@ -7,29 +7,31 @@
         <title>接口服务平台后台管理系统</title>
     </head>
     <style>
-      
+      .list a {
+          text-decoration: none;
+      }
     </style>
     <body>
-        <dev id="main">
-            <h1>充值接口</h1>
-            <dev>
-                <a onclick="$('#money').show();$('#main').hide();">1.余额充值</a>
-                <a onclick="$('#product').show();$('#main').hide();">2.剩余量充值</a>
-            </dev>
-        </dev>
-        <dev id="money" style="display: none;">
+        <div id="main">
+            <div class="list">
+                <h1>充值接口</h1>
+                <a href="#" onclick="$('#money').show();$('#main').hide();">1.余额充值</a><br>
+                <a href="#" onclick="$('#product').show();$('#main').hide();">2.剩余量充值</a>
+            </div>
+        </div>
+        <div id="money" style="display: none;">
             <input type="number" id="moneys" placeholder="请输入充值金额">
             <button type="button" id="moneyBtn">提交</button>
-        </dev>
-        <dev id="product" style="display: none;">
+        </div>
+        <div id="product" style="display: none;">
             <input type="number" id="productId" placeholder="请输入产品id">
             <input type="number" id="rechargeNum" placeholder="请输入充值次数">
             <input type="text" id="endTime" placeholder="请输入结束时间">
             <button type="button" id="productBtn">提交</button>
-        </dev>
-        <dev id="resultContent"></dev>
+        </div>
+        <div id="resultContent"></div>
         <script>
-            var appid = "sfGSVYRQMAAgkGBAUBJg4f";
+            var appid = getParam("id");
             function submit(param,rType,url,hearders){
                 $.ajax({
                     url: url,
@@ -66,6 +68,18 @@
                 var rType = "post";
                 submit(param,rType,url);
             })
+            
+            // 获取上个页面传来的参数
+            function getParam(name) {
+                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+                var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
+                var context = "";
+                if (r != null)
+                    context = r[2];
+                reg = null;
+                r = null;
+                return context == null || context == "" || context == "undefined" ? "" : context;
+            }
         </script>
     </body>
     </html>

+ 88 - 0
sword_base/utils/stringutil.go

@@ -8,6 +8,7 @@ import (
 	"io"
 	"math/big"
 	"math/rand"
+	"net/url"
 	"strconv"
 	"strings"
 	"time"
@@ -196,6 +197,93 @@ func ObjArrToMapArr(old []interface{}) []map[string]interface{} {
 	}
 }
 
+func Int64All(num interface{}) int64 {
+	if i, ok := num.(int64); ok {
+		return int64(i)
+	} else if i0, ok0 := num.(int32); ok0 {
+		return int64(i0)
+	} else if i1, ok1 := num.(float64); ok1 {
+		return int64(i1)
+	} else if i2, ok2 := num.(int); ok2 {
+		return int64(i2)
+	} else if i3, ok3 := num.(float32); ok3 {
+		return int64(i3)
+	} else if i4, ok4 := num.(string); ok4 {
+		i64, _ := strconv.ParseInt(i4, 10, 64)
+		//in, _ := strconv.Atoi(i4)
+		return i64
+	} else if i5, ok5 := num.(int16); ok5 {
+		return int64(i5)
+	} else if i6, ok6 := num.(int8); ok6 {
+		return int64(i6)
+	} else if i7, ok7 := num.(*big.Int); ok7 {
+		in, _ := strconv.ParseInt(fmt.Sprint(i7), 10, 64)
+		return int64(in)
+	} else if i8, ok8 := num.(*big.Float); ok8 {
+		in, _ := strconv.ParseInt(fmt.Sprint(i8), 10, 64)
+		return int64(in)
+	} else {
+		return 0
+	}
+}
+
+func Float64All(num interface{}) float64 {
+	if i, ok := num.(float64); ok {
+		return float64(i)
+	} else if i0, ok0 := num.(int32); ok0 {
+		return float64(i0)
+	} else if i1, ok1 := num.(int64); ok1 {
+		return float64(i1)
+	} else if i2, ok2 := num.(int); ok2 {
+		return float64(i2)
+	} else if i3, ok3 := num.(float32); ok3 {
+		return float64(i3)
+	} else if i4, ok4 := num.(string); ok4 {
+		in, _ := strconv.ParseFloat(i4, 64)
+		return in
+	} else if i5, ok5 := num.(int16); ok5 {
+		return float64(i5)
+	} else if i6, ok6 := num.(int8); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint8); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint16); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint32); ok6 {
+		return float64(i6)
+	} else if i6, ok6 := num.(uint64); ok6 {
+		return float64(i6)
+	} else if i7, ok7 := num.(*big.Float); ok7 {
+		in, _ := strconv.ParseFloat(fmt.Sprint(i7), 64)
+		return float64(in)
+	} else if i8, ok8 := num.(*big.Int); ok8 {
+		in, _ := strconv.ParseFloat(fmt.Sprint(i8), 64)
+		return float64(in)
+	} else {
+		return 0
+	}
+}
+
+//通用加密
+func CommonEncodeArticle(stype string, keys ...string) (id string) {
+	//正文
+	var SE = &SimpleEncrypt{Key: "topnet2015topnet2015"}
+	var SE2 = &SimpleEncrypt{Key: "2017jianyu"}
+	if stype == "content" {
+		id = BEncodeArticleId2ByCheck("A", SE, SE2, keys...)
+	}
+	return
+}
+
+//短地址加密,二次加密带校验和
+func BEncodeArticleId2ByCheck(h string, s1, s2 *SimpleEncrypt, keys ...string) string {
+	kstr := strings.Join(keys, ",")
+	kstr = s1.EncodeStringByCheck(kstr)
+	return url.QueryEscape(h + GetLetterRandom(2) + s2.EncodeStringByCheck(kstr))
+}
+
 /**
 产生一般订单编号方法
 */