package com.warewms.common.entity.kingdee.form;

import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang.StringUtils;

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

/**
 * Created by IntelliJ IDEA.
 * User: andy.qu
 * Date: 2019/9/12
 */
@Getter
@Setter
public class OrderForm implements Serializable {
    private String warehouseId;
    private String customerId;
    private String orderNo;
    private String orderCode;
    private String orderType;
    private String carrierId;//配送方式 和 WMS 的carrierid不匹配，先这样吧   WMS.doc_order_header.route
    private String expressCompany;//快递/物流公司   WMS.doc_order_header.carrierid
    private String settlementType;//结算方式  WMS.doc_order_header.stop
    private String name;
    private String postcode;
    private String phone;
    private String mobile;
    private String prov;
    private String city;
    private String district;
    private String address;
    private String remark;
    private String userdefine1;
    private String userdefine2;
    private String userdefine3;
    private String userdefine4;
    private String userdefine5;
    private String userdefine6;
    private String supplierid;

    private List<ItemForm> itemList;

    public String getUserdefine1(boolean split) {
        if (split) {
            if (StringUtils.isEmpty(userdefine1) || userdefine1.length() < 2) {
                return userdefine1;
            }
            if (userdefine1.contains("&")) {

                String[] array = userdefine1.split("&");
                if (array.length > 1) {
                    String primaryKey = array[0];
                    return primaryKey.substring(2);
                } else {
                    return userdefine1;
                }
            } else {

                return userdefine1.substring(2);
            }
        } else {
            return userdefine1;
        }
    }
}