1 package com.foxinmy.weixin4j.pay.payment.mch;
2
3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.annotation.JSONField;
5
6 import javax.xml.bind.annotation.XmlAccessType;
7 import javax.xml.bind.annotation.XmlAccessorType;
8 import javax.xml.bind.annotation.XmlElement;
9 import javax.xml.bind.annotation.XmlRootElement;
10
11 @XmlRootElement
12 @XmlAccessorType(XmlAccessType.FIELD)
13 public class SceneInfoApp implements SceneInfo {
14
15
16
17 private String type;
18
19
20
21 @XmlElement(name = "wap_name")
22 @JSONField(name = "wap_name")
23 private String name;
24
25
26
27 @XmlElement(name = "wap_url")
28 @JSONField(name = "wap_url")
29 private String path;
30
31 @JSONField(serialize = false)
32 private String sceneInfo;
33
34 protected SceneInfoApp(){
35
36 }
37
38 private SceneInfoApp(String type, String name, String path) {
39 this.type = type;
40 this.name = name;
41 this.path = path;
42 }
43
44 public String getType() {
45 return type;
46 }
47
48 public void setType(String type) {
49 this.type = type;
50 }
51
52 public String getName() {
53 return name;
54 }
55
56 public void setName(String name) {
57 this.name = name;
58 }
59
60 public String getPath() {
61 return path;
62 }
63
64 public void setPath(String path) {
65 this.path = path;
66 }
67
68 @Deprecated
69 public String getSceneInfo() {
70 return sceneInfo;
71 }
72 @Deprecated
73 public void setSceneInfo(String sceneInfo) {
74 this.sceneInfo = sceneInfo;
75 }
76
77
78
79
80
81
82
83
84
85
86 @Deprecated
87 public static SceneInfoApp createIOSAPP(String appName, String bundleId) {
88 SceneInfoApp app = new SceneInfoApp("IOS", appName, bundleId);
89 String sceneInfo = String
90 .format("{\"type\": \"%s\",\"app_name\": \"%s\",\"bundle_id\": \"%s\"}",
91 app.getType(), app.getName(), app.getPath());
92 app.setSceneInfo(sceneInfo);
93 return app;
94 }
95
96
97
98
99
100
101
102
103
104
105 @Deprecated
106 public static SceneInfoApp createAndroidAPP(String appName, String packageName) {
107 SceneInfoApp app = new SceneInfoApp("Android", appName, packageName);
108 String sceneInfo = String
109 .format("{\"type\": \"%s\",\"app_name\": \"%s\",\"package_name\": \"%s\"}",
110 app.getType(), app.getName(), app.getPath());
111 app.setSceneInfo(sceneInfo);
112 return app;
113 }
114
115
116
117
118
119
120
121
122
123
124 public static SceneInfoApp createWapAPP(String name, String url) {
125 SceneInfoApp app = new SceneInfoApp("Wap", name, url);
126 String sceneInfo = String.format(
127 "{\"type\": \"%s\",\"wap_name\": \"%s\",\"wap_url\": \"%s\"}",
128 app.getType(), app.getName(), app.getPath());
129 app.setSceneInfo(sceneInfo);
130 return app;
131 }
132
133 @Override
134 public String toJson() {
135 return String.format("{\"h5_info\": %s}", JSON.toJSONString(this));
136 }
137 }