|
|
@ -185,6 +185,29 @@ func ExistPayApproval(in *approval.CreateRequest) bool {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 余额申请 校验
|
|
|
|
|
|
|
|
func ExistLeaveApplyApproval(in *approval.CreateRequest) bool {
|
|
|
|
|
|
|
|
var count int64
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验 规则
|
|
|
|
|
|
|
|
// 一年一次 多次 一次
|
|
|
|
|
|
|
|
subQuery1 := DB.Model(&Approval{}).Where(&Approval{SubmitterID: in.SubmitterID, Type: in.Type}).
|
|
|
|
|
|
|
|
Where("status in (?)", []uint64{StatusDoing, StatusOk})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if LeaveBalanceUsefulTime[in.Type] == OnceAYear {
|
|
|
|
|
|
|
|
subQuery1.Where("DATE_FORMAT(created_at,%Y) = ?", time.Now().Format("2006"))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subQuery1.Select("id")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB.Model(&ApprovalOA{}).Where("approval_id in (?)", subQuery1).Count(&count)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if count >= 1 {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func StoreApproval(in *approval.CreateRequest) (*Approval, error) {
|
|
|
|
func StoreApproval(in *approval.CreateRequest) (*Approval, error) {
|
|
|
|
var entity *Approval
|
|
|
|
var entity *Approval
|
|
|
|
|
|
|
|
|
|
|
@ -549,7 +572,7 @@ func MyAllWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
|
|
|
|
|
|
|
|
|
|
|
|
modelObj = modelObj.Where(&Approval{Type: in.Type}).Where(
|
|
|
|
modelObj = modelObj.Where(&Approval{Type: in.Type}).Where(
|
|
|
|
DB.Where(&Approval{NowUserId: in.UserID, Status: StatusDoing}). // 我需要审批的
|
|
|
|
DB.Where(&Approval{NowUserId: in.UserID, Status: StatusDoing}). // 我需要审批的
|
|
|
|
Or(DB.Where("status = ?", StatusOk).Where("id in (?)", s1))) // 已完成,抄送给我的
|
|
|
|
Or(DB.Where("status = ?", StatusOk).Where("id in (?)", s1))) // 已完成,抄送给我的
|
|
|
|
modelObj.Count(&count)
|
|
|
|
modelObj.Count(&count)
|
|
|
|
|
|
|
|
|
|
|
|
if len(ids) > 0 { //根据具体id排序
|
|
|
|
if len(ids) > 0 { //根据具体id排序
|
|
|
@ -596,8 +619,8 @@ func MyApprovalWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
|
|
|
|
if in.UserID != 0 {
|
|
|
|
if in.UserID != 0 {
|
|
|
|
modelObj = modelObj.Where(
|
|
|
|
modelObj = modelObj.Where(
|
|
|
|
DB.Where("JSON_CONTAINS(approval_users,JSON_OBJECT('ID', ?))", in.UserID).
|
|
|
|
DB.Where("JSON_CONTAINS(approval_users,JSON_OBJECT('ID', ?))", in.UserID).
|
|
|
|
Where("status != ?", StatusDoing). //完成,我参与审批
|
|
|
|
Where("status != ?", StatusDoing). //完成,我参与审批
|
|
|
|
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
|
|
|
|
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
|
|
|
|
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
|
|
|
|
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -655,8 +678,8 @@ func MyWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
|
|
|
|
if in.UserID != 0 {
|
|
|
|
if in.UserID != 0 {
|
|
|
|
modelObj = modelObj.Where(
|
|
|
|
modelObj = modelObj.Where(
|
|
|
|
DB.Where("JSON_CONTAINS(approval_users,JSON_OBJECT('ID', ?))", in.UserID).
|
|
|
|
DB.Where("JSON_CONTAINS(approval_users,JSON_OBJECT('ID', ?))", in.UserID).
|
|
|
|
Where("status != ?", StatusDoing). //完成,我参与审批
|
|
|
|
Where("status != ?", StatusDoing). //完成,我参与审批
|
|
|
|
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
|
|
|
|
Or(DB.Where("now_user_id", in.UserID).Where("status = ?", StatusDoing)). //进行中,当前审批人是我,
|
|
|
|
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
|
|
|
|
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|