latest
This commit is contained in:
93
bookstore-api/.idea/workspace.xml
generated
93
bookstore-api/.idea/workspace.xml
generated
@@ -19,8 +19,8 @@
|
||||
<file leaf-file-name="CheckoutResource.java" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/CheckoutResource.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="333">
|
||||
<caret line="56" column="60" lean-forward="false" selection-start-line="56" selection-start-column="60" selection-end-line="56" selection-end-column="60" />
|
||||
<state relative-caret-position="303">
|
||||
<caret line="89" column="0" lean-forward="true" selection-start-line="89" selection-start-column="0" selection-end-line="89" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@@ -28,6 +28,36 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="Order.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/domain/Order.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="321">
|
||||
<caret line="149" column="17" lean-forward="true" selection-start-line="149" selection-start-column="17" selection-end-line="149" selection-end-column="17" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="CartItem.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/domain/CartItem.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-162">
|
||||
<caret line="38" column="15" lean-forward="false" selection-start-line="38" selection-start-column="15" selection-end-line="38" selection-end-column="15" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="OrderServiceImpl.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/service/impl/OrderServiceImpl.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="533">
|
||||
<caret line="81" column="24" lean-forward="false" selection-start-line="81" selection-start-column="17" selection-end-line="81" selection-end-column="24" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="Payment.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/domain/Payment.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
@@ -122,12 +152,12 @@
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/Book.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/CartResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/BookResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/CartItem.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShoppingCartResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/Order.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShippingResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/PaymentResource.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/resources/templates/orderConfirmationEmailTemplate.html" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/CartItem.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/domain/Order.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/bookstore/resource/CheckoutResource.java" />
|
||||
</list>
|
||||
</option>
|
||||
@@ -954,12 +984,12 @@
|
||||
<workItem from="1488378219247" duration="650000" />
|
||||
<workItem from="1488461561430" duration="18419000" />
|
||||
<workItem from="1488731165185" duration="30270000" />
|
||||
<workItem from="1489159532831" duration="8291000" />
|
||||
<workItem from="1489159532831" duration="11257000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="100573000" />
|
||||
<option name="totallyTimeSpent" value="103539000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="72" y="23" width="1280" height="797" extended-state="0" />
|
||||
@@ -1015,13 +1045,6 @@
|
||||
<option name="FILTER_TARGETS" value="false" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/service/impl/OrderServiceImpl.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="193">
|
||||
<caret line="43" column="27" lean-forward="false" selection-start-line="43" selection-start-column="27" selection-end-line="43" selection-end-column="27" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/utility/USConstants.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
@@ -1377,14 +1400,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/domain/CartItem.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="420">
|
||||
<caret line="33" column="15" lean-forward="false" selection-start-line="33" selection-start-column="15" selection-end-line="33" selection-end-column="15" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/ShippingResource.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="143">
|
||||
@@ -1437,14 +1452,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/domain/Order.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="45">
|
||||
<caret line="34" column="0" lean-forward="true" selection-start-line="34" selection-start-column="0" selection-end-line="34" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/resources/templates/orderConfirmationEmailTemplate.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1890">
|
||||
@@ -1477,10 +1484,34 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/service/impl/OrderServiceImpl.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="533">
|
||||
<caret line="81" column="24" lean-forward="false" selection-start-line="81" selection-start-column="17" selection-end-line="81" selection-end-column="24" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/domain/CartItem.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-162">
|
||||
<caret line="38" column="15" lean-forward="false" selection-start-line="38" selection-start-column="15" selection-end-line="38" selection-end-column="15" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/domain/Order.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="321">
|
||||
<caret line="149" column="17" lean-forward="true" selection-start-line="149" selection-start-column="17" selection-end-line="149" selection-end-column="17" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/bookstore/resource/CheckoutResource.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="333">
|
||||
<caret line="56" column="60" lean-forward="false" selection-start-line="56" selection-start-column="60" selection-end-line="56" selection-end-column="60" />
|
||||
<state relative-caret-position="303">
|
||||
<caret line="89" column="0" lean-forward="true" selection-start-line="89" selection-start-column="0" selection-end-line="89" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
||||
@@ -36,6 +36,7 @@ public class CartItem implements Serializable {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "order_id")
|
||||
@JsonIgnore
|
||||
private Order order;
|
||||
|
||||
public Long getId() {
|
||||
|
||||
@@ -31,12 +31,15 @@ public class Order implements Serializable {
|
||||
private List<CartItem> cartItemList;
|
||||
|
||||
@OneToOne(cascade=CascadeType.ALL)
|
||||
@JsonIgnore
|
||||
private ShippingAddress shippingAddress;
|
||||
|
||||
@OneToOne(cascade=CascadeType.ALL)
|
||||
@JsonIgnore
|
||||
private BillingAddress billingAddress;
|
||||
|
||||
@OneToOne(cascade=CascadeType.ALL)
|
||||
@JsonIgnore
|
||||
private Payment payment;
|
||||
|
||||
@ManyToOne
|
||||
@@ -130,4 +133,21 @@ public class Order implements Serializable {
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Order{" +
|
||||
"id=" + id +
|
||||
", orderDate=" + orderDate +
|
||||
", shippingDate=" + shippingDate +
|
||||
", shippingMethod='" + shippingMethod + '\'' +
|
||||
", orderStatus='" + orderStatus + '\'' +
|
||||
", orderTotal=" + orderTotal +
|
||||
", cartItemList=" + cartItemList +
|
||||
", shippingAddress=" + shippingAddress +
|
||||
", billingAddress=" + billingAddress +
|
||||
", payment=" + payment +
|
||||
", user=" + user +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.security.Principal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created by z00382545 on 3/10/17.
|
||||
@@ -24,6 +25,8 @@ import java.util.*;
|
||||
@RequestMapping("/checkout")
|
||||
public class CheckoutResource {
|
||||
|
||||
private Order order = new Order();
|
||||
|
||||
@Autowired
|
||||
private JavaMailSender mailSender;
|
||||
|
||||
@@ -43,7 +46,7 @@ public class CheckoutResource {
|
||||
private MailConstructor mailConstructor;
|
||||
|
||||
@RequestMapping(value = "/checkout", method = RequestMethod.POST)
|
||||
public ResponseEntity checkoutPost(
|
||||
public Order checkoutPost(
|
||||
@RequestBody HashMap<String, Object> mapper,
|
||||
Principal principal
|
||||
) {
|
||||
@@ -78,7 +81,11 @@ public class CheckoutResource {
|
||||
estimatedDeliveryDate = today.plusDays(3);
|
||||
}
|
||||
|
||||
return new ResponseEntity("Order Checkout Successful!", HttpStatus.OK);
|
||||
this.order = order;
|
||||
|
||||
return order;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {AppConst} from '../../constants/app-const';
|
||||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||
import {Params, ActivatedRoute,Router} from "@angular/router";
|
||||
import { AppConst } from '../../constants/app-const';
|
||||
import { CheckoutService } from '../../services/checkout.service';
|
||||
import { Order } from '../../models/order';
|
||||
import { CartItem } from '../../models/cart-item';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -9,10 +13,39 @@ import {AppConst} from '../../constants/app-const';
|
||||
})
|
||||
export class OrderSummaryComponent implements OnInit {
|
||||
private serverPath = AppConst.serverPath;
|
||||
private order:Order = new Order();
|
||||
private estimatedDeliveryDate:string;
|
||||
private cartItemList:CartItem[] = [];
|
||||
|
||||
constructor() { }
|
||||
constructor(
|
||||
private checkoutService:CheckoutService,
|
||||
private route: ActivatedRoute,
|
||||
private router:Router
|
||||
) {
|
||||
this.route.queryParams.subscribe(params => {
|
||||
|
||||
this.order = JSON.parse(params['order']);
|
||||
|
||||
let deliveryDate = new Date();
|
||||
|
||||
if (this.order.shippingMethod=="groundShipping") {
|
||||
deliveryDate.setDate(deliveryDate.getDate()+5);
|
||||
} else {
|
||||
deliveryDate.setDate(deliveryDate.getDate()+3);
|
||||
}
|
||||
|
||||
let days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
|
||||
|
||||
this.estimatedDeliveryDate = days[deliveryDate.getDay()]+', '+deliveryDate.getFullYear()+'/'+deliveryDate.getMonth()+'/'+deliveryDate.getDate();
|
||||
|
||||
this.cartItemList = this.order.cartItemList;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {AppConst} from '../../constants/app-const';
|
||||
import {Book} from '../../models/book';
|
||||
import {Router} from "@angular/router";
|
||||
import {Router, NavigationExtras} from "@angular/router";
|
||||
import {CartService} from '../../services/cart.service';
|
||||
import {ShippingService} from '../../services/shipping.service';
|
||||
import {PaymentService} from '../../services/payment.service';
|
||||
@@ -14,7 +14,7 @@ import {UserPayment} from '../../models/user-payment';
|
||||
import {UserBilling} from '../../models/user-billing';
|
||||
import {UserShipping} from '../../models/user-shipping';
|
||||
import {Payment} from '../../models/payment';
|
||||
|
||||
import {Order} from '../../models/order';
|
||||
|
||||
@Component({
|
||||
selector: 'app-order',
|
||||
@@ -41,6 +41,7 @@ export class OrderComponent implements OnInit {
|
||||
private emptyPaymentList: boolean = true;
|
||||
private stateList: string[] = [];
|
||||
private shippingMethod:string;
|
||||
private order:Order = new Order();
|
||||
|
||||
constructor(
|
||||
private router:Router,
|
||||
@@ -69,13 +70,13 @@ export class OrderComponent implements OnInit {
|
||||
|
||||
getCartItemList(){
|
||||
this.cartService.getCartItemList().subscribe(
|
||||
res=>{
|
||||
this.cartItemList = res.json();
|
||||
this.cartItemNumber = this.cartItemList.length;
|
||||
},
|
||||
error=>{
|
||||
console.log(error.text());
|
||||
}
|
||||
res=>{
|
||||
this.cartItemList = res.json();
|
||||
this.cartItemNumber = this.cartItemList.length;
|
||||
},
|
||||
error=>{
|
||||
console.log(error.text());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -110,58 +111,65 @@ export class OrderComponent implements OnInit {
|
||||
console.log("same as shipping")
|
||||
|
||||
if(checked) {
|
||||
this.billingAddress.billingAddressName = this.shippingAddress.shippingAddressName;
|
||||
this.billingAddress.billingAddressStreet1 = this.shippingAddress.shippingAddressStreet1;
|
||||
this.billingAddress.billingAddressStreet2 = this.shippingAddress.shippingAddressStreet2;
|
||||
this.billingAddress.billingAddressCity = this.shippingAddress.shippingAddressCity;
|
||||
this.billingAddress.billingAddressState = this.shippingAddress.shippingAddressState;
|
||||
this.billingAddress.billingAddressCountry = this.shippingAddress.shippingAddressCountry;
|
||||
this.billingAddress.billingAddressZipcode = this.shippingAddress.shippingAddressZipcode;
|
||||
} else {
|
||||
this.billingAddress.billingAddressName = "";
|
||||
this.billingAddress.billingAddressStreet1 = "";
|
||||
this.billingAddress.billingAddressStreet2 = "";
|
||||
this.billingAddress.billingAddressCity = "";
|
||||
this.billingAddress.billingAddressState = "";
|
||||
this.billingAddress.billingAddressCountry = "";
|
||||
this.billingAddress.billingAddressZipcode = "";
|
||||
}
|
||||
this.billingAddress.billingAddressName = this.shippingAddress.shippingAddressName;
|
||||
this.billingAddress.billingAddressStreet1 = this.shippingAddress.shippingAddressStreet1;
|
||||
this.billingAddress.billingAddressStreet2 = this.shippingAddress.shippingAddressStreet2;
|
||||
this.billingAddress.billingAddressCity = this.shippingAddress.shippingAddressCity;
|
||||
this.billingAddress.billingAddressState = this.shippingAddress.shippingAddressState;
|
||||
this.billingAddress.billingAddressCountry = this.shippingAddress.shippingAddressCountry;
|
||||
this.billingAddress.billingAddressZipcode = this.shippingAddress.shippingAddressZipcode;
|
||||
} else {
|
||||
this.billingAddress.billingAddressName = "";
|
||||
this.billingAddress.billingAddressStreet1 = "";
|
||||
this.billingAddress.billingAddressStreet2 = "";
|
||||
this.billingAddress.billingAddressCity = "";
|
||||
this.billingAddress.billingAddressState = "";
|
||||
this.billingAddress.billingAddressCountry = "";
|
||||
this.billingAddress.billingAddressZipcode = "";
|
||||
}
|
||||
}
|
||||
|
||||
onSubmit(){
|
||||
this.checkoutService.checkout(
|
||||
this.shippingAddress,
|
||||
this.billingAddress,
|
||||
this.payment,
|
||||
this.shippingMethod
|
||||
).subscribe(
|
||||
this.shippingAddress,
|
||||
this.billingAddress,
|
||||
this.payment,
|
||||
this.shippingMethod
|
||||
).subscribe(
|
||||
res=>{
|
||||
console.log(res.text());
|
||||
},
|
||||
error=>{
|
||||
console.log(error.text());
|
||||
}
|
||||
);
|
||||
this.order=res.json();
|
||||
console.log(this.order);
|
||||
|
||||
this.router.navigate(['/orderSummary']);
|
||||
}
|
||||
let navigationExtras: NavigationExtras = {
|
||||
queryParams: {
|
||||
"order": JSON.stringify(this.order)
|
||||
}
|
||||
};
|
||||
|
||||
ngOnInit() {
|
||||
this.getCartItemList();
|
||||
|
||||
this.router.navigate(['/orderSummary'], navigationExtras);
|
||||
},
|
||||
error=>{
|
||||
console.log(error.text());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.cartService.getShoppingCart().subscribe(
|
||||
res=>{
|
||||
ngOnInit() {
|
||||
this.getCartItemList();
|
||||
|
||||
|
||||
this.cartService.getShoppingCart().subscribe(
|
||||
res=>{
|
||||
console.log(res.json());
|
||||
this.shoppingCart=res.json();
|
||||
},
|
||||
error=>{
|
||||
console.log(error.text());
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
this.shippingService.getUserShippingList().subscribe(
|
||||
res=>{
|
||||
this.shippingService.getUserShippingList().subscribe(
|
||||
res=>{
|
||||
console.log(res.json());
|
||||
this.userShippingList=res.json();
|
||||
this.emptyShippingList = false;
|
||||
@@ -169,10 +177,10 @@ export class OrderComponent implements OnInit {
|
||||
error=>{
|
||||
console.log(error.text());
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
this.paymentService.getUserPaymentList().subscribe(
|
||||
res=>{
|
||||
this.paymentService.getUserPaymentList().subscribe(
|
||||
res=>{
|
||||
console.log(res.json());
|
||||
this.userPaymentList=res.json();
|
||||
this.emptyPaymentList = false;
|
||||
@@ -180,20 +188,20 @@ export class OrderComponent implements OnInit {
|
||||
error=>{
|
||||
console.log(error.text());
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
for (let s in AppConst.usStates) {
|
||||
this.stateList.push(s);
|
||||
for (let s in AppConst.usStates) {
|
||||
this.stateList.push(s);
|
||||
}
|
||||
|
||||
this.payment.type="";
|
||||
this.payment.expiryMonth="";
|
||||
this.payment.expiryYear="";
|
||||
this.billingAddress.billingAddressState="";
|
||||
this.shippingAddress.shippingAddressState="";
|
||||
this.shippingMethod="groundShipping";
|
||||
}
|
||||
|
||||
this.payment.type="";
|
||||
this.payment.expiryMonth="";
|
||||
this.payment.expiryYear="";
|
||||
this.billingAddress.billingAddressState="";
|
||||
this.shippingAddress.shippingAddressState="";
|
||||
this.shippingMethod="groundShipping";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import {CartItem} from "./cart-item";
|
||||
|
||||
export class Order {
|
||||
public id:number;
|
||||
public orderDate: string;
|
||||
@@ -5,4 +7,5 @@ export class Order {
|
||||
public shippingMethod: string;
|
||||
public orderStatus: string;
|
||||
public orderTotal: number;
|
||||
public cartItemList: CartItem[];
|
||||
}
|
||||
|
||||
@@ -29,4 +29,13 @@ export class CheckoutService {
|
||||
return this.http.post(url, order, {headers : tokenHeader});
|
||||
}
|
||||
|
||||
getUserOrder() {
|
||||
let url = AppConst.serverPath+"/checkout/getUserOrder";
|
||||
|
||||
let tokenHeader = new Headers ({
|
||||
'x-auth-token' : localStorage.getItem("xAuthToken")
|
||||
});
|
||||
return this.http.get(url, {headers : tokenHeader});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user