|
@@ -11,74 +11,6 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-// @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 "每页数据条数"
|
|
@@ -148,7 +80,7 @@ func (this *OverseasCustomController) CustomList() {
|
|
|
|
|
|
companyIds = append(companyIds, enCompanyIds...)
|
|
|
|
|
|
- condition += fmt.Sprintf(` AND c.company_id IN (%s) `, utils.GetOrmInReplace(len(companyIds)))
|
|
|
+ condition += fmt.Sprintf(` AND m.company_id IN (%s) `, utils.GetOrmInReplace(len(companyIds)))
|
|
|
pars = append(pars, companyIds)
|
|
|
}
|
|
|
if sellerId > 0 {
|
|
@@ -169,11 +101,26 @@ func (this *OverseasCustomController) CustomList() {
|
|
|
br.ErrMsg = "获取数据失败, Err: " + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ for _, v := range list {
|
|
|
+ if v.Source == 1 && v.OverseasStatus != "" {
|
|
|
+ v.CompanyStatus = v.OverseasStatus
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ StatisticsDataList, err := obj.GetCustomTotal(condition, pars)
|
|
|
+ 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
|
|
|
+ resp.StatisticsData = StatisticsDataList
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|
|
@@ -256,3 +203,80 @@ func (this *OverseasCustomController) CustomHide() {
|
|
|
br.Success = true
|
|
|
br.Msg = "隐藏成功"
|
|
|
}
|
|
|
+
|
|
|
+// @Title 客户状态设置
|
|
|
+// @Description 客户状态设置
|
|
|
+// @Param request body overseas_custom.CustomHideReq true "type json string"
|
|
|
+// @Success 200 string "操作成功"
|
|
|
+// @router /custom/status_set [post]
|
|
|
+func (this *OverseasCustomController) CustomStatusSet() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ var req overseas_custom.CustomHideReq
|
|
|
+ if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.CompanyId <= 0 {
|
|
|
+ br.Msg = "参数错误!"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ obj := new(overseas_custom.Custom)
|
|
|
+ item, err := obj.GetCustomByCompanyId(req.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "隐藏失败!"
|
|
|
+ br.ErrMsg = "隐藏失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //是否隐藏:0:不隐藏,1:隐藏
|
|
|
+ var overseasStatus string
|
|
|
+ if item.OverseasStatus == "" {
|
|
|
+ overseasStatus = "正式"
|
|
|
+ } else {
|
|
|
+ overseasStatus = ""
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.CompanyId > 1000000 {
|
|
|
+ enCompanyObj := new(models.EnglishCompany)
|
|
|
+ // 更新客户
|
|
|
+ nowTime := time.Now().Local()
|
|
|
+ enCompanyObj.CompanyId = req.CompanyId - utils.EnCompanyIdStep
|
|
|
+ enCompanyObj.OverseasStatus = overseasStatus
|
|
|
+ enCompanyObj.ModifyTime = nowTime
|
|
|
+ updateCols := []string{"OverseasStatus", "ModifyTime"}
|
|
|
+ if err = enCompanyObj.Update(updateCols); err != nil {
|
|
|
+ br.Msg = "隐藏失败"
|
|
|
+ br.ErrMsg = "更新英文客户转正式状态失败, Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ companyObj := new(company.Company)
|
|
|
+ companyObj.CompanyId = req.CompanyId
|
|
|
+ companyObj.OverseasStatus = overseasStatus
|
|
|
+ updateCols := []string{"OverseasStatus"}
|
|
|
+ err = companyObj.Update(updateCols)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "隐藏失败"
|
|
|
+ br.ErrMsg = "更新客户转正式状态失败, Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+}
|