|
|
|
|
12
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
12
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
13
|
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
13
|
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
14
|
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
14
|
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
|
|
15
|
+import org.slf4j.Logger;
|
|
|
16
|
+import org.slf4j.LoggerFactory;
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
import org.springframework.web.bind.annotation.*;
|
18
|
import org.springframework.web.bind.annotation.*;
|
17
|
|
19
|
|
|
|
|
|
37
|
|
39
|
|
38
|
/**
|
40
|
/**
|
39
|
* 换取openid接口并插入公众号人员表
|
41
|
* 换取openid接口并插入公众号人员表
|
|
|
42
|
+ *
|
40
|
* @param mpAppid
|
43
|
* @param mpAppid
|
41
|
* @param code
|
44
|
* @param code
|
42
|
* @param request
|
45
|
* @param request
|
43
|
* @return
|
46
|
* @return
|
44
|
*/
|
47
|
*/
|
45
|
@GetMapping("/third/redirect/{mpAppid}/greet")
|
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
|
WxMpService wxService = getWxMpService();
|
50
|
WxMpService wxService = getWxMpService();
|
48
|
if (!wxService.switchover(mpAppid)) {
|
51
|
if (!wxService.switchover(mpAppid)) {
|
49
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
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
|
try {
|
55
|
try {
|
53
|
//换取openid
|
56
|
//换取openid
|
54
|
WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
|
57
|
WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
|
|
|
|
|
56
|
map = iTaThirdPartyMiniappConfigService.newMpPerson(accessToken, mpAppid, drainageId, sponsorPersonId, personId);
|
59
|
map = iTaThirdPartyMiniappConfigService.newMpPerson(accessToken, mpAppid, drainageId, sponsorPersonId, personId);
|
57
|
} catch (WxErrorException e) {
|
60
|
} catch (WxErrorException e) {
|
58
|
// e.printStackTrace();
|
61
|
// e.printStackTrace();
|
59
|
- return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
|
|
|
|
62
|
+ return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
|
60
|
}
|
63
|
}
|
61
|
return ResponseBean.success(map);
|
64
|
return ResponseBean.success(map);
|
62
|
}
|
65
|
}
|
|
|
|
|
83
|
|
86
|
|
84
|
/**
|
87
|
/**
|
85
|
* 根据personid查询这个人需要的信息
|
88
|
* 根据personid查询这个人需要的信息
|
|
|
89
|
+ *
|
86
|
* @param mpAppid
|
90
|
* @param mpAppid
|
87
|
* @param request
|
91
|
* @param request
|
88
|
* @return
|
92
|
* @return
|
89
|
*/
|
93
|
*/
|
90
|
@GetMapping("/third/activity/{mpAppid}/personInfo")
|
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
|
WxMpService wxService = getWxMpService();
|
96
|
WxMpService wxService = getWxMpService();
|
93
|
if (!wxService.switchover(mpAppid)) {
|
97
|
if (!wxService.switchover(mpAppid)) {
|
94
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
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
|
try {
|
101
|
try {
|
98
|
//插入公众号人员信息并插入表
|
102
|
//插入公众号人员信息并插入表
|
99
|
map = iTaThirdPartyMiniappConfigService.getPersonInfo(mpAppid, drainageId, personId);
|
103
|
map = iTaThirdPartyMiniappConfigService.getPersonInfo(mpAppid, drainageId, personId);
|
100
|
} catch (Exception e) {
|
104
|
} catch (Exception e) {
|
101
|
e.printStackTrace();
|
105
|
e.printStackTrace();
|
102
|
- return ResponseBean.error(e.getMessage(),ResponseBean.ERROR_UNAVAILABLE);
|
|
|
|
|
106
|
+ return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
|
103
|
}
|
107
|
}
|
104
|
return ResponseBean.success(map);
|
108
|
return ResponseBean.success(map);
|
105
|
}
|
109
|
}
|
106
|
|
110
|
|
107
|
/**
|
111
|
/**
|
108
|
* 我要参加 活动接口
|
112
|
* 我要参加 活动接口
|
|
|
113
|
+ *
|
109
|
* @param mpAppid
|
114
|
* @param mpAppid
|
110
|
* @param personId
|
115
|
* @param personId
|
111
|
* @param request
|
116
|
* @param request
|
112
|
* @return
|
117
|
* @return
|
113
|
*/
|
118
|
*/
|
114
|
@PostMapping("/third/activity/{mpAppid}/participate")
|
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
|
WxMpService wxService = getWxMpService();
|
121
|
WxMpService wxService = getWxMpService();
|
117
|
if (!wxService.switchover(mpAppid)) {
|
122
|
if (!wxService.switchover(mpAppid)) {
|
118
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
123
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
119
|
}
|
124
|
}
|
120
|
try {
|
125
|
try {
|
121
|
- ResponseBean res = iTaThirdPartyMiniappConfigService.participateActivity(mpAppid,personId,drainageId);
|
|
|
|
|
126
|
+ ResponseBean res = iTaThirdPartyMiniappConfigService.participateActivity(mpAppid, personId, drainageId);
|
122
|
return res;
|
127
|
return res;
|
123
|
- }catch (Exception e){
|
|
|
|
|
128
|
+ } catch (Exception e) {
|
124
|
e.printStackTrace();
|
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
|
* @param mpAppid
|
137
|
* @param mpAppid
|
132
|
* @param personId
|
138
|
* @param personId
|
133
|
* @param request
|
139
|
* @param request
|
134
|
* @return
|
140
|
* @return
|
135
|
*/
|
141
|
*/
|
136
|
@PostMapping("/third/activity/{mpAppid}/help")
|
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
|
WxMpService wxService = getWxMpService();
|
144
|
WxMpService wxService = getWxMpService();
|
139
|
if (!wxService.switchover(mpAppid)) {
|
145
|
if (!wxService.switchover(mpAppid)) {
|
140
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
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
|
try {
|
152
|
try {
|
147
|
ResponseBean res = iTaThirdPartyMiniappConfigService.helpActivity(mpAppid, personId, sponsorPersonId, drainageId);
|
153
|
ResponseBean res = iTaThirdPartyMiniappConfigService.helpActivity(mpAppid, personId, sponsorPersonId, drainageId);
|
148
|
return res;
|
154
|
return res;
|
149
|
- }catch (Exception e){
|
|
|
|
|
155
|
+ } catch (Exception e) {
|
150
|
e.printStackTrace();
|
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
|
* @param drainageId
|
164
|
* @param drainageId
|
158
|
* @param request
|
165
|
* @param request
|
159
|
* @return
|
166
|
* @return
|
|
|
|
|
165
|
return iTaThirdPartyMiniappConfigService.getRanking(drainageId);
|
172
|
return iTaThirdPartyMiniappConfigService.getRanking(drainageId);
|
166
|
} catch (Exception e) {
|
173
|
} catch (Exception e) {
|
167
|
// e.printStackTrace();
|
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
|
}
|