function union(arr){
arr = arr || [];
var tmp = {};
for(var i = 0, len = arr.length; i < len; i++){
var obj = arr[i];
if(obj.id in tmp){
tmp[obj.id].num += obj.num;
}else{
tmp[obj.id] = obj;
}
}
var result = [];
for(var key in tmp){
result.push(tmp[key]);
}
return result;
}