浏览代码

wip:格式化

wangshan 9 月之前
父节点
当前提交
e3740a838d
共有 3 个文件被更改,包括 50 次插入20 次删除
  1. 2 2
      jyBXCore/api/bxcore.api
  2. 2 2
      jyBXCore/api/internal/types/types.go
  3. 46 16
      jyBXCore/rpc/service/purchase.go

+ 2 - 2
jyBXCore/api/bxcore.api

@@ -286,8 +286,8 @@ type (
 		DomainFirstType  string `json:"domainFirstType,optional"`  //领域一级分类
 		DomainSecondType string `json:"domainSecondType,optional"` //领域二级分类
 		DomainThirdType  string `json:"domainThirdType,optional"`  //领域三级分类
-		DeadlineStatus   int64  `json:"deadlineStatus"`            //报名截止状态
-		DeadlineTime     string `json:"deadlineTime"`              //报名截止时间
+		DeadlineStatus   int64  `json:"deadlineStatus,optional"`   //报名截止状态
+		DeadlineTime     string `json:"deadlineTime,optional"`     //报名截止时间
 		DeliveryArea     string `json:"deliveryArea,optional"`     //交付地点-省份
 		DeliveryCity     string `json:"deliveryCity,optional"`     //交付地点-城市
 		DeliveryDistrict string `json:"deliveryDistrict,optional"` //交付地点-县区

+ 2 - 2
jyBXCore/api/internal/types/types.go

@@ -245,8 +245,8 @@ type PurSearchReq struct {
 	DomainFirstType  string `json:"domainFirstType,optional"`  //领域一级分类
 	DomainSecondType string `json:"domainSecondType,optional"` //领域二级分类
 	DomainThirdType  string `json:"domainThirdType,optional"`  //领域三级分类
-	DeadlineStatus   int64  `json:"deadlineStatus"`            //报名截止状态
-	DeadlineTime     string `json:"deadlineTime"`              //报名截止时间
+	DeadlineStatus   int64  `json:"deadlineStatus,optional"`   //报名截止状态
+	DeadlineTime     string `json:"deadlineTime,optional"`     //报名截止时间
 	DeliveryArea     string `json:"deliveryArea,optional"`     //交付地点-省份
 	DeliveryCity     string `json:"deliveryCity,optional"`     //交付地点-城市
 	DeliveryDistrict string `json:"deliveryDistrict,optional"` //交付地点-县区

+ 46 - 16
jyBXCore/rpc/service/purchase.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	MC "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/encrypt"
 	elastic "app.yhyue.com/moapp/jybase/es"
 	"app.yhyue.com/moapp/jybase/redis"
@@ -105,26 +106,56 @@ func NewPurchase(in *bxcore.PurchaseReq) *Purchase {
 	}
 }
 
+var (
+	AreaLabelLink = "/list/%s/%s.html"
+)
+
 // 格式化
 func (p *Purchase) PurchaseListFormat(res *[]map[string]interface{}) (list []*bxcore.PurchaseList) {
 	for _, rv := range *res {
 		id := MC.InterfaceToStr(rv["id"])
+		area := MC.InterfaceToStr(rv["area"])
+		city := MC.InterfaceToStr(rv["city"])
+		district := MC.InterfaceToStr(rv["district"])
+		regionUrl := ""
+		if district != "" && IC.DistrictMap[district] != "" {
+			regionUrl = fmt.Sprintf(AreaLabelLink, "city", IC.DistrictMap[district])
+		} else if city != "" && IC.CityMap[city] != "" {
+			regionUrl = fmt.Sprintf(AreaLabelLink, "city", IC.CityMap[city])
+		} else if area != "" && IC.AreaMap[area] != "" {
+			regionUrl = fmt.Sprintf(AreaLabelLink, "area", IC.AreaMap[area])
+		}
+		var price int64
+		if budget, ok := rv["budget"].(float64); ok && budget > 0 { //预算
+			price = int64(budget)
+		}
+		if bidAmount, ok := rv["bidamount"].(float64); ok && bidAmount > 0 { //中标金额
+			price = int64(bidAmount)
+		}
+		signEndTime := "" //报名截止时间
+		if set := MC.Int64All(rv["signendtime"]); set > 0 {
+			signEndTime = date.FormatDateByInt64(&set, "2006-01-02 15:04")
+		}
+		//deliver_area  交付省份
+		//deliver_city  交付城市
+		//deliver_district  交付区县
+		deliveryLoc := fmt.Sprintf("%s-%s-%s", MC.InterfaceToStr(rv["deliver_area"]), MC.InterfaceToStr(rv["deliver_city"]), MC.InterfaceToStr(rv["deliver_district"]))
 		list = append(list, &bxcore.PurchaseList{
 			Id:           encrypt.EncodeArticleId2ByCheck(id),
-			Area:         "",
-			City:         "",
-			District:     "",
-			RegionUrl:    "",
-			BuyerClass:   "",
-			PublishTime:  0,
-			FileExists:   false,
-			Title:        "",
-			Price:        0,
-			Buyer:        "",
-			BuyerTel:     "",
-			DeadlineTime: "",
-			DeliveryLoc:  "",
-			Industry:     "",
+			Area:         MC.InterfaceToStr(rv["area"]),
+			City:         MC.InterfaceToStr(rv["city"]),
+			District:     MC.InterfaceToStr(rv["district"]),
+			RegionUrl:    regionUrl,
+			BuyerClass:   MC.InterfaceToStr(rv["buyerclass"]),
+			PublishTime:  MC.Int64All(rv["publishtime"]),
+			FileExists:   rv["isValidFile"].(bool),
+			Title:        MC.InterfaceToStr(rv["title"]),
+			Price:        price,
+			Buyer:        MC.InterfaceToStr(rv["buyer"]),
+			BuyerTel:     MC.InterfaceToStr(rv["buyertel"]),
+			DeadlineTime: signEndTime,
+			DeliveryLoc:  deliveryLoc,
+			Industry:     util.IndustryFormat(p.Industry, strings.Trim(MC.ObjToString(rv["s_subscopeclass"]), ",")),
 		})
 	}
 	return
@@ -362,11 +393,10 @@ func (p *Purchase) GetPurchaseData() (list []*bxcore.PurchaseList, err error) {
 		*res = (*res)[start:pageSize]
 	} else {
 		//实时查询
-		//未登录查询 限制并发数
 		_, res, err = p.FindDataFromES()
 	}
 	if len(*res) > 0 {
-		p.PurchaseListFormat(res)
+		list = p.PurchaseListFormat(res)
 	}
 	return
 }