feat 对已经申请过的进行处理
This commit is contained in:
parent
2618dfa869
commit
5690a6697c
@ -163,6 +163,22 @@ AND approval.domain = ? AND approval.submitter_id = ? AND approval.type = ? AND
|
||||
return total - usedNum
|
||||
}
|
||||
|
||||
func ExistPayApproval(in *approval.CreateRequest) bool {
|
||||
var count int64
|
||||
|
||||
//
|
||||
subQuery1 := DB.Model(&Approval{}).Where(&Approval{SubmitterID: in.SubmitterID, Type: TypeBundlePayPrice}).
|
||||
Where("status in (?)",[]uint64{StatusDoing,StatusOk}).
|
||||
Select("id")
|
||||
|
||||
DB.Model(&BundlePayPrice{}).Where("approval_id in (?)", subQuery1).Where(&BundlePayPrice{ShowUid: in.BundlePayPrice.ShowUid}).Count(&count)
|
||||
|
||||
if count >= 1 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func StoreApproval(in *approval.CreateRequest) (*Approval, error) {
|
||||
var entity *Approval
|
||||
|
||||
|
@ -19,6 +19,13 @@ type ApprovalProvider struct {
|
||||
func (a *ApprovalProvider) Create(ctx context.Context, in *approval.CreateRequest) (*approval.ApprovalResponse, error) {
|
||||
response := &approval.ApprovalResponse{}
|
||||
|
||||
//下载单子只能下载一次
|
||||
if in.Type == model.TypeBundlePayPrice {
|
||||
if model.ExistPayApproval(in) == true {
|
||||
return response, errors.New("该画展宝已经有审批中或者审批通过的提交")
|
||||
}
|
||||
}
|
||||
|
||||
entity, err := model.StoreApproval(in)
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
Loading…
Reference in New Issue
Block a user