company_product.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. // 更新客户是否签约状态
  37. func init12323() {
  38. list, err := company.GetTryOutCompanyOperationRecordList()
  39. if err != nil {
  40. fmt.Println(err)
  41. return
  42. }
  43. for _, v := range list {
  44. fmt.Println(v.CompanyId)
  45. err = company.UpdateCompanyProductIsSigningById(v.CompanyId, v.ProductId)
  46. }
  47. return
  48. }
  49. // func init() {
  50. // Need960init()
  51. // }
  52. func Need960init() (respMap map[int]string) {
  53. var err error
  54. defer func() {
  55. if err != nil {
  56. fmt.Println(err)
  57. }
  58. }()
  59. var pars []interface{}
  60. var condition string
  61. respMap = make(map[int]string, 0)
  62. condition = " AND share_seller_id > 0 GROUP BY share_seller_id "
  63. list, e := company.GetCompanyProductList(condition, pars)
  64. if e != nil {
  65. err = errors.New("GetCompanyProductList, Err: " + e.Error())
  66. return
  67. }
  68. for _, v := range list {
  69. fmt.Println(v.ShareSellerId)
  70. seller, err := system.GetSysAdminById(v.ShareSellerId)
  71. if err != nil {
  72. fmt.Println(err)
  73. return
  74. }
  75. err = company.UpdateSharGroupid(seller.GroupId, v.ShareSellerId)
  76. if err != nil {
  77. fmt.Println(err)
  78. return
  79. }
  80. }
  81. return
  82. }