6、卖家订单部分

1、推荐一个bootstrap在线制作模板的一个网站: http://www.ibootstrap.cn/

2、订单列表:

@GetMapping("/list")
public ModelAndView list(@RequestParam(value = "page", defaultValue = "1") Integer page,
                         @RequestParam(value = "size" ,defaultValue = "10") Integer size,
                         Map<String,Object> map){
    PageRequest request = new PageRequest(page-1,size);
    Page<OrderDto> orderDtoPage = orderService.findList(request);
    map.put("orderDtoPage",orderDtoPage);
    map.put("currentPage", page);
    map.put("size", size);
    return new ModelAndView("order/list",map);
}

这样对于前台的list.ftl:

<html>
<#--全局的样式-->
<#include "../common/header.ftl">
<body>
<div id="wrapper" class="toggled">
    <#--边栏sidebar-->
    <#include "../common/nav.ftl">
     <#--主要内容content-->
    <div id="page-content-wrapper">
        <div class="container-fluid">
            <div class="row clearfix">
                <div class="col-md-12 column">
                    <table class="table table-bordered table-condensed">
                        <thead>
                        <tr>
                            <th>订单idth>
                            <th>姓名th>
                            <th>手机号th>
                            <th>地址th>
                            <th>金额th>
                            <th>订单状态th>
                            <th>支付状态th>
                            <th>创建时间th>
                            <th colspan="2">操作th>
                        tr>
                        thead>
                        <tbody>

                        <#list orderDtoPage.content as orderDto>
                        <tr>
                            <td>${orderDto.orderId}td>
                            <td>${orderDto.buyerName}td>
                            <td>${orderDto.buyerPhone}td>
                            <td>${orderDto.buyerAddress}td>
                            <td>${orderDto.orderAmount}td>
                            <td>${orderDto.getOrderStatusEnum().message}td>
                            <td>${orderDto.getPayStatusEnum().message}td>
                            <td>${orderDto.createTime}td>
                            <td><a href="/sell/seller/order/detail?orderId=${orderDto.orderId}">详情a>td>
                            <td>
                                <#if orderDto.getOrderStatusEnum().message == "新订单">
                                    <a href="/sell/seller/order/cancel?orderId=${orderDto.orderId}">取消a>
                                #if>
                            td>
                        tr>
                        #list>
                        tbody>
                    table>
                div>

                <#--分页-->
                <div class="col-md-12 column">
                    <ul class="pagination pull-right">

                    <#--上一页-->
                    <#if currentPage lte 1>
                        <li class="disabled"><a href="#">上一页a>li>
                    <#else>
                        <li><a href="/sell/seller/order/list?page=${currentPage - 1}&size=${size}">上一页a>li>
                    #if>

                    <#--1-N页-->
                    <#list 1..orderDtoPage.getTotalPages() as index>
                        <#if currentPage == index>
                            <li class="disabled"><a href="#">${index}a>li>
                        <#else>
                            <li><a href="/sell/seller/order/list?page=${index}&size=${size}">${index}a>li>
                        #if>
                    #list>

                    <#--下一页-->
                    <#if currentPage gte orderDtoPage.getTotalPages()>
                        <li class="disabled"><a href="#">下一页a>li>
                    <#else>
                        <li><a href="/sell/seller/order/list?page=${currentPage + 1}&size=${size}">下一页a>li>
                    #if>
                    ul>
                div>
            div>
        div>
    div>
div>
body>
html>

这里用的是freemark模板,直接就是引入依赖就可以使用了。

<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-freemarkerartifactId>
dependency>

3、对于订单详情、取消订单、完结订单:

@GetMapping("/cancel")
public ModelAndView cancel(@RequestParam("orderId") String orderId,
                           Map map){
    try {
        OrderDto orderDto = orderService.findOne(orderId);
        orderService.cancel(orderDto);
    } catch (SellException e) {
        log.error("【卖家端取消订单】发生异常{}", e);
        map.put("msg", e.getMessage());
        map.put("url", "/sell/seller/order/list");
        return new ModelAndView("common/error", map);
    }
    map.put("msg", ResultEnum.ORDER_CANCEL_SUCCESS.getMessage());
    map.put("url", "/sell/seller/order/list");
    return new ModelAndView("common/success");
}

/**
 * 订单详情
 * @param orderId
 * @param map
 * @return
 */
@GetMapping("/detail")
public ModelAndView detail(@RequestParam("orderId") String orderId,
                           Map map) {
    OrderDto orderDto = new OrderDto();
    try {
        orderDto = orderService.findOne(orderId);
    }catch (SellException e) {
        log.error("【卖家端查询订单详情】发生异常{}", e);
        map.put("msg", e.getMessage());
        map.put("url", "/sell/seller/order/list");
        return new ModelAndView("common/error", map);
    }

    map.put("orderDTO", orderDto);
    return new ModelAndView("order/detail", map);
}

/**
 * 完结订单
 * @param orderId
 * @param map
 * @return
 */
@GetMapping("/finish")
public ModelAndView finished(@RequestParam("orderId") String orderId,
                             Map map) {
    try {
        OrderDto orderDTO = orderService.findOne(orderId);
        orderService.finish(orderDTO);
    } catch (SellException e) {
        log.error("【卖家端完结订单】发生异常{}", e);
        map.put("msg", e.getMessage());
        map.put("url", "/sell/seller/order/list");
        return new ModelAndView("common/error", map);
    }

    map.put("msg", ResultEnum.ORDER_FINISH_SUCCESS.getMessage());
    map.put("url", "/sell/seller/order/list");
    return new ModelAndView("common/success");
}

你可能感兴趣的:(6、卖家订单部分)