package com.lgx8.management.entities;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import org.json.JSONException;
import org.json.JSONObject;
import com.lgx8.common.IGridRow;
import com.lgx8.right.entities.User;
import com.lgx8.util.IdGenerator;
/**
* 充值信息
* @author pengdeyi
*
*/
@Entity
@Table(name="rechargehistory")
public class Rechargehistory implements Serializable,IGridRow {
/**
*
*/
private static final long serialVersionUID = 1L;
public static final int RECHARGEHISTORY_INIT = 0;//正在充值
public static final int RECHARGEHISTORY_OVER = 1;//充值完成
public static final String RECHARGEHISTORY_CZLX_ZFBZ = "01";//支付宝充值
public static final String RECHARGEHISTORY_CZLX_SDCZ = "02";//手动充值
@Id
@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.RECHARGEHISTORY_ID_GENERATOR)
@TableGenerator(
name = IdGenerator.RECHARGEHISTORY_ID_GENERATOR,
table = IdGenerator.GENERATOR_TABLE,
pkColumnName = IdGenerator.GEN_NAME,
pkColumnValue = IdGenerator.RECHARGEHISTORY_ID_GENERATOR,
valueColumnName = IdGenerator.GEN_VALUE,
initialValue = 1,
allocationSize = 1
)
private long ID;
@ManyToOne
@JoinColumn(name="czyhbh")
private User CZYHBH;//充值用户
@ManyToOne
@JoinColumn(name="czsjbh")
private Merchant merchant;//充值商家
private String CZYHLX;//充值用户类型
private double CZJE;//充值金额
private double CZDHJFS;//充值兑换金额数
private Date CZSJ;//充值时间
@ManyToOne
@JoinColumn(name="czqdr")
private User CZQDR;//充值确定人
private Date czqdrq;//充值确定日期
private int czzt;//充值状态
private String BZ;//备注
private String DELETEFLAG;
private String RESERVATION01;//充值类型
private String RESERVATION02;//充值是否返利-----是否手动设置积分数量 01-返利,02-不返利
private String RESERVATION03;
private Date RESERVATION04;
private double RESERVATION05;
public String getBZ() {
return BZ;
}
public void setBZ(String bz) {
BZ = bz;
}
public double getCZDHJFS() {
return CZDHJFS;
}
public void setCZDHJFS(double czdhjfs) {
CZDHJFS = czdhjfs;
}
public double getCZJE() {
return CZJE;
}
public void setCZJE(double czje) {
CZJE = czje;
}
public User getCZQDR() {
return CZQDR;
}
public void setCZQDR(User czqdr) {
CZQDR = czqdr;
}
public Date getCZSJ() {
return CZSJ;
}
public void setCZSJ(Date czsj) {
CZSJ = czsj;
}
public User getCZYHBH() {
return CZYHBH;
}
public void setCZYHBH(User czyhbh) {
CZYHBH = czyhbh;
}
public String getCZYHLX() {
return CZYHLX;
}
public void setCZYHLX(String czyhlx) {
CZYHLX = czyhlx;
}
public String getDELETEFLAG() {
return DELETEFLAG;
}
public void setDELETEFLAG(String deleteflag) {
DELETEFLAG = deleteflag;
}
public long getID() {
return ID;
}
public void setID(long id) {
ID = id;
}
public String getRESERVATION01() {
return RESERVATION01;
}
public void setRESERVATION01(String reservation01) {
RESERVATION01 = reservation01;
}
public String getRESERVATION02() {
return RESERVATION02;
}
public void setRESERVATION02(String reservation02) {
RESERVATION02 = reservation02;
}
public String getRESERVATION03() {
return RESERVATION03;
}
public void setRESERVATION03(String reservation03) {
RESERVATION03 = reservation03;
}
public Date getRESERVATION04() {
return RESERVATION04;
}
public void setRESERVATION04(Date reservation04) {
RESERVATION04 = reservation04;
}
public Merchant getMerchant() {
return merchant;
}
public void setMerchant(Merchant merchant) {
this.merchant = merchant;
}
public double getRESERVATION05() {
return RESERVATION05;
}
public void setRESERVATION05(double reservation05) {
RESERVATION05 = reservation05;
}
public Date getCzqdrq() {
return czqdrq;
}
public void setCzqdrq(Date czqdrq) {
this.czqdrq = czqdrq;
}
public int getCzzt() {
return czzt;
}
public void setCzzt(int czzt) {
this.czzt = czzt;
}
public static String changeToCN(int _type){
if(_type == RECHARGEHISTORY_INIT){
return "充值进行中";
}
if(_type == RECHARGEHISTORY_OVER){
return "充值完成";
}
return null;
}
public static String changetoCN(String _type){
if(_type!=null&&_type.equals(Rechargehistory.RECHARGEHISTORY_CZLX_SDCZ)){
return "手动充值";
}
if(_type!=null&&_type.equals(Rechargehistory.RECHARGEHISTORY_CZLX_ZFBZ)){
return "支付宝充值";
}
return null;
}
public String toJSON(){
JSONObject jObj = new JSONObject();
Merchant _m = getMerchant();
User _czyh = getCZYHBH();
User _u = getCZQDR();
try {
jObj.put("id", getID());
jObj.put("user_id", _czyh!=null?"":_czyh.getId());
jObj.put("user_name", _czyh==null?"":_czyh.getUsername());
jObj.put("merchat_id", _m==null?"":_m.getID());
jObj.put("m_name", _m==null?"":_m.getSJMC());
jObj.put("czlx", changetoCN(getRESERVATION01()));
jObj.put("czje", getCZJE());
jObj.put("dhjf", getCZDHJFS());
jObj.put("czsj", getCZSJ());
jObj.put("czzt", changeToCN(getCzzt()));
jObj.put("czqdr", _u==null?"":_u.getUsername());
jObj.put("czqrrq", getCzqdrq());
} catch (JSONException e) {
e.printStackTrace();
}
return jObj.toString();
}
}