- add param isAsync and isContinueWhenError for update store sku serial apis
This commit is contained in:
@@ -419,11 +419,11 @@ func GetStoresSkusSaleInfo(ctx *jxcontext.Context, storeIDs []int, skuIDs []int,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func UpdateStoreSku(ctx *jxcontext.Context, storeID int, skuBindInfo *StoreSkuBindInfo) (num int64, err error) {
|
||||
return UpdateStoreSkus(ctx, storeID, []*StoreSkuBindInfo{skuBindInfo})
|
||||
func UpdateStoreSku(ctx *jxcontext.Context, storeID int, skuBindInfo *StoreSkuBindInfo, isAsync, isContinueWhenError bool) (num int64, err error) {
|
||||
return UpdateStoreSkus(ctx, storeID, []*StoreSkuBindInfo{skuBindInfo}, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
func UpdateStoreSkus(ctx *jxcontext.Context, storeID int, skuBindInfos []*StoreSkuBindInfo) (num int64, err error) {
|
||||
func UpdateStoreSkus(ctx *jxcontext.Context, storeID int, skuBindInfos []*StoreSkuBindInfo, isAsync, isContinueWhenError bool) (num int64, err error) {
|
||||
// skuIDs, err := updateStoresSkusWithoutSync(ctx, []int{storeID}, skuBindInfos)
|
||||
// num = int64(len(skuIDs))
|
||||
// if err == nil && num > 0 {
|
||||
@@ -432,15 +432,15 @@ func UpdateStoreSkus(ctx *jxcontext.Context, storeID int, skuBindInfos []*StoreS
|
||||
// return int64(len(skuIDs)), err
|
||||
// }
|
||||
// return 0, err
|
||||
return UpdateStoresSkus(ctx, []int{storeID}, skuBindInfos)
|
||||
return UpdateStoresSkus(ctx, []int{storeID}, skuBindInfos, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
func UpdateStoresSkus(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (num int64, err error) {
|
||||
func UpdateStoresSkus(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo, isAsync, isContinueWhenError bool) (num int64, err error) {
|
||||
skuIDs, err := updateStoresSkusWithoutSync(ctx, storeIDs, skuBindInfos)
|
||||
num = int64(len(skuIDs))
|
||||
if num > 0 {
|
||||
db := dao.GetDB()
|
||||
_, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, false)
|
||||
_, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, isAsync, isContinueWhenError)
|
||||
}
|
||||
return num, err
|
||||
}
|
||||
@@ -711,7 +711,7 @@ func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBind
|
||||
return needSyncSkus, err
|
||||
}
|
||||
|
||||
func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfos []*StoreSkuBindSkuInfo, userName string) (num int64, err error) {
|
||||
func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfos []*StoreSkuBindSkuInfo, userName string, isAsync, isContinueWhenError bool) (num int64, err error) {
|
||||
for _, storeID := range storeIDs {
|
||||
skuIDs, err2 := updateStoreSkusSaleWithoutSync(ctx, storeID, skuBindSkuInfos, userName)
|
||||
if err = err2; err != nil {
|
||||
@@ -724,7 +724,7 @@ func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfo
|
||||
skuIDs = append(skuIDs, v.SkuID)
|
||||
}
|
||||
db := dao.GetDB()
|
||||
_, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, false)
|
||||
_, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, isAsync, isContinueWhenError)
|
||||
return num, err
|
||||
}
|
||||
|
||||
@@ -1095,7 +1095,7 @@ func AcceptStoreOpRequests(ctx *jxcontext.Context, reqIDs []int) (err error) {
|
||||
}
|
||||
}
|
||||
if err2 == nil {
|
||||
_, err2 := UpdateStoresSkus(ctx, []int{op.StoreID}, []*StoreSkuBindInfo{skuBindInfo})
|
||||
_, err2 := UpdateStoresSkus(ctx, []int{op.StoreID}, []*StoreSkuBindInfo{skuBindInfo}, false, false)
|
||||
isLocalSucess := true
|
||||
if err2 != nil {
|
||||
subErrors[reqID] = err2
|
||||
|
||||
@@ -55,6 +55,8 @@ func (c *StoreSkuController) GetStoreSkus() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeID formData int true 门店ID"
|
||||
// @Param payload formData string true "json数据,StoreSkuBindInfo对象"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Param isAsync formData bool false "是否异步操作"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateStoreSku [put]
|
||||
@@ -62,7 +64,7 @@ func (c *StoreSkuController) UpdateStoreSku() {
|
||||
c.callUpdateStoreSku(func(params *tStoreSkuUpdateStoreSkuParams) (retVal interface{}, errCode string, err error) {
|
||||
var skuBindInfo cms.StoreSkuBindInfo
|
||||
if err = jxutils.Strings2Objs(params.Payload, &skuBindInfo); err == nil {
|
||||
retVal, err = cms.UpdateStoreSku(params.Ctx, params.StoreID, &skuBindInfo)
|
||||
retVal, err = cms.UpdateStoreSku(params.Ctx, params.StoreID, &skuBindInfo, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
@@ -73,6 +75,8 @@ func (c *StoreSkuController) UpdateStoreSku() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeID formData int true "门店ID"
|
||||
// @Param payload formData string true "json数据,StoreSkuBindInfo对象数组"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Param isAsync formData bool false "是否异步操作"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateStoreSkus [put]
|
||||
@@ -80,7 +84,7 @@ func (c *StoreSkuController) UpdateStoreSkus() {
|
||||
c.callUpdateStoreSkus(func(params *tStoreSkuUpdateStoreSkusParams) (retVal interface{}, errCode string, err error) {
|
||||
var skuBindInfos []*cms.StoreSkuBindInfo
|
||||
if err = jxutils.Strings2Objs(params.Payload, &skuBindInfos); err == nil {
|
||||
retVal, err = cms.UpdateStoreSkus(params.Ctx, params.StoreID, skuBindInfos)
|
||||
retVal, err = cms.UpdateStoreSkus(params.Ctx, params.StoreID, skuBindInfos, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
@@ -114,6 +118,8 @@ func (c *StoreSkuController) SyncStoresSkus() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string true "门店ID列表"
|
||||
// @Param payload formData string true "json数据,StoreSkuBindInfo对象数组"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Param isAsync formData bool false "是否异步操作"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateStoresSkus [put]
|
||||
@@ -124,7 +130,7 @@ func (c *StoreSkuController) UpdateStoresSkus() {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Payload, &skuBindInfos); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.UpdateStoresSkus(params.Ctx, storeIDs, skuBindInfos)
|
||||
retVal, err = cms.UpdateStoresSkus(params.Ctx, storeIDs, skuBindInfos, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -153,6 +159,8 @@ func (c *StoreSkuController) CopyStoreSkus() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string true "门店ID列表"
|
||||
// @Param payload formData string true "json数据,StoreSkuBindSkuInfo对象数组"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Param isAsync formData bool false "是否异步操作"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateStoresSkusSale [put]
|
||||
@@ -163,7 +171,7 @@ func (c *StoreSkuController) UpdateStoresSkusSale() {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Payload, &skuBindSkuInfos); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.UpdateStoresSkusSale(params.Ctx, storeIDs, skuBindSkuInfos, params.Ctx.GetUserName())
|
||||
retVal, err = cms.UpdateStoresSkusSale(params.Ctx, storeIDs, skuBindSkuInfos, params.Ctx.GetUserName(), params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user