CouponStock.java

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

  2. import java.util.Date;

  3. import javax.xml.bind.annotation.XmlAccessType;
  4. import javax.xml.bind.annotation.XmlAccessorType;
  5. import javax.xml.bind.annotation.XmlElement;
  6. import javax.xml.bind.annotation.XmlRootElement;

  7. import com.alibaba.fastjson.annotation.JSONField;
  8. import com.foxinmy.weixin4j.payment.mch.MerchantResult;
  9. import com.foxinmy.weixin4j.type.mch.CouponStockStatus;
  10. import com.foxinmy.weixin4j.type.mch.CouponType;
  11. import com.foxinmy.weixin4j.util.DateUtil;

  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.  * @deprecated 迁移到子模块weixin4j-pay
  21.  */
  22. @Deprecated
  23. @XmlRootElement
  24. @XmlAccessorType(XmlAccessType.FIELD)
  25. public class CouponStock extends MerchantResult {

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

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

  117.     public CouponStock() {

  118.     }

  119.     public String getCouponStockId() {
  120.         return couponStockId;
  121.     }

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

  125.     public int getCouponValue() {
  126.         return couponValue;
  127.     }

  128.     /**
  129.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  130.      *
  131.      * @return 元单位
  132.      */
  133.     @JSONField(serialize = false)
  134.     public double getFormatCouponValue() {
  135.         return couponValue / 100d;
  136.     }

  137.     public Integer getCouponMininumn() {
  138.         return couponMininumn;
  139.     }

  140.     /**
  141.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  142.      *
  143.      * @return 元单位
  144.      */
  145.     @JSONField(serialize = false)
  146.     public double getFormatCouponMininumn() {
  147.         return couponMininumn != null ? couponMininumn.intValue() / 100d : 0d;
  148.     }

  149.     public int getCouponType() {
  150.         return couponType;
  151.     }

  152.     @JSONField(serialize = false)
  153.     public CouponType getFormatCouponType() {
  154.         for (CouponType couponType : CouponType.values()) {
  155.             if (couponType.getVal() == this.couponType) {
  156.                 return couponType;
  157.             }
  158.         }
  159.         return null;
  160.     }

  161.     public int getCouponStockStatus() {
  162.         return couponStockStatus;
  163.     }

  164.     @JSONField(serialize = false)
  165.     public CouponStockStatus getFormatCouponStockStatus() {
  166.         for (CouponStockStatus couponStockStatus : CouponStockStatus.values()) {
  167.             if (couponStockStatus.getVal() == this.couponStockStatus) {
  168.                 return couponStockStatus;
  169.             }
  170.         }
  171.         return null;
  172.     }

  173.     public int getCouponTotal() {
  174.         return couponTotal;
  175.     }

  176.     public Integer getMaxQuota() {
  177.         return maxQuota;
  178.     }

  179.     /**
  180.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  181.      *
  182.      * @return 元单位
  183.      */
  184.     @JSONField(serialize = false)
  185.     public double getFormatMaxQuota() {
  186.         return maxQuota != null ? maxQuota.intValue() / 100d : 0d;
  187.     }

  188.     public Integer getLockedNum() {
  189.         return lockedNum;
  190.     }

  191.     /**
  192.      * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
  193.      *
  194.      * @return 元单位
  195.      */
  196.     @JSONField(serialize = false)
  197.     public double getFormatLockedNum() {
  198.         return lockedNum != null ? lockedNum.intValue() / 100d : 0d;
  199.     }

  200.     public Integer getUsedNum() {
  201.         return usedNum;
  202.     }

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

  212.     public Integer getSendNum() {
  213.         return sendNum;
  214.     }

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

  224.     public String getBeginTime() {
  225.         return beginTime;
  226.     }

  227.     @JSONField(serialize = false)
  228.     public Date getFormatBeginTime() {
  229.         return beginTime != null ? DateUtil.parse2yyyyMMddHHmmss(beginTime)
  230.                 : null;
  231.     }

  232.     public String getEndTime() {
  233.         return endTime;
  234.     }

  235.     @JSONField(serialize = false)
  236.     public Date getFormatEndTime() {
  237.         return endTime != null ? DateUtil.parse2yyyyMMddHHmmss(endTime) : null;
  238.     }

  239.     public String getCreateTime() {
  240.         return createTime;
  241.     }

  242.     @JSONField(serialize = false)
  243.     public Date getFormatCreateTime() {
  244.         return createTime != null ? DateUtil.parse2yyyyMMddHHmmss(createTime)
  245.                 : null;
  246.     }

  247.     public Integer getCouponBudget() {
  248.         return couponBudget;
  249.     }

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

  259.     @Override
  260.     public String toString() {
  261.         return "CouponDetail [couponStockId=" + couponStockId + ", couponName="
  262.                 + couponName + ", couponValue=" + getFormatCouponValue()
  263.                 + ", couponMininumn=" + getFormatCouponMininumn()
  264.                 + ", couponType=" + getFormatCouponType()
  265.                 + ", couponStockStatus=" + getFormatCouponStockStatus()
  266.                 + ", couponTotal=" + couponTotal + ", maxQuota="
  267.                 + getFormatMaxQuota() + ", lockedNum=" + getFormatLockedNum()
  268.                 + ", usedNum=" + getFormatUsedNum() + ", sendNum="
  269.                 + getFormatSendNum() + ", beginTime=" + beginTime
  270.                 + ", endTime=" + endTime + ", createTime=" + createTime
  271.                 + ", couponBudget=" + getFormatCouponBudget() + ", "
  272.                 + super.toString() + "]";
  273.     }
  274. }