- fix placeCond and vendorStoreCond bug.

This commit is contained in:
gazebo
2018-09-13 11:29:28 +08:00
parent 016727586d
commit f782e8dcc0
2 changed files with 22 additions and 14 deletions

View File

@@ -145,10 +145,11 @@ func GetStores(keyword string, params map[string]interface{}, offset, pageSize i
sqlParams = append(sqlParams, fromStatus, toStatus)
}
if vendorStoreCond := strings.ToUpper(utils.Interface2String(params["vendorStoreCond"])); vendorStoreCond == "AND" || vendorStoreCond == "OR" {
sqlVendorStoreCond := ""
if vendorStoreCond == "AND" {
sqlWhere += " AND ( 1 = 1"
sqlVendorStoreCond += " AND ( 1 = 1"
} else {
sqlWhere += " AND ( 1 = 0"
sqlVendorStoreCond += " AND ( 1 = 0"
}
condMap := map[string]int{
"jdm": utils.Interface2DirectIntWithDefault(params["jdCond"], 0),
@@ -157,15 +158,17 @@ func GetStores(keyword string, params map[string]interface{}, offset, pageSize i
}
for tableName, cond := range condMap {
if cond != 0 {
sqlWhere += " " + vendorStoreCond + " " + tableName
sqlVendorStoreCond += " " + vendorStoreCond + " " + tableName
}
if cond == -1 {
sqlWhere += ".vendor_store_id IS NULL"
sqlVendorStoreCond += ".vendor_store_id IS NULL"
} else if cond == 1 {
sqlWhere += ".vendor_store_id IS NOT NULL"
sqlVendorStoreCond += ".vendor_store_id IS NOT NULL"
}
}
sqlWhere += ")"
if sqlVendorStoreCond != " AND ( 1 = 0" {
sqlWhere += sqlVendorStoreCond + ")"
}
}
sql := "SELECT SQL_CALC_FOUND_ROWS t1.*, city.name city_name, district.name district_name, jdm.vendor_store_id jd_id, elmm.vendor_store_id elm_id, ebaim.vendor_store_id ebai_id\n" +
sqlFrom + sqlWhere + `