[Spring][쇼핑몰 프로젝트][41] 주문 구현(주문 페이지) - 1
https://kimvampa.tistory.com/272?category=771727
This commit is contained in:
21
VamPa/src/main/java/com/vam/controller/OrderController.java
Normal file
21
VamPa/src/main/java/com/vam/controller/OrderController.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.vam.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import com.vam.model.OrderPageDTO;
|
||||
|
||||
@Controller
|
||||
public class OrderController {
|
||||
|
||||
@GetMapping("/order/{memberId}")
|
||||
public void orderPgaeGET(@PathVariable("memberId") String memberId, OrderPageDTO opd, Model model) {
|
||||
|
||||
System.out.println("memberId : " + memberId);
|
||||
System.out.println("orders : " + opd.getOrders());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
23
VamPa/src/main/java/com/vam/model/OrderPageDTO.java
Normal file
23
VamPa/src/main/java/com/vam/model/OrderPageDTO.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OrderPageDTO {
|
||||
|
||||
private List<OrderPageItemDTO> orders;
|
||||
|
||||
public List<OrderPageItemDTO> getOrders() {
|
||||
return orders;
|
||||
}
|
||||
|
||||
public void setOrders(List<OrderPageItemDTO> orders) {
|
||||
this.orders = orders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderPageDTO [orders=" + orders + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
115
VamPa/src/main/java/com/vam/model/OrderPageItemDTO.java
Normal file
115
VamPa/src/main/java/com/vam/model/OrderPageItemDTO.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package com.vam.model;
|
||||
|
||||
public class OrderPageItemDTO {
|
||||
|
||||
/* 뷰로부터 전달받을 값 */
|
||||
private int bookId;
|
||||
|
||||
private int bookCount;
|
||||
|
||||
/* DB로부터 꺼내올 값 */
|
||||
private String bookName;
|
||||
|
||||
private int bookPrice;
|
||||
|
||||
private double bookDiscount;
|
||||
|
||||
/* 만들어 낼 값 */
|
||||
private int salePrice;
|
||||
|
||||
private int totalPrice;
|
||||
|
||||
private int point;
|
||||
|
||||
private int totalPoint;
|
||||
|
||||
public int getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
public void setBookId(int bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
public int getBookCount() {
|
||||
return bookCount;
|
||||
}
|
||||
|
||||
public void setBookCount(int bookCount) {
|
||||
this.bookCount = bookCount;
|
||||
}
|
||||
|
||||
public String getBookName() {
|
||||
return bookName;
|
||||
}
|
||||
|
||||
public void setBookName(String bookName) {
|
||||
this.bookName = bookName;
|
||||
}
|
||||
|
||||
public int getBookPrice() {
|
||||
return bookPrice;
|
||||
}
|
||||
|
||||
public void setBookPrice(int bookPrice) {
|
||||
this.bookPrice = bookPrice;
|
||||
}
|
||||
|
||||
public double getBookDiscount() {
|
||||
return bookDiscount;
|
||||
}
|
||||
|
||||
public void setBookDiscount(double bookDiscount) {
|
||||
this.bookDiscount = bookDiscount;
|
||||
}
|
||||
|
||||
public int getSalePrice() {
|
||||
return salePrice;
|
||||
}
|
||||
|
||||
public void setSalePrice(int salePrice) {
|
||||
this.salePrice = salePrice;
|
||||
}
|
||||
|
||||
public int getTotalPrice() {
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
public void setTotalPrice(int totalPrice) {
|
||||
this.totalPrice = totalPrice;
|
||||
}
|
||||
|
||||
public int getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
public void setPoint(int point) {
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
public int getTotalPoint() {
|
||||
return totalPoint;
|
||||
}
|
||||
|
||||
public void setTotalPoint(int totalPoint) {
|
||||
this.totalPoint = totalPoint;
|
||||
}
|
||||
|
||||
public void initSaleTotal() {
|
||||
this.salePrice = (int) (this.bookPrice * (1-this.bookDiscount));
|
||||
this.totalPrice = this.salePrice*this.bookCount;
|
||||
this.point = (int)(Math.floor(this.salePrice*0.05));
|
||||
this.totalPoint =this.point * this.bookCount;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderPageItemDTO [bookId=" + bookId + ", bookCount=" + bookCount + ", bookName=" + bookName
|
||||
+ ", bookPrice=" + bookPrice + ", bookDiscount=" + bookDiscount + ", salePrice=" + salePrice
|
||||
+ ", totalPrice=" + totalPrice + ", point=" + point + ", totalPoint=" + totalPoint + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -128,6 +128,7 @@
|
||||
<input type="hidden" class="individual_totalPrice_input" value="${ci.salePrice * ci.bookCount}">
|
||||
<input type="hidden" class="individual_point_input" value="${ci.point}">
|
||||
<input type="hidden" class="individual_totalPoint_input" value="${ci.totalPoint}">
|
||||
<input type="hidden" class="individual_bookId_input" value="${ci.bookId}">
|
||||
</td>
|
||||
<td class="td_width_2">
|
||||
<div class="image_wrap" data-bookid="${ci.imageList[0].bookId}" data-path="${ci.imageList[0].uploadPath}" data-uuid="${ci.imageList[0].uuid}" data-filename="${ci.imageList[0].fileName}">
|
||||
@@ -234,7 +235,7 @@
|
||||
</div>
|
||||
<!-- 구매 버튼 영역 -->
|
||||
<div class="content_btn_section">
|
||||
<a>주문하기</a>
|
||||
<a class="order_btn">주문하기</a>
|
||||
</div>
|
||||
|
||||
<!-- 수량 조정 form -->
|
||||
@@ -249,6 +250,11 @@
|
||||
<input type="hidden" name="cartId" class="delete_cartId">
|
||||
<input type="hidden" name="memberId" value="${member.memberId}">
|
||||
</form>
|
||||
<!-- 주문 form -->
|
||||
<form action="/order/${member.memberId}" method="get" class="order_form">
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -428,6 +434,35 @@ $(".delete_btn").on("click", function(e){
|
||||
$(".quantity_delete_form").submit();
|
||||
});
|
||||
|
||||
/* 주문 페이지 이동 */
|
||||
$(".order_btn").on("click", function(){
|
||||
|
||||
let form_contents ='';
|
||||
let orderNumber = 0;
|
||||
|
||||
$(".cart_info_td").each(function(index, element){
|
||||
|
||||
if($(element).find(".individual_cart_checkbox").is(":checked") === true){ //체크여부
|
||||
|
||||
let bookId = $(element).find(".individual_bookId_input").val();
|
||||
let bookCount = $(element).find(".individual_bookCount_input").val();
|
||||
|
||||
let bookId_input = "<input name='orders[" + orderNumber + "].bookId' type='hidden' value='" + bookId + "'>";
|
||||
form_contents += bookId_input;
|
||||
|
||||
let bookCount_input = "<input name='orders[" + orderNumber + "].bookCount' type='hidden' value='" + bookCount + "'>";
|
||||
form_contents += bookCount_input;
|
||||
|
||||
orderNumber += 1;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$(".order_form").html(form_contents);
|
||||
$(".order_form").submit();
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -162,7 +162,11 @@
|
||||
<div class="content_bottom">
|
||||
리뷰
|
||||
</div>
|
||||
|
||||
<!-- 주문 form -->
|
||||
<form action="/order/${member.memberId}" method="get" class="order_form">
|
||||
<input type="hidden" name="orders[0].bookId" value="${goodsInfo.bookId}">
|
||||
<input type="hidden" name="orders[0].bookCount" value="">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Footer 영역 -->
|
||||
@@ -285,7 +289,12 @@ const form = {
|
||||
alert("로그인이 필요합니다.");
|
||||
}
|
||||
}
|
||||
|
||||
/* 바로구매 버튼 */
|
||||
$(".btn_buy").on("click", function(){
|
||||
let bookCount = $(".quantity_input").val();
|
||||
$(".order_form").find("input[name='orders[0].bookCount']").val(bookCount);
|
||||
$(".order_form").submit();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Mon Nov 29 11:24:17 KST 2021
|
||||
#Wed Dec 08 02:51:47 KST 2021
|
||||
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa
|
||||
m2e.projectName=VamPa
|
||||
groupId=com.vam
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.vam.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import com.vam.model.OrderPageDTO;
|
||||
|
||||
@Controller
|
||||
public class OrderController {
|
||||
|
||||
@GetMapping("/order/{memberId}")
|
||||
public void orderPgaeGET(@PathVariable("memberId") String memberId, OrderPageDTO opd, Model model) {
|
||||
|
||||
System.out.println("memberId : " + memberId);
|
||||
System.out.println("orders : " + opd.getOrders());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
22
VamPa_MySQL/src/main/java/com/vam/model/OrderPageDTO.java
Normal file
22
VamPa_MySQL/src/main/java/com/vam/model/OrderPageDTO.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OrderPageDTO {
|
||||
|
||||
private List<OrderPageItemDTO> orders;
|
||||
|
||||
public List<OrderPageItemDTO> getOrders() {
|
||||
return orders;
|
||||
}
|
||||
|
||||
public void setOrders(List<OrderPageItemDTO> orders) {
|
||||
this.orders = orders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderPageDTO [orders=" + orders + "]";
|
||||
}
|
||||
|
||||
}
|
||||
113
VamPa_MySQL/src/main/java/com/vam/model/OrderPageItemDTO.java
Normal file
113
VamPa_MySQL/src/main/java/com/vam/model/OrderPageItemDTO.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.vam.model;
|
||||
|
||||
public class OrderPageItemDTO {
|
||||
|
||||
/* 뷰로부터 전달받을 값 */
|
||||
private int bookId;
|
||||
|
||||
private int bookCount;
|
||||
|
||||
/* DB로부터 꺼내올 값 */
|
||||
private String bookName;
|
||||
|
||||
private int bookPrice;
|
||||
|
||||
private double bookDiscount;
|
||||
|
||||
/* 만들어 낼 값 */
|
||||
private int salePrice;
|
||||
|
||||
private int totalPrice;
|
||||
|
||||
private int point;
|
||||
|
||||
private int totalPoint;
|
||||
|
||||
public int getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
public void setBookId(int bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
public int getBookCount() {
|
||||
return bookCount;
|
||||
}
|
||||
|
||||
public void setBookCount(int bookCount) {
|
||||
this.bookCount = bookCount;
|
||||
}
|
||||
|
||||
public String getBookName() {
|
||||
return bookName;
|
||||
}
|
||||
|
||||
public void setBookName(String bookName) {
|
||||
this.bookName = bookName;
|
||||
}
|
||||
|
||||
public int getBookPrice() {
|
||||
return bookPrice;
|
||||
}
|
||||
|
||||
public void setBookPrice(int bookPrice) {
|
||||
this.bookPrice = bookPrice;
|
||||
}
|
||||
|
||||
public double getBookDiscount() {
|
||||
return bookDiscount;
|
||||
}
|
||||
|
||||
public void setBookDiscount(double bookDiscount) {
|
||||
this.bookDiscount = bookDiscount;
|
||||
}
|
||||
|
||||
public int getSalePrice() {
|
||||
return salePrice;
|
||||
}
|
||||
|
||||
public void setSalePrice(int salePrice) {
|
||||
this.salePrice = salePrice;
|
||||
}
|
||||
|
||||
public int getTotalPrice() {
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
public void setTotalPrice(int totalPrice) {
|
||||
this.totalPrice = totalPrice;
|
||||
}
|
||||
|
||||
public int getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
public void setPoint(int point) {
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
public int getTotalPoint() {
|
||||
return totalPoint;
|
||||
}
|
||||
|
||||
public void setTotalPoint(int totalPoint) {
|
||||
this.totalPoint = totalPoint;
|
||||
}
|
||||
|
||||
public void initSaleTotal() {
|
||||
this.salePrice = (int) (this.bookPrice * (1-this.bookDiscount));
|
||||
this.totalPrice = this.salePrice*this.bookCount;
|
||||
this.point = (int)(Math.floor(this.salePrice*0.05));
|
||||
this.totalPoint =this.point * this.bookCount;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderPageItemDTO [bookId=" + bookId + ", bookCount=" + bookCount + ", bookName=" + bookName
|
||||
+ ", bookPrice=" + bookPrice + ", bookDiscount=" + bookDiscount + ", salePrice=" + salePrice
|
||||
+ ", totalPrice=" + totalPrice + ", point=" + point + ", totalPoint=" + totalPoint + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -128,6 +128,7 @@
|
||||
<input type="hidden" class="individual_totalPrice_input" value="${ci.salePrice * ci.bookCount}">
|
||||
<input type="hidden" class="individual_point_input" value="${ci.point}">
|
||||
<input type="hidden" class="individual_totalPoint_input" value="${ci.totalPoint}">
|
||||
<input type="hidden" class="individual_bookId_input" value="${ci.bookId}">
|
||||
</td>
|
||||
<td class="td_width_2">
|
||||
<div class="image_wrap" data-bookid="${ci.imageList[0].bookId}" data-path="${ci.imageList[0].uploadPath}" data-uuid="${ci.imageList[0].uuid}" data-filename="${ci.imageList[0].fileName}">
|
||||
@@ -234,7 +235,7 @@
|
||||
</div>
|
||||
<!-- 구매 버튼 영역 -->
|
||||
<div class="content_btn_section">
|
||||
<a>주문하기</a>
|
||||
<a class="order_btn">주문하기</a>
|
||||
</div>
|
||||
|
||||
<!-- 수량 조정 form -->
|
||||
@@ -249,6 +250,11 @@
|
||||
<input type="hidden" name="cartId" class="delete_cartId">
|
||||
<input type="hidden" name="memberId" value="${member.memberId}">
|
||||
</form>
|
||||
<!-- 주문 form -->
|
||||
<form action="/order/${member.memberId}" method="get" class="order_form">
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -428,6 +434,35 @@ $(".delete_btn").on("click", function(e){
|
||||
$(".quantity_delete_form").submit();
|
||||
});
|
||||
|
||||
/* 주문 페이지 이동 */
|
||||
$(".order_btn").on("click", function(){
|
||||
|
||||
let form_contents ='';
|
||||
let orderNumber = 0;
|
||||
|
||||
$(".cart_info_td").each(function(index, element){
|
||||
|
||||
if($(element).find(".individual_cart_checkbox").is(":checked") === true){ //체크여부
|
||||
|
||||
let bookId = $(element).find(".individual_bookId_input").val();
|
||||
let bookCount = $(element).find(".individual_bookCount_input").val();
|
||||
|
||||
let bookId_input = "<input name='orders[" + orderNumber + "].bookId' type='hidden' value='" + bookId + "'>";
|
||||
form_contents += bookId_input;
|
||||
|
||||
let bookCount_input = "<input name='orders[" + orderNumber + "].bookCount' type='hidden' value='" + bookCount + "'>";
|
||||
form_contents += bookCount_input;
|
||||
|
||||
orderNumber += 1;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$(".order_form").html(form_contents);
|
||||
$(".order_form").submit();
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -123,7 +123,11 @@
|
||||
<div class="discount_price">
|
||||
판매가 : <span class="discount_price_number"><fmt:formatNumber value="${goodsInfo.bookPrice - (goodsInfo.bookPrice*goodsInfo.bookDiscount)}" pattern="#,### 원" /></span>
|
||||
[<fmt:formatNumber value="${goodsInfo.bookDiscount*100}" pattern="###" />%
|
||||
<fmt:formatNumber value="${goodsInfo.bookPrice*goodsInfo.bookDiscount}" pattern="#,### 원" /> 할인]</div>
|
||||
<fmt:formatNumber value="${goodsInfo.bookPrice*goodsInfo.bookDiscount}" pattern="#,### 원" /> 할인]
|
||||
</div>
|
||||
<div>
|
||||
적립 포인트 : <span class="point_span"></span>원
|
||||
</div>
|
||||
</div>
|
||||
<div class="line">
|
||||
</div>
|
||||
@@ -158,7 +162,11 @@
|
||||
<div class="content_bottom">
|
||||
리뷰
|
||||
</div>
|
||||
|
||||
<!-- 주문 form -->
|
||||
<form action="/order/${member.memberId}" method="get" class="order_form">
|
||||
<input type="hidden" name="orders[0].bookId" value="${goodsInfo.bookId}">
|
||||
<input type="hidden" name="orders[0].bookCount" value="">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Footer 영역 -->
|
||||
@@ -231,7 +239,13 @@ $(document).ready(function(){
|
||||
|
||||
$(".publeyear").html(publeYear);
|
||||
|
||||
});
|
||||
/* 포인트 삽입 */
|
||||
let salePrice = "${goodsInfo.bookPrice - (goodsInfo.bookPrice*goodsInfo.bookDiscount)}"
|
||||
let point = salePrice*0.05;
|
||||
point = Math.floor(point);
|
||||
$(".point_span").text(point);
|
||||
|
||||
}); //$(document).ready(function(){
|
||||
|
||||
|
||||
// 수량 버튼 조작
|
||||
@@ -275,7 +289,12 @@ const form = {
|
||||
alert("로그인이 필요합니다.");
|
||||
}
|
||||
}
|
||||
|
||||
/* 바로구매 버튼 */
|
||||
$(".btn_buy").on("click", function(){
|
||||
let bookCount = $(".quantity_input").val();
|
||||
$(".order_form").find("input[name='orders[0].bookCount']").val(bookCount);
|
||||
$(".order_form").submit();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Mon Nov 29 11:24:18 KST 2021
|
||||
#Wed Dec 08 23:55:17 KST 2021
|
||||
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa_MySQL
|
||||
m2e.projectName=VamPa_MySQL
|
||||
groupId=com.vam
|
||||
|
||||
Reference in New Issue
Block a user