Browse Source

Merge branch 'crm/crm_15.4' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

xingzai 11 months ago
parent
commit
bd067a0b49
3 changed files with 304 additions and 0 deletions
  1. 182 0
      controllers/cygx/enter_score.go
  2. 95 0
      models/cygx/enter_score.go
  3. 27 0
      routers/commentsRouter.go

+ 182 - 0
controllers/cygx/enter_score.go

@@ -2,6 +2,7 @@ package cygx
 
 import (
 	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hz_crm_api/controllers"
 	"hongze/hz_crm_api/models"
 	"hongze/hz_crm_api/models/company"
@@ -17,6 +18,58 @@ type EnterScoreController struct {
 	controllers.BaseAuthController
 }
 
+// @Title X试用类客户检索
+// @Description X试用类客户检索接口
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} company.CompanyNameAndIdListResp
+// @router /enterScore/company/searchlist [get]
+func (this *EnterScoreController) CompanySearchList() {
+	br := new(models.BaseResponse).Init()
+	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
+	}
+	keyWord := this.GetString("KeyWord")
+	keyWord = strings.Trim(keyWord, " ")
+	keyWord = strings.Replace(keyWord, "'", "", -1)
+
+	resp := new(company.CompanyNameAndIdListResp)
+	var companyCondition string
+	var companypars []interface{}
+	var listResp []*company.CompanyNameAndId
+	companyCondition += ` AND b.product_name = ? `
+	companypars = append(companypars, "权益")
+	companyCondition += ` AND b.status = ? `
+	companypars = append(companypars, "永续")
+
+	if keyWord != "" {
+		companyCondition += ` AND a.company_name LIKE '%` + keyWord + `%' `
+	}
+	companyList, err := company.GetCompanyIdListByproductName(companyCondition, companypars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if len(companyList) == 0 {
+		listResp = make([]*company.CompanyNameAndId, 0)
+	} else {
+		listResp = companyList
+	}
+	resp.List = listResp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
 // @Title  详情
 // @Description 获取详情接口
 // @Param   EnterScoreId   query   int  true       "录分ID"
@@ -393,3 +446,132 @@ func (this *EnterScoreController) EnterScoreUpdate() {
 	br.IsAddLog = true
 	br.Msg = "操作成功"
 }
+
+// @Title 列表
+// @Description 列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   AdminId   query   string  true       "销售id,多个用英文逗号隔开,空字符串为全部"
+// @Success 200 {object} cygx.GetCygxEnterScoreListRep
+// @router /enterScore/list [get]
+func (this *EnterScoreController) EnterScoreList() {
+	br := new(models.BaseResponse).Init()
+	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")
+	keyWord := this.GetString("KeyWord")
+	adminId := this.GetString("AdminId")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	if keyWord != "" {
+		condition += ` AND company_name LIKE '%` + keyWord + `%' `
+	}
+	if adminId != "" {
+		condition += ` AND seller_id IN (` + adminId + `) `
+	}
+	total, err := cygx.GetCygxEnterScoreCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	list, err := cygx.GetCygxEnterScoreList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	resp := new(cygx.GetCygxEnterScoreListRep)
+	if len(list) == 0 {
+		resp.List = make([]*cygx.EnterScoreListResp, 0)
+	} else {
+		for _, v := range list {
+			item := new(cygx.EnterScoreListResp)
+			item.EnterScoreId = v.EnterScoreId
+			item.CompanyId = v.CompanyId
+			item.CompanyName = v.CompanyName
+			item.Quarter = strings.Split(v.Quarter, ",")
+			item.EnterScoreType = v.EnterScoreType
+			item.Ranking = v.Ranking
+			item.IsMergeScoring = v.IsMergeScoring
+			item.SecuritiesFirmsName = v.SecuritiesFirmsName
+			item.ProportionTotal = v.ProportionTotal
+			item.EnterScoreId = v.EnterScoreId
+			item.SellerId = v.SellerId
+			item.SellerName = v.SellerName
+			item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
+			item.ModifyTime = v.ModifyTime.Format(utils.FormatDateTime)
+			resp.List = append(resp.List, item)
+		}
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 更新录分
+// @Description 更新录分接口
+// @Param	request	body cygx.UpdateEnterScoreReq true "type json string"
+// @Success 200 {object} "保存成功"
+// @router /enterScore/delete [post]
+func (this *EnterScoreController) EnterScoreDelete() {
+	br := new(models.BaseResponse).Init()
+	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 cygx.EnterScoreIdReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	enterScoreId := req.EnterScoreId
+	if enterScoreId == 0 {
+		br.Msg = "参数错误!"
+		br.ErrMsg = "参数错误,EnterScoreId 不能为0"
+		return
+	}
+	err = cygx.DeleteEnterScore(enterScoreId)
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "操作失败Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.IsAddLog = true
+	br.Msg = "删除成功"
+}

+ 95 - 0
models/cygx/enter_score.go

@@ -2,6 +2,7 @@ package cygx
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -97,6 +98,10 @@ type UpdateEnterScoreReq struct {
 	ListGroup           []*EnterScoreGroupListResp      //其他配置信息
 }
 
+type EnterScoreIdReq struct {
+	EnterScoreId int `comment:"录分ID"`
+}
+
 // CygxEnterScoreGroup 结构体代表 cygx_enter_score_group 表
 type CygxEnterScoreGroup struct {
 	EnterScoreGroupId int       `orm:"column(enter_score_group_id);pk";comment:"主键"`
@@ -294,3 +299,93 @@ func GeCygxEnterScoreGroupListById(enterScoreId int) (items []*CygxEnterScoreGro
 	_, err = o.Raw(sql, enterScoreId).QueryRows(&items)
 	return
 }
+
+// 获取列表
+func GetCygxEnterScoreList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxEnterScore, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_enter_score  WHERE 1 = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+// 获取数量
+func GetCygxEnterScoreCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_enter_score  WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+type EnterScoreListResp struct {
+	EnterScoreId        int      `comment:"录分ID"`
+	CompanyId           int      `comment:"公司ID,公司标识符"`
+	CompanyName         string   `comment:"公司名称"`
+	Quarter             []string `comment:"季度,评分季度"`
+	EnterScoreType      int      `comment:"录入方式 1:按评分录入、2:按比例录入"`
+	Ranking             string   `comment:"排名"`
+	IsMergeScoring      int      `comment:"是否合并打分"`
+	SecuritiesFirmsName string   `comment:"券商名称"`
+	ProportionTotal     float64  `comment:"合计总占比"`
+	SellerId            int      `comment:"所属销售id"`
+	SellerName          string   `comment:"所属销售名称"`
+	CreateTime          string   `comment:"创建时间"`
+	ModifyTime          string   `comment:"更新时间"`
+}
+
+type GetCygxEnterScoreListRep struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*EnterScoreListResp
+}
+
+// 删除
+func DeleteEnterScore(enterScoreId int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+
+	//删除单条录分信息
+	sql := `DELETE FROM cygx_enter_score WHERE enter_score_id = ?`
+	_, err = to.Raw(sql, enterScoreId).Exec()
+	if err != nil {
+		return
+	}
+
+	//批量删除行业信息
+	sql = `DELETE FROM cygx_enter_score_permission WHERE enter_score_id = ?`
+	_, err = to.Raw(sql, enterScoreId).Exec()
+	if err != nil {
+		return
+	}
+
+	//批量删除研究员信息
+	sql = `	DELETE FROM cygx_enter_score_researcher WHERE enter_score_id = ?`
+	_, err = to.Raw(sql, enterScoreId).Exec()
+	if err != nil {
+		return
+	}
+
+	//批量删除自定义分组信息
+	sql = `	DELETE FROM cygx_enter_score_group WHERE enter_score_id = ?`
+	_, err = to.Raw(sql, enterScoreId).Exec()
+	if err != nil {
+		return
+	}
+
+	return
+}

+ 27 - 0
routers/commentsRouter.go

@@ -1456,6 +1456,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"],
+        beego.ControllerComments{
+            Method: "CompanySearchList",
+            Router: `/enterScore/company/searchlist`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"],
+        beego.ControllerComments{
+            Method: "EnterScoreDelete",
+            Router: `/enterScore/delete`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"],
         beego.ControllerComments{
             Method: "EnterScoreDetail",
@@ -1465,6 +1483,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"],
+        beego.ControllerComments{
+            Method: "EnterScoreList",
+            Router: `/enterScore/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:EnterScoreController"],
         beego.ControllerComments{
             Method: "EnterScoreUpdate",