|
@@ -21,8 +21,10 @@ func AddCompanyReportRecord(cont context.Context) (err error) {
|
|
|
}()
|
|
|
|
|
|
endDate := time.Now().Format(utils.FormatDate)
|
|
|
+ productId := 1
|
|
|
|
|
|
- existList, err := models.GetExistCompanyReportRecord(endDate)
|
|
|
+ // 查找已经记录的ficc的记录
|
|
|
+ existList, err := models.GetExistCompanyReportRecord(endDate, productId)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -30,15 +32,23 @@ func AddCompanyReportRecord(cont context.Context) (err error) {
|
|
|
for _, v := range existList {
|
|
|
existMap[v.CompanyId] = v
|
|
|
}
|
|
|
- list, err := models.GetCompanyList(endDate)
|
|
|
+ // 查找当前ficc的客户列表
|
|
|
+ list, err := models.GetCompanyList(productId)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
for _, v := range list {
|
|
|
- if _, ok := existMap[v.CompanyId]; ok { //修改
|
|
|
+ if info, ok := existMap[v.CompanyId]; ok { //修改
|
|
|
+ //校验字段是否变更,如果有变更,那么就更新
|
|
|
+ if !checkUpdate(info, v) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
utils.FileLog.Info("update company:" + strconv.Itoa(v.CompanyId))
|
|
|
recordWhereParams := make(map[string]interface{})
|
|
|
- recordWhereParams["company_id"] = v.CompanyId
|
|
|
+ //recordWhereParams["company_id"] = v.CompanyId
|
|
|
+ //recordWhereParams["product_id"] = productId
|
|
|
+ //recordWhereParams["create_date"] = endDate
|
|
|
+ recordWhereParams["company_report_record_id"] = info.CompanyReportRecordId
|
|
|
|
|
|
recordUpdateParams := make(map[string]interface{})
|
|
|
recordUpdateParams["company_name"] = v.CompanyName
|
|
@@ -54,6 +64,7 @@ func AddCompanyReportRecord(cont context.Context) (err error) {
|
|
|
utils.FileLog.Info("add company:" + strconv.Itoa(v.CompanyId))
|
|
|
item := new(models.CompanyReportRecord)
|
|
|
item.CompanyId = v.CompanyId
|
|
|
+ item.ProductId = v.ProductId
|
|
|
item.CompanyProductId = v.CompanyProductId
|
|
|
item.CompanyName = v.CompanyName
|
|
|
item.Status = v.Status
|
|
@@ -74,3 +85,37 @@ func AddCompanyReportRecord(cont context.Context) (err error) {
|
|
|
companyLock.Unlock()
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+// checkUpdate 判断是否要更新
|
|
|
+func checkUpdate(companyReportRecordInfo, companyInfo *models.CompanyReportRecord) bool {
|
|
|
+ // 潜在用户过滤
|
|
|
+ if companyInfo.CompanyId == 1 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //状态
|
|
|
+ if companyReportRecordInfo.Status != companyInfo.Status {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ //客户名称
|
|
|
+ if companyReportRecordInfo.CompanyName != companyInfo.CompanyName {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ //有效开始时间
|
|
|
+ if companyReportRecordInfo.StartDate != companyInfo.StartDate {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ //有效结束时间
|
|
|
+ if companyReportRecordInfo.EndDate != companyInfo.EndDate {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ //所属销售
|
|
|
+ if companyReportRecordInfo.SellerId != companyInfo.SellerId {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ //社会信用码
|
|
|
+ if companyReportRecordInfo.CreditCode != companyInfo.CreditCode {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ return false
|
|
|
+}
|