作者 yangfu

修改 草稿箱列表(自查内容,表单)

@@ -381,6 +381,10 @@ func (this *ChanceController) ChanceDetail() { @@ -381,6 +381,10 @@ func (this *ChanceController) ChanceDetail() {
381 return 381 return
382 } 382 }
383 header := controllers.GetRequestHeader(this.Ctx) 383 header := controllers.GetRequestHeader(this.Ctx)
  384 + if request.IsDraft {
  385 + msg = protocol.NewReturnResponse(chance.ChanceDraftDetail(header, request))
  386 + return
  387 + }
384 msg = protocol.NewReturnResponse(chance.ChanceDetail(header, request)) 388 msg = protocol.NewReturnResponse(chance.ChanceDetail(header, request))
385 } 389 }
386 390
@@ -834,6 +838,7 @@ func (this *ChanceController) DraftSaveChance() { @@ -834,6 +838,7 @@ func (this *ChanceController) DraftSaveChance() {
834 return 838 return
835 } 839 }
836 header := controllers.GetRequestHeader(this.Ctx) 840 header := controllers.GetRequestHeader(this.Ctx)
  841 + request.SelfChecks.SetSelfChecksLevel1ByRule()
837 msg = protocol.NewReturnResponse(chance.DraftSaveChance(header, request)) 842 msg = protocol.NewReturnResponse(chance.DraftSaveChance(header, request))
838 } 843 }
839 844
@@ -130,6 +130,7 @@ type TemplateRequest struct { @@ -130,6 +130,7 @@ type TemplateRequest struct {
130 TemplateId int `json:"templateId" valid:"Required"` 130 TemplateId int `json:"templateId" valid:"Required"`
131 131
132 ChanceId int64 `json:"chanceId" ` //机会编号 ios特殊使用 132 ChanceId int64 `json:"chanceId" ` //机会编号 ios特殊使用
  133 + IsDraft bool `json:"isDraft"` //是否是草稿
133 } 134 }
134 type TemplateResponse struct { 135 type TemplateResponse struct {
135 Template *Template `json:"template"` 136 Template *Template `json:"template"`
@@ -417,6 +418,7 @@ type CommChanceItemOrm struct { @@ -417,6 +418,7 @@ type CommChanceItemOrm struct {
417 /*ChanceDetail 机会详情*/ 418 /*ChanceDetail 机会详情*/
418 type ChanceDetailRequest struct { 419 type ChanceDetailRequest struct {
419 Id int64 `json:"id"` //机会编号 420 Id int64 `json:"id"` //机会编号
  421 + IsDraft bool `json:"isDraft"` //是否是草稿
420 } 422 }
421 type ChanceDetailResponse struct { 423 type ChanceDetailResponse struct {
422 ChanceDetail ChanceItem `json:"chance"` 424 ChanceDetail ChanceItem `json:"chance"`
@@ -594,6 +596,9 @@ type CommonListItem struct { @@ -594,6 +596,9 @@ type CommonListItem struct {
594 ReviewStatus int `json:"reviewStatus,omitempty"` //审核状态 596 ReviewStatus int `json:"reviewStatus,omitempty"` //审核状态
595 597
596 ChanceId int64 `json:"chanceId,omitempty"` //机会编号 598 ChanceId int64 `json:"chanceId,omitempty"` //机会编号
  599 +
  600 + //Questions interface{} `json:"questions,omitempty"`
  601 +
597 } 602 }
598 603
599 type MsgCommonListItem struct { 604 type MsgCommonListItem struct {
@@ -290,13 +290,14 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) @@ -290,13 +290,14 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
290 templates *models.AuditTemplate 290 templates *models.AuditTemplate
291 forms []*models.AuditForm 291 forms []*models.AuditForm
292 chance *models.Chance 292 chance *models.Chance
  293 + chanceDraft *models.ChanceDraft
293 ) 294 )
294 rsp = &protocol.TemplateResponse{} 295 rsp = &protocol.TemplateResponse{}
295 if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil { 296 if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil {
296 log.Error(fmt.Sprintf("公司:%v chance_type_id:%v id:%v无模板 ", header.CompanyId, request.ChanceTypeId, request.TemplateId), err) 297 log.Error(fmt.Sprintf("公司:%v chance_type_id:%v id:%v无模板 ", header.CompanyId, request.ChanceTypeId, request.TemplateId), err)
297 return 298 return
298 } 299 }
299 - if request.ChanceId > 0 { 300 + if request.ChanceId > 0 && !request.IsDraft {
300 if chance, err = models.GetChanceById(request.ChanceId); err == nil { 301 if chance, err = models.GetChanceById(request.ChanceId); err == nil {
301 if chance.EnableStatus == 0 { 302 if chance.EnableStatus == 0 {
302 err = protocol.NewErrWithMessage(5101) 303 err = protocol.NewErrWithMessage(5101)
@@ -326,10 +327,18 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) @@ -326,10 +327,18 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
326 template.Link = fmt.Sprintf("%v/#/ability/opportunity?id=%v", beego.AppConfig.String("h5_host"), item.Id) 327 template.Link = fmt.Sprintf("%v/#/ability/opportunity?id=%v", beego.AppConfig.String("h5_host"), item.Id)
327 } 328 }
328 if request.ChanceId > 0 { 329 if request.ChanceId > 0 {
  330 + if request.IsDraft { //是否是机会草稿
  331 + if chanceDraft, err = models.GetChanceDraftById(request.ChanceId); err == nil {
  332 + var old []protocol.SelfCheck
  333 + utils.JsonUnmarshal(chanceDraft.SelfChecks, &old)
  334 + template.Questions = GetNewestCheckQuestions(chanceDraft.AuditTemplateId, old)
  335 + }
  336 + } else { //正常机会
329 if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil { 337 if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil {
330 log.Error(err) 338 log.Error(err)
331 return 339 return
332 } 340 }
  341 + }
333 } else { 342 } else {
334 if template.Questions, err = agg.GetCheckQuestionsByTemplateId(templates.Id); err != nil { 343 if template.Questions, err = agg.GetCheckQuestionsByTemplateId(templates.Id); err != nil {
335 log.Error(err) 344 log.Error(err)
@@ -2043,6 +2052,60 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail @@ -2043,6 +2052,60 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
2043 return 2052 return
2044 } 2053 }
2045 2054
  2055 +func ChanceDraftDetail(header *protocol.RequestHeader, request *protocol.ChanceDetailRequest) (rsp *protocol.ChanceDetailResponse, err error) {
  2056 + var (
  2057 + chance *models.ChanceDraft
  2058 + chanceData *models.ChanceData
  2059 + provider *protocol.BaseUserInfo
  2060 + )
  2061 + rsp = &protocol.ChanceDetailResponse{}
  2062 + if chance, err = models.GetChanceDraftById(request.Id); err != nil {
  2063 + if err == orm.ErrNoRows {
  2064 + err = protocol.NewErrWithMessage(5101)
  2065 + return
  2066 + }
  2067 + log.Error(err)
  2068 + return
  2069 + }
  2070 + //用户信息
  2071 + if provider, err = agg.GetUserBaseInfo(chance.UserId, header.CompanyId); err != nil {
  2072 + log.Error(err)
  2073 + return
  2074 + }
  2075 + if template, e := models.GetAuditTemplateById(chance.AuditTemplateId); e == nil {
  2076 + rsp.ChanceTemplate = protocol.NameItem{
  2077 + Id: int(template.Id),
  2078 + Name: template.Name,
  2079 + }
  2080 + }
  2081 + if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil {
  2082 + rsp.ChanceType = protocol.NameItem{
  2083 + Id: int(chanceType.Id),
  2084 + Name: chanceType.Name,
  2085 + }
  2086 + }
  2087 + item := protocol.ChanceItem{
  2088 + Id: chance.Id,
  2089 + Provider: provider,
  2090 + CreateTime: chance.CreateAt.Unix() * 1000,
  2091 + UpdateTime: chance.UpdateAt.Unix() * 1000,
  2092 + }
  2093 + jsonUnmarshal(chance.SourceContent, &item.FormList)
  2094 + jsonUnmarshal(chance.SelfChecks, &item.SelfChecks)
  2095 + item.FormList = clearEmptyForm(item.FormList)
  2096 +
  2097 + if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
  2098 + if len(chanceData.Videos) > 0 {
  2099 + chanceData.Videos = strings.ReplaceAll(chanceData.Videos, "https", "http")
  2100 + }
  2101 + jsonUnmarshal(chanceData.Images, &item.Pictures)
  2102 + jsonUnmarshal(chanceData.Speechs, &item.Speechs)
  2103 + jsonUnmarshal(chanceData.Videos, &item.Videos)
  2104 + }
  2105 + rsp.ChanceDetail = item
  2106 + return
  2107 +}
  2108 +
2046 //机会删除 2109 //机会删除
2047 func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDeleteRequest) (rsp *protocol.ChanceDeleteResponse, err error) { 2110 func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDeleteRequest) (rsp *protocol.ChanceDeleteResponse, err error) {
2048 var ( 2111 var (
@@ -2408,11 +2471,11 @@ func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChan @@ -2408,11 +2471,11 @@ func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChan
2408 commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId) 2471 commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId)
2409 commItem.Chance.ApproveTime = 0 2472 commItem.Chance.ApproveTime = 0
2410 2473
2411 - commItem.Chance.FormList = GetNewestFormList(header, ormItem.ChanceTypeId, ormItem.TemplateId, commItem.Chance.FormList) 2474 + //commItem.Chance.FormList = GetNewestFormList(header, ormItem.ChanceTypeId, ormItem.TemplateId, commItem.Chance.FormList)
2412 if len(ormItem.SelfChecks) > 0 { 2475 if len(ormItem.SelfChecks) > 0 {
2413 utils.JsonUnmarshal(ormItem.SelfChecks, &commItem.Chance.SelfChecks) 2476 utils.JsonUnmarshal(ormItem.SelfChecks, &commItem.Chance.SelfChecks)
2414 } 2477 }
2415 - commItem.Chance.SelfChecks = GetNewestSelfChecks(int64(ormItem.TemplateId), commItem.Chance.SelfChecks) 2478 + //commItem.Questions = GetNewestCheckQuestions(int64(ormItem.TemplateId), commItem.Chance.SelfChecks)
2416 rsp.List = append(rsp.List, commItem) 2479 rsp.List = append(rsp.List, commItem)
2417 } 2480 }
2418 return 2481 return
@@ -2445,31 +2508,20 @@ func getNewestFormList(new []*protocol.Form, old []*protocol.Form) []*protocol.F @@ -2445,31 +2508,20 @@ func getNewestFormList(new []*protocol.Form, old []*protocol.Form) []*protocol.F
2445 } 2508 }
2446 2509
2447 //获取最新的自查列表 2510 //获取最新的自查列表
2448 -func GetNewestSelfChecks(tpId int64, old []protocol.SelfCheck) protocol.SelfChecks {  
2449 - var new []protocol.SelfCheck = make([]protocol.SelfCheck, 0) 2511 +func GetNewestCheckQuestions(tpId int64, old []protocol.SelfCheck) []*protocol.CheckQuestion {
  2512 + var rsp = []*protocol.CheckQuestion{}
2450 if questions, err := agg.GetCheckQuestionsByTemplateId(tpId); err != nil { 2513 if questions, err := agg.GetCheckQuestionsByTemplateId(tpId); err != nil {
2451 log.Error(err) 2514 log.Error(err)
2452 - return old 2515 + return rsp
2453 } else { 2516 } else {
2454 - for i := range questions {  
2455 - q := questions[i]  
2456 - new = append(new, protocol.SelfCheck{  
2457 - Id: q.Id,  
2458 - ParentId: q.ParentId,  
2459 - CheckItem: q.CheckItem,  
2460 - GroupId: q.GroupId,  
2461 - Answer: q.Answer,  
2462 - Reason: q.Reason,  
2463 - })  
2464 - } 2517 + getNewestSelfChecks(questions, old)
  2518 + rsp = questions
2465 } 2519 }
2466 - new = getNewestSelfChecks(new, old)  
2467 - protocol.SelfChecks(new).SetSelfChecksLevel1ByRule()  
2468 - return new 2520 + return rsp
2469 } 2521 }
2470 -func getNewestSelfChecks(new []protocol.SelfCheck, old []protocol.SelfCheck) []protocol.SelfCheck { 2522 +func getNewestSelfChecks(new []*protocol.CheckQuestion, old []protocol.SelfCheck) {
2471 if len(new) == 0 { 2523 if len(new) == 0 {
2472 - return old 2524 + return
2473 } 2525 }
2474 for i := 0; i < len(new); i++ { 2526 for i := 0; i < len(new); i++ {
2475 itemNew := new[i] 2527 itemNew := new[i]
@@ -2482,5 +2534,5 @@ func getNewestSelfChecks(new []protocol.SelfCheck, old []protocol.SelfCheck) []p @@ -2482,5 +2534,5 @@ func getNewestSelfChecks(new []protocol.SelfCheck, old []protocol.SelfCheck) []p
2482 } 2534 }
2483 } 2535 }
2484 } 2536 }
2485 - return new 2537 + return
2486 } 2538 }
  1 +package contrab
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  6 + "net/url"
  7 + "opp/internal/aliyun"
  8 + "strings"
  9 + "testing"
  10 +)
  11 +
  12 +func MyGetURLUploadInfos(client *vod.Client) (response *vod.GetURLUploadInfosResponse, err error) {
  13 + request := vod.CreateGetURLUploadInfosRequest()
  14 +
  15 + // 对URL进行编码
  16 + sourceUrls := []string{
  17 + "http:/mmm-opp-dev.fjmaimaimai.com/file/opp/voice/20200106/1578275187_mxeseTAEQXTH7A7ZK6z4FzZ2YeDwX3Kw.mp3",
  18 + //"http:/mmm-opp-dev.fjmaimaimai.com/file/opp/image/20200106/1578297295_RxJscRHCzQmxeseTAEQXTH7A7ZK6z4Fz.jpg",
  19 + }
  20 + uploadUrls := []string{}
  21 + for _, surl := range sourceUrls {
  22 + encodeUrl := url.QueryEscape(surl)
  23 + uploadUrls = append(uploadUrls, encodeUrl)
  24 + }
  25 +
  26 + // 设置上传的URL列表,用逗号分隔
  27 + request.UploadURLs = strings.Join(uploadUrls, ",")
  28 +
  29 + // 也可以传入jobId查询
  30 + //request.JobIds = "jobId1,jobId2"
  31 +
  32 + request.AcceptFormat = "JSON"
  33 + return client.GetURLUploadInfos(request)
  34 +}
  35 +
  36 +func Test_MyGetURLUploadInfos(t *testing.T) {
  37 + client, err := aliyun.DefaultVodClient()
  38 + if err != nil {
  39 + panic(err)
  40 + }
  41 +
  42 + response, err := MyGetURLUploadInfos(client)
  43 + if err != nil {
  44 + panic(err)
  45 + }
  46 +
  47 + fmt.Println(response.GetHttpContentString())
  48 + fmt.Println(response.NonExists)
  49 + for _, uploadInfo := range response.URLUploadInfoList {
  50 + fmt.Printf("%s: %s %s\n", uploadInfo.UploadURL, uploadInfo.Status, uploadInfo.MediaId)
  51 + }
  52 +}