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"
}
}
}

View File

@@ -29,7 +29,7 @@ type StoreController struct {
// @Param tel query string false "电话"
// @Param statuss query string false "门店状态列表[-1,0,1]-1禁用0休息关店1正常开店,缺省不限制"
// @Param vendorStoreCond query string false "查询关联门店的条件如果此字段没有设置vendorStoreConds无效andor指的是vendorStoreConds里的条件间的关系这组条件与其它条件都是与的关系"
// @Param vendorStoreConds query string false "为厂商条件对象{vendorID: cond}注意vendorID是字符串形式cond-1没有关联0不限定1有关联缺省为0"
// @Param vendorStoreConds query string false "为厂商条件对象{vendorID: cond}注意vendorID是字符串形式cond-1没有关联0不限定1有关联缺省为0其它值表示vendorOrgCode"
// @Param courierStoreCond query string false "查询关联门店的条件如果此字段没有设置courierStoreConds无效andor指的是courierStoreConds里的条件间的关系这组条件与其它条件都是与的关系"
// @Param courierStoreConds query string false "为厂商条件对象{vendorID: cond}注意vendorID是字符串形式cond-1没有关联0不限定1有关联缺省为0"
// @Param mapLongitude query string false "地图中心经度"