Parcourir la source

Merge branch 'crm_15.9' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai il y a 8 mois
Parent
commit
3b00ba2cc5
2 fichiers modifiés avec 81 ajouts et 14 suppressions
  1. 14 0
      models/rai_serve/rai_serve_bill.go
  2. 67 14
      services/rai_serve_count.go

+ 14 - 0
models/rai_serve/rai_serve_bill.go

@@ -2,6 +2,7 @@ package rai_serve
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
 	"time"
 )
 
@@ -91,3 +92,16 @@ func AddCygxRaiServeBillMulti(items []*CygxRaiServeBill) (err error) {
 	}
 	return
 }
+
+// 批量删除
+func DelCygxRaiServeCompanyMulti(delBillIds []int) (err error) {
+	lenArr := len(delBillIds)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_rai_serve_bill  WHERE bill_id  IN  (` + utils.GetOrmInReplace(lenArr) + `) `
+	_, err = o.Raw(sql, delBillIds).Exec()
+
+	return
+}

+ 67 - 14
services/rai_serve_count.go

@@ -388,6 +388,7 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 			go utils.SendAlarmMsg("批量更新企业服务明细记录失败: UpdateCygxRaiServeBillByCompanyIds Err"+err.Error(), 2)
 		}
 	}()
+	var delBillIds []int
 	fmt.Println("UpdateCygxRaiServeBillByCompanyIds start")
 	companyList, e := rai_serve.GetCygxRaiServeCompanyAllList()
 	if e != nil {
@@ -585,15 +586,15 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 		var parsBill []interface{}
 		conditionBill = " AND source = 'activity' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
 		parsBill = append(parsBill, companyIds, createTime)
-		listBillByArticle, e := rai_serve.GetCygxRaiServeBillListAll(conditionBill, parsBill)
+		listBillByActivity, e := rai_serve.GetCygxRaiServeBillListAll(conditionBill, parsBill)
 		if e != nil {
 			err = errors.New("GetCygxRaiServeBillListAll, Err: " + e.Error())
 			return
 		}
 
-		mapArticleBill := make(map[string]bool)
-		for _, v := range listBillByArticle {
-			mapArticleBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		mapActivityeBill := make(map[string]bool)
+		for _, v := range listBillByActivity {
+			mapActivityeBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
 		}
 
 		mapArticleBillDel := make(map[string]bool)
@@ -601,8 +602,18 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 			mapArticleBillDel[fmt.Sprint("UID_", v.UserId, "SID_", v.ActivityId)] = true
 		}
 
+		mapDelActivityBillDel := make(map[string]bool)
 		for _, v := range signUpDetailList {
-			if mapArticleBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ActivityId)] { // 如果内容存在就不插入
+			mapDelActivityBillDel[fmt.Sprint("UID_", v.UserId, "SID_", v.ActivityId)] = true
+		}
+		for _, v := range listBillByActivity {
+			if !mapDelActivityBillDel[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
+		for _, v := range signUpDetailList {
+			if mapActivityeBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ActivityId)] { // 如果内容存在就不插入
 				continue
 			}
 			item := new(rai_serve.CygxRaiServeBill)
@@ -652,19 +663,29 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 		var parsBill []interface{}
 		conditionBill = " AND source = 'activityspecial' AND   company_id IN  (" + utils.GetOrmInReplace(lencompanyId) + ")  AND view_time > ?  "
 		parsBill = append(parsBill, companyIds, createTime)
-		listBillByArticle, e := rai_serve.GetCygxRaiServeBillListAll(conditionBill, parsBill)
+		listBillByActivitySpecial, e := rai_serve.GetCygxRaiServeBillListAll(conditionBill, parsBill)
 		if e != nil {
 			err = errors.New("GetCygxRaiServeBillListAll, Err: " + e.Error())
 			return
 		}
 
-		mapArticleBill := make(map[string]bool)
-		for _, v := range listBillByArticle {
-			mapArticleBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		mapActivitySpecial := make(map[string]bool)
+		for _, v := range listBillByActivitySpecial {
+			mapActivitySpecial[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
+		}
+
+		mapDelActivitySpecial := make(map[string]bool)
+		for _, v := range activitySpecialList {
+			mapDelActivitySpecial[fmt.Sprint("UID_", v.UserId, "SID_", v.ActivityId)] = true
+		}
+		for _, v := range listBillByActivitySpecial {
+			if !mapDelActivitySpecial[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
 		}
 
 		for _, v := range activitySpecialList {
-			if mapArticleBill[fmt.Sprint("UID_", v.UserId, "SID_", v.ActivityId)] { // 如果内容存在就不插入
+			if mapActivitySpecial[fmt.Sprint("UID_", v.UserId, "SID_", v.ActivityId)] { // 如果内容存在就不插入
 				continue
 			}
 			item := new(rai_serve.CygxRaiServeBill)
@@ -753,6 +774,16 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 			mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
 		}
 
+		mapDelRscalendarBill := make(map[string]bool)
+		for _, v := range calendarMeetingUserList {
+			mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.RsCalendarId)] = true
+		}
+		for _, v := range listBillByRscalendar {
+			if !mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
 		for _, v := range calendarMeetingUserList {
 			if mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.RsCalendarId)] { // 如果内容存在就不插入
 				continue
@@ -817,6 +848,16 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 			mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] = true
 		}
 
+		mapDelRscalendarBill := make(map[string]bool)
+		for _, v := range userFeedbackList {
+			mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.UserFeedbackId)] = true
+		}
+		for _, v := range listBillByuserFeedback {
+			if !mapDelRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.SourceId)] { // 如果内容存在就插入删除ID中
+				delBillIds = append(delBillIds, v.BillId)
+			}
+		}
+
 		for _, v := range userFeedbackList {
 			if mapRscalendarBill[fmt.Sprint("UID_", v.UserId, "SID_", v.UserFeedbackId)] { // 如果内容存在就不插入
 				continue
@@ -846,11 +887,23 @@ func UpdateCygxRaiServeBillByCompanyIds() (err error) {
 	}
 	//交流反馈 end
 
-	e = rai_serve.AddCygxRaiServeBillMulti(items)
-	if e != nil {
-		err = errors.New("AddCygxRaiServeBillMulti, Err: " + e.Error())
-		return
+	if len(items) > 0 {
+		e = rai_serve.AddCygxRaiServeBillMulti(items)
+		if e != nil {
+			err = errors.New("AddCygxRaiServeBillMulti, Err: " + e.Error())
+			return
+		}
+	}
+
+	if len(delBillIds) > 0 {
+		e = rai_serve.DelCygxRaiServeCompanyMulti(delBillIds)
+		if e != nil {
+			err = errors.New("AddCygxRaiServeBillMulti, Err: " + e.Error())
+			return
+		}
 	}
+
+	fmt.Println("delBillIds", (delBillIds))
 	fmt.Println("UpdateCygxRaiServeBillByCompanyIds end")
 	return
 }