修改门店评分细节

This commit is contained in:
Rosy-zhudan
2019-09-16 16:20:46 +08:00
parent 22f8d169d0
commit e35d86f690
6 changed files with 104 additions and 60 deletions

View File

@@ -6,7 +6,6 @@ import (
"git.rosy.net.cn/jx-callback/business/model"
)
// func InsertStoreScore(storeID int, scores map[string]int) error {
func InsertStoreScore(storeScore *model.StoreScore) error {
storeScore.CreatedAt = time.Now()
return CreateEntity(nil, storeScore)
@@ -17,7 +16,7 @@ func GetLatestWeeklyStoreScoreList(db *DaoDB, storeID, weekNum int) (storeScoreL
SELECT t2.name store_name, t1.* FROM store_score t1
JOIN store t2 ON t1.store_id = t2.id
WHERE t1.store_id = ?
AND DATE(t1.created_at) >= DATE_SUB(
AND DATE(t1.ScoreDate) >= DATE_SUB(
DATE_SUB(
CURDATE(),
INTERVAL
@@ -29,7 +28,7 @@ func GetLatestWeeklyStoreScoreList(db *DaoDB, storeID, weekNum int) (storeScoreL
),
INTERVAL ? DAY
)
AND DATE(t1.created_at) <= DATE_SUB(
AND DATE(t1.ScoreDate) <= DATE_SUB(
CURDATE(),
INTERVAL
IF (
@@ -38,7 +37,7 @@ func GetLatestWeeklyStoreScoreList(db *DaoDB, storeID, weekNum int) (storeScoreL
DAYOFWEEK(CURDATE()) - 1
) DAY
)
ORDER BY created_at DESC
ORDER BY ScoreDate DESC
`
if weekNum <= 0 {
weekNum = 1
@@ -51,3 +50,18 @@ func GetLatestWeeklyStoreScoreList(db *DaoDB, storeID, weekNum int) (storeScoreL
err = GetRows(db, &storeScoreList, sql, sqlParams)
return storeScoreList, err
}
func CheckHasStoreScoreData(db *DaoDB, dateTime time.Time) (hasStoreScoreData bool, err error) {
sql := `
SELECT COUNT(*) count
FROM store_score
WHERE DATE(createtime) = DATE(?)
`
sqlParams := []interface{}{
dateTime,
}
count := 0
err = GetRow(db, &count, sql, sqlParams)
hasStoreScoreData = count > 0
return hasStoreScoreData, err
}