...
|
...
|
@@ -408,9 +408,9 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit |
|
|
AuditLevel: 1,
|
|
|
ReviewStatus: protocol.ReviewStatusAuditging,
|
|
|
DepartmentId: request.RelatedDepartment,
|
|
|
Code: fmt.Sprintf("%v%v", chanceType.Code, template.Code),
|
|
|
Status: models.ChanceStatusOpen,
|
|
|
SelfChecks: common.AssertJson(request.SelfChecks),
|
|
|
//Code: fmt.Sprintf("%v%v", chanceType.Code, template.Code),
|
|
|
Status: models.ChanceStatusOpen,
|
|
|
SelfChecks: common.AssertJson(request.SelfChecks),
|
|
|
}
|
|
|
//生成提交记录
|
|
|
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header.UserId, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil {
|
...
|
...
|
@@ -2253,3 +2253,131 @@ func CheckQuestions(header *protocol.RequestHeader, request *protocol.CheckQuest |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//机会保存到草稿箱
|
|
|
func DraftSaveChance(header *protocol.RequestHeader, request *protocol.DraftSaveChanceRequest) (rsp *protocol.DraftSaveChanceResponse, err error) {
|
|
|
var (
|
|
|
template *models.AuditTemplate
|
|
|
chanceData *models.ChanceData
|
|
|
chance *models.ChanceDraft
|
|
|
)
|
|
|
rsp = &protocol.DraftSaveChanceResponse{}
|
|
|
|
|
|
//1.模板是否存在
|
|
|
if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil {
|
|
|
log.Error("模板不存在:", request.AuditTemplateId, err)
|
|
|
return
|
|
|
}
|
|
|
if _, err = models.GetChanceTypeById(template.ChanceTypeId); err != nil {
|
|
|
log.Error("一级分类不存在:", request.AuditTemplateId, err)
|
|
|
return
|
|
|
}
|
|
|
//2.检查模板是否有权限
|
|
|
if request.Id > 0 {
|
|
|
//更新机会
|
|
|
if chance, err = models.GetChanceDraftById(request.Id); err != nil {
|
|
|
err = protocol.NewCustomMessage(1, "该机会已不存在")
|
|
|
return
|
|
|
}
|
|
|
chance.SourceContent = common.AssertJson(request.FormList)
|
|
|
chance.UpdateAt = time.Now()
|
|
|
chance.DepartmentId = request.RelatedDepartment
|
|
|
if err = models.UpdateChanceDraftById(chance); err != nil {
|
|
|
err = protocol.NewCustomMessage(1, "该机会已不存在")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//更新机会数据
|
|
|
if chanceData, err = models.GetChanceDataByChanceId(request.Id); err != nil {
|
|
|
err = protocol.NewCustomMessage(1, "该机会已不存在")
|
|
|
return
|
|
|
}
|
|
|
chanceDataMap := map[string]interface{}{
|
|
|
"Speechs": common.AssertJson(request.Speechs),
|
|
|
"Images": common.AssertJson(request.Pictures),
|
|
|
"Videos": common.AssertJson(request.Videos),
|
|
|
"UpdateAt": time.Now(),
|
|
|
}
|
|
|
if err = utils.UpdateTableByMap(chanceData, chanceDataMap); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
//3.添加机会 添加文件
|
|
|
chance = &models.ChanceDraft{
|
|
|
Id: idgen.Next(),
|
|
|
UserId: header.UserId,
|
|
|
CompanyId: header.CompanyId,
|
|
|
ChanceTypeId: template.ChanceTypeId,
|
|
|
AuditTemplateId: template.Id,
|
|
|
SourceContent: common.AssertJson(request.FormList),
|
|
|
EnableStatus: 1,
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
DepartmentId: request.RelatedDepartment,
|
|
|
}
|
|
|
if _, err = models.AddChanceDraft(chance); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
data := &models.ChanceData{
|
|
|
Id: idgen.Next(),
|
|
|
ChanceId: chance.Id,
|
|
|
Speechs: common.AssertJson(request.Speechs),
|
|
|
Images: common.AssertJson(request.Pictures),
|
|
|
Videos: common.AssertJson(request.Videos),
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
}
|
|
|
if _, err = models.AddChanceData(data); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//草稿删除(清空)
|
|
|
func DraftDelete(header *protocol.RequestHeader, request *protocol.DraftDeleteRequest) (rsp *protocol.DraftDeleteResponse, err error) {
|
|
|
var (
|
|
|
sql string
|
|
|
)
|
|
|
rsp = &protocol.DraftDeleteResponse{}
|
|
|
sql = fmt.Sprintf(models.DeleteChanceDraft, header.UserId, request.Id)
|
|
|
if request.Id < 0 {
|
|
|
sql = fmt.Sprintf(models.DeleteAllChanceDraft, header.UserId)
|
|
|
}
|
|
|
o := orm.NewOrm()
|
|
|
if err = utils.ExecuteSQLWithOrmer(o, sql); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//草稿箱-机会列表
|
|
|
func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChanceRequest) (rsp *protocol.DraftByChanceResponse, err error) {
|
|
|
var (
|
|
|
ormItems []protocol.DraftChanceItemOrm
|
|
|
)
|
|
|
rsp = &protocol.DraftByChanceResponse{}
|
|
|
rsp.List = make([]protocol.CommonListItem, 0)
|
|
|
if rsp.Total, err = models.GetDraftByChance(header.UserId, request.Offset(), request.PageSize, &ormItems); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
err = nil
|
|
|
return
|
|
|
}
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
for i := 0; i < len(ormItems); i++ {
|
|
|
ormItem := ormItems[i]
|
|
|
commItem := agg.NewCommonListItem(header, ormItem.CommChanceItemOrm)
|
|
|
commItem.Chance.CreateTime = ormItem.UpdateTime.Unix() * 1000
|
|
|
commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId)
|
|
|
commItem.Chance.ApproveTime = 0
|
|
|
|
|
|
rsp.List = append(rsp.List, commItem)
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|