socket为空时 报错问题

登录时 获取手机号乱码
This commit is contained in:
2024-05-30 16:47:02 +08:00
parent 9a30a40cee
commit c403b69102
5 changed files with 40 additions and 28 deletions

View File

@@ -110,7 +110,6 @@ public class LoginContoller {
String encryptedData = map.get("encryptedData"); String encryptedData = map.get("encryptedData");
String ivStr = map.get("iv"); String ivStr = map.get("iv");
// String phone = map.get("phone"); // String phone = map.get("phone");
log.info("登录传参:入参:{}",JSONUtil.toJSONString(map));
// 用户非敏感信息rawData // 用户非敏感信息rawData
// 签名signature // 签名signature
JSONObject rawDataJson = JSON.parseObject(rawData); JSONObject rawDataJson = JSON.parseObject(rawData);
@@ -128,10 +127,11 @@ public class LoginContoller {
} }
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr); String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
String phone = ""; String phone = "";
log.info("登录传参:解码获取手机号{}",data); try{
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) { if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
phone =JSONObject.parseObject(data).get("phoneNumber").toString(); phone =JSONObject.parseObject(data).get("phoneNumber").toString();
}else { }
}catch (Exception e){
log.info("登录传参:获取手机号失败{}",data); log.info("登录传参:获取手机号失败{}",data);
} }
String nickName = rawDataJson.getString("nickName"); String nickName = rawDataJson.getString("nickName");

View File

@@ -57,7 +57,9 @@ public class LoginService {
public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String ip) throws Exception { public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String ip) throws Exception {
TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId); TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId);
if (ObjectUtil.isNull(userInfo)) { if (ObjectUtil.isNull(userInfo)) {
if(StringUtils.isNotBlank(telephone)){
userInfo = tbUserInfoMapper.selectByPhone(telephone); userInfo = tbUserInfoMapper.selectByPhone(telephone);
}
if (ObjectUtil.isNull(userInfo)) { if (ObjectUtil.isNull(userInfo)) {
userInfo = new TbUserInfo(); userInfo = new TbUserInfo();
userInfo.setAmount(BigDecimal.ZERO); userInfo.setAmount(BigDecimal.ZERO);
@@ -84,6 +86,7 @@ public class LoginService {
userInfo.setLastLogInAt(System.currentTimeMillis()); userInfo.setLastLogInAt(System.currentTimeMillis());
userInfo.setCreatedAt(System.currentTimeMillis()); userInfo.setCreatedAt(System.currentTimeMillis());
userInfo.setUpdatedAt(System.currentTimeMillis()); userInfo.setUpdatedAt(System.currentTimeMillis());
if(StringUtils.isNotBlank(telephone)){
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone); List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
if(CollectionUtils.isEmpty(tbShopUsers)){ if(CollectionUtils.isEmpty(tbShopUsers)){
for (TbShopUser tbShopUser : tbShopUsers) { for (TbShopUser tbShopUser : tbShopUsers) {
@@ -97,6 +100,7 @@ public class LoginService {
tbShopUserMapper.updateByPrimaryKey(tbShopUser); tbShopUserMapper.updateByPrimaryKey(tbShopUser);
} }
} }
}
tbUserInfoMapper.insert(userInfo); tbUserInfoMapper.insert(userInfo);
} }
else { else {
@@ -108,6 +112,7 @@ public class LoginService {
} }
else { else {
String phone = userInfo.getTelephone(); String phone = userInfo.getTelephone();
if(StringUtils.isNotBlank(telephone)){
if (StringUtils.isBlank(phone) || !phone.equals(telephone)) { if (StringUtils.isBlank(phone) || !phone.equals(telephone)) {
userInfo.setTelephone(telephone); userInfo.setTelephone(telephone);
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo); tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
@@ -118,6 +123,7 @@ public class LoginService {
} }
} }
} }
}
//生成token 信息 //生成token 信息
String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(), userInfo.getNickName()); String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(), userInfo.getNickName());

View File

@@ -275,13 +275,17 @@ public class AppWebSocketServer {
* @throws IOException * @throws IOException
*/ */
public static void AppSendInfo(Object message, String tableId,String userId, boolean userFlag) throws IOException { public static void AppSendInfo(Object message, String tableId,String userId, boolean userFlag) throws IOException {
log.info("发送消息 tableId:{} \n userFlag:{}\n message:{}",tableId,userFlag,JSONUtil.toJSONString(message)); log.info("发送消息 tableId:{} \n userId:{}\n userFlag:{}\n message:{}",tableId,userId,userFlag,JSONUtil.toJSONString(message));
if (userFlag) { if (userFlag) {
if (webSocketMap.containsKey(tableId)) { if (webSocketMap.containsKey(tableId)) {
ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = webSocketMap.get(tableId); ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = webSocketMap.get(tableId);
if(!userSocketMap.isEmpty()){
if(StringUtils.isNotBlank(userId)){ if(StringUtils.isNotBlank(userId)){
userSocketMap.get(userId).sendMessage(message); userSocketMap.get(userId).sendMessage(message);
} }
}else {
log.error("请求的tableId:"+tableId+"用户连接为空");
}
}else { }else {
log.error("请求的tableId:"+tableId+" userId:" + userId + "不在该服务器上"); log.error("请求的tableId:"+tableId+" userId:" + userId + "不在该服务器上");
} }

View File

@@ -52,7 +52,7 @@ mybatis:
ysk: ysk:
url: https://gatewaytestapi.sxczgkj.cn/gate-service/ url: https://gatewaytestapi.sxczgkj.cn/gate-service/
callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack
callBackGroupurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBackGroup callBackGroupurl: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
default: 18710449883 default: 18710449883
server: server:

View File

@@ -402,6 +402,7 @@
LEFT JOIN tb_product_sku sku ON pro.id = sku.product_id LEFT JOIN tb_product_sku sku ON pro.id = sku.product_id
WHERE WHERE
pro.type_enum = 'group' pro.type_enum = 'group'
AND pro.is_combo = '1'
GROUP BY GROUP BY
sku.product_id sku.product_id
ORDER BY ORDER BY
@@ -421,6 +422,7 @@
LEFT JOIN tb_product_sku sku ON pro.id = sku.product_id LEFT JOIN tb_product_sku sku ON pro.id = sku.product_id
WHERE WHERE
pro.type_enum = 'group' pro.type_enum = 'group'
AND pro.is_combo = '1'
GROUP BY GROUP BY
sku.product_id sku.product_id
ORDER BY ORDER BY