From 94f9a07519ba213d9f802a890e4d1b2bd96799cb Mon Sep 17 00:00:00 2001 From: Rosy-zhudan Date: Thu, 8 Aug 2019 12:03:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/misc/misc2.go | 100 +++++++++++++++------------------ 1 file changed, 45 insertions(+), 55 deletions(-) diff --git a/business/jxstore/misc/misc2.go b/business/jxstore/misc/misc2.go index b8fb90dc4..4c21d844e 100644 --- a/business/jxstore/misc/misc2.go +++ b/business/jxstore/misc/misc2.go @@ -19,44 +19,42 @@ const ( specialSkuNameKeyWord = "温馨提示" startOpStoreStockNumber = 0 endOpStoreStockNumber = model.MaxStoreSkuStockQty - startOpStoreTimeDefaultMTWM = int16(2200) - endOpStoreTimeDefaultMTWM = int16(2355) - startOpStoreTimeDefaultEBAI = int16(5) - endOpStoreTimeDefaultEBAI = int16(2355) ) var ( - //only for MTWM - startOpStoreTimeListJXGY_MTWM = []string{ - "22:00:00", - } - endOpStoreTimeListJXGY_MTWM = []string{ - "00:00:00", - } - startOpStoreTimeListJXCS_MTWM = []string { - "22:10:00", - } - endOpStoreTimeListJXCS_MTWM = []string{ - "00:10:00", - } - //for other vendor - startOpStoreTimeListJXGY = []string{ - "22:20:00", - } - endOpStoreTimeListJXGY = []string{ - "06:00:00", - } - startOpStoreTimeListJXCS = []string{ - "22:30:00", - } - endOpStoreTimeListJXCS = []string{ - "06:10:00", - } - vendorList = map[int]bool { model.VendorIDMTWM: true, model.VendorIDEBAI: true, } + + vendorStoreRefreshTimeList = map[int][]string { + model.VendorIDMTWM: []string { + //start and end time for JXGY + "22:00:00", + "00:00:00", + //start and end time for JXCS + "22:10:00", + "00:10:00", + }, + model.VendorIDEBAI: []string { + "22:20:00", + "06:00:00", + + "22:30:00", + "06:10:00", + }, + } + + vendorStartEndStoreTime = map[int][]int16 { + model.VendorIDMTWM: []int16 { + int16(2200),//start time + int16(2355),//end time + }, + model.VendorIDEBAI: []int16 { + int16(5), + int16(2355), + }, + } ) func AddOrDelExtraStoreOptime(vendorID, storeID int, vendorStoreID string, storeInfo *model.Store, startOpStoreTime, endOpStoreTime int16, needAddTime bool) bool { @@ -78,13 +76,9 @@ func GetStockValue(isStart bool) int { } func GetOpStoreTime(vendorID int) (startTime, endTime int16) { - if vendorID == model.VendorIDMTWM { - return startOpStoreTimeDefaultMTWM, endOpStoreTimeDefaultMTWM - } else if vendorID == model.VendorIDEBAI { - return startOpStoreTimeDefaultEBAI, endOpStoreTimeDefaultEBAI - } - - return 0, 0 + startTime = vendorStartEndStoreTime[vendorID][0] + endTime = vendorStartEndStoreTime[vendorID][1] + return startTime, endTime } func IsSpecialSku(name string) bool { @@ -212,25 +206,21 @@ func StartOrEndOpStore(isStart bool, vendorIDList []int, storeIDList []int, star return retVal, err } -func StartDaemon(vendorID int) { - startTimeList := []string{} - stopTimeList := []string{} - if vendorID == model.VendorIDMTWM { - startTimeList = startOpStoreTimeListJXCS_MTWM - stopTimeList = endOpStoreTimeListJXCS_MTWM - if !globals.IsMainProductEnv() { - startTimeList = startOpStoreTimeListJXGY_MTWM - stopTimeList = endOpStoreTimeListJXGY_MTWM - } +func GetVendorStoreRefreshTime(vendorID int) (startTimeList, stopTimeList []string) { + isJXCS := globals.IsMainProductEnv() + refreshTimeList := vendorStoreRefreshTimeList[vendorID] + if isJXCS { + startTimeList = []string{refreshTimeList[2]} + stopTimeList = []string{refreshTimeList[3]} } else { - startTimeList = startOpStoreTimeListJXCS - stopTimeList = endOpStoreTimeListJXCS - if !globals.IsMainProductEnv() { - startTimeList = startOpStoreTimeListJXGY - stopTimeList = endOpStoreTimeListJXGY - } + startTimeList = []string{refreshTimeList[0]} + stopTimeList = []string{refreshTimeList[1]} } + return startTimeList, stopTimeList +} +func RefreshStore(vendorID int) { + startTimeList, stopTimeList := GetVendorStoreRefreshTime(vendorID) vendorIDList := []int{vendorID} storeIDList := []int{} ScheduleTimerFunc("StartOpStore", func() { @@ -248,7 +238,7 @@ func StartDaemon(vendorID int) { func InitEx() { for index, value := range vendorList { if value { - StartDaemon(index) + RefreshStore(index) } } }