From fa4ef5b3755b5669c9dec08a5fa69f91c298d672 Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Thu, 18 Jan 2024 11:36:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=9E=B6=E6=97=B6=E9=97=B4=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gateway/src/main/resources/jwt.properties | 3 +- .../PlatformTeamAccountController.java | 6 + .../nakadai/controller/ProductController.java | 2 +- .../nakadai/entity/req/AppletCallbackReq.java | 3 + .../nakadai/entity/req/InviteJoinInfo.java | 3 + .../mapper/xml/PlatformTeamAccountMapper.xml | 2 +- .../service/PlatformTeamAccountService.java | 2 + .../impl/PlatformTeamAccountServiceImpl.java | 109 ++++++++++++++---- .../users/mapper/xml/HrUserAccountMapper.xml | 10 +- .../impl/HrUserAccountServiceImpl.java | 5 + 10 files changed, 115 insertions(+), 30 deletions(-) diff --git a/gateway/src/main/resources/jwt.properties b/gateway/src/main/resources/jwt.properties index 4540c90..c136a2e 100644 --- a/gateway/src/main/resources/jwt.properties +++ b/gateway/src/main/resources/jwt.properties @@ -101,4 +101,5 @@ jwt.ignoreUrlList=/users/users/user/captcha,\ /nakadai/tags/tagsList,\ /nakadai/nakadai/partner/schemeManagement/schemeList,\ /nakadai/kindergarten/platformTeamAccount/weChatAppletCallbackByKindergarten,\ - /nakadai/kindergarten/platformTeamAccount/kindergartenWeChatApplication + /nakadai/kindergarten/platformTeamAccount/kindergartenWeChatApplication,\ + /nakadai/kindergarten/platformTeamAccount/loginWithPhoneNumber diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java index 5ecaf65..35d2cb6 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java @@ -229,6 +229,12 @@ public class PlatformTeamAccountController { return platformTeamAccountService.kindergartenWeChatApplication(appletCallbackReq); } + @ApiOperation(value = "幼教产品微信小程序查询手机号登录") + @PostMapping("/loginWithPhoneNumber") + public R loginWithPhoneNumber(@RequestBody @Valid AppletCallbackReq appletCallbackReq) { + return platformTeamAccountService.getUserAccountByPhone(appletCallbackReq); + } + @ApiOperation(value = "获取当前平台用户的团队信息", response = PartnerAccountResp.class) @GetMapping("/getTeamsByPlatformId") public R getTeamsByPlatformId(@ApiParam(name = "platformId", value = "平台id") @RequestParam Integer platformId, HttpServletRequest request) { diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/ProductController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/ProductController.java index 5ecaf89..4fcbcb4 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/ProductController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/ProductController.java @@ -131,7 +131,7 @@ public class ProductController { // product.setDeliveryMode(Json.toJsonString(productParam.getDeliveryModeVo())); product.setShopId(TokenUtils.getShopIdByJwtToken(request)); product.setUpdateTime(new Date()); - if (product.getStatus() == 0) { + if (product.getStatus() == 1) { product.setPutawayTime(new Date()); } product.setCreateTime(new Date()); diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/req/AppletCallbackReq.java b/nakadai/src/main/java/com/huoran/nakadai/entity/req/AppletCallbackReq.java index 7dab0cc..0a6511a 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/req/AppletCallbackReq.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/req/AppletCallbackReq.java @@ -20,6 +20,9 @@ public class AppletCallbackReq { @ApiModelProperty("平台标识:5幼儿园,6供应商,7个人端") private Integer platformId; + @ApiModelProperty(value = "姓名") + private String name; + @ApiModelProperty("唯一标识") private String openId; diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java b/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java index 43bfc4a..54352d2 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java @@ -11,6 +11,9 @@ public class InviteJoinInfo { @ApiModelProperty(value = "手机验证码") private String code; + @ApiModelProperty(value = "姓名") + private String name; + @ApiModelProperty(value = "电话") private String phone; diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml index 646f83b..6d4660a 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml @@ -146,7 +146,7 @@ hpa.account_id, a.account, pc.classification_name as teamName, - pc.id as partnerClassificationId, + pc.id as classificationId, pc.is_team, pc.parent_id, pc.create_time as joinTime, diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java b/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java index 4e10acf..9ba66a3 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java @@ -26,6 +26,8 @@ public interface PlatformTeamAccountService extends IService data = new HashedMap(); - UserAccount userAccount = baseMapper.selectAccountByOpenId(appletCallbackReq.getOpenId(), appletCallbackReq.getPlatformId()); - //该平台已经注册 - if (userAccount != null){ - data.put("registerId", userAccount.getId()); - data.put("openId", appletCallbackReq.getOpenId()); - return R.ok().put("data",data); - } - if (appletCallbackReq.getPhone()!= null){ - UserAccount userAccountByPhone = baseMapper.selectAccount(appletCallbackReq.getPhone(),appletCallbackReq.getPlatformId().toString()); + ArrayList arrayList = new ArrayList<>(); + arrayList.add("5"); + arrayList.add("6"); + for (String platformId : arrayList) { + UserAccount userAccountByPhone = baseMapper.selectAccount(appletCallbackReq.getPhone(), platformId); //根据手机号查询用户 if (userAccountByPhone != null){ if (!userAccountByPhone.getIsEnable()){ throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED); } - //邀请添加用户没有openid,登录更新openId - baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccountByPhone.getId()); - //更新登录时间 - baseMapper.updateUserInfo(userAccountByPhone.getUserId()); - data.put("token", JwtUtils.getJwtToken(userAccountByPhone.getId().toString(),getShopId(appletCallbackReq.getOpenId(),appletCallbackReq.getPlatformId()),appletCallbackReq.getPlatformId())); + if (userAccountByPhone.getAppOpenId().equals("0")){ + data.put("platformId", platformId); + //邀请添加用户没有openid,登录更新openId + baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccountByPhone.getId()); + //查询个人端账号更新openid + UserAccount userAccount = baseMapper.selectAccount(appletCallbackReq.getPhone(), "7"); + baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccount.getId()); + //更新登录时间 + baseMapper.updateUserInfo(userAccountByPhone.getUserId()); + } + data.put("token", JwtUtils.getJwtToken(userAccountByPhone.getId().toString(),getShopId(appletCallbackReq.getOpenId(),Integer.valueOf(platformId)),Integer.valueOf(platformId))); data.put("openId", appletCallbackReq.getOpenId()); - //TODO 团队信息待处理 -// data.put("teamId",platformTeamClassification.getId()); -// data.put("teamName",teamName); + return R.ok().put("data",data); } } + + return R.ok(); + } + + @Override + public R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq) { + Map data = new HashedMap(); + UserAccount userAccount = baseMapper.selectAccountByOpenId(appletCallbackReq.getOpenId(), appletCallbackReq.getPlatformId()); + //该平台已经注册 + if (userAccount != null){ + data.put("registerId", userAccount.getId()); + data.put("openId", appletCallbackReq.getOpenId()); + return R.ok().put("data",data); + } + String randomNumber5 = cn.hutool.core.util.RandomUtil.randomNumbers(5); String randomNumber6 = cn.hutool.core.util.RandomUtil.randomNumbers(6); String randomNumber7 = cn.hutool.core.util.RandomUtil.randomNumbers(7); @@ -216,6 +232,9 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl(). eq("account_id", userAccount.getId())); - manageId = platformTeamAccount.getManageId(); - //被邀请人有合伙人账号,判断是否已经存在当前团队中 + + //被邀请人有团队账号,判断是否已经存在当前团队中 if (ObjectUtil.isNotNull(platformTeamAccount)){ + manageId = platformTeamAccount.getManageId(); List platformTeamList = platformTeamMapper.selectList(new QueryWrapper(). eq("manage_id", platformTeamAccount.getManageId())); - //查询团队下的成员是否存在团队中 List teamMeb = platformTeamClassificationMapper.selectList(new QueryWrapper(). eq("parent_id", inviteJoinInfo.getClassificationId())); @@ -405,6 +424,51 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl 0) { + PlatformTeam platformTeam = new PlatformTeam(); + platformTeam.setManageId(platformTeamAccount.getManageId()); + platformTeam.setClassificationId(platformTeamMeb.getId()); + platformTeamMapper.insert(platformTeam); + } + return insert > 0 ? R.ok() : R.error(); + //拉入当前团队 + }else { + //添加团队管理账号 + PlatformTeamAccount platformTeamAccount1 = new PlatformTeamAccount(); + platformTeamAccount1.setAccountId(userAccount.getId()); + platformTeamAccount1.setPlatformId(inviteJoinInfo.getPlatformId()); + String username = partnerAccountMapper.selectUsername(inviteJoinInfo.getAccountId()); + platformTeamAccount1.setInvitationAccount(username); + baseMapper.insert(platformTeamAccount1); + + PlatformTeamClassification platformTeamAdmin = platformTeamClassificationMapper.selectById(inviteJoinInfo.getClassificationId()); + //新增团队成员 + PlatformTeamClassification platformTeamMeb = new PlatformTeamClassification(); + platformTeamMeb.setIsTeam(0); + platformTeamMeb.setParentId(inviteJoinInfo.getClassificationId()); + platformTeamMeb.setLevel(platformTeamAdmin.getLevel() + 1); + platformTeamMeb.setClassificationName(platformTeamAdmin.getClassificationName()); + int insert = platformTeamClassificationMapper.insert(platformTeamMeb); + + //团队分类 + if (insert > 0) { + PlatformTeam platformTeam = new PlatformTeam(); + platformTeam.setManageId(platformTeamAccount1.getManageId()); + platformTeam.setClassificationId(platformTeamMeb.getId()); + platformTeamMapper.insert(platformTeam); + } + return insert > 0 ? R.ok() : R.error(); } }else { //不存在创建账号,拉入组织 @@ -412,6 +476,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl data =(Map) r.get("data"); Integer registerId =(Integer) data.get("registerId"); diff --git a/users/src/main/java/com/huoran/users/mapper/xml/HrUserAccountMapper.xml b/users/src/main/java/com/huoran/users/mapper/xml/HrUserAccountMapper.xml index 21ebeae..9edae4e 100644 --- a/users/src/main/java/com/huoran/users/mapper/xml/HrUserAccountMapper.xml +++ b/users/src/main/java/com/huoran/users/mapper/xml/HrUserAccountMapper.xml @@ -843,7 +843,7 @@ count(u.login_number) as login_number, max(CASE WHEN a.platform_id = 7 THEN u.user_name ELSE NULL END) as user_name, a.work_number, - GROUP_CONCAT(s.platform_name) as platformName, + GROUP_CONCAT( DISTINCT s.platform_name) as platformName, CASE WHEN count(ai.id) > 0 THEN '已认证' ELSE '未认证' @@ -1116,14 +1116,14 @@ ec.audit_status, ta.manage_id FROM - hr_enterprise_certification ec - INNER JOIN hr_user_account hu ON hu.app_open_id = ec.open_id - AND ec.platform_source = hu.platform_id and hu.is_del = 0 + hr_user_account hu + left JOIN hr_enterprise_certification ec ON hu.app_open_id = ec.open_id + AND ec.platform_source = hu.platform_id INNER JOIN k_platform_team_account ta ON ta.account_id = hu.id INNER JOIN k_platform_team pt ON ta.manage_id = pt.manage_id INNER JOIN k_platform_team_classification tc ON tc.id = pt.classification_id and tc.is_del = 0 WHERE - ec.open_id = #{openId} + hu.app_open_id = #{openId} and hu.is_del = 0 diff --git a/users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java b/users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java index bc32263..26e015c 100644 --- a/users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java +++ b/users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java @@ -426,10 +426,15 @@ public class HrUserAccountServiceImpl extends ServiceImpl