scorebudget.go 1.7 KB

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