修改门店评分细节
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package misc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"sync"
|
||||
@@ -48,7 +49,8 @@ var (
|
||||
scoreStoreTimeList = []string{
|
||||
"22:00:00",
|
||||
}
|
||||
fullVendorList = map[int]bool{
|
||||
scoreStoreCheckTimeEnd = "23:30:00"
|
||||
fullVendorList = map[int]bool{
|
||||
model.VendorIDJD: true,
|
||||
model.VendorIDMTWM: true,
|
||||
model.VendorIDEBAI: true,
|
||||
@@ -68,6 +70,8 @@ var (
|
||||
|
||||
storeScoreDataWrapper StoreScoreDataWrapper
|
||||
allStoreSkusWrapper AllStoreSkusWrapper
|
||||
scoreDate time.Time
|
||||
isScoring bool
|
||||
)
|
||||
|
||||
type AllStoreSkusWrapper struct {
|
||||
@@ -127,6 +131,7 @@ func (s *StoreScoreDataWrapper) SetData(storeID int, valueName string, value int
|
||||
if data == nil {
|
||||
data = &model.StoreScore{}
|
||||
data.StoreID = storeID
|
||||
data.ScoreDate = scoreDate
|
||||
s.storeScoreData[storeID] = data
|
||||
}
|
||||
valueInfo := reflect.ValueOf(data).Elem()
|
||||
@@ -251,10 +256,11 @@ func ScoreStoreOpenTime(storeInfo *cms.StoreExt) {
|
||||
finalScore := 0
|
||||
if isStoreOpen {
|
||||
for _, storeMap := range storeInfo.StoreMaps {
|
||||
isSyncStoreSku := int(utils.MustInterface2Int64(storeMap["isSync"]))
|
||||
vendorStoreStatus := int(utils.MustInterface2Int64(storeMap["status"]))
|
||||
isVendorStoreOpen := vendorStoreStatus == model.StoreStatusOpened
|
||||
opTimeList := storeInfo.GetOpTimeList()
|
||||
if len(opTimeList) > 0 && isStoreOpen && isVendorStoreOpen {
|
||||
if len(opTimeList) > 0 && isStoreOpen && isVendorStoreOpen && isSyncStoreSku != 0 {
|
||||
opTime := GetOpenTime(opTimeList)
|
||||
if opTime >= StoreOpenTimeNormalTime {
|
||||
finalScore = ItemTotalScore
|
||||
@@ -278,15 +284,6 @@ func ScoreSaleSkuCount(storeInfo *cms.StoreExt) {
|
||||
finalScore := 0
|
||||
if len(skusMapData) > 0 {
|
||||
saleSkuCount := len(skusMapData)
|
||||
// saleSkuCount := 0
|
||||
// for _, value := range skusMapData {
|
||||
// for _, skuInfo := range value.Skus2 {
|
||||
// saleStatus := jxutils.MergeSkuStatus(skuInfo.SkuStatus, skuInfo.StoreSkuStatus)
|
||||
// if saleStatus == model.SkuStatusNormal {
|
||||
// saleSkuCount++
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
finalScore = int(math.Round(float64(saleSkuCount) * SaleSkuScorePerUnit))
|
||||
if finalScore > ItemTotalScore {
|
||||
finalScore = ItemTotalScore
|
||||
@@ -299,7 +296,7 @@ func ScoreSaleSkuCount(storeInfo *cms.StoreExt) {
|
||||
func ScoreAveragePickupTime(storeInfo *cms.StoreExt) {
|
||||
storeID := storeInfo.ID
|
||||
db := dao.GetDB()
|
||||
orderList, err := dao.GetDailyFinishOrderList(db, storeID)
|
||||
orderList, err := dao.GetDailyFinishOrderList(db, storeID, scoreDate)
|
||||
orderListCount := len(orderList)
|
||||
finalScore := 0
|
||||
if err == nil && orderListCount > 0 {
|
||||
@@ -392,7 +389,7 @@ func ScorePromotionSku(storeInfo *cms.StoreExt) {
|
||||
db := dao.GetDB()
|
||||
beginTime := time.Now()
|
||||
endTime := time.Now()
|
||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, -1, []int{}, []int{storeID}, []int{}, beginTime, endTime)
|
||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, -1, nil, []int{storeID}, nil, beginTime, endTime)
|
||||
finalScore := 0
|
||||
if err == nil && len(actStoreSkuList) > 0 {
|
||||
actStoreSkuMap := make(map[int]int)
|
||||
@@ -424,10 +421,11 @@ func ScoreFullVendor(storeInfo *cms.StoreExt) {
|
||||
isStoreOpen := storeStatus == model.StoreStatusOpened
|
||||
count := 0
|
||||
for _, storeMap := range storeInfo.StoreMaps {
|
||||
isSyncStoreSku := int(utils.MustInterface2Int64(storeMap["isSync"]))
|
||||
vendorStoreStatus := int(utils.MustInterface2Int64(storeMap["status"]))
|
||||
isVendorStoreOpen := vendorStoreStatus == model.StoreStatusOpened
|
||||
opTimeList := storeInfo.GetOpTimeList()
|
||||
if len(opTimeList) > 0 && isStoreOpen && isVendorStoreOpen {
|
||||
if len(opTimeList) > 0 && isStoreOpen && isVendorStoreOpen && isSyncStoreSku != 0 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
@@ -573,6 +571,8 @@ func GetFilterStoreListEx(storeList []*cms.StoreExt, storeIDMap map[int]int) (ou
|
||||
}
|
||||
|
||||
func ScoreStore(ctx *jxcontext.Context, storeIDList []int) (retVal interface{}, err error) {
|
||||
isScoring = true
|
||||
scoreDate = utils.GetCurDate()
|
||||
var storeList []*cms.StoreExt
|
||||
taskCount := 5
|
||||
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
@@ -590,13 +590,13 @@ func ScoreStore(ctx *jxcontext.Context, storeIDList []int) (retVal interface{},
|
||||
baseapi.SugarLogger.Debugf("ScoreStore step1 end")
|
||||
case 2:
|
||||
db := dao.GetDB()
|
||||
storeCountList, _ := dao.GetDailyBadCommentOrderCount(db)
|
||||
storeCountList, _ := dao.GetDailyBadCommentOrderCount(db, scoreDate)
|
||||
storeScoreDataWrapper.SetDailyBadCommentOrderCount(storeCountList)
|
||||
storeCountList, _ = dao.GetDailyUnFinishOrderCount(db)
|
||||
storeCountList, _ = dao.GetDailyUnFinishOrderCount(db, scoreDate)
|
||||
storeScoreDataWrapper.SetDailyUnFinishOrderCount(storeCountList)
|
||||
storeCountList, _ = dao.GetDailyFinishOrderCount(db)
|
||||
storeCountList, _ = dao.GetDailyFinishOrderCount(db, scoreDate)
|
||||
storeScoreDataWrapper.SetDailyFinishOrderCount(storeCountList)
|
||||
storeCountList, _ = dao.GetDailyAbsentGoodsOrderCount(db)
|
||||
storeCountList, _ = dao.GetDailyAbsentGoodsOrderCount(db, scoreDate)
|
||||
storeScoreDataWrapper.SetDailyAbsentGoodsOrderCount(storeCountList)
|
||||
case 3:
|
||||
baseapi.SugarLogger.Debugf("ScoreStore step2 begin")
|
||||
@@ -631,6 +631,7 @@ func ScoreStore(ctx *jxcontext.Context, storeIDList []int) (retVal interface{},
|
||||
storeScoreDataWrapper.ClearData()
|
||||
allStoreSkusWrapper.ClearData()
|
||||
baseapi.SugarLogger.Debugf("ScoreStore step3 end")
|
||||
isScoring = false
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
@@ -643,8 +644,29 @@ func ScoreStore(ctx *jxcontext.Context, storeIDList []int) (retVal interface{},
|
||||
func ScheduleScoreStore() {
|
||||
if EnableScheduleScoreStore {
|
||||
ScheduleTimerFunc("ScheduleScoreStore", func() {
|
||||
ScoreStore(jxcontext.AdminCtx, []int{})
|
||||
if !isScoring {
|
||||
ScoreStore(jxcontext.AdminCtx, nil)
|
||||
}
|
||||
}, scoreStoreTimeList)
|
||||
CheckScoreStore()
|
||||
}
|
||||
}
|
||||
|
||||
func CheckScoreStore() {
|
||||
if !isScoring {
|
||||
curTime := time.Now()
|
||||
year, month, day := curTime.Date()
|
||||
checkTimeStr1 := fmt.Sprintf("%d-%d-%d "+scoreStoreTimeList[0], year, int(month), day)
|
||||
checkTime1 := utils.Str2Time(checkTimeStr1)
|
||||
checkTimeStr2 := fmt.Sprintf("%d-%d-%d "+scoreStoreCheckTimeEnd, year, int(month), day)
|
||||
checkTime2 := utils.Str2Time(checkTimeStr2)
|
||||
if curTime.Unix() >= checkTime1.Unix() && curTime.Unix() <= checkTime2.Unix() {
|
||||
db := dao.GetDB()
|
||||
hasStoreScoreData, err := dao.CheckHasStoreScoreData(db, time.Now())
|
||||
if err == nil && !hasStoreScoreData {
|
||||
ScoreStore(jxcontext.AdminCtx, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user