Commit f67da0a4 by 罗承锋

添加移动端非微信授权登录,修改线上版本配置

parent 0f5790e1
...@@ -196,7 +196,7 @@ public class SyncController { ...@@ -196,7 +196,7 @@ public class SyncController {
orderView.setOrderName(order.getCustomerName()); orderView.setOrderName(order.getCustomerName());
orderView.setOrderPhone(order.getContactNumber()); orderView.setOrderPhone(order.getContactNumber());
orderView.setOrderNumber(order.getIdCard()); orderView.setOrderNumber(order.getIdCard());
orderView.setProductName("中国电信校园高速宽带"); orderView.setProductName(jsonObject.getString("prodName"));
orderView.setOrderSetMeal("无人厅"); orderView.setOrderSetMeal("无人厅");
orderView.setOrderDate(order.getCreateTime()); orderView.setOrderDate(order.getCreateTime());
orderView.setOrderUniversityName(order.getHehuorenSchool()); orderView.setOrderUniversityName(order.getHehuorenSchool());
...@@ -256,7 +256,7 @@ public class SyncController { ...@@ -256,7 +256,7 @@ public class SyncController {
if (jsonObject.getString("termNo") == null // 终端编码 if (jsonObject.getString("termNo") == null // 终端编码
|| jsonObject.getString("orderTime") == null // 订单时间 || jsonObject.getString("orderTime") == null // 订单时间
|| jsonObject.getString("prodName") == null // 时间戳 || jsonObject.getString("prodName") == null // 产品名
|| jsonObject.getString("custName") == null //客户姓名 || jsonObject.getString("custName") == null //客户姓名
|| jsonObject.getString("recNo") == null // 订单流水号 || jsonObject.getString("recNo") == null // 订单流水号
|| jsonObject.getString("userName") == null // 合伙人账号 || jsonObject.getString("userName") == null // 合伙人账号
......
...@@ -268,7 +268,7 @@ public class LoginPwdController extends BaseController { ...@@ -268,7 +268,7 @@ public class LoginPwdController extends BaseController {
String username, String verificationCode, String username, String verificationCode,
@RequestParam(value = "remember", defaultValue = "false") boolean remember) { @RequestParam(value = "remember", defaultValue = "false") boolean remember) {
log.info(accessToken+":"+openid+":"+":"+username+":"+verificationCode + ":" + remember); log.info(accessToken+":"+openid+":"+":"+username+":"+verificationCode + ":" + remember);
if (StringUtils.isBlank(accessToken) || StringUtils.isBlank(openid) || StringUtils.isBlank(username) || StringUtils.isBlank(verificationCode)) { if (StringUtils.isBlank(username) || StringUtils.isBlank(verificationCode)) {
return ResponseData.error("绑定失败,授权失效或账号验证码为空!"); return ResponseData.error("绑定失败,授权失效或账号验证码为空!");
} }
String str = stringRedisTemplate.opsForValue().get(username + GETPHONECODE); String str = stringRedisTemplate.opsForValue().get(username + GETPHONECODE);
...@@ -284,39 +284,54 @@ public class LoginPwdController extends BaseController { ...@@ -284,39 +284,54 @@ public class LoginPwdController extends BaseController {
if (users.size() == 0) { if (users.size() == 0) {
return ResponseData.error("当前账号有误!"); return ResponseData.error("当前账号有误!");
} }
log.info("openId:"+openid);
String url1 = "https://api.weixin.qq.com/sns/userinfo?access_token="+accessToken+"&openid="+openid+"&lang=zh_CN";
String jsonObject1 = null;
try {
jsonObject1 = HttpHelper.sendGet(url1);
} catch (Exception e) {
log.error("微信登录获取用户信息失败"+ e.getMessage(),e);
}
if (StringUtils.isBlank(jsonObject1)) {
return ResponseData.error("微信授权失效,请重新授权!");
}
if(!jsonObject1.contains("openid")){
return ResponseData.error("微信授权失效,请重新授权!");
}
log.info(jsonObject1);
Map<String,Object> map1 = JSON.parseObject(jsonObject1, Map.class);
String headimgurl = map1.get("headimgurl").toString();
String nickname = map1.get("nickname").toString();
SysUser sysUser = users.get(0); SysUser sysUser = users.get(0);
Wrapper wrapper = new EntityWrapper<>(); // 没有openid和accessToken直接登录,不访问微信
wrapper.eq("id", sysUser.getId()); if (StringUtils.isNotBlank(openid) && StringUtils.isNotBlank(accessToken)) {
Map<String, Object> dataMapping = new HashMap<>(); log.info("openId:"+openid);
// 不绑定微信则不保存openId String url1 = "https://api.weixin.qq.com/sns/userinfo?access_token="+accessToken+"&openid="+openid+"&lang=zh_CN";
if (remember) { String jsonObject1 = null;
dataMapping.put("open_id", openid); try {
} jsonObject1 = HttpHelper.sendGet(url1);
} catch (Exception e) {
log.error("微信登录获取用户信息失败"+ e.getMessage(),e);
}
if (StringUtils.isBlank(jsonObject1)) {
return ResponseData.error("微信授权失效,请重新授权!");
}
if(!jsonObject1.contains("openid")){
return ResponseData.error("微信授权失效,请重新授权!");
}
log.info(jsonObject1);
Map<String,Object> map1 = JSON.parseObject(jsonObject1, Map.class);
String headimgurl = map1.get("headimgurl").toString();
String nickname = map1.get("nickname").toString();
Wrapper wrapper = new EntityWrapper<>();
wrapper.eq("id", sysUser.getId());
Map<String, Object> dataMapping = new HashMap<>();
// 不绑定微信则不保存openId
if (remember) {
dataMapping.put("open_id", openid);
}
dataMapping.put("wx_head_img_url",headimgurl); dataMapping.put("wx_head_img_url",headimgurl);
dataMapping.put("wx_nick_name",nickname); dataMapping.put("wx_nick_name",nickname);
Integer integer = hhrUserMapper.updateForSet(MyBatisPlusUpdateUtils.toUpdateSet(dataMapping), wrapper); Integer integer = hhrUserMapper.updateForSet(MyBatisPlusUpdateUtils.toUpdateSet(dataMapping), wrapper);
if (integer == 1) { if (integer == 1) {
return this.loginvalid(null, sysUser.getAccount(), openid); return this.loginvalid(null, sysUser.getAccount(), openid);
}
}else{
// 查询openid,模拟微信登录
HhrUser hhrUser = hhrUserMapper.selectById(sysUser.getId());
if (hhrUser == null) {
return ResponseData.error("合伙人信息有误!");
}
if (StringUtils.isBlank(hhrUser.getOpenId())) {
return ResponseData.error("请先在一人一码中绑定微信登录");
}
return this.loginvalid(null, sysUser.getAccount(), hhrUser.getOpenId());
} }
return ResponseData.error("绑定失败!"); return ResponseData.error("绑定失败!");
} }
......
...@@ -96,8 +96,8 @@ spring: ...@@ -96,8 +96,8 @@ spring:
prohibition: 600 prohibition: 600
datasource: datasource:
url: jdbc:mysql://localhost:3306/school_center?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&allowPublicKeyRetrieval=true url: jdbc:mysql://localhost:3306/school_center?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&allowPublicKeyRetrieval=true
username: yzzx username: root
password: yzzx123!@# password: AMrGBg6ZSsRrDLs6
#用来搜集数据库的所有表 #用来搜集数据库的所有表
db-name: guns db-name: guns
filters: wall,mergeStat filters: wall,mergeStat
......
...@@ -131,9 +131,9 @@ spring: ...@@ -131,9 +131,9 @@ spring:
max-active: 30 max-active: 30
datasource: datasource:
master: master:
url: jdbc:mysql://localhost:3306/school_center?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&allowPublicKeyRetrieval=true url: ${spring.datasource.url}
username: yzzx username: ${spring.datasource.username}
password: yzzx123!@# password: ${spring.datasource.password}
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
devtools: devtools:
restart: restart:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment