package com.gingersoft.gsa.cloud.table.mvp.model.bean;

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

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：ELEGANT_BIN
 * 版本：1.6.0
 * 创建日期：2020-01-02
 * 修订历史：2020-01-02
 * 描述：
 */
public class BaseRespose {

    /**
     * success : true
     * sysTime : 1579003211275
     * data : {"id":40553,"orderNo":"gs204650350122922","status":0,"totalAmount":141,"totalPoints":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 String errMsg;
    private boolean success;
    private long sysTime;
    private OrderBean data;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public long getSysTime() {
        return sysTime;
    }

    public void setSysTime(long sysTime) {
        this.sysTime = sysTime;
    }

    public OrderBean getData() {
        return data;
    }

    public void setData(OrderBean data) {
        this.data = data;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public static List<Food> TransFoods(List<OrderBean.OrderDetailsBean> orderDetails) {
        List<Food> foods = new ArrayList<>();
        for (OrderBean.OrderDetailsBean orderDetailsBean : orderDetails) {
            Food food = new Food((long) orderDetailsBean.getId(),
                    Integer.parseInt(orderDetailsBean.getProductId()),
                    orderDetailsBean.getProductName(),
                    orderDetailsBean.getPrice(),
                    orderDetailsBean.getNumber(),
                    orderDetailsBean.getStatus() == 0, orderDetailsBean.getLunchboxPrice());
            foods.add(food);
        }
        return foods;
    }



}
