Merge remote-tracking branch 'origin/mark' into yonghui

This commit is contained in:
苏尹岚
2019-12-10 11:48:18 +08:00
10 changed files with 258 additions and 8 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

@@ -129,6 +129,13 @@ func (v *VendorSync) syncCategories(ctx *jxcontext.Context, parentTask tasksch.I
}
func (v *VendorSync) SyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
if !model.IsUseThingMap {
return v.oldSyncCategory(ctx, db, categoryID, isAsync, userName)
}
return SyncCategories(ctx, nil, nil, nil, []int{categoryID}, isAsync)
}
func (v *VendorSync) oldSyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
globals.SugarLogger.Debug("SyncCategory")
hint, err = v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("同步分类信息:%d", categoryID), isAsync, false,
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
@@ -158,6 +165,13 @@ func (v *VendorSync) SyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, categor
}
func (v *VendorSync) SyncReorderCategories(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
if !model.IsUseThingMap {
return v.oldSyncReorderCategories(ctx, db, categoryID, isAsync, userName)
}
return SyncReorderCategories(ctx, -1, isAsync)
}
func (v *VendorSync) oldSyncReorderCategories(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
hint, err = v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("分类重排序:%d", categoryID), isAsync, false, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
vendorInfo := batchItemList[0].(*tMultiStoreVendorInfo)
multiStoresHandler := v.GetMultiStoreHandler(vendorInfo.VendorID)
@@ -232,6 +246,13 @@ func (v *VendorSync) SyncSku(ctx *jxcontext.Context, db *dao.DaoDB, nameID, skuI
}
func (v *VendorSync) SyncSkus(ctx *jxcontext.Context, db *dao.DaoDB, nameIDs []int, skuIDs []int, isAsync, isContinueWhenError bool, userName string) (hint string, err error) {
if !model.IsUseThingMap {
return v.oldSyncSkus(ctx, db, nameIDs, skuIDs, isAsync, isContinueWhenError, userName)
}
return SyncSkus(ctx, nil, nil, nil, nameIDs, skuIDs, isAsync)
}
func (v *VendorSync) oldSyncSkus(ctx *jxcontext.Context, db *dao.DaoDB, nameIDs []int, skuIDs []int, isAsync, isContinueWhenError bool, userName string) (hint string, err error) {
globals.SugarLogger.Debugf("SyncSku trackInfo:%s, nameIDs:%v, skuIDs:%v, userName:%s", ctx.GetTrackInfo(), nameIDs, skuIDs, userName)
isManagedIt := !(len(nameIDs) > 0 && len(nameIDs) <= 2 || len(skuIDs) > 0 && len(skuIDs) < 8)
return v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("同步商品信息, nameIDs:%v, skuIDs:%v", nameIDs, skuIDs), isAsync, isManagedIt,