|
@@ -12,6 +12,8 @@ import me.chanjar.weixin.mp.api.WxMpService;
|
12
|
12
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
13
|
13
|
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
14
|
14
|
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
|
15
|
+import org.slf4j.Logger;
|
|
16
|
+import org.slf4j.LoggerFactory;
|
15
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
18
|
import org.springframework.web.bind.annotation.*;
|
17
|
19
|
|
|
@@ -37,18 +39,19 @@ public class WxRedpackController {
|
37
|
39
|
|
38
|
40
|
/**
|
39
|
41
|
* 换取openid接口并插入公众号人员表
|
|
42
|
+ *
|
40
|
43
|
* @param mpAppid
|
41
|
44
|
* @param code
|
42
|
45
|
* @param request
|
43
|
46
|
* @return
|
44
|
47
|
*/
|
45
|
48
|
@GetMapping("/third/redirect/{mpAppid}/greet")
|
46
|
|
- public ResponseBean greetUser(@PathVariable String mpAppid, @RequestParam String code, @RequestParam String personId,@RequestParam(required = false) String sponsorPersonId,@RequestParam String drainageId, HttpServletRequest request) {
|
|
49
|
+ public ResponseBean greetUser(@PathVariable String mpAppid, @RequestParam String code, @RequestParam String personId, @RequestParam(required = false) String sponsorPersonId, @RequestParam String drainageId, HttpServletRequest request) {
|
47
|
50
|
WxMpService wxService = getWxMpService();
|
48
|
51
|
if (!wxService.switchover(mpAppid)) {
|
49
|
52
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
50
|
53
|
}
|
51
|
|
- Map<String,Object> map = new HashMap<>();
|
|
54
|
+ Map<String, Object> map = new HashMap<>();
|
52
|
55
|
try {
|
53
|
56
|
//换取openid
|
54
|
57
|
WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
|
|
@@ -56,7 +59,7 @@ public class WxRedpackController {
|
56
|
59
|
map = iTaThirdPartyMiniappConfigService.newMpPerson(accessToken, mpAppid, drainageId, sponsorPersonId, personId);
|
57
|
60
|
} catch (WxErrorException e) {
|
58
|
61
|
// e.printStackTrace();
|
59
|
|
- return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
|
62
|
+ return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
|
60
|
63
|
}
|
61
|
64
|
return ResponseBean.success(map);
|
62
|
65
|
}
|
|
@@ -83,77 +86,81 @@ public class WxRedpackController {
|
83
|
86
|
|
84
|
87
|
/**
|
85
|
88
|
* 根据personid查询这个人需要的信息
|
|
89
|
+ *
|
86
|
90
|
* @param mpAppid
|
87
|
91
|
* @param request
|
88
|
92
|
* @return
|
89
|
93
|
*/
|
90
|
94
|
@GetMapping("/third/activity/{mpAppid}/personInfo")
|
91
|
|
- public ResponseBean getPersonInfo(@PathVariable String mpAppid, @RequestParam String personId,@RequestParam String drainageId, HttpServletRequest request) {
|
|
95
|
+ public ResponseBean getPersonInfo(@PathVariable String mpAppid, @RequestParam String personId, @RequestParam String drainageId, HttpServletRequest request) {
|
92
|
96
|
WxMpService wxService = getWxMpService();
|
93
|
97
|
if (!wxService.switchover(mpAppid)) {
|
94
|
98
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
95
|
99
|
}
|
96
|
|
- Map<String,Object> map = new HashMap<>();
|
|
100
|
+ Map<String, Object> map = new HashMap<>();
|
97
|
101
|
try {
|
98
|
102
|
//插入公众号人员信息并插入表
|
99
|
103
|
map = iTaThirdPartyMiniappConfigService.getPersonInfo(mpAppid, drainageId, personId);
|
100
|
104
|
} catch (Exception e) {
|
101
|
105
|
e.printStackTrace();
|
102
|
|
- return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
|
106
|
+ return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
|
103
|
107
|
}
|
104
|
108
|
return ResponseBean.success(map);
|
105
|
109
|
}
|
106
|
110
|
|
107
|
111
|
/**
|
108
|
112
|
* 我要参加 活动接口
|
|
113
|
+ *
|
109
|
114
|
* @param mpAppid
|
110
|
115
|
* @param personId
|
111
|
116
|
* @param request
|
112
|
117
|
* @return
|
113
|
118
|
*/
|
114
|
119
|
@PostMapping("/third/activity/{mpAppid}/participate")
|
115
|
|
- public ResponseBean participateActivity(@PathVariable String mpAppid, @RequestParam String personId,@RequestParam String drainageId, HttpServletRequest request) {
|
|
120
|
+ public ResponseBean participateActivity(@PathVariable String mpAppid, @RequestParam String personId, @RequestParam String drainageId, HttpServletRequest request) {
|
116
|
121
|
WxMpService wxService = getWxMpService();
|
117
|
122
|
if (!wxService.switchover(mpAppid)) {
|
118
|
123
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
119
|
124
|
}
|
120
|
125
|
try {
|
121
|
|
- ResponseBean res = iTaThirdPartyMiniappConfigService.participateActivity(mpAppid,personId,drainageId);
|
|
126
|
+ ResponseBean res = iTaThirdPartyMiniappConfigService.participateActivity(mpAppid, personId, drainageId);
|
122
|
127
|
return res;
|
123
|
|
- }catch (Exception e){
|
|
128
|
+ } catch (Exception e) {
|
124
|
129
|
e.printStackTrace();
|
125
|
|
- return ResponseBean.error("程序出错请联系运营人员",ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
130
|
+ return ResponseBean.error("程序出错请联系运营人员", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
126
|
131
|
}
|
127
|
132
|
}
|
128
|
133
|
|
129
|
134
|
/**
|
130
|
135
|
* 帮他助力 接口
|
|
136
|
+ *
|
131
|
137
|
* @param mpAppid
|
132
|
138
|
* @param personId
|
133
|
139
|
* @param request
|
134
|
140
|
* @return
|
135
|
141
|
*/
|
136
|
142
|
@PostMapping("/third/activity/{mpAppid}/help")
|
137
|
|
- public ResponseBean helpActivity(@PathVariable String mpAppid, @RequestParam String personId, @RequestParam String sponsorPersonId,@RequestParam String drainageId, HttpServletRequest request) {
|
|
143
|
+ public ResponseBean helpActivity(@PathVariable String mpAppid, @RequestParam String personId, @RequestParam String sponsorPersonId, @RequestParam String drainageId, HttpServletRequest request) {
|
138
|
144
|
WxMpService wxService = getWxMpService();
|
139
|
145
|
if (!wxService.switchover(mpAppid)) {
|
140
|
146
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
141
|
147
|
}
|
142
|
|
- if (personId.equals(sponsorPersonId)){
|
143
|
|
- return ResponseBean.error("自己不能助力自己",ResponseBean.ERROR_UNAVAILABLE);
|
|
148
|
+ if (personId.equals(sponsorPersonId)) {
|
|
149
|
+ return ResponseBean.error("自己不能助力自己", ResponseBean.ERROR_UNAVAILABLE);
|
144
|
150
|
}
|
145
|
151
|
|
146
|
152
|
try {
|
147
|
153
|
ResponseBean res = iTaThirdPartyMiniappConfigService.helpActivity(mpAppid, personId, sponsorPersonId, drainageId);
|
148
|
154
|
return res;
|
149
|
|
- }catch (Exception e){
|
|
155
|
+ } catch (Exception e) {
|
150
|
156
|
e.printStackTrace();
|
151
|
|
- return ResponseBean.error("程序出错请联系运营人员",ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
157
|
+ return ResponseBean.error("程序出错请联系运营人员", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
152
|
158
|
}
|
153
|
159
|
}
|
154
|
160
|
|
155
|
161
|
/**
|
156
|
162
|
* 获取此活动的排行榜
|
|
163
|
+ *
|
157
|
164
|
* @param drainageId
|
158
|
165
|
* @param request
|
159
|
166
|
* @return
|
|
@@ -165,7 +172,7 @@ public class WxRedpackController {
|
165
|
172
|
return iTaThirdPartyMiniappConfigService.getRanking(drainageId);
|
166
|
173
|
} catch (Exception e) {
|
167
|
174
|
// e.printStackTrace();
|
168
|
|
- return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
|
175
|
+ return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
|
169
|
176
|
}
|
170
|
177
|
}
|
171
|
178
|
}
|