xingzai 1 anno fa
parent
commit
0dac8177b5
4 ha cambiato i file con 325 aggiunte e 17 eliminazioni
  1. 179 1
      controllers/cygx/enter_score.go
  2. 133 16
      models/cygx/enter_score.go
  3. 4 0
      models/db.go
  4. 9 0
      routers/commentsRouter.go

+ 179 - 1
controllers/cygx/enter_score.go

@@ -1,11 +1,15 @@
 package cygx
 
 import (
+	"encoding/json"
 	"hongze/hz_crm_api/controllers"
 	"hongze/hz_crm_api/models"
+	"hongze/hz_crm_api/models/company"
 	"hongze/hz_crm_api/models/cygx"
 	"hongze/hz_crm_api/models/system"
 	"hongze/hz_crm_api/utils"
+	"strings"
+	"time"
 )
 
 // X类客户录分模块
@@ -98,7 +102,7 @@ func (this *EnterScoreController) CompanyContracDetail() {
 		item.GroupName = v
 		itemsGroup = append(itemsGroup, item)
 	}
-	resp.EnterScoreObj.ListProup = itemsGroup
+	resp.EnterScoreObj.ListGroup = itemsGroup
 	resp.PercentageObj = resp.EnterScoreObj
 	resp.EnterScoreType = 1
 	resp.Quarter = make([]string, 0)
@@ -107,3 +111,177 @@ func (this *EnterScoreController) CompanyContracDetail() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 更新派点
+// @Description 更新派点接口
+// @Param	request	body cygx.AddProductInteriorReq true "type json string"
+// @Success 200 {object} "保存成功"
+// @router /enterScore/update [post]
+func (this *EnterScoreController) EnterScoreUpdate() {
+	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.UpdateEnterScoreReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	enterScoreId := req.EnterScoreId
+	companyId := req.CompanyId
+	if companyId == 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,companyId不可为空"
+		return
+	}
+
+	//EnterScoreId        int       `orm:"column(enter_score_id);pk";comment:"主键"`
+	//CompanyId           int       `comment:"公司ID"`
+	//CompanyName         string    `comment:"客户名称"`
+	//StartDate           time.Time `comment:"开始日期"`
+	//EndDate             time.Time `comment:"结束日期"`
+	//Quarter             string    `comment:"季度"`
+	//EnterScoreType      int       `comment:"录入方式 1:按评分录入、2:按比例录入"`
+	//TotalScore          string    `comment:"总分"`
+	//Ranking             string    `comment:"排名"`
+	//IsMergeScoring      int       `comment:"是否合并打分"`
+	//SecuritiesFirmsName string    `comment:"券商名称"`
+	//MergeProportion     float64   `comment:"合并占比"`
+	//RaiProportionTotal  float64   `comment:"权益研究员占比"`
+	//FiccProportionTotal float64   `comment:"FICC研究员占比"`
+	//ProportionTotal     float64   `comment:"合计总占比"`
+	//SellerId            int       `comment:"所属销售id"`
+	//SellerName          string    `comment:"所属销售名称"`
+	//AdminId             int       `comment:"操作人ID"`
+	//AdminName           string    `comment:"操作人姓名"`
+	//CreateTime          time.Time `comment:"创建时间"`
+	//ModifyTime          time.Time `comment:"更新时间"`
+
+	companyProduct, err := company.GetCompanyProductByCompanyIdAndProductId(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if err != nil {
+		br.Msg = "查询客户产品信息失败"
+		br.ErrMsg = "查询客户产品信息失败,Err:" + err.Error()
+		return
+	}
+
+	item := new(cygx.CygxEnterScore)
+	item.EnterScoreId = enterScoreId
+	item.CompanyId = companyId
+	item.CompanyName = req.CompanyName
+	item.StartDate = req.StartDate
+	item.EndDate = req.EndDate
+	item.Quarter = strings.Join(req.Quarter, ",")
+	item.EnterScoreType = req.EnterScoreType
+	item.Ranking = req.Ranking
+	item.IsMergeScoring = req.IsMergeScoring
+	item.SecuritiesFirmsName = req.SecuritiesFirmsName
+	item.MergeProportion = req.MergeProportion
+	item.RaiProportionTotal = req.RaiProportionTotal
+	item.FiccProportionTotal = req.FiccProportionTotal
+	item.ProportionTotal = req.ProportionTotal
+	item.SellerId = companyProduct.SellerId
+	item.SellerName = companyProduct.SellerName
+	item.AdminId = sysUser.AdminId
+	item.AdminName = sysUser.RealName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+
+	var itemsPermission []*cygx.CygxEnterScorePermission //行业数组
+	var itemsResearcher []*cygx.CygxEnterScoreResearcher //研究员数组
+	var itemsGroup []*cygx.CygxEnterScoreGroup           //自定义分组
+	listRai := req.ListRai
+	listFicc := req.ListFicc
+	listGroup := req.ListGroup
+
+	for _, v := range listRai { // 权益数据
+		itemPermission := new(cygx.CygxEnterScorePermission)
+		itemPermission.ChartPermissionName = v.ChartPermissionName
+		itemPermission.Proportion = v.Proportion
+		itemPermission.EnterScoreId = v.EnterScoreId
+		itemPermission.AdminId = sysUser.AdminId
+		itemPermission.AdminName = sysUser.RealName
+		itemPermission.ProductId = utils.COMPANY_PRODUCT_RAI_ID
+		itemPermission.CreateTime = time.Now()
+		itemPermission.ModifyTime = time.Now()
+		itemsPermission = append(itemsPermission, itemPermission)
+		for _, vResearcher := range v.List {
+			itemResearcher := new(cygx.CygxEnterScoreResearcher)
+			itemResearcher.ChartPermissionName = v.ChartPermissionName
+			itemResearcher.EnterScoreId = v.EnterScoreId
+			itemResearcher.RealName = vResearcher.RealName
+			itemResearcher.Proportion = vResearcher.Proportion
+			itemResearcher.AdminId = sysUser.AdminId
+			itemResearcher.AdminName = sysUser.RealName
+			itemResearcher.ProductId = utils.COMPANY_PRODUCT_RAI_ID
+			itemResearcher.CreateTime = time.Now()
+			itemResearcher.ModifyTime = time.Now()
+			itemsResearcher = append(itemsResearcher, itemResearcher)
+		}
+	}
+
+	for _, v := range listFicc { // FICC数据
+		itemPermission := new(cygx.CygxEnterScorePermission)
+		itemPermission.ChartPermissionName = v.ChartPermissionName
+		itemPermission.Proportion = v.Proportion
+		itemPermission.EnterScoreId = v.EnterScoreId
+		itemPermission.AdminId = sysUser.AdminId
+		itemPermission.AdminName = sysUser.RealName
+		itemPermission.ProductId = utils.COMPANY_PRODUCT_FICC_ID
+		itemPermission.CreateTime = time.Now()
+		itemPermission.ModifyTime = time.Now()
+		itemsPermission = append(itemsPermission, itemPermission)
+		for _, vResearcher := range v.List {
+			itemResearcher := new(cygx.CygxEnterScoreResearcher)
+			itemResearcher.ChartPermissionName = v.ChartPermissionName
+			itemResearcher.EnterScoreId = v.EnterScoreId
+			itemResearcher.RealName = vResearcher.RealName
+			itemResearcher.Proportion = vResearcher.Proportion
+			itemResearcher.AdminId = sysUser.AdminId
+			itemResearcher.AdminName = sysUser.RealName
+			itemResearcher.ProductId = utils.COMPANY_PRODUCT_FICC_ID
+			itemResearcher.CreateTime = time.Now()
+			itemResearcher.ModifyTime = time.Now()
+			itemsResearcher = append(itemsResearcher, itemResearcher)
+		}
+	}
+
+	for _, v := range listGroup {
+		itemGroup := new(cygx.CygxEnterScoreGroup)
+		itemGroup.GroupName = v.GroupName
+		itemGroup.Proportion = v.Proportion
+		itemGroup.AdminId = sysUser.AdminId
+		itemGroup.AdminName = sysUser.RealName
+		itemGroup.CreateTime = time.Now()
+		itemGroup.ModifyTime = time.Now()
+		itemsGroup = append(itemsGroup, itemGroup)
+	}
+	//fmt.Println("itemsPermission", len(itemsPermission))
+	//fmt.Println("itemsResearcher", len(itemsResearcher))
+	//fmt.Println("itemsGroup", len(itemsGroup))
+
+	if enterScoreId == 0 { // 新增
+		err = cygx.AddCygxEnterScore(item, itemsPermission, itemsResearcher, itemsGroup)
+	} else { // 修改
+
+	}
+
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.IsAddLog = true
+	br.Msg = "操作成功"
+}

+ 133 - 16
models/cygx/enter_score.go

@@ -1,30 +1,34 @@
 package cygx
 
-import "time"
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
 
 // CygxEnterScore 结构体代表了 cygx_enter_score 表格
 type CygxEnterScore struct {
-	EnterScoreID        int       `comment:"主键"`
-	EnterScoreType      int       `comment:"录入方式 1:按评分录入、2:按比例录入"`
-	CompanyID           int       `comment:"公司ID"`
-	CreateTime          time.Time `comment:"创建时间"`
-	ModifyTime          time.Time `comment:"更新时间"`
-	AdminID             int       `comment:"操作人ID"`
-	AdminName           string    `comment:"操作人姓名"`
-	Proportion          float64   `comment:"占比"`
-	ChartPermissionName string    `comment:"名称"`
-	SellerID            int       `comment:"所属销售id"`
-	SellerName          string    `comment:"所属销售名称"`
+	EnterScoreId        int       `orm:"column(enter_score_id);pk";comment:"主键"`
+	CompanyId           int       `comment:"公司ID"`
 	CompanyName         string    `comment:"客户名称"`
-	StartDate           time.Time `comment:"开始日期"`
-	EndDate             time.Time `comment:"结束日期"`
+	StartDate           string    `comment:"开始日期"`
+	EndDate             string    `comment:"结束日期"`
 	Quarter             string    `comment:"季度"`
-	TotalScore          string    `comment:"总分"`
+	EnterScoreType      int       `comment:"录入方式 1:按评分录入、2:按比例录入"`
 	Ranking             string    `comment:"排名"`
 	IsMergeScoring      int       `comment:"是否合并打分"`
 	SecuritiesFirmsName string    `comment:"券商名称"`
 	MergeProportion     float64   `comment:"合并占比"`
+	RaiProportionTotal  float64   `comment:"权益研究员占比"`
+	FiccProportionTotal float64   `comment:"FICC研究员占比"`
+	ProportionTotal     float64   `comment:"合计总占比"`
+	SellerId            int       `comment:"所属销售id"`
+	SellerName          string    `comment:"所属销售名称"`
+	AdminId             int       `comment:"操作人ID"`
+	AdminName           string    `comment:"操作人姓名"`
+	CreateTime          time.Time `comment:"创建时间"`
+	ModifyTime          time.Time `comment:"更新时间"`
 }
+
 type CygxEnterScoreDetailResp struct {
 	EnterScoreId        int               `comment:"录分ID"`
 	CompanyId           int               `comment:"公司ID,公司标识符"`
@@ -41,7 +45,7 @@ type CygxEnterScoreDetailResp struct {
 type EnterScoreDateObj struct {
 	ListRai   []*EnterScorePermissionListResp //权益列表
 	ListFicc  []*EnterScorePermissionListResp //FICC列表
-	ListProup []*EnterScoreGroupListResp      //其他配置信息
+	ListGroup []*EnterScoreGroupListResp      //其他配置信息
 }
 
 // 行业
@@ -64,3 +68,116 @@ type EnterScoreGroupListResp struct {
 	GroupName  string  `description:"研究员姓名"`
 	Proportion float64 `description:"占比"`
 }
+
+// 添加或修改录分时的入参结构体
+type UpdateEnterScoreReq struct {
+	EnterScoreId        int                             `comment:"录分ID"`
+	CompanyId           int                             `comment:"公司ID"`
+	CompanyName         string                          `comment:"客户名称"`
+	StartDate           string                          `comment:"开始日期"`
+	EndDate             string                          `comment:"结束日期"`
+	Quarter             []string                        `comment:"季度"`
+	EnterScoreType      int                             `comment:"录入方式 1:按评分录入、2:按比例录入"`
+	Ranking             string                          `comment:"排名"`
+	IsMergeScoring      int                             `comment:"是否合并打分"`
+	SecuritiesFirmsName string                          `comment:"券商名称"`
+	MergeProportion     float64                         `comment:"合并占比"`
+	RaiProportionTotal  float64                         `comment:"权益研究员占比"`
+	FiccProportionTotal float64                         `comment:"FICC研究员占比"`
+	ProportionTotal     float64                         `comment:"合计总占比"`
+	ListRai             []*EnterScorePermissionListResp //权益列表
+	ListFicc            []*EnterScorePermissionListResp //FICC列表
+	ListGroup           []*EnterScoreGroupListResp      //其他配置信息
+}
+
+// CygxEnterScoreGroup 结构体代表 cygx_enter_score_group 表
+type CygxEnterScoreGroup struct {
+	EnterScoreGroupId int       `orm:"column(enter_score_group_id);pk";comment:"主键"`
+	EnterScoreId      int       `comment:"cygx_enter_score主键"`
+	GroupName         string    `comment:"名称"`
+	Proportion        float64   `comment:"占比"`
+	AdminId           int       `comment:"操作人ID"`
+	AdminName         string    `comment:"操作人姓名"`
+	CreateTime        time.Time `comment:"创建时间"`
+	ModifyTime        time.Time `comment:"更新时间"`
+}
+
+// CygxEnterScorePermission 结构体代表 cygx_enter_score_permission 表
+type CygxEnterScorePermission struct {
+	EnterScorePermissionId int       `orm:"column(enter_score_permission_id);pk";comment:"主键"`
+	EnterScoreId           int       `comment:"cygx_enter_score主键"`
+	ChartPermissionName    string    `comment:"名称"`
+	Proportion             float64   `comment:"占比"`
+	ProductId              float64   `comment:"产品id,1:FICC、2:权益"`
+	AdminId                int       `comment:"操作人ID"`
+	AdminName              string    `comment:"操作人姓名"`
+	CreateTime             time.Time `comment:"创建时间"`
+	ModifyTime             time.Time `comment:"更新时间"`
+}
+
+// CygxEnterScoreResearcher 结构体代表 cygx_enter_score_researcher 表
+type CygxEnterScoreResearcher struct {
+	EnterScoreDataId    int       `orm:"column(enter_score_data_id);pk";comment:"主键"`
+	EnterScoreId        int       `comment:"cygx_enter_score主键"`
+	Proportion          float64   `comment:"占比"`
+	RealName            string    `comment:"研究员姓名"`
+	ChartPermissionName string    `comment:"名称"`
+	ProductId           float64   `comment:"产品id,1:FICC、2:权益"`
+	AdminId             int       `comment:"操作人ID"`
+	AdminName           string    `comment:"操作人姓名"`
+	CreateTime          time.Time `comment:"创建时间"`
+	ModifyTime          time.Time `comment:"更新时间"`
+}
+
+// 更新派点信息
+func AddCygxEnterScore(item *CygxEnterScore, itemsPermission []*CygxEnterScorePermission, itemsResearcher []*CygxEnterScoreResearcher, itemsGroup []*CygxEnterScoreGroup) (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()
+		}
+	}()
+
+	newId, err := to.Insert(item)
+	if err != nil {
+		return
+	}
+	enterScoreId := int(newId)
+
+	for _, v := range itemsPermission {
+		v.EnterScoreId = enterScoreId
+	}
+
+	for _, v := range itemsResearcher {
+		v.EnterScoreId = enterScoreId
+	}
+
+	for _, v := range itemsGroup {
+		v.EnterScoreId = enterScoreId
+	}
+
+	//批量添加行业信息
+	_, err = to.InsertMulti(len(itemsPermission), itemsPermission)
+	if err != nil {
+		return
+	}
+
+	//批量添加研究员信息
+	_, err = to.InsertMulti(len(itemsResearcher), itemsResearcher)
+	if err != nil {
+		return
+	}
+
+	//批量添加自定义分组信息
+	_, err = to.InsertMulti(len(itemsGroup), itemsGroup)
+	if err != nil {
+		return
+	}
+	return
+}

+ 4 - 0
models/db.go

@@ -472,6 +472,10 @@ func initCygx() {
 		new(cygx.CygxActivitySpecialPermissionPoints),
 		new(cygx.CygxUserYanxuanPermission),
 		new(cygx.CygxUserYanxuanPermissionLog),
+		new(cygx.CygxEnterScore),
+		new(cygx.CygxEnterScoreGroup),
+		new(cygx.CygxEnterScorePermission),
+		new(cygx.CygxEnterScoreResearcher),
 	)
 }
 

+ 9 - 0
routers/commentsRouter.go

@@ -1465,6 +1465,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: "EnterScoreUpdate",
+            Router: `/enterScore/update`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialAnalystController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:IndustrialAnalystController"],
         beego.ControllerComments{
             Method: "IndustrialAnalystAdd",