作者 yangfu

Merge remote-tracking branch 'origin/dev' into test

... ... @@ -28,16 +28,20 @@
|功能|完成状态|时间|接口路径
|---|---|----|----|
|我的机会-我提交的| | |/v1/chance/mySubmitChance|
|机会详情| | |v1/chance/detail|
|机会更新| | | |
|机会删除| | |/v1/chance/delete|
|我的机会-我的审核| | | |
|机会审核| | | /v1/chance/approve|
|机会修改评分| | |/v1/chance/changeScore|
|机会修改公开状态| | |/v1/chance/changePublish|
|计算发现分| | |/v1/chance/calculateScore|
|用户机会权限| | | |
|机会池| | | |
|我的机会-我的审核| | |/v1/chance/myApproveChance|
|机会-详情| | |v1/chance/detail|
|机会-更新| | | |
|机会-删除| | |/v1/chance/delete|
|机会-审核| | | /v1/chance/approve|
|机会-修改评分| | |/v1/chance/changeScore|
|机会-修改公开状态| | |/v1/chance/changePublish|
|机会-计算发现分| | |/v1/chance/calculateScore|
|配置-用户机会权限| | | |
|配置-评分| | |v1/config/score|
|消息-机会审核消息| | | |
|机会池| | |/v1/chance/chancePool|
|我的机会-我的收藏| | |/v1/chance/|
|我的机会-我的点赞| | |/v1/chance/|
|消息-点赞| | |v1/message/msgInteractive|
|消息-评论| | |v1/message/msgInteractive|
|机会评论列表| | |/v1/chance/comments|
... ... @@ -49,12 +53,5 @@
|我的评论|完成|2019.11.21|/v1/chance/iComments|
|我来评论|完成|2019.11.21|/v1/chance/iComment|
|机会审核消息| | |v1/message/msgInteractive|
|我提交的机会| | | v1/chance/chances|
|我审核的机会| | | v1/chance/chances|
|机会详情| | | |
|待抓住机会列表| | |v1/chance/chances|
|配置-评分| | |v1/config/score|
|机会审核| | |v1/chance/audit|
|机会修改评分| | |v1/chance/editScore|
|机会修改公开状态| | |v1/chance/editStatus|
... ...
... ... @@ -40,4 +40,4 @@ user_center_app_secret ="cykbjnfqgctn"
h5_host = "http://mmm-web-open-test.fjmaimaimai.com"
#审核中心
suplus_host ="http://suplus-approve-dev.fjmaimaimai.com"
\ No newline at end of file
suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com"
\ No newline at end of file
... ...
... ... @@ -40,4 +40,4 @@ user_center_app_secret ="cykbjnfqgctn"
h5_host = "http://mmm-web-open-test.fjmaimaimai.com"
#审核中心
suplus_host ="http://suplus-approve-test.fjmaimaimai.com"
\ No newline at end of file
suplus_approve_host ="http://suplus-approve-test.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 {
... ...
... ... @@ -185,6 +185,27 @@ func (this *ChanceController) ChanceType() {
msg = protocol.NewReturnResponse(chance.ChanceType(header, request))
}
//Permission 机会权限
//@router /permission [post]
func (this *ChanceController) Permission() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ChancePermissionRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChancePermission(header, request))
}
//Templates
//@router /templates [post]
func (this *ChanceController) Templates() {
... ... @@ -231,7 +252,7 @@ func (this *ChanceController) ChanceSubmit() {
msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request))
}
//ChanceStatistics
//ChanceStatistics 机会统计
//@router /statistics [post]
func (this *ChanceController) ChanceStatistics() {
var msg *protocol.ResponseMessage
... ... @@ -273,6 +294,27 @@ func (this *ChanceController) MySubmitChance() {
msg = protocol.NewReturnResponse(chance.MySubmitChance(header, request))
}
//ChancePool 机会池
//@router /chancePool [post]
func (this *ChanceController) ChancePool() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ChancePoolRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}
//ChanceDetail 机会详情
//@router /chanceDetail [post]
func (this *ChanceController) ChanceDetail() {
... ...
package v1
import (
"encoding/json"
"opp/controllers"
"opp/protocol"
"opp/services/config"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
)
//BulletinController 公告
type ConfigController struct {
controllers.BaseController
}
//GetConfigScore
//@router /score/get [post]
func (this *ConfigController) GetConfigScore() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.GetConfigScoreRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(config.GetConfigScore(header, request))
}
... ...
... ... @@ -158,3 +158,24 @@ func (this *MessageController) MsgCompanyNotice() {
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(message.MsgCompanyNotice(header, request))
}
//MsgChanceApprove 机会审核消息
//@router /msgChanceApprove [post]
func (this *MessageController) MsgChanceApprove() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MsgChanceApproveRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(message.MsgChanceApprove(header, request))
}
... ...
... ... @@ -150,7 +150,7 @@ func ExecuteQueryOneWithOrmer(o orm.Ormer, result interface{}, sqlstr string, pa
//ExecuteQuerySql 执行原生sql查询多条记录
func ExecuteQueryAll(result interface{}, sqlstr string, param ...interface{}) error {
PrintLogSql(sqlstr, param...)
//PrintLogSql(sqlstr, param...)
var err error
o := orm.NewOrm()
err = ExecuteQueryAllWithOrmer(o, result, sqlstr, param)
... ...
package utils
import (
"encoding/json"
"errors"
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"reflect"
"strings"
)
... ... @@ -74,3 +76,12 @@ func IsNil(i interface{}) bool {
}
return false
}
func JsonUnmarshal(jsonData string, v interface{}) {
if len(jsonData) == 0 {
return
}
if e := json.Unmarshal([]byte(jsonData), v); e != nil {
log.Error("json.unmarshal error data:", jsonData, e)
}
}
... ...
... ... @@ -30,6 +30,8 @@ type AuditFlowProcess struct {
UserName string `orm:"column(user_name);size(50)" description:"用户名-冗余"`
RoleName string `orm:"column(role_name);size(50)" description:"角色名-冗余"`
RoleId int `orm:"column(role_id);size(50)" description:"角色id-冗余"`
ApproveMessage string `orm:"column(approve_message);size(50)" description:"审核消息-冗余"`
TemplateId int `orm:"column(template_id);size(50)" description:"模板编号-冗余"`
}
func (t *AuditFlowProcess) TableName() string {
... ...
... ... @@ -103,18 +103,18 @@ func DeleteChance(id int64) (err error) {
func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := `select a.*,b.images,speechs,videos
from (
select id,user_id,create_at,source_content from chance
select id,user_id,create_at,source_content,approve_data,review_status from chance
where user_id=? and company_id=? and review_status in (?) and (?=0 or id>?)
order by create_at desc
limit ?
) a left JOIN chance_data b on a.id =b.chance_id`
sqlCount := `select count(0) from (
sqlCount := fmt.Sprintf(`select count(0) from (
select id,user_id,create_at,source_content from chance
where user_id=? and company_id=? and review_status in (?)
where user_id=? and company_id=? and review_status in (%v)
order by create_at desc
) a left JOIN chance_data b on a.id =b.chance_id`
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid, utils.JoinInt8s(reviewStatus, ",")); err != nil {
) a left JOIN chance_data b on a.id =b.chance_id`, utils.JoinInt8s(reviewStatus, ","))
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil {
return
}
if v != nil {
... ... @@ -126,22 +126,48 @@ order by create_at desc
}
func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := `select a.*,b.images,b.speechs,b.videos from (
select a.*,b.user_id,b.source_content,b.enable_status from (
select id,approve_time,approve_data,uid,chance_id
from audit_flow_process where uid=? and enable_status =1 and review_status in (?) and (?=0 or id>?)
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
select a.*,b.user_id,b.source_content,b.enable_status,b.review_status from (
select id,approve_time,approve_data,uid,chance_id,approve_message,create_at process_create_time
from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) and (?=0 or id>?)
)a left outer join chance b on a.chance_id = b.id
)a left outer join chance_data b on a.chance_id =b.chance_id
order by a.approve_time desc
LIMIT ?`
order by process_create_time desc
LIMIT ?`, utils.JoinInt8s(reviewStatus, ","))
sqlCount := fmt.Sprintf(`select count(0)
from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) `, utils.JoinInt8s(reviewStatus, ","))
if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil {
return
}
}
return
}
sqlCount := `select count(0)
from audit_flow_process where uid=? and enable_status =1 and review_status in (?) `
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, utils.JoinInt8s(reviewStatus, ",")); err != nil {
func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := `select a.*,b.images,speechs,videos
from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
where user_id=? and company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1
order by create_at desc
limit ?
) a left JOIN chance_data b on a.id =b.chance_id`
//if public==protocol.pu
sqlCount := fmt.Sprintf(`select count(0) from (
select id from chance
where user_id=? and company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
order by create_at desc
) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, utils.JoinInt8s(reviewStatus, ","), lastId, lastId, pageSize); err != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
return
}
}
... ...
package models
import (
"fmt"
"time"
"github.com/astaxie/beego/orm"
)
type SysConfig struct {
Id int `orm:"column(id);auto" description:"唯一编号"`
Key string `orm:"column(key);size(50);null" description:"自定义键值 score:评分模式配置"`
Content string `orm:"column(content);size(1000);null" description:"配置内容 json"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null"`
CompanyId int `orm:"column(company_id);null" description:"公司编号"`
}
func (t *SysConfig) TableName() string {
return "sys_config"
}
func init() {
orm.RegisterModel(new(SysConfig))
}
var (
KeyScore = "score"
)
// AddSysConfig insert a new SysConfig into database and returns
// last inserted Id on success.
func AddSysConfig(m *SysConfig) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetSysConfigById retrieves SysConfig by Id. Returns error if
// Id doesn't exist
func GetSysConfigById(id int) (v *SysConfig, err error) {
o := orm.NewOrm()
v = &SysConfig{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// UpdateSysConfig updates SysConfig by Id and returns error if
// the record to be updated doesn't exist
func UpdateSysConfigById(m *SysConfig) (err error) {
o := orm.NewOrm()
v := SysConfig{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Update(m); err == nil {
fmt.Println("Number of records updated in database:", num)
}
}
return
}
// DeleteSysConfig deletes SysConfig by Id and returns error if
// the record to be deleted doesn't exist
func DeleteSysConfig(id int) (err error) {
o := orm.NewOrm()
v := SysConfig{Id: id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Delete(&SysConfig{Id: id}); err == nil {
fmt.Println("Number of records deleted in database:", num)
}
}
return
}
func GetSysConfigByCompanyId(cid int, key string) (v *SysConfig, err error) {
o := orm.NewOrm()
sql := "select * from sys_config where `key`=? and company_id=?"
if err = o.Raw(sql, key, cid).QueryRow(&v); err == nil {
return v, nil
}
return nil, err
}
... ...
... ... @@ -173,3 +173,27 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag
}
return
}
//获取机会消息
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,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_at desc
LIMIT ?`
sqlCount := `select count(0)
from user_msg where receive_user_id=? and source_type=1 and msg_type=? `
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, msgType); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, msgType, pageSize); err != nil {
return
}
}
return
}
... ...
... ... @@ -39,6 +39,7 @@ const (
ReviewStatusReturn = 2 //退回
ReviewStatusPass = 3 //通过
ReviewStatusSubmit = 4 //提交
ReviewStatusAuditg = 5 //审批中
)
//公开状态
... ... @@ -48,7 +49,12 @@ const (
PublicToCompany = 2 //公司公开
)
/*Favorite */
const (
ChanceStatusDelete = 1 //删除
ChanceStatusClose = 2 //关闭
)
/*Favorite 我的收藏/点赞*/
type FavoriteRequest struct {
ObjectType int `json:"object_type" valid:"Required"` //收藏 点赞
ChanceType int `json:"chance_type" valid:"Required"`
... ... @@ -61,29 +67,7 @@ type FavoriteResponse struct {
Lists []*ChanceFavorite `json:"lists"`
}
type ChanceFavorite struct {
Id int64 `json:"id"`
Favorite interface{} `json:"favorite"`
}
type ChanceDetail struct {
Id int64 `json:"id"`
Provider *BaseUserInfo `json:"provider"`
IsCollect bool `json:"is_collect"`
IsZan bool `json:"is_zan"`
Content string `json:"content"`
ChanceType int `json:"chance_type"`
//图片
//视频
//语音
ViewTotal int `json:"view_total"`
CommentTotal int `json:"comment_total"`
ZanTotal int `json:"zan_total"`
}
/*SympathyAction */
/*SympathyAction 点赞,收藏*/
type SympathyActionRequest struct {
MarkType int `json:"mark_type" valid:"Required"` // 1.赞 2.收藏
SourceType int `json:"source_type" valid:"Required"` //protocol.SourceType //机会 评论
... ... @@ -108,27 +92,7 @@ type TemplatesResponse struct {
Templates []*Template `json:"list"`
}
//模板
type Template struct {
Id int64 `json:"id"`
Name string `json:"name"`
Doc string `json:"doc"`
Icon string `json:"icon"`
FormList []*Form `json:"formList"`
Link string `json:"link"` //示例
}
//表单
type Form struct {
Id int `json:"id"`
Label string `json:"label"`
InputType string `json:"inputType"`
SectionType int8 `json:"sectionType"`
Value string `json:"value"`
Required int8 `json:"required"`
}
/*ChanceExample*/
/*ChanceExample 机会示例*/
type ChanceExampleRequest struct {
TemplateId int `json:"templateId" valid:"Required"`
}
... ... @@ -136,6 +100,7 @@ type ChanceExampleResponse struct {
Content string `json:"content"`
}
/*提交机会*/
type ChanceSubmitRequest struct {
Id int64 `json:"id"` // = 0添加 >0 编辑
AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"`
... ... @@ -146,29 +111,9 @@ type ChanceSubmitRequest struct {
Videos []Video `json:"videos"`
RelatedDepartment int64 `json:"relatedDepartments" valid:"Required"`
}
type ChanceSubmitResponse struct {
}
type Speech struct {
Path string `json:"path"`
Duration int `json:"duration"`
}
type Picture struct {
Path string `json:"path"`
W int `json:"w"`
H int `json:"h"`
}
type Video struct {
Path string `json:"path"`
Cover Cover `json:"cover"` //封面
Duration int `json:"duration"`
}
type AuditConfig struct {
NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】
}
/*ChanceStatistics 首页-机会池统计*/
type ChanceStatisticsRequest struct {
}
... ... @@ -177,12 +122,6 @@ type ChanceStatisticsResponse struct {
List []ChanceTotalItem `json:"list"`
}
type ChanceTotalItem struct {
Id int `json:"id"` //类型
Name string `json:"name"` //总数
Total int `json:"total"`
}
/*MyChance 我的机会*/
type MySubmitChanceRequest struct {
LastId int64 `json:"lastId"`
... ... @@ -190,33 +129,29 @@ type MySubmitChanceRequest struct {
ReviewStatus int8 `json:"reviewStatus"` //审核状态
}
type MySubmitChanceResponse struct {
List []ChanceItem `json:"list"`
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
/*MyApproveChance 我审核的机会*/
type MyApproveChanceRequest struct {
/*ChancePool 机会池*/
type ChancePoolRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
ReviewStatus int8 `json:"reviewStatus"` //审核状态
ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会
}
type MyApproveChanceResponse struct {
type ChancePoolResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//机会列表 通用项
type CommonListItem struct {
Chance ChanceItem `json:"chance,omitempty"` //机会详情
ChanceData ChanceData `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)
Approve Approve `json:"approve,omitempty"` //审核人 审核信息(时间)
ApproveData ApproveData `json:"ApproveData"` //审核数据(公开状态 评分)
Message interface{} `json:"message,omitempty"`
Comment interface{} `json:"comment,omitempty"`
ChanceStatus int `json:"chanceStatus,omitempty"` //1.删除 2.关闭
/*Permission 机会权限*/
type ChancePermissionRequest struct {
}
type ChanceData struct {
type ChancePermissionResponse struct {
EditScore int `json:"editScore"`
EditChance int `json:"editChance"`
EditPublic int `json:"editPublic"`
CloseChance int `json:"closeChance"`
}
//我的机会列表
... ... @@ -228,49 +163,80 @@ type ChanceItemOrm struct {
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
ApproveData string `json:"approveData"` //审核数据
}
type ChanceItem struct {
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
Provider *BaseUserInfo `json:"provider"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
/*MyApproveChance 我审核的机会*/
type MyApproveChanceRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
ReviewStatus int8 `json:"reviewStatus"` //审核状态
}
type MyApproveChanceResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//我的审核机会列表
type ChanceApproveItemOrm struct {
ChanceUserId int64 `orm:"column(chance_user_id)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus string `orm:"column(enable_status)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
ReviewStatus int `orm:"column(review_status)"`
Id int64 `orm:"column(id)"` //审核id
ApproveTime time.Time `orm:"column(approve_time)"`
ApproveData string `orm:"column(approve_data)"`
ApproveMessage string `orm:"column(approve_message)"`
ApproveUserId int64 `orm:"column(uid)"`
ProcessCreateTime time.Time `orm:"column(process_create_time)"`
ChanceId int64 `orm:"column(chance_id)"` // 机会id
}
//机会池列表
type ChancePoolItemOrm struct {
Id int64 `orm:"column(id)"`
Uid int64 `orm:"column(user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
//ApproveData string `json:"approveData"` //审核数据
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
}
/*ChanceDetail 机会详情*/
type ChanceDetailRequest struct {
Id int64 `json:"id"` //机会编号
}
type ChanceDetailResponse struct {
ChanceDetail ChanceItem `json:"chanceDetail"`
ApproveData *ApproveData `json:"publicData"`
ChanceDetail ChanceItem `json:"chance"`
ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
ApproveData *ApproveData `json:"approveData"`
ApproveProcess []*ProcessItem `json:"approveProcess"`
ApproveAccess *ApproveAccess `json:"approveAccess"` //
ChanceType NameItem `json:"chanceType"` //机会类型
ChanceTemplate NameItem `json:"template"` //机会模板
ReviewStatus int `json:"review_status"` //审核状态 1:待审核 2:被退回 3:已通过
}
/*ChanceDelete 机会删除*/
type ChanceDeleteRequest struct {
Id int64 `json:"id"` //机会编号
}
type ChanceDeleteResponse struct {
type ChanceType struct {
Id int `json:"id"`
Name string `json:"name"`
Template
}
/*ChanceChangePublish 修改公开状态*/
... ... @@ -296,3 +262,121 @@ type ChanceCalculateScoreRequest struct {
type ChanceCalculateScoreResponse struct {
DiscoveryScore float64 `json:"discoveryScore"` //发现分
}
/*ChanceDelete 机会删除*/
type ChanceDeleteRequest struct {
Id int64 `json:"id"` //机会编号
}
type ChanceDeleteResponse struct {
}
type ChanceFavorite struct {
Id int64 `json:"id"`
Favorite interface{} `json:"favorite"`
}
//机会详情
type ChanceDetail struct {
Id int64 `json:"id"`
Provider *BaseUserInfo `json:"provider"`
IsCollect bool `json:"is_collect"`
IsZan bool `json:"is_zan"`
Content string `json:"content"`
ChanceType int `json:"chance_type"`
//图片
//视频
//语音
ViewTotal int `json:"view_total"`
CommentTotal int `json:"comment_total"`
ZanTotal int `json:"zan_total"`
}
//模板
type Template struct {
Id int64 `json:"id"`
Name string `json:"name"`
Doc string `json:"doc"`
Icon string `json:"icon"`
FormList []*Form `json:"formList"`
Link string `json:"link"` //示例
}
//表单
type Form struct {
Id int `json:"id"`
Label string `json:"label"`
InputType string `json:"inputType"`
SectionType int8 `json:"sectionType"`
Value string `json:"value"`
Required int8 `json:"required"`
}
//语音
type Speech struct {
Path string `json:"path"`
Duration int `json:"duration"`
}
//图片
type Picture struct {
Path string `json:"path"`
W int `json:"w"`
H int `json:"h"`
}
//视频
type Video struct {
Path string `json:"path"`
Cover Cover `json:"cover"` //封面
Duration int `json:"duration"`
}
//审批配置
type AuditConfig struct {
NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】
}
//机会池 - 统计
type ChanceTotalItem struct {
Id int `json:"id"` //类型
Name string `json:"name"` //总数
Total int `json:"total"`
}
//机会列表 通用项
type CommonListItem struct {
Chance ChanceItem `json:"chance,omitempty"` //机会详情
ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve
ApproveData interface{} `json:"approveData,omitempty"` //审核数据(公开状态 评分) ApproveData
Message interface{} `json:"message,omitempty"` //消息
Comment interface{} `json:"comment,omitempty"` //评论
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
ReviewStatus int `json:"reviewStatus"` //审核状态
//我审核的-通过
Score interface{} `json:"score,omitempty"`
//模板
ChanceType interface{} `json:"chanceType,omitempty"` //机会类型
ChanceTemplate interface{} `json:"template,omitempty"` //机会模板
}
type ChanceItem struct {
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
Provider *BaseUserInfo `json:"provider"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
}
type ChanceData struct {
ThumbsUpTotal int `json:"thumbsupTotal"` //点赞总数
CommentTotal int `json:"commentTotal"` //评论总数
PageViewTotal int `json:"pageView"` //评论总数
IsThumbsUp bool `json:"thumbsup"` //是否点赞 1 点赞, 0 没有点赞
IsCollect bool `json:"isCollect"` //是否收藏 1 是 0 否
}
... ...
... ... @@ -37,6 +37,27 @@ type ChanceApproveProcessResponse struct {
ApproveAccess *ApproveAccess `json:"approveOperate"`
}
//审批数据
type Approve struct {
//Provider *BaseUserInfo `json:"provider"`
ProcessId int64 `json:"processId"`
CreateTime int64 `json:"createTime"`
ApproveTime int64 `json:"approveTime"`
}
//审核操作权限
type ApproveAccess struct {
ProcessId int64 `json:"processId"`
AllowApprove int `json:"allowApprove"`
AllowReject int `json:"allowReject"`
}
//审核数据 审核通过
type ApproveData struct {
PublicData PublicData `json:"publicData"` // 公开数据
Score Score `json:"score"`
}
//进程项
type ProcessItem struct {
Id int64 `json:"id"`
... ... @@ -49,35 +70,11 @@ type ProcessItem struct {
Name string `json:"name"`
RoleName string `json:"roleName"`
Role int `json:"-"`
ApproveData ApproveData `json:"ApproveData"` //审核数据
ApproveData *ApproveData `json:"approveData"` //审核数据
//ApproveUser UserItem `json:"approveUser"` //审核人 //状态不是审核中
ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色
}
//用户项
type UserItem struct {
Uid int64 `json:"uid"`
Name string `json:"name"`
}
//角色项
type Role struct {
Id int `json:"id"`
Name string `json:"name"`
}
type Approve struct {
Provider BaseUserInfo `json:"provider"`
ProcessId int64 `json:"processId"`
ApproveTime int64 `json:"approveTime"`
}
//审核数据 审核通过
type ApproveData struct {
PublicData PublicData `json:"publicData"` // 公开数据
Score Score `json:"score"`
}
//公开数据
type PublicData struct {
PublishStatus int `json:"publishStatus"` //公开状态 0未公开、1部门公开、2公司公开
... ... @@ -98,10 +95,3 @@ type Score struct {
ValueScore float64 `json:"valueScore"` //价值分
DiscoveryScore float64 `json:"discoveryScore"` //发现分
}
//审核操作权限
type ApproveAccess struct {
ProcessId int64 `json:"processId"`
AllowApprove int `json:"allowApprove"`
AllowReject int `json:"allowReject"`
}
... ...
package protocol
/*GetConfigScore */
type GetConfigScoreRequest struct {
}
type GetConfigScoreResponse struct {
ScoreConfig
}
type ScoreConfig struct {
DiscoveryScore *DiscoveryScore `json:"discoveryScore"`
SumScore *SumScore `json:"-"` //sumScore
BasicScore *ScoreRange `json:"basicScore"`
ExtraScore *ScoreRange `json:"extraScore"`
ValueScore *ScoreRange `json:"valueScore"`
}
//发现评分计算规则
type DiscoveryScore struct {
BasicFactor float64 `json:"basicFactor"` //基础分系数
ExtraFactor float64 `json:"extraFactor"` //附加分系数
ValueFactor float64 `json:"valueFactor"` //价值分系数
}
//总分计算规则
type SumScore struct {
DiscoveryFactor float64 `json:"discoveryFactor"` //发现分系数
CatchFactor float64 `json:"catchFactor"` //抓住分系数
}
type ScoreRange struct {
Min float64 `json:"min"` //最小分
Max float64 `json:"max"` //最大分
Step float64 `json:"step"` //步长
}
... ...
... ... @@ -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()
... ...
... ... @@ -36,3 +36,37 @@ const (
MyAuditChancePass //我审核的机会-已通过
MyAuditChanceReturn //我审核的机会-已退回
)
var MapStaticName map[int64]string
func init() {
MapStaticName = make(map[int64]string)
MapStaticName[CollectStatic] = "收藏"
MapStaticName[ZanStatic] = "点赞"
MapStaticName[CommentStatic] = "评论"
MapStaticName[MyCommitChance] = "我提交的机会"
MapStaticName[MyCommitChanceWait] = "我提交的机会-待审批"
MapStaticName[MyCommitChanceReturn] = "我提交的机会-退回"
MapStaticName[MyCommitChancePass] = "我提交的机会-已通过"
MapStaticName[MyAuditChance] = "我审核的机会"
MapStaticName[MyAuditChanceWait] = "我审核的机会-待我审批"
MapStaticName[MyAuditChancePass] = "我审核的机会-已通过"
MapStaticName[MyAuditChanceReturn] = "我审核的机会-已退回"
}
//用户项
type UserItem struct {
Uid int64 `json:"uid"`
Name string `json:"name"`
}
//角色项
type Role struct {
Id int `json:"id"`
Name string `json:"name"`
}
type NameItem struct {
Id int `json:"id"`
Name string `json:"name"`
}
... ...
... ... @@ -2,6 +2,7 @@ package protocol
import (
"encoding/json"
"time"
)
var errmessge ErrorMap = map[int]string{
... ... @@ -51,6 +52,15 @@ const (
MsgTypeCommend = 2 //表彰
MsgTypeInteraction = 4 //互动消息
MsgTypeAudit = 8 //机会审核
MsgTypeAuditBy = 16 //机会被审核消息
MsgTypeComment = 32 //评论
MsgTypeThumbUp = 64 //点赞
)
var (
MessageApproving = "提交了一条%v机会消息,需要您审核"
MessageApproveSuccess = "审核通过你提交的%v机会"
MessageApproveReject = "退回您了提交的%v机会"
)
/*MessageCenter */
... ... @@ -186,6 +196,36 @@ type MsgCompanyNoticeResponse struct {
Total int `json:"total"`
}
/*MsgChanceApprove 机会审核消息*/
type MsgChanceApproveRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MsgChanceApproveResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//我的审核机会列表
type MsgChanceApproveItemOrm struct {
ChanceUserId int64 `orm:"column(chance_user_id)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
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)"`
CreateTime time.Time `orm:"column(create_at)"`
Message string `orm:"column(message)"`
IsRead int64 `orm:"column(isRead)"`
ChanceId int64 `orm:"column(source_id)"` // 机会id
//EnableStatus int `orm:"column(enable_status)"`
}
/*Announcement H5公告详情*/
type AnnouncementRequest struct {
Id int `json:"id" valid:"Required"`
... ...
... ... @@ -54,6 +54,15 @@ type UserInfoResponse struct {
User User `json:"user"`
}
//用户统计信息
/*UserStatistics */
type UserStatisticsRequest struct {
TypeTotal int64 `json:"typeTotal" valid:"Required"`
}
type UserStatisticsResponse struct {
Totals []TypeTotalItem `json:"totals"`
}
type User struct {
UserId int64 `json:"uid"`
Name string `json:"uname"`
... ... @@ -89,14 +98,6 @@ type Job struct {
Level int `json:"level"`
}
//用户统计信息
/*UserStatistics */
type UserStatisticsRequest struct {
TypeTotal int64 `json:"typeTotal" valid:"Required"`
}
type UserStatisticsResponse struct {
Totals []TypeTotalItem `json:"totals"`
}
type TypeTotalItem struct {
Type int64 `json:"type"` //类型
Total int `json:"total"` //总数
... ...
... ... @@ -81,6 +81,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChancePool",
Router: `/chancePool`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChanceType",
Router: `/chanceType`,
AllowHTTPMethods: []string{"post"},
... ... @@ -177,6 +185,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "Permission",
Router: `/permission`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChanceStatistics",
Router: `/statistics`,
AllowHTTPMethods: []string{"post"},
... ... @@ -215,6 +231,14 @@ func init() {
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ConfigController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ConfigController"],
beego.ControllerComments{
Method: "GetConfigScore",
Router: `/score/get`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"],
beego.ControllerComments{
Method: "Departments",
... ... @@ -265,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"},
... ...
... ... @@ -22,6 +22,7 @@ func init() {
beego.NSNamespace("chance", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.ChanceController{})),
beego.NSNamespace("message", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.MessageController{})),
beego.NSNamespace("department", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.DepartmentController{})),
beego.NSNamespace("config", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.ConfigController{})),
)
beego.AddNamespace(nsV1)
... ...
... ... @@ -3,6 +3,7 @@ package agg
import (
"bytes"
"fmt"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/utils"
"opp/models"
... ... @@ -177,6 +178,20 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e
return
}
//获取机会标记数据 点赞 / 收藏
func GetChanceMarkData(userId, companyId int64, sourceId int64) (flag int, err error) {
var (
v *models.ChanceFavorite
)
if v, err = models.GetChanceFavorite(userId, companyId, sourceId, protocol.SourceTypeChance); err != nil {
if err == orm.ErrNoRows {
return 0, nil
}
return
}
return v.MarkFlag, nil
}
//构建统计sql语句
func GetIncrementSql(table string, column string, incre int, id int64) *utils.SqlData {
var sql *bytes.Buffer
... ... @@ -187,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
}
... ...
... ... @@ -84,6 +84,56 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan
return
}
//发送被审核消息
func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int) (err error) {
var (
chanceType *models.ChanceType
format string
)
switch reviewStatus {
case protocol.ReviewStatusAuditging:
format = MessageApproving
break
case protocol.ReviewStatusReturn:
format = MessageApproveReject
break
case protocol.ReviewStatusPass:
format = MessageApproveSuccess
break
default:
format = MessageApproving
break
}
if chanceType, err = models.GetChanceTypeById(chanceTypeId); err != nil {
return
}
format = fmt.Sprintf(format, chanceType.Name)
return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType)
}
//发送消息
func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int) (err error) {
var (
userMsg *models.UserMsg
)
userMsg = &models.UserMsg{
Id: idgen.Next(),
CompanyId: companyId,
ReceiveUserId: receiverId,
MsgType: msgType,
Message: message,
SourceId: sourceId,
SourceType: sourceType,
IsPublic: 0,
CreateAt: time.Now(),
}
if _, err = models.AddUserMsg(userMsg); err != nil {
return
}
logMsg(userMsg, name)
return
}
//打印消息日志
func logMsg(msg *models.UserMsg, name string) {
log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v",
... ...
... ... @@ -20,3 +20,16 @@ func MyChanceStatic(header *protocol.RequestHeader, reviewStatus ...int8) (total
}
return
}
func MyApproveStatic(header *protocol.RequestHeader, reviewStatus ...int8) (total int, err error) {
var ()
if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, reviewStatus, 0, 0, nil); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
return
}
... ...
... ... @@ -43,7 +43,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces
relativeId int64
userCompany *models.UserCompany
)
if userCompany, err = models.GetUserCompanyByUserId(header.UserId, header.CompanyId); err != nil {
if userCompany, err = models.GetUserCompanyByUserId(header.Uid, header.CompanyId); err != nil {
log.Error(err)
return
}
... ... @@ -291,6 +291,11 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
err = protocol.NewErrWithMessage(5101)
return
}
if chance.EnableStatus == 0 {
log.Error(fmt.Sprintf("chance_id:%v enable_status:%v", chance.Id, chance.EnableStatus))
err = protocol.NewErrWithMessage(5101)
return
}
if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil {
log.Error(request.ProcessId, header.UserId, err)
err = protocol.NewErrWithMessage(5202)
... ... @@ -501,14 +506,23 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance)
}
}
}
//兼容审批流 待审核1->审批中5
//chanceProcessItemReviewStatus:=func(item *protocol.ProcessItem ) *protocol.ProcessItem {
// if item.ReviewStatus==protocol.ReviewStatusAuditging{
// item.ReviewStatus= protocol.ReviewStatusAuditg
// }
// return item
//}
for i := range processList {
p := processList[i]
item := newProcessItem(p)
checkApprovePermission(p)
//机会已经审核通过的直接添加到审核人列表
if chance.ReviewStatus == protocol.ReviewStatusPass {
if len(p.ApproveData) > 0 {
if e := json.Unmarshal([]byte(p.ApproveData), &item.ApproveData); e != nil {
log.Error(e)
log.Error("data", p.ApproveData, e)
}
}
rsp.ApproveProcess = append(rsp.ApproveProcess, item)
continue
... ...
... ... @@ -236,12 +236,17 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
auditConfig *protocol.AuditConfig
auditFlows []*models.AuditFlowProcess
suplusApprove SuplusApprove
chanceType *models.ChanceType
)
//1.模板是否存在
if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil {
log.Error("模板不存在:", request.AuditTemplateId, err)
return
}
if chanceType, err = models.GetChanceTypeById(template.ChanceTypeId); err != nil {
log.Error("一级分类不存在:", request.AuditTemplateId, err)
return
}
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
orm := orm.NewOrm()
orm.Begin()
... ... @@ -284,6 +289,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
return
}
for i := 0; i < len(auditFlows); i++ {
auditFlows[i].ApproveMessage = fmt.Sprintf(protocol.MessageApproving, chanceType.Name)
//auditFlows[i].TemplateId = int(template.Id)
if _, err = orm.Insert(auditFlows[i]); err != nil {
log.Error(err)
orm.Rollback()
... ... @@ -379,6 +386,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit
//6.更新文件
{
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, map[string]interface{}{
"Speechs": common.AssertJson(request.Speechs),
"Images": common.AssertJson(request.Pictures),
... ... @@ -520,6 +528,19 @@ func ChanceCalculateScore(header *protocol.RequestHeader, request *protocol.Chan
return
}
//机会权限
func ChancePermission(header *protocol.RequestHeader, request *protocol.ChancePermissionRequest) (rsp *protocol.ChancePermissionResponse, err error) {
var ()
rsp = &protocol.ChancePermissionResponse{}
{
rsp.EditChance = 1
rsp.EditScore = 1
rsp.EditPublic = 1
rsp.CloseChance = 1
}
return
}
//生成审批流-提交记录
func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64) (v *models.AuditFlowProcess) {
v = &models.AuditFlowProcess{
... ... @@ -660,6 +681,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
RoleName: roleName,
UserName: approver.NickName,
ReviewStatus: protocol.ReviewStatusAuditging,
TemplateId: int(templateId),
}
if config.Level == 1 {
item.IsActive = 1
... ... @@ -777,29 +799,38 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh
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,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
rsp.List = append(rsp.List, item)
commItem.Chance = item
}
commItem.ReviewStatus = chance.ReviewStatus
if request.ReviewStatus == protocol.ReviewStatusPass {
jsonUnmarshal(chance.ApproveData, &commItem.ApproveData)
}
rsp.List = append(rsp.List, commItem)
}
return
}
//我审核的机会
func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) {
//机会池
func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequest) (rsp *protocol.ChancePoolResponse, err error) {
var (
myChances []protocol.ChanceApproveItemOrm
myChances []protocol.ChancePoolItemOrm
total int
provider *protocol.BaseUserInfo
flag int
)
rsp = &protocol.MyApproveChanceResponse{}
if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
if total, err = models.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ... @@ -811,26 +842,127 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
log.Error(err)
return
}
rsp = &protocol.MyApproveChanceResponse{Total: total}
rsp = &protocol.ChancePoolResponse{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,
CreateTime: chance.CreateTime.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
commItem.ReviewStatus = chance.ReviewStatus
{
var chanceData = protocol.ChanceData{
ThumbsUpTotal: chance.ZanTotal,
CommentTotal: chance.CommentTotal,
PageViewTotal: chance.ViewTotal,
}
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.Id); err != nil {
log.Error(err)
continue
}
chanceData.IsThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan
chanceData.IsCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
commItem.ChanceData = chanceData
}
{
commItem.Chance = item
//做一次查询 查回所有的模板数据
if template, e := models.GetAuditTemplateById(int64(chance.TemplateId)); e == nil {
commItem.ChanceTemplate = protocol.NameItem{
Id: int(template.Id),
Name: template.Name,
}
}
if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil {
commItem.ChanceType = protocol.NameItem{
Id: int(chanceType.Id),
Name: chanceType.Name,
}
}
}
rsp.List = append(rsp.List, commItem)
}
return
}
//我审核的机会
func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) {
var (
myChances []protocol.ChanceApproveItemOrm
total int
provider *protocol.BaseUserInfo
)
rsp = &protocol.MyApproveChanceResponse{}
if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MyApproveChanceResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
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(header.UserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
} else {
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
//CreateTime: chance.CreateTime.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
approve := protocol.Approve{
ProcessId: chance.Id,
//Provider:provider,
CreateTime: chance.ProcessCreateTime.Unix() * 1000,
}
//审核过的才有审核时间
if request.ReviewStatus != protocol.ReviewStatusAuditging {
approve.ApproveTime = chance.ApproveTime.Unix() * 1000
}
commItem.Approve = approve
//审核完有审核数据
if request.ReviewStatus == protocol.ReviewStatusAuditging {
commItem.Message = chance.ApproveMessage
}
if request.ReviewStatus == protocol.ReviewStatusPass {
var approveData *protocol.ApproveData
jsonUnmarshal(chance.ApproveData, &approveData)
if approveData != nil {
commItem.Score = approveData.Score
}
}
rsp.List = append(rsp.List, commItem)
}
return
}
... ... @@ -843,6 +975,20 @@ func jsonUnmarshal(jsonData string, v interface{}) {
}
}
//清楚未填写的表单数据
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
}
//机会详情
func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetailRequest) (rsp *protocol.ChanceDetailResponse, err error) {
var (
... ... @@ -850,6 +996,8 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
chanceData *models.ChanceData
provider *protocol.BaseUserInfo
approveProcess *protocol.ChanceApproveProcessResponse
//chanceType *models.ChanceType
//tempalte *models.AuditTemplate
)
rsp = &protocol.ChanceDetailResponse{}
if chance, err = models.GetChanceById(request.Id); err != nil {
... ... @@ -860,6 +1008,18 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
log.Error(err)
return
}
if template, e := models.GetAuditTemplateById(chance.AuditTemplateId); e == nil {
rsp.ChanceTemplate = protocol.NameItem{
Id: int(template.Id),
Name: template.Name,
}
}
if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil {
rsp.ChanceType = protocol.NameItem{
Id: int(chanceType.Id),
Name: chanceType.Name,
}
}
if chance.EnableStatus == 0 {
err = protocol.NewErrWithMessage(5101)
return
... ... @@ -883,6 +1043,7 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
}
jsonUnmarshal(chance.ApproveData, &rsp.ApproveData)
rsp.ChanceDetail = item
rsp.ReviewStatus = int(chance.ReviewStatus)
if approveProcess, err = ChanceApproveProcess(header, chance); err != nil {
log.Error(err)
return
... ...
package config
import (
"encoding/json"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/models"
"opp/protocol"
)
func GetConfigScore(header *protocol.RequestHeader, request *protocol.GetConfigScoreRequest) (rsp *protocol.GetConfigScoreResponse, err error) {
var (
scoreConfig *models.SysConfig
)
rsp = &protocol.GetConfigScoreResponse{}
if scoreConfig, err = models.GetSysConfigByCompanyId(int(header.CompanyId), models.KeyScore); err != nil {
log.Error(err.Error())
return
}
if err = json.Unmarshal([]byte(scoreConfig.Content), &rsp); err != nil {
log.Error(err.Error())
return
}
return
}
... ...
... ... @@ -10,6 +10,7 @@ import (
"opp/internal/utils"
"opp/models"
"opp/protocol"
"opp/services/agg"
"time"
)
... ... @@ -182,13 +183,71 @@ func MsgCompanyNotice(header *protocol.RequestHeader, request *protocol.MsgCompa
return
}
//消息中心-机会审核消息
func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanceApproveRequest) (rsp *protocol.MsgChanceApproveResponse, err error) {
var (
myChances []protocol.MsgChanceApproveItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAudit, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MsgChanceApproveResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
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
}
}
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
}
//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
//bulletinAnswer *models.BulletinQuestionAnswer
setRead bool = false
answer *protocol.Answer
)
... ... @@ -227,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
... ...
... ... @@ -368,40 +368,67 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis
total int
)
rsp = &protocol.UserStatisticsResponse{}
isMark := func(v int64) bool {
if flag != v {
return false
}
return (request.TypeTotal & v) > 0
}
for flag = 1; flag < (1 << 20); flag = flag << 1 {
//buf :=bytes.NewBuffer(nil)
//buf.WriteString(fmt.Sprintf("用户中心-统计信息 user:%v type_total:%v \n",header.UserId,request.TypeTotal))
for flag = 1; flag <= (protocol.MyAuditChanceReturn); flag = flag << 1 {
total = 0
if isMark(protocol.MyCommitChance) {
switch flag {
case protocol.MyCommitChance:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil {
log.Error(err)
}
}
if isMark(protocol.MyCommitChanceWait) {
break
case protocol.MyCommitChanceWait:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging); err != nil {
log.Error(err)
}
break
case protocol.MyCommitChancePass:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusPass); err != nil {
log.Error(err)
}
if isMark(protocol.MyAuditChanceReturn) {
break
case protocol.MyCommitChanceReturn:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusReturn); err != nil {
log.Error(err)
}
break
case protocol.MyAuditChance:
if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil {
log.Error(err)
}
if isMark(protocol.MyCommitChancePass) {
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusPass); err != nil {
break
case protocol.MyAuditChanceWait:
if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusAuditging); err != nil {
log.Error(err)
}
break
case protocol.MyAuditChancePass:
if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusPass); err != nil {
log.Error(err)
}
break
case protocol.MyAuditChanceReturn:
if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusReturn); err != nil {
log.Error(err)
}
break
}
if flag&request.TypeTotal > 0 {
rsp.Totals = append(rsp.Totals, protocol.TypeTotalItem{
Type: flag,
Total: total,
})
log.Debug(fmt.Sprintf("用户中心-统计信息 user:%v name:%v type:%v total:%v ", header.UserId, protocol.MapStaticName[flag], flag, total))
//buf.WriteString(fmt.Sprintf("user:%v name:%v type:%v total:%v ",header.UserId,protocol.MapStaticName[flag],flag,total))
//if err!=nil{
// buf.WriteString("err:%v \n")
//}else{
// buf.WriteString("\n")
//}
}
}
//log.Debug(buf.String())
return
}
... ...