|
@@ -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 = "操作成功"
|
|
|
+}
|