避免价格包因为有小数导致的问题

This commit is contained in:
gazebo
2019-11-13 17:30:54 +08:00
parent ae5a923d38
commit 5935c94aca

View File

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