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

This commit is contained in:
gazebo
2019-08-13 15:18:52 +08:00
3 changed files with 27 additions and 23 deletions

View File

@@ -165,6 +165,18 @@ func GetSkuSaleStatusName(status int) string {
return model.SkuStatusName[status] return model.SkuStatusName[status]
} }
func GetBoolName(flag bool) string {
if flag {
return "是"
} else {
return "否"
}
}
func IsSkuCanSale(saleStatus int) bool {
return saleStatus == model.SkuStatusNormal
}
func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) { func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) {
for skuID, jxSkuInfo := range filterJxSkuInfoMap { for skuID, jxSkuInfo := range filterJxSkuInfoMap {
skuIDStr := utils.Int2Str(skuID) skuIDStr := utils.Int2Str(skuID)
@@ -182,23 +194,14 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
status = jxSkuInfo.Skus2[0].JdSyncStatus status = jxSkuInfo.Skus2[0].JdSyncStatus
} }
syncStatus := utils.Int2Str(int(status)) syncStatus := utils.Int2Str(int(status))
toBeCreate := "否" toBeCreate := GetBoolName(model.IsSyncStatusNeedCreate(status))
if model.IsSyncStatusNeedCreate(status) { toBeDel := GetBoolName(model.IsSyncStatusNeedDelete(status))
toBeCreate = "是"
}
toBeDel := "否"
if model.IsSyncStatusNeedDelete(status) {
toBeDel = "是"
}
if vendorSkuInfo != nil { if vendorSkuInfo != nil {
vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName
vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status) vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status)
isSaleStatusDiff := jxSkuSaleStatusName != vendorSkuSaleStatusName isSaleStatusDiff := jxSkuSaleStatusName != vendorSkuSaleStatusName
if isFilterToBeCreateAndNotSale && model.IsSyncStatusNeedCreate(status) && jxSkuSaleStatus != model.SkuStatusNormal {
continue
}
isNameDiff := jxSkuDetailName != vendorSkuDetailName isNameDiff := jxSkuDetailName != vendorSkuDetailName
if jxSkuDetailName != "" && vendorSkuDetailName != "" && strings.Contains(jxSkuDetailName, vendorSkuDetailName) { if jxSkuDetailName != "" && vendorSkuDetailName != "" && strings.Contains(jxSkuDetailName, vendorSkuDetailName) {
isNameDiff = false isNameDiff = false
@@ -208,6 +211,9 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
diffData.AppendData(vendorID, outPutData) diffData.AppendData(vendorID, outPutData)
} }
} else { } else {
if isFilterToBeCreateAndNotSale && model.IsSyncStatusNeedCreate(status) && !IsSkuCanSale(jxSkuSaleStatus) {
continue
}
outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, ""} outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, ""}
diffData.AppendData(vendorID, outPutData) diffData.AppendData(vendorID, outPutData)
} }

View File

@@ -57,8 +57,7 @@ var (
} }
) )
func AddOrDelExtraStoreOptime(vendorID, storeID int, vendorStoreID string, storeInfo *model.Store, startOpStoreTime, endOpStoreTime int16, needAddTime bool) bool { func AddOrDelExtraStoreOptime(ctx *jxcontext.Context, vendorID, storeID int, vendorStoreID string, storeInfo *model.Store, startOpStoreTime, endOpStoreTime int16, needAddTime bool) bool {
ctx := jxcontext.AdminCtx
opTimeList := storeInfo.GetOpTimeList() opTimeList := storeInfo.GetOpTimeList()
if needAddTime { if needAddTime {
opTimeList = []int16{startOpStoreTime, endOpStoreTime} opTimeList = []int16{startOpStoreTime, endOpStoreTime}
@@ -97,8 +96,7 @@ func SetSkuStock(isStart bool, storeSkuNameList []*partner.SkuNameInfo) {
} }
} }
func SetSpecialSkuStatus(storeID, vendorID int, vendorStoreID string, storeSkuNameList []*partner.SkuNameInfo) { func SetSpecialSkuStatus(ctx *jxcontext.Context, storeID, vendorID int, vendorStoreID string, storeSkuNameList []*partner.SkuNameInfo) {
ctx := jxcontext.AdminCtx
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler) singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
for _, skuNameInfo := range storeSkuNameList { for _, skuNameInfo := range storeSkuNameList {
for _, skuInfo := range skuNameInfo.SkuList { for _, skuInfo := range skuNameInfo.SkuList {
@@ -120,7 +118,7 @@ func GetFilterStoreSkuList(storeSkuList []*partner.StoreSkuInfo) (storeSkuListOu
return storeSkuListOut return storeSkuListOut
} }
func StartOrEndOpStore(isStart bool, vendorIDList []int, storeIDList []int, startTime, endTime int16, isAsync, isContinueWhenError bool) (retVal interface{}, err error) { func StartOrEndOpStore(ctx *jxcontext.Context, isStart bool, vendorIDList []int, storeIDList []int, startTime, endTime int16, isAsync, isContinueWhenError bool) (retVal interface{}, err error) {
startProcessTime := time.Now().Unix() startProcessTime := time.Now().Unix()
vendorMap := make(map[int]bool) vendorMap := make(map[int]bool)
for _, vendorID := range vendorIDList { for _, vendorID := range vendorIDList {
@@ -131,7 +129,6 @@ func StartOrEndOpStore(isStart bool, vendorIDList []int, storeIDList []int, star
storeIDMap[storeID] = true storeIDMap[storeID] = true
} }
baseapi.SugarLogger.Debugf("StartOrEndOpStore start time: %v", time.Now()) baseapi.SugarLogger.Debugf("StartOrEndOpStore start time: %v", time.Now())
ctx := jxcontext.AdminCtx
storeInfo, err := cms.GetStores(ctx, "", map[string]interface{}{}, 0, -1, utils.DefaultTimeValue, utils.DefaultTimeValue, 0, 0) storeInfo, err := cms.GetStores(ctx, "", map[string]interface{}{}, 0, -1, utils.DefaultTimeValue, utils.DefaultTimeValue, 0, 0)
if err != nil { if err != nil {
@@ -170,14 +167,14 @@ func StartOrEndOpStore(isStart bool, vendorIDList []int, storeIDList []int, star
baseapi.SugarLogger.Errorf("StartOrEndOpStore GetStoreSkusFullInfo error:%v storeID:%d vendorID:%d vendorStoreID:%s", err, storeID, vendorID, vendorStoreID) baseapi.SugarLogger.Errorf("StartOrEndOpStore GetStoreSkusFullInfo error:%v storeID:%d vendorID:%d vendorStoreID:%s", err, storeID, vendorID, vendorStoreID)
} else { } else {
SetSkuStock(isStart, storeSkuNameList) SetSkuStock(isStart, storeSkuNameList)
SetSpecialSkuStatus(storeID, vendorID, vendorStoreID, storeSkuNameList) SetSpecialSkuStatus(ctx, storeID, vendorID, vendorStoreID, storeSkuNameList)
storeSkuList := putils.StoreSkuFullList2Bare(storeSkuNameList) storeSkuList := putils.StoreSkuFullList2Bare(storeSkuNameList)
if vendorID == model.VendorIDMTWM { if vendorID == model.VendorIDMTWM {
storeSkuList = GetFilterStoreSkuList(storeSkuList) storeSkuList = GetFilterStoreSkuList(storeSkuList)
} }
if len(storeSkuList) > 0 { if len(storeSkuList) > 0 {
if !isStart { if !isStart {
AddOrDelExtraStoreOptime(vendorID, storeID, vendorStoreID, &storeListValue.Store, startOpStoreTime, endOpStoreTime, false) AddOrDelExtraStoreOptime(ctx, vendorID, storeID, vendorStoreID, &storeListValue.Store, startOpStoreTime, endOpStoreTime, false)
} }
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品库存", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) { _, err = putils.FreeBatchStoreSkuInfo("更新门店商品库存", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
@@ -190,7 +187,7 @@ func StartOrEndOpStore(isStart bool, vendorIDList []int, storeIDList []int, star
}, ctx, task, storeSkuList, singleStoreHandler.GetStoreSkusBatchSize(partner.FuncUpdateStoreSkusStock), true) }, ctx, task, storeSkuList, singleStoreHandler.GetStoreSkusBatchSize(partner.FuncUpdateStoreSkusStock), true)
if isStart { if isStart {
AddOrDelExtraStoreOptime(vendorID, storeID, vendorStoreID, &storeListValue.Store, startOpStoreTime, endOpStoreTime, true) AddOrDelExtraStoreOptime(ctx, vendorID, storeID, vendorStoreID, &storeListValue.Store, startOpStoreTime, endOpStoreTime, true)
} }
} }
} }
@@ -233,17 +230,18 @@ func GetVendorStoreRefreshTime(vendorID int) (startTimeList, stopTimeList []stri
} }
func RefreshStore(vendorID int) { func RefreshStore(vendorID int) {
ctx := jxcontext.AdminCtx
startTimeList, stopTimeList := GetVendorStoreRefreshTime(vendorID) startTimeList, stopTimeList := GetVendorStoreRefreshTime(vendorID)
vendorIDList := []int{vendorID} vendorIDList := []int{vendorID}
storeIDList := []int{} storeIDList := []int{}
ScheduleTimerFunc("StartOpStore", func() { ScheduleTimerFunc("StartOpStore", func() {
if !IsImportantTaskRunning(TaskNameSyncStoreSku) { if !IsImportantTaskRunning(TaskNameSyncStoreSku) {
StartOrEndOpStore(true, vendorIDList, storeIDList, 0, 0, false, true) StartOrEndOpStore(ctx, true, vendorIDList, storeIDList, 0, 0, false, true)
} }
}, startTimeList) }, startTimeList)
ScheduleTimerFunc("EndOpStore", func() { ScheduleTimerFunc("EndOpStore", func() {
if !IsImportantTaskRunning(TaskNameSyncStoreSku) { if !IsImportantTaskRunning(TaskNameSyncStoreSku) {
StartOrEndOpStore(false, vendorIDList, storeIDList, 0, 0, false, true) StartOrEndOpStore(ctx, false, vendorIDList, storeIDList, 0, 0, false, true)
} }
}, stopTimeList) }, stopTimeList)
} }

View File

@@ -292,7 +292,7 @@ func (c *TempOpController) TestStartOrEndOpStore() {
var vendorIDList []int var vendorIDList []int
var storeIDList []int var storeIDList []int
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil { if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil {
retVal, err = misc.StartOrEndOpStore(params.StartOrEndStore, vendorIDList, storeIDList, int16(params.StartTime), int16(params.EndTime), params.IsAsync, params.IsContinueWhenError) retVal, err = misc.StartOrEndOpStore(params.Ctx, params.StartOrEndStore, vendorIDList, storeIDList, int16(params.StartTime), int16(params.EndTime), params.IsAsync, params.IsContinueWhenError)
} }
return retVal, "", err return retVal, "", err
}) })