Commit e45f6ea0 authored by rani0808's avatar rani0808

order generation to create orders

parent 816b2644
......@@ -55,6 +55,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
......
......@@ -6,9 +6,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class OmdCheckoutServiceApplication {
public static void main(String[] args) {
SpringApplication.run(OmdCheckoutServiceApplication.class, args);
}
}
package com.nisum.omd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.omd.domain.Order;
import com.nisum.omd.service.RandomDataGeneratorImpl;
@Component
public class OrderGenerator implements CommandLineRunner{
@Autowired
RandomDataGeneratorImpl rdg;
@Autowired
Order order;
Boolean orderGenerateFlag = true;
public Boolean getOrderGenerateFlag() {
return orderGenerateFlag;
}
public void setOrderGenerateFlag(Boolean orderGenerateFlag) {
this.orderGenerateFlag = orderGenerateFlag;
}
public void run(String... args) throws Exception {
while(orderGenerateFlag){
order=getObjectData(order);
ObjectMapper objectMapper = new ObjectMapper();
String jsonOrderStr = objectMapper.writeValueAsString(order);
System.out.println(jsonOrderStr);
}
}
public Order getObjectData(Order order2) {
order.setOrderNum(rdg.generateOrderNumber());
order.setCustomerId(rdg.generateCustomerId());
order.setLineItem(rdg.genetateLineItem(order.getLineItem()));
return order;
}
}
......@@ -13,21 +13,6 @@ public class BillingTo {
private String eMailID;
private boolean residentialAddr;
public BillingTo(String firstName, String lastName, String addressLine1, String city, String state, String zipCode,
String country, int mobileNum, String eMailID, boolean residentialAddr) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.addressLine1 = addressLine1;
this.city = city;
this.state = state;
this.zipCode = zipCode;
this.country = country;
this.mobileNum = mobileNum;
this.eMailID = eMailID;
this.residentialAddr = residentialAddr;
}
public String getFirstName() {
return firstName;
}
......
......@@ -3,6 +3,9 @@ package com.nisum.omd.domain;
import java.util.Map;
import org.springframework.stereotype.Component;
@Component
public class LineItem {
private String lineItemNumber;
private String skuNumber;
......@@ -14,8 +17,6 @@ public class LineItem {
private boolean shipChrgApplInd;
private String estimatedShipDate;
private Map<String,Object> linePriceInfo;
private String taxCode;
private boolean autoAddInd;
private Map<String,Object> lineTax;
private String originalLineItemId;
private String vendorUpcCode;
......@@ -55,6 +56,7 @@ public class LineItem {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getItemType() {
......@@ -81,18 +83,6 @@ public class LineItem {
public void setLinePriceInfo(Map<String, Object> linePriceInfo) {
this.linePriceInfo = linePriceInfo;
}
public String getTaxCode() {
return taxCode;
}
public void setTaxCode(String taxCode) {
this.taxCode = taxCode;
}
public boolean isAutoAddInd() {
return autoAddInd;
}
public void setAutoAddInd(boolean autoAddInd) {
this.autoAddInd = autoAddInd;
}
public Map<String, Object> getLineTax() {
return lineTax;
}
......
package com.nisum.omd.domain;
import java.util.List;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties("app")
public class Order {
......@@ -14,7 +16,7 @@ public class Order {
private String customerType;
private String gift;
private Promotions promotions;
private List<LineItem> lineItem;
private LineItem lineItem;
private BillingTo billingTo;
private OrderCharges orderCharges;
private OrderTaxes orderTaxes;
......@@ -22,28 +24,19 @@ public class Order {
private ShipTo shipTo;
private PaymentMethod paymentMethod;
public Order(String orderNum, String orderDate, String currency, String shipMethod, String customerId,
String customerType, String gift, Promotions promotions, List<LineItem> lineItem, BillingTo billingTo,
OrderCharges orderCharges, OrderTaxes orderTaxes, ShippingInfo shippingInfo, ShipTo shipTo,
PaymentMethod paymentMethod) {
super();
this.orderNum = orderNum;
this.orderDate = orderDate;
this.currency = currency;
this.shipMethod = shipMethod;
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
this.customerType = customerType;
this.gift = gift;
this.promotions = promotions;
this.lineItem = lineItem;
this.billingTo = billingTo;
this.orderCharges = orderCharges;
this.orderTaxes = orderTaxes;
this.shippingInfo = shippingInfo;
this.shipTo = shipTo;
this.paymentMethod = paymentMethod;
}
public String getOrderNum() {
return orderNum;
}
......@@ -76,13 +69,7 @@ public class Order {
this.shipMethod = shipMethod;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getCustomerType() {
return customerType;
......@@ -108,11 +95,11 @@ public class Order {
this.promotions = promotions;
}
public List<LineItem> getLineItem() {
public LineItem getLineItem() {
return lineItem;
}
public void setLineItem(List<LineItem> lineItem) {
public void setLineItem(LineItem lineItem) {
this.lineItem = lineItem;
}
......
......@@ -6,13 +6,6 @@ public class OrderCharges {
private String chargeCategory;
private String chargeName;
public OrderCharges(float chargeAmount, String chargeCategory, String chargeName) {
super();
this.chargeAmount = chargeAmount;
this.chargeCategory = chargeCategory;
this.chargeName = chargeName;
}
public float getChargeAmount() {
return chargeAmount;
}
......
......@@ -8,15 +8,6 @@ public class OrderTaxes {
private String taxCode;
private int taxPercentage;
public OrderTaxes(String chargeCategory, String taxName, float tax, String taxCode, int taxPercentage) {
super();
this.chargeCategory = chargeCategory;
this.taxName = taxName;
this.tax = tax;
this.taxCode = taxCode;
this.taxPercentage = taxPercentage;
}
public String getChargeCategory() {
return chargeCategory;
}
......
......@@ -4,7 +4,6 @@ import java.util.Map;
public class Promotions {
private Map<String,Object> PromotionDetails;
private Map<String,Object> Awards;
public Map<String, Object> getPromotionDetails() {
return PromotionDetails;
......@@ -12,11 +11,5 @@ public class Promotions {
public void setPromotionDetails(Map<String, Object> promotionDetails) {
PromotionDetails = promotionDetails;
}
public Map<String, Object> getAwards() {
return Awards;
}
public void setAwards(Map<String, Object> awards) {
Awards = awards;
}
}
......@@ -13,20 +13,6 @@ public class ShipTo {
private String eMailID;
private boolean residentialAddr;
public ShipTo(String firstName, String lastName, String addressLine1, String city, String state, String zipCode,
String country, int mobileNum, String eMailID, boolean residentialAddr) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.addressLine1 = addressLine1;
this.city = city;
this.state = state;
this.zipCode = zipCode;
this.country = country;
this.mobileNum = mobileNum;
this.eMailID = eMailID;
this.residentialAddr = residentialAddr;
}
public String getFirstName() {
return firstName;
......
......@@ -7,13 +7,6 @@ public class ShippingInfo {
private int minDaysToDeliver;
public ShippingInfo(Boolean vaildShipTo, int maxDaysToDeliver, int minDaysToDeliver) {
super();
this.vaildShipTo = vaildShipTo;
this.maxDaysToDeliver = maxDaysToDeliver;
this.minDaysToDeliver = minDaysToDeliver;
}
public Boolean getVaildShipTo() {
return vaildShipTo;
}
......@@ -33,7 +26,4 @@ public class ShippingInfo {
this.minDaysToDeliver = minDaysToDeliver;
}
}
package com.nisum.omd.service;
import com.nisum.omd.domain.LineItem;
public interface RandomDataGenerator {
String generateOrderNumber();
String generateCustomerId();
LineItem genetateLineItem(LineItem li);
}
package com.nisum.omd.service;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.github.javafaker.Faker;
import com.nisum.omd.domain.LineItem;
import com.nisum.omd.domain.Order;
@Component
@RequestMapping("app")
public class RandomDataGeneratorImpl implements RandomDataGenerator {
@Autowired
Order order;
Faker fk = new Faker();
public String generateOrderNumber() {
// TODO Auto-generated method stub
return String.valueOf(fk.number().numberBetween(1000000, 9999999));
}
@Override
public String generateCustomerId() {
// TODO Auto-generated method stub
return String.valueOf(fk.number().numberBetween(1, 1000));
}
@GetMapping("/orderDate")
public String getOrderDate()
{
return order.getOrderDate();
}
@Override
public LineItem genetateLineItem(LineItem li) {
List<String> productname = new ArrayList<String>();
productname.add("Easy Heavyweight T-Shirt");
productname.add("Classic stripe T-Shirt");
productname.add("Icon denim jacket");
productname.add("Graphic crewneck T-Shirt");
productname.add("Classic V T-Shirt");
Random rand = new Random();
int randomIndex = rand.nextInt(productname.size());
String randomElement = productname.get(randomIndex);
li.setProductName(randomElement);
return li;
}
}
app.orderDate=2020-04-26T13:33:15.657-05:00
app.currency=INR
app.shipMethod=1
app.customerType=01
app.promotionDesc=Electronic Items Ship Free
app.promotionApplied=false
app.awardId=1000
app.awardAmt=0.00
app.gift=false
app.promotions.promotionDetails.promotionDesc=Electronic Items Ship Free
app.promotions.promotionDetails.promotionApplied=false
app.promotions.promotionDetails.awards.awardId=1000
app.promotions.promotionDetails.awards.awardAmt=0.00
app.lineItem.lineItemNumber=5475
app.lineItem.skuNumber=22222222
app.lineItem.itemColorDesc=White
app.lineItem.size=6
app.lineItem.orderedQty=2
app.lineItem.itemType=7
app.lineItem.shipChrgApplInd=true
app.lineItem.estimatedShipDate=2020-04-26T00:00:00-05:00
app.lineItem.linePriceInfo.listPrice=29.50
app.lineItem.linePriceInfo.retailPrice=29.50
app.lineItem.linePriceInfo.unitPrice=20.00
app.lineItem.linePriceInfo.linePriceType=03
app.lineItem.lineTax.chargeCategory=Price
app.lineItem.lineTax.chargeName=Price
app.lineItem.lineTax.taxName=SalesTax
app.lineItem.lineTax.tax=3.40
app.lineItem.lineTax.taxPercentage=8.50
app.lineItem.lineTax.taxCode=C1
app.lineItem.lineTax.unitTaxAmount=1.70
app.shippingInfo.vaildShipTo=true
app.shippingInfo.maxDaysToDeliver=9
app.shippingInfo.minDaysToDeliver=6
app.shipTo.firstName=Narendra
app.shipTo.lastName=Modi
app.shipTo.addressLine1=2 Folsom St
app.shipTo.city=Delhi
app.shipTo.state=DL
app.shipTo.zipCode=110001
app.shipTo.country=IN
app.shipTo.mobile=9988776655
app.shipTo.eMailID=modi@india.com
app.shipTo.residentialAddr=false
app.billingTo.firstName=Narendra
app.billingTo.lastName=Modi
app.billingTo.addressLine1=2 Folsom St
app.billingTo.city=Delhi
app.billingTo.state=DL
app.billingTo.zipCode=110001
app.billingTo.country=IN
app.billingTo.mobile=9988776655
app.billingTo.eMailID=modi@india.com
app.billingTo.residentialAddr=false
app.orderCharges.ChargeAmount=10.00
app.orderCharges.ChargeCategory=Ship
app.orderCharges.ChargeName=Ship
app.orderTaxes.ChargeCategory=Shipping
app.orderTaxes.TaxName=GST
app.orderTaxes.Tax=0.00
app.orderTaxes.taxCode=C1
app.orderTaxes.TaxPercentage=12
app.paymentMethod.paymentMethod=CC
app.paymentMethod.creditCardNo=12345678987665
app.paymentMethod.creditCardType=VISA
app.paymentMethod.displayCreditCardNo=8277
app.paymentMethod.paymentStatus=AUTH
app.paymentMethod.paymentDetail.TransactionId=021361475199
app.paymentMethod.paymentDetail.ProcessedAmount=1000.00
app.paymentMethod.paymentDetail.RequestAmount=1000.00
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