package com.pj.project.tb_business;

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

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.pj.project.tb_business_car.TbBusinessCar;
import com.pj.project.tb_business_item.TbBusinessItem;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;

import lombok.Data;
import lombok.Getter;
import lombok.experimental.Accessors;

/**
 * Model: tb_business -- 入境登记
 *
 * @author qzy
 */
@Data
@Accessors(chain = true)
@TableName(TbBusiness.TABLE_NAME)
@EqualsAndHashCode(callSuper = false)
public class TbBusiness extends Model<TbBusiness> implements Serializable {

    // ---------- 模块常量 ----------
    /**
     * 序列化版本id
     */
    private static final long serialVersionUID = 1L;
    /**
     * 此模块对应的表名
     */
    public static final String TABLE_NAME = "tb_business";
    /**
     * 此模块对应的权限码
     */
    public static final String PERMISSION_CODE = "tb-business";
    public static final String PERMISSION_LIST = "tb-business-list";
    public static final String PERMISSION_CONFIRM = "tb-business-confirm";
    public static final String PERMISSION_PAY = "tb-business-pay";
    public static final String PERMISSION_INPUT = "tb-business-add";
    public static final String PERMISSION_MANUAL_PAY = "tb-flex-business-pay";



    // ---------- 表中字段 ----------
    /**
     * 主键
     */
    private String id;

    /**
     * 客户id
     */
    private String customerId;
    /**
     * 申报单号
     */
    private String declareNo;

    /**
     * 客户名称
     */
    private String customerName;

    /**
     * 编号
     */
    private String no;

    /**
     * 车牌号
     */
    private String cardNo;
    private String countryName;

    /**
     * 车规格
     */
    private Double cardSize;

    /**
     * 载重(kg)
     */
    private Double netWeight;

    /**
     * 商品
     */
    private String goodsName;

    /**
     * 商品编号
     */
    private String goodsCode;

    /**
     * 司机名称
     */
    private String driverName;

    /**
     * 司机id
     */
    private String driverId;

    /**
     * 司机联系号码
     */
    private String driverPhone;

    /**
     * 司机身份证
     */
    private String driverIdCard;

    /**
     * 支付凭证
     */
    private String payTicket;

    /**
     * 预计进边境日期
     */
    private String expectInDay;

    /**
     * 实际进边境日期
     */
    private Date realInDay;

    /**
     * 实际进境时间
     */
    private Date realInTime;
    /**
     * 入场通道
     */
    private String inChannel;


    /**
     * 支付状态(1=未支付,2=已支付,3=运营人员确认支付,4部分支付)
     */
    private Integer payStatus = 1;

    /**
     * 支付时间
     */
    private Date payTime;

    /**
     * 支付方式(1=线下支付,2现金支付,3=微信支付，4=支付宝支付)
     */
    private Integer payType = 1;
    /**
     * 支付订单号
     */
    private String payNo;
    private String payBy;

    /**
     * 离境时间
     */
    private Date outDayTime;
    /**
     * 出场通道
     */
    private String outChannel;


    /**
     * 停车费用
     */
    private BigDecimal partMoney=new BigDecimal(0);

    private BigDecimal chinaPartMoney=new BigDecimal(0);

    /**
     * 停车时常(分)
     */
    private Long partTime;
    private Long chinaCarPartTime;
    private BigDecimal itemPrice=new BigDecimal(0);
    private BigDecimal payMoney=new BigDecimal(0);
    private BigDecimal totalMoney=new BigDecimal(0);
    private Date createTime;
    private String createBy;
    private Integer confirmInput;
    private Date confirmInputTime;
    private String confirmInputBy;


    private Integer adminConfirmInput;
    private Integer adminConfirmPay;
    private Date adminConfirmPayTime;
    private String adminConfirmPayBy;
    private int adminConfirmOut=0;
    private int adminConfirmIn=0;
    //结账方式（1=现结,2=月结）[j]
    private int customerType;
    private String chinaCarNo;
    private String chinaCarInChannel;
    private String chinaCarOutChannel;
    private Date chinaCarInTime;
    private Date chinaCarOutTime;
    /**
     * 是否完成 0 1
     */
    private Integer complete=0;

    private String nucleicReport;
    private String disinfectReport;
    private String checkReport;
    private String outReport;
    /**
     * 业务类型(1=其他业务,2=整车业务)
     */
    private Integer businessType=2;
    private String itemTypeId;
    private String operator;
    private String operateTime;

    private String businessCarId;

    private String itemTypeName;


    private Integer payStep=2;

    private transient String itemJson;
    private transient String peopleJson;
    private transient String carJson;
    @TableField(exist = false)
    private List<TbBusinessItem> items = new ArrayList<>();
    @TableField(exist = false)
    private List<TbBusinessCar> cars = new ArrayList<>();


    @Getter
    @AllArgsConstructor
    public static enum BusinessType{
        NO_BUSINESS(0,"无业务车辆"),
        CAR_DISINCLE(1,"其他业务"),
        HOLD_CAR(2,"整车业务"),
        ;
        private Integer code;
        private String desc;
    }

    @Getter
    @AllArgsConstructor
   public static enum PayStatus{
        NO_PAY(1,"未支付"),
        HAS_PAY(2,"已支付"),
        HAS_PAY_CONFIRM(3,"已支付已确认"),
        HAS_PAY_PART(4,"已支付"),
        ;
        private int code;
        private String desc;
    }


    public void setCardNo(String cardNo) {
        this.cardNo = StrUtil.isNotEmpty(cardNo)? cardNo.toUpperCase().trim():"";
    }


    public void setChinaCarNo(String chinaCarNo) {
        this.chinaCarNo = StrUtil.isNotEmpty(chinaCarNo)? chinaCarNo.toUpperCase().trim():"";
    }
}
