From 218ddf418f60a4c4787f5fae9fe83510379da69b Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 12 Feb 2020 16:35:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E8=B4=A6=E5=8D=95=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=8E=A8=E9=80=81=E5=88=B0=E4=B8=BB=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 19 ++----------------- business/jxstore/financial/financial.go | 4 ++-- business/model/dao/store.go | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 44b3252f1..f5326f72b 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -785,7 +785,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa } if valid["linkStoreID"] != nil { linkStoreID := int(utils.Interface2Int64WithDefault(valid["linkStoreID"], 0)) - linkStoreID, err = getRealLinkStoreID(linkStoreID) + linkStoreID, err = dao.GetRealLinkStoreID(db, linkStoreID) if err != nil { return 0, err } @@ -1038,7 +1038,7 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i return 0, err } } - realLinkStoreID, err := getRealLinkStoreID(storeExt.LinkStoreID) + realLinkStoreID, err := dao.GetRealLinkStoreID(db, storeExt.LinkStoreID) if err != nil { return 0, err } @@ -1085,21 +1085,6 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i return 0, err } -func getRealLinkStoreID(linkStoreID int) (realLinkStoreID int, err error) { - if linkStoreID != 0 { - store := &model.Store{} - store.ID = linkStoreID - if err = dao.GetEntity(dao.GetDB(), store); err == nil { - if store.LinkStoreID != 0 { - realLinkStoreID = store.LinkStoreID - } else { - realLinkStoreID = linkStoreID - } - } - } - return realLinkStoreID, err -} - func GetStoreVendorMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, vendorID int) (storeMaps []*model.StoreMap, err error) { cond := map[string]interface{}{ model.FieldStoreID: storeID, diff --git a/business/jxstore/financial/financial.go b/business/jxstore/financial/financial.go index e4a4a3fa2..f607effb5 100644 --- a/business/jxstore/financial/financial.go +++ b/business/jxstore/financial/financial.go @@ -56,7 +56,8 @@ func SendFilesToStores(ctx *jxcontext.Context, files []*multipart.FileHeader, ti func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { fileInfo := batchItemList[0].(*tUploadFileInfo) fileHeader := fileInfo.FileHeader - storeID := fileInfo.StoreID + db := dao.GetDB() + storeID, _ := dao.GetRealLinkStoreID(db, fileInfo.StoreID) file, err := fileHeader.Open() globals.SugarLogger.Debugf("SendFilesToStores upload file:%s", fileHeader.Filename) if err == nil { @@ -70,7 +71,6 @@ func SendFilesToStores(ctx *jxcontext.Context, files []*multipart.FileHeader, ti } file.Close() if err == nil { - db := dao.GetDB() billRec := &legacymodel.StoreBill{ Date: time.Now(), Url: strings.Replace(jxutils.ComposeQiniuResURL(ret.Key), "http://", "https://", -1), diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 08ea0505d..8dbd17e77 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -699,3 +699,19 @@ func GetStoreLinkStores(db *DaoDB, storeID int) (storeList []*model.Store, err e err = GetRows(db, &storeList, sql, sqlParams...) return storeList, err } + +func GetRealLinkStoreID(db *DaoDB, linkStoreID int) (realLinkStoreID int, err error) { + realLinkStoreID = linkStoreID + if linkStoreID != 0 { + store := &model.Store{} + store.ID = linkStoreID + if err = GetEntity(db, store); err == nil { + if store.LinkStoreID != 0 { + realLinkStoreID = store.LinkStoreID + } else { + realLinkStoreID = linkStoreID + } + } + } + return realLinkStoreID, err +}