正在显示
9 个修改的文件
包含
166 行增加
和
22 行删除
@@ -34,4 +34,7 @@ net_im_app_key ="9c5410602597a7fe367aeeebd8210262" | @@ -34,4 +34,7 @@ net_im_app_key ="9c5410602597a7fe367aeeebd8210262" | ||
34 | user_center_url ="http://suplus-ucenter-dev.fjmaimaimai.com" | 34 | user_center_url ="http://suplus-ucenter-dev.fjmaimaimai.com" |
35 | user_center_salt ="rsF0pL!6DwjBO735" | 35 | user_center_salt ="rsF0pL!6DwjBO735" |
36 | user_center_app_key ="39aefef9e22744a3b2d2d3791824ae7b" | 36 | user_center_app_key ="39aefef9e22744a3b2d2d3791824ae7b" |
37 | -user_center_app_secret ="cykbjnfqgctn" | ||
37 | +user_center_app_secret ="cykbjnfqgctn" | ||
38 | + | ||
39 | +#Html5 | ||
40 | +h5_host = "https://web-open.fjmaimaimai.com" |
@@ -252,14 +252,14 @@ func (this *ChanceController) ChanceStatistics() { | @@ -252,14 +252,14 @@ func (this *ChanceController) ChanceStatistics() { | ||
252 | msg = protocol.NewReturnResponse(chance.ChanceStatistics(header, request)) | 252 | msg = protocol.NewReturnResponse(chance.ChanceStatistics(header, request)) |
253 | } | 253 | } |
254 | 254 | ||
255 | -//MyChance 我的机会 | ||
256 | -//@router /myChance [post] | ||
257 | -func (this *ChanceController) MyChance() { | 255 | +//MySubmitChance 我提交的机会 |
256 | +//@router /mySubmitChance [post] | ||
257 | +func (this *ChanceController) MySubmitChance() { | ||
258 | var msg *protocol.ResponseMessage | 258 | var msg *protocol.ResponseMessage |
259 | defer func() { | 259 | defer func() { |
260 | this.Resp(msg) | 260 | this.Resp(msg) |
261 | }() | 261 | }() |
262 | - var request *protocol.MyChanceRequest | 262 | + var request *protocol.MySubmitChanceRequest |
263 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 263 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
264 | log.Error(err) | 264 | log.Error(err) |
265 | msg = protocol.BadRequestParam(1) | 265 | msg = protocol.BadRequestParam(1) |
@@ -270,5 +270,5 @@ func (this *ChanceController) MyChance() { | @@ -270,5 +270,5 @@ func (this *ChanceController) MyChance() { | ||
270 | return | 270 | return |
271 | } | 271 | } |
272 | header := controllers.GetRequestHeader(this.Ctx) | 272 | header := controllers.GetRequestHeader(this.Ctx) |
273 | - msg = protocol.NewReturnResponse(chance.MyChance(header, request)) | 273 | + msg = protocol.NewReturnResponse(chance.MySubmitChance(header, request)) |
274 | } | 274 | } |
@@ -2,7 +2,9 @@ package utils | @@ -2,7 +2,9 @@ package utils | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "errors" | 4 | "errors" |
5 | + "fmt" | ||
5 | "reflect" | 6 | "reflect" |
7 | + "strings" | ||
6 | ) | 8 | ) |
7 | 9 | ||
8 | // 此函数将指定的结构体成员值更新到结构体中 | 10 | // 此函数将指定的结构体成员值更新到结构体中 |
@@ -41,3 +43,18 @@ func SetStructValueByType(s interface{}, columnType string, columnValue interfac | @@ -41,3 +43,18 @@ func SetStructValueByType(s interface{}, columnType string, columnValue interfac | ||
41 | } | 43 | } |
42 | return nil | 44 | return nil |
43 | } | 45 | } |
46 | + | ||
47 | +func JoinInts(ids []int, spilt string) string { | ||
48 | + var idStrings []string = make([]string, len(ids)) | ||
49 | + for i := 0; i < len(ids); i++ { | ||
50 | + idStrings[i] = fmt.Sprintf("%v", ids[i]) | ||
51 | + } | ||
52 | + return strings.Join(idStrings, spilt) | ||
53 | +} | ||
54 | +func JoinInt8s(ids []int8, spilt string) string { | ||
55 | + var idStrings []string = make([]string, len(ids)) | ||
56 | + for i := 0; i < len(ids); i++ { | ||
57 | + idStrings[i] = fmt.Sprintf("%v", ids[i]) | ||
58 | + } | ||
59 | + return strings.Join(idStrings, spilt) | ||
60 | +} |
@@ -90,26 +90,25 @@ func DeleteChance(id int64) (err error) { | @@ -90,26 +90,25 @@ func DeleteChance(id int64) (err error) { | ||
90 | return | 90 | return |
91 | } | 91 | } |
92 | 92 | ||
93 | -//我的机会列表 | ||
94 | -func GetChanceMyChance(uid, cid int64, reviewStatus int8, lastId int64, pageSize int, v interface{}) (total int, err error) { | 93 | +func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { |
95 | sql := `select a.*,b.images,speechs,videos | 94 | sql := `select a.*,b.images,speechs,videos |
96 | from ( | 95 | from ( |
97 | select id,user_id,create_at,source_content from chance | 96 | select id,user_id,create_at,source_content from chance |
98 | -where user_id=? and company_id=? and review_status =? and (?=0 or id>?) | 97 | +where user_id=? and company_id=? and review_status in (?) and (?=0 or id>?) |
99 | order by create_at desc | 98 | order by create_at desc |
100 | limit ? | 99 | limit ? |
101 | ) a left JOIN chance_data b on a.id =b.chance_id` | 100 | ) a left JOIN chance_data b on a.id =b.chance_id` |
102 | 101 | ||
103 | sqlCount := `select count(0) from ( | 102 | sqlCount := `select count(0) from ( |
104 | select id,user_id,create_at,source_content from chance | 103 | select id,user_id,create_at,source_content from chance |
105 | -where user_id=? and company_id=? and review_status =? | 104 | +where user_id=? and company_id=? and review_status in (?) |
106 | order by create_at desc | 105 | order by create_at desc |
107 | ) a left JOIN chance_data b on a.id =b.chance_id` | 106 | ) a left JOIN chance_data b on a.id =b.chance_id` |
108 | - if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid, reviewStatus); err != nil { | 107 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid, utils.JoinInt8s(reviewStatus, ",")); err != nil { |
109 | return | 108 | return |
110 | } | 109 | } |
111 | if v != nil { | 110 | if v != nil { |
112 | - if err = utils.ExecuteQueryAll(v, sql, uid, cid, reviewStatus, lastId, lastId, pageSize); err != nil { | 111 | + if err = utils.ExecuteQueryAll(v, sql, uid, cid, utils.JoinInt8s(reviewStatus, ","), lastId, lastId, pageSize); err != nil { |
113 | return | 112 | return |
114 | } | 113 | } |
115 | } | 114 | } |
1 | package protocol | 1 | package protocol |
2 | 2 | ||
3 | -import "opp/models" | 3 | +import ( |
4 | + "opp/models" | ||
5 | + "time" | ||
6 | +) | ||
4 | 7 | ||
5 | //机会审核 | 8 | //机会审核 |
6 | //审核对象 | 9 | //审核对象 |
@@ -164,7 +167,32 @@ type ChanceTotalItem struct { | @@ -164,7 +167,32 @@ type ChanceTotalItem struct { | ||
164 | } | 167 | } |
165 | 168 | ||
166 | /*MyChance 我的机会*/ | 169 | /*MyChance 我的机会*/ |
167 | -type MyChanceRequest struct { | ||
168 | -} | ||
169 | -type MyChanceResponse struct { | 170 | +type MySubmitChanceRequest struct { |
171 | + LastId int64 `json:"lastId"` | ||
172 | + PageSize int `json:"pageSize" valid:"Required"` | ||
173 | + ReviewStatus int8 `json:"reviewStatus"` //审核状态 | ||
174 | +} | ||
175 | +type MySubmitChanceResponse struct { | ||
176 | + List []ChanceItem `json:"list"` | ||
177 | + Total int `json:"total"` | ||
178 | +} | ||
179 | + | ||
180 | +//我的机会列表 | ||
181 | +type ChanceItemOrm struct { | ||
182 | + Id int64 `orm:"column(id)"` | ||
183 | + Uid int64 `orm:"column(user_id)"` | ||
184 | + CreateTime time.Time `orm:"column(create_at)"` | ||
185 | + SourceContent string `orm:"column(source_content)"` | ||
186 | + Images string `orm:"column(images)"` | ||
187 | + Voices string `orm:"column(speechs)"` | ||
188 | + Videos string `orm:"column(videos)"` | ||
189 | +} | ||
190 | +type ChanceItem struct { | ||
191 | + Id int64 `json:"id"` | ||
192 | + CreateTime int64 `json:"createTime"` | ||
193 | + Provider *BaseUserInfo `json:"provider"` | ||
194 | + FormList []*Form `json:"formList" valid:"Required"` | ||
195 | + Speechs []Speech `json:"speechs"` | ||
196 | + Pictures []Picture `json:"pictures"` | ||
197 | + Videos []Video `json:"videos"` | ||
170 | } | 198 | } |
@@ -113,6 +113,14 @@ func init() { | @@ -113,6 +113,14 @@ func init() { | ||
113 | 113 | ||
114 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 114 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
115 | beego.ControllerComments{ | 115 | beego.ControllerComments{ |
116 | + Method: "MySubmitChance", | ||
117 | + Router: `/mySubmitChance`, | ||
118 | + AllowHTTPMethods: []string{"post"}, | ||
119 | + MethodParams: param.Make(), | ||
120 | + Params: nil}) | ||
121 | + | ||
122 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
123 | + beego.ControllerComments{ | ||
116 | Method: "ChanceStatistics", | 124 | Method: "ChanceStatistics", |
117 | Router: `/statistics`, | 125 | Router: `/statistics`, |
118 | AllowHTTPMethods: []string{"post"}, | 126 | AllowHTTPMethods: []string{"post"}, |
1 | package agg | 1 | package agg |
2 | + | ||
3 | +import ( | ||
4 | + "github.com/astaxie/beego/orm" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
6 | + "opp/models" | ||
7 | + "opp/protocol" | ||
8 | +) | ||
9 | + | ||
10 | +//我的机会 | ||
11 | +func MyChanceStatic(header *protocol.RequestHeader, reviewStatus ...int8) (total int, err error) { | ||
12 | + var () | ||
13 | + if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, reviewStatus, 0, 0, nil); err != nil { | ||
14 | + if err == orm.ErrNoRows { | ||
15 | + err = nil | ||
16 | + return | ||
17 | + } | ||
18 | + log.Error(err) | ||
19 | + return | ||
20 | + } | ||
21 | + return | ||
22 | +} |
@@ -587,9 +587,48 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt | @@ -587,9 +587,48 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt | ||
587 | return | 587 | return |
588 | } | 588 | } |
589 | 589 | ||
590 | -//我的机会 | ||
591 | -func MyChance(header *protocol.RequestHeader, request *protocol.MyChanceRequest) (rsp *protocol.MyChanceResponse, err error) { | ||
592 | - var () | ||
593 | - rsp = &protocol.MyChanceResponse{} | 590 | +//我提交的机会 |
591 | +func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitChanceRequest) (rsp *protocol.MySubmitChanceResponse, err error) { | ||
592 | + var ( | ||
593 | + myChances []protocol.ChanceItemOrm | ||
594 | + total int | ||
595 | + provider *protocol.BaseUserInfo | ||
596 | + ) | ||
597 | + if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { | ||
598 | + if err == orm.ErrNoRows { | ||
599 | + err = nil | ||
600 | + return | ||
601 | + } | ||
602 | + log.Error(err) | ||
603 | + return | ||
604 | + } | ||
605 | + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil { | ||
606 | + log.Error(err) | ||
607 | + return | ||
608 | + } | ||
609 | + rsp = &protocol.MySubmitChanceResponse{Total: total} | ||
610 | + | ||
611 | + for i := 0; i < len(myChances); i++ { | ||
612 | + chance := myChances[i] | ||
613 | + item := protocol.ChanceItem{ | ||
614 | + Id: chance.Id, | ||
615 | + Provider: provider, | ||
616 | + CreateTime: chance.CreateTime.Unix(), | ||
617 | + } | ||
618 | + jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
619 | + jsonUnmarshal(chance.Images, &item.Pictures) | ||
620 | + jsonUnmarshal(chance.Voices, &item.Speechs) | ||
621 | + jsonUnmarshal(chance.Videos, &item.Videos) | ||
622 | + rsp.List = append(rsp.List, item) | ||
623 | + } | ||
594 | return | 624 | return |
595 | } | 625 | } |
626 | + | ||
627 | +func jsonUnmarshal(jsonData string, v interface{}) { | ||
628 | + if len(jsonData) == 0 { | ||
629 | + return | ||
630 | + } | ||
631 | + if e := json.Unmarshal([]byte(jsonData), v); e != nil { | ||
632 | + log.Error("json.unmarshal error data:", jsonData, e) | ||
633 | + } | ||
634 | +} |
@@ -362,13 +362,42 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) | @@ -362,13 +362,42 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) | ||
362 | //用户中心-统计信息 | 362 | //用户中心-统计信息 |
363 | func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatisticsRequest) (rsp *protocol.UserStatisticsResponse, err error) { | 363 | func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatisticsRequest) (rsp *protocol.UserStatisticsResponse, err error) { |
364 | var ( | 364 | var ( |
365 | - flag int64 | 365 | + flag int64 |
366 | + total int | ||
366 | ) | 367 | ) |
367 | rsp = &protocol.UserStatisticsResponse{} | 368 | rsp = &protocol.UserStatisticsResponse{} |
369 | + isMark := func(v int64) bool { | ||
370 | + if flag != v { | ||
371 | + return false | ||
372 | + } | ||
373 | + return (request.TypeTotal & v) > 0 | ||
374 | + } | ||
368 | for flag = 1; flag < (1 << 20); flag = flag << 1 { | 375 | for flag = 1; flag < (1 << 20); flag = flag << 1 { |
376 | + total = 0 | ||
377 | + if isMark(protocol.MyCommitChance) { | ||
378 | + if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil { | ||
379 | + log.Error(err) | ||
380 | + } | ||
381 | + } | ||
382 | + if isMark(protocol.MyCommitChanceWait) { | ||
383 | + if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging); err != nil { | ||
384 | + log.Error(err) | ||
385 | + } | ||
386 | + } | ||
387 | + if isMark(protocol.MyAuditChanceReturn) { | ||
388 | + if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusReturn); err != nil { | ||
389 | + log.Error(err) | ||
390 | + } | ||
391 | + } | ||
392 | + if isMark(protocol.MyCommitChancePass) { | ||
393 | + if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusPass); err != nil { | ||
394 | + log.Error(err) | ||
395 | + } | ||
396 | + } | ||
369 | if flag&request.TypeTotal > 0 { | 397 | if flag&request.TypeTotal > 0 { |
370 | rsp.Totals = append(rsp.Totals, protocol.TypeTotalItem{ | 398 | rsp.Totals = append(rsp.Totals, protocol.TypeTotalItem{ |
371 | - Type: flag, | 399 | + Type: flag, |
400 | + Total: total, | ||
372 | }) | 401 | }) |
373 | } | 402 | } |
374 | } | 403 | } |
-
请 注册 或 登录 后发表评论