|
@@ -31,7 +31,7 @@ func HandleCompanyContract(cont context.Context) (err error) {
|
|
utils.FileLog.Info("HandleCompanyContract Err:%s" + err.Error())
|
|
utils.FileLog.Info("HandleCompanyContract Err:%s" + err.Error())
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- fmt.Sprintln("总共d%条数据待处理", total)
|
|
+ fmt.Printf("总共%d条数据待处理\n", total)
|
|
errorList := make([]string, 0)
|
|
errorList := make([]string, 0)
|
|
for _, v := range list {
|
|
for _, v := range list {
|
|
|
|
|
|
@@ -135,10 +135,10 @@ func HandleCompanyContract(cont context.Context) (err error) {
|
|
|
|
|
|
{
|
|
{
|
|
cygx.YanXuanCompanyApproval(v.CompanyId)
|
|
cygx.YanXuanCompanyApproval(v.CompanyId)
|
|
- cygx.ActivitySpecialCompanyApproval(v.CompanyId, v.CompanyContractId, companyProduct.CompanyName)
|
|
+ cygx.ActivitySpecialCompanyApproval(v.CompanyId, v.CompanyContractId, companyProduct.CompanyName)
|
|
- cygx.HandleAllocationCompanyContractByYanXuan(v.CompanyContractId)
|
|
+ cygx.HandleAllocationCompanyContractByYanXuan(v.CompanyContractId)
|
|
- cygx.HandleCompanyContractPackageDifference(v.CompanyContractId)
|
|
+ cygx.HandleCompanyContractPackageDifference(v.CompanyContractId)
|
|
- cygx.HandleCompanyContractPermissionContractType(v.CompanyContractId)
|
|
+ cygx.HandleCompanyContractPermissionContractType(v.CompanyContractId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -235,7 +235,7 @@ func HandleCompanyRenewalRecord(cont context.Context) (err error) {
|
|
utils.FileLog.Info("HandleCompanyRenewalRecord GetStartContractListByEndDate Err:%s" + err.Error())
|
|
utils.FileLog.Info("HandleCompanyRenewalRecord GetStartContractListByEndDate Err:%s" + err.Error())
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- fmt.Sprintln("总共d%条数据待处理", total)
|
|
+ fmt.Printf("总共%d条数据待处理\n", total)
|
|
if total <= 0 {
|
|
if total <= 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -281,3 +281,431 @@ func HandleCompanyRenewalRecord(cont context.Context) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func handleCompanyRenewalRecord(endDate string, source int) (err error) {
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ go alarm_msg.SendAlarmMsg(fmt.Sprintf("日期:%s;来源%d;处理合同到期后还未续约的记录异常 ErrMsg:%s", endDate, source, err.Error()), 3)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ total, list, err := company_contract.GetContractListByEndDate(endDate)
|
|
|
|
+ if err != nil {
|
|
|
|
+ utils.FileLog.Info("HandleCompanyRenewalRecord GetStartContractListByEndDate Err:%s" + err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ fmt.Printf("总共%d条数据待处理\n", total)
|
|
|
|
+ if total <= 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ companyIdList := make([]int, 0)
|
|
|
|
+ for _, companyInfo := range list {
|
|
|
|
+ companyIdList = append(companyIdList, companyInfo.CompanyId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ companyList, err := models.GetCompanyProductItemListByCompanyIdList(companyIdList, 1)
|
|
|
|
+ if err != nil {
|
|
|
|
+ utils.FileLog.Info("HandleCompanyRenewalRecord GetCompanyProductListByCompanyIdList Err:%s" + err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addList := make([]*models.CompanyRenewalRecord, 0)
|
|
|
|
+ for _, v := range companyList {
|
|
|
|
+ if v.Status != "正式" {
|
|
|
|
+ var shareSellerId int
|
|
|
|
+ var shareSellerName string
|
|
|
|
+ if v.IsShare == 1 {
|
|
|
|
+ shareSellerId = v.ShareSellerId
|
|
|
|
+ shareSellerName = v.ShareSeller
|
|
|
|
+ }
|
|
|
|
+ addList = append(addList, &models.CompanyRenewalRecord{
|
|
|
|
+ Id: 0,
|
|
|
|
+ CompanyId: v.CompanyId,
|
|
|
|
+ ProductId: v.ProductId,
|
|
|
|
+ Source: source,
|
|
|
|
+ SellerId: v.SellerId,
|
|
|
|
+ SellerName: v.SellerName,
|
|
|
|
+ ShareSellerId: shareSellerId,
|
|
|
|
+ ShareSellerName: shareSellerName,
|
|
|
|
+ CreateTime: time.Now(),
|
|
|
|
+ ModifyTime: time.Now(),
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if len(addList) > 0 {
|
|
|
|
+ err = models.MultiAddCompanyRenewalRecord(addList)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func handleCompanyExpiringRenewalRecord(contractDate string, source int) (err error) {
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ go alarm_msg.SendAlarmMsg(fmt.Sprintf("日期:%s;来源%d;处理合同即将到期(还未过期)后还未续约的记录异常 ErrMsg:%s", contractDate, source, err.Error()), 3)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ total, list, err := company_contract.GetContractListByEndDate(contractDate)
|
|
|
|
+ if err != nil {
|
|
|
|
+ utils.FileLog.Info("HandleCompanyRenewalRecord GetStartContractListByEndDate Err:%s" + err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ fmt.Printf("总共%d条数据待处理\n", total)
|
|
|
|
+ if total <= 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ companyIdList := make([]int, 0)
|
|
|
|
+ for _, companyInfo := range list {
|
|
|
|
+ companyIdList = append(companyIdList, companyInfo.CompanyId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ afterContractCompanyIdMap := make(map[int]int)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ _, afterContractList, tmpErr := company_contract.GetAfterCompanyContractListByCompanyIdListAndEndDate(contractDate, companyIdList)
|
|
|
|
+ if tmpErr != nil {
|
|
|
|
+ err = tmpErr
|
|
|
|
+ utils.FileLog.Info("company_contract.GetAfterCompanyContractListByCompanyIdListAndEndDate Err:%s" + err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, afterContract := range afterContractList {
|
|
|
|
+ afterContractCompanyIdMap[afterContract.CompanyId] = afterContract.CompanyId
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ companyList, err := models.GetCompanyProductItemListByCompanyIdList(companyIdList, 1)
|
|
|
|
+ if err != nil {
|
|
|
|
+ utils.FileLog.Info("HandleCompanyRenewalRecord GetCompanyProductListByCompanyIdList Err:%s" + err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addList := make([]*models.CompanyRenewalRecord, 0)
|
|
|
|
+ for _, v := range companyList {
|
|
|
|
+ _, ok := afterContractCompanyIdMap[v.CompanyId]
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if ok {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var shareSellerId int
|
|
|
|
+ var shareSellerName string
|
|
|
|
+ if v.IsShare == 1 {
|
|
|
|
+ shareSellerId = v.ShareSellerId
|
|
|
|
+ shareSellerName = v.ShareSeller
|
|
|
|
+ }
|
|
|
|
+ addList = append(addList, &models.CompanyRenewalRecord{
|
|
|
|
+ Id: 0,
|
|
|
|
+ CompanyId: v.CompanyId,
|
|
|
|
+ ProductId: v.ProductId,
|
|
|
|
+ Source: source,
|
|
|
|
+ SellerId: v.SellerId,
|
|
|
|
+ SellerName: v.SellerName,
|
|
|
|
+ ShareSellerId: shareSellerId,
|
|
|
|
+ ShareSellerName: shareSellerName,
|
|
|
|
+ CreateTime: time.Now(),
|
|
|
|
+ ModifyTime: time.Now(),
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if len(addList) > 0 {
|
|
|
|
+ err = models.MultiAddCompanyRenewalRecord(addList)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func HandleCompanyRenewalRecordV2(cont context.Context) (err error) {
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ go alarm_msg.SendAlarmMsg("合同处理 ErrMsg:"+err.Error(), 3)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ endDate := time.Now().AddDate(0, 0, -60-1).Format(utils.FormatDate)
|
|
|
|
+ handleCompanyRenewalRecord(endDate, 1)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ endDate := time.Now().AddDate(0, 0, -30-1).Format(utils.FormatDate)
|
|
|
|
+ handleCompanyRenewalRecord(endDate, 4)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ endDate := time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
|
|
|
|
+ handleCompanyRenewalRecord(endDate, 5)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ endDate := time.Now().AddDate(0, 0, 30-1).Format(utils.FormatDate)
|
|
|
|
+ handleCompanyExpiringRenewalRecord(endDate, 6)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ endDate := time.Now().AddDate(0, 0, 60-1).Format(utils.FormatDate)
|
|
|
|
+ handleCompanyExpiringRenewalRecord(endDate, 7)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ endDate := time.Now().AddDate(0, 0, 90-1).Format(utils.FormatDate)
|
|
|
|
+ handleCompanyExpiringRenewalRecord(endDate, 8)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ endDate := time.Now().AddDate(0, 0, 120-1).Format(utils.FormatDate)
|
|
|
|
+ handleCompanyExpiringRenewalRecord(endDate, 9)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
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