CouponStock.java

  1. package com.foxinmy.weixin4j.pay.payment.coupon;

  2. import com.alibaba.fastjson.annotation.JSONField;
  3. import com.foxinmy.weixin4j.pay.payment.mch.MerchantResult;
  4. import com.foxinmy.weixin4j.pay.type.mch.CouponStockStatus;
  5. import com.foxinmy.weixin4j.pay.type.mch.CouponType;
  6. import com.foxinmy.weixin4j.util.DateUtil;

  7. import javax.xml.bind.annotation.XmlAccessType;
  8. import javax.xml.bind.annotation.XmlAccessorType;
  9. import javax.xml.bind.annotation.XmlElement;
  10. import javax.xml.bind.annotation.XmlRootElement;
  11. import java.util.Date;

  12. /**
  13.  * 代金券信息
  14.  *
  15.  * @className CouponStock
  16.  * @author jinyu(foxinmy@gmail.com)
  17.  * @date 2015年3月27日
  18.  * @since JDK 1.6
  19.  * @see
  20.  */
  21. @XmlRootElement
  22. @XmlAccessorType(XmlAccessType.FIELD)
  23. public class CouponStock extends MerchantResult {

  24.     private static final long serialVersionUID = -8627202879200080499L;

  25.     /**
  26.      * 代金券批次ID
  27.      */
  28.     @XmlElement(name = "coupon_stock_id")
  29.     @JSONField(name = "coupon_stock_id")
  30.     private String couponStockId;
  31.     /**
  32.      * 代金券名称
  33.      */
  34.     @XmlElement(name = "coupon_name")
  35.     @JSONField(name = "coupon_name")
  36.     private String couponName;
  37.     /**
  38.      * 代金券面额
  39.      */
  40.     @XmlElement(name = "coupon_value")
  41.     @JSONField(name = "coupon_value")
  42.     private int couponValue;
  43.     /**
  44.      * 代金券使用最低限额
  45.      */
  46.     @XmlElement(name = "coupon_mininumn")
  47.     @JSONField(name = "coupon_mininumn")
  48.     private Integer couponMininumn;
  49.     /**
  50.      * 代金券类型:1-代金券无门槛,2-代金券有门槛互斥,3-代金券有门槛叠加
  51.      */
  52.     @XmlElement(name = "coupon_type")
  53.     @JSONField(name = "coupon_type")
  54.     private int couponType;
  55.     /**
  56.      * 批次状态: 1-未激活;2-审批中;4-已激活;8-已作废;16-中止发放;
  57.      */
  58.     @XmlElement(name = "coupon_stock_status")
  59.     @JSONField(name = "coupon_stock_status")
  60.     private int couponStockStatus;
  61.     /**
  62.      * 代金券数量
  63.      */
  64.     @XmlElement(name = "coupon_total")
  65.     @JSONField(name = "coupon_total")
  66.     private int couponTotal;
  67.     /**
  68.      * 代金券每个人最多能领取的数量, 如果为0,则表示没有限制
  69.      */
  70.     @XmlElement(name = "max_quota")
  71.     @JSONField(name = "max_quota")
  72.     private Integer maxQuota;
  73.     /**
  74.      * 代金券锁定数量
  75.      */
  76.     @XmlElement(name = "locked_num")
  77.     @JSONField(name = "locked_num")
  78.     private Integer lockedNum;
  79.     /**
  80.      * 代金券已使用数量
  81.      */
  82.     @XmlElement(name = "used_num")
  83.     @JSONField(name = "used_num")
  84.     private Integer usedNum;
  85.     /**
  86.      * 代金券已经发送的数量
  87.      */
  88.     @XmlElement(name = "is_send_num")
  89.     @JSONField(name = "is_send_num")
  90.     private Integer sendNum;
  91.     /**
  92.      * 生效开始时间 格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
  93.      */
  94.     @XmlElement(name = "begin_time")
  95.     @JSONField(name = "begin_time")
  96.     private String beginTime;
  97.     /**
  98.      * 生效结束时间 格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
  99.      */
  100.     @XmlElement(name = "end_time")
  101.     @JSONField(name = "end_time")
  102.     private String endTime;
  103.     /**
  104.      * 创建时间 格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
  105.      */
  106.     @XmlElement(name = "create_time")
  107.     @JSONField(name = "create_time")
  108.     private String createTime;
  109.     /**
  110.      * 代金券预算额度
  111.      */
  112.     @XmlElement(name = "coupon_budget")
  113.     @JSONField(name = "coupon_budget")
  114.     private Integer couponBudget;

  115.     public CouponStock() {

  116.     }

  117.     public String getCouponStockId() {
  118.         return couponStockId;
  119.     }

  120.     public void setCouponStockId(String couponStockId) {
  121.         this.couponStockId = couponStockId;
  122.     }

  123.     public String getCouponName() {
  124.         return couponName;
  125.     }

  126.     public void setCouponName(String couponName) {
  127.         this.couponName = couponName;
  128.     }

  129.     public int getCouponValue() {
  130.         return couponValue;
  131.     }

  132.     public void setCouponValue(int couponValue) {
  133.         this.couponValue = couponValue;
  134.     }

  135.     /**
  136.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  137.      *
  138.      * @return 元单位
  139.      */
  140.     @JSONField(serialize = false)
  141.     public double getFormatCouponValue() {
  142.         return couponValue / 100d;
  143.     }

  144.     public Integer getCouponMininumn() {
  145.         return couponMininumn;
  146.     }

  147.     public void setCouponMininumn(Integer couponMininumn) {
  148.         this.couponMininumn = couponMininumn;
  149.     }

  150.     /**
  151.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  152.      *
  153.      * @return 元单位
  154.      */
  155.     @JSONField(serialize = false)
  156.     public double getFormatCouponMininumn() {
  157.         return couponMininumn != null ? couponMininumn.intValue() / 100d : 0d;
  158.     }

  159.     public int getCouponType() {
  160.         return couponType;
  161.     }

  162.     @JSONField(serialize = false)
  163.     public CouponType getFormatCouponType() {
  164.         for (CouponType couponType : CouponType.values()) {
  165.             if (couponType.getVal() == this.couponType) {
  166.                 return couponType;
  167.             }
  168.         }
  169.         return null;
  170.     }

  171.     public void setCouponType(int couponType) {
  172.         this.couponType = couponType;
  173.     }

  174.     public int getCouponStockStatus() {
  175.         return couponStockStatus;
  176.     }

  177.     @JSONField(serialize = false)
  178.     public CouponStockStatus getFormatCouponStockStatus() {
  179.         for (CouponStockStatus couponStockStatus : CouponStockStatus.values()) {
  180.             if (couponStockStatus.getVal() == this.couponStockStatus) {
  181.                 return couponStockStatus;
  182.             }
  183.         }
  184.         return null;
  185.     }

  186.     public void setCouponStockStatus(int couponStockStatus) {
  187.         this.couponStockStatus = couponStockStatus;
  188.     }

  189.     public int getCouponTotal() {
  190.         return couponTotal;
  191.     }

  192.     public void setCouponTotal(int couponTotal) {
  193.         this.couponTotal = couponTotal;
  194.     }

  195.     public Integer getMaxQuota() {
  196.         return maxQuota;
  197.     }

  198.     public void setMaxQuota(Integer maxQuota) {
  199.         this.maxQuota = maxQuota;
  200.     }

  201.     /**
  202.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  203.      *
  204.      * @return 元单位
  205.      */
  206.     @JSONField(serialize = false)
  207.     public double getFormatMaxQuota() {
  208.         return maxQuota != null ? maxQuota.intValue() / 100d : 0d;
  209.     }

  210.     public Integer getLockedNum() {
  211.         return lockedNum;
  212.     }

  213.     public void setLockedNum(Integer lockedNum) {
  214.         this.lockedNum = lockedNum;
  215.     }

  216.     /**
  217.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  218.      *
  219.      * @return 元单位
  220.      */
  221.     @JSONField(serialize = false)
  222.     public double getFormatLockedNum() {
  223.         return lockedNum != null ? lockedNum.intValue() / 100d : 0d;
  224.     }

  225.     public Integer getUsedNum() {
  226.         return usedNum;
  227.     }

  228.     public void setUsedNum(Integer usedNum) {
  229.         this.usedNum = usedNum;
  230.     }

  231.     /**
  232.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  233.      *
  234.      * @return 元单位
  235.      */
  236.     @JSONField(serialize = false)
  237.     public double getFormatUsedNum() {
  238.         return usedNum != null ? usedNum.intValue() / 100d : 0d;
  239.     }

  240.     public Integer getSendNum() {
  241.         return sendNum;
  242.     }

  243.     public void setSendNum(Integer sendNum) {
  244.         this.sendNum = sendNum;
  245.     }

  246.     /**
  247.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  248.      *
  249.      * @return 元单位
  250.      */
  251.     @JSONField(serialize = false)
  252.     public double getFormatSendNum() {
  253.         return sendNum != null ? sendNum.intValue() / 100d : 0d;
  254.     }

  255.     public String getBeginTime() {
  256.         return beginTime;
  257.     }

  258.     public void setBeginTime(String beginTime) {
  259.         this.beginTime = beginTime;
  260.     }

  261.     @JSONField(serialize = false)
  262.     public Date getFormatBeginTime() {
  263.         return beginTime != null ? DateUtil.parse2yyyyMMddHHmmss(beginTime)
  264.                 : null;
  265.     }

  266.     public String getEndTime() {
  267.         return endTime;
  268.     }

  269.     public void setEndTime(String endTime) {
  270.         this.endTime = endTime;
  271.     }

  272.     @JSONField(serialize = false)
  273.     public Date getFormatEndTime() {
  274.         return endTime != null ? DateUtil.parse2yyyyMMddHHmmss(endTime) : null;
  275.     }

  276.     public String getCreateTime() {
  277.         return createTime;
  278.     }

  279.     public void setCreateTime(String createTime) {
  280.         this.createTime = createTime;
  281.     }

  282.     @JSONField(serialize = false)
  283.     public Date getFormatCreateTime() {
  284.         return createTime != null ? DateUtil.parse2yyyyMMddHHmmss(createTime)
  285.                 : null;
  286.     }

  287.     public Integer getCouponBudget() {
  288.         return couponBudget;
  289.     }

  290.     public void setCouponBudget(Integer couponBudget) {
  291.         this.couponBudget = couponBudget;
  292.     }

  293.     /**
  294.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  295.      *
  296.      * @return 元单位
  297.      */
  298.     @JSONField(serialize = false)
  299.     public double getFormatCouponBudget() {
  300.         return couponBudget != null ? couponBudget.intValue() / 100d : 0d;
  301.     }

  302.     @Override
  303.     public String toString() {
  304.         return "CouponDetail [couponStockId=" + couponStockId + ", couponName="
  305.                 + couponName + ", couponValue=" + getFormatCouponValue()
  306.                 + ", couponMininumn=" + getFormatCouponMininumn()
  307.                 + ", couponType=" + getFormatCouponType()
  308.                 + ", couponStockStatus=" + getFormatCouponStockStatus()
  309.                 + ", couponTotal=" + couponTotal + ", maxQuota="
  310.                 + getFormatMaxQuota() + ", lockedNum=" + getFormatLockedNum()
  311.                 + ", usedNum=" + getFormatUsedNum() + ", sendNum="
  312.                 + getFormatSendNum() + ", beginTime=" + beginTime
  313.                 + ", endTime=" + endTime + ", createTime=" + createTime
  314.                 + ", couponBudget=" + getFormatCouponBudget() + ", "
  315.                 + super.toString() + "]";
  316.     }
  317. }