conroller层
public void flowersOrder(){
String userId = getPara("userId", "");
Flowerorder model = new Flowerorder();
Flowersrelation flowers = new Flowersrelation();JSONObject where = new JSONObject();
where.put("userId", userId);
List<Record> result = model.getList(where);
List<Record> re = null ;
for (Record record : result) {
String orderId = record.get("orderId");
re = flowers.flowersList(orderId, getRequest());
record.set("mealsList", re);
}
renderJSON(true, "请求成功", result);
}
model层
/**
* @方法名:一个订单多条数据
* @参数:
* @输出:
* @备注:
* @作者: DF
* @时间: 2018年5月7日 11:37:59
* @修改:
*/
public List<Record> flowersList(String orderId,HttpServletRequest req){
StringBuffer sql = new StringBuffer();
sql.append(" select t2.flowersPic,t2.flowersId,t2.name,t3.price,t1.num,t4.format,t4.price,t4.id ");
sql.append(" from "+ this.tableName()+" t1");
sql.append(" left join "+new Format().tableName()+" t4 on t4.id = t1.id ");
sql.append(" left join "+new Flowers().tableName()+" t2 on t4.flowersId = t2.flowersId ");
sql.append(" left join "+new Flowerorder().tableName()+" t3 on t3.orderId = t1.orderId ");
sql.append(" where t1.orderId = ? and t1.isDel = 0 and t3.isDel = 0 order by t1.addTime desc ");
List<Record> pic = Db.find(sql.toString(),orderId);
return pic;
}