public void toCoin(ModelMap modelMap, String Id, int startIndex,
Http
ServletRequest request) {
// 根据手机号获取会员id
class="java" name="code">
String phone = request.getParameter("phone");
// Id = "";
if (!("".equals(phone) || phone == "") && (Id == "" || "".equals(Id))) {
PhoneUsersPO po = phoneUsers
Service.findByPhone(phone);
if (po == null) {
Id = "0";
modelMap.addAttribute("flag", "-1");
} else {
Id = po.getUserid() + "";
}
}
// 查询会员信息
PhoneUsersPO phoneUserpo = phoneUsersService.find(Id);
modelMap.addAttribute("phoneUserpo", phoneUserpo);
// 查询畅达币信息
Abstract
WebserviceInvoker webserviceInvoker = new LcdCoinInfosHandler();
Map<String, Object> phoneCoinInfo = (Map<String, Object>) webserviceInvoker
.invoke(WebServiceConstant.getTicketNewPoint(),
"getMLcdCoinInfos", WebServiceConstant.getQname(),
new Object[] { Id });
modelMap.addAttribute("phoneCoinPO", phoneCoinInfo);
// 获取会员畅达币明细
Pages page = new Pages(startIndex);
Map<Object, Object> map = new HashMap<Object, Object>();
// map.put("startIndex", startIndex);
map.put("userid", Id);
String coinstutas = request.getParameter("coinstutas");
String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate");
String details = request.getParameter("coinDetails");
String coinDetails = details == null ? details : details.trim();
map.put("coinstatus", coinstutas);
map.put("startDate", startDate);
map.put("endDate", endDate);
map.put("coinDetails", coinDetails);
map.put("page", page);
// / List<Map> temList = phoneCoinDetailsService.findByUserId1(map);
List<PhoneCoinDetailsVO> temList = phoneCoinDetailsService
.findUserCoinDetailNew(map);
page.setItems(temList);
// page.setTotalCount(phoneCoinDetailsService.countFindAllForPage1(map));
int coinCount = phoneCoinDetailsService.countUserCoinDetailNew(map);
page.setTotalCount(coinCount);
modelMap.addAttribute("page", page);
modelMap.addAttribute("coinstutas", coinstutas);
modelMap.addAttribute("startDate", startDate);
modelMap.addAttribute("endDate", endDate);
modelMap.addAttribute("coinDetails", coinDetails);
// modelMap.addAttribute("flag", "0");
}
重构后代码:
// 显示详细畅达币
public void toCoin(ModelMap modelMap, String id, int startIndex,
HttpServletRequest request) {
// 根据手机号获取会员id
String phone = request.getParameter("phone");
// Id = "";
if (!("".equals(phone) || phone == "") && (id == "" || "".equals(id))) {
PhoneUsersPO po = phoneUsersService.findByPhone(phone);
if (po == null) {
id = "0";
modelMap.addAttribute("flag", "-1");
} else {
id = po.getUserid() + "";
}
}
// 查询会员信息
PhoneUsersPO phoneUserpo = phoneUsersService.find(id);
modelMap.addAttribute("phoneUserpo", phoneUserpo);
// 查询畅达币信息
AbstractWebserviceInvoker webserviceInvoker = new LcdCoinInfosHandler();
@SuppressWarnings("unchecked")
Map<String, Object> phoneCoinInfo = (Map<String, Object>) webserviceInvoker
.invoke(WebServiceConstant.getTicketNewPoint(),
"getMLcdCoinInfos", WebServiceConstant.getQname(),
new Object[] { id });
modelMap.addAttribute("phoneCoinPO", phoneCoinInfo);
String coinstutas = request.getParameter("coinstutas");
String startDate = request.getParameter("startDate");
String endDate = request.getParameter("endDate");
String details = request.getParameter("coinDetails");
String coinDetails = details == null ? details : details.trim();
modelMap.addAttribute("coinstutas", coinstutas);
modelMap.addAttribute("startDate", startDate);
modelMap.addAttribute("endDate", endDate);
modelMap.addAttribute("coinDetails", coinDetails);
modelMap.addAttribute("page",
getUserCoinDetailsForMethodToCoin(startIndex,coinstutas, startDate,
endDate, details, id));
}
private Pages<PhoneCoinDetailsVO> getUserCoinDetailsForMethodToCoin(
int startIndex, String coinstutas, String startDate,
String endDate, String details, String userId) {
Pages<PhoneCoinDetailsVO> page = new Pages<PhoneCoinDetailsVO>(
startIndex);
Map<Object, Object> map = new HashMap<Object, Object>();
map.put("userid", userId);
map.put("coinDetails", details == null ? details : details.trim());
map.put("page", page);
List<PhoneCoinDetailsVO> temList = phoneCoinDetailsService
.findUserCoinDetailNew(map);
page.setItems(temList);
int coinCount = phoneCoinDetailsService.countUserCoinDetailNew(map);
page.setTotalCount(coinCount);
return page;
}