package overseas_custom import ( "fmt" "hongze/hz_crm_api/models" "hongze/hz_crm_api/models/overseas_custom" "hongze/hz_crm_api/utils" ) // @Title 海外客户统计数据 // @Description 海外客户统计数据 // @Param Keywords query string false "关键词:客户名称/社会信用码/联系人手机号/邮箱" // @Param SellerId query int false "销售ID" // @Success 200 {object} models.EnglishCompanyPageListResp // @router /custom/statistics [get] func (this *OverseasCustomController) CustomStatistics() { br := new(models.BaseResponse).Init() br.IsSendEmail = false defer func() { this.Data["json"] = br this.ServeJSON() }() sysUser := this.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } keywords := this.GetString("Keywords", "") sellerId, _ := this.GetInt("SellerId", 0) obj := new(overseas_custom.Custom) var cond string var pars []interface{} if keywords != "" { k := "%" + keywords + "%" enCompanyIds, e := models.GetEnCompanyIdsByKeyword(k) if e != nil { br.Msg = "获取失败" br.ErrMsg = "关键词获取英文客户IDs失败, Err: " + e.Error() return } //获取中文客户 companyIds, err := obj.GetCompanyIdsByKeyword(k) if err != nil { br.Msg = "获取失败" br.ErrMsg = "关键词获取客户IDs失败, Err: " + err.Error() return } companyIds = append(companyIds, enCompanyIds...) cond += fmt.Sprintf(` AND c.company_id IN (%s) `, utils.GetOrmInReplace(len(companyIds))) pars = append(pars, companyIds) } if sellerId > 0 { cond = ` AND m.seller_id=? ` pars = append(pars, sellerId) } list, err := obj.GetCustomTotal(cond, pars) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取各状态总数失败, Err: " + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = list }