Commit e45f6ea0 authored by rani0808's avatar rani0808

order generation to create orders

parent 816b2644
...@@ -55,6 +55,11 @@ ...@@ -55,6 +55,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -5,10 +5,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -5,10 +5,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class OmdCheckoutServiceApplication { public class OmdCheckoutServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(OmdCheckoutServiceApplication.class, 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 { ...@@ -13,21 +13,6 @@ public class BillingTo {
private String eMailID; private String eMailID;
private boolean residentialAddr; 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() { public String getFirstName() {
return firstName; return firstName;
} }
......
...@@ -3,6 +3,9 @@ package com.nisum.omd.domain; ...@@ -3,6 +3,9 @@ package com.nisum.omd.domain;
import java.util.Map; import java.util.Map;
import org.springframework.stereotype.Component;
@Component
public class LineItem { public class LineItem {
private String lineItemNumber; private String lineItemNumber;
private String skuNumber; private String skuNumber;
...@@ -14,8 +17,6 @@ public class LineItem { ...@@ -14,8 +17,6 @@ public class LineItem {
private boolean shipChrgApplInd; private boolean shipChrgApplInd;
private String estimatedShipDate; private String estimatedShipDate;
private Map<String,Object> linePriceInfo; private Map<String,Object> linePriceInfo;
private String taxCode;
private boolean autoAddInd;
private Map<String,Object> lineTax; private Map<String,Object> lineTax;
private String originalLineItemId; private String originalLineItemId;
private String vendorUpcCode; private String vendorUpcCode;
...@@ -55,7 +56,8 @@ public class LineItem { ...@@ -55,7 +56,8 @@ public class LineItem {
return productName; return productName;
} }
public void setProductName(String productName) { public void setProductName(String productName) {
this.productName = productName;
this.productName = productName;
} }
public String getItemType() { public String getItemType() {
return itemType; return itemType;
...@@ -81,18 +83,6 @@ public class LineItem { ...@@ -81,18 +83,6 @@ public class LineItem {
public void setLinePriceInfo(Map<String, Object> linePriceInfo) { public void setLinePriceInfo(Map<String, Object> linePriceInfo) {
this.linePriceInfo = 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() { public Map<String, Object> getLineTax() {
return lineTax; return lineTax;
} }
......
package com.nisum.omd.domain; package com.nisum.omd.domain;
import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.Map; import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties("app")
public class Order { public class Order {
...@@ -14,36 +16,27 @@ public class Order { ...@@ -14,36 +16,27 @@ public class Order {
private String customerType; private String customerType;
private String gift; private String gift;
private Promotions promotions; private Promotions promotions;
private List<LineItem> lineItem; private LineItem lineItem;
private BillingTo billingTo; private BillingTo billingTo;
private OrderCharges orderCharges; private OrderCharges orderCharges;
private OrderTaxes orderTaxes; private OrderTaxes orderTaxes;
private ShippingInfo shippingInfo; private ShippingInfo shippingInfo;
private ShipTo shipTo; private ShipTo shipTo;
private PaymentMethod paymentMethod; 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, public String getCustomerId() {
OrderCharges orderCharges, OrderTaxes orderTaxes, ShippingInfo shippingInfo, ShipTo shipTo, return customerId;
PaymentMethod paymentMethod) { }
super();
this.orderNum = orderNum;
this.orderDate = orderDate;
this.currency = currency; public void setCustomerId(String customerId) {
this.shipMethod = shipMethod;
this.customerId = 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() { public String getOrderNum() {
return orderNum; return orderNum;
} }
...@@ -76,13 +69,7 @@ public class Order { ...@@ -76,13 +69,7 @@ public class Order {
this.shipMethod = shipMethod; this.shipMethod = shipMethod;
} }
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getCustomerType() { public String getCustomerType() {
return customerType; return customerType;
...@@ -108,11 +95,11 @@ public class Order { ...@@ -108,11 +95,11 @@ public class Order {
this.promotions = promotions; this.promotions = promotions;
} }
public List<LineItem> getLineItem() { public LineItem getLineItem() {
return lineItem; return lineItem;
} }
public void setLineItem(List<LineItem> lineItem) { public void setLineItem(LineItem lineItem) {
this.lineItem = lineItem; this.lineItem = lineItem;
} }
......
...@@ -5,13 +5,6 @@ public class OrderCharges { ...@@ -5,13 +5,6 @@ public class OrderCharges {
private float chargeAmount; private float chargeAmount;
private String chargeCategory; private String chargeCategory;
private String chargeName; private String chargeName;
public OrderCharges(float chargeAmount, String chargeCategory, String chargeName) {
super();
this.chargeAmount = chargeAmount;
this.chargeCategory = chargeCategory;
this.chargeName = chargeName;
}
public float getChargeAmount() { public float getChargeAmount() {
return chargeAmount; return chargeAmount;
......
...@@ -7,15 +7,6 @@ public class OrderTaxes { ...@@ -7,15 +7,6 @@ public class OrderTaxes {
private float tax; private float tax;
private String taxCode; private String taxCode;
private int taxPercentage; 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() { public String getChargeCategory() {
return chargeCategory; return chargeCategory;
......
...@@ -4,7 +4,6 @@ import java.util.Map; ...@@ -4,7 +4,6 @@ import java.util.Map;
public class Promotions { public class Promotions {
private Map<String,Object> PromotionDetails; private Map<String,Object> PromotionDetails;
private Map<String,Object> Awards;
public Map<String, Object> getPromotionDetails() { public Map<String, Object> getPromotionDetails() {
return PromotionDetails; return PromotionDetails;
...@@ -12,11 +11,5 @@ public class Promotions { ...@@ -12,11 +11,5 @@ public class Promotions {
public void setPromotionDetails(Map<String, Object> promotionDetails) { public void setPromotionDetails(Map<String, Object> promotionDetails) {
PromotionDetails = 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 { ...@@ -13,20 +13,6 @@ public class ShipTo {
private String eMailID; private String eMailID;
private boolean residentialAddr; 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() { public String getFirstName() {
return firstName; return firstName;
......
...@@ -7,13 +7,6 @@ public class ShippingInfo { ...@@ -7,13 +7,6 @@ public class ShippingInfo {
private int minDaysToDeliver; private int minDaysToDeliver;
public ShippingInfo(Boolean vaildShipTo, int maxDaysToDeliver, int minDaysToDeliver) {
super();
this.vaildShipTo = vaildShipTo;
this.maxDaysToDeliver = maxDaysToDeliver;
this.minDaysToDeliver = minDaysToDeliver;
}
public Boolean getVaildShipTo() { public Boolean getVaildShipTo() {
return vaildShipTo; return vaildShipTo;
} }
...@@ -32,8 +25,5 @@ public class ShippingInfo { ...@@ -32,8 +25,5 @@ public class ShippingInfo {
public void setMinDaysToDeliver(int minDaysToDeliver) { public void setMinDaysToDeliver(int minDaysToDeliver) {
this.minDaysToDeliver = minDaysToDeliver; 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