- 将一些需要返回json信息的错误,正式编码,从-101开始

This commit is contained in:
gazebo
2019-07-12 14:29:38 +08:00
parent 166675232c
commit 7d59d1d0f1
3 changed files with 25 additions and 10 deletions

View File

@@ -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 {

View File

@@ -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
}

View File

@@ -11,7 +11,8 @@ const (
ErrCodeUserNotExist = "-3"
ErrCodeUserAlreadyExist = "-4"
ErrCodeJsonFormat = "-10" // 这个错误号表示description中的是一个json对象不是错误文本
ErrCodeJsonActSkuConflict = "-101" // 这个错误号表示description中的是一个json对象不是错误文本
ErrCodeJsonActPriceTooLarger = "-102" // 这个错误号表示description中的是一个json对象不是错误文本
)
var (