八月七号

alipayForm中添加:private Integer index = 0;

在Controller里的order路径下添加如下代码:

 @RequestMapping(value = "order", method = RequestMethod.GET)

    public String order(Model model, AlipayForm alipayForm, HttpSession session, Device device) {

    GoodsForm goodsForm=new GoodsForm();

    List<GoodsForm> commodityType = goodsService.getType();

    goodsForm.setCommodityTypeId(commodityType.get(0).getCommodityTypeId());

    model.addAttribute("goodsForm", goodsForm);

    model.addAttribute("commodityType", commodityType);

    log.info("我的订单");

    CartForm cartForm = new CartForm();

    model.addAttribute("cartForm", cartForm);

    UVO uvo = (UVO)session.getAttribute("UVO");

    if (uvo == null || StringUtils.isEmpty(uvo.getGuestId())) {

    return "redirect:/initGuestLogin";

    }

    cartForm.setGuestId(uvo.getGuestId());

    model.addAttribute("cartList", cartService.searchCartList(cartForm));

    model.addAttribute("pagesList", cartService.searchOrderListCount(cartForm));

    model.addAttribute("orderList", cartService.searchOrderList(cartForm, alipayForm.getIndex()));

    model.addAttribute("alipayForm", alipayForm);

        if(device.isNormal()) {

    return "shop/order";

    } else {

    return "mobile/alipay/replayAlipayConfirm";

    }

    }

对应的Service里添加相应的方法

public List<Integer> searchOrderListCount(CartForm frm) {

Double count = queryDao.executeForObject("Cart.selectAlipayHistoryListCount", frm, Double.class);

List<Integer> list = new ArrayList<>();

Integer pages = (int) Math.ceil(count/5);

for (int i=1; i<=pages; i++) {

list.add(i);

}

return list;

}

public List<AlipayForm> searchOrderList(CartForm frm, Integer index) {

      List<AlipayForm> result = queryDao.executeForObjectList("Cart.selectAlipayHistoryList", frm, index*5, 5);

return result;

}

SQL文

<select id="selectAlipayHistoryListCount" parameterClass="cn.agriculture.web.form.CartForm"

resultClass="java.lang.Double">     //查询数据库中的记录有多少条

SELECT count(0)

FROM alipay_history

WHERE commodity_id is null

AND guest_id = #guestId#

ORDER BY update_time DESC

</select>

<select id="selectAlipayHistoryList" parameterClass="cn.agriculture.web.form.CartForm"

resultClass="cn.agriculture.web.form.AlipayForm">

SELECT out_trade_no as outTradeNo,

subject as subject,

price as price,

body as body,

show_url as showUrl,

receive_name as receiveName,

receive_address as receiveAddress,

receive_zip as receiveZip,

receive_phone as receivePhone,

receive_mobile as receiveMobile,

guest_id as guestId,

update_time as updateTime,

update_user as updateUser,

is_paid as isPaid

FROM alipay_history

WHERE commodity_id is null

AND guest_id = #guestId#

ORDER BY update_time DESC

</select>

页面中的获取

 <ul class="pagination fr">

 <li><a href="order?index=0">«第一页</a></li>

 <li th:each="pages,sts:${pagesList}" th:class="${alipayForm.index==sts.index}?'active':''">                                                                    <a th:href="@{order(index=${sts.index})}" th:text="${pages}">1</a></li>

 <li><a th:href="@{order(index=${pagesList.size()}-1)}">最后一页»</a></li>

</ul>



转载于:https://my.oschina.net/u/2411785/blog/488948

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值