|
@@ -757,6 +757,9 @@ func afterApproved(companyApprovalId int, opUserId int, opUserName string) (err
|
|
|
|
|
|
//如果合同时间小于等于今天,那么立马执行合同内容
|
|
|
if time.Now().After(contractStartDate) {
|
|
|
+ // 合同处理完成后的续约异常记录
|
|
|
+ contactHandleCompanyRenewalRecord(contractInfo)
|
|
|
+
|
|
|
startDate = contractInfo.StartDate
|
|
|
endDate = contractInfo.EndDate
|
|
|
companyReportPermissionList, err = company.ApplyServiceUpdate(recodeInfo.CompanyId, recodeInfo.ProductId, opUser.AdminId, recodeInfo.CompanyApprovalId, recodeInfo.CompanyContractId, companyProduct.StartDate, contractInfo.EndDate, opUser.RealName, companyProduct.ProductName, contractInfo.PackageType, contractInfo.RaiPackageType)
|
|
@@ -887,6 +890,79 @@ func afterApproved(companyApprovalId int, opUserId int, opUserName string) (err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// contactHandleCompanyRenewalRecord
|
|
|
+// @Description: 合同处理完成后的续约异常记录
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2023-12-07 14:24:44
|
|
|
+// @param contractInfo *company_contract.CompanyContract
|
|
|
+// @param day string
|
|
|
+// @return err error
|
|
|
+func contactHandleCompanyRenewalRecord(contractInfo *company.CompanyContractDetail) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Error("合同处理完成后的续约异常记录," + err.Error())
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ // 判断合同类型是否是续约合同,如果不是的话,就不往下走了
|
|
|
+ if contractInfo.ContractType != `续约合同` {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ day := time.Now().Format(utils.FormatDate)
|
|
|
+
|
|
|
+ // 获取早于当前合同结束日期的上一份合同
|
|
|
+ lastContract, tmpErr := company.GetLastContractListByEndDate(contractInfo.CompanyId, contractInfo.ProductId, contractInfo.EndDate)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = errors.New(fmt.Sprint("合同id:", contractInfo.CompanyContractId, ";通过最近一份合同的日期获取早于该合同的最晚一份合同失败,ERR:", tmpErr))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 校验 上一份合同的结束日期 与 今天 相隔的天数
|
|
|
+ betweenDay, tmpErr := utils.GetDaysBetween2Date(utils.FormatDate, day, lastContract.EndDate)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = errors.New(fmt.Sprint("合同id:", contractInfo.CompanyContractId, ";计算两个日期相差的天数失败,ERR:", tmpErr))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ source := 2 // 正常续约
|
|
|
+ // 如果间隔时间超过60天,那么标记为超时续约
|
|
|
+ if betweenDay > 60 {
|
|
|
+ source = 3 // 超时续约
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果间隔时间超过60天,那么标记为超时续约
|
|
|
+ companyProductItem, tmpErr := company.GetCompanyProductItemByCompanyId(contractInfo.CompanyId, contractInfo.ProductId)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = errors.New(fmt.Sprint("合同id:", contractInfo.CompanyContractId, ";GetCompanyProductItemByCompanyId失败,ERR:", tmpErr))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var shareSellerId int
|
|
|
+ var shareSellerName string
|
|
|
+ if companyProductItem.IsShare == 1 {
|
|
|
+ shareSellerId = companyProductItem.ShareSellerId
|
|
|
+ shareSellerName = companyProductItem.ShareSeller
|
|
|
+ }
|
|
|
+ item := &company.CompanyRenewalRecord{
|
|
|
+ Id: 0,
|
|
|
+ CompanyId: contractInfo.CompanyId,
|
|
|
+ ProductId: contractInfo.ProductId,
|
|
|
+ Source: source,
|
|
|
+ SellerId: companyProductItem.SellerId,
|
|
|
+ SellerName: companyProductItem.SellerName,
|
|
|
+ ShareSellerId: shareSellerId,
|
|
|
+ ShareSellerName: shareSellerName,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ ModifyTime: time.Now(),
|
|
|
+ }
|
|
|
+ tmpErr = item.Add()
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = errors.New(fmt.Sprint("合同id:", contractInfo.CompanyContractId, ";添加续约异常记录失败,ERR:", tmpErr))
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// afterReject 驳回完成后操作
|
|
|
func afterReject(companyApprovalId, opUserId int, opUserName, remark string) (err error) {
|
|
|
defer func() {
|