package com.usoft.fin.grpc.bl.entity.b2b;

import com.alibaba.fastjson.annotation.JSONField;
import com.usoft.fin.grpc.dal.entity.DrawApplyOrderAccept;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 验收单明细
 * @author wangmh
 * @date 2018-08-29 11:38
 **/
public class AcceptItem {
    /**
     * acceptAmount : 16
     * acceptCode : YS18060002
     * acceptDate : 1527850820000
     * acceptQty : 100
     * detno : 1
     * id : 17687
     * isCheck : 已收货
     */

    /**
     * 验收金额
     */
    private double acceptAmount;

    /**
     * 验收单编号
     */
    private String acceptCode;

    /**
     * 验收单日期
     */
    private String acceptDate;

    /**
     * 验收单明细数量
     */
    private int acceptQty;

    /**
     * 验收单明细序号
     */
    private int detno;

    /**
     * 验收单明细id
     */
    private int id;

    /**
     * 验收状态
     */
    private String isCheck;

    /**
     * 订单明细
     */
    private OrderItem orderItem;

    @JSONField(name = "amount")
    public double getAcceptAmount() {
        return acceptAmount;
    }

    public void setAcceptAmount(double acceptAmount) {
        this.acceptAmount = acceptAmount;
    }

    @JSONField(name = "code")
    public String getAcceptCode() {
        return acceptCode;
    }

    public void setAcceptCode(String acceptCode) {
        this.acceptCode = acceptCode;
    }

    @JSONField(name = "acceptDate")
    public String getAcceptDate() {
        return acceptDate;
    }

    public void setAcceptDate(long acceptDate) {
        this.acceptDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(acceptDate));
    }

    public void setAcceptDate(String acceptDate) {
        this.acceptDate = acceptDate;
    }

    public int getAcceptQty() {
        return acceptQty;
    }

    public void setAcceptQty(int acceptQty) {
        this.acceptQty = acceptQty;
    }

    public int getDetno() {
        return detno;
    }

    public void setDetno(int detno) {
        this.detno = detno;
    }

    public int getId() {
        return id;
    }

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

    @JSONField(name = "status")
    public String getIsCheck() {
        return isCheck;
    }

    public void setIsCheck(String isCheck) {
        this.isCheck = isCheck;
    }

    public OrderItem getOrderItem() {
        return orderItem;
    }

    public void setOrderItem(OrderItem orderItem) {
        this.orderItem = orderItem;
    }

    /**
     * 转数据库实体
     * @return
     */
    public DrawApplyOrderAccept toDrawApplyOrderAccept() {
        DrawApplyOrderAccept drawApplyOrderAccept = new DrawApplyOrderAccept();
        drawApplyOrderAccept.setAcceptAmount(this.acceptAmount);
        drawApplyOrderAccept.setAcceptCode(this.acceptCode);
        drawApplyOrderAccept.setAcceptDate(this.acceptDate);
        drawApplyOrderAccept.setAcceptId(this.id);
        drawApplyOrderAccept.setAcceptStatus(this.isCheck);
        drawApplyOrderAccept.setProductCode(this.orderItem.getProductCode());
        drawApplyOrderAccept.setProductCmpcode(this.orderItem.getProductCmpcode());
        drawApplyOrderAccept.setProductSpec(this.orderItem.getProductSpec());
        drawApplyOrderAccept.setProductTitle(this.orderItem.getProductTitle());
        drawApplyOrderAccept.setOrderId(this.orderItem.getOrder().getId());
        drawApplyOrderAccept.setOrderCode(this.orderItem.getOrder().getOrderCode());
        drawApplyOrderAccept.setOrderDate(this.orderItem.getOrder().getDate());
        drawApplyOrderAccept.setOrderTotal(this.orderItem.getOrder().getTotal());
        drawApplyOrderAccept.setOrderItemId(this.orderItem.getId());
        drawApplyOrderAccept.setCustName(this.orderItem.getOrder().getCustName());
        return drawApplyOrderAccept;
    }
}
