处理UpdateStore时,传入autoEnableAt引起的crash
This commit is contained in:
@@ -618,6 +618,9 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
return 0, err
|
||||
}
|
||||
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)
|
||||
if err = checkStoreDeliveryRange(utils.Interface2String(valid["deliveryRange"])); err != nil {
|
||||
return 0, err
|
||||
@@ -722,7 +725,6 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
} else {
|
||||
if valid["autoEnableAt"] != nil {
|
||||
status = model.StoreStatusHaveRest
|
||||
valid["autoEnableAt"] = utils.Time2Date(utils.Str2Time(utils.Interface2String(valid["autoEnableAt"])))
|
||||
} else {
|
||||
status = model.StoreStatusClosed
|
||||
}
|
||||
@@ -735,6 +737,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
}
|
||||
|
||||
//时间校验
|
||||
if outStore != 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))
|
||||
@@ -757,6 +760,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
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
|
||||
// if valid["districtCode"] != nil {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
func CheckAndGetStructValue(item interface{}) *reflect.Value {
|
||||
@@ -70,7 +71,9 @@ func FilterMapByStructObject(mapData map[string]interface{}, obj interface{}, ob
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user