package org.cs.mgr.order.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Version;
import java.util.HashMap;
import java.math.BigDecimal;
import java.util.Map;
import java.util.Date;
import org.cs.core.model.BaseEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * 推介佣金表 
 * 推介成功佣金记录表
 * @ClassName: MgmOrderCommission 
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:29:03
 */
@Table(name = "mgm_order_commission")
@Entity
@DynamicInsert
@DynamicUpdate
public class MgmOrderCommission extends  BaseEntity {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1865203827840662009L;
	private static final Class<MgmOrderCommission> ENTITY_CLASS = MgmOrderCommission.class;
    
	public MgmOrderCommission()
	{
		
	}

//	/** id  */
//	private Integer id;  
	/** 订单id  */
	private Integer orderId;  
	/** 推介人  */
	private Integer userId;  
	/** 佣金  */
	private Double commission;  
	/** 佣金类型  */
	private String type; 
	/** 佣金状态  */
	private String state;  //0.无效  1.有效
	/** 佣金时间  */
	private java.util.Date finishTime;  


	@Id
	@SequenceGenerator(name="sequenceGenerator",sequenceName="mgm_order_commission_seq")
	@GeneratedValue(generator="sequenceGenerator",strategy=GenerationType.SEQUENCE)
	@Column(name = "id", unique = true, nullable = false, precision = 11, scale = 0)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	
	@Column(name = "order_id", columnDefinition="NUMBER " )
	public Integer getOrderId()
	{
		return orderId;
	}
	
	public void setOrderId(Integer orderId)
	{
		this.orderId= orderId;
	}
	
	
	@Column(name = "user_id", columnDefinition="NUMBER " )
	public Integer getUserId()
	{
		return userId;
	}
	
	public void setUserId(Integer userId)
	{
		this.userId= userId;
	}
	
	
	@Column(name = "commission", columnDefinition="NUMBER(8,2) " )
	public Double getCommission()
	{
		return commission;
	}
	
	public void setCommission(Double commission)
	{
		this.commission= commission;
	}
	
	
	@Column(name = "type", columnDefinition="CHAR(1) " )
	public String getType()
	{
		return type;
	}
	
	public void setType(String type)
	{
		this.type= type;
	}
	
	
	@Column(name = "state", columnDefinition="CHAR(1) " )
	public String getState()
	{
		return state;
	}
	
	public void setState(String state)
	{
		this.state= state;
	}
	
	
	@Column(name = "finish_time", columnDefinition="DATE " )
	public java.util.Date getFinishTime()
	{
		return finishTime;
	}
	
	public void setFinishTime(java.util.Date finishTime)
	{
		this.finishTime= finishTime;
	}
	
	
	 
	public Class entityClass()
	{
		return ENTITY_CLASS;
	}
	
	
 	protected StringBuilder toStringBuilder(StringBuilder sb)
 	{
 		return sb 
		.append(",id=").append(this.id)
		.append(",orderId=").append(this.orderId)
		.append(",userId=").append(this.userId)
		.append(",commission=").append(this.commission)
		.append(",type=").append(this.type)
		.append(",state=").append(this.state)
		.append(",finishTime=").append(this.finishTime)
		.append(",attr1=").append(this.attr1)
		.append(",attr2=").append(this.attr2)
		.append(",attr3=").append(this.attr3)
		.append(",createDate=").append(this.createDate)
		.append(",modifyDate=").append(this.modifyDate)
		.append(",isDelete=").append(this.isDelete)
		;
 	}
 	
 	
 	@Override
	public String toString()
	{
		return toStringBuilder(new StringBuilder().append("MgmOrderCommission[")).append(']').toString();
	}
	 
	
	public Map<String,Object> mapValue()
	{
	    Map<String,Object> map=new HashMap<String,Object>();
	     if(this.id!=null){ map.put("id",this.id);}
	     if(this.orderId!=null){ map.put("orderId",this.orderId);}
	     if(this.userId!=null){ map.put("userId",this.userId);}
	     if(this.commission!=null){ map.put("commission",this.commission);}
	     if(this.type!=null){ map.put("type",this.type);}
	     if(this.state!=null){ map.put("state",this.state);}
	     if(this.finishTime!=null){ map.put("finishTime",this.finishTime);}
		 if(this.attr1 !=null){ map.put("attr1", this.attr1);}
		 if(this.attr2 !=null){ map.put("attr2", this.attr2);}
		 if(this.attr3 !=null){ map.put("attr3", this.attr3);}
		 if(this.createDate != null){ map.put("createDate", this.createDate);}
		 if(this.modifyDate != null){ map.put("modifyDate", this.modifyDate);}
		 if(this.isDelete != null){ map.put("isDelete", this.isDelete);}
		return map;
	}
	
	public void mergeTo(MgmOrderCommission en)
	{
		  if(this.id !=null){ en.setId(this.id);}
		  if(this.orderId !=null){ en.setOrderId(this.orderId);}
		  if(this.userId !=null){ en.setUserId(this.userId);}
		  if(this.commission !=null){ en.setCommission(this.commission);}
		  if(this.type !=null){ en.setType(this.type);}
		  if(this.state !=null){ en.setState(this.state);}
		  if(this.finishTime !=null){ en.setFinishTime(this.finishTime);}
		  if(this.attr1!=null){ en.setAttr1(this.attr1);}
		  if(this.attr2!=null){ en.setAttr2(this.attr2);}
		  if(this.attr3!=null){ en.setAttr3(this.attr3);}
		  if(this.createDate != null){ en.setCreateDate(this.createDate);}
		  if(this.modifyDate != null){ en.setModifyDate(this.modifyDate);}
		  if(this.isDelete != null){ en.setIsDelete(this.isDelete);}
	}
	
  	@Override
  	public void copyFrom(Object obj)
  	{  
  		 if(!(obj instanceof MgmOrderCommission)) {
  	 		super.copyFrom(obj);
  	 	}else {
  	  		MgmOrderCommission bean=(MgmOrderCommission)obj;
			this.setId(bean.getId());
			this.setOrderId(bean.getOrderId());
			this.setUserId(bean.getUserId());
			this.setCommission(bean.getCommission());
			this.setType(bean.getType());
			this.setState(bean.getState());
			this.setFinishTime(bean.getFinishTime());
     	this.setAttr1(bean.getAttr1());
     	this.setAttr2(bean.getAttr2());
     	this.setAttr3(bean.getAttr3());
     	this.setCreateDate(bean.getCreateDate());
     	this.setModifyDate(bean.getModifyDate());
     	this.setIsDelete(bean.getIsDelete());
     	}
 	 }
}
