Explorar o código

修改数据导出列表

wangkaiyue %!s(int64=6) %!d(string=hai) anos
pai
achega
3062fd0fa5
Modificáronse 2 ficheiros con 27 adicións e 9 borrados
  1. 20 6
      common/src/qfw/util/mysql/mysql.go
  2. 7 3
      core/src/qfw/manage/dataExportOrder.go

+ 20 - 6
common/src/qfw/util/mysql/mysql.go

@@ -74,7 +74,8 @@ func (m *Mysql) Insert(tableName string, data map[string]interface{}) int64 {
 }
 
 /*不等于 map[string]string{"ne":"1"}
- *
+ *字段为空 map[string]string{"name":"$isNull"}
+ *字段不为空 map[string]string{"name":"$isNotNull"}
  */
 func (m *Mysql) Find(tableName string, query map[string]interface{}, fields, order string, start, pageSize int) *[]map[string]interface{} {
 	fs := []string{}
@@ -90,8 +91,14 @@ func (m *Mysql) Find(tableName string, query map[string]interface{}, fields, ord
 				}
 			}
 		} else {
-			fs = append(fs, fmt.Sprintf("%s=?", k))
-			vs = append(vs, v)
+			if v == "$isNull" {
+				fs = append(fs, fmt.Sprintf("%s is null", k))
+			} else if v == "$isNotNull" {
+				fs = append(fs, fmt.Sprintf("%s is not null", k))
+			} else {
+				fs = append(fs, fmt.Sprintf("%s=?", k))
+				vs = append(vs, v)
+			}
 		}
 	}
 	var buffer bytes.Buffer
@@ -241,11 +248,18 @@ func (m *Mysql) Count(tableName string, query map[string]interface{}) int64 {
 	fields := []string{}
 	values := []interface{}{}
 	for k, v := range query {
-		fields = append(fields, fmt.Sprintf("%s=?", k))
-		values = append(values, v)
+		if v == "$isNull" {
+			fields = append(fields, fmt.Sprintf("%s is null", k))
+		} else if v == "$isNotNull" {
+			log.Println("xxxx")
+			fields = append(fields, fmt.Sprintf("%s is not null", k))
+		} else {
+			fields = append(fields, fmt.Sprintf("%s=?", k))
+			values = append(values, v)
+		}
 	}
 	q := fmt.Sprintf("select count(1) as count from %s", tableName)
-	if len(values) > 0 {
+	if len(query) > 0 {
 		q += fmt.Sprintf(" where %s", strings.Join(fields, " and "))
 	}
 	log.Println(q, values)

+ 7 - 3
core/src/qfw/manage/dataExportOrder.go

@@ -2,6 +2,7 @@ package manage
 
 import (
 	"fmt"
+
 	"qfw/coreconfig"
 	util "qfw/coreutil"
 
@@ -32,15 +33,18 @@ func (d *DataExportOrder) Pageing() {
 		qMap["order_code"] = code
 	}
 	if order_status != "" {
-		qMap["order_status"] = order_status
+		if order_status == "0" {
+			qMap["pay_time"] = "$isNull"
+		} else if order_status == "1" {
+			qMap["pay_time"] = "$isNotNull"
+		}
 	}
 	if service_status != "" {
 		qMap["service_status"] = service_status
 	}
 	res := util.Mysql.Find("dataexport_order", qMap, "order_code,pay_time,data_spec,order_money,order_status,service_status,download_url,applybill_status,pay_money,pay_way,user_mail,applybill_company,applybill_type", "create_time desc", (currentPage-1)*perPage, perPage)
-	fmt.Println("res", res)
-	count := util.Mysql.Count("dataexport_order", qMap)
 
+	count := util.Mysql.Count("dataexport_order", qMap)
 	for k, v := range *res {
 		v["index"] = k + 1
 		var y, n int64 = 1, 0