Sql sql;
Date now= HgUtils.getTodayStart();
// now.set(Calendar.HOUR_OF_DAY,0);
// now.set(Calendar.MINUTE,0);
// now.set(Calendar.SECOND,0);
if(fetch == null){
sql = Sqls.create("SELECT COALESCE(SUM(o.total_price),0) as sum FROM orderinfo o INNER JOIN User_Account u ON o.`user_account` = u.`account` WHERE o.parent = '0000' AND o.ostatus = '已完成' AND o.`create_time` > '"+sdf.format(now.getTime())+"' AND o.`create_time` < '"+sdf.format(new Date())+"';");
ok.setv("wallet","0");
// sql.params().set("parent","0000");
// return Result.fail().setv("admin",1);
}else{
sql = Sqls.create("SELECT COALESCE(SUM(o.total_price),0) as sum FROM orderinfo o INNER JOIN User_Account u ON o.`user_account` = u.`account` WHERE o.parent = '"+fetch.getPhone()+"' AND o.ostatus = '已完成' AND o.`create_time` > '"+sdf.format(now.getTime())+"' AND o.`create_time` < '"+sdf.format(new Date())+"' ;");
// sql.params().set("parent",fetch.getPhone());
ok.setv("wallet",fetch.getWallet());
}
final double[] todayMoney = new double[1];
sql.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
if(rs.next()){
return rs.getDouble("sum");
}
return 0;
}
});
dao.execute(sql);
// int anInt = execute.getInt();
ok.setv("todayMoney",sql.getDouble());//当日余额
执行的sql我复制到工具里执行了,是有值的,但就是取值的时候一直是0.0,我取得有问题吗?