|
@@ -16,12 +16,14 @@ import com.huiju.estateagents.common.CommConstant;
|
16
|
16
|
import com.huiju.estateagents.common.WxUtils;
|
17
|
17
|
import com.huiju.estateagents.entity.*;
|
18
|
18
|
import com.huiju.estateagents.event.EventBus;
|
|
19
|
+import com.huiju.estateagents.mapper.TaOrgCityMapper;
|
19
|
20
|
import com.huiju.estateagents.mapper.TaShareMapper;
|
20
|
21
|
import com.huiju.estateagents.service.*;
|
21
|
22
|
import com.huiju.estateagents.common.JWTUtils;
|
22
|
23
|
import com.huiju.estateagents.third.entity.TaThirdPartyMiniappConfig;
|
23
|
24
|
import com.huiju.estateagents.third.service.ITaThirdPartyMiniappConfigService;
|
24
|
25
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
26
|
+import net.bytebuddy.asm.Advice;
|
25
|
27
|
import org.apache.commons.collections.CollectionUtils;
|
26
|
28
|
import org.apache.commons.lang3.StringUtils;
|
27
|
29
|
import org.apache.http.HttpStatus;
|
|
@@ -85,6 +87,14 @@ public class MiniAppController extends BaseController {
|
85
|
87
|
@Autowired
|
86
|
88
|
public ITdPointsRulesService iTdPointsRulesService;
|
87
|
89
|
|
|
90
|
+ @Autowired
|
|
91
|
+ public ITaMiniappService iTaMiniappService;
|
|
92
|
+
|
|
93
|
+ @Autowired
|
|
94
|
+ public TaOrgCityMapper taOrgCityMapper;
|
|
95
|
+
|
|
96
|
+ @Autowired
|
|
97
|
+ public ITdCityService iTdCityService;
|
88
|
98
|
|
89
|
99
|
/**
|
90
|
100
|
* 验证接入
|
|
@@ -97,6 +107,60 @@ public class MiniAppController extends BaseController {
|
97
|
107
|
return echostr;
|
98
|
108
|
}
|
99
|
109
|
|
|
110
|
+
|
|
111
|
+ /**
|
|
112
|
+ * 小程序数据预拉取 https://developers.weixin.qq.com/miniprogram/dev/framework/ability/pre-fetch.html
|
|
113
|
+ * @param appid
|
|
114
|
+ * @param timestamp
|
|
115
|
+ * @param token
|
|
116
|
+ * @param code
|
|
117
|
+ * @param path
|
|
118
|
+ * @param query
|
|
119
|
+ * @param scene
|
|
120
|
+ * @return
|
|
121
|
+ */
|
|
122
|
+ @GetMapping("/preload")
|
|
123
|
+ public ResponseBean getPreloadData(
|
|
124
|
+ @RequestParam(name = "appid") String appid,
|
|
125
|
+ @RequestParam(name = "timestamp") Long timestamp,
|
|
126
|
+ String token,
|
|
127
|
+ String code,
|
|
128
|
+ String path,
|
|
129
|
+ String query,
|
|
130
|
+ Integer scene
|
|
131
|
+ ) {
|
|
132
|
+ // 获取小程序信息
|
|
133
|
+ TaMiniapp taMiniapp = iTaMiniappService.getInfoWithTpls(appid);
|
|
134
|
+ if (null == taMiniapp) {
|
|
135
|
+ return ResponseBean.error("当前 appid 未在系统内注册", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
136
|
+ }
|
|
137
|
+
|
|
138
|
+ // 获取组织信息
|
|
139
|
+ TaOrg taOrg = taOrgService.getById(taMiniapp.getOrgId());
|
|
140
|
+ if (null == taOrg) {
|
|
141
|
+ return ResponseBean.error("当前 appid 未设置对应组织", ResponseBean.ERROR_UNAVAILABLE);
|
|
142
|
+ }
|
|
143
|
+
|
|
144
|
+ // 获取城市列表
|
|
145
|
+ QueryWrapper<TaOrgCity> queryCity = new QueryWrapper<>();
|
|
146
|
+ queryCity.eq("id", taOrg.getOrgId());
|
|
147
|
+ queryCity.eq("status", CommConstant.STATUS_NORMAL);
|
|
148
|
+ List<TaOrgCity> taOrgCityList = taOrgCityMapper.selectList(queryCity);
|
|
149
|
+
|
|
150
|
+ // 获取默认扩展设置
|
|
151
|
+ QueryWrapper<TaCustomImg> queryExt = new QueryWrapper<>();
|
|
152
|
+ queryExt.eq("org_id", taOrg.getOrgId());
|
|
153
|
+ queryExt.eq("status", CommConstant.STATUS_NORMAL);
|
|
154
|
+ List<TaCustomImg> taCustomImg = iTaCustomImgService.list(queryExt);
|
|
155
|
+
|
|
156
|
+ return ResponseBean.success(new HashMap<String, Object>(){{
|
|
157
|
+ put("miniapp", taMiniapp);
|
|
158
|
+ put("org", taOrg);
|
|
159
|
+ put("cityList", taOrgCityList);
|
|
160
|
+ put("customImg", taCustomImg);
|
|
161
|
+ }});
|
|
162
|
+ }
|
|
163
|
+
|
100
|
164
|
/**
|
101
|
165
|
* 登陆接口
|
102
|
166
|
*/
|
|
@@ -104,8 +168,10 @@ public class MiniAppController extends BaseController {
|
104
|
168
|
public ResponseBean login(
|
105
|
169
|
String code,
|
106
|
170
|
@RequestParam(required = false) String from,
|
107
|
|
- @RequestParam(required = false)String recommender,
|
108
|
|
- @RequestParam(required = false)String targetId,
|
|
171
|
+ @RequestParam(required = false) String recommender,
|
|
172
|
+ @RequestParam(required = false) String targetId,
|
|
173
|
+ @RequestParam(required = false) String lon,
|
|
174
|
+ @RequestParam(required = false) String lat,
|
109
|
175
|
HttpServletRequest request) {
|
110
|
176
|
String appid = request.getHeader("appid");
|
111
|
177
|
|
|
@@ -218,7 +284,7 @@ public class MiniAppController extends BaseController {
|
218
|
284
|
// 所有人员都返回 org yansen 2019-11-13 19:56:18
|
219
|
285
|
// if (CommConstant.PERSON_REALTY_CONSULTANT.equals(taPerson.getPersonType())){
|
220
|
286
|
QueryWrapper<TaOrg>orgQueryWrapper = new QueryWrapper<>();
|
221
|
|
- orgQueryWrapper.eq("org_id",taPerson.getOrgId());
|
|
287
|
+ orgQueryWrapper.eq("org_id", orgId);
|
222
|
288
|
TaOrg org = taOrgService.getOne(orgQueryWrapper);
|
223
|
289
|
taPerson.setOrg(org);
|
224
|
290
|
// }
|
|
@@ -230,21 +296,25 @@ public class MiniAppController extends BaseController {
|
230
|
296
|
|
231
|
297
|
//返回是否授权标识
|
232
|
298
|
QueryWrapper<TaCustomImg> queryWrapper = new QueryWrapper<>();
|
233
|
|
- queryWrapper.eq("org_id", getOrgId(request));
|
|
299
|
+ queryWrapper.eq("org_id", orgId);
|
234
|
300
|
queryWrapper.eq("img_type", "auth");
|
235
|
301
|
List<TaCustomImg> taCustomImgs = iTaCustomImgService.list(queryWrapper);
|
236
|
302
|
result.put("avatarAuth", CollectionUtils.isEmpty(taCustomImgs) ? false : "1".equals(taCustomImgs.get(0).getImgUrl()) ? true: false);
|
237
|
303
|
|
238
|
|
-
|
239
|
304
|
String token = (String) miniResp.get("token");
|
240
|
305
|
sysTokenService.saveToken(token);
|
241
|
306
|
|
242
|
307
|
//把積分規則返回給小程序
|
243
|
308
|
QueryWrapper<TdPointsRules> tdPointsRulesQueryWrapper = new QueryWrapper<>();
|
244
|
|
- tdPointsRulesQueryWrapper.eq("org_id",taPerson.getOrgId());
|
|
309
|
+ tdPointsRulesQueryWrapper.eq("org_id", orgId);
|
245
|
310
|
List<TdPointsRules> rulesPointList = iTdPointsRulesService.list(tdPointsRulesQueryWrapper);
|
246
|
311
|
result.put("rulesPointList",rulesPointList);
|
247
|
312
|
|
|
313
|
+ // 定位城市
|
|
314
|
+ String location = null == lon ? null : lon + "," + lat;
|
|
315
|
+ TdCity tdCity = iTdCityService.getLocationCity(location, orgId);
|
|
316
|
+ result.put("city", tdCity);
|
|
317
|
+
|
248
|
318
|
return ResponseBean.success(result);
|
249
|
319
|
} catch (WxErrorException e) {
|
250
|
320
|
System.err.println(e.getError());
|