作者 tangxvhui

bug 修复

@@ -7,6 +7,8 @@ import ( @@ -7,6 +7,8 @@ import (
7 "oppmg/models" 7 "oppmg/models"
8 "oppmg/protocol" 8 "oppmg/protocol"
9 serveachievement "oppmg/services/achievement" 9 serveachievement "oppmg/services/achievement"
  10 +
  11 + "github.com/astaxie/beego/orm"
10 ) 12 )
11 13
12 type AchievementController struct { 14 type AchievementController struct {
@@ -93,7 +95,6 @@ func (c AchievementController) EditAchievement() { @@ -93,7 +95,6 @@ func (c AchievementController) EditAchievement() {
93 defer func() { 95 defer func() {
94 c.ResposeJson(msg) 96 c.ResposeJson(msg)
95 }() 97 }()
96 -  
97 var param protocol.RequestEditAchievement 98 var param protocol.RequestEditAchievement
98 if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil { 99 if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
99 log.Error("json 解析失败 err:%s", err) 100 log.Error("json 解析失败 err:%s", err)
@@ -110,6 +111,25 @@ func (c AchievementController) EditAchievement() { @@ -110,6 +111,25 @@ func (c AchievementController) EditAchievement() {
110 msg = protocol.BadRequestParam("10108") 111 msg = protocol.BadRequestParam("10108")
111 return 112 return
112 } 113 }
  114 + if param.GraspScore < 0 || param.GraspScore > 100 {
  115 + log.Error(" param.GraspScore < 0 || param.GraspScore > 100 ")
  116 + msg = protocol.BadRequestParam("10121")
  117 + return
  118 + }
  119 + if param.UserGraspScore < 0 || param.UserGraspScore > 100 {
  120 + log.Error("param.UserGraspScore < 0 || param.UserGraspScore > 100")
  121 + msg = protocol.BadRequestParam("10122")
  122 + }
  123 + var providerScore float64
  124 + for _, v := range param.Provider {
  125 + providerScore += v.UserGraspScore
  126 + }
  127 + remainScore := param.GraspScore - param.UserGraspScore - providerScore
  128 + if remainScore < 0 {
  129 + log.Error("分配的总分不可大于把握分")
  130 + msg = protocol.BadRequestParam("10122")
  131 + return
  132 + }
113 companyid := c.GetCompanyId() 133 companyid := c.GetCompanyId()
114 err := serveachievement.EditAchievement(&param, companyid) 134 err := serveachievement.EditAchievement(&param, companyid)
115 msg = protocol.NewReturnResponse(nil, err) 135 msg = protocol.NewReturnResponse(nil, err)
@@ -171,10 +191,19 @@ func (c AchievementController) DeleteAchievement() { @@ -171,10 +191,19 @@ func (c AchievementController) DeleteAchievement() {
171 return 191 return
172 } 192 }
173 achievementData.Status = models.ACHIEVEMENT_STATUS_DEL 193 achievementData.Status = models.ACHIEVEMENT_STATUS_DEL
  194 + o := orm.NewOrm()
  195 + o.Begin()
174 err = models.UpdateAchievementById(achievementData, []string{"Status"}) 196 err = models.UpdateAchievementById(achievementData, []string{"Status"})
175 if err != nil { 197 if err != nil {
  198 + o.Rollback()
176 log.Error("更新achievement数据失败:%s", err) 199 log.Error("更新achievement数据失败:%s", err)
177 } 200 }
  201 + err = models.IncreaseAchevementScore(companyid, -achievementData.GraspScoreRemain, o)
  202 + if err != nil {
  203 + o.Rollback()
  204 + log.Error("更新福利池失败数据失败:%s", err)
  205 + }
  206 + o.Commit()
178 msg = protocol.NewReturnResponse(nil, nil) 207 msg = protocol.NewReturnResponse(nil, nil)
179 return 208 return
180 } 209 }
@@ -499,6 +499,10 @@ func (c RankController) RankItemEdit() { @@ -499,6 +499,10 @@ func (c RankController) RankItemEdit() {
499 msg = protocol.BadRequestParam("1") 499 msg = protocol.BadRequestParam("1")
500 return 500 return
501 } 501 }
  502 + if len(param.ItemKey) > 4 {
  503 + msg = protocol.BadRequestParam("10123")
  504 + return
  505 + }
502 companyid := c.GetCompanyId() 506 companyid := c.GetCompanyId()
503 err := serverank.GetRankItemEdit(companyid, param.RankTypeId, param.ItemKey) 507 err := serverank.GetRankItemEdit(companyid, param.RankTypeId, param.ItemKey)
504 msg = protocol.NewReturnResponse(nil, err) 508 msg = protocol.NewReturnResponse(nil, err)
@@ -9,22 +9,23 @@ import ( @@ -9,22 +9,23 @@ import (
9 ) 9 )
10 10
11 type Achievement struct { 11 type Achievement struct {
12 - Id int64 `orm:"column(id);auto" description:"id 主键"`  
13 - CompanyId int64 `orm:"column(company_id);null" description:"公司编号 表company.id"`  
14 - DepartmentId int64 `orm:"column(department_id);null" description:"表department.id 部门id (创建成果指定的部门)"`  
15 - UserCompanyId int64 `orm:"column(user_company_id)" description:"把握人 表user_company.id id"`  
16 - ChanceTypeId int64 `orm:"column(chance_type_id);null" description:"表chance_type.id 机会类型 "`  
17 - AuditTemplateId int64 `orm:"column(audit_template_id);null" description:"表audit_template.id 所属审批模板编号"`  
18 - SourceContent string `orm:"column(source_content);null" description:"成果详情文本"`  
19 - GraspScore float64 `orm:"column(grasp_score);digits(4);decimals(1)" description:"把握分"`  
20 - UserGraspScore float64 `orm:"column(user_grasp_score);digits(4);decimals(1)" description:"把握人得分"`  
21 - UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`  
22 - CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`  
23 - ViewTotal int `orm:"column(view_total);null" description:"查看总数"`  
24 - CommentTotal int `orm:"column(comment_total);null" description:"评论总数"`  
25 - ZanTotal int `orm:"column(zan_total);null" description:"点赞总数"`  
26 - Status int8 `orm:"column(status);null" description:"机会状态 1:开启 2:关闭 0:删除"`  
27 - Images string `orm:"column(images);null" description:"图片 json"` 12 + Id int64 `orm:"column(id);auto" description:"id 主键"`
  13 + CompanyId int64 `orm:"column(company_id);null" description:"公司编号 表company.id"`
  14 + DepartmentId int64 `orm:"column(department_id);null" description:"表department.id 部门id (创建成果指定的部门)"`
  15 + UserCompanyId int64 `orm:"column(user_company_id)" description:"把握人 表user_company.id id"`
  16 + ChanceTypeId int64 `orm:"column(chance_type_id);null" description:"表chance_type.id 机会类型 "`
  17 + AuditTemplateId int64 `orm:"column(audit_template_id);null" description:"表audit_template.id 所属审批模板编号"`
  18 + SourceContent string `orm:"column(source_content);null" description:"成果详情文本"`
  19 + GraspScore float64 `orm:"column(grasp_score);digits(4);decimals(1)" description:"把握分"`
  20 + UserGraspScore float64 `orm:"column(user_grasp_score);digits(4);decimals(1)" description:"把握人得分"`
  21 + UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
  22 + CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
  23 + ViewTotal int `orm:"column(view_total);null" description:"查看总数"`
  24 + CommentTotal int `orm:"column(comment_total);null" description:"评论总数"`
  25 + ZanTotal int `orm:"column(zan_total);null" description:"点赞总数"`
  26 + Status int8 `orm:"column(status);null" description:"机会状态 1:开启 2:关闭 0:删除"`
  27 + Images string `orm:"column(images);null" description:"图片 json"`
  28 + GraspScoreRemain float64 `orm:"column(grasp_score_remain);digits(4);decimals(1)" `
28 } 29 }
29 30
30 func (t *Achievement) TableName() string { 31 func (t *Achievement) TableName() string {
@@ -38,14 +38,15 @@ type RequestAddAchievement struct { @@ -38,14 +38,15 @@ type RequestAddAchievement struct {
38 38
39 //RequestAddAchievement 添加成果 39 //RequestAddAchievement 添加成果
40 type RequestEditAchievement struct { 40 type RequestEditAchievement struct {
41 - AchievementId int64 `json:"achievement_id"`  
42 - ChanceData []AchievementChance `json:"chance_data"`  
43 - ChanceTypeId int64 `json:"chance_type_id"` //机会一级分类 chance_type  
44 - AuditTemplateId int64 `json:"audit_template_id"` //机会二级分类  
45 - GraspScore float64 `json:"grasp_score"` //把握分  
46 - // UserGraspScore float64 `json:"user_grasp_score"` //把握人总得分  
47 - SourceContent string `json:"source_content"` //成果描述文本  
48 - Images []AchievementImage `json:"image"` //图片 41 + AchievementId int64 `json:"achievement_id"`
  42 + ChanceData []AchievementChance `json:"chance_data"`
  43 + ChanceTypeId int64 `json:"chance_type_id"` //机会一级分类 chance_type
  44 + AuditTemplateId int64 `json:"audit_template_id"` //机会二级分类
  45 + GraspScore float64 `json:"grasp_score"` //把握分
  46 + UserGraspScore float64 `json:"user_grasp_score"` //把握人总得分
  47 + SourceContent string `json:"source_content"` //成果描述文本
  48 + Provider []AchievementProvider `json:"provider"` //机会提供者
  49 + Images []AchievementImage `json:"image"` //图片
49 } 50 }
50 51
51 // ResponseRankSeasonList 赛季列表 52 // ResponseRankSeasonList 赛季列表
@@ -120,6 +120,7 @@ var errmessge ErrorMap = map[string]string{ @@ -120,6 +120,7 @@ var errmessge ErrorMap = map[string]string{
120 "10110": "把握人得分不可大于把握得分", 120 "10110": "把握人得分不可大于把握得分",
121 "10121": "把握得分必填,0.1-100", 121 "10121": "把握得分必填,0.1-100",
122 "10122": "分配的总分不可大于把握分", 122 "10122": "分配的总分不可大于把握分",
  123 + "10123": "排行榜评比项最多4项",
123 } 124 }
124 125
125 //错误码转换 ,兼容需要 126 //错误码转换 ,兼容需要
@@ -25,6 +25,7 @@ func addAchievementProvider(addData []protocol.AchievementProvider, achievementI @@ -25,6 +25,7 @@ func addAchievementProvider(addData []protocol.AchievementProvider, achievementI
25 AchievementId: achievementId, 25 AchievementId: achievementId,
26 UserCompanyId: v.UserCompanyId, 26 UserCompanyId: v.UserCompanyId,
27 UserGraspScore: v.UserGraspScore, 27 UserGraspScore: v.UserGraspScore,
  28 + DepartmentId: v.DepartmentId,
28 CreateAt: nowTime, 29 CreateAt: nowTime,
29 } 30 }
30 providerList = append(providerList, m) 31 providerList = append(providerList, m)
@@ -54,6 +55,10 @@ func addAchievementChance(addData []protocol.AchievementChance, achievementId in @@ -54,6 +55,10 @@ func addAchievementChance(addData []protocol.AchievementChance, achievementId in
54 return err 55 return err
55 } 56 }
56 57
  58 +func achievementGraspScoreRemain(graspScore, userGraspScore, providerScoreAll float64) float64 {
  59 + return graspScore - userGraspScore - providerScoreAll
  60 +}
  61 +
57 //AddAchievement 添加成果 62 //AddAchievement 添加成果
58 func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) error { 63 func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) error {
59 var ( 64 var (
@@ -61,18 +66,24 @@ func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) er @@ -61,18 +66,24 @@ func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) er
61 err error 66 err error
62 ) 67 )
63 nowTime := time.Now() 68 nowTime := time.Now()
  69 + var providerScore float64
  70 + for _, v := range addData.Provider {
  71 + providerScore += v.UserGraspScore
  72 + }
  73 + scoreRemain := achievementGraspScoreRemain(addData.GraspScore, addData.UserGraspScore, providerScore)
64 achievementData = &models.Achievement{ 74 achievementData = &models.Achievement{
65 - CompanyId: companyid,  
66 - DepartmentId: addData.DepartmentId,  
67 - UserCompanyId: addData.UserCompanyId,  
68 - ChanceTypeId: addData.ChanceTypeId,  
69 - AuditTemplateId: addData.AuditTemplateId,  
70 - SourceContent: addData.SourceContent,  
71 - GraspScore: addData.GraspScore,  
72 - UserGraspScore: addData.UserGraspScore,  
73 - CreateAt: nowTime,  
74 - UpdateAt: nowTime,  
75 - Status: models.ACHIEVEMENT_STATUS_YES, 75 + CompanyId: companyid,
  76 + DepartmentId: addData.DepartmentId,
  77 + UserCompanyId: addData.UserCompanyId,
  78 + ChanceTypeId: addData.ChanceTypeId,
  79 + AuditTemplateId: addData.AuditTemplateId,
  80 + SourceContent: addData.SourceContent,
  81 + GraspScore: addData.GraspScore,
  82 + UserGraspScore: addData.UserGraspScore,
  83 + CreateAt: nowTime,
  84 + UpdateAt: nowTime,
  85 + Status: models.ACHIEVEMENT_STATUS_YES,
  86 + GraspScoreRemain: scoreRemain,
76 } 87 }
77 if imgData, err := json.Marshal(addData.Images); err == nil { 88 if imgData, err := json.Marshal(addData.Images); err == nil {
78 achievementData.Images = string(imgData) 89 achievementData.Images = string(imgData)
@@ -105,12 +116,8 @@ func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) er @@ -105,12 +116,8 @@ func AddAchievement(addData *protocol.RequestAddAchievement, companyid int64) er
105 } 116 }
106 } 117 }
107 //操作achievement_score福利池数据 118 //操作achievement_score福利池数据
108 - var providerScore float64  
109 - for _, v := range addData.Provider {  
110 - providerScore += v.UserGraspScore  
111 - }  
112 - addScore := addData.GraspScore - addData.UserGraspScore - providerScore  
113 - err = models.IncreaseAchevementScore(companyid, addScore, o) 119 +
  120 + err = models.IncreaseAchevementScore(companyid, scoreRemain, o)
114 if err != nil { 121 if err != nil {
115 o.Rollback() 122 o.Rollback()
116 log.Error("更新福利池分数achevement_score失败") 123 log.Error("更新福利池分数achevement_score失败")
@@ -130,6 +137,16 @@ func EditAchievement(editData *protocol.RequestEditAchievement, companyid int64) @@ -130,6 +137,16 @@ func EditAchievement(editData *protocol.RequestEditAchievement, companyid int64)
130 log.Error("获取achievement失败:%s", err) 137 log.Error("获取achievement失败:%s", err)
131 return protocol.NewErrWithMessage("1") 138 return protocol.NewErrWithMessage("1")
132 } 139 }
  140 + var (
  141 + oldRemain float64
  142 + newRamain float64
  143 + providerScore float64
  144 + )
  145 + oldRemain = achievementData.GraspScoreRemain
  146 + for _, v := range editData.Provider {
  147 + providerScore += v.UserGraspScore
  148 + }
  149 + newRamain = achievementGraspScoreRemain(editData.GraspScore, editData.UserGraspScore, providerScore)
133 nowTime := time.Now() 150 nowTime := time.Now()
134 achievementData.UpdateAt = nowTime 151 achievementData.UpdateAt = nowTime
135 achievementData.ChanceTypeId = editData.ChanceTypeId 152 achievementData.ChanceTypeId = editData.ChanceTypeId
@@ -137,8 +154,11 @@ func EditAchievement(editData *protocol.RequestEditAchievement, companyid int64) @@ -137,8 +154,11 @@ func EditAchievement(editData *protocol.RequestEditAchievement, companyid int64)
137 achievementData.SourceContent = editData.SourceContent 154 achievementData.SourceContent = editData.SourceContent
138 achievementData.GraspScore = editData.GraspScore 155 achievementData.GraspScore = editData.GraspScore
139 achievementData.UpdateAt = nowTime 156 achievementData.UpdateAt = nowTime
  157 + achievementData.UserGraspScore = editData.UserGraspScore
  158 + achievementData.GraspScoreRemain = newRamain
140 cols := []string{ 159 cols := []string{
141 "UpdateAt", "ChanceTypeId", "AuditTemplateId", "SourceContent", "GraspScore", 160 "UpdateAt", "ChanceTypeId", "AuditTemplateId", "SourceContent", "GraspScore",
  161 + "UserGraspScore",
142 } 162 }
143 o := orm.NewOrm() 163 o := orm.NewOrm()
144 o.Begin() 164 o.Begin()
@@ -158,13 +178,33 @@ func EditAchievement(editData *protocol.RequestEditAchievement, companyid int64) @@ -158,13 +178,33 @@ func EditAchievement(editData *protocol.RequestEditAchievement, companyid int64)
158 log.Info("删除achievement_chance数据失败:%s", err) 178 log.Info("删除achievement_chance数据失败:%s", err)
159 return protocol.NewErrWithMessage("1") 179 return protocol.NewErrWithMessage("1")
160 } 180 }
161 -  
162 err = addAchievementChance(editData.ChanceData, achievementData.Id, o) 181 err = addAchievementChance(editData.ChanceData, achievementData.Id, o)
163 if err != nil { 182 if err != nil {
164 log.Error("添加achievement_chance失败:%s", err) 183 log.Error("添加achievement_chance失败:%s", err)
165 o.Rollback() 184 o.Rollback()
166 return protocol.NewErrWithMessage("1") 185 return protocol.NewErrWithMessage("1")
167 } 186 }
  187 + //删除提供者分数
  188 + _, err = o.QueryTable(&models.AchievementProvider{}).
  189 + Filter("achievement_id", editData.AchievementId).
  190 + Delete()
  191 + if err != nil {
  192 + o.Rollback()
  193 + log.Info("删除achievement_provider数据失败:%s", err)
  194 + return protocol.NewErrWithMessage("1")
  195 + }
  196 + err = addAchievementProvider(editData.Provider, achievementData.Id, o)
  197 + if err != nil {
  198 + log.Error("添加achievement_provider失败:%s", err)
  199 + o.Rollback()
  200 + return protocol.NewErrWithMessage("1")
  201 + }
  202 + err = models.IncreaseAchevementScore(companyid, newRamain-oldRemain, o)
  203 + if err != nil {
  204 + o.Rollback()
  205 + log.Error("更新福利池分数achevement_score失败")
  206 + return protocol.NewErrWithMessage("1")
  207 + }
168 o.Commit() 208 o.Commit()
169 return nil 209 return nil
170 } 210 }
@@ -184,7 +224,7 @@ func GetAchievementList(pageIndex int, pageSize int, companyId int64, status int @@ -184,7 +224,7 @@ func GetAchievementList(pageIndex int, pageSize int, companyId int64, status int
184 dataSql += ` AND a.status>0 ` 224 dataSql += ` AND a.status>0 `
185 countSql += ` AND a.status>0 ` 225 countSql += ` AND a.status>0 `
186 } 226 }
187 - dataSql = fmt.Sprintf("%s ORDER BY a.create_at LIMIT %d,%d", dataSql, pageStart, pageSize) 227 + dataSql = fmt.Sprintf("%s ORDER BY a.create_at DESC LIMIT %d,%d", dataSql, pageStart, pageSize)
188 type SqlData struct { 228 type SqlData struct {
189 Id int64 `orm:"column(id)"` 229 Id int64 `orm:"column(id)"`
190 ChanceTypeId int `orm:"column(chance_type_id)"` 230 ChanceTypeId int `orm:"column(chance_type_id)"`
@@ -186,13 +186,13 @@ func SeleteGetChanceTypeList(companyid int64) []protocol.ChanceTypeBase { @@ -186,13 +186,13 @@ func SeleteGetChanceTypeList(companyid int64) []protocol.ChanceTypeBase {
186 func SelectCompanyUserList(pageIndex int, pageSize int, companyid int64, userName string) protocol.SelectCompanyUserList { 186 func SelectCompanyUserList(pageIndex int, pageSize int, companyid int64, userName string) protocol.SelectCompanyUserList {
187 datasql := `SELECT b.id,a.id as user_company_id,d.nick_name,c.name AS department_name,c.id AS department_id 187 datasql := `SELECT b.id,a.id as user_company_id,d.nick_name,c.name AS department_name,c.id AS department_id
188 FROM user_company AS a 188 FROM user_company AS a
189 - LEFT JOIN user_department AS b ON a.id = b.user_company_id and a.enable=1 189 + LEFT JOIN user_department AS b ON a.id = b.user_company_id AND b.enable_status=1
190 LEFT JOIN department AS c ON b.department_id = c.id 190 LEFT JOIN department AS c ON b.department_id = c.id
191 LEFT JOIN user AS d ON a.user_id = d.id 191 LEFT JOIN user AS d ON a.user_id = d.id
192 WHERE a.delete_at = 0 AND c.company_id = ? ` 192 WHERE a.delete_at = 0 AND c.company_id = ? `
193 countsql := `SELECT count(*) 193 countsql := `SELECT count(*)
194 FROM user_company AS a 194 FROM user_company AS a
195 - LEFT JOIN user_department AS b ON a.id = b.user_company_id AND a.enable=1 195 + LEFT JOIN user_department AS b ON a.id = b.user_company_id AND b.enable_status=1
196 LEFT JOIN department AS c ON b.department_id = c.id 196 LEFT JOIN department AS c ON b.department_id = c.id
197 LEFT JOIN user AS d ON a.user_id = d.id 197 LEFT JOIN user AS d ON a.user_id = d.id
198 WHERE a.delete_at = 0 AND c.company_id =? ` 198 WHERE a.delete_at = 0 AND c.company_id =? `
@@ -241,12 +241,12 @@ func SelectChanceList(pageIndex int, pageSize int, companyid int64, searchType i @@ -241,12 +241,12 @@ func SelectChanceList(pageIndex int, pageSize int, companyid int64, searchType i
241 FROM chance as a 241 FROM chance as a
242 LEFT JOIN user_company AS b ON a.user_id = b.id 242 LEFT JOIN user_company AS b ON a.user_id = b.id
243 JOIN user AS c ON b.user_id = c.id 243 JOIN user AS c ON b.user_id = c.id
244 - WHERE a.company_id =? ` 244 + WHERE a.company_id =? AND a.status=1 AND a.enable_status=1 AND a.review_status=3 `
245 countsql := `SELECT count(*) 245 countsql := `SELECT count(*)
246 FROM chance as a 246 FROM chance as a
247 LEFT JOIN user_company AS b ON a.user_id = b.id 247 LEFT JOIN user_company AS b ON a.user_id = b.id
248 JOIN user AS c ON b.user_id = c.id 248 JOIN user AS c ON b.user_id = c.id
249 - WHERE a.company_id =? ` 249 + WHERE a.company_id =? AND a.status=1 AND a.enable_status=1 AND a.review_status=3 `
250 cond := []interface{}{companyid} 250 cond := []interface{}{companyid}
251 where := "" 251 where := ""
252 if len(chanceCode) > 0 { 252 if len(chanceCode) > 0 {
@@ -191,6 +191,7 @@ func AddRankPeriod(rankTypeId int64, beginTime int64, endTime int64, name string @@ -191,6 +191,7 @@ func AddRankPeriod(rankTypeId int64, beginTime int64, endTime int64, name string
191 EndTime: time.Unix(endTime, 0).Local(), 191 EndTime: time.Unix(endTime, 0).Local(),
192 Status: 0, 192 Status: 0,
193 } 193 }
  194 +
194 _, err = models.AddRankPeriod(m) 195 _, err = models.AddRankPeriod(m)
195 if err != nil { 196 if err != nil {
196 log.Error("添加赛季失败;%s", err) 197 log.Error("添加赛季失败;%s", err)
@@ -208,9 +209,13 @@ func RankPeriodCheckTime(rankTypeId int64, beginTime int64, endTime int64, idNot @@ -208,9 +209,13 @@ func RankPeriodCheckTime(rankTypeId int64, beginTime int64, endTime int64, idNot
208 (UNIX_TIMESTAMP(begin_time) BETWEEN %d AND %d) 209 (UNIX_TIMESTAMP(begin_time) BETWEEN %d AND %d)
209 OR 210 OR
210 (UNIX_TIMESTAMP(end_time) BETWEEN %d AND %d) 211 (UNIX_TIMESTAMP(end_time) BETWEEN %d AND %d)
  212 + OR
  213 + (%d BETWEEN UNIX_TIMESTAMP(begin_time) AND UNIX_TIMESTAMP(end_time))
  214 + OR
  215 + (%d BETWEEN UNIX_TIMESTAMP(begin_time) AND UNIX_TIMESTAMP(end_time))
211 ) 216 )
212 LIMIT 1 ` 217 LIMIT 1 `
213 - sql = fmt.Sprintf(sql, rankTypeId, idNot, beginTime, endTime, beginTime, endTime) 218 + sql = fmt.Sprintf(sql, rankTypeId, idNot, beginTime, endTime, beginTime, endTime, beginTime, endTime)
214 var cnt int 219 var cnt int
215 err := utils.ExecuteQueryOne(&cnt, sql) 220 err := utils.ExecuteQueryOne(&cnt, sql)
216 if err != nil { 221 if err != nil {
@@ -240,6 +245,7 @@ func EditRankPeriod(id int64, beginTime int64, endTime int64, name string, compa @@ -240,6 +245,7 @@ func EditRankPeriod(id int64, beginTime int64, endTime int64, name string, compa
240 m.SeasonName = name 245 m.SeasonName = name
241 m.BeginTime = time.Unix(beginTime, 0) 246 m.BeginTime = time.Unix(beginTime, 0)
242 m.EndTime = time.Unix(endTime, 0) 247 m.EndTime = time.Unix(endTime, 0)
  248 +
243 err = models.UpdateRankPeriodById(m, []string{"SeasonName", "BeginTime", "EndTime"}) 249 err = models.UpdateRankPeriodById(m, []string{"SeasonName", "BeginTime", "EndTime"})
244 if err != nil { 250 if err != nil {
245 log.Error("更新赛季失败;%s", err) 251 log.Error("更新赛季失败;%s", err)
@@ -386,7 +392,7 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co @@ -386,7 +392,7 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co
386 oldids []int64 392 oldids []int64
387 ) 393 )
388 for i := range rankRangeDatas { 394 for i := range rankRangeDatas {
389 - oldids = append(oldids, rankRangeDatas[i].RelationId) 395 + oldids = append(oldids, rankRangeDatas[i].Id)
390 } 396 }
391 var ( 397 var (
392 addRangeData []models.RankRangeData 398 addRangeData []models.RankRangeData
@@ -403,7 +409,6 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co @@ -403,7 +409,6 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co
403 rankRange.Type = rangetype 409 rankRange.Type = rangetype
404 o := orm.NewOrm() 410 o := orm.NewOrm()
405 o.Begin() 411 o.Begin()
406 -  
407 err = models.UpdateRankRangeById(rankRange, []string{"Name", "Type"}, o) 412 err = models.UpdateRankRangeById(rankRange, []string{"Name", "Type"}, o)
408 if err != nil { 413 if err != nil {
409 o.Rollback() 414 o.Rollback()