...
|
...
|
@@ -654,7 +654,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
|
err = protocol.NewErrWithMessage(5301)
|
|
|
return
|
|
|
}
|
|
|
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
|
|
|
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover, SelfCheckNeed: template.SelfCheckNeed}
|
|
|
|
|
|
CheckChanceDifferent(header, chance, request)
|
|
|
|
...
|
...
|
@@ -797,11 +797,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate |
|
|
|
|
|
//检查机会更新
|
|
|
func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, request *protocol.ChanceUpdateRequest) {
|
|
|
var (
|
|
|
isSaveLog bool = false
|
|
|
chanceReviseLog *models.ChanceReviseLog
|
|
|
message string
|
|
|
)
|
|
|
defer func() {
|
|
|
if p := recover(); p != nil {
|
|
|
log.Error(p)
|
...
|
...
|
@@ -813,49 +808,76 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
|
if chance.ReviewStatus != protocol.ReviewStatusPass {
|
|
|
return
|
|
|
}
|
|
|
var modifyLog = protocol.ChanceReviseLog{
|
|
|
RemoveAllPhotoVideo: false,
|
|
|
RemoveAllSpeech: false,
|
|
|
}
|
|
|
checkIsSaveLog := func() {
|
|
|
|
|
|
var (
|
|
|
isSaveLog bool = false
|
|
|
modifyLog = protocol.ChanceReviseLog{
|
|
|
RemoveAllPhotoVideo: false,
|
|
|
RemoveAllSpeech: false,
|
|
|
}
|
|
|
)
|
|
|
funcCheckSave := func() {
|
|
|
if !isSaveLog {
|
|
|
isSaveLog = true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
diffFormList := func(source string, dis []*protocol.Form) {
|
|
|
funcDiffForms := func(source string, src []*protocol.Form) {
|
|
|
var (
|
|
|
src []*protocol.Form
|
|
|
mapForm map[string]*protocol.Form = make(map[string]*protocol.Form)
|
|
|
dst []*protocol.Form
|
|
|
mapForm = make(map[string]*protocol.Form)
|
|
|
reviseContents []protocol.ReviseContent
|
|
|
)
|
|
|
jsonUnmarshal(source, &src)
|
|
|
keyFunc := func(form *protocol.Form) string {
|
|
|
utils.JsonUnmarshal(source, &dst)
|
|
|
funcKey := func(form *protocol.Form) string {
|
|
|
return fmt.Sprintf("%v_%v", form.Label, form.SectionType)
|
|
|
}
|
|
|
for i := range src {
|
|
|
mapForm[keyFunc(src[i])] = src[i]
|
|
|
for i := range dst {
|
|
|
mapForm[funcKey(dst[i])] = dst[i]
|
|
|
}
|
|
|
for i := range dis {
|
|
|
isDiff := false
|
|
|
srcValue := ""
|
|
|
if v, ok := mapForm[keyFunc(dis[i])]; ok {
|
|
|
for i := range src {
|
|
|
var (
|
|
|
isDiff = false
|
|
|
oldForm *protocol.Form
|
|
|
srcValue = ""
|
|
|
)
|
|
|
|
|
|
if v, ok := mapForm[funcKey(src[i])]; ok {
|
|
|
srcValue = v.Value
|
|
|
if dis[i].Value != v.Value {
|
|
|
if src[i].Value != v.Value {
|
|
|
isDiff = true
|
|
|
}
|
|
|
if len(src[i].Data) > 0 {
|
|
|
if !reflect.DeepEqual(src[i].Data, v.Data) {
|
|
|
isDiff = true
|
|
|
}
|
|
|
}
|
|
|
oldForm = v
|
|
|
} else {
|
|
|
isDiff = true
|
|
|
}
|
|
|
|
|
|
if isDiff {
|
|
|
reviseContents = append(reviseContents, protocol.ReviseContent{
|
|
|
Content: fmt.Sprintf("将“%v”由“%v”改为 “%v”", dis[i].Label, srcValue, dis[i].Value)})
|
|
|
checkIsSaveLog()
|
|
|
c := protocol.ReviseContent{
|
|
|
Content: fmt.Sprintf("将“%v”由“%v”改为 “%v”", src[i].Label, srcValue, src[i].Value),
|
|
|
Label: src[i].Label,
|
|
|
InputType: src[i].InputType,
|
|
|
Data: src[i].Data,
|
|
|
}
|
|
|
|
|
|
//文件表单
|
|
|
if src[i].InputType == protocol.InputFiles {
|
|
|
if oldForm != nil && len(oldForm.Data) > 0 && len(src[i].Data) == 0 {
|
|
|
c.RemoveAllPhotoVideo = true
|
|
|
}
|
|
|
c.Content = fmt.Sprintf("将%v修改为:", src[i].Label)
|
|
|
}
|
|
|
reviseContents = append(reviseContents, c)
|
|
|
funcCheckSave()
|
|
|
}
|
|
|
}
|
|
|
modifyLog.DiffContents = reviseContents
|
|
|
}
|
|
|
diffChanceData := func() {
|
|
|
funcDiffChanceData := func() {
|
|
|
var (
|
|
|
speechs []protocol.Speech
|
|
|
pictures []protocol.Picture
|
...
|
...
|
@@ -866,12 +888,12 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
|
jsonUnmarshal(chanceData.Images, &pictures)
|
|
|
jsonUnmarshal(chanceData.Videos, &videos)
|
|
|
if !reflect.DeepEqual(request.Videos, videos) || !reflect.DeepEqual(request.Pictures, pictures) {
|
|
|
checkIsSaveLog()
|
|
|
funcCheckSave()
|
|
|
modifyLog.Videos = request.Videos
|
|
|
modifyLog.Pictures = request.Pictures
|
|
|
}
|
|
|
if !reflect.DeepEqual(request.Speechs, speechs) {
|
|
|
checkIsSaveLog()
|
|
|
funcCheckSave()
|
|
|
modifyLog.Speechs = request.Speechs
|
|
|
}
|
|
|
|
...
|
...
|
@@ -888,16 +910,13 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
|
modifyLog.RemoveAllSpeech = true
|
|
|
}
|
|
|
} else {
|
|
|
checkIsSaveLog()
|
|
|
funcCheckSave()
|
|
|
modifyLog.Speechs = request.Speechs
|
|
|
modifyLog.Videos = request.Videos
|
|
|
modifyLog.Speechs = request.Speechs
|
|
|
}
|
|
|
}
|
|
|
|
|
|
diffFormList(chance.SourceContent, request.FormList)
|
|
|
diffChanceData()
|
|
|
checkModifyLog := func() {
|
|
|
funcFormatEmpty := func() {
|
|
|
if len(modifyLog.Speechs) == 0 {
|
|
|
modifyLog.Speechs = make([]protocol.Speech, 0)
|
|
|
}
|
...
|
...
|
@@ -911,49 +930,61 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, |
|
|
modifyLog.DiffContents = make([]protocol.ReviseContent, 0)
|
|
|
}
|
|
|
}
|
|
|
checkModifyLog()
|
|
|
if isSaveLog { //&& changeCount > 0
|
|
|
orm := orm.NewOrm()
|
|
|
orm.Begin()
|
|
|
var logId int64
|
|
|
//发送日志
|
|
|
if id, err := agg.SaveApproveLogResult(orm, 10, header.UserId, chance.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
} else {
|
|
|
logId = id
|
|
|
}
|
|
|
//保存修改详情
|
|
|
chanceReviseLog = &models.ChanceReviseLog{
|
|
|
Id: idgen.Next(),
|
|
|
ChanceId: chance.Id,
|
|
|
UserCompanyId: header.UserId,
|
|
|
Data: common.AssertJson(modifyLog),
|
|
|
CreateAt: time.Now(),
|
|
|
AuditFlowLogId: logId,
|
|
|
}
|
|
|
if _, e := orm.Insert(chanceReviseLog); e != nil {
|
|
|
log.Error(e)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
if chanceType, err := models.GetChanceTypeById(chance.ChanceTypeId); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
} else {
|
|
|
message = fmt.Sprintf(protocol.MessageChanceRevise, chanceType.Name)
|
|
|
}
|
|
|
//发送修改机会消息
|
|
|
if err := agg.SendMsgWithHeader(header, chance.UserId, "", chanceReviseLog.Id, protocol.SourceTypeChanceReviseLog, message, protocol.MsgTypeChanceRevise, chance.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
orm.Commit()
|
|
|
funcDiffForms(chance.SourceContent, request.FormList) //比对表单
|
|
|
funcDiffChanceData() //比对机会数据
|
|
|
funcFormatEmpty() //格式化变更日志
|
|
|
if isSaveLog {
|
|
|
_ = SaveChanceReviseLog(header, chance, modifyLog)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//保存机会变更日志
|
|
|
func SaveChanceReviseLog(header *protocol.RequestHeader, chance *models.Chance, modifyLog protocol.ChanceReviseLog) (err error) {
|
|
|
var (
|
|
|
chanceReviseLog *models.ChanceReviseLog
|
|
|
message string
|
|
|
)
|
|
|
orm := orm.NewOrm()
|
|
|
orm.Begin()
|
|
|
var logId int64
|
|
|
//发送日志
|
|
|
if id, err := agg.SaveApproveLogResult(orm, 10, header.UserId, chance.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
} else {
|
|
|
logId = id
|
|
|
}
|
|
|
//保存修改详情
|
|
|
chanceReviseLog = &models.ChanceReviseLog{
|
|
|
Id: idgen.Next(),
|
|
|
ChanceId: chance.Id,
|
|
|
UserCompanyId: header.UserId,
|
|
|
Data: common.AssertJson(modifyLog),
|
|
|
CreateAt: time.Now(),
|
|
|
AuditFlowLogId: logId,
|
|
|
}
|
|
|
if _, e := orm.Insert(chanceReviseLog); e != nil {
|
|
|
log.Error(e)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
if chanceType, err := models.GetChanceTypeById(chance.ChanceTypeId); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
} else {
|
|
|
message = fmt.Sprintf(protocol.MessageChanceRevise, chanceType.Name)
|
|
|
}
|
|
|
//发送修改机会消息
|
|
|
if err := agg.SendMsgWithHeader(header, chance.UserId, "", chanceReviseLog.Id, protocol.SourceTypeChanceReviseLog, message, protocol.MsgTypeChanceRevise, chance.Id); err != nil {
|
|
|
log.Error(err)
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
orm.Commit()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//修改公开状态
|
...
|
...
|
@@ -1627,6 +1658,8 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ |
|
|
jsonUnmarshal(chance.Images, &item.Pictures)
|
|
|
jsonUnmarshal(chance.Voices, &item.Speechs)
|
|
|
jsonUnmarshal(chance.Videos, &item.Videos)
|
|
|
item.Pictures, item.Videos = agg.CombineAllFiles(item.FormList, item.Pictures, item.Videos)
|
|
|
item.FormList = agg.FormFilter(item.FormList, agg.ClearEmptyForm, agg.ClearFilesForm)
|
|
|
commItem.Chance = item
|
|
|
|
|
|
//点赞评论数据
|
...
|
...
|
|