From 5935c94aca1bb612a7721dcbb3dc2e4072fa6e74 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 13 Nov 2019 17:30:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E4=BB=B7=E6=A0=BC=E5=8C=85?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E6=9C=89=E5=B0=8F=E6=95=B0=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/store.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 75f0234a7..a603c7856 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -295,15 +295,31 @@ func GetRebindPrinterStoreList(db *DaoDB) (storeList []*model.Store, err error) return storeList, err } +// 容错用 +type tPricePercentageItemFloat struct { + BeginPrice float64 `json:"beginPrice"` // 起始价格区间(包括) + PricePercentage float64 `json:"pricePercentage"` // 调价比例 + PriceAdd float64 `json:"priceAdd"` // 调价额定值 +} + func PricePercentagePack2Obj(packStr string) (obj model.PricePercentagePack) { if packStr != "" { - if err := utils.UnmarshalUseNumber([]byte(packStr), &obj); err == nil { - for _, v := range obj { - if v.PricePercentage >= 500 || v.PricePercentage <= 80 { - return nil + var floatObj []*tPricePercentageItemFloat + if err := utils.UnmarshalUseNumber([]byte(packStr), &floatObj); err == nil { + if len(floatObj) > 0 { + obj = make(model.PricePercentagePack, len(floatObj)) + for k, v := range floatObj { + if v.PricePercentage >= 500 || v.PricePercentage <= 80 { + return nil + } + obj[k] = &model.PricePercentageItem{ + BeginPrice: int(v.BeginPrice), + PricePercentage: int(v.PricePercentage), + PriceAdd: int(v.PriceAdd), + } } + sort.Sort(obj) } - sort.Sort(obj) } } return obj