- 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

@@ -9,15 +9,16 @@ import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
)
type SkuNameExt struct {
model.SkuName
Skus []*model.Sku `orm:"-" json:"skus"`
SkusStr string `orm:"size(2000)" json:"-"`
SkusStr string `json:"-"`
Places []*model.SkuNamePlaceBind `orm:"-" json:"places"`
PlacesStr string `orm:"size(2000)" json:"-"`
PlacesStr string `json:"-"`
}
type SkuNamesInfo struct {
@@ -189,23 +190,26 @@ func GetSkuNames(keyword string, params map[string]interface{}, offset, pageSize
sqlParams = append(sqlParams, params["unit"].(string))
}
if placeCond := strings.ToUpper(utils.Interface2String(params["placeCond"])); placeCond == "AND" || placeCond == "OR" {
sqlPlaceCond := ""
if placeCond == "AND" {
sql += " AND ( 1 = 1"
sqlPlaceCond += " AND ( 1 = 1"
} else {
sql += " AND ( 1 = 0"
sqlPlaceCond += " AND ( 1 = 0"
}
if params["placeCode"] != nil {
sql += " " + placeCond + " t3.place_code = ?"
sqlPlaceCond += " " + placeCond + " t3.place_code = ?"
sqlParams = append(sqlParams, params["placeCode"].(int))
}
if params["isGlobal"] != nil {
if params["isGlobal"].(bool) {
sql += " " + placeCond + " t1.is_global = 1"
sqlPlaceCond += " " + placeCond + " t1.is_global = 1"
} else {
sql += " " + placeCond + " t1.is_global = 0"
sqlPlaceCond += " " + placeCond + " t1.is_global = 0"
}
}
sql += ")"
if sqlPlaceCond != " AND ( 1 = 0" {
sql += sqlPlaceCond + ")"
}
}
if params["skuID"] != nil {
sql += " AND t2.id = ?"
@@ -267,6 +271,7 @@ func GetSkuNames(keyword string, params map[string]interface{}, offset, pageSize
}
sqlParams = append(sqlParams, pageSize, offset)
skuNamesInfo = &SkuNamesInfo{}
globals.SugarLogger.Debug(sqlData)
if err = dao.GetRows(db, &skuNamesInfo.SkuNames, sqlData, sqlParams...); err == nil {
countInfo := &struct{ Ct int }{}
if err = dao.GetRow(db, countInfo, "SELECT FOUND_ROWS() ct"); err == nil {