package cn.pluss.platform.vo;

import cn.pluss.platform.entity.MerchantOrderSplit;
import cn.pluss.platform.entity.MerchantOrderSplitDetail;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * TODO
 * 分账返回参数封装
 * @author crystal
 * @date 2022/7/14 10:03
 */
@Data
@NoArgsConstructor
public class SplitOrderVo  implements Serializable {

    private String merchantCode;

    private String merchantName;

    private String divisionMode;

    private String orderNumber;

    private String mercOrderNo;
    
    private Integer divStatus;

    private String orderAmt;

    private String remark;

    private String sign;

    private List<SplitOrderDetailVo> detailList;

    public SplitOrderVo(MerchantOrderSplit order, List<MerchantOrderSplitDetail> splitDetailList) {
        this.setMerchantCode(order.getMerchantCode());
        this.setMerchantName(order.getMerchantName());
        this.setDivisionMode(order.getDivisionMode());
        this.setOrderNumber(order.getOrderNumber());
        this.setMercOrderNo(order.getMercOrderNo());
        this.setDivStatus(order.getDivStatus());
        this.setOrderAmt(order.getOrderAmt().toString());
        this.setRemark(order.getRemark());
        if(!splitDetailList.isEmpty()){
            List<SplitOrderDetailVo> list = new ArrayList<>(splitDetailList.size());
            for (MerchantOrderSplitDetail detail:splitDetailList) {
                SplitOrderDetailVo vo = new SplitOrderDetailVo(detail);
                list.add(vo);
            }
            this.setDetailList(list);
        }
    }
}
