定时刷新商品可售状态
This commit is contained in:
@@ -79,9 +79,13 @@ type StoreSkuSyncInfo struct {
|
||||
StoreCatSyncStatus int8
|
||||
VendorCatID string `orm:"column(vendor_cat_id)"`
|
||||
|
||||
VendorPrice int64
|
||||
MergedStatus int
|
||||
SkuName string
|
||||
VendorPrice int64
|
||||
MergedStatus int
|
||||
SkuName string
|
||||
StatusSaleBegin int `json:"statusSaleBegin"` //商品可售时间范围
|
||||
StatusSaleEnd int `json:"statusSaleEnd"`
|
||||
OpenTime int //门店营业时间
|
||||
CloseTime int
|
||||
}
|
||||
|
||||
type MissingStoreSkuInfo struct {
|
||||
@@ -107,14 +111,6 @@ type StoreSkuNameInfo struct {
|
||||
UnitPrice int64
|
||||
}
|
||||
|
||||
type StoreSkuBindWithSaleTime struct {
|
||||
StoreSkuBind model.StoreSkuBind
|
||||
TimeBegin1 int
|
||||
TimeEnd1 int
|
||||
TimeBegin2 int
|
||||
TimeEnd2 int
|
||||
}
|
||||
|
||||
// todo 应该通过需要同步的skuid来驱动同步分类,而不是当前这种分开的逻辑
|
||||
// 单门店模式厂商适用
|
||||
// 从store_sku_bind中,得到所有依赖的商家分类信息
|
||||
@@ -224,7 +220,9 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql := `
|
||||
SELECT t1.id bind_id, t1.sku_id, t1.price, t1.unit_price, t1.status store_sku_status, %s.%s_id vendor_sku_id,
|
||||
t1.%s_sync_status store_sku_sync_status, t1.store_id, t1.deleted_at bind_deleted_at,
|
||||
t1.%s_sync_status store_sku_sync_status, t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end,
|
||||
IF(t6.open_time2 <> 0 AND t6.close_time2 <>0,IF(t6.open_time1 < t6.open_time2,t6.open_time1,t6.open_time2),t6.open_time1) open_time,
|
||||
IF(t6.open_time2 <> 0 AND t6.close_time2 <>0,IF(t6.close_time1 > t6.close_time2,t6.close_time1,t6.close_time2),t6.close_time1) close_time,
|
||||
t2.*,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc,
|
||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||
@@ -257,6 +255,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
||||
LEFT JOIN data_resource t11 ON t11.main_url = t3.img
|
||||
LEFT JOIN data_resource t12 ON t12.main_url = t3.img2
|
||||
LEFT JOIN data_resource t13 ON t13.main_url = t3.desc_img
|
||||
LEFT JOIN store t6 ON t6.id = t1.store_id
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
@@ -593,20 +592,17 @@ func (s *StoreSkuSyncInfo) GetSeq() int {
|
||||
return int(s.VendorPrice)
|
||||
}
|
||||
|
||||
func GetStoresSkusInfoBySaleTime(db *DaoDB) (storeSkuBindList []*StoreSkuBindWithSaleTime, err error) {
|
||||
func GetStoresSkusInfoBySaleTime(db *DaoDB) (storeSkuBindList []*model.StoreSkuBind, err error) {
|
||||
sql := `
|
||||
SELECT t1.*,
|
||||
IF(t2.open_time1 <= t1.status_sale_begin,t2.open_time1,0) time_begin1,
|
||||
IF(t2.open_time1 <= t1.status_sale_begin,t1.status_sale_begin,0) time_end1,
|
||||
IF(t2.close_time1 >= t1.status_sale_end,t1.status_sale_end,0) time_begin2,
|
||||
IF(t2.close_time1 >= t1.status_sale_end,t2.close_time1,0) time_end2
|
||||
SELECT t1.*
|
||||
FROM store_sku_bind t1
|
||||
JOIN store t2 ON t1.store_id = t2.id
|
||||
WHERE t1.status_sale_begin <> 0 AND t1.status_sale_end <> 0
|
||||
AND t1.status != ?
|
||||
AND t1.status = ?
|
||||
AND t1.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.SkuStatusDeleted,
|
||||
model.SkuStatusNormal,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
err = GetRows(db, &storeSkuBindList, sql, sqlParams...)
|
||||
return storeSkuBindList, err
|
||||
|
||||
Reference in New Issue
Block a user