728x90
관리자가 등록한 상품을 사용자가
회원가입 - 로그인 - 상품목록 - 상품내용 - 장바구니 - 주문 의 로직으로 주문을 완료했을때
아래 관리자페이지의 주문관리에 주문 목록이 표시된다.
관리자는 물품준비중에 들어온 주문의 주문번호를 눌러서 물품을 확인하고,
배송이 완료되면 송장번호입력 버튼을 눌러서 송장번호를 입력하면,
배송상태가 배송중으로 바뀌며, DB에 송장번호가 들어가고,
사용자는 마이페이지 주문목록에서 송장번호와 배송상태를 확인 할 수 있다.
사용자가 주문취소 버튼을 누른 건은 취소요청버튼을 눌러서 확인 할 수 있고,
환불처리 또는 교환처리를 할 수 있다.
Mapper
<select id="orderList" resultType="kr.co.vo.OrderedVO"
parameterType="kr.co.vo.ItemCriteria">
SELECT *
FROM (
SELECT
ordered_no,ordered_mem_no,ordered_to_name,ordered_to_tel,ordered_to_email,
ordered_to_adr,ordered_to_post,ordered_from_name,ordered_from_tel,
ordered_from_adr,ordered_from_post,ordered_cartprice,ordered_orderprice,
ordered_cpn_name,ordered_cpn_disc,ordered_usepoint,ordered_payhow,
ordered_paystate,ordered_delivstate,ordered_delivnum,ordered_date,
ordered_cdate,
ROW_NUMBER() OVER(
ORDER BY ORDERED_NO ASC
) AS RNUM
FROM ORDERED
WHERE
<include refid="delivstate" />
)
WHERE RNUM BETWEEN #{rowStart} AND #{rowEnd}
order by ORDERED_NO ASC
</select>
<select id="orderCount" resultType="int" parameterType="kr.co.vo.ItemCriteria">
SELECT COUNT(*) FROM ORDERED WHERE <![CDATA[ORDERED_NO > 0 ]]>
AND
<include refid="delivstate"/>
</select>
<sql id="delivstate">
<if test="delivstate == null ">
ordered_delivstate = 1 AND ordered_paystate = 1
</if>
<if test="delivstate == '' ">
ordered_delivstate = 1 AND ordered_paystate = 1
</if>
<if test="delivstate == 1 ">
ordered_delivstate = 1 AND ordered_paystate = 1
</if>
<if test="delivstate == 2 ">
ordered_delivstate = 2 AND ordered_paystate = 1
</if>
<if test="delivstate == 3 ">
ordered_delivstate = 3 AND ordered_paystate = 1
</if>
<if test="delivstate == 4">
ordered_paystate = 2
</if>
<if test="delivstate == 5">
ordered_paystate = 3
</if>
<if test="delivstate == 6">
ordered_paystate = 4
</if>
</sql>
<select id="orderState1" resultType="int">
select count(*) from ordered where ordered_delivstate = 1 AND ordered_paystate = 1
</select>
<select id="orderState2" resultType="int">
select count(*) from ordered where ordered_delivstate = 2 AND ordered_paystate = 1
</select>
<select id="orderState3" resultType="int">
select count(*) from ordered where ordered_paystate = 2
</select>
<update id="delivNumberUpdate">
update ordered set ORDERED_DELIVSTATE = #{ordered_delivstate} where ordered_no = #{ordered_no}
</update>
<!-- 송장번호입력 -->
<update id="delivNumberInsert">
update ordered set ORDERED_DELIVNUM = #{ordered_delivnum} where ordered_no = #{ordered_no}
</update>
<update id="orderExchange">
update ordered set ordered_paystate = 3 where ordered_no = #{ordered_no}
</update>
<update id="orderCancel">
update ordered set ordered_paystate = 4 where ordered_no = #{ordered_no}
</update>
<select id="orderItemView" resultType="kr.co.vo.OrderItemInsertVO">
select * from orderItem where ORDERITEM_ORDER_NO = #{ordered_no}
</select>
<select id="orderItemInfo" resultType="kr.co.vo.OrderedVO">
select * from ordered where ordered_no = #{ordered_no}
</select>
주문목록을 위한 List , 송장번호 입력 후 배송중으로 바꾸기 위한 update ,
주문취소, 교환 , 환불처리, 주문서 확인등의 쿼리이다
Controller
@RequestMapping(value = {"/orderManage"}, method = {RequestMethod.GET})
public String itemView(Model model, @ModelAttribute("cri") ItemCriteria cri) throws Exception {
model.addAttribute("orderList", clientService.orderList(cri));
ItemPageMaker pageMaker = new ItemPageMaker();
pageMaker.setCri(cri);
pageMaker.setTotalCount(clientService.orderCount(cri));
model.addAttribute("pageMaker", pageMaker);
model.addAttribute("orderState1", clientService.orderState1());
model.addAttribute("orderState2", clientService.orderState2());
model.addAttribute("orderState3", clientService.orderState3());
return "/master/orderManage";
}
@RequestMapping(value = {"/delivNumberInsert"}, method = {RequestMethod.POST})
public String delivNumberInsert(OrderedVO orderedVO)throws Exception{
clientService.delivNumberInsert(orderedVO);
orderedVO.setOrdered_delivstate(2);
clientService.delivNumberUpdate(orderedVO);
return "redirect:/master/orderManage";
}
@RequestMapping(value="/orderExchange" , method=RequestMethod.POST)
public String orderExchange(int ordered_no)throws Exception{
clientService.orderExchange(ordered_no);
return "redirect:/master/orderManage";
}
@RequestMapping(value="/orderCancel" , method=RequestMethod.POST)
public String orderCancel(int ordered_no)throws Exception{
clientService.orderCancel(ordered_no);
return "redirect:/master/orderManage";
}
@RequestMapping(value="/orderItemView", method=RequestMethod.GET)
public String orderItemView(int ordered_no, Model model) throws Exception{
logger.info("ordered_no"+ordered_no);
model.addAttribute("orderItemView", clientService.orderItemView(ordered_no));
model.addAttribute("orderItemInfo", clientService.orderItemInfo(ordered_no));
return "/master/orderItemView";
}
View
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
console.log("111111");
delivNumberAdd();
});
function delivNumberAdd() {
var optionIndex = 1;
$("#delivNumberAdd_btn")
.on(
"click",
function() {
console.log("dasda");
$("#delivNumber")
.append(
" <div class='form-group'><input placeholder='송장번호와 택배사' class='form-control' type='text' style='float:left;' name='ordered_delivnum' >"
+ "<button type='submit' class='btn btn-round btn-g'>"
+ "입력" + "</button></div>"
);
});
}
</script>
<!-- header 입니다 -->
<%@include file="../include/header.jsp"%>
<!-- header 입니다 -->
<main>
<div class="main">
<section class="module">
<%@include file="../include/masterSidebar.jsp"%>
<div class="col-sm-10 mb-sm-10" style="float: none; margin:0 auto;">
<h1 class="font-alt mb-0" align="center" style="margin-top: -20; margin-right:50px; padding-bottom: 52px;">주문관리</h1>
<div class="row" style="margin-left: 130px;">
<div class="col-sm-12">
<div class="col-sm-3 mb-20" >
<button class="btn btn-round btn-g" onclick="location.href='http://localhost/master/orderManage?delivstate=1'">물품준비중 <span style="font-size:15px;">(${orderState1})</span></button>
</div>
<div class="col-sm-3">
<button class="btn btn-round btn-g" onclick="location.href='http://localhost/master/orderManage?delivstate=2'">배송중<span style="font-size:15px;">(${orderState2})</span></button>
</div>
<div class="col-sm-3">
<button class="btn btn-round btn-g" onclick="location.href='http://localhost/master/orderManage?delivstate=4'">취소신청 <span style="font-size:15px;">(${orderState3})</span></button>
</div>
<div class="col-sm-1">
<button class="btn btn-round btn-g" onclick="location.href='http://localhost/master/orderManage?delivstate=5'">환불처리 </button>
</div>
<div class="col-sm-1">
<button class="btn btn-round btn-g" onclick="location.href='http://localhost/master/orderManage?delivstate=6'">교환처리</button>
</div>
<div class="col-sm-1">
<button class="btn btn-round btn-g" onclick="location.href='http://localhost/master/orderManage?delivstate=3'">배송완료</button>
</div>
<table class="table " style="text-align: center;;" >
<tbody>
<tr style="vertical-align : middle;" >
<th class="font-alt" style="text-align: center; vertical-align : middle; width:13%;" >주문일</th>
<th class="font-alt" style="text-align: center; vertical-align : middle; width:8%;">주문번호</th>
<th class="font-alt" style="text-align: center; vertical-align : middle; width:14%;">주문자</th>
<th class="font-alt" style="text-align: center; vertical-align : middle; width:8%;">총금액</th>
<th class="font-alt" class="hidden-xs" style="text-align: center; vertical-align : middle; width:13%;">결제금액</th>
<th class="font-alt" style="text-align: center; vertical-align : middle;; width:20%;">배송</th>
<th class="font-alt" style="text-align: center; vertical-align : middle;; width:14%;">취소</th>
</tr>
<c:forEach items="${orderList}" var="orderList">
<tr style="text-align: center; ">
<td style="vertical-align : middle;">
<fmt:formatDate pattern="yy-MM-dd" value="${orderList.ordered_date}"/>
</td>
<td class="hidden-xs" style="vertical-align : middle;">
<a href="http://localhost/master/orderItemView?ordered_no=${orderList.ordered_no}">${orderList.ordered_no}</a>
</td>
<td class="hidden-xs" style="vertical-align : middle;">
${orderList.ordered_to_name}
</td>
<td class="hidden-xs" style="vertical-align : middle;">
₩ <fmt:formatNumber pattern="###,###,###" value="${orderList.ordered_cartprice}"/>
</td>
<td class="hidden-xs" style="vertical-align : middle;">
₩ <fmt:formatNumber pattern="###,###,###" value="${orderList.ordered_orderprice}"/>
</td>
<td class="hidden-xs" style="vertical-align : middle; " >
<form action="/master/delivNumberInsert" method="post">
<input type="hidden" value="${orderList.ordered_no}" name="ordered_no" id="ordered_no">
<div id="delivNumber">
<c:if test="${orderList.ordered_delivstate == 1 and orderList.ordered_paystate == 1}">
물품준비중
<button class="btn btn-round btn-g" id="delivNumberAdd_btn" type="button">
송장번호입력
</button>
</c:if>
<c:if test="${orderList.ordered_delivstate == 2}">
배송중
</c:if>
<c:if test="${orderList.ordered_delivstate == 3}">
배송완료
</c:if>
</div>
</form>
</td>
<td class="hidden-xs" style="vertical-align : middle;">
<c:if test="${orderList.ordered_paystate == 1}">
정상주문
</c:if>
<c:if test="${orderList.ordered_paystate == 2}">
취소신청
<form action="/master/orderExchange" method="post">
<input type="hidden" value="${orderList.ordered_no}" name="ordered_no">
<button class="btn btn-round btn-g" type="submit">
교환처리
</button>
</form>
<form action="/master/orderCancel" method="post">
<input type="hidden" value="${orderList.ordered_no}" name="ordered_no">
<button class="btn btn-round btn-g" type="submit">
환불처리
</button>
</form>
</c:if>
<c:if test="${orderList.ordered_paystate == 3}">
환불
</c:if>
<c:if test="${orderList.ordered_paystate == 4}">
교환
</c:if>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<div class="row">
<div class="col-sm-12">
<div class="pagination font-alt">
<c:if test="${pageMaker.prev}">
<a href="/main/itemView${pageMaker.makeOrderQuery(pageMaker.startPage - 1)}"><i class="fa fa-angle-left"></i></a>
</c:if>
<c:forEach begin="${pageMaker.startPage}" end="${pageMaker.endPage}" var="idx">
<a class="active" href="/main/itemView${pageMaker.makeOrderQuery(idx)}">${idx}</a>
</c:forEach>
<c:if test="${pageMaker.next && pageMaker.endPage > 0}">
<a href="/main/itemView${pageMaker.makeOrderQuery(pageMaker.endPage + 1)}"><i class="fa fa-angle-right"></i></a>
</c:if>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</main>
<!-- footer 입니다 -->
<%@include file="../include/footer.jsp"%>
<!-- footer 입니다 -->
다음글은 상품목록과 비동기 검색 부분을 다뤄보겠다.
728x90
'SPRING > Homme Shop' 카테고리의 다른 글
[스프링] 쇼핑몰 - 비동기 검색 (0) | 2021.12.09 |
---|---|
[스프링] 쇼핑몰 - 상품목록과 페이징 (2) | 2021.12.09 |
[스프링] 쇼핑몰 - 주문목록 (0) | 2021.12.09 |
[스프링] 쇼핑몰 - 상품 주문 [ 2 ] (0) | 2021.12.09 |
[스프링] 쇼핑몰 - 상품 주문 [ 1 ] (0) | 2021.12.08 |