package com.tzy.pojo.item.dto;

import com.tzy.pojo.item.OrderList;
import lombok.Data;

import javax.persistence.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class OrderDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id;
    /** 商家id */
    private Long merchantId;
    //商家名称
    private String merchantName;
    //商家头像
    private String avatar;
    /** 订单编码 */
    private String orderNo;
    /** 应付款 */
    private BigDecimal accountsPayable;
    /** 实付款 */
    private BigDecimal actualPayment;
    @Transient
    private String paymentType;
    public String getPaymentType(){
//        if(null== this.paymentType) return "";
        if( "JSAPI".equals(paymentType) || "公众号支付".equals(paymentType)){
//            this.paymentType = "公众号支付";
            this.paymentType = "微信支付";
        }
        if( "NATIVE".equals(paymentType) || "扫码支付".equals(paymentType)){
//            this.paymentType = "扫码支付";
            this.paymentType = "微信支付";
        }
        if( "APP".equals(paymentType) || "APP支付".equals(paymentType)){
//            this.paymentType = "APP支付";
            this.paymentType = "微信支付";
        }
        if( "MICROPAY".equals(paymentType) || "付款码支付".equals(paymentType)){
//            this.paymentType = "付款码支付";
            this.paymentType = "微信支付";
        }
        if( "MWEB".equals(paymentType) || "H5支付".equals(paymentType)){
//            this.paymentType = "H5支付";
            this.paymentType = "微信支付";
        }
        if( "FACEPAY".equals(paymentType) || "刷脸支付".equals(paymentType)){
//            this.paymentType = "刷脸支付";
            this.paymentType = "微信支付";
        }
        if( "JSAPI".equals(paymentType) || "微信支付".equals(paymentType)){
            this.paymentType = "微信支付";
        }
        if( "ALIPAY".equals(paymentType) || "支付宝".equals(paymentType)){
            this.paymentType = "支付宝";
        }
        if( "wxpay".equals(paymentType) || "微信支付".equals(paymentType)){
            this.paymentType = "微信支付";
        }
        return this.paymentType;
    }
    /** 支付流水号 */
    private String paymentNum;
    /** 支付时间 */
    private Date paymentTime;
    /** 优惠券 */
    private Long coupon;
    /** 折扣金额 */
    private BigDecimal discount;
    /** 消耗积分 */
    private Integer point;
    /**
     * 订单状态
     * 100 待支付
     * 101 已支付 待开奖
     * 102 已开奖
     * 103 待发货
     * 104 已发货
     * 105 运货中
     * 106 待收货
     * 201 订单超时 取消
     * 202 用户取消
     * 203 支付失败
     * 204 退款中
     * 205 退款完成
     * 206 退款失败
     * 301 订单完成
     * 302 未中卡
     * 303 订单已关闭
     */
    private Long status;
    /**
     * 状态说明
     */
    @Transient
    private String statusMsg;
    public String getStatusMsg(){
        String cellValue = "";
        Integer status = (this.status == null ? 100 :this.status.intValue());
        if( 100 == status || "待支付".equals(statusMsg)){
            cellValue = "待支付";
        }
        if( 101 == status || "已支付".equals(statusMsg)){
            cellValue = "已支付";
        }
        if( 102 == status || "已开奖".equals(statusMsg)){
            cellValue = "已开奖";
        }
        if( 103 == status || "待发货".equals(statusMsg)){
            cellValue = "待发货";
        }
        if( 104 == status || "已发货".equals(statusMsg)){
            cellValue = "已发货";
        }
        if( 105 == status || "运货中".equals(statusMsg)){
            cellValue = "运货中";
        }
        if( 106 == status || "待收货".equals(statusMsg)){
            cellValue = "待收货";
        }
        if( 201 == status || "订单超时".equals(statusMsg)){
            cellValue = "订单超时";
        }
        if( 202 == status || "用户取消".equals(statusMsg)){
            cellValue = "用户取消";
        }
        if( 203 == status || "支付失败".equals(statusMsg)){
            cellValue = "支付失败";
        }
        if( 204 == status || "退款中".equals(statusMsg)){
            cellValue = "退款中";
        }
        if( 205 == status || "退款完成".equals(statusMsg)){
            cellValue = "退款完成";
        }
        if( 206 == status || "退款失败".equals(statusMsg)){
            cellValue = "退款失败";
        }
        if( 301 == status || "订单完成".equals(statusMsg)){
            cellValue = "订单完成";
        }
        if( 302 == status || "未中卡".equals(statusMsg)){
            cellValue = "未中卡";
        }
        return cellValue;
    }
    //收货联系人
    private String shippingAddressLinkname;
    //收货地址
    private String shippingAddress;
    //收货联系方式
    private String shippingAddressPhone;
    //快递单号
    private String courierNum;
    //快递公司
    private String curierCompany;
    /**仅退款refund_amount,退货退款refund_goods,换货change*/
    private String refundType;
    /**订单退换原因*/
    private String refundReason;
    /**订单评价*/
    private String evaluation;
    /**退换物流公司*/
    private String refundCurierCompany;
    /**退换物流单号*/
    private String refundCurierNum;
    /**退换申请时间*/
    private Date userRefundTime;
    /**1:申请  2同意 3拒绝 ,4退回货物  5商家收到货*/
    private Integer refundStatus;
    /**退换物流时间*/
    private Date refundShipTime;
    private Date shipTime;
    /**
     * 退款金额
     */
    private BigDecimal refundFee;
    //订单type
    private String orderType;
    /**订单交易金额 accountsPayable-discount*/
    private BigDecimal tradeAmount ;
    /**商家拒绝理由*/
    private String merchantRefundReason;
    /**订单明细*/
    @Transient
    private List<OrderList> orderLists;
}
