GetStores的vendorStoreConds规则修改,添加vendorOrgCode查询支持

This commit is contained in:
gazebo
2019-12-10 10:38:54 +08:00
parent 70b1dc74d3
commit f3a94938aa
2 changed files with 17 additions and 6 deletions

View File

@@ -239,14 +239,21 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
if mapCond := strings.ToUpper(utils.Interface2String(params[mapCondKey])); mapCond == "AND" || mapCond == "OR" {
mapCondsStr := utils.Interface2String(params[mapCondKey+"s"])
if mapCondsStr != "" {
var vendorStoreConds map[string]int
var vendorStoreConds map[string]interface{}
if err = utils.UnmarshalUseNumber([]byte(mapCondsStr), &vendorStoreConds); err != nil {
return "", nil, "", nil, err
}
sqlVendorStoreCond := ""
for vendor, cond := range vendorStoreConds {
for vendor, cond2 := range vendorStoreConds {
var cond string
if condStr, ok := cond2.(string); !ok {
cond = utils.Int64ToStr(utils.ForceInterface2Int64(cond2))
} else {
cond = condStr
}
tableAlias := tableName + vendor
if cond != 0 {
if cond != "0" && cond != "" {
if sqlVendorStoreCond == "" {
if mapCond == "AND" {
sqlVendorStoreCond += " AND ( 1 = 1"
@@ -258,10 +265,14 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
tableAlias + ".store_id = t1.id AND " + tableAlias + ".deleted_at = ? AND " +
tableAlias + ".is_sync <> 0 "
sqlFromParams = append(sqlFromParams, vendor, utils.DefaultTimeValue)
if cond == 1 {
if cond == "1" {
sqlVendorStoreCond += " " + mapCond + " " + tableAlias + ".id IS NOT NULL"
} else {
} else if cond == "-1" {
sqlVendorStoreCond += " " + mapCond + " " + tableAlias + ".id IS NULL"
} else {
sqlFrom += " AND " + tableAlias + ".vendor_org_code = ?"
sqlFromParams = append(sqlFromParams, cond)
sqlVendorStoreCond += " " + mapCond + " " + tableAlias + ".id IS NOT NULL"
}
}
}