- 添加对于监控平台门店状态初始版本
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
@@ -19,7 +21,8 @@ type StoreDetail struct {
|
||||
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
|
||||
IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步
|
||||
|
||||
model.Place // district info
|
||||
model.Place // district info
|
||||
DistrictName string `json:"-"`
|
||||
}
|
||||
|
||||
type StoreDetail2 struct {
|
||||
@@ -35,7 +38,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
SELECT t1.*,
|
||||
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status,
|
||||
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
|
||||
district.code, district.name, district.parent_code, district.level, district.tel_code, district.jd_code, district.ebai_code, district.enabled, district.mtps_price
|
||||
district.code, district.name district_name, district.parent_code, district.level, district.tel_code, district.jd_code, district.ebai_code, district.enabled, district.mtps_price
|
||||
FROM store t1
|
||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
||||
LEFT JOIN place district ON t1.district_code = district.code
|
||||
@@ -56,6 +59,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
}
|
||||
storeDetail = &StoreDetail{}
|
||||
if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil {
|
||||
storeDetail.Place.Name = storeDetail.DistrictName
|
||||
return storeDetail, nil
|
||||
}
|
||||
return nil, err
|
||||
@@ -181,7 +185,7 @@ func GetStoreCourierList(db *DaoDB, storeID, status int) (courierStoreList []*mo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status int) (storeMapList []*model.StoreMap, err error) {
|
||||
func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int) (storeMapList []*model.StoreMap, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
FROM store_map t1
|
||||
@@ -202,6 +206,11 @@ func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status int) (storeMa
|
||||
sql += " AND t1.status = ?"
|
||||
sqlParams = append(sqlParams, status)
|
||||
}
|
||||
if isSync != model.StoreIsSyncAll {
|
||||
sql += " AND t1.is_sync = ?"
|
||||
sqlParams = append(sqlParams, isSync)
|
||||
}
|
||||
sql += " ORDER BY t1.store_id, t1.vendor_id"
|
||||
if err = GetRows(db, &storeMapList, sql, sqlParams...); err == nil {
|
||||
return storeMapList, nil
|
||||
}
|
||||
@@ -256,3 +265,17 @@ func FormalizeStoreStatus(db *DaoDB, storeID, storeStatus int) (err error) {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetVendorStoreSnapshot(db *DaoDB, excludeSnapshotAt time.Time) (snapshotList []*model.VendorStoreSnapshot, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM vendor_store_snapshot t1
|
||||
WHERE t1.snapshot_at = (
|
||||
SELECT MAX(snapshot_at) snapshot_at
|
||||
FROM vendor_store_snapshot
|
||||
WHERE snapshot_at > ? AND snapshot_at <> ?
|
||||
)
|
||||
`
|
||||
err = GetRows(db, &snapshotList, sql, time.Now().Add(-48*time.Hour), excludeSnapshotAt)
|
||||
return snapshotList, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user