View Javadoc
1   package com.zone.weixin4j.mp.event;
2   
3   import com.zone.weixin4j.message.event.EventMessage;
4   import com.zone.weixin4j.type.EventType;
5   
6   import javax.xml.bind.annotation.XmlElement;
7   import javax.xml.bind.annotation.XmlTransient;
8   
9   /**
10   * 扫描二维码事件
11   * 
12   * @className ScanEventMessage
13   * @author jinyu(foxinmy@gmail.com)
14   * @date 2014年4月6日
15   * @since JDK 1.6
16   * @see <a
17   *      href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140454&token=&lang=zh_CN">扫描二维码事件</a>
18   */
19  public class ScanEventMessage extends EventMessage {
20  
21  	private static final long serialVersionUID = 8078674062833071562L;
22  
23  	public ScanEventMessage() {
24  		super(EventType.scan.name());
25  	}
26  
27  	public ScanEventMessage(String eventType) {
28  		super(eventType);
29  	}
30  
31  	/**
32  	 * 事件KEY值,是一个32位无符号整数,即创建二维码时的二维码scene_id
33  	 */
34  	@XmlElement(name = "EventKey")
35  	private String eventKey;
36  	/**
37  	 * 二维码的ticket,可用来换取二维码图片
38  	 */
39  	@XmlElement(name = "Ticket")
40  	private String ticket;
41  
42  	public String getEventKey() {
43  		return eventKey;
44  	}
45  
46  	public String getTicket() {
47  		return ticket;
48  	}
49  
50  	@XmlTransient
51  	public String getParameter() {
52  		return eventKey.replaceFirst("qrscene_", "");
53  	}
54  
55  	@Override
56  	public String toString() {
57  		return "ScanEventMessage [eventKey=" + eventKey + ", ticket=" + ticket
58  				+ ", " + super.toString() + "]";
59  	}
60  }