CreateAct与AddStoreVendorMap必须要求vendorOrgCode
修复UpdateStoreVendorMap中的bug
This commit is contained in:
@@ -407,6 +407,10 @@ func CreateAct(ctx *jxcontext.Context, act *model.Act, vendorIDs []int, vendorOr
|
||||
return "", err
|
||||
}
|
||||
act.VendorMask = model.GetVendorMask(vendorIDs...)
|
||||
if act.VendorMask&(^model.GetVendorMask(model.VendorIDJX)) != 0 &&
|
||||
vendorOrgCode == "" {
|
||||
return "", fmt.Errorf("必须指定平台分账号信息")
|
||||
}
|
||||
setActDefault(act)
|
||||
|
||||
db := dao.GetDB()
|
||||
|
||||
@@ -1037,7 +1037,13 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend
|
||||
userName := ctx.GetUserName()
|
||||
storeMap.StoreID = storeID
|
||||
storeMap.VendorID = vendorID
|
||||
storeMap.Status = model.StoreStatusOpened
|
||||
storeMap.DeliveryType = model.StoreDeliveryTypeByStore
|
||||
storeMap.SyncStatus = 0
|
||||
if vendorID != model.VendorIDJX {
|
||||
if storeMap.VendorOrgCode == "" {
|
||||
return nil, fmt.Errorf("必须指定平台分账号信息")
|
||||
}
|
||||
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
||||
store, err2 := handler.ReadStore(ctx, vendorOrgCode, storeMap.VendorStoreID)
|
||||
if err = err2; err == nil || storeMap.IsSync == 0 {
|
||||
@@ -1052,8 +1058,8 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend
|
||||
err = ErrCanNotFindVendor
|
||||
}
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(storeMap, userName)
|
||||
if err == nil {
|
||||
dao.WrapAddIDCULDEntity(storeMap, userName)
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -1101,9 +1107,12 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
return 0, fmt.Errorf("非京东平台要求必须自动拣货")
|
||||
}
|
||||
}
|
||||
storeHandler := CurVendorSync.GetStoreHandler(vendorID)
|
||||
if storeHandler == nil {
|
||||
return 0, ErrCanNotFindVendor
|
||||
var storeHandler partner.IPurchasePlatformHandler
|
||||
if vendorID != model.VendorIDJX {
|
||||
storeHandler = CurVendorSync.GetStoreHandler(vendorID)
|
||||
if storeHandler == nil {
|
||||
return 0, ErrCanNotFindVendor
|
||||
}
|
||||
}
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
@@ -1141,19 +1150,24 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
}
|
||||
}
|
||||
|
||||
if vendorStoreID := utils.Interface2String(valid["vendorStoreID"]); vendorStoreID != "" {
|
||||
vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, storeMap.VendorOrgCode, vendorStoreID)
|
||||
if err = err2; err == nil {
|
||||
valid["deliveryType"] = vendorStoreInfo.DeliveryType
|
||||
if vendorID != model.VendorIDJX {
|
||||
if vendorStoreID := utils.Interface2String(valid["vendorStoreID"]); vendorStoreID != "" {
|
||||
vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, storeMap.VendorOrgCode, vendorStoreID)
|
||||
if err = err2; err == nil {
|
||||
valid["deliveryType"] = vendorStoreInfo.DeliveryType
|
||||
}
|
||||
err = nil // todo 忽略读不到DeliveryType的错误
|
||||
}
|
||||
err = nil // todo 忽略读不到DeliveryType的错误
|
||||
}
|
||||
if err == nil {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(valid, false))
|
||||
if len(valid) > 0 {
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
dao.Rollback(db)
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if valid["status"] != nil { // 对于store vendor map,只有Status改变才需要同步到厂商
|
||||
num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeMap, valid, userName, map[string]interface{}{
|
||||
@@ -1166,19 +1180,24 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
model.FieldVendorID: vendorID,
|
||||
})
|
||||
}
|
||||
if err == nil && num > 0 {
|
||||
if err != nil {
|
||||
dao.Rollback(db)
|
||||
return 0, err
|
||||
}
|
||||
if num > 0 {
|
||||
if valid["pricePercentage"] != nil || valid["pricePercentagePack"] != nil {
|
||||
storeSkuBind := &model.StoreSkuBind{}
|
||||
if num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeSkuBind, nil, userName, map[string]interface{}{
|
||||
model.FieldStoreID: storeID,
|
||||
}, dao.GetSyncStatusStructField(model.VendorNames[vendorID]), model.SyncFlagPriceMask); err != nil {
|
||||
dao.Rollback(db)
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
dao.Commit(db)
|
||||
if valid["status"] != nil || valid["freightDeductionPack"] != nil {
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
|
||||
}
|
||||
}
|
||||
dao.Commit(db)
|
||||
if vendorID != model.VendorIDJX && (valid["status"] != nil || valid["freightDeductionPack"] != nil) {
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user