作者 唐旭辉

bug fix

  1 +package models
  2 +
  3 +import (
  4 + "time"
  5 +
  6 + "github.com/astaxie/beego/orm"
  7 +)
  8 +
  9 +type AuditFlowProcess struct {
  10 + Id int64 `orm:"column(id);pk" description:"唯一标识"`
  11 + ChanceId int64 `orm:"column(chance_id)" description:"实例id,关联chance表id"`
  12 + Uid int64 `orm:"column(uid)" description:"用户id(审批人)"`
  13 + Level int `orm:"column(level)" description:"审批步骤"`
  14 + IsActive int8 `orm:"column(is_active)" description:"是否激活"`
  15 + ApproveTime time.Time `orm:"column(approve_time);type(timestamp);null" description:"审批时间"`
  16 + BasicScore float64 `orm:"column(basic_score);null;digits(4);decimals(1)" description:"基础评分"`
  17 + ExtraScore float64 `orm:"column(extra_score);null;digits(4);decimals(1)" description:"附加评分"`
  18 + ValueScore float64 `orm:"column(value_score);null;digits(4);decimals(1)" description:"价值评分"`
  19 + DiscoveryScore float64 `orm:"column(discovery_score);null;digits(4);decimals(0)" description:"发现评分"`
  20 + ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 审核状态 0:待处理 1:待审核 2:被退回 3:已通过 4:提交 "`
  21 + AuditFlowType int `orm:"column(audit_flow_type)" description:"审核流类型 1.部门长 2.指定成员 3.指定角色 4.特殊审核人"`
  22 + FlowType int `orm:"column(flow_type)" description:"审批类型 1:正常审核 2:特殊审核"`
  23 + ActionType int `orm:"column(action_type)" description:"审批执行方式【1:or】【2:and】"`
  24 + CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
  25 + UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
  26 + EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 (被驳回以后,未完成的审核置为无效)"`
  27 + ApproveData string `orm:"column(approve_data);size(500);null" description:"审核数据 json{公开状态 公开对象 分数}"`
  28 + UserName string `orm:"column(user_name);size(50);null" description:"用户名-冗余"`
  29 + RoleName string `orm:"column(role_name);size(50);null" description:"角色名-冗余"`
  30 + RoleId int `orm:"column(role_id);null" description:"角色id-冗余"`
  31 + ApproveMessage string `orm:"column(approve_message);size(255);null" description:"审核消息-冗余"`
  32 + TemplateId int `orm:"column(template_id);null" description:"模板编号"`
  33 +}
  34 +
  35 +func (t *AuditFlowProcess) TableName() string {
  36 + return "audit_flow_process"
  37 +}
  38 +
  39 +func init() {
  40 + orm.RegisterModel(new(AuditFlowProcess))
  41 +}
  42 +
  43 +//有效状态 0:无效 1:有效 (被驳回以后,未完成的审核置为无效)
  44 +const (
  45 + AuditFlowProcessEnableYes int = 1
  46 + AuditFlowProcessEnableNo int = 0
  47 +)
  48 +
  49 +//审核状态 审核状态 0:待处理 1:待审核 2:被退回 3:已通过 4:提交
  50 +const (
  51 + AuditFlowProcessReviewWait int = 0
  52 + AuditFlowProcessReviewIng int = 1
  53 + AuditFlowProcessReviewBack int = 2
  54 + AuditFlowProcessReviewPass int = 3
  55 + AuditFlowProcessReviewCommit int = 4
  56 +)
  57 +
  58 +// GetAuditFlowProcessById retrieves AuditFlowProcess by Id. Returns error if
  59 +// Id doesn't exist
  60 +func GetAuditFlowProcessById(id int64) (v *AuditFlowProcess, err error) {
  61 + o := orm.NewOrm()
  62 + v = &AuditFlowProcess{Id: id}
  63 + if err = o.Read(v); err == nil {
  64 + return v, nil
  65 + }
  66 + return nil, err
  67 +}
@@ -31,6 +31,7 @@ type Chance struct { @@ -31,6 +31,7 @@ type Chance struct {
31 PublishStatus int `orm:"column(publish_status)" description:"公开状态 -1 未公开、1部门公开、2公司公开"` 31 PublishStatus int `orm:"column(publish_status)" description:"公开状态 -1 未公开、1部门公开、2公司公开"`
32 AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` 32 AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"`
33 ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"` 33 ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"`
  34 + Code string `orm:"column(code)" description:"机会编码"`
34 } 35 }
35 36
36 func (t *Chance) TableName() string { 37 func (t *Chance) TableName() string {
@@ -49,6 +49,8 @@ var errmessge ErrorMap = map[string]string{ @@ -49,6 +49,8 @@ var errmessge ErrorMap = map[string]string{
49 "10071": "不能删除主管理员", 49 "10071": "不能删除主管理员",
50 "10072": "不能禁用主管理员", 50 "10072": "不能禁用主管理员",
51 "10073": "角色组已存在", 51 "10073": "角色组已存在",
  52 + "10074": "删除失败,存在需要用户审批的单子",
  53 + "10075": "禁用失败,存在需要用户审批的单子",
52 //部门相关 54 //部门相关
53 "10041": "无效的主管设置", 55 "10041": "无效的主管设置",
54 "10042": "上级部门不能选择当前部门及其子部门", 56 "10042": "上级部门不能选择当前部门及其子部门",
@@ -92,6 +94,8 @@ var errmessge ErrorMap = map[string]string{ @@ -92,6 +94,8 @@ var errmessge ErrorMap = map[string]string{
92 //评分配置相关 94 //评分配置相关
93 "12101": "分值范围不符合要求", 95 "12101": "分值范围不符合要求",
94 "12102": "评分规则不符合要求", 96 "12102": "评分规则不符合要求",
  97 + //权限配置相关
  98 + "10091": "至少选择一个特定部门",
95 } 99 }
96 100
97 //错误码转换 ,兼容需要 101 //错误码转换 ,兼容需要
@@ -465,7 +465,14 @@ func UserDelete(userCompanyids []int64, companyid int64) error { @@ -465,7 +465,14 @@ func UserDelete(userCompanyids []int64, companyid int64) error {
465 log.Error("获取用户数据失败:%s", err) 465 log.Error("获取用户数据失败:%s", err)
466 return protocol.NewErrWithMessage("1") 466 return protocol.NewErrWithMessage("1")
467 } 467 }
468 - 468 + exist := o.QueryTable(&models.AuditFlowProcess{}).
  469 + Filter("uid__in", userCompanyids).
  470 + Filter("enable_status", models.AuditFlowProcessEnableYes).
  471 + Filter("review_status__in", models.AuditFlowProcessReviewWait, models.AuditFlowProcessReviewIng).
  472 + Exist()
  473 + if exist {
  474 + return protocol.NewErrWithMessage("10074")
  475 + }
469 var ( 476 var (
470 ids []int64 477 ids []int64
471 ) 478 )
@@ -657,6 +664,14 @@ func UserForbid(userCompanyids []int64, companyid int64) error { @@ -657,6 +664,14 @@ func UserForbid(userCompanyids []int64, companyid int64) error {
657 log.Error("获取用户数据失败:%s", err) 664 log.Error("获取用户数据失败:%s", err)
658 return protocol.NewErrWithMessage("1") 665 return protocol.NewErrWithMessage("1")
659 } 666 }
  667 + exist := o.QueryTable(&models.AuditFlowProcess{}).
  668 + Filter("uid__in", userCompanyids).
  669 + Filter("enable_status", models.AuditFlowProcessEnableYes).
  670 + Filter("review_status__in", models.AuditFlowProcessReviewWait, models.AuditFlowProcessReviewIng).
  671 + Exist()
  672 + if exist {
  673 + return protocol.NewErrWithMessage("10075")
  674 + }
660 var ( 675 var (
661 ids []int64 676 ids []int64
662 ) 677 )
@@ -173,6 +173,13 @@ func UpdateSetOpportunity(param OptionOpportunity, roleid int64, companyid int64 @@ -173,6 +173,13 @@ func UpdateSetOpportunity(param OptionOpportunity, roleid int64, companyid int64
173 err error 173 err error
174 menuinfo *models.Menu 174 menuinfo *models.Menu
175 ) 175 )
  176 +
  177 + if param.Check == OpportunityCheckLv3 {
  178 + if len(param.CheckOption.Departments) == 0 {
  179 + return protocol.NewErrWithMessage("10091")
  180 + }
  181 + }
  182 +
176 menuinfo, err = models.GetMenuByCode(M_SYSTEM_OPPORTUNITY) 183 menuinfo, err = models.GetMenuByCode(M_SYSTEM_OPPORTUNITY)
177 if err != nil { 184 if err != nil {
178 log.Error("获取菜单数据失败GetMenuByCode(%s):%s", M_SYSTEM_OPPORTUNITY, err) 185 log.Error("获取菜单数据失败GetMenuByCode(%s):%s", M_SYSTEM_OPPORTUNITY, err)