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 { ...@@ -403,6 +403,12 @@ md-card {
font-size: 10px; font-size: 10px;
} }
.discount-rate {
color: green;
padding-left: 5px;
font-weight: 700;
}
.individual-price { .individual-price {
display: block; display: block;
font-size: 12px; font-size: 12px;
......
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
</div> </div>
<div class="large-6 columns ecm-item-info"> <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.itemDescr}} </span>
<span style="display: block;font-size: 16px;"> {{item.itemHeader.itemShDescr}} </span>
<div *ngIf="item.itemCategory.catCode == 'CAT0000004'" class="delivery-offers"> <div *ngIf="item.itemCategory.catCode == 'CAT0000004'" class="delivery-offers">
<span>FREE Delivery in 5 to 6 days</span> <span>FREE Delivery in 5 to 6 days</span>
<button type="button" class="md-button link_button"> <button type="button" class="md-button link_button">
...@@ -208,10 +209,9 @@ ...@@ -208,10 +209,9 @@
<counter [quantity]="item.itemQuantity" (decrement)="decrement(item);" (increment)="increment(item);"> <counter [quantity]="item.itemQuantity" (decrement)="decrement(item);" (increment)="increment(item);">
<price> <price>
<div *ngIf="item.itemCategory.catCode == 'CAT0000004'" class="product-price">
<span style="display: block;" class="total-cost">Rs {{item.itemHeader.itemDiscountedRate}}</span> <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> <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> <span *ngIf="item == 'occassion'" class="individual-price">Rs 500 per person (Inclusive GST)</span>
</price> </price>
</counter> </counter>
......
...@@ -36,15 +36,15 @@ import { EcmCartService } from '../ecm-cart/ecm-cart.service'; ...@@ -36,15 +36,15 @@ import { EcmCartService } from '../ecm-cart/ecm-cart.service';
@Component( { @Component( {
selector: 'ecm-checkout', selector: 'ecm-checkout',
templateUrl: './ecm-checkout.component.html', templateUrl: './ecm-checkout.component.html',
styleUrls: ['./ecm-checkout.component.css'], styleUrls: ['./ecm-checkout.component.css']
providers:[EcmCheckoutService]
}) })
export class EcmCheckoutComponent implements OnInit ,DoCheck { export class EcmCheckoutComponent implements OnInit ,DoCheck {
dataSource = '/ibase/ecm/service/customers/' dataSource = '/ibase/ecm/service/customers/'
@ViewChild('userForm') currentForm: NgForm; @ViewChild('userForm') currentForm: NgForm;
@Input() unAuthorized: boolean = false; @Input() unAuthorized: boolean = false;
maxDate = new Date(); //date upadted
checked = false; checked = false;
totalPrice:number = 0; totalPrice:number = 0;
cartItems; cartItems;
...@@ -54,6 +54,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -54,6 +54,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
orderReviewed; orderReviewed;
selectedAddressOpt; selectedAddressOpt;
ecmType; //chitra ecmType; //chitra
order;
@ViewChild( 'cardScreen' ) child: CardScreenComponent; @ViewChild( 'cardScreen' ) child: CardScreenComponent;
@ViewChild('addrAddScreen') addScreen: AddressScreenComponent; @ViewChild('addrAddScreen') addScreen: AddressScreenComponent;
...@@ -82,7 +83,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -82,7 +83,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
customerInformation; 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.profileActions.loadProfile());
this.store.dispatch(this.addressActions.loadAddress()); this.store.dispatch(this.addressActions.loadAddress());
this.store.dispatch(this.cardActions.loadSavedCards()); this.store.dispatch(this.cardActions.loadSavedCards());
...@@ -100,9 +101,9 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -100,9 +101,9 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
this.store.dispatch(this.cardActions.loadSavedCards()); this.store.dispatch(this.cardActions.loadSavedCards());
window.scrollTo(0,0); window.scrollTo(0,0);
this.createUserData(); this.createUserData();
this.getCartItems();
if(this.checkoutService.getItem()){ if(this.checkoutService.getItem()){
console.log('checkout service get item:::::',this.checkoutService.getItem());
this.cartItems = []; this.cartItems = [];
this.cartItems.push(this.checkoutService.getItem()); this.cartItems.push(this.checkoutService.getItem());
this.checkoutService.reset(); this.checkoutService.reset();
...@@ -114,6 +115,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -114,6 +115,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
); );
}else { }else {
console.log(':::::::::::::::GET');
this.getCartItems(); this.getCartItems();
} }
...@@ -180,12 +182,15 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -180,12 +182,15 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
} }
getCartItems() { getCartItems() {
console.log('Inside getCartItems ');
this.store.select('cartItems').subscribe( cartItems => { this.store.select('cartItems').subscribe( cartItems => {
this.totalPrice = 0; this.totalPrice = 0;
this.cartItems = cartItems; this.cartItems = cartItems;
this.cartItems.forEach( this.cartItems.forEach(
item => { item => {
console.log('Inside getCartItems ',item);
this.totalPrice = this.totalPrice + (parseFloat( item.itemHeader.itemDiscountedRate ) * item.itemQuantity); 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 { ...@@ -193,7 +198,7 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
executePayment() { executePayment() {
let paymentInfo; let paymentInfo;
console.log('executePayment customerInformation',this.customerInformation);
switch(this.selectedPaymntOpt) switch(this.selectedPaymntOpt)
{ {
case 'newcard': case 'newcard':
...@@ -217,12 +222,15 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -217,12 +222,15 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
paymentInfo = { "paymentOption":'card', "cardDetails": this.cardList.find(x => x.lineNo === this.selectedPaymntOpt)}; paymentInfo = { "paymentOption":'card', "cardDetails": this.cardList.find(x => x.lineNo === this.selectedPaymntOpt)};
break; 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}; this.placeOrder(this.order);
console.log('-----order-----',order);
this.placeOrder(order);
} }
placeOrder(data) placeOrder(data)
...@@ -233,12 +241,13 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -233,12 +241,13 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
if(result.Response.status == 'Unauthorized') if(result.Response.status == 'Unauthorized')
{ {
this.unAuthorized=true; this.unAuthorized=true;
} }
else else
{ {
this.unAuthorized=false; this.unAuthorized=false;
alert('Form sumited'); alert('Form sumited');
//this.store.dispatch(this.cartActions.resetCart()); this.store.dispatch(this.cartAction.resetCart());
this._location.back(); this._location.back();
} }
...@@ -251,6 +260,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -251,6 +260,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
console.log( 'comp errorMessage[' + errorMessage + ']' ); console.log( 'comp errorMessage[' + errorMessage + ']' );
} }
); );
} }
saveAddress(){ saveAddress(){
...@@ -263,6 +274,26 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -263,6 +274,26 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
} }
selectAddress(address){ 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; this.selectedAddress = address;
setTimeout(() => { setTimeout(() => {
this.stepper.next(); this.stepper.next();
...@@ -282,7 +313,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -282,7 +313,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
cartData.itemCode = item.itemCode; cartData.itemCode = item.itemCode;
cartData.itemQuantity = item.itemQuantity; 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 ); this.openSnackBar( 'Quantity increased of ' + item.itemHeader.itemShDescr );
} }
...@@ -291,7 +323,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -291,7 +323,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
let cartData = new Item; let cartData = new Item;
cartData.itemCode = item.itemCode; cartData.itemCode = item.itemCode;
cartData.itemQuantity = item.itemQuantity; 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 ); this.openSnackBar( 'Quantity decreased of ' + item.itemHeader.itemShDescr );
} }
...@@ -372,7 +405,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -372,7 +405,8 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
ngDoCheck() ngDoCheck()
{ {
if( this.userData && !this.redirect) //already logged in
if( this.userData && !this.redirect)
{ {
console.log('stepper--',this.stepper._steps,this.stepper.selectedIndex); console.log('stepper--',this.stepper._steps,this.stepper.selectedIndex);
if(this.stepper._steps && this.stepper.selectedIndex == 0) if(this.stepper._steps && this.stepper.selectedIndex == 0)
...@@ -432,7 +466,28 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck { ...@@ -432,7 +466,28 @@ export class EcmCheckoutComponent implements OnInit ,DoCheck {
} }
submitForm(){ 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); console.log('submitted---',this.customerInformationFormGroup);
} }
} }
......
...@@ -12,7 +12,7 @@ export class EcmCheckoutService { ...@@ -12,7 +12,7 @@ export class EcmCheckoutService {
constructor (private http: Http,public hostUrlService : HostUrlService ) {} constructor (private http: Http,public hostUrlService : HostUrlService ) {}
singleItem: ItemDetail; singleItem: ItemDetail;
private SERVICE_URL = '/ecm/service/SalesRate'; // URL to web service
sendData(data, _tokenid: string): Observable<any> { sendData(data, _tokenid: string): Observable<any> {
console.log( "inside send data" + JSON.stringify(data)); console.log( "inside send data" + JSON.stringify(data));
let authUrl = '/ecm/service/order'; // URL to web service let authUrl = '/ecm/service/order'; // URL to web service
...@@ -27,6 +27,19 @@ export class EcmCheckoutService { ...@@ -27,6 +27,19 @@ export class EcmCheckoutService {
.map( (res) => this.extractData(res) ); .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){ setItem(item){
this.singleItem = item; this.singleItem = item;
console.log("the item of set now start",this.singleItem) 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