门店评分-优化
This commit is contained in:
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
const (
|
||||
EnableScheduleScoreStore = !true
|
||||
ParallelCount = 5
|
||||
ParallelCount = 10
|
||||
|
||||
GoldMedalScore = 90
|
||||
SilverMedalScore = 80
|
||||
@@ -232,11 +232,15 @@ func ScoreAveragePickupTime(storeInfo *cms.StoreExt) {
|
||||
}
|
||||
|
||||
//差评订单和完成订单比例小于0.2%,得满分10分,每增加0.1%减1分
|
||||
func ScoreBadCommentOrder(storeInfo *cms.StoreExt) {
|
||||
func ScoreBadCommentOrder(storeInfo *cms.StoreExt, paramFinishOrderCount int64) (finishOrderCount int64) {
|
||||
storeID := storeInfo.ID
|
||||
db := dao.GetDB()
|
||||
badCommentOrderCount, _ := dao.GetDailyBadCommentOrderCount(db, storeID)
|
||||
finishOrderCount, _ := dao.GetDailyFinishOrderCount(db, storeID)
|
||||
if paramFinishOrderCount == -1 {
|
||||
finishOrderCount, _ = dao.GetDailyFinishOrderCount(db, storeID)
|
||||
} else {
|
||||
finishOrderCount = paramFinishOrderCount
|
||||
}
|
||||
if finishOrderCount > 0 {
|
||||
finalScore := 0
|
||||
badCommentOrderRatio := float64(badCommentOrderCount) * 100 / float64(finishOrderCount)
|
||||
@@ -251,14 +255,20 @@ func ScoreBadCommentOrder(storeInfo *cms.StoreExt) {
|
||||
}
|
||||
storeScoreDataWrapper.SetData(storeID, model.FieldBadCommentOrder, finalScore)
|
||||
}
|
||||
|
||||
return finishOrderCount
|
||||
}
|
||||
|
||||
//未完成订单和完成订单比小于1%,得满分10分,比例每增加5%,分数减1
|
||||
func ScoreUnfinishOrder(storeInfo *cms.StoreExt) {
|
||||
func ScoreUnfinishOrder(storeInfo *cms.StoreExt, paramFinishOrderCount int64) (finishOrderCount int64) {
|
||||
storeID := storeInfo.ID
|
||||
db := dao.GetDB()
|
||||
unFinishOrderCount, _ := dao.GetDailyUnFinishOrderCount(db, storeID)
|
||||
finishOrderCount, _ := dao.GetDailyFinishOrderCount(db, storeID)
|
||||
if paramFinishOrderCount == -1 {
|
||||
finishOrderCount, _ = dao.GetDailyFinishOrderCount(db, storeID)
|
||||
} else {
|
||||
finishOrderCount = paramFinishOrderCount
|
||||
}
|
||||
if finishOrderCount > 0 {
|
||||
finalScore := 0
|
||||
unfinishOrderRatio := float64(unFinishOrderCount) * 100 / float64(finishOrderCount)
|
||||
@@ -273,14 +283,20 @@ func ScoreUnfinishOrder(storeInfo *cms.StoreExt) {
|
||||
}
|
||||
storeScoreDataWrapper.SetData(storeID, model.FieldUnfinishOrder, finalScore)
|
||||
}
|
||||
|
||||
return finishOrderCount
|
||||
}
|
||||
|
||||
//缺货订单和完成订单比小于1%得10分,比例每增加0.1%减1分
|
||||
func ScoreAbsentGoodsOrder(storeInfo *cms.StoreExt) {
|
||||
func ScoreAbsentGoodsOrder(storeInfo *cms.StoreExt, paramFinishOrderCount int64) (finishOrderCount int64) {
|
||||
storeID := storeInfo.ID
|
||||
db := dao.GetDB()
|
||||
absentGoodsOrderCount, _ := dao.GetDailyAbsentGoodsOrderCount(db, storeID)
|
||||
finishOrderCount, _ := dao.GetDailyFinishOrderCount(db, storeID)
|
||||
if paramFinishOrderCount == -1 {
|
||||
finishOrderCount, _ = dao.GetDailyFinishOrderCount(db, storeID)
|
||||
} else {
|
||||
finishOrderCount = paramFinishOrderCount
|
||||
}
|
||||
if finishOrderCount > 0 {
|
||||
finalScore := 0
|
||||
absentGoodsOrderRatio := float64(absentGoodsOrderCount) * 100 / float64(finishOrderCount)
|
||||
@@ -295,6 +311,8 @@ func ScoreAbsentGoodsOrder(storeInfo *cms.StoreExt) {
|
||||
}
|
||||
storeScoreDataWrapper.SetData(storeID, model.FieldAbsentGoodsOrder, finalScore)
|
||||
}
|
||||
|
||||
return finishOrderCount
|
||||
}
|
||||
|
||||
//促销品数量20个以上为满分10分,每少2个扣1分
|
||||
@@ -507,16 +525,19 @@ func ScoreStore(ctx *jxcontext.Context, storeIDList []int) (retVal interface{},
|
||||
baseapi.SugarLogger.Debugf("ScoreStore step2 begin")
|
||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeInfo := batchItemList[0].(*cms.StoreExt)
|
||||
storeID := storeInfo.ID
|
||||
baseapi.SugarLogger.Debugf("Begin store id:%d", storeID)
|
||||
ScoreStoreOpenTime(storeInfo)
|
||||
ScoreSaleSkuCount(storeInfo)
|
||||
ScoreAveragePickupTime(storeInfo)
|
||||
ScoreBadCommentOrder(storeInfo)
|
||||
ScoreUnfinishOrder(storeInfo)
|
||||
ScoreAbsentGoodsOrder(storeInfo)
|
||||
finishOrderCount := ScoreBadCommentOrder(storeInfo, -1)
|
||||
ScoreUnfinishOrder(storeInfo, finishOrderCount)
|
||||
ScoreAbsentGoodsOrder(storeInfo, finishOrderCount)
|
||||
ScorePromotionSku(storeInfo)
|
||||
ScoreFullVendor(storeInfo)
|
||||
ScoreStoreRange(storeInfo)
|
||||
ScoreSaleSkuPrice(storeInfo, storeList)
|
||||
baseapi.SugarLogger.Debugf("End store id:%d", storeID)
|
||||
return retVal, err
|
||||
}
|
||||
taskParallel := tasksch.NewParallelTask("计算门店得分", tasksch.NewParallelConfig().SetParallelCount(ParallelCount), ctx, taskFunc, storeList)
|
||||
|
||||
Reference in New Issue
Block a user