重构代码(一)

public void toCoin(ModelMap modelMap, String Id, int startIndex,
HttpServletRequest request) {
// 根据手机号获取会员id

[code="java"][/code]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();
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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值