- check store existing for CopyStoreSkus.
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -447,7 +448,18 @@ func CopyStoreSkus(fromStoreID, toStoreID int, copyMode string, params map[strin
|
||||
if copyMode != CopyStoreSkuModeFresh && copyMode != CopyStoreSkuModeUpdate {
|
||||
return 0, fmt.Errorf("不支持的拷贝模式:%s", copyMode)
|
||||
}
|
||||
if fromStoreID == toStoreID {
|
||||
return 0, fmt.Errorf("源门店:%d与目标门店:%d相同", fromStoreID, toStoreID)
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
if err = checkStoreExisting(db, fromStoreID); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if err = checkStoreExisting(db, toStoreID); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
sqlCatAndSku := ""
|
||||
sqlCatAndSkuParams := make([]interface{}, 0)
|
||||
if params["categoryIDs"] != nil {
|
||||
@@ -549,3 +561,15 @@ func setStoreSkuBindStatus(skuBind *model.StoreSkuBind, status int8) {
|
||||
skuBind.ElmSyncStatus |= status
|
||||
skuBind.EbaiSyncStatus |= status
|
||||
}
|
||||
|
||||
func checkStoreExisting(db *dao.DaoDB, storeID int) (err error) {
|
||||
store := model.Store{}
|
||||
store.ID = storeID
|
||||
if err = dao.GetEntity(db, store); err != nil {
|
||||
if err == orm.ErrNoRows {
|
||||
return fmt.Errorf("门店:%d不存在", storeID)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user