错误返回
This commit is contained in:
@@ -618,6 +618,9 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
var outStore *model.Store
|
var outStore *model.Store
|
||||||
|
if payload["autoEnableAt"] != nil {
|
||||||
|
payload["autoEnableAt"] = utils.Time2Date(utils.Str2Time(utils.Interface2String(payload["autoEnableAt"])))
|
||||||
|
}
|
||||||
valid := dao.StrictMakeMapByStructObject2(payload, store, &outStore, userName)
|
valid := dao.StrictMakeMapByStructObject2(payload, store, &outStore, userName)
|
||||||
if err = checkStoreDeliveryRange(utils.Interface2String(valid["deliveryRange"])); err != nil {
|
if err = checkStoreDeliveryRange(utils.Interface2String(valid["deliveryRange"])); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -722,7 +725,6 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
|||||||
} else {
|
} else {
|
||||||
if valid["autoEnableAt"] != nil {
|
if valid["autoEnableAt"] != nil {
|
||||||
status = model.StoreStatusHaveRest
|
status = model.StoreStatusHaveRest
|
||||||
valid["autoEnableAt"] = utils.Time2Date(utils.Str2Time(utils.Interface2String(valid["autoEnableAt"])))
|
|
||||||
} else {
|
} else {
|
||||||
status = model.StoreStatusClosed
|
status = model.StoreStatusClosed
|
||||||
}
|
}
|
||||||
@@ -735,27 +737,29 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
//时间校验
|
//时间校验
|
||||||
if outStore.OpenTime1 != 0 && outStore.CloseTime1 != 0 {
|
if outStore != nil {
|
||||||
if err := ValidateStructPartial(outStore, "OpenTime1", "CloseTime1"); err != nil {
|
if outStore.OpenTime1 != 0 && outStore.CloseTime1 != 0 {
|
||||||
|
if err := ValidateStructPartial(outStore, "OpenTime1", "CloseTime1"); err != nil {
|
||||||
|
return 0, errors.New(fmt.Sprintf("门店营业时间1设置不合法!时间范围1 :[%v] 至 [%v]", outStore.OpenTime1, outStore.CloseTime1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (outStore.OpenTime1 == 0 && outStore.CloseTime1 != 0) || (outStore.OpenTime1 != 0 && outStore.CloseTime1 == 0) {
|
||||||
return 0, errors.New(fmt.Sprintf("门店营业时间1设置不合法!时间范围1 :[%v] 至 [%v]", outStore.OpenTime1, outStore.CloseTime1))
|
return 0, errors.New(fmt.Sprintf("门店营业时间1设置不合法!时间范围1 :[%v] 至 [%v]", outStore.OpenTime1, outStore.CloseTime1))
|
||||||
}
|
}
|
||||||
}
|
if outStore.OpenTime2 != 0 && outStore.CloseTime2 != 0 {
|
||||||
if (outStore.OpenTime1 == 0 && outStore.CloseTime1 != 0) || (outStore.OpenTime1 != 0 && outStore.CloseTime1 == 0) {
|
if err := ValidateStructPartial(outStore, "OpenTime2", "CloseTime2"); err != nil {
|
||||||
return 0, errors.New(fmt.Sprintf("门店营业时间1设置不合法!时间范围1 :[%v] 至 [%v]", outStore.OpenTime1, outStore.CloseTime1))
|
return 0, errors.New(fmt.Sprintf("门店营业时间2设置不合法!时间范围2 :[%v] 至 [%v]", outStore.OpenTime2, outStore.CloseTime2))
|
||||||
}
|
}
|
||||||
if outStore.OpenTime2 != 0 && outStore.CloseTime2 != 0 {
|
}
|
||||||
if err := ValidateStructPartial(outStore, "OpenTime2", "CloseTime2"); err != nil {
|
if (outStore.OpenTime2 == 0 && outStore.CloseTime2 != 0) || (outStore.OpenTime2 != 0 && outStore.CloseTime2 == 0) {
|
||||||
return 0, errors.New(fmt.Sprintf("门店营业时间2设置不合法!时间范围2 :[%v] 至 [%v]", outStore.OpenTime2, outStore.CloseTime2))
|
return 0, errors.New(fmt.Sprintf("门店营业时间2设置不合法!时间范围2 :[%v] 至 [%v]", outStore.OpenTime1, outStore.CloseTime1))
|
||||||
|
}
|
||||||
|
if outStore.OpenTime2 > outStore.OpenTime1 {
|
||||||
|
return 0, errors.New(fmt.Sprintf("门店营业时间设置不合法!第二段营业时间应该在第一段营业时间之后!"))
|
||||||
|
}
|
||||||
|
if beginAt, endAt := GetTimeMixByInt(outStore.OpenTime1, outStore.CloseTime1, outStore.OpenTime2, outStore.CloseTime2); beginAt != 0 && endAt != 0 {
|
||||||
|
return 0, errors.New(fmt.Sprintf("两段门店营业时间不可交叉!时间范围1 :[%v] 至 [%v], 时间范围2 :[%v] 至 [%v]", outStore.OpenTime1, outStore.CloseTime1, outStore.OpenTime2, outStore.CloseTime2))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (outStore.OpenTime2 == 0 && outStore.CloseTime2 != 0) || (outStore.OpenTime2 != 0 && outStore.CloseTime2 == 0) {
|
|
||||||
return 0, errors.New(fmt.Sprintf("门店营业时间2设置不合法!时间范围2 :[%v] 至 [%v]", outStore.OpenTime1, outStore.CloseTime1))
|
|
||||||
}
|
|
||||||
if outStore.OpenTime2 > outStore.OpenTime1 {
|
|
||||||
return 0, errors.New(fmt.Sprintf("门店营业时间设置不合法!第二段营业时间应该在第一段营业时间之后!"))
|
|
||||||
}
|
|
||||||
if beginAt, endAt := GetTimeMixByInt(outStore.OpenTime1, outStore.CloseTime1, outStore.OpenTime2, outStore.CloseTime2); beginAt != 0 && endAt != 0 {
|
|
||||||
return 0, errors.New(fmt.Sprintf("两段门店营业时间不可交叉!时间范围1 :[%v] 至 [%v], 时间范围2 :[%v] 至 [%v]", outStore.OpenTime1, outStore.CloseTime1, outStore.OpenTime2, outStore.CloseTime2))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// districtCode := 0
|
// districtCode := 0
|
||||||
|
|||||||
@@ -248,6 +248,17 @@ func GetGoodsInfoAndDetailMap(goodsList []*weimobapi.GoodsInfo) (goodsMap map[st
|
|||||||
return goodsMap
|
return goodsMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func getSelectedClassifyLeafList(l []weimobapi.SelectedClassifyList) (list []int64) {
|
||||||
|
// for _, v := range l {
|
||||||
|
// if v.ChildrenClassify == nil {
|
||||||
|
// list = append(list, v.ClassifyID)
|
||||||
|
// } else {
|
||||||
|
// subList := getSelectedClassifyLeafList(v.ChildrenClassify)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return list
|
||||||
|
// }
|
||||||
|
|
||||||
func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.GoodsDetailInfo) (goodsID int64, skuMap map[string]int64, err error) {
|
func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.GoodsDetailInfo) (goodsID int64, skuMap map[string]int64, err error) {
|
||||||
var (
|
var (
|
||||||
categoryList []*weimobapi.CategoryList
|
categoryList []*weimobapi.CategoryList
|
||||||
@@ -272,6 +283,7 @@ func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.Good
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
baseapi.SugarLogger.Errorf("FindFreightTemplateList error:%v", err)
|
baseapi.SugarLogger.Errorf("FindFreightTemplateList error:%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//寻找分类子ID
|
//寻找分类子ID
|
||||||
categoryList = goodsDetail.CategoryList
|
categoryList = goodsDetail.CategoryList
|
||||||
if len(categoryList) > 0 {
|
if len(categoryList) > 0 {
|
||||||
@@ -279,6 +291,17 @@ func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.Good
|
|||||||
} else {
|
} else {
|
||||||
return 0, nil, errors.New(fmt.Sprintf("未查询到此商品的分类信息!goodsID : [%v] ,", goodsDetail.GoodsID))
|
return 0, nil, errors.New(fmt.Sprintf("未查询到此商品的分类信息!goodsID : [%v] ,", goodsDetail.GoodsID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectedClassifyList := goodsDetail.SelectedClassifyList
|
||||||
|
var selectedClassifyListID []int64
|
||||||
|
if len(selectedClassifyList) > 0 {
|
||||||
|
for _, v := range selectedClassifyList {
|
||||||
|
selectedClassifyListID = append(selectedClassifyListID, v.ChildrenClassify[0].ClassifyID)
|
||||||
|
}
|
||||||
|
// categoryID = categoryList[len(categoryList)-1].CategoryID
|
||||||
|
} else {
|
||||||
|
return 0, nil, errors.New(fmt.Sprintf("未查询到此商品的分类信息!goodsID : [%v] ,", goodsDetail.GoodsID))
|
||||||
|
}
|
||||||
b2CSku := &weimobapi.B2CSku{
|
b2CSku := &weimobapi.B2CSku{
|
||||||
Weight: skuListInfo.B2CSku.Weight,
|
Weight: skuListInfo.B2CSku.Weight,
|
||||||
Volume: skuListInfo.B2CSku.Volume,
|
Volume: skuListInfo.B2CSku.Volume,
|
||||||
@@ -298,16 +321,17 @@ func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.Good
|
|||||||
}
|
}
|
||||||
skuListParam = append(skuListParam, skuList)
|
skuListParam = append(skuListParam, skuList)
|
||||||
goods := &weimobapi.Goods{
|
goods := &weimobapi.Goods{
|
||||||
B2CGoods: b2CGoods,
|
B2CGoods: b2CGoods,
|
||||||
SkuList: skuListParam,
|
SkuList: skuListParam,
|
||||||
Title: goodsDetail.Title,
|
Title: goodsDetail.Title,
|
||||||
IsMultiSku: goodsDetail.IsMultiSku,
|
IsMultiSku: goodsDetail.IsMultiSku,
|
||||||
IsPutAway: weimobapi.GoodsTypeNormal,
|
IsPutAway: weimobapi.GoodsTypeNormal,
|
||||||
GoodsImageURL: goodsDetail.GoodsImageURL,
|
GoodsImageURL: goodsDetail.GoodsImageURL,
|
||||||
GoodsID: goodsDetail.GoodsID,
|
GoodsID: goodsDetail.GoodsID,
|
||||||
CategoryID: categoryID,
|
CategoryID: categoryID,
|
||||||
OuterGoodsCode: goodsDetail.OuterGoodsCode,
|
OuterGoodsCode: goodsDetail.OuterGoodsCode,
|
||||||
PointDeductRatio: goodsDetail.PointDeductRatio,
|
PointDeductRatio: goodsDetail.PointDeductRatio,
|
||||||
|
SelectedClassifyIDList: selectedClassifyListID,
|
||||||
}
|
}
|
||||||
updateGoodsParam := &weimobapi.UpdateGoodsParam{
|
updateGoodsParam := &weimobapi.UpdateGoodsParam{
|
||||||
Goods: goods,
|
Goods: goods,
|
||||||
|
|||||||
@@ -208,13 +208,10 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
if len(storeSkuList) > 1 {
|
if len(storeSkuList) > 1 {
|
||||||
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
||||||
if err = err2; err != nil && opResult != nil {
|
if err = err2; err != nil && opResult != nil {
|
||||||
failedList = putils.SelectStoreSkuListByOpResult(storeID, storeSkuList, opResult)
|
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
||||||
}
|
}
|
||||||
} else if len(storeSkuList) == 1 {
|
} else if len(storeSkuList) == 1 {
|
||||||
err = api.EbaiAPI.SkuPriceUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
_, err = api.EbaiAPI.SkuPriceUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
||||||
// if err != nil && opResult2 != nil {
|
|
||||||
// failedList = putils.SelectStoreSkuListByOpResult(storeID, storeSkuList, opResult2)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return failedList, err
|
return failedList, err
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CheckAndGetStructValue(item interface{}) *reflect.Value {
|
func CheckAndGetStructValue(item interface{}) *reflect.Value {
|
||||||
@@ -70,7 +71,9 @@ func FilterMapByStructObject(mapData map[string]interface{}, obj interface{}, ob
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if objPtr != nil {
|
if objPtr != nil {
|
||||||
utils.Map2StructByJson(m, objPtr, true)
|
if err := utils.Map2StructByJson(m, objPtr, true); err != nil {
|
||||||
|
globals.SugarLogger.Warnf("FilterMapByStructObject failed with err:%v, mapData:%s", err, utils.Format4Output(mapData, true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return valid, invalid
|
return valid, invalid
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user