package com.njzscloud.dispose.cst.order.pojo.result;

import com.njzscloud.dispose.cst.customer.constant.SettlementWay;
import com.njzscloud.dispose.cst.order.constant.*;
import com.njzscloud.dispose.finance.constant.ExpenseItemCategory;
import com.njzscloud.dispose.finance.constant.ExpenseStrategy;
import com.njzscloud.dispose.finance.constant.Unit;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 收/销订单
 *
 * @author ljw
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
public class SearchOrderResult {

    /**
     * 主键
     */
    private Long id;

    /**
     * 订单编号
     */
    private String sn;

    /**
     * 项目 Id
     */
    private Long projectId;

    /**
     * 下单人 Id；sys_user.id
     */
    private Long userId;

    /**
     * 下单人客户 Id；cst_customer.id
     */
    private Long customerId;

    /**
     * 下单人姓名
     */
    private String contacts;

    /**
     * 下单人联系方式
     */
    private String phone;

    /**
     * 下单时间
     */
    private LocalDateTime orderTime;

    /**
     * 订单类型；字典代码：order_category，HuiShouYuYue-->回收预约单、XiaoShouYuYue-->销售预约单、DuanBoRu-->短驳入、DuanBoChu-->短驳出
     */
    private OrderCategory orderCategory;

    /**
     * 订单状态；字典代码：order_status，YiYuYue-->已预约、JinXingZhong-->进行中、YiWanCheng-->已完成、YiQuXiao-->已取消
     */
    private OrderStatus orderStatus;

    /**
     * 完结时间
     */
    private LocalDateTime finishTime;

    /**
     * 运输组织 Id；cst_org.id
     */
    private Long transOrgId;

    /**
     * 运输方客户 Id
     */
    private Long transCustomerId;

    /**
     * 指派清运公司时间
     */
    private LocalDateTime assignmentTransTime;

    /**
     * 站点 Id；cst_station.id
     */
    private Long stationId;

    /**
     * 站点名称；cst_station.station.name
     */
    private String stationName;

    /**
     * 运距；单位：米
     */
    private Integer transDistance;

    /**
     * 预估量
     */
    private Integer estimatedQuantity;

    /**
     * 预估车数
     */
    private Integer estimatedTrainNum;

    /**
     * 产品 Id
     */
    private Long goodsId;

    /**
     * 产品名称
     */
    private String goodsName;
    private String goodsPicture;

    /**
     * 计量单位；字典代码：unit
     */
    private Unit unit;

    /**
     * 客户备注
     */
    private String customerMemo;
    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    private List<TransRecode> transRecodes;
    private CargoPlace cargoPlace;
    private ProjectInfo projectInfo;

    @Getter
    @Setter
    @ToString
    @Accessors(chain = true)
    public static class PaymentRecord {
        private Long id;
        private Long orderId;
        private Long expenseItemId;
        private Long transId;
        private BigDecimal quantity;
        private PaymentStatus paymentStatus;
        private LocalDateTime payTime;
        private LocalDateTime refundTime;
        private BigDecimal totalMoney;
        private BigDecimal discountMoney;
        private BigDecimal reviseMoney;
        private BigDecimal settleMoney;
        private SettlementWay settlementWay;
        private Long payerUserId;
        private Long payerCustomerId;
        private Long payerMoneyAccountId;
        private ExpenseItemCategory expenseItemCategory;
        private String goodsId;
        private String expenseItemName;
        private ExpenseStrategy expenseStrategy;
        private Unit unit;
        private BigDecimal taxRate;
        private BigDecimal unitPrice;
        private BigDecimal initialPrice;
        private Integer initialQuantity;
        private Integer everyQuantity;
    }

    @Getter
    @Setter
    @ToString
    @Accessors(chain = true)
    public static class TransRecode {
        private Long id;

        /**
         * 车次
         */
        private Integer trainNum;

        /**
         * 订单 Id
         */
        private Long orderId;

        /**
         * 运输状态；字典代码：trans_status，DaiPaiDan-->待派单、DaiJieDan-->待接单、YiJieDan-->已接单、YunShuZhong-->运输中、YiJinChang-->已进场、YiChuChang-->已出场、YiWanCheng-->已完成、YiQuXiao-->已取消
         */
        private TransStatus transStatus;

        /**
         * 车道名称
         */
        private String lane;

        /**
         * 指派司机时间
         */
        private LocalDateTime assignmentDriverTime;

        /**
         * 司机确认接单时间
         */
        private LocalDateTime driverConfirmTime;

        /**
         * 开始运输时间
         */
        private LocalDateTime transTime;

        /**
         * 完结时间
         */
        private LocalDateTime finishTime;

        /**
         * 看料员 Id；sys_user.id
         */
        private Long checkerId;

        /**
         * 勘料状态；字典代码：check_status，Wu-->无需勘料、YiKanLiao-->已勘料、WeiKanLiao-->未勘料
         */
        private CheckStatus checkStatus;

        /**
         * 勘料时间
         */
        private LocalDateTime checkTime;

        /**
         * 勘料照片
         */
        private List<String> checkPhoto;

        /**
         * 勘料员备注
         */
        private String checkerMemo;

        /**
         * 司机 Id
         */
        private Long driverId;

        /**
         * 司机所属客户 Id；cst_customer.id
         */
        private Long driverCustomerId;

        /**
         * 司机所属用户 Id
         */
        private Long driverUserId;
        private String driverName;
        private String driverPhone;
        /**
         * 归属客户 Id；cst_customer.id
         */
        private Long truckCustomerId;

        /**
         * 归属组织
         */
        private Long truckOrgId;

        /**
         * 车辆 Id
         */
        private Long truckId;

        /**
         * 车牌号
         */
        private String truckLicensePlate;

        /**
         * 历史皮重
         */
        private Integer historyTareWeight;

        /**
         * 毛重；单位：千克
         */
        private Integer roughWeight;

        /**
         * 皮重；单位：千克
         */
        private Integer tareWeight;

        /**
         * 净重；单位：千克
         */
        private Integer settleWeight;

        /**
         * 运距；单位：米
         */
        private Integer transDistance;

        /**
         * 进场车头照片
         */
        private String inFrontPhoto;

        /**
         * 进场车斗照片
         */
        private String inBodyPhoto;

        /**
         * 出场车头照片
         */
        private String outFrontPhoto;

        /**
         * 出场车斗照片
         */
        private String outBodyPhoto;

        /**
         * 进场时间
         */
        private LocalDateTime inTime;

        /**
         * 出场时间
         */
        private LocalDateTime outTime;
        private List<PaymentRecord> paymentRecord;
    }

    @Getter
    @Setter
    @ToString
    @Accessors(chain = true)
    public static class CargoPlace {
        private Long id;

        /**
         * 订单 Id
         */
        private Long orderId;

        /**
         * 装/卸货，ZhuangHuo-->装货地址、XieHuo-->卸货地址
         */
        private String zx;

        /**
         * 省；代码
         */
        private String province;

        /**
         * 市；代码
         */
        private String city;

        /**
         * 区县；代码
         */
        private String area;

        /**
         * 乡镇街道；代码
         */
        private String town;

        /**
         * 省；名称
         */
        private String provinceName;

        /**
         * 市；名称
         */
        private String cityName;

        /**
         * 区县；名称
         */
        private String areaName;

        /**
         * 乡镇街道；名称
         */
        private String townName;

        /**
         * 详细地址
         */
        private String address;

        /**
         * 经度
         */
        private Double lng;

        /**
         * 纬度
         */
        private Double lat;
    }

    @Getter
    @Setter
    @ToString
    @Accessors(chain = true)
    public static class ProjectInfo {
        private Long id;

        /**
         * 项目名称
         */
        private String projectName;

        /**
         * 合同图片
         */
        private String contractPicture;

        /**
         * 运输方客户 Id
         */
        private Long transCustomerId;

        /**
         * 运输方组织 Id
         */
        private Long transOrgId;

        /**
         * 产废方/购买方客户 Id
         */
        private Long fringeCustomerId;

        /**
         * 产废方/购买方组织 Id
         */
        private Long fringeOrgId;

        /**
         * 省；代码
         */
        private String province;

        /**
         * 市；代码
         */
        private String city;

        /**
         * 区县；代码
         */
        private String area;

        /**
         * 乡镇街道；代码
         */
        private String town;

        /**
         * 省；名称
         */
        private String provinceName;

        /**
         * 市；名称
         */
        private String cityName;

        /**
         * 区县；名称
         */
        private String areaName;

        /**
         * 乡镇街道；名称
         */
        private String townName;

        /**
         * 详细地址
         */
        private String address;

        /**
         * 经度
         */
        private Double lng;

        /**
         * 纬度
         */
        private Double lat;

        /**
         * 合同有效期
         */
        private LocalDate contractStartDate;

        /**
         * 合同有效期
         */
        private LocalDate contractEndDate;
    }
}


