- 添加对于监控平台门店状态初始版本
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err error) {
|
||||
@@ -19,7 +18,7 @@ func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err
|
||||
model.UserStatusNormal,
|
||||
fieldValue,
|
||||
}
|
||||
globals.SugarLogger.Debugf("GetUserByID sql:%s, sqlParams:%s", sql, utils.Format4Output(sqlParams, false))
|
||||
// globals.SugarLogger.Debugf("GetUserByID sql:%s, sqlParams:%s", sql, utils.Format4Output(sqlParams, false))
|
||||
err = GetRow(db, &user, sql, sqlParams...)
|
||||
return user, err
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
StoreStatusAll = -9
|
||||
StoreStatusDisabled = -2
|
||||
StoreStatusClosed = -1
|
||||
StoreStatusHaveRest = 0
|
||||
StoreStatusOpened = 1
|
||||
|
||||
StoreIsSyncAll = -1
|
||||
StoreIsSyncNo = 0
|
||||
StoreIsSyncYes = 1
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -243,3 +253,47 @@ func (*StoreCourierMap) TableUnique() [][]string {
|
||||
[]string{"VendorStoreID", "VendorID", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
type VendorStoreSnapshot struct {
|
||||
ModelIDCULD
|
||||
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
||||
SnapshotAt time.Time `orm:"type(datetime)" json:"snapshotAt"` // 这个不同于CreatedAt,SnapshotAt是逻辑上的时间,CreatedAt是实际存储的时间
|
||||
|
||||
Status int `json:"status"` // 取值同Store.Status
|
||||
OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有
|
||||
CloseTime1 int16 `json:"closeTime1"` // 格式同上
|
||||
OpenTime2 int16 `json:"openTime2"` // 格式同上
|
||||
CloseTime2 int16 `json:"closeTime2"` // 格式同上
|
||||
}
|
||||
|
||||
func (*VendorStoreSnapshot) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"VendorStoreID", "VendorID", "SnapshotAt"},
|
||||
}
|
||||
}
|
||||
|
||||
func (*VendorStoreSnapshot) TableIndex() [][]string {
|
||||
return [][]string{
|
||||
[]string{"SnapshotAt"},
|
||||
}
|
||||
}
|
||||
|
||||
func (v *VendorStoreSnapshot) GenMapKey() string {
|
||||
return v.VendorStoreID + utils.Int2Str(v.VendorID)
|
||||
}
|
||||
|
||||
func (v *VendorStoreSnapshot) CompareOperationTime(s2 *VendorStoreSnapshot) int {
|
||||
if s2 == nil {
|
||||
return 1
|
||||
}
|
||||
if v.OpenTime1 == s2.OpenTime1 && v.CloseTime1 == s2.CloseTime1 &&
|
||||
v.OpenTime2 == s2.OpenTime2 && v.CloseTime2 == s2.CloseTime2 {
|
||||
return 0
|
||||
} else if v.OpenTime1 > s2.OpenTime1 || v.CloseTime1 < s2.CloseTime2 {
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user