company_product.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models/company"
  6. "hongze/hz_crm_api/models/system"
  7. "hongze/hz_crm_api/services/alarm_msg"
  8. )
  9. // 根据公司ID获取权益销售名称
  10. func GetSellNameMapByCompanyIds(companyIds []int) (respMap map[int]string) {
  11. var err error
  12. defer func() {
  13. if err != nil {
  14. fmt.Println(err)
  15. go alarm_msg.SendAlarmMsg("根据公司ID获取权益销售名称,失败:"+err.Error()+fmt.Sprint(companyIds), 2)
  16. }
  17. }()
  18. lenarr := len(companyIds)
  19. if lenarr == 0 {
  20. return
  21. }
  22. var pars []interface{}
  23. var condition string
  24. respMap = make(map[int]string, 0)
  25. condition = " AND product_id = 2 "
  26. list, e := company.GetCompanyProductList(condition, pars)
  27. if e != nil {
  28. err = errors.New("GetCompanyProductList, Err: " + e.Error())
  29. return
  30. }
  31. for _, v := range list {
  32. respMap[v.CompanyId] = v.SellerName
  33. }
  34. return
  35. }
  36. // func init() {
  37. // Need960init()
  38. // }
  39. func Need960init() (respMap map[int]string) {
  40. var err error
  41. defer func() {
  42. if err != nil {
  43. fmt.Println(err)
  44. }
  45. }()
  46. var pars []interface{}
  47. var condition string
  48. respMap = make(map[int]string, 0)
  49. condition = " AND share_seller_id > 0 GROUP BY share_seller_id "
  50. list, e := company.GetCompanyProductList(condition, pars)
  51. if e != nil {
  52. err = errors.New("GetCompanyProductList, Err: " + e.Error())
  53. return
  54. }
  55. for _, v := range list {
  56. fmt.Println(v.ShareSellerId)
  57. seller, err := system.GetSysAdminById(v.ShareSellerId)
  58. if err != nil {
  59. fmt.Println(err)
  60. return
  61. }
  62. err = company.UpdateSharGroupid(seller.GroupId, v.ShareSellerId)
  63. if err != nil {
  64. fmt.Println(err)
  65. return
  66. }
  67. }
  68. return
  69. }