zhou.xiaoning il y a 3 ans
Parent
commit
107d9d6fce
2 fichiers modifiés avec 9 ajouts et 1 suppressions
  1. 1 1
      models/wrTrade2.go
  2. 8 0
      utils/sqlUtils.go

+ 1 - 1
models/wrTrade2.go

@@ -151,7 +151,7 @@ func (r *WrOrderQuote) buildSqlFixedPrice() string {
 	param.AndEx("t.deliverymonth", r.DELIVERYMONTH, len(r.DELIVERYMONTH) > 1)
 
 	if d, ok := r.ftItemName(); ok {
-		param2.AndLikes("w.wrfactortypename", d...)
+		param2.AndLikes2("w.wrfactortypename", "w.wrfactortypename2", d...)
 	}
 	//指定品类id
 	if r.WRSTANDARDID > 0 {

+ 8 - 0
utils/sqlUtils.go

@@ -100,6 +100,14 @@ func (r *SQLVal) AndLikes(fieldName string, param ...string) {
 	}
 }
 
+func (r *SQLVal) AndLikes2(fieldName string, fieldName2 string, param ...string) {
+	if len(param) > 0 {
+		for _, val := range param {
+			*r += SQLVal(fmt.Sprintf(" and (%v like '%%%v%%' or %v like '%%%v%%')", fieldName, val, fieldName2, val))
+		}
+	}
+}
+
 // Page 分页查询 pageNum-页码 第几页, pageSize-每页大小
 func (r *SQLVal) Page(pageNum int, pageSize int) {
 	if pageNum <= 0 || pageSize <= 0 {