增加StoreScoreEx结构来获取门店名字,去掉表中的字段StoreName

This commit is contained in:
Rosy-zhudan
2019-09-10 15:42:26 +08:00
parent 69c57c6520
commit 40586e19a6
4 changed files with 70 additions and 53 deletions

View File

@@ -75,6 +75,6 @@ type OrderFinancialSkuExt struct {
}
type OrderPickupTime struct {
StatusTime time.Time `orm:"type(datetime)" json:"statusTime"`
PickDeadline time.Time `orm:"type(datetime)" json:"pickDeadline"`
StatusTime time.Time
PickDeadline time.Time
}

View File

@@ -12,17 +12,12 @@ func InsertStoreScore(storeScore *model.StoreScore) error {
return CreateEntity(nil, storeScore)
}
func GetLatestWeeklyStoreScoreList(db *DaoDB, storeID, weekNum int) (storeScoreList []*model.StoreScore, err error) {
// sql := `
// SET @dayInWeek = IF(DAYOFWEEK(CURDATE()) - 1 = 0, 7, DAYOFWEEK(CURDATE()) - 1);
// SET @endDate = DATE_SUB(CURDATE(), INTERVAL @dayInWeek DAY);
// SET @beginData = DATE_SUB(@endDate, INTERVAL ? DAY);
// SELECT * FROM store_score
// WHERE store_id = ? AND DATE(created_at) >= @beginData AND DATE(created_at) <= @endDate ORDER BY created_at DESC
// `
func GetLatestWeeklyStoreScoreList(db *DaoDB, storeID, weekNum int) (storeScoreList []*model.StoreScoreEx, err error) {
sql := `
SELECT * FROM store_score WHERE store_id = ?
AND DATE(created_at) >= DATE_SUB(
SELECT t2.name store_name, t1.* FROM store_score t1
JOIN store t2 ON t1.store_id = t2.id
WHERE store_id = ?
AND DATE(t1.created_at) >= DATE_SUB(
DATE_SUB(
CURDATE(),
INTERVAL
@@ -34,7 +29,7 @@ func GetLatestWeeklyStoreScoreList(db *DaoDB, storeID, weekNum int) (storeScoreL
),
INTERVAL ? DAY
)
AND DATE(created_at) <= DATE_SUB(
AND DATE(t1.created_at) <= DATE_SUB(
CURDATE(),
INTERVAL
IF (

View File

@@ -21,7 +21,6 @@ type StoreScore struct {
ID int `orm:"column(id)" json:"id"`
CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"`
StoreID int `orm:"column(store_id)" json:"storeID"`
StoreName string `orm:"column(store_name)" json:"storeName"`
StoreOpenTime int `orm:"column(store_open_time)" json:"storeOpenTime"`
SaleSkuCount int `orm:"column(sale_sku_count)" json:"saleSkuCount"`
@@ -35,8 +34,13 @@ type StoreScore struct {
SaleSkuPrice int `orm:"column(sale_sku_price)" json:"saleSkuPrice"`
}
type WeeklyStoreScore struct {
type StoreScoreEx struct {
StoreScore
StoreName string `json:"storeName"`
}
type WeeklyStoreScore struct {
StoreScoreEx
BeginTime time.Time `json:"beginTime"`
EndTime time.Time `json:"endTime"`
TotalScore int `json:"totalScore"`