|
@@ -20,21 +20,14 @@ import (
|
|
|
|
|
|
// AddSeal 添加用印
|
|
|
func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, companyName, creditCode, serviceType, sealType, remark, fileUrl string) (sealInfo *seal.Seal, err error) {
|
|
|
- useList := []string{"销售合同", "渠道合同", "付款通知函", "招投标", "战略合作协议"}
|
|
|
- serviceTypeList := []string{"新签合同", "续约合同", "补充协议"}
|
|
|
- sealTypeList := []string{"合同章", "公章", "法人章"}
|
|
|
- if !strings.Contains(strings.Join(useList, ","), use) {
|
|
|
+ if !strings.Contains(strings.Join(seal.EnumUse, ","), use) {
|
|
|
err = errors.New("用印用途异常")
|
|
|
return
|
|
|
}
|
|
|
- if !strings.Contains(strings.Join(serviceTypeList, ","), serviceType) {
|
|
|
+ if !strings.Contains(strings.Join(seal.EnumServiceType, ","), serviceType) {
|
|
|
err = errors.New("业务类型异常")
|
|
|
return
|
|
|
}
|
|
|
- if !strings.Contains(strings.Join(sealTypeList, ","), sealType) {
|
|
|
- err = errors.New("加盖印章类型异常")
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
sealCode, err := seal.GetSealCode()
|
|
|
if err != nil {
|
|
@@ -59,26 +52,31 @@ func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, com
|
|
|
CreateTime: time.Now(),
|
|
|
}
|
|
|
err = seal.AddSeal(sealInfo)
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("新增用印失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 操作日志
|
|
|
+ err = seal.AddSealOperationRecord(sealInfo.SealId, userId, 0, "apply", userName, "提交审批", "")
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("新增用印日志失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// Edit 修改用印
|
|
|
-func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompanyName, creditCode, serviceType, sealType, remark, fileUrl string) (sealInfo *seal.Seal, err error) {
|
|
|
- useList := []string{"销售合同", "渠道合同", "付款通知函", "招投标", "战略合作协议"}
|
|
|
- serviceTypeList := []string{"新签合同", "续约合同", "补充协议"}
|
|
|
- sealTypeList := []string{"合同章", "公章", "法人章"}
|
|
|
- if !strings.Contains(strings.Join(useList, ","), use) {
|
|
|
+func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompanyName, creditCode, serviceType, sealType, remark, fileUrl, userName string) (sealInfo *seal.Seal, err error) {
|
|
|
+ if !strings.Contains(strings.Join(seal.EnumUse, ","), use) {
|
|
|
err = errors.New("用印用途异常")
|
|
|
return
|
|
|
}
|
|
|
- if !strings.Contains(strings.Join(serviceTypeList, ","), serviceType) {
|
|
|
+ if !strings.Contains(strings.Join(seal.EnumServiceType, ","), serviceType) {
|
|
|
err = errors.New("业务类型异常")
|
|
|
return
|
|
|
}
|
|
|
- if !strings.Contains(strings.Join(sealTypeList, ","), sealType) {
|
|
|
- err = errors.New("加盖印章类型异常")
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
//查询当前合同信息
|
|
|
sealInfo, err = seal.GetSealInfoById(sealId)
|
|
@@ -112,22 +110,27 @@ func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompany
|
|
|
sealInfo.Status = "待提交" //用印状态
|
|
|
|
|
|
err = sealInfo.Update([]string{"Use", "CompanyName", "UseCompanyName", "CreditCode", "ServiceType", "SealType", "Remark", "FileUrl", "ModifyTime", "Status"})
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("新增用印日志失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 操作日志
|
|
|
+ err = seal.AddSealOperationRecord(sealInfo.SealId, userId, 0, "edit", userName, "重提审批", "")
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("编辑用印日志失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// CheckEdit 审批者修改用印
|
|
|
func CheckEdit(sealInfo *seal.Seal, approvalInfo *contract_approval.ContractApproval, approvalRecord *contract_approval_record.ContractApprovalRecord, fileNum int, fileUrl, use, sealType, remark string, opUser *custom.AdminWx) (err error) {
|
|
|
- useList := []string{"销售合同", "渠道合同", "付款通知函", "招投标", "战略合作协议"}
|
|
|
- sealTypeList := []string{"合同章", "公章", "法人章"}
|
|
|
- if !strings.Contains(strings.Join(useList, ","), use) {
|
|
|
+ if !strings.Contains(strings.Join(seal.EnumUse, ","), use) {
|
|
|
err = errors.New("用印用途异常")
|
|
|
return
|
|
|
}
|
|
|
- if !strings.Contains(strings.Join(sealTypeList, ","), sealType) {
|
|
|
- err = errors.New("加盖印章类型异常")
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
//判断是否是合规账号
|
|
|
if opUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE {
|
|
@@ -172,10 +175,14 @@ func CheckEdit(sealInfo *seal.Seal, approvalInfo *contract_approval.ContractAppr
|
|
|
}
|
|
|
content := "用印修改:" + opUser.RealName + "修改了" + strings.Join(updateContent, "、")
|
|
|
|
|
|
+ // 通过盖章类型判断是否需要变更审批流程
|
|
|
+ originFlowType := GetFlowTypeBySealType(sealInfo.SealType)
|
|
|
+ reqFlowType := GetFlowTypeBySealType(sealType)
|
|
|
+
|
|
|
//如果变更了盖章类型(涉及到审批流程变更),那么需要变更审批流
|
|
|
//变更审批流:先驳回用印申请,再修改用印,再发消息给申请人,再替申请人重新发起申请,
|
|
|
//然后遍历审批流程,当前操作人节点之前的全部审核通过,最后通过当前操作人的节点(改成如果一级审批人如果是自己,那么直接通过这一级审批,否则不通过,让审批单重走流程)
|
|
|
- if (sealInfo.SealType == "合同章" && strings.Contains("公章,法人章", sealType)) || (strings.Contains("公章,法人章", sealInfo.SealType) && sealType == "合同章") {
|
|
|
+ if originFlowType != reqFlowType {
|
|
|
//先驳回
|
|
|
err = CheckReject(sealInfo, approvalInfo, approvalRecord, opUser, "")
|
|
|
if err != nil {
|
|
@@ -225,6 +232,9 @@ func CheckEdit(sealInfo *seal.Seal, approvalInfo *contract_approval.ContractAppr
|
|
|
func checkEdit(sealInfo *seal.Seal, updateCol []string, approvalRecordId int, content string, opUser *custom.AdminWx) {
|
|
|
_ = sealInfo.Update(updateCol)
|
|
|
|
|
|
+ // 操作日志
|
|
|
+ _ = seal.AddSealOperationRecord(sealInfo.SealId, opUser.AdminId, approvalRecordId, "edit", opUser.RealName, "审批人修改信息", "")
|
|
|
+
|
|
|
//给用印人,发送修改消息
|
|
|
sysUserMobile := ""
|
|
|
sysUser, _ := admin.GetAdminById(opUser.AdminId)
|
|
@@ -266,6 +276,13 @@ func Invalid(sealId int, opUser *custom.AdminWx, isInvalidContract bool) (err er
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 操作日志
|
|
|
+ err = seal.AddSealOperationRecord(sealInfo.SealId, opUser.AdminId, 0, "invalid", opUser.RealName, "作废审批", "")
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("新增用印日志失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
//如果是系统合同,同时需要同步作废合同时,那么逻辑处理
|
|
|
if sealInfo.ContractId > 0 && isInvalidContract {
|
|
|
err = contractService.InvalidContract(sealInfo.ContractId, opUser)
|
|
@@ -431,7 +448,7 @@ func GetOpButton(sealInfo *seal.Seal, contractApprovalInfo *contract_approval.Co
|
|
|
|
|
|
//待审批状态下,如果当前审批节点就是操作人,审批节点超过当前审批节点,且节点类型是抄送人,,那么标记为处理中
|
|
|
if contractApprovalInfo.Status == "待审批" {
|
|
|
- if approvalRecord.ApproveUserId == opUser.AdminId && approvalRecord.NodeId < contractApprovalInfo.CurrNodeId && approvalRecord.NodeType != "cc" {
|
|
|
+ if approvalRecord.ApproveUserId == opUser.AdminId && approvalRecord.NodeId < contractApprovalInfo.CurrNodeId && approvalRecord.NodeType == "cc" {
|
|
|
sealInfo.Status = "处理中"
|
|
|
}
|
|
|
}
|