|
@ -155,4 +155,77 @@ public class BundleBean extends IpuAppBean{
|
155
|
155
|
return in;
|
156
|
156
|
}
|
157
|
157
|
|
|
158
|
/**
|
|
159
|
* 根据服务端的信息表与传入app参数对比,计算返回的更新信息
|
|
160
|
* @param {"appV":"1","bundleV":"1.1","platform":"Android"}
|
|
161
|
* @return {"status":"0","latestBundleV":"2.3","latestAppMinV":"2","canUpdate":"true","canUpdateBundle":"1.3","canUpdateAppMinV":"1","patchUrl":"http://www.xxx.xxx/xxx","des":"一些备注","platForm":"Android"}
|
|
162
|
*/
|
|
163
|
private IData calUpdate(IData params){
|
|
164
|
IData results = new DataMap();
|
|
165
|
String appV = params.getString("appV");
|
|
166
|
String appBundleV = params.getString("bundleV");
|
|
167
|
String platForm = params.getString("platform");
|
|
168
|
//获取后台信息进行匹配
|
|
169
|
String des = null;
|
|
170
|
//1.appV判断是否可以更新
|
|
171
|
List<String> appVs = getAppVs(platForm);
|
|
172
|
List<Integer> appVIns = new ArrayList<Integer>();
|
|
173
|
for(String s:appVs){
|
|
174
|
appVIns.add(Integer.parseInt(s));
|
|
175
|
}
|
|
176
|
if(appVIns.size() <= 0){
|
|
177
|
results.put("status","-1");
|
|
178
|
results.put("des","没有获取到任何App版本信息");
|
|
179
|
return results;
|
|
180
|
}
|
|
181
|
int minApp = Collections.min(appVIns);
|
|
182
|
int maxApp = Collections.max(appVIns);
|
|
183
|
boolean noLowThanMinApp = Integer.parseInt(appV) >= minApp;//不低于最低app版本
|
|
184
|
boolean isAppUpdate = false;
|
|
185
|
boolean canUpdate = false;
|
|
186
|
//2.bundleV判断提供哪个patches版本或bundle,或者不用更新
|
|
187
|
if(noLowThanMinApp){
|
|
188
|
String lastestBundleV = queryLastestBundleV(appV,platForm);//获取此app版本下最新bundle版本
|
|
189
|
results.put("lastestBundleV",lastestBundleV);
|
|
190
|
if(Float.parseFloat(appBundleV) < Float.parseFloat(lastestBundleV)){
|
|
191
|
String patchUrl = queryUpdatePatch(appBundleV,lastestBundleV,platForm);
|
|
192
|
des = "可以更新," + "当前App版本"+ appV + "支持最新Bundle版本" + lastestBundleV;
|
|
193
|
results.put("patchUrl",patchUrl);
|
|
194
|
canUpdate = true;
|
|
195
|
}else{
|
|
196
|
canUpdate = false;
|
|
197
|
des = "不能更新," + "已经是当前App版本"+ appV + "的最新Bundle版本";
|
|
198
|
}
|
|
199
|
if(Integer.parseInt(appV) < maxApp){//appV低于最高版本appV
|
|
200
|
des = des + ";最新的App版本为" + maxApp;
|
|
201
|
String appUrl = queryLastestAppUrl();
|
|
202
|
results.put("appUrl",appUrl);
|
|
203
|
isAppUpdate = true;
|
|
204
|
}
|
|
205
|
}else {
|
|
206
|
canUpdate = false;
|
|
207
|
des = "不能更新,低于最低App版本" + minApp + ";可更新到最新的App版本" + maxApp;
|
|
208
|
String appUrl = queryLastestAppUrl();
|
|
209
|
results.put("appUrl",appUrl);
|
|
210
|
isAppUpdate = true;
|
|
211
|
}
|
|
212
|
//3.拼接结果
|
|
213
|
results.put("status","0");
|
|
214
|
results.put("canUpdate",canUpdate);
|
|
215
|
results.put("isAppUpdate",isAppUpdate);
|
|
216
|
results.put("des",des);
|
|
217
|
return results;
|
|
218
|
}
|
|
219
|
|
|
220
|
/**
|
|
221
|
* 返回对应App能拿到的更新信息
|
|
222
|
* @param {"appV":"1","bundleV":"1.1","platform":"Android"}
|
|
223
|
* @return {"status":"0","latestBundleV":"2.3","latestAppMinV":"2","canUpdate":"true","canUpdateBundle":"1.3","canUpdateAppMinV":"1","patchUrl":"http://www.xxx.xxx/xxx","des":"一些备注","platForm":"Android"}
|
|
224
|
*/
|
|
225
|
public IData getPatchInfo(IData params){
|
|
226
|
IData results = null;
|
|
227
|
results = calUpdate(params);
|
|
228
|
return results;
|
|
229
|
}
|
|
230
|
|
158
|
231
|
}
|