From faf33855d63f48b3fb44ddd4fe6e478dccedcbe1 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 17 Jul 2024 14:58:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=88=E6=9D=83=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E6=89=8B=E6=9C=BA=E5=8F=B7=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LoginContoller.java | 1 + .../cashierservice/service/LoginService.java | 39 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index 2961e4b..cbdcdb2 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -208,6 +208,7 @@ public class LoginContoller { return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString()); } } catch (Exception e){ +// e.printStackTrace(); log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,data); } return Result.fail("获取手机号失败,请重试!"); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index f4e4ab3..dee9506 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.redis.RedisCst; @@ -416,23 +417,33 @@ public class LoginService { @Transactional public Result upPhone(String openId, String phone, String shopId) { TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId); + boolean isup = false; + if(StringUtils.isNotBlank(userInfo.getTelephone())){ + List tbShopUsers = tbShopUserMapper.selectByPhone(userInfo.getTelephone()); + for (TbShopUser tbShopUser : tbShopUsers) { + if (tbShopUser.getShopId().equals(shopId)) { + isup = true; + } + tbShopUser.setTelephone(phone); + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + tbShopUserMapper.updateByPrimaryKey(tbShopUser); + } + if(!isup){ + registerShopUser(userInfo,shopId); + } + }else { + TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userInfo.getId().toString(), shopId); + if (shopUser != null) { + shopUser.setTelephone(phone); + shopUser.setUpdatedAt(System.currentTimeMillis()); + tbShopUserMapper.updateByPrimaryKey(shopUser); + }else { + registerShopUser(userInfo,shopId); + } + } userInfo.setTelephone(phone); userInfo.setUpdatedAt(System.currentTimeMillis()); tbUserInfoMapper.updateByPrimaryKeySelective(userInfo); - TbShopUser shopUser = tbShopUserMapper.selectByUserIdAndShopId(userInfo.getId().toString(), shopId); - if (shopUser != null) if (!shopUser.getIsVip().equals(1) && shopUser.getAmount().equals(BigDecimal.ZERO)) { - tbShopUserMapper.deleteByPrimaryKey(shopUser.getId()); - List tbShopUsers = tbShopUserMapper.selectByPhone(phone); - if (!CollectionUtils.isEmpty(tbShopUsers)) { - for (TbShopUser tbShopUser : tbShopUsers) { - tbShopUser.setUserId(userInfo.getId() + ""); - tbShopUser.setUpdatedAt(System.currentTimeMillis()); - tbShopUserMapper.updateByPrimaryKey(tbShopUser); - } - return Result.success(CodeEnum.SUCCESS); - } - } - registerShopUser(userInfo,shopId); return Result.success(CodeEnum.SUCCESS); }