|
@@ -56,14 +56,22 @@ func UpdateRaiServeBillDate(cont context.Context) (err error) {
|
|
|
go utils.SendAlarmMsg(fmt.Sprint("定时任务处理权益服务公司 失败 UpdateRaiServeBillDate ,err:", err.Error()), 2)
|
|
|
}
|
|
|
}()
|
|
|
+
|
|
|
+ err = UpdateRaiServeCompany() // 处理共享机构信息
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
err = UpdateCygxRaiServeBillByCompanyIds() // 处理个人流水记录
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
err = UpdateCygxRaiServeBillWeekTask() // 更新周度服务明细
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
err = UpdateWeekAvg() //更新最近四周平均覆盖率,是否标红,权限,时间,金额
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -90,12 +98,29 @@ func UpdateRaiServeCompany() (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ raiServeCompanyList, e := rai_serve.GetCygxRaiServeCompanyAllList()
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCygxRaiServeCompanyAllList, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ mapOLdCompany := make(map[int]bool)
|
|
|
+ mapOLdCompanyDate := make(map[int]string)
|
|
|
+ for _, v := range raiServeCompanyList {
|
|
|
+ mapOLdCompany[v.CompanyId] = true
|
|
|
+ mapOLdCompanyDate[v.CompanyId] = fmt.Sprint(v.CompanyId, v.CompanyName, v.SellerId, v.StartDate, v.EndDate, v.ShareSeller, v.ShareSellerId, v.Status, v.GroupId, v.ShareGroupId)
|
|
|
+ }
|
|
|
+
|
|
|
+ var delCompanyIds []int // 需要删除的公司ID
|
|
|
+ for _, v := range listCompanyProduct {
|
|
|
+ if !mapOLdCompany[v.CompanyId] {
|
|
|
+ delCompanyIds = append(delCompanyIds, v.CompanyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var items []*rai_serve.CygxRaiServeCompany
|
|
|
+ var itemsUpadte []*rai_serve.CygxRaiServeCompany
|
|
|
for _, v := range listCompanyProduct {
|
|
|
- //mapNewCompanyId[v.CompanyId] = true
|
|
|
- //if mapOldCompanyId[v.CompanyId] {
|
|
|
- // continue
|
|
|
- //}
|
|
|
item := new(rai_serve.CygxRaiServeCompany)
|
|
|
item.CompanyId = v.CompanyId
|
|
|
item.CompanyName = v.CompanyName
|
|
@@ -109,11 +134,21 @@ func UpdateRaiServeCompany() (err error) {
|
|
|
item.Status = v.Status
|
|
|
item.GroupId = v.GroupId
|
|
|
item.ShareGroupId = v.ShareGroupId
|
|
|
- items = append(items, item)
|
|
|
+ if !mapOLdCompany[v.CompanyId] {
|
|
|
+ items = append(items, item) // 如果原有数据不存在就新增
|
|
|
+ } else {
|
|
|
+ if mapOLdCompanyDate[v.CompanyId] != fmt.Sprint(v.CompanyId, v.CompanyName, v.SellerId, v.StartDate, v.EndDate, v.ShareSeller, v.ShareSellerId, v.Status, v.GroupId, v.ShareGroupId) {
|
|
|
+ itemsUpadte = append(itemsUpadte, item) // 新老数据不一致就进行修改
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ fmt.Println("items", len(items))
|
|
|
+ fmt.Println("itemsUpadte", len(itemsUpadte))
|
|
|
+ fmt.Println("delCompanyIds", len(delCompanyIds))
|
|
|
+
|
|
|
//先删除老的再添加新的
|
|
|
- e = rai_serve.AddCygxRaiServeCompanyMulti(items)
|
|
|
+ e = rai_serve.AddCygxRaiServeCompanyMulti(items, itemsUpadte, delCompanyIds)
|
|
|
if e != nil {
|
|
|
err = errors.New("AddCygxRaiServeCompanyMulti, Err: " + e.Error())
|
|
|
return
|