Merge branch 'open_gj' into 'master'

渤海及公众号登录修改

See merge request !207
This commit is contained in:
2021-12-02 10:05:51 +08:00
5 changed files with 57 additions and 16 deletions
@@ -85,7 +85,7 @@ public class UserController {
try { try {
if(StringUtils.isNotBlank(weiXinId) && StringUtils.isNotBlank(cacheWeiXinId)){ if(StringUtils.isNotBlank(weiXinId) && StringUtils.isNotBlank(cacheWeiXinId)){
System.out.println("cookie weiXinId:"+weiXinId); System.out.println("cookie weiXinId:"+weiXinId);
response.sendRedirect("reqCityChoicePage?type=b&code="+model.getCode()); response.sendRedirect("reqCityChoicePage?type=bh&code="+model.getCode());
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@@ -127,33 +127,49 @@ public class UserController {
if(weiXinId != null && !weiXinId.equals("")){ if(weiXinId != null && !weiXinId.equals("")){
CookieUtils.setCookie("we_chat_open_id", weiXinId, "/", 60 * 60 * 24 *7, response); CookieUtils.setCookie("we_chat_open_id", weiXinId, "/", 60 * 60 * 24 *7, response);
} }
System.out.println("微信OPEN_ID:" + weiXinId); System.out.println("reqCityChoicePage 微信OPEN_ID:" + weiXinId);
//企业用户入口查询企业账户开通的城市 //企业用户入口查询企业账户开通的城市
if(type.equals("b")){ if(type.equals("b") || type.equals("bh")){
//Boolean isLogin = usersInfoService.checkEnterpriseWeiXinUserIsLogin(weiXinId); //Boolean isLogin = usersInfoService.checkEnterpriseWeiXinUserIsLogin(weiXinId);
String cacheWeiXinId = CookieUtils.getCookieValue(request,"login_enterpriseuser_weixinid"); String cacheWeiXinId = CookieUtils.getCookieValue(request,"login_enterpriseuser_weixinid");
if(cacheWeiXinId != null) { String loginUserIdstr = CookieUtils.getCookieValue(request,"login_user_id");
Long userId = Long.parseLong(CookieUtils.getCookieValue(request,"login_user_id")); if(cacheWeiXinId != null && StringUtils.isNotBlank(loginUserIdstr)) {
Long userId = Long.parseLong(loginUserIdstr);
CookieUtils.setCookie("login_user_id", userId + "", "/", 60 * 60 * 24 *7, response); CookieUtils.setCookie("login_user_id", userId + "", "/", 60 * 60 * 24 *7, response);
try { try {
FjtUsers users = fjtUsersService.findById(userId); FjtUsers users = fjtUsersService.findById(userId);
List<String> citys = userCityService.findSupportCityByUserId(userId);
if(citys == null || citys.isEmpty()){ if(users.getRole()==17 && type.equals("b")){
citys = Arrays.asList("上海"); CookieUtils.removeCookie(request, response, "login_enterpriseuser_weixinid");
} response.sendRedirect("reqLoginPage");
}else if(users.getRole()==12 && type.equals("bh")){
CookieUtils.removeCookie(request, response, "login_enterpriseuser_weixinid");
response.sendRedirect("bhydLoginPage?code="+model.getCode());
}else{
List<String> citys = userCityService.findSupportCityByUserId(userId);
if(citys == null || citys.isEmpty()){
citys = Arrays.asList("上海");
}
// if(users!=null && users.getRole() == 12){ // if(users!=null && users.getRole() == 12){
// citys = Arrays.asList("上海"); // citys = Arrays.asList("上海");
// }else{ // }else{
// citys = userCityService.findSupportCityByUserId(userId); // citys = userCityService.findSupportCityByUserId(userId);
// } // }
model.setCitys(citys); model.setCitys(citys);
}
} catch (Exception e) { } catch (Exception e) {
model.setCitys(new ArrayList<String>()); model.setCitys(new ArrayList<String>());
} }
} else { } else {
CookieUtils.removeCookie(request, response, "login_enterpriseuser_weixinid");
try { try {
response.sendRedirect("bhydLoginPage?code="+model.getCode()); if(type.equals("bh")){
response.sendRedirect("bhydLoginPage?code="+model.getCode());
}else{
response.sendRedirect("reqLoginPage");
}
} catch (IOException e) { } catch (IOException e) {
} }
} }
@@ -368,7 +384,7 @@ public class UserController {
return resultModel; return resultModel;
} }
CookieUtils.setCookie("login_user_id", user.getId() + "", "/", 60 * 60 * 24 *7, response); CookieUtils.setCookie("login_user_id", user.getId() + "", "/", 60 * 60 * 24 *7, response);
CookieUtils.setCookie("login_user_type", "b", "/", 60 * 60 * 24 *7, response); CookieUtils.setCookie("login_user_type", "bh", "/", 60 * 60 * 24 *7, response);
CookieUtils.setCookie("login_enterpriseuser_weixinid", weiXinId, "/", 60 * 60 * 24 *7, response); CookieUtils.setCookie("login_enterpriseuser_weixinid", weiXinId, "/", 60 * 60 * 24 *7, response);
resultModel.setResult(Message.RESULT_SUCCESS); resultModel.setResult(Message.RESULT_SUCCESS);
return resultModel; return resultModel;
@@ -454,7 +454,7 @@ public class WeiXinEvaluationController {
System.out.println("渤海地址搜索 "+evaluation.getAddress()); System.out.println("渤海地址搜索 "+evaluation.getAddress());
List<JSONObject> bhDists = BHBankUtils.getDistrictByBhbank(evaluation.getAddress()); List<JSONObject> bhDists = BHBankUtils.getDistrictByBhbank(evaluation.getAddress());
JSONObject o = null; JSONObject o = null;
if(bhDists.size()<1){ if(bhDists.size()<1 && bhDists.size()>0){
bhDists = BHBankUtils.getDistrictByBhbank(district.getName()); bhDists = BHBankUtils.getDistrictByBhbank(district.getName());
o = bhDists.get(0); o = bhDists.get(0);
}else if(bhDists.size()>1){ }else if(bhDists.size()>1){
@@ -135,7 +135,7 @@
if(re.result == "fail"){ if(re.result == "fail"){
$.toast(re.msg); $.toast(re.msg);
} else { } else {
window.location.href = "reqCityChoicePage?type=b"; window.location.href = "reqCityChoicePage?type=bh";
} }
},error:function (data, status) { },error:function (data, status) {
$.toast("发送失败,请重试"); $.toast("发送失败,请重试");
@@ -42,7 +42,7 @@
</div> </div>
<div class="container"> <div class="container">
<div class="city"> <div class="city">
<#if type?? && type == 'b' && (citys??&&citys?size>0)> <#if type?? && (type == 'b' || type == 'bh') && (citys??&&citys?size>0)>
<div class="city-list"> <div class="city-list">
<#list citys as bo> <#list citys as bo>
<p onclick="req2(this)">${bo}</p> <p onclick="req2(this)">${bo}</p>
@@ -54,7 +54,7 @@
</#list> </#list>
</div> </div>
</#if> </#if>
<#if type?? && type == 'c' || type == 'b' && (citys??&&citys?size=0)> <#if type?? && type == 'c' || type == 'b' || type=='bh' && (citys??&&citys?size=0)>
<div class="city-list curCity"> <div class="city-list curCity">
<span class="city-letter" id="Cur">当前定位城市</span> <span class="city-letter" id="Cur">当前定位城市</span>
</div> </div>
@@ -1,5 +1,7 @@
package com.fangjia.service.util; package com.fangjia.service.util;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -29,6 +31,29 @@ public class CookieUtils {
} }
public static boolean removeCookie(HttpServletRequest request, HttpServletResponse response, String name) {
if(request.getCookies() == null){
return false;
}
if (StringUtils.isBlank(name)) {
return false;
}
Cookie[] cookies = request.getCookies();
if (null != cookies) {
for (Cookie cookie : cookies) {
if (name.equals(cookie.getName())) {
cookie.setValue(null);
cookie.setMaxAge(0);
cookie.setPath("/");
response.addCookie(cookie);
return true;
}
}
}
return false;
}
public static void setCookie(String name, String value, String path,int maxAge, HttpServletResponse response){ public static void setCookie(String name, String value, String path,int maxAge, HttpServletResponse response){
Cookie cookie = new Cookie(name, value); Cookie cookie = new Cookie(name, value);
if(path != null){ if(path != null){