Commit b5407092 authored by pborate's avatar pborate

Updated ecm-checkout.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@175957 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f363a9ee
......@@ -403,6 +403,12 @@ md-card {
font-size: 10px;
}
.discount-rate {
color: green;
padding-left: 5px;
font-weight: 700;
}
.individual-price {
display: block;
font-size: 12px;
......
......@@ -197,6 +197,7 @@
</div>
<div class="large-6 columns ecm-item-info">
<span style="display: block;font-size: 16px;"> {{item.itemHeader.itemDescr}} </span>
<span style="display: block;font-size: 16px;"> {{item.itemHeader.itemShDescr}} </span>
<div *ngIf="item.itemCategory.catCode == 'CAT0000004'" class="delivery-offers">
<span>FREE Delivery in 5 to 6 days</span>
<button type="button" class="md-button link_button">
......@@ -208,10 +209,9 @@
<counter [quantity]="item.itemQuantity" (decrement)="decrement(item);" (increment)="increment(item);">
<price>
<div *ngIf="item.itemCategory.catCode == 'CAT0000004'" class="product-price">
<span style="display: block;" class="total-cost">Rs {{item.itemHeader.itemDiscountedRate}}</span>
<span class="discounted-price"><s>Rs {{item.itemHeader.itemCostRate}}</s> <span class="discount-rate">{{item.itemHeader.itemDiscount}}% Off</span></span>
</div>
<span *ngIf="item == 'occassion'" class="individual-price">Rs 500 per person (Inclusive GST)</span>
</price>
</counter>
......
......@@ -36,15 +36,15 @@ import { EcmCartService } from '../ecm-cart/ecm-cart.service';
@Component( {
selector: 'ecm-checkout',
templateUrl: './ecm-checkout.component.html',
styleUrls: ['./ecm-checkout.component.css'],
providers:[EcmCheckoutService]
styleUrls: ['./ecm-checkout.component.css']
})
export class EcmCheckoutComponent implements OnInit ,DoCheck {
dataSource = '/ibase/ecm/service/customers/'
@ViewChild('userForm') currentForm: NgForm;
@Input() unAuthorized: boolean = false;
maxDate = new Date(); //date upadted
checked = false;
totalPrice:number = 0;
cartItems;
......@@ -54,6 +54,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
orderReviewed;
selectedAddressOpt;
ecmType; //chitra
order;
@ViewChild( 'cardScreen' ) child: CardScreenComponent;
@ViewChild('addrAddScreen') addScreen: AddressScreenComponent;
......@@ -82,7 +83,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
customerInformation;
constructor(private formBuilder: FormBuilder, private store: Store<AppState>,public checkoutService: EcmCheckoutService,private _location: Location, private cartActions: CartActions, public breadcrumbSerivce: Breadcrumbs, private cardActions: SavedCardAction, private profileActions: ProfileActions, private addressActions: AdressAction, public snackBar: MdSnackBar, private _formBuilder: FormBuilder) {
constructor(private formBuilder: FormBuilder, private store: Store<AppState>,public checkoutService: EcmCheckoutService,private _location: Location, private cartAction: CartActions, public breadcrumbSerivce: Breadcrumbs, private cardActions: SavedCardAction, private profileActions: ProfileActions, private addressActions: AdressAction, public snackBar: MdSnackBar, private _formBuilder: FormBuilder) {
this.store.dispatch(this.profileActions.loadProfile());
this.store.dispatch(this.addressActions.loadAddress());
this.store.dispatch(this.cardActions.loadSavedCards());
......@@ -100,9 +101,9 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
this.store.dispatch(this.cardActions.loadSavedCards());
window.scrollTo(0,0);
this.createUserData();
this.getCartItems();
if(this.checkoutService.getItem()){
console.log('checkout service get item:::::',this.checkoutService.getItem());
this.cartItems = [];
this.cartItems.push(this.checkoutService.getItem());
this.checkoutService.reset();
......@@ -114,6 +115,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
);
}else {
console.log(':::::::::::::::GET');
this.getCartItems();
}
......@@ -180,12 +182,15 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
}
getCartItems() {
console.log('Inside getCartItems ');
this.store.select('cartItems').subscribe( cartItems => {
this.totalPrice = 0;
this.cartItems = cartItems;
this.cartItems.forEach(
item => {
console.log('Inside getCartItems ',item);
this.totalPrice = this.totalPrice + (parseFloat( item.itemHeader.itemDiscountedRate ) * item.itemQuantity);
console.log('Inside getCartItems totalPrice ',this.totalPrice);
}
);
});
......@@ -193,7 +198,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
executePayment() {
let paymentInfo;
console.log('executePayment customerInformation',this.customerInformation);
switch(this.selectedPaymntOpt)
{
case 'newcard':
......@@ -217,12 +222,15 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
paymentInfo = { "paymentOption":'card', "cardDetails": this.cardList.find(x => x.lineNo === this.selectedPaymntOpt)};
break;
}
if(this.ecmType=='1') {
this.order = { "token_id": this.userData.TOKEN_ID, "billAddress": this.selectedAddress,"paymentInfo": paymentInfo, "ecm_type":this.ecmType};
}
else {
this.order = { "token_id": this.userData.TOKEN_ID,"saleAddress":this.customerInformation , "paymentInfo": paymentInfo, "ecm_type":this.ecmType};
}
console.log('-----order-----',this.order);
let order = { "token_id": this.userData.TOKEN_ID, "billAddress": this.selectedAddress, "orderedItems":this.cartItems, "paymentInfo": paymentInfo};
console.log('-----order-----',order);
this.placeOrder(order);
this.placeOrder(this.order);
}
placeOrder(data)
......@@ -233,12 +241,13 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
if(result.Response.status == 'Unauthorized')
{
this.unAuthorized=true;
}
else
{
this.unAuthorized=false;
alert('Form sumited');
//this.store.dispatch(this.cartActions.resetCart());
this.store.dispatch(this.cartAction.resetCart());
this._location.back();
}
......@@ -251,6 +260,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
console.log( 'comp errorMessage[' + errorMessage + ']' );
}
);
}
saveAddress(){
......@@ -263,6 +274,26 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
}
selectAddress(address){
console.log('selectAddress cartItems:', this.cartItems);
this.cartItems.forEach(
item => {
item.itemCode;
console.log('selectAddress cartItems:', item.itemCode);
// this.checkoutService.getSalesRate(item.itemCode).subscribe(
// result => {
// console.log( 'comp results[' + result.sales + ']status' );
//
// },
// error => {
// let errorMessage = <any>error;
// console.log( 'comp errorMessage[' + errorMessage + ']' );
// }
// );
}
);
this.selectedAddress = address;
setTimeout(() => {
this.stepper.next();
......@@ -282,7 +313,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
cartData.itemCode = item.itemCode;
cartData.itemQuantity = item.itemQuantity;
this.store.dispatch(this.cartActions.updateCart(cartData));
this.store.dispatch(this.cartAction.updateCart(cartData));
this.getCartItems();
this.openSnackBar( 'Quantity increased of ' + item.itemHeader.itemShDescr );
}
......@@ -291,7 +323,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
let cartData = new Item;
cartData.itemCode = item.itemCode;
cartData.itemQuantity = item.itemQuantity;
this.store.dispatch(this.cartActions.updateCart(cartData));
this.store.dispatch(this.cartAction.updateCart(cartData));
this.getCartItems();
this.openSnackBar( 'Quantity decreased of ' + item.itemHeader.itemShDescr );
}
......@@ -372,7 +405,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
ngDoCheck()
{
if( this.userData && !this.redirect)
//already logged in
if( this.userData && !this.redirect)
{
console.log('stepper--',this.stepper._steps,this.stepper.selectedIndex);
if(this.stepper._steps && this.stepper.selectedIndex == 0)
......@@ -432,7 +466,28 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
}
submitForm(){
console.log("addressObj in ecm checkout ",this.addressObj.custCode);
var custCode=this.addressObj.custCode;
this.cartItems.forEach(
item => {
item.itemCode;
console.log('selectAddress cartItems:', item.itemCode);
this.checkoutService.getSalesRate(item.itemCode,custCode).subscribe(
result => {
console.log( 'comp results[' + result + ']', result);
console.log( 'comp results..........[' + result.Response + ']');
},
error => {
let errorMessage = <any>error;
console.log( 'comp errorMessage[' + errorMessage + ']' );
}
);
}
);
console.log('submitted---',this.customerInformationFormGroup);
}
}
......
......@@ -12,7 +12,7 @@ export class EcmCheckoutService {
constructor (private http: Http,public hostUrlService : HostUrlService ) {}
singleItem: ItemDetail;
private SERVICE_URL = '/ecm/service/SalesRate'; // URL to web service
sendData(data, _tokenid: string): Observable<any> {
console.log( "inside send data" + JSON.stringify(data));
let authUrl = '/ecm/service/order'; // URL to web service
......@@ -27,6 +27,19 @@ export class EcmCheckoutService {
.map( (res) => this.extractData(res) );
}
getSalesRate (itemCode : string, custCode :string): Observable<any> {
console.log( "getSalesRate1.....[" + itemCode+"] custCode....["+custCode+"]");
itemCode=itemCode.trim();
let salesRateUrl = this.hostUrlService.hostUrl+this.SERVICE_URL + '/' + itemCode+'/'+custCode;
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
console.log( "getSalesRate 2...." + salesRateUrl);
return this.http.get( salesRateUrl, options)
.map( (res) => this.extractData(res) );
}
setItem(item){
this.singleItem = item;
console.log("the item of set now start",this.singleItem)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment