diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index c94a354d6..b6338bba0 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -952,7 +952,7 @@ func DeleteSkusFromAct(ctx *jxcontext.Context, vendorID int, actTypes, skuIDs [] return hint, err } -func ForceUpdateVendorPrice(ctx *jxcontext.Context, vendorID int, actType int, storeSkuList []*ActStoreSkuParam, isAsync bool) (hint string, err error) { +func ForceUpdateVendorPrice(ctx *jxcontext.Context, vendorID int, actType int, storeSkuList []*ActStoreSkuParam, lockTime time.Time, isAsync bool) (hint string, err error) { var wrongSkuList []*ActStoreSkuParam var storeSkuBindList []*model.StoreSkuBind @@ -986,7 +986,7 @@ func ForceUpdateVendorPrice(ctx *jxcontext.Context, vendorID int, actType int, s } } if storeSkuBind != nil { - dao.SetStoreSkuBindVendorPrice(storeSkuBind, vendorID, vendorPrice) + dao.SetStoreSkuBindVendorPrice(storeSkuBind, vendorID, vendorPrice, lockTime) if vendorID != model.VendorIDJX { dao.SetStoreSkuBindSyncStatus(storeSkuBind, vendorID, dao.GetStoreSkuBindSyncStatus(storeSkuBind, vendorID)|model.SyncFlagPriceMask) } diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 0fcb3ba69..b8c193368 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -319,6 +319,12 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool sqlParams = append(sqlParams, skuID) } } + if lockTimeStr, ok := params["lockTime"].(string); ok && lockTimeStr != "" { + if timeList, err2 := jxutils.BatchStr2Time(lockTimeStr); err2 == nil { + sql += " AND (t4.jd_lock_time > ? OR t4.mtwm_lock_time > ? OR t4.ebai_lock_time > ? OR t4.jx_lock_time > ?)" + sqlParams = append(sqlParams, timeList[0], timeList[0], timeList[0], timeList[0]) + } + } if isFocus { if params["fromStatus"] != nil { fromStatus := params["fromStatus"].(int) @@ -451,6 +457,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo t4.ebai_id, t4.mtwm_id, t4.jd_sync_status, t4.ebai_sync_status, t4.mtwm_sync_status, t4.jd_price, t4.ebai_price, t4.mtwm_price, t4.jx_price, + t4.jd_lock_time, t4.ebai_lock_time, t4.mtwm_lock_time, t4.jx_lock_time, t4.status_sale_begin, t4.status_sale_end `, jdVendorIDField) + sql var tmpList []*tGetStoresSkusInfo diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index b42377490..8d18508e9 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -335,7 +335,8 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo } now := jxutils.OperationTime2HourMinuteFormat(time.Now()) for _, sku := range skus { - if !useVendorPriceDirectly { + if !useVendorPriceDirectly && + (sku.LockTime == nil || time.Now().Sub(*sku.LockTime) > 0) { sku.VendorPrice = 0 } sku.MergedStatus = MergeSkuSaleStatusWithStoreOpTime(sku, storeDetail, now) diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index e8d758482..e683bf57a 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -81,7 +81,9 @@ type StoreSkuSyncInfo struct { CatSyncStatus int8 VendorCatID string `orm:"column(vendor_cat_id)"` - VendorPrice int64 + VendorPrice int64 + LockTime *time.Time + MergedStatus int SkuName string StatusSaleBegin int16 `json:"statusSaleBegin"` //商品可售时间范围 @@ -167,6 +169,11 @@ type StoreSkuExt struct { MtwmPrice int `json:"mtwmPrice"` JxPrice int `json:"jxPrice"` + JdLockTime *time.Time `orm:"null" json:"jdLockTime,omitempty"` + EbaiLockTime *time.Time `orm:"null" json:"ebaiLockTime,omitempty"` + MtwmLockTime *time.Time `orm:"null" json:"mtwmLockTime,omitempty"` + JxLockTime *time.Time `orm:"null" json:"jxLockTime,omitempty"` + AutoSaleAt time.Time `orm:"type(datetime);null" json:"autoSaleAt"` ActPrice int `json:"actPrice"` @@ -302,7 +309,7 @@ func newGetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty SELECT t14.vendor_id, t14.vendor_org_code, t1.id bind_id, t1.sku_id, t1.price, t1.unit_price, t1.status store_sku_status, - %s vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, + %s vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time, t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end, t2.*, t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, @@ -311,7 +318,7 @@ func newGetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty t13.%s desc_img, t4.%s_category_id vendor_vendor_cat_id` fmtParams := []interface{}{ - skuVendorIDField, fieldPrefix, fieldPrefix, + skuVendorIDField, fieldPrefix, fieldPrefix, fieldPrefix, GetDataResFieldName(vendorID), GetDataResFieldName(vendorID), GetDataResFieldName(vendorID), GetDataResFieldName(vendorID), GetDataResFieldName(vendorID), @@ -509,7 +516,8 @@ func newGetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSync SELECT sm.vendor_id, sm.vendor_org_code, t1.id bind_id, t1.price, t1.unit_price, t1.status store_sku_status, - t1.%s_sync_status sku_sync_status, t1.store_id, t1.deleted_at bind_deleted_at, + t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time, + t1.store_id, t1.deleted_at bind_deleted_at, t2.*, t2.id sku_id, t2m.vendor_thing_id vendor_sku_id, t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, IF(t11.%s <> '', t11.%s, t3.img) img, @@ -544,7 +552,7 @@ func newGetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSync } fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID]) sql = fmt.Sprintf(sql, - fieldPrefix, + fieldPrefix, fieldPrefix, fieldPrefix, GetDataResFieldName(vendorID), GetDataResFieldName(vendorID), GetDataResFieldName(vendorID), GetDataResFieldName(vendorID), GetDataResFieldName(vendorID), @@ -1108,16 +1116,21 @@ func GetStoreSkuNamePrice(db *DaoDB) (storeSkuNamePriceList []*model.StoreSkuNam return storeSkuNamePriceList, err } -func SetStoreSkuBindVendorPrice(storeSkuBind *model.StoreSkuBind, vendorID int, vendorPrice int) { +func SetStoreSkuBindVendorPrice(storeSkuBind *model.StoreSkuBind, vendorID int, vendorPrice int, lockTime time.Time) { + pLockTime := utils.Time2Pointer(lockTime) switch vendorID { case model.VendorIDJD: storeSkuBind.JdPrice = vendorPrice + storeSkuBind.JdLockTime = pLockTime case model.VendorIDMTWM: storeSkuBind.MtwmPrice = vendorPrice + storeSkuBind.MtwmLockTime = pLockTime case model.VendorIDEBAI: storeSkuBind.EbaiPrice = vendorPrice + storeSkuBind.EbaiLockTime = pLockTime case model.VendorIDJX: storeSkuBind.JxPrice = vendorPrice + storeSkuBind.JxLockTime = pLockTime } } diff --git a/business/model/dao/store_sku_test.go b/business/model/dao/store_sku_test.go new file mode 100644 index 000000000..d787bb8c6 --- /dev/null +++ b/business/model/dao/store_sku_test.go @@ -0,0 +1,17 @@ +package dao + +import ( + "testing" + + "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/globals" +) + +func TestGetFullStoreSkus(t *testing.T) { + skuList, err := GetFullStoreSkus(GetDB(), model.VendorIDJD, 100118) + if err != nil { + t.Fatal(err) + } + globals.SugarLogger.Debug(utils.Format4Output(skuList, false)) +} diff --git a/business/model/store_sku.go b/business/model/store_sku.go index 382a97b61..a8d29c37f 100644 --- a/business/model/store_sku.go +++ b/business/model/store_sku.go @@ -109,7 +109,11 @@ type StoreSkuBind struct { EbaiPrice int `json:"ebaiPrice"` MtwmPrice int `json:"mtwmPrice"` JxPrice int `json:"jxPrice"` - // WscPrice int `json:"wscPrice"` + + JdLockTime *time.Time `orm:"null" json:"jdLockTime"` + EbaiLockTime *time.Time `orm:"null" json:"ebaiLockTime"` + MtwmLockTime *time.Time `orm:"null" json:"mtwmLockTime"` + JxLockTime *time.Time `orm:"null" json:"jxLockTime"` AutoSaleAt time.Time `orm:"type(datetime);null" json:"autoSaleAt"` diff --git a/controllers/act.go b/controllers/act.go index b746302a0..8d05ff4de 100644 --- a/controllers/act.go +++ b/controllers/act.go @@ -309,6 +309,7 @@ func (c *ActController) DeleteSkusFromAct() { // @Param type formData int true "活动类型,3:直降,4:秒杀(美团当前不支持秒杀)" // @Param vendorID formData int true "厂商ID,当前只支持,京东:0,京西(用于记录活动信息):9" // @Param actStoreSkuList formData string true "活动门店商品信息" +// @Param lockTime formData string false "平台价格锁定截止时间" // @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult @@ -317,7 +318,10 @@ func (c *ActController) ForceUpdateVendorPrice() { c.callForceUpdateVendorPrice(func(params *tActForceUpdateVendorPriceParams) (retVal interface{}, errCode string, err error) { var actStoreSkuList []*act.ActStoreSkuParam if err = jxutils.Strings2Objs(params.ActStoreSkuList, &actStoreSkuList); err == nil { - retVal, err = act.ForceUpdateVendorPrice(params.Ctx, params.VendorID, params.Type, actStoreSkuList, params.IsAsync) + timeList, err2 := jxutils.BatchStr2Time(params.LockTime) + if err = err2; err == nil { + retVal, err = act.ForceUpdateVendorPrice(params.Ctx, params.VendorID, params.Type, actStoreSkuList, timeList[0], params.IsAsync) + } } return retVal, "", err }) diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index aeb1de9c0..71fe04087 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -43,6 +43,7 @@ type StoreSkuController struct { // @Param jdSyncStatus query int false "京东同步标识" // @Param ebaiSyncStatus query int false "饿百同步标识" // @Param mtwmSyncStatus query int false "美团外卖同步标识" +// @Param lockTime query string false "价格锁定时间" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetStoreSkus [get] @@ -83,6 +84,7 @@ func (c *StoreSkuController) GetStoreSkus() { // @Param jdSyncStatus query int false "京东同步标识" // @Param ebaiSyncStatus query int false "饿百同步标识" // @Param mtwmSyncStatus query int false "美团外卖同步标识" +// @Param lockTime query string false "价格锁定时间" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetStoresSkus [get,post]