package services import ( "errors" "fmt" "hongze/hz_crm_api/models/company" "hongze/hz_crm_api/services/alarm_msg" "hongze/hz_crm_api/utils" ) // 处理公司归因展示 func GetCompanyAscribeContentMap(companyIds []int) (mapResp map[string]string, mapCountResp map[string]string) { var err error defer func() { if err != nil { fmt.Println("err:", err) go alarm_msg.SendAlarmMsg(" 处理公司归因展示失败 GetCompanyAscribeContent,Err:"+err.Error(), 3) } }() lenArr := len(companyIds) if lenArr == 0 { return } var condition string var pars []interface{} condition = ` AND company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)` pars = append(pars, companyIds) list, e := company.GetCompanyNoRenewedAscribeList(condition, pars, 0, 0) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCompanyNoRenewedAscribeList, Err: " + e.Error()) return } mapResp = make(map[string]string, 0) mapCountResp = make(map[string]string, 0) for _, v := range list { mapResp[fmt.Sprint("CID_", v.CompanyId, "PID_", v.ProductId)] = v.AscribeContent mapCountResp[fmt.Sprint("CID_", v.CompanyId, "PID_", v.ProductId)] = v.Content } return } // 处理公司是否添加过未续约说明展示 func GetCompanyNoRenewedNoteMap(companyIds []int) (mapResp map[string]bool) { var err error defer func() { if err != nil { fmt.Println("err:", err) go alarm_msg.SendAlarmMsg(" 处理公司是否添加过未续约说明展示失败 GetCompanyNoRenewedNoteMap,Err:"+err.Error(), 3) } }() lenArr := len(companyIds) if lenArr == 0 { return } var condition string var pars []interface{} condition = ` AND company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)` pars = append(pars, companyIds) list, e := company.GetCompanyNoRenewedNoteList(condition, pars, 0, 0) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCompanyNoRenewedNoteList, Err: " + e.Error()) return } mapResp = make(map[string]bool, 0) for _, v := range list { mapResp[fmt.Sprint("CID_", v.CompanyId, "PID_", v.ProductId)] = true } return } // 处理公司合同归因展示 func GetCompanyContractAscribeContentMap(companyContractIds []int) (mapResp map[int]string, mapCountResp map[int]string) { var err error defer func() { if err != nil { fmt.Println("err:", err) go alarm_msg.SendAlarmMsg(" 处理公司归因展示失败 GetCompanyContractAscribeContentMap,Err:"+err.Error(), 3) } }() lenArr := len(companyContractIds) if lenArr == 0 { return } var condition string var pars []interface{} condition = ` AND company_contract_id IN (` + utils.GetOrmInReplace(len(companyContractIds)) + `)` pars = append(pars, companyContractIds) list, e := company.GetCompanyContractNoRenewedAscribeList(condition, pars, 0, 0) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetCompanyNoRenewedAscribeList, Err: " + e.Error()) return } mapResp = make(map[int]string, 0) mapCountResp = make(map[int]string, 0) for _, v := range list { mapResp[v.CompanyContractId] = v.AscribeContent mapCountResp[v.CompanyContractId] = v.Content } return }