diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index bd7b30644..8c56f758a 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -87,7 +87,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac return nil, nil, nil, err } if len(effectActStoreSkuList) > 0 { - return nil, nil, nil, jsonerr.New(effectActStoreSkuList) + return nil, nil, nil, jsonerr.New(effectActStoreSkuList, model.ErrCodeJsonActSkuConflict) } storeSkuList, err2 := dao.GetStoresSkusInfo(db, storeIDs, skuIDs) @@ -99,6 +99,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)] = v } + var wrongSkuList []*ActStoreSkuParam for storeID, oneStoreSkuParam := range storeSkuParamMap { validVendorMap := make(map[int]int) validSkuMap := make(map[int]int) @@ -118,6 +119,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac SyncStatus: model.SyncFlagNewMask, VendorPrice: int64(jxutils.CaculateSkuVendorPrice(storeSkuInfo.Price, int(storeDetail.PricePercentage), 0)), } + v.OriginalPrice = actSkuMap.VendorPrice if v.ActPrice != 0 { actSkuMap.ActualActPrice = v.ActPrice } else { @@ -127,8 +129,12 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac } actSkuMap.ActualActPrice = int64(jxutils.CaculateSkuVendorPrice(int(actSkuMap.VendorPrice), percentage, 0)) } - dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) - actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) + if actSkuMap.ActualActPrice >= actSkuMap.VendorPrice { + wrongSkuList = append(wrongSkuList, v) + } else { + dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) + actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) + } } } wholeValidVendorMap[vendorID] = 1 @@ -138,7 +144,9 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac err = nil } } - + if len(wrongSkuList) > 0 { + return nil, nil, nil, jsonerr.New(wrongSkuList, model.ErrCodeJsonActPriceTooLarger) + } for _, v := range oneStoreSkuParam { if validSkuMap[v.SkuID] == 1 { // todo 这里是否需要判断 if storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)]; storeSkuInfo != nil { diff --git a/business/jxutils/jsonerr/jsonerr.go b/business/jxutils/jsonerr/jsonerr.go index e991df7d6..c055536e6 100644 --- a/business/jxutils/jsonerr/jsonerr.go +++ b/business/jxutils/jsonerr/jsonerr.go @@ -3,14 +3,16 @@ package jsonerr import "git.rosy.net.cn/baseapi/utils" type Error struct { - Obj interface{} - ObjStr string + errCode string + Obj interface{} + ObjStr string } -func New(obj interface{}) (err *Error) { +func New(obj interface{}, errCode string) (err *Error) { return &Error{ - Obj: obj, - ObjStr: string(utils.MustMarshal(obj)), + errCode: errCode, + Obj: obj, + ObjStr: string(utils.MustMarshal(obj)), } } @@ -22,3 +24,7 @@ func IsJsonErr(err error) bool { func (e *Error) Error() string { return e.ObjStr } + +func (e *Error) ErrCode() string { + return e.errCode +} diff --git a/business/model/error_code.go b/business/model/error_code.go index c1370cb1b..5c85e0449 100644 --- a/business/model/error_code.go +++ b/business/model/error_code.go @@ -11,7 +11,8 @@ const ( ErrCodeUserNotExist = "-3" ErrCodeUserAlreadyExist = "-4" - ErrCodeJsonFormat = "-10" // 这个错误号表示description中的是一个json对象,不是错误文本 + ErrCodeJsonActSkuConflict = "-101" // 这个错误号表示description中的是一个json对象,不是错误文本 + ErrCodeJsonActPriceTooLarger = "-102" // 这个错误号表示description中的是一个json对象,不是错误文本 ) var (