فهرست منبع

feat:表名更换

wangchuanjin 10 ماه پیش
والد
کامیت
1cab2d81be
1فایلهای تغییر یافته به همراه9 افزوده شده و 5 حذف شده
  1. 9 5
      src/jfw/modules/subscribepay/src/service/network.go

+ 9 - 5
src/jfw/modules/subscribepay/src/service/network.go

@@ -38,6 +38,10 @@ func (n *Network) ProjectExport() {
 	pool := make(chan bool, 3)
 	wait := &sync.WaitGroup{}
 	lock := &sync.Mutex{}
+	tableName := "transaction_info"
+	if n.GetString("version") == "1" {
+		tableName := "transaction_info_all"
+	}
 	for _, v := range strings.Split(exportIds, ",") {
 		args = append(args, v)
 		wh = append(wh, "?")
@@ -49,7 +53,7 @@ func (n *Network) ProjectExport() {
 					<-pool
 					wait.Done()
 				}()
-				ids := n.search(wh1, args1)
+				ids := n.search(tableName, wh1, args1)
 				lock.Lock()
 				bIds = append(bIds, ids...)
 				lock.Unlock()
@@ -60,7 +64,7 @@ func (n *Network) ProjectExport() {
 	}
 	wait.Wait()
 	if len(args) > 0 {
-		bIds = append(bIds, n.search(wh, args)...)
+		bIds = append(bIds, n.search(tableName, wh, args)...)
 	}
 	if len(bIds) == 0 {
 		return
@@ -90,7 +94,7 @@ func (n *Network) ProjectExport() {
 		return
 	} else if file == nil {
 		log.Println("人脉通项目导出", export_id, "未找到标讯的情报信息")
-		http.Error(n.ResponseWriter, "未找到标讯的情报信息", http.StatusInternalServerError)
+		http.Error(n.ResponseWriter, "未找到标讯信息", http.StatusInternalServerError)
 		return
 	} else if fileErr != nil {
 		log.Println("人脉通项目导出", export_id, fileErr)
@@ -107,9 +111,9 @@ func (n *Network) ProjectExport() {
 	}
 }
 
-func (n *Network) search(wh []string, args []interface{}) []string {
+func (n *Network) search(tableName string, wh []string, args []interface{}) []string {
 	bIds := []string{}
-	rows, err := util.ClickhouseConn.Query(context.Background(), `select info_id,info_ids from information.transaction_info where project_id in (`+strings.Join(wh, ",")+`)`, args...)
+	rows, err := util.ClickhouseConn.Query(context.Background(), `select info_id,info_ids from information.`+tableName+` where project_id in (`+strings.Join(wh, ",")+`)`, args...)
 	if err != nil {
 		log.Println(err)
 		return bIds