package com.prime.sony.ecommerce.model;

import java.util.Date;

import com.prime.sony.ecommerce.util.DateHelper;
import com.prime.sony.ecommerce.util.StringUtil;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class Orders extends BaseModel {

	private Long order_primary_key;
	private String store_id;
	private String snowflake_schema;
	private Long product_id;
	private Long product_variant_id;
	private String product_sku;
	private Long store_customer_id;
	private String order_id;
	private Float order_total;
	private Float order_subtotal;
	private String currency;
	private String coupon_code;
	private Date coupon_start_date;
	private Date coupon_expiry_date;
	private String coupon_description;
	private Float refund_total;
	private Date refund_date;
	private String order_status;
	private Date order_date;
	private Long total_quantity;
	private Long total_order_items;
	private String order_items_id;
	private Long order_items_quantity;
	private Float order_items_total;
	private Float order_items_subtotal;
	private Float order_items_refund_subtotal;
	private Float order_items_refund_quantity;
	private Date order_date_created;
	private Date order_date_modified;
	private Date consolidated_date_created;
	private Date consolidated_date_modified;
	private String errorMessage;
	private String altOrderId;
	private String email;
	private String customerId;
	private boolean marketing_consent;
	private String discount_Code__c;

	public String getHeader() {
		return "Name,Consolidated_Date_Created__c,Consolidated_Date_Modified__c,Coupon_Code__c,"
				+ "Coupon_Description__c,Coupon_Expiry_Date__c,Coupon_Start_Date__c,Currency__c,"
				+ "Order_date__c,Order_Date_Created__c,Order_Date_Modified__c,Order_ID__c,"
				+ "Order_Items_ID__c,Order_Items_Quantity__c,Order_Items_Refund_Quantity__c,"
				+ "Order_Items_Refund_SubTotal__c,Order_Items_SubTotal__c,Order_Items_Total__c,"
				+ "Order_Status__c,Order_SubTotal__c,Order_Total__c,Product_ID__c,"
				+ "Product_Sku__c,Product_Variant_ID__c,Refund_Date__c,Refund_Total__c,"
				+ "SnowFlake_Schema__c,Store_Customer_ID__c,Store_ID__c,Total_Order_Items__c,"
				+ "Total_Quantity__c,Alt_Order_ID__c,Customer_ID__c,Email__c,Marketing_Consent__c,Discount_Code__c";
	}
	//Customer_Primary_Key_Hidden__c

	public String getCSVvalue() {

		StringBuilder sb = new StringBuilder();
		//Name
		sb.append(this.getOrder_primary_key() + ",");

		// Consolidated_Date_Created__c
		if (null != this.getConsolidated_date_created()) {
			sb.append(DateHelper.getFormattedDateValue(this.getConsolidated_date_created()) + ",");
		} else {
			sb.append(",");
		}

		// Consolidated_Date_Modified__c
		if (null != this.getConsolidated_date_modified()) {
			sb.append(DateHelper.getFormattedDateValue(this.getConsolidated_date_modified()) + ",");
		} else {
			sb.append(",");
		}

		// Coupon_Code__c
		sb.append(StringUtil.strValidate(this.getCoupon_code()) + ",");

		// Coupon_Description__c
		sb.append(StringUtil.strValidate(this.getCoupon_description()) + ",");

		// Coupon_Expiry_Date__c
		if (null != this.getCoupon_expiry_date()) {
			sb.append(DateHelper.getFormattedDateValue(this.getCoupon_expiry_date()) + ",");
		} else {
			sb.append(",");
		}

		// Coupon_Start_Date__c
		if (null != this.getCoupon_start_date()) {
			sb.append(DateHelper.getFormattedDateValue(this.getCoupon_start_date()) + ",");
		} else {
			sb.append(",");
		}

		// Currency__c
		sb.append(StringUtil.strValidate(this.getCurrency()) + ",");

		// Order_date__c
		if (null != this.getOrder_date()) {
			sb.append(DateHelper.getFormattedDateValue(this.getOrder_date()) + ",");
		} else {
			sb.append(",");
		}

		// Order_Date_Created__c
		if (null != this.getOrder_date_created()) {
			sb.append(DateHelper.getFormattedDateValue(this.getOrder_date_created()) + ",");
		} else {
			sb.append(",");
		}

		// Order_Date_Modified__c
		if (null != this.getOrder_date_modified()) {
			sb.append(DateHelper.getFormattedDateValue(this.getOrder_date_modified()) + ",");
		} else {
			sb.append(",");
		}

		// Order_ID__c
		sb.append(StringUtil.strValidate(this.getOrder_id()) + ",");

		// Order_Items_ID__c
		sb.append(StringUtil.strValidate(this.getOrder_items_id()) + ",");

		// Order_Items_Quantity__c
		sb.append(this.getOrder_items_quantity() + ",");

		// Order_Items_Refund_Quantity__c
		sb.append(this.getOrder_items_refund_quantity() + ",");

		// Order_Items_Refund_SubTotal__c
		sb.append(this.getOrder_items_refund_subtotal() + ",");

		// Order_Items_SubTotal__c
		sb.append(this.getOrder_items_subtotal() + ",");

		// Order_Items_Total__c
		sb.append(this.getOrder_items_total() + ",");

		// Order_Status__c
		sb.append(StringUtil.strValidate(this.getOrder_status()) + ",");

		// Order_SubTotal__c
		sb.append(this.getOrder_subtotal() + ",");

		// Order_Total__c
		sb.append(this.getOrder_total() + ",");

		// Product_ID__c
		sb.append(this.getProduct_id() + ",");

		// Product_Sku__c
		sb.append(StringUtil.strValidate(this.getProduct_sku()) + ",");
		
		//Product_Variant_ID__c
		sb.append(this.getProduct_variant_id() + ",");

		// Refund_Date__c
		if (null != this.getRefund_date()) {
			sb.append(DateHelper.getFormattedDateValue(this.getRefund_date()) + ",");
		} else {
			sb.append(",");
		}

		// Refund_Total__c
		sb.append(this.getRefund_total() + ",");

		// SnowFlake_Schema__c
		sb.append(StringUtil.strValidate(this.getSnowflake_schema()) + ",");

		// Store_Customer_ID__c
		sb.append(this.getStore_customer_id() + ",");

		// Store_ID__c
		sb.append(StringUtil.strValidate(this.getStore_id()) + ",");

		// Total_Order_Items__c
		sb.append(this.getTotal_order_items() + ",");

		// Total_Quantity__c
		sb.append(this.getTotal_quantity()+ ",");
		
		//Alt_Order_ID__c
		sb.append(this.getAltOrderId()+ ",");
		
		//Customer_ID__c
		sb.append(this.getCustomerId()+ ",");
		
		//Email__c
		sb.append(this.getEmail()+",");
		
		//Marketing_Consent__c
		sb.append(this.isMarketing_consent()+",");
		
		
		//Discount_Code__c
		sb.append(StringUtil.strValidate(this.getDiscount_Code__c()));		
		
		/*
		 * //Customer_Primary_Key_Hidden__c sb.append(this.getCustomer_Primary_Key());
		 */

		return sb.toString();
	}

}
