1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package main
- import (
- "fmt"
- "go.mongodb.org/mongo-driver/bson/primitive"
- qu "qfw/util"
- )
- func bidamountFieldScore(tmp map[string]interface{},score int64) (map[string]interface{}) {
- bidamount := qu.Float64All(tmp["bidamount"])
- budget := qu.Float64All(tmp["budget"])
- reason,desc:=fmt.Sprintf("%d初始分",score),""
- /*错误项*/
- if (bidamount < 10.0 || bidamount > 20000000000.0 ) {
- return map[string]interface{}{
- "score":int64(0),
- "reason":"错误:大小",
- }
- }
- /*减分项
- "行业范围": 1,
- "间隔异常": 2
- */
- if budget > 0.0 {
- proportion := bidamount/budget
- if (proportion>=0.1&&proportion<=0.3)||(proportion>=3&&proportion<=5){
- desc = "间隔异常"
- reason+="~"+desc
- score -= qu.Int64All(bidamount_score[desc])
- }
- if proportion>=0.001&&proportion<0.1{
- return map[string]interface{}{
- "score":int64(0),
- "reason":"错误:比例",
- }
- }
- }
- class := make(map[string]interface{},0)
- if topscopeclass, ok := tmp["topscopeclass"].(primitive.A); ok&&len(topscopeclass)>0 {
- for _,v := range topscopeclass{
- value := qu.ObjToString(v)
- new_value := value[:len(value)-1]
- if class[new_value]==nil {//校验行业
- if !checkingClassMoney(bidamount,new_value) {
- desc = "行业范围"
- reason+="~"+desc
- score -= qu.Int64All(bidamount_score[desc])
- }
- class[new_value]=1
- }
- }
- }
- return map[string]interface{}{
- "score":score,
- "reason":reason,
- }
- }
|