socket为空时 报错问题

登录时 获取手机号乱码
This commit is contained in:
wangw 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 ivStr = map.get("iv");
// String phone = map.get("phone");
log.info("登录传参:入参:{}",JSONUtil.toJSONString(map));
// 用户非敏感信息rawData
// 签名signature
JSONObject rawDataJson = JSON.parseObject(rawData);
@ -128,10 +127,11 @@ public class LoginContoller {
}
String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
String phone = "";
log.info("登录传参:解码获取手机号{}",data);
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
phone =JSONObject.parseObject(data).get("phoneNumber").toString();
}else {
try{
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
phone =JSONObject.parseObject(data).get("phoneNumber").toString();
}
}catch (Exception e){
log.info("登录传参:获取手机号失败{}",data);
}
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 {
TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId);
if (ObjectUtil.isNull(userInfo)) {
userInfo = tbUserInfoMapper.selectByPhone(telephone);
if(StringUtils.isNotBlank(telephone)){
userInfo = tbUserInfoMapper.selectByPhone(telephone);
}
if (ObjectUtil.isNull(userInfo)) {
userInfo = new TbUserInfo();
userInfo.setAmount(BigDecimal.ZERO);
@ -84,17 +86,19 @@ public class LoginService {
userInfo.setLastLogInAt(System.currentTimeMillis());
userInfo.setCreatedAt(System.currentTimeMillis());
userInfo.setUpdatedAt(System.currentTimeMillis());
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
if(CollectionUtils.isEmpty(tbShopUsers)){
for (TbShopUser tbShopUser : tbShopUsers) {
userInfo.setNickName(tbShopUser.getName());
userInfo.setSex(tbShopUser.getSex());
userInfo.setBirthDay(tbShopUser.getBirthDay());
tbShopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
tbShopUser.setCode(dynamicCode);
tbShopUser.setUserId(userInfo.getId() + "");
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
if(StringUtils.isNotBlank(telephone)){
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByPhone(telephone);
if(CollectionUtils.isEmpty(tbShopUsers)){
for (TbShopUser tbShopUser : tbShopUsers) {
userInfo.setNickName(tbShopUser.getName());
userInfo.setSex(tbShopUser.getSex());
userInfo.setBirthDay(tbShopUser.getBirthDay());
tbShopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
tbShopUser.setCode(dynamicCode);
tbShopUser.setUserId(userInfo.getId() + "");
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
}
}
tbUserInfoMapper.insert(userInfo);
@ -108,13 +112,15 @@ public class LoginService {
}
else {
String phone = userInfo.getTelephone();
if (StringUtils.isBlank(phone) || !phone.equals(telephone)) {
userInfo.setTelephone(telephone);
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectAllByUserId(userInfo.getId().toString());
for (TbShopUser tbShopUser : tbShopUsers) {
tbShopUser.setTelephone(phone);
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
if(StringUtils.isNotBlank(telephone)){
if (StringUtils.isBlank(phone) || !phone.equals(telephone)) {
userInfo.setTelephone(telephone);
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectAllByUserId(userInfo.getId().toString());
for (TbShopUser tbShopUser : tbShopUsers) {
tbShopUser.setTelephone(phone);
tbShopUserMapper.updateByPrimaryKey(tbShopUser);
}
}
}
}

View File

@ -275,12 +275,16 @@ public class AppWebSocketServer {
* @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 (webSocketMap.containsKey(tableId)) {
ConcurrentHashMap<String, AppWebSocketServer> userSocketMap = webSocketMap.get(tableId);
if(StringUtils.isNotBlank(userId)){
userSocketMap.get(userId).sendMessage(message);
if(!userSocketMap.isEmpty()){
if(StringUtils.isNotBlank(userId)){
userSocketMap.get(userId).sendMessage(message);
}
}else {
log.error("请求的tableId:"+tableId+"用户连接为空");
}
}else {
log.error("请求的tableId:"+tableId+" userId:" + userId + "不在该服务器上");

View File

@ -52,7 +52,7 @@ mybatis:
ysk:
url: https://gatewaytestapi.sxczgkj.cn/gate-service/
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
default: 18710449883
server:

View File

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