From 4feb821f7009512ebeaacb430e0d2f0ff8fa22f4 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 23 Jul 2024 10:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=91=98=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/service/LoginService.java | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) 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 6f5ff31..a8aebc1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -414,28 +414,20 @@ 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); - } + // 同一个手机号 同一个店 userId 不为空 + TbShopUser tbShopUserPC = tbShopUserMapper.selectPCByPhoneAndShopId(userInfo.getTelephone(),shopId); + if (tbShopUserPC != null) { + TbShopUser tbShopUserSM = tbShopUserMapper.selectByUserIdAndShopId(userInfo.getId().toString(),shopId); + tbShopUserMapper.deleteByPrimaryKey(tbShopUserSM.getId()); + tbShopUserPC.setUserId(userInfo.getId().toString()); + tbShopUserMapper.updateByPrimaryKey(tbShopUserPC); }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); + TbShopUser tbShopUserSM = tbShopUserMapper.selectByUserIdAndShopId(userInfo.getId().toString(),shopId); + if (tbShopUserSM != null) { + tbShopUserSM.setIsVip(Byte.parseByte("1")); + tbShopUserSM.setTelephone(phone); + tbShopUserSM.setUpdatedAt(System.currentTimeMillis()); + tbShopUserMapper.updateByPrimaryKey(tbShopUserSM); } } userInfo.setTelephone(phone); @@ -454,7 +446,7 @@ public class LoginService { shopUser.setCode(dynamicCode); shopUser.setTelephone(userInfo.getTelephone()); shopUser.setAmount(BigDecimal.ZERO); - shopUser.setIsVip(Byte.parseByte("0")); + shopUser.setIsVip(Byte.parseByte("1")); shopUser.setCreditAmount(BigDecimal.ZERO); shopUser.setConsumeAmount(BigDecimal.ZERO); shopUser.setConsumeNumber(0);