func (m *DecemberPrize) PrizeList(virtual int) ([]orm.Params, error) { o := orm.NewOrm() var maps []orm.Params if virtual == 1 { sql := "SELECT id,low_index,name,image,weight,num,virtual,if_reserve,stock,`left`,`top` FROM " + m.TableName() + " WHERE virtual=? and num>0 AND status=1 ORDER BY weight asc" _, e := o.Raw(sql, virtual).Values(&maps) return maps, e } else { sql := "SELECT id,low_index,name,image,weight,num,virtual,if_reserve,stock,`left`,`top` FROM " + m.TableName() + " WHERE virtual=? and num>0 AND status=1 ORDER BY weight asc" _, e := o.Raw(sql, virtual).Values(&maps) return maps, e } }
for k, v := range params { s := v["weight"].(string) //fmt.Println("sss ",s) //vWeight, _ := strconv.ParseInt(s, 10, 64) vWeight, _ := strconv.ParseFloat(s, 64) //fmt.Println(vWeight) params[k]["weight"] = vWeight * 10000 //if($v->num == 0) $radio += $v->weight; num1 := v["num"].(string) num, _ := strconv.Atoi(num1) if num <= 0 { ratio += float64(vWeight) } }