改门店调价包

This commit is contained in:
苏尹岚
2020-07-24 10:48:06 +08:00
parent 29673dd992
commit 3a98d6fee8
2 changed files with 65 additions and 0 deletions

View File

@@ -3361,3 +3361,51 @@ func findSkusBetweenJdsMainStore(db *dao.DaoDB, storeID int) (skus []int) {
}
return skus
}
func UpdateStorePricePack(ctx *jxcontext.Context, storeID, vendorID int, pricePack, value string) (err error) {
if err = checkConfig(model.SyncFlagModifiedMask, model.ConfigTypePricePack, pricePack, value); err != nil {
return err
}
db := dao.GetDB()
dao.Begin(db)
defer func() {
if r := recover(); r != nil {
dao.Rollback(db)
panic(r)
}
}()
//证明是门店自己的调价包
if strings.Contains(pricePack, utils.Int2Str(storeID)) {
} else {
configList, err := dao.QueryConfigs(db, pricePack, model.ConfigTypePricePack, "")
if err != nil {
dao.Rollback(db)
return err
}
if _, err = dao.UpdateEntityLogically(db, configList[0], map[string]interface{}{
"Value": value,
}, ctx.GetUserName(), nil); err != nil {
dao.Rollback(db)
return err
}
}
storeMapList, err := dao.GetStoresMapList(db, nil, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, pricePack, "")
if err != nil {
dao.Rollback(db)
return err
}
dao.Commit(db)
vendorStoreMap := make(map[int][]int)
for _, v := range storeMapList {
vendorStoreMap[v.VendorID] = append(vendorStoreMap[v.VendorID], v.StoreID)
}
for vendorID, storeIDs := range vendorStoreMap {
if vendorID != model.VendorIDJX {
dao.SetStoreSkuSyncStatus(db, vendorID, storeIDs, nil, model.SyncFlagPriceMask)
} else {
_, err = ReCalculateJxPrice(db, ctx, storeIDs)
}
}
return err
}

View File

@@ -775,3 +775,20 @@ func (c *SkuController) CopyStoreCategories() {
return retVal, "", err
})
}
// @Title 修改门店专属调价包
// @Description 修改门店专属调价包
// @Param token header string true "认证token"
// @Param storeID formData int true "门店ID"
// @Param vendorID formData int true "平台ID"
// @Param pricePack formData string true "门店调价包"
// @Param value formData string false "调价包json串"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /UpdateStorePricePack [put]
func (c *StoreController) UpdateStorePricePack() {
c.callUpdateStorePricePack(func(params *tStoreUpdateStorePricePackParams) (retVal interface{}, errCode string, err error) {
err = cms.UpdateStorePricePack(params.Ctx, params.StoreID, params.VendorID, params.PricePack, params.Value)
return retVal, "", err
})
}