|
@@ -77,13 +77,16 @@ public class TSzsmWxController {
|
|
|
wx.setModifyDate(new Date());
|
|
|
wx.setOpenId(openid);
|
|
|
szsmWxService.save(wx);
|
|
|
- return R.ok(wx);
|
|
|
+ LambdaQueryWrapper<TSzsmWx> query1 = Wrappers.lambdaQuery();
|
|
|
+ query1.eq(TSzsmWx::getOpenId,openid);
|
|
|
+ List<TSzsmWx> list1 = szsmWxService.list(query1);
|
|
|
+ return R.ok(list1.get(0));
|
|
|
}
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
|
/**
|
|
|
- * 获取微信openid
|
|
|
+ * 获取手机号
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
@@ -94,21 +97,6 @@ public class TSzsmWxController {
|
|
|
// 微信小程序秘钥
|
|
|
String secret = "191b2fb5ad897c53aff19d2b40d677da";
|
|
|
|
|
|
-// //1,获取获取token
|
|
|
-// String token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+appid+"&secret="+secret;
|
|
|
-// JSONObject token = null;
|
|
|
-// try {
|
|
|
-// token = JSON.parseObject(HttpClientSslUtils.doGet(token_url));
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// if (token == null) {
|
|
|
-// return R.ok("获取token失败");
|
|
|
-// }
|
|
|
-// String accessToken = token.getString("access_token");
|
|
|
-// if (StringUtils.isEmpty(accessToken)) {
|
|
|
-// return R.ok("获取token失败");
|
|
|
-// }
|
|
|
String accessToken =null;
|
|
|
TSzsmWx wx = szsmWxService.getById(1);
|
|
|
accessToken = wx.getAvatarUrl();
|
|
@@ -130,7 +118,7 @@ public class TSzsmWxController {
|
|
|
if(StringUtils.isNotEmpty(phoneNumber)){
|
|
|
TSzsmWx szsmWx = szsmWxService.getById(id);
|
|
|
szsmWx.setPhone(phoneNumber);
|
|
|
- szsmWxService.save(szsmWx);
|
|
|
+ szsmWxService.updateById(szsmWx);
|
|
|
return R.ok(szsmWx);
|
|
|
}
|
|
|
}
|
|
@@ -144,6 +132,46 @@ public class TSzsmWxController {
|
|
|
return R.ok();
|
|
|
}
|
|
|
/**
|
|
|
+ * 获取不限制的小程序码 +优惠券
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getQRCodeAndYHJ")
|
|
|
+ public ResponseModel<?> getQRCodeAndYHJ(String clientId,String flag) {
|
|
|
+ if(StringUtils.isEmpty(clientId)||StringUtils.isEmpty(flag)){
|
|
|
+ return R.fail(ResponseCodesEnum.A0001);
|
|
|
+ }
|
|
|
+ // 微信小程序ID
|
|
|
+ String appid = "wx5071443e63295c29";
|
|
|
+ // 微信小程序秘钥
|
|
|
+ String secret = "191b2fb5ad897c53aff19d2b40d677da";
|
|
|
+
|
|
|
+ String accessToken =null;
|
|
|
+ TSzsmWx wx = szsmWxService.getById(1);
|
|
|
+ accessToken = wx.getAvatarUrl();
|
|
|
+ //获取phone
|
|
|
+ String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("scene", clientId+"-"+flag);
|
|
|
+// jsonObject.put("env_version", "trial");
|
|
|
+ String reqJsonStr = JsonUtil.objToString(jsonObject);
|
|
|
+ JSONObject phoneObject = null;
|
|
|
+ try {
|
|
|
+ String s = httpPostWithJSON(url, reqJsonStr);
|
|
|
+ if(StringUtils.isEmpty(s)){
|
|
|
+ return R.fail("获取失败");
|
|
|
+ }else {
|
|
|
+ return R.ok(s);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (phoneObject == null) {
|
|
|
+ return R.fail("获取失败");
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 获取不限制的小程序码
|
|
|
* @param
|
|
|
* @return
|
|
@@ -219,5 +247,19 @@ public class TSzsmWxController {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户信息
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getUserInfo")
|
|
|
+ public ResponseModel<?> getUserInfo(String id) {
|
|
|
+ if(StringUtils.isEmpty(id)){
|
|
|
+ return R.fail(ResponseCodesEnum.A0001);
|
|
|
+ }
|
|
|
+ TSzsmWx szsmWx = szsmWxService.getById(id);
|
|
|
+ return R.ok(szsmWx);
|
|
|
+ }
|
|
|
}
|
|
|
|