package com.gingersoft.gsa.cloud.base.common.bean;

import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.database.bean.Food;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Wyh on 2020/1/17.
 */
public class OrderBean {
    /**
     * id : 40553
     * orderNo : gs204650350122922
     * status : 0
     * totalAmount : 141.0
     * totalPoints : 0.0
     * createTime : Jan 14, 2020 7:49:50 PM
     * orderDetails : [{"id":1621502,"productName":"胡椒排骨涼瓜煲","productId":"4257","price":58,"lunchboxPrice":0,"number":1,"createTime":"Jan 14, 2020 8:00:11 PM","status":0},{"id":1621503,"productName":"海南雞(例牌)","productId":"4258","price":83,"lunchboxPrice":0,"number":1,"createTime":"Jan 14, 2020 8:00:11 PM","status":0}]
     */

    private long id;
    private String orderNo;
    private int status;
    private int person;
    private double totalAmount;
    private double totalPoints;
    /**折扣金額*/
    private double discountAmount;
    /**折扣比例*/
    private double discountValue;
    /**折扣類型*/
    private int type;
    /**
     * 生成訂單時間
     */
    private String createTime;
    private List<OrderDetailsBean> orderDetails;

    public OrderBean() {
    }

    public OrderBean(OrderBean orderBean) {
        this.id = orderBean.id;
        this.status = orderBean.status;
        this.orderNo = orderBean.orderNo;
        this.person = orderBean.person;
        this.discountAmount = orderBean.discountAmount;
        this.discountValue = orderBean.discountValue;
        this.type = orderBean.type;
        this.createTime = orderBean.createTime;
    }

    public OrderBean(int orderId) {
        this.id = orderId;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getPerson() {
        return person;
    }

    public void setPerson(int person) {
        this.person = person;
    }

    public double getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(double totalAmount) {
        this.totalAmount = totalAmount;
    }

    public double getTotalPoints() {
        return totalPoints;
    }

    public void setTotalPoints(double totalPoints) {
        this.totalPoints = totalPoints;
    }

    public double getDiscountAmount() {
        return discountAmount;
    }

    public void setDiscountAmount(double discountAmount) {
        this.discountAmount = discountAmount;
    }

    public double getDiscountValue() {
        return discountValue;
    }

    public void setDiscountValue(double discountValue) {
        this.discountValue = discountValue;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public List<OrderDetailsBean> getOrderDetails() {
        return orderDetails;
    }

    public void setOrderDetails(List<OrderDetailsBean> orderDetails) {
        this.orderDetails = orderDetails;
    }

    public static class OrderDetailsBean implements Serializable {
        /**
         * id : 1621502
         * orderId : 47039
         * parentId : 1639956
         * productName : 胡椒排骨涼瓜煲
         * productId : 4257
         * price : 58.0
         * lunchboxPrice : 0.0
         * number : 1
         * createTime : Jan 14, 2020 8:00:11 PM
         * status : 0
         */
        private int id;
        private String productName;
        private long productId;
        //單價
        private double price;
        private double lunchboxPrice;
        private int number;
        private String createTime;
        private int status;

        private byte type;
        private long parentId;
        private long orderId;
        /**
         * 是否参与折扣#0:不參與;1:參與;
         */
        private long ablediscount;
        /**
         * 自定義字段
         */
        /**
         * 商品父級ID
         */
        private long topId;
        private long memberId;

        public OrderDetailsBean() {
        }


        public OrderDetailsBean(String productName, long productId, long parentId, double price, double lunchboxPrice, int number, byte type, long orderId) {
            this.productName = productName;
            this.productId = productId;
            this.parentId = parentId;
            this.price = price;
            this.lunchboxPrice = lunchboxPrice;
            this.number = number;
            this.type = type;
            this.orderId = orderId;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public long getMemberId() {
            return memberId;
        }

        public void setMemberId(long memberId) {
            this.memberId = memberId;
        }

        public byte getType() {
            return type;
        }

        public void setType(byte type) {
            this.type = type;
        }

        public long getParentId() {
            return parentId;
        }

        public void setParentId(long parentId) {
            this.parentId = parentId;
        }

        public String getProductName() {
            return productName;
        }

        public void setProductName(String productName) {
            this.productName = productName;
        }

        public long getProductId() {
            return productId;
        }

        public void setProductId(long productId) {
            this.productId = productId;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }

        public double getLunchboxPrice() {
            return lunchboxPrice;
        }

        public void setLunchboxPrice(double lunchboxPrice) {
            this.lunchboxPrice = lunchboxPrice;
        }

        public int getNumber() {
            return number;
        }

        public void setNumber(int number) {
            this.number = number;
        }

        public String getCreateTime() {
            return createTime;
        }

        public void setCreateTime(String createTime) {
            this.createTime = createTime;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public long getOrderId() {
            return orderId;
        }

        public void setOrderId(long orderId) {
            this.orderId = orderId;
        }

        public long getAblediscount() {
            return ablediscount;
        }

        public void setAblediscount(long ablediscount) {
            this.ablediscount = ablediscount;
        }

        public long getTopId() {
            return topId;
        }

        public void setTopId(long topId) {
            this.topId = topId;
        }

        @Override
        public String toString() {
            return "OrderDetailsBean{" +
                    "id=" + id +
                    ", productName='" + productName + '\'' +
                    ", productId=" + productId +
                    ", price=" + price +
                    ", lunchboxPrice=" + lunchboxPrice +
                    ", number=" + number +
                    ", status=" + status +
                    ", type=" + type +
                    ", parentId=" + parentId +
                    ", orderId=" + orderId +
                    ", topId=" + topId +
                    '}';
        }
    }

//    public static List<OrderDetailsBean> transOrderDetails(List<Food> foods) {
//        List<OrderDetailsBean> orderDetailsBeans = new ArrayList<>();
//        for (Food food : foods) {
//            OrderDetailsBean orderDetailsBean = new OrderDetailsBean(food.getFoodName(), food.getParentId()+ "", food.getPrice(), food.getLunchboxPrice(), food.getNumber(), food.getOrderId());
//            orderDetailsBeans.add(orderDetailsBean);
//        }
//        return orderDetailsBeans;
//    }

    public static List<OrderDetailsBean> transOrderDetails(List<OrderDetail> foods) {
        List<OrderDetailsBean> orderDetailsBeans = new ArrayList<>();
        for (OrderDetail food : foods) {
            OrderDetailsBean orderDetailsBean = new OrderDetailsBean(food.getProductName(), food.getProductId(), food.getParentId(), food.getUnit_price(), food.getLunchboxPrice(), food.getNumber(), food.getType(), food.getOrderId());
            orderDetailsBeans.add(orderDetailsBean);
        }
        return orderDetailsBeans;
    }

}
