|
@@ -3,7 +3,6 @@ package com.huiju.estateagents.third.controller;
|
3
|
3
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
4
|
import com.huiju.estateagents.base.ResponseBean;
|
5
|
5
|
import com.huiju.estateagents.common.CommConstant;
|
6
|
|
-import com.huiju.estateagents.redpack.entity.TaMpPerson;
|
7
|
6
|
import com.huiju.estateagents.third.entity.TaMpInfo;
|
8
|
7
|
import com.huiju.estateagents.third.entity.TaThirdPartyMiniappConfig;
|
9
|
8
|
import com.huiju.estateagents.third.service.ITaMpInfoService;
|
|
@@ -20,7 +19,9 @@ import org.springframework.stereotype.Controller;
|
20
|
19
|
import org.springframework.web.bind.annotation.*;
|
21
|
20
|
|
22
|
21
|
import javax.servlet.http.HttpServletRequest;
|
|
22
|
+import java.util.HashMap;
|
23
|
23
|
import java.util.List;
|
|
24
|
+import java.util.Map;
|
24
|
25
|
import java.util.stream.Collectors;
|
25
|
26
|
|
26
|
27
|
/**
|
|
@@ -45,27 +46,23 @@ public class WxRedpackController {
|
45
|
46
|
* @return
|
46
|
47
|
*/
|
47
|
48
|
@GetMapping("/third/redirect/{mpAppid}/greet")
|
48
|
|
- public ResponseBean greetUser(@PathVariable String mpAppid, @RequestParam String code, @RequestParam String personId, HttpServletRequest request) {
|
|
49
|
+ public ResponseBean greetUser(@PathVariable String mpAppid, @RequestParam String code, @RequestParam String personId,@RequestParam String sponsorPersonId,@RequestParam String drainageId, HttpServletRequest request) {
|
49
|
50
|
WxMpService wxService = getWxMpService();
|
50
|
51
|
if (!wxService.switchover(mpAppid)) {
|
51
|
52
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
52
|
53
|
}
|
53
|
|
- TaMpPerson taMpPerson = new TaMpPerson();
|
|
54
|
+ Map<String,Object> map = new HashMap<>();
|
54
|
55
|
try {
|
55
|
56
|
//换取openid
|
56
|
57
|
WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
|
57
|
58
|
WxMpUser user = wxService.oauth2getUserInfo(accessToken, null);
|
58
|
59
|
|
59
|
|
- //获取H5项目相关信息
|
60
|
|
- String xAppid = request.getHeader("x-appid");
|
61
|
|
- //获取小程序appid
|
62
|
|
- String miniAppid = request.getHeader("appid");
|
63
|
60
|
//插入公众号人员信息并插入表
|
64
|
|
- taMpPerson = iTaThirdPartyMiniappConfigService.newMpPerson(user, mpAppid, xAppid, miniAppid, personId);
|
|
61
|
+ map = iTaThirdPartyMiniappConfigService.newMpPerson(user, mpAppid, drainageId, sponsorPersonId, personId);
|
65
|
62
|
} catch (WxErrorException e) {
|
66
|
63
|
e.printStackTrace();
|
67
|
64
|
}
|
68
|
|
- return ResponseBean.success(taMpPerson);
|
|
65
|
+ return ResponseBean.success(map);
|
69
|
66
|
}
|
70
|
67
|
|
71
|
68
|
private WxMpService getWxMpService() {
|
|
@@ -95,16 +92,15 @@ public class WxRedpackController {
|
95
|
92
|
* @return
|
96
|
93
|
*/
|
97
|
94
|
@PostMapping("/third/activity/{mpAppid}/participate")
|
98
|
|
- public ResponseBean participateActivity(@PathVariable String mpAppid, @RequestParam String mpPersonId, HttpServletRequest request) {
|
|
95
|
+ public ResponseBean participateActivity(@PathVariable String mpAppid, @RequestParam String mpPersonId,@RequestParam String drainageId, HttpServletRequest request) {
|
99
|
96
|
WxMpService wxService = getWxMpService();
|
100
|
97
|
if (!wxService.switchover(mpAppid)) {
|
101
|
98
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
102
|
99
|
}
|
103
|
100
|
//获取H5项目相关信息
|
104
|
|
- String xAppid = request.getHeader("x-appid");
|
105
|
101
|
QueryWrapper<TaThirdPartyMiniappConfig> taThirdPartyMiniappConfigQueryWrapper = new QueryWrapper<>();
|
106
|
102
|
|
107
|
|
- taThirdPartyMiniappConfigQueryWrapper.eq("appid", xAppid);
|
|
103
|
+ taThirdPartyMiniappConfigQueryWrapper.eq("appid", drainageId);
|
108
|
104
|
TaThirdPartyMiniappConfig taThirdPartyMiniappConfig = iTaThirdPartyMiniappConfigService.getOne(taThirdPartyMiniappConfigQueryWrapper);
|
109
|
105
|
if (null == taThirdPartyMiniappConfig){
|
110
|
106
|
return ResponseBean.error("不存在的H5活动",ResponseBean.ERROR_UNAVAILABLE);
|
|
@@ -126,22 +122,21 @@ public class WxRedpackController {
|
126
|
122
|
* @return
|
127
|
123
|
*/
|
128
|
124
|
@PostMapping("/third/activity/{mpAppid}/help")
|
129
|
|
- public ResponseBean helpActivity(@PathVariable String mpAppid, @RequestParam String mpPersonId, @RequestParam String parentMpPersonId ,HttpServletRequest request) {
|
|
125
|
+ public ResponseBean helpActivity(@PathVariable String mpAppid, @RequestParam String mpPersonId, @RequestParam String sponsorPersonId,@RequestParam String drainageId, HttpServletRequest request) {
|
130
|
126
|
WxMpService wxService = getWxMpService();
|
131
|
127
|
if (!wxService.switchover(mpAppid)) {
|
132
|
128
|
throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", mpAppid));
|
133
|
129
|
}
|
134
|
130
|
//获取H5项目相关信息
|
135
|
|
- String xAppid = request.getHeader("x-appid");
|
136
|
131
|
QueryWrapper<TaThirdPartyMiniappConfig> taThirdPartyMiniappConfigQueryWrapper = new QueryWrapper<>();
|
137
|
132
|
|
138
|
|
- taThirdPartyMiniappConfigQueryWrapper.eq("appid", xAppid);
|
|
133
|
+ taThirdPartyMiniappConfigQueryWrapper.eq("appid", drainageId);
|
139
|
134
|
TaThirdPartyMiniappConfig taThirdPartyMiniappConfig = iTaThirdPartyMiniappConfigService.getOne(taThirdPartyMiniappConfigQueryWrapper);
|
140
|
135
|
if (null == taThirdPartyMiniappConfig){
|
141
|
136
|
return ResponseBean.error("不存在的H5活动",ResponseBean.ERROR_UNAVAILABLE);
|
142
|
137
|
}
|
143
|
138
|
try {
|
144
|
|
- ResponseBean res = iTaThirdPartyMiniappConfigService.helpActivity(mpAppid, mpPersonId, parentMpPersonId, taThirdPartyMiniappConfig.getTargetId(),taThirdPartyMiniappConfig.getOrgId());
|
|
139
|
+ ResponseBean res = iTaThirdPartyMiniappConfigService.helpActivity(mpAppid, mpPersonId, sponsorPersonId, taThirdPartyMiniappConfig.getTargetId(),taThirdPartyMiniappConfig.getOrgId());
|
145
|
140
|
return res;
|
146
|
141
|
}catch (Exception e){
|
147
|
142
|
e.printStackTrace();
|