From 3a98d6fee8052adc85380c1a5d8aa4be7cd55362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 24 Jul 2020 10:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E9=97=A8=E5=BA=97=E8=B0=83=E4=BB=B7?= =?UTF-8?q?=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 48 +++++++++++++++++++++++++++++++++++ controllers/cms_store.go | 17 +++++++++++++ 2 files changed, 65 insertions(+) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 2bb3c575a..266708685 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -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 +} diff --git a/controllers/cms_store.go b/controllers/cms_store.go index 142f262bb..103e1b12f 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -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 + }) +}