门店评分修改
This commit is contained in:
@@ -6,14 +6,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/refutil"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/refutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -28,16 +27,17 @@ const (
|
|||||||
|
|
||||||
ItemTotalScore = 10
|
ItemTotalScore = 10
|
||||||
|
|
||||||
StoreOpenTimeNormalTime = 12.0 //小时
|
StoreOpenTimeNormalTime = 12.0 //小时
|
||||||
SaleSkuNormalCount = 1000
|
SaleSkuNormalCount = 1000 //数量
|
||||||
SaleSkuScorePerUnit = float64(ItemTotalScore) / SaleSkuNormalCount
|
SaleSkuScorePerUnit = float64(ItemTotalScore) / SaleSkuNormalCount //分数
|
||||||
PromotionSkuNormalCount = 20
|
PromotionSkuNormalCount = 20 //数量
|
||||||
AveragePickupTimeNormalTime = 10.0 //分钟
|
AveragePickupTimeNormalTime = 10.0 //分钟
|
||||||
BadCommentOrderNormalRatio = 0.2
|
BadCommentOrderNormalRatio = 0.2 //百分比
|
||||||
UnfinishOrderNormalRatio = 1.0
|
UnfinishOrderNormalRatio = 1.0 //百分比
|
||||||
StoreRangeGoodRadius = 2.0 //千米
|
AbsentGoodsOrderNormalRatio = 1.0 //百分比
|
||||||
StoreRangeBadRadius = 1.0 //千米
|
StoreRangeGoodRadius = 2.0 //千米
|
||||||
SaleSkuPriceRatio = 90 //百分比
|
StoreRangeBadRadius = 1.0 //千米
|
||||||
|
SaleSkuPriceRatio = 90 //百分比
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -263,7 +263,27 @@ func ScoreUnfinishOrder(storeList []*cms.StoreExt) {
|
|||||||
|
|
||||||
//缺货订单和完成订单比小于1%得10分,比例每增加0.1%减1分
|
//缺货订单和完成订单比小于1%得10分,比例每增加0.1%减1分
|
||||||
func ScoreAbsentGoodsOrder(storeList []*cms.StoreExt) {
|
func ScoreAbsentGoodsOrder(storeList []*cms.StoreExt) {
|
||||||
|
for _, storeInfo := range storeList {
|
||||||
|
storeID := storeInfo.ID
|
||||||
|
storeName := storeInfo.Name
|
||||||
|
db := dao.GetDB()
|
||||||
|
absentGoodsOrderCount, _ := dao.GetDailyAbsentGoodsOrderCount(db, storeID)
|
||||||
|
finishOrderCount, _ := dao.GetDailyFinishOrderCount(db, storeID)
|
||||||
|
if finishOrderCount > 0 {
|
||||||
|
finalScore := 0
|
||||||
|
absentGoodsOrderRatio := float64(absentGoodsOrderCount) * 100 / float64(finishOrderCount)
|
||||||
|
if absentGoodsOrderRatio <= AbsentGoodsOrderNormalRatio {
|
||||||
|
finalScore = ItemTotalScore
|
||||||
|
} else {
|
||||||
|
decScore := int(math.Round((absentGoodsOrderRatio - AbsentGoodsOrderNormalRatio) / 0.1))
|
||||||
|
finalScore = ItemTotalScore - decScore
|
||||||
|
if finalScore < 0 {
|
||||||
|
finalScore = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
storeScoreDataWrapper.SetData(storeID, storeName, model.FieldAbsentGoodsOrder, finalScore)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//促销品数量20个以上为满分10分,每少2个扣1分
|
//促销品数量20个以上为满分10分,每少2个扣1分
|
||||||
@@ -461,11 +481,16 @@ func GetFilterStoreListEx(storeList []*cms.StoreExt, storeIDMap map[int]int) (ou
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var tempStoreMaps []map[string]interface{}
|
||||||
for _, vendorStoreInfo := range storeInfo.StoreMaps {
|
for _, vendorStoreInfo := range storeInfo.StoreMaps {
|
||||||
vendorID := int(utils.MustInterface2Int64(vendorStoreInfo["vendorID"]))
|
vendorID := int(utils.MustInterface2Int64(vendorStoreInfo["vendorID"]))
|
||||||
if _, ok := fullVendorList[vendorID]; !ok {
|
if _, ok := fullVendorList[vendorID]; !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
tempStoreMaps = append(tempStoreMaps, vendorStoreInfo)
|
||||||
|
}
|
||||||
|
if len(tempStoreMaps) > 0 {
|
||||||
|
storeInfo.StoreMaps = tempStoreMaps
|
||||||
outStoreList = append(outStoreList, storeInfo)
|
outStoreList = append(outStoreList, storeInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,30 +306,42 @@ func GetDailyFinishOrderList(db *DaoDB, storeID int) (orderList []*model.OrderPi
|
|||||||
return orderList, GetRows(db, &orderList, sql, sqlParams...)
|
return orderList, GetRows(db, &orderList, sql, sqlParams...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDailyBadCommentOrderCount(db *DaoDB, storeID int) (num int64, err error) {
|
func GetDailyBadCommentOrderCount(db *DaoDB, storeID int) (count int64, err error) {
|
||||||
sql := `select count(*) from jx_bad_comments where DATE(createtime) = CURDATE() and jxstoreid = ?`
|
sql := `select count(*) from jx_bad_comments where DATE(createtime) = CURDATE() and jxstoreid = ?`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
storeID,
|
storeID,
|
||||||
}
|
}
|
||||||
return ExecuteSQL(db, sql, sqlParams)
|
err = GetRow(db, &count, sql, sqlParams...)
|
||||||
|
|
||||||
|
return count, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDailyUnFinishOrderCount(db *DaoDB, storeID int) (num int64, err error) {
|
func GetDailyUnFinishOrderCount(db *DaoDB, storeID int) (num int64, err error) {
|
||||||
return GetDailyEndOrderCount(db, storeID, []int{model.OrderStatusCanceled})
|
return GetDailyEndOrderCount(db, storeID, []int{model.OrderStatusCanceled}, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDailyFinishOrderCount(db *DaoDB, storeID int) (num int64, err error) {
|
func GetDailyFinishOrderCount(db *DaoDB, storeID int) (num int64, err error) {
|
||||||
return GetDailyEndOrderCount(db, storeID, []int{model.OrderStatusFinished})
|
return GetDailyEndOrderCount(db, storeID, []int{model.OrderStatusFinished}, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDailyEndOrderCount(db *DaoDB, storeID int, statusList []int) (num int64, err error) {
|
func GetDailyAbsentGoodsOrderCount(db *DaoDB, storeID int) (num int64, err error) {
|
||||||
sql := `select count(*) from goods_order
|
return GetDailyEndOrderCount(db, storeID, []int{model.OrderStatusFinished, model.OrderStatusCanceled}, true)
|
||||||
where DATE(order_finished_at) = CURDATE()
|
}
|
||||||
and jx_store_id = ?
|
|
||||||
and status in (` + GenQuestionMarks(len(statusList)) + `)`
|
func GetDailyEndOrderCount(db *DaoDB, storeID int, statusList []int, isAbsentOrder bool) (count int64, err error) {
|
||||||
|
sql := `SELECT COUNT(*) FROM goods_order
|
||||||
|
WHERE DATE(order_finished_at) = CURDATE()
|
||||||
|
AND jx_store_id = ?
|
||||||
|
AND status IN (` + GenQuestionMarks(len(statusList)) + `)`
|
||||||
|
if isAbsentOrder {
|
||||||
|
sql += `
|
||||||
|
AND adjust_count > 0`
|
||||||
|
}
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
storeID,
|
storeID,
|
||||||
}
|
}
|
||||||
sqlParams = append(sqlParams, statusList)
|
sqlParams = append(sqlParams, statusList)
|
||||||
return ExecuteSQL(db, sql, sqlParams)
|
err = GetRow(db, &count, sql, sqlParams...)
|
||||||
|
|
||||||
|
return count, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user