123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- package overseas_custom
- import (
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "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
- }
- // @Title 获取海外客户列表数据
- // @Description 获取海外客户列表数据
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param Keywords query string false "关键词:客户名称/社会信用码/联系人手机号/邮箱"
- // @Param CompanyStatus query string false "状态:全部,正式,试用,关闭"
- // @Param SellerId query int false "销售ID"
- // @Param CustomType query int false "1:海外客户,2:隐藏客户"
- // @Param SortField query string false "排序字段:ViewTotal,RoadShowTotal,CreateTime"
- // @Param SortDesc query int false "1:降序,默认,2:升序"
- // @Success 200 {object} models.EnglishCompanyPageListResp
- // @router /custom/list [get]
- func (this *OverseasCustomController) CustomList() {
- 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
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- keywords := this.GetString("Keywords", "")
- sellerId, _ := this.GetInt("SellerId", 0)
- companyStatus := this.GetString("CompanyStatus")
- sortField := this.GetString("SortField")
- sortDesc, _ := this.GetInt("SortDesc")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- obj := new(overseas_custom.Custom)
- var condition 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...)
- condition += fmt.Sprintf(` AND c.company_id IN (%s) `, utils.GetOrmInReplace(len(companyIds)))
- pars = append(pars, companyIds)
- }
- if sellerId > 0 {
- condition = ` AND m.seller_id=? `
- pars = append(pars, sellerId)
- }
- total, err := obj.GetCustomListCount(condition, pars, companyStatus)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据总数失败, Err: " + err.Error()
- return
- }
- list, err := obj.GetCustomList(condition, pars, companyStatus, sortField, startSize, pageSize, sortDesc)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败, Err: " + err.Error()
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(overseas_custom.CustomListResp)
- resp.Paging = page
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|