|
@@ -2,6 +2,7 @@ package service
|
|
|
|
|
|
import (
|
|
import (
|
|
MC "app.yhyue.com/moapp/jybase/common"
|
|
MC "app.yhyue.com/moapp/jybase/common"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
"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) {
|
|
func (p *Purchase) PurchaseListFormat(res *[]map[string]interface{}) (list []*bxcore.PurchaseList) {
|
|
for _, rv := range *res {
|
|
for _, rv := range *res {
|
|
id := MC.InterfaceToStr(rv["id"])
|
|
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{
|
|
list = append(list, &bxcore.PurchaseList{
|
|
Id: encrypt.EncodeArticleId2ByCheck(id),
|
|
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
|
|
return
|
|
@@ -362,11 +393,10 @@ func (p *Purchase) GetPurchaseData() (list []*bxcore.PurchaseList, err error) {
|
|
*res = (*res)[start:pageSize]
|
|
*res = (*res)[start:pageSize]
|
|
} else {
|
|
} else {
|
|
//实时查询
|
|
//实时查询
|
|
- //未登录查询 限制并发数
|
|
|
|
_, res, err = p.FindDataFromES()
|
|
_, res, err = p.FindDataFromES()
|
|
}
|
|
}
|
|
if len(*res) > 0 {
|
|
if len(*res) > 0 {
|
|
- p.PurchaseListFormat(res)
|
|
|
|
|
|
+ list = p.PurchaseListFormat(res)
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|