/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.dm.order.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.modules.system.domain.Dept;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.List;

/**
* @website https://el-admin.vip
* @description /
* @author sunmz
* @date 2021-09-15
**/
@Entity
@Data
@Table(name="dm_order_record")
public class DmOrderRecord implements Serializable {

    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

//    @Column(name = "bh")
//    @ApiModelProperty(value = "订单编号")
//    private String bh;

//    @JoinColumn(name = "id")
//    @ManyToOne(fetch=FetchType.LAZY)
//    @ApiModelProperty(value = "订单编号", hidden = true)
    @OneToMany
    @JoinColumn(name = "bh",referencedColumnName = "bh")
    @ApiModelProperty(value = "订单编号")
    private List<DmOrderItem> orderItems;

    @Column(name = "bh")
    @ApiModelProperty(value = "订单编号")
    private String bh;

    @Column(name = "money")
    @ApiModelProperty(value = "实付金额")
    private String money;

    @Column(name = "mob")
    @ApiModelProperty(value = "用户唯一识别号")
    private String mob;

    @Column(name = "user_code")
    @ApiModelProperty(value = "用户工号")
    private String userCode;

    @Column(name = "user_name")
    @ApiModelProperty(value = "用户姓名")
    private String userName;

    @OneToOne
    @JoinColumn(name = "dept_id")
    @ApiModelProperty(value = "用户部门")
    private Dept dept;

    @Column(name = "user_type")
    @ApiModelProperty(value = "人员种类")
    private String userType;

    @Column(name = "phone")
    @ApiModelProperty(value = "用户手机号")
    private String phone;

    @Column(name = "create_date")
    @ApiModelProperty(value = "下单时间")
    private Timestamp createDate;

    @Column(name = "total_money")
    @ApiModelProperty(value = "合计金额")
    private String totalMoney;

    @Column(name = "zk_money")
    @ApiModelProperty(value = "折扣")
    private String zkMoney;

    @Column(name = "seq")
    @ApiModelProperty(value = "流水号")
    private Long seq;

    @Column(name = "card")
    @ApiModelProperty(value = "卡id")
    private String card;

    @Column(name = "card_no")
    @ApiModelProperty(value = "卡no")
    private String cardNo;

    @Column(name = "part")
    @ApiModelProperty(value = "餐别 1-早餐,2-午餐,3-晚餐,4-夜宵")
    private Integer part;

    @Column(name = "term")
    @ApiModelProperty(value = "终端id")
    private Integer term;

    @Column(name = "shop")
    @ApiModelProperty(value = "餐厅id")
    private Integer shop;

    @Column(name = "term_name")
    @ApiModelProperty(value = "终端名称")
    private String termName;

    @Column(name = "shop_name")
    @ApiModelProperty(value = "餐厅名称")
    private String shopName;

    @Column(name = "amt")
    @ApiModelProperty(value = "金额")
    private Double amt;

    @Column(name = "tel")
    @ApiModelProperty(value = "tel")
    private String tel;

    @Column(name = "card_profile")
    @ApiModelProperty(value = "card_profile")
    private Integer cardProfile;

    @Column(name = "balance")
    @ApiModelProperty(value = "卡余额")
    private Double balance;

    @Column(name = "account")
    @ApiModelProperty(value = "账户类型 0-主账户、1-补贴账户")
    private Integer account;

    @Column(name = "type")
    @ApiModelProperty(value = "支付类型 11-主账户、21-补贴账户、 2-现金、 3-银联、30-扫码支付、31-微信、32-支付宝")
    private Integer type;

    public void copy(DmOrderRecord source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}