作者 yangfu

机会池统计修改

@@ -152,7 +152,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, @@ -152,7 +152,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int,
152 sql := `select a.*,b.images,speechs,videos 152 sql := `select a.*,b.images,speechs,videos
153 from ( 153 from (
154 select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance 154 select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
155 -where user_id=? and company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1 155 +where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1
156 order by create_at desc 156 order by create_at desc
157 limit ? 157 limit ?
158 ) a left JOIN chance_data b on a.id =b.chance_id` 158 ) a left JOIN chance_data b on a.id =b.chance_id`
@@ -160,14 +160,14 @@ limit ? @@ -160,14 +160,14 @@ limit ?
160 160
161 sqlCount := fmt.Sprintf(`select count(0) from ( 161 sqlCount := fmt.Sprintf(`select count(0) from (
162 select id from chance 162 select id from chance
163 -where user_id=? and company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1 163 +where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
164 order by create_at desc 164 order by create_at desc
165 ) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId) 165 ) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
166 - if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil { 166 + if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
167 return 167 return
168 } 168 }
169 if v != nil { 169 if v != nil {
170 - if err = utils.ExecuteQueryAll(v, sql, uid, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil { 170 + if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
171 return 171 return
172 } 172 }
173 } 173 }
@@ -766,6 +766,8 @@ func getParentDepartmentors(pid int) (ids []int64) { @@ -766,6 +766,8 @@ func getParentDepartmentors(pid int) (ids []int64) {
766 func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceStatisticsRequest) (rsp *protocol.ChanceStatisticsResponse, err error) { 766 func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceStatisticsRequest) (rsp *protocol.ChanceStatisticsResponse, err error) {
767 var ( 767 var (
768 chanceType []*models.ChanceType 768 chanceType []*models.ChanceType
  769 + total int
  770 + sum int
769 ) 771 )
770 if chanceType, err = models.GetChanceTypeAll(header.CompanyId); err != nil { 772 if chanceType, err = models.GetChanceTypeAll(header.CompanyId); err != nil {
771 log.Error(err) 773 log.Error(err)
@@ -774,12 +776,18 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt @@ -774,12 +776,18 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt
774 rsp = &protocol.ChanceStatisticsResponse{} 776 rsp = &protocol.ChanceStatisticsResponse{}
775 for i := range chanceType { 777 for i := range chanceType {
776 item := chanceType[i] 778 item := chanceType[i]
  779 + if total, err = models.GetChancePool(header.UserId, header.CompanyId, item.Id, 0, 0, nil); err != nil {
  780 + log.Error(err)
  781 + return
  782 + }
  783 + sum += total
777 rsp.List = append(rsp.List, protocol.ChanceTotalItem{ 784 rsp.List = append(rsp.List, protocol.ChanceTotalItem{
778 Id: item.Id, 785 Id: item.Id,
779 Name: item.Name, 786 Name: item.Name,
780 - Total: i * 2, 787 + Total: total,
781 }) 788 })
782 } 789 }
  790 + rsp.ChanceTotal = sum
783 return 791 return
784 } 792 }
785 793