作者 yangfu

公告修改

... ... @@ -37,7 +37,7 @@ user_center_app_key ="39aefef9e22744a3b2d2d3791824ae7b"
user_center_app_secret ="cykbjnfqgctn"
#Html5
h5_host = "https://mmm-web-open-test.fjmaimaimai.com"
h5_host = "http://mmm-web-open-test.fjmaimaimai.com"
#审核中心
suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com"
\ No newline at end of file
... ...
... ... @@ -81,6 +81,14 @@ func (this *BaseController) Resp(msg *protocol.ResponseMessage) {
this.ServeJSON()
}
func (this *BaseController) RespH5(msg *protocol.ResponseMessage) {
if msg.Errno != 0 {
msg.Errno = -1
}
this.Data["json"] = msg
this.ServeJSON()
}
//获取请求头信息
func GetRequestHeader(ctx *context.Context) *protocol.RequestHeader {
h := &protocol.RequestHeader{}
... ...
... ... @@ -17,7 +17,7 @@ type H5Controller struct {
func (this *H5Controller) Announcement() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
this.RespH5(msg)
}()
var request *protocol.AnnouncementRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
... ... @@ -38,7 +38,7 @@ func (this *H5Controller) Announcement() {
func (this *H5Controller) AnnouncementSubmit() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
this.RespH5(msg)
}()
var request *protocol.AnnouncementSubmitRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
... ... @@ -59,7 +59,7 @@ func (this *H5Controller) AnnouncementSubmit() {
func (this *H5Controller) ChanceExample() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
this.RespH5(msg)
}()
var request *protocol.ChanceExampleRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
... ...
... ... @@ -175,14 +175,14 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag
}
//获取机会消息
func GetChanceMsg(uid, cid int64, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) {
func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) {
sql := `select a.*,b.images,b.speechs,b.videos from (
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id from (
select id,company_id,receive_user_id,message,source_id,create_time,is_read
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from (
select id,company_id,receive_user_id,message,source_id,is_read
from user_msg where receive_user_id=? and source_type=1 and (?=0 or id>?) and msg_type=?
)a left outer join chance b on a.source_id = b.id
)a left outer join chance_data b on a.source_id =b.chance_id
order by a.create_time desc
order by a.create_at desc
LIMIT ?`
sqlCount := `select count(0)
... ...
... ... @@ -95,13 +95,6 @@ func NewReturnResponse(data interface{}, eRR error) *ResponseMessage {
msg.Data = data
return msg
}
//if x,ok :=eRR.(*ErrWithMessage);ok{
// if x.ErrorCode.Errno==0{
// msg = x.ParseToMessage()
// msg.Data = data
// }
// return msg
//}
// fmt.Println("日志:" + eRR.Error())
if x, ok := eRR.(CustomErrParse); ok {
msg = x.ParseToMessage()
... ...
... ... @@ -214,7 +214,8 @@ type MsgChanceApproveItemOrm struct {
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
//ReviewStatus int `orm:"column(review_status)"`
ReviewStatus int `orm:"column(review_status)"`
ApproveData string `orm:"column(approve_data)"` //审核数据
Id int64 `orm:"column(id)"` //消息id
ReceiveUserId int64 `orm:"column(receive_user_id)"`
... ...
... ... @@ -289,6 +289,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgChanceApprove",
Router: `/msgChanceApprove`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgCompanyNotice",
Router: `/msgCompanyNotice`,
AllowHTTPMethods: []string{"post"},
... ...
... ... @@ -202,3 +202,17 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq
Sql: sql.String(),
}
}
//清楚未填写的表单数据
func ClearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) {
if len(inputFormList) == 0 {
return
}
for i := range inputFormList {
item := inputFormList[i]
if len(item.Value) > 0 {
FormList = append(FormList, item)
}
}
return
}
... ...
... ... @@ -190,7 +190,7 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceMsg(header.UserId, header.CompanyId, request.LastId, request.PageSize, protocol.MsgTypeAudit, &myChances); err != nil {
if total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAudit, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ... @@ -198,26 +198,44 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
log.Error(err)
return
}
if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil {
log.Error(err)
return
}
rsp = &protocol.MsgChanceApproveResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
item := protocol.ChanceItem{
Id: chance.Id,
Provider: provider,
//CreateTime: chance.CreateTime.Unix() * 1000,
commItem.ReviewStatus = chance.ReviewStatus
if len(chance.SourceContent) == 0 { //机会删除
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
continue
} else {
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = agg.ClearEmptyForm(item.FormList)
utils.JsonUnmarshal(chance.Images, &item.Pictures)
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
utils.JsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
utils.JsonUnmarshal(chance.Images, &item.Pictures)
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
utils.JsonUnmarshal(chance.Videos, &item.Videos)
{
commItem.Chance = item
if chance.ReviewStatus == protocol.ReviewStatusPass {
var approveData *protocol.ApproveData
utils.JsonUnmarshal(chance.ApproveData, &approveData)
if approveData != nil {
commItem.Score = approveData.Score
}
}
//审核完有审核数据
commItem.Message = chance.Message
rsp.List = append(rsp.List, commItem)
}
return
... ... @@ -226,12 +244,12 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
//H5公告详情
func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) {
var (
bulletin *models.Bulletin
question *models.BulletinQuestion
userMsg *models.UserMsg
bulletinAnswer *models.BulletinQuestionAnswer
setRead bool = false
answer *protocol.Answer
bulletin *models.Bulletin
question *models.BulletinQuestion
userMsg *models.UserMsg
//bulletinAnswer *models.BulletinQuestionAnswer
setRead bool = false
answer *protocol.Answer
)
if bulletin, err = models.GetBulletinById(request.Id); err != nil {
log.Error(err.Error())
... ... @@ -268,10 +286,11 @@ func H5Announcement(header *protocol.RequestHeader, request *protocol.Announceme
}
//获取回答详情数据
if bulletinAnswer, err = models.GetBulletinQuestionAnswerBy(request.Id, int64(request.Uid)); err == nil {
if bulletinAnswer, e := models.GetBulletinQuestionAnswerBy(request.Id, int64(request.Uid)); e == nil {
if len(bulletinAnswer.Answer) != 0 {
if err = json.Unmarshal([]byte(bulletinAnswer.Answer), &answer); err != nil {
log.Error(err)
log.Error(e)
return
} else {
rsp.Announcement.EditContent = answer.EditContent
rsp.Announcement.VoteResults = answer.VoteResults
... ...