package com.neusoft.smart.pos.dto.trade.response;

import com.neusoft.smart.pos.framework.bean.PaginationExtendBean;
import com.neusoft.smart.pos.framework.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

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

/**
 * @author zcf
 * @date 2018-02-28 16：20
 * @description 商户未结算信息查询使用Response
 */
@Data
@ApiModel
@NoArgsConstructor
public class GetBillDetailsResponse implements Serializable {
    
    @ApiModelProperty(name = "paginationExtendBean", value = "账单明细分页数据", dataType = "Object")
    public PaginationExtendBean<BillDetailsData> paginationExtendBean;
    
    @Data
    @ApiModel
    public static class BillDetailsData{
        @ApiModelProperty(name = "id", value = "主键", dataType = "int")
        private Integer id;
        
        @ApiModelProperty(name = "billNumber", value = "账单编号", dataType = "String")
        private String billNumber;
        
        @ApiModelProperty(name = "orderNumber", value = "订单编号", dataType = "String")
        private String orderNumber;
        
        @ApiModelProperty(name = "orgId", value = "集团ID", dataType = "int")
        private Integer orgId;
        
        @ApiModelProperty(name = "shopId", value = "门店ID", dataType = "int")
        private Integer shopId;
    
        @ApiModelProperty(name = "shopName", value = "门店名称", dataType = "String")
        private String shopName;
        
        @ApiModelProperty(name = "serialNo", value = "设备序列号", dataType = "String")
        private String serialNo;
        
        @ApiModelProperty(name = "deviceName", value = "设备名称", dataType = "String")
        private String deviceName;
        
        @ApiModelProperty(name = "customerNumber", value = "操作员编号", dataType = "String")
        private String customerNumber;
        
        @ApiModelProperty(name = "seqNo", value = "订单序号", dataType = "int")
        private Integer seqNo;
        
        @ApiModelProperty(name = "memberCardNo", value = "会员卡号、东软员工号", dataType = "String")
        private String memberCardNo;
        
        @ApiModelProperty(name = "memberName", value = "会员名称、员工姓名", dataType = "String")
        private String memberName;
        
        @ApiModelProperty(name = "cardNum", value = "会员卡编号(印刷,沈阳食堂使用)", dataType = "String")
        private String cardNum;
        
        @ApiModelProperty(name = "orderAmount", value = "订单应付金额(实付金额+折扣金额)", dataType = "String")
        private String orderAmount;
        
        @ApiModelProperty(name = "realPayAmount", value = "订单实付金额", dataType = "String")
        private String realPayAmount;
        
        @ApiModelProperty(name = "discountAmount", value = "折扣金额", dataType = "String")
        private String discountAmount;
        
        @ApiModelProperty(name = "payType", value = "付款方式编号", dataType = "String")
        private String payType;
    
        @ApiModelProperty(name = "payTypeName", value = "付款方式名称", dataType = "String")
        private String payTypeName;
        
        @ApiModelProperty(name = "paidTime", value = "支付完成时间", dataType = "long")
        private Long paidTime;
        
        @ApiModelProperty(name = "orderType", value = "订单类型@1正常订单@2POS端补录订单@3会员卡充值订单@4微信点餐订单@5饿了么订单", dataType = "String")
        private String orderType;
    
        @ApiModelProperty(name = "orderTypeName", value = "订单类型名称", dataType = "String")
        private String orderTypeName;
        
        @ApiModelProperty(name = "locationNo", value = "位置编号(如桌号等)", dataType = "String")
        private String locationNo;
        
        @ApiModelProperty(name = "retrvlRefNo", value = "原交易参考号(银行卡支付专用)", dataType = "String")
        private String retrvlRefNo;
        
        @ApiModelProperty(name = "oriTraceNo", value = "原交易凭证号(银行卡支付专用)", dataType = "String")
        private String oriTraceNo;
        
        @ApiModelProperty(name = "transDate", value = "交易日期(银行卡支付专用)", dataType = "String")
        private String transDate;
        
        @ApiModelProperty(name = "oriBatchNo", value = "原批次号(银行卡支付专用)", dataType = "String")
        private String oriBatchNo;
        
        @ApiModelProperty(name = "score", value = "订单获赠积分", dataType = "int")
        private Integer score;
    
        @ApiModelProperty(name = "remark", value = "备注", dataType = "String")
        private String remark;
        
        @ApiModelProperty(name = "createdAt", value = "创建时间", dataType = "long")
        private Long createdAt;
        
        @ApiModelProperty(name = "updatedAt", value = "更新时间", dataType = "long")
        private Long updatedAt;
    
        @ApiModelProperty(name = "billSubjectDetailList", value = "订单分润列表", dataType = "list")
        private List<BillSubjectDetail> billSubjectDetailList = new ArrayList<>();
        
        public void setOrderAmount(BigDecimal orderAmount) {
            this.orderAmount = StringUtils.roundByScale(orderAmount,2);
        }
        
        public void setRealPayAmount(BigDecimal realPayAmount) {
            this.realPayAmount = StringUtils.roundByScale(realPayAmount,2);
        }
        
        public void setDiscountAmount(BigDecimal discountAmount) {
            this.discountAmount = StringUtils.roundByScale(discountAmount,2);
        }
        
        public void setPaidTime(Date paidTime) {
            this.paidTime = paidTime.getTime();
        }
        
        public void setCreatedAt(Date createdAt) {
            this.createdAt = createdAt.getTime();
        }
        
        public void setUpdatedAt(Date updatedAt) {
            this.updatedAt = updatedAt.getTime();
        }
    }
    
    @Data
    @ApiModel
    public static class BillSubjectDetail{
        
        @ApiModelProperty(name = "subjectName", value = "分润主体名称", dataType = "String" ,example="微信支付")
        public String subjectName;
        
        @ApiModelProperty(name = "profitAmount", value = "分润金额", dataType = "String" ,example="198.22")
        public String profitAmount = "0.00";
        
        @ApiModelProperty(name = "profitRate", value = "分润比例", dataType = "BigDecimal" ,example="10")
        public BigDecimal profitRate = BigDecimal.ZERO;
        
        public void setProfitAmount(BigDecimal profitAmount) {
            this.profitAmount = StringUtils.roundByScale(profitAmount,2);
        }
    }
}