scorebudget.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package main
  2. import (
  3. "fmt"
  4. "go.mongodb.org/mongo-driver/bson/primitive"
  5. qu "qfw/util"
  6. )
  7. func budgetFieldScore(tmp map[string]interface{},score int64) (map[string]interface{}) {
  8. budget := qu.Float64All(tmp["budget"])
  9. bidamount := qu.Float64All(tmp["bidamount"])
  10. reason,desc:=fmt.Sprintf("%d初始分",score),""
  11. /*错误项*/
  12. if (budget<10.0||budget>20000000000.0) {
  13. return map[string]interface{}{
  14. "score":int64(0),
  15. "reason":"错误:大小",
  16. }
  17. }
  18. /*减分项
  19. "行业范围": 1,
  20. "间隔异常": 2
  21. */
  22. if bidamount > 0.0 && budget >0.0 {
  23. proportion := bidamount/budget
  24. if (proportion>=0.1&&proportion<=0.3)||(proportion>=3&&proportion<=5){
  25. desc = "间隔异常"
  26. reason+="~"+desc
  27. score -= qu.Int64All(budget_score[desc])
  28. }
  29. if proportion>=0.001&&proportion<0.1{
  30. return map[string]interface{}{
  31. "score":int64(0),
  32. "reason":"错误:比例",
  33. }
  34. }
  35. }
  36. class := make(map[string]interface{},0)
  37. if topscopeclass, ok := tmp["topscopeclass"].(primitive.A); budget>0.0&&ok&&len(topscopeclass)>0 {
  38. for _,v := range topscopeclass{
  39. value := qu.ObjToString(v)
  40. new_value := value[:len(value)-1]
  41. if class[new_value]==nil {//校验行业
  42. if !checkingClassMoney(budget,new_value) {
  43. desc = "行业范围"
  44. reason+="~"+desc
  45. score -= qu.Int64All(budget_score[desc])
  46. }
  47. class[new_value]=1
  48. }
  49. }
  50. }
  51. return map[string]interface{}{
  52. "score":score,
  53. "reason":reason,
  54. }
  55. }