- fix bug in promotion.OnStoreStockMsg
This commit is contained in:
@@ -696,30 +696,30 @@ func RefreshJdPromotionLockStatus(promotionID int) (err error) {
|
||||
|
||||
func OnStoreStockMsg(msg *jdapi.CallbackStoreStockMsg) (retVal *jdapi.CallbackResponse) {
|
||||
var err error
|
||||
globals.SugarLogger.Debugf("OnStoreStockMsg msg:%s", utils.Format4Output(msg, false))
|
||||
// globals.SugarLogger.Debugf("OnStoreStockMsg IsJdStoreSkuLocked:%t", storeskulock.IsJdStoreSkuLocked(msg.StationNo, msg.SkuId))
|
||||
if (msg.Vendibility == 1 || !msg.Have) && storeskulock.IsJdStoreSkuLocked(msg.StationNo, msg.SkuId) {
|
||||
db := dao.GetDB()
|
||||
if msg.Vendibility == 1 {
|
||||
sku := &model.Sku{}
|
||||
sku.JdID = msg.SkuId
|
||||
if err = dao.GetEntity(db, sku); err == nil {
|
||||
if msg.Vendibility == 1 {
|
||||
vendibility := &jdapi.StockVendibility{
|
||||
OutSkuId: utils.Int2Str(sku.ID),
|
||||
DoSale: true,
|
||||
}
|
||||
_, err = api.JdAPI.BatchUpdateVendibility("", msg.StationNo, []*jdapi.StockVendibility{
|
||||
vendibility,
|
||||
}, "prevent")
|
||||
sku := &model.Sku{}
|
||||
sku.JdID = msg.SkuId
|
||||
if err = dao.GetEntity(db, sku, model.FieldJdID); err == nil {
|
||||
if msg.Vendibility == 1 {
|
||||
vendibility := &jdapi.StockVendibility{
|
||||
OutSkuId: utils.Int2Str(sku.ID),
|
||||
DoSale: true,
|
||||
}
|
||||
if !msg.Have {
|
||||
stock := &jdapi.SkuStock{
|
||||
OutSkuId: utils.Int2Str(sku.ID),
|
||||
StockQty: model.MaxStoreSkuStockQty,
|
||||
}
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", msg.StationNo, []*jdapi.SkuStock{
|
||||
stock,
|
||||
}, "prevent")
|
||||
_, err = api.JdAPI.BatchUpdateVendibility("", msg.StationNo, []*jdapi.StockVendibility{
|
||||
vendibility,
|
||||
}, "prevent")
|
||||
}
|
||||
if !msg.Have {
|
||||
stock := &jdapi.SkuStock{
|
||||
OutSkuId: utils.Int2Str(sku.ID),
|
||||
StockQty: model.MaxStoreSkuStockQty,
|
||||
}
|
||||
_, err = api.JdAPI.BatchUpdateCurrentQtys("", msg.StationNo, []*jdapi.SkuStock{
|
||||
stock,
|
||||
}, "prevent")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user