diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcAppUserMapper.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcAppUserMapper.java index 8c364d28..d2e36ebd 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcAppUserMapper.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcAppUserMapper.java @@ -2,6 +2,7 @@ package com.xhpc.card.mapper; import com.xhpc.card.domain.SearchCardUserQueryCondition; import com.xhpc.card.pojo.XhpcAppUser; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -26,7 +27,7 @@ public interface XhpcAppUserMapper { * @date 2022/1/28 16:30 * @since version-1.0 */ - Long selectCount(SearchCardUserQueryCondition queryCondition); + Long selectCount(@Param("queryCondition") SearchCardUserQueryCondition queryCondition, @Param("userIdList") List userIdList); /** * 根据条件查询记录 @@ -35,7 +36,7 @@ public interface XhpcAppUserMapper { * @date 2022/1/28 16:29 * @since version-1.0 */ - List selectByCondition(SearchCardUserQueryCondition queryCondition); + List selectByCondition(@Param("queryCondition") SearchCardUserQueryCondition queryCondition, @Param("userIdList") List userIdList); /** * 根据手机号查找C端用户充值记录 diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCardMapper.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCardMapper.java index dd142760..99f343d9 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCardMapper.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCardMapper.java @@ -4,6 +4,7 @@ import com.xhpc.card.pojo.XhpcIcCardInfo; import com.xhpc.common.domain.IccardInfo; import org.apache.ibatis.annotations.Param; +import java.util.List; import java.util.Map; public interface XhpcCardMapper { @@ -42,4 +43,13 @@ public interface XhpcCardMapper { */ Map selectByAccount(@Param("userAccount") String userAccount, @Param("userType") Integer userType); + /** + * 查询出指定类型的用户 + * + * @author WH + * @date 2022/3/1 17:53 + * @since version-1.0 + */ + List selectUserIdsByUserType(Integer userType); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCommunityPersonnelMapper.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCommunityPersonnelMapper.java index 597838f9..713a6d1a 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCommunityPersonnelMapper.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCommunityPersonnelMapper.java @@ -36,7 +36,7 @@ public interface XhpcCommunityPersonnelMapper { * @date 2022/2/8 10:44 * @since version-1.0 */ - List selectByCondition(SearchCardUserQueryCondition queryCondition); + List selectByCondition(@Param("queryCondition") SearchCardUserQueryCondition queryCondition, @Param("userIdList") List userIdList); /** * 根据分页条件,查询出符合条件记录的总条数 @@ -45,7 +45,7 @@ public interface XhpcCommunityPersonnelMapper { * @date 2022/2/8 10:51 * @since version-1.0 */ - Long selectCount(SearchCardUserQueryCondition queryCondition); + Long selectCount(@Param("queryCondition") SearchCardUserQueryCondition queryCondition, @Param("userIdList") List usrIdList); /** * 根据运营商id、分页条件、查询符合的记录 @@ -53,7 +53,7 @@ public interface XhpcCommunityPersonnelMapper { * @param operatorId 运营商id * @return 符合条件的所有记录 */ - List selectByOperatorId(@Param("operatorId") Long operatorId, @Param("currentPage") Long currentPage, @Param("items") Long items); + List selectByOperatorId(@Param("operatorId") Long operatorId, @Param("currentPage") Long currentPage, @Param("items") Long items, @Param("userIdList") List userIdList); /** * 根据运营商id、分页条件、查询符合的记录的个数 @@ -61,7 +61,7 @@ public interface XhpcCommunityPersonnelMapper { * @param operatorId 运营商id * @return 符合条件个数 */ - Long selectCountByOperatorId(@Param("operatorId") Long operatorId); + Long selectCountByOperatorId(@Param("operatorId") Long operatorId, @Param("userIdList") List userIdList); /** * query record by userAccount diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCustomersPersonnelMapper.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCustomersPersonnelMapper.java index f68de70d..af6bae1a 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCustomersPersonnelMapper.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/XhpcCustomersPersonnelMapper.java @@ -36,7 +36,7 @@ public interface XhpcCustomersPersonnelMapper { * @date 2022/2/8 14:39 * @since version-1.0 */ - List selectByCondition(SearchCardUserQueryCondition queryCondition); + List selectByCondition(@Param("queryCondition") SearchCardUserQueryCondition queryCondition, @Param("userIdList") List userIdList); /** * 根据条件查询所有记录个数 @@ -45,7 +45,7 @@ public interface XhpcCustomersPersonnelMapper { * @date 2022/2/8 14:43 * @since version-1.0 */ - Long selectCount(SearchCardUserQueryCondition queryCondition); + Long selectCount(@Param("queryCondition") SearchCardUserQueryCondition queryCondition, @Param("userIdList") List userIdList); /** * 根据运营商id、分页条件、查询对应的记录 @@ -55,7 +55,7 @@ public interface XhpcCustomersPersonnelMapper { * @param items 当前要显示的条数 * @return 对应的记录 */ - List selectByOperatorId(@Param("operatorId") Long operatorId, @Param("currentPage") Long currentPage, @Param("items") Long items); + List selectByOperatorId(@Param("operatorId") Long operatorId, @Param("currentPage") Long currentPage, @Param("items") Long items, @Param("userIdList") List userIdList); /** * 根据运营商id,查询符合条件的总条数 @@ -63,7 +63,7 @@ public interface XhpcCustomersPersonnelMapper { * @param operatorId * @return */ - Long selectCountByOperatorId(Long operatorId); + Long selectCountByOperatorId(@Param("operatorId") Long operatorId, @Param("userIdList") List userIdList); /** * query record by user account diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java index 034f8506..2a30d9f2 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java @@ -193,6 +193,10 @@ public class XhpcCardServiceImpl implements IXhpcCardService { if (dataDTO.getClassification() == 0) { //离线用户类型为10 dataDTO.setUserType(10L); + int userIndex = (int) data.get("userIndex"); + TIccardUsers tIccardUser = tIccardUsersMapper.selectByPrimaryKey(userIndex); + String phone = tIccardUser.getPhone(); + dataDTO.setUserAccount(phone); } else { dataDTO.setUserType((Long) data.get("user_type")); } @@ -247,8 +251,9 @@ public class XhpcCardServiceImpl implements IXhpcCardService { //(0 C端用户 2社区用户 3 B端用户) switch (queryCondition.getUserType()) { case 0: - List appUserList = xhpcAppUserMapper.selectByCondition(queryCondition); - Long allCount = xhpcAppUserMapper.selectCount(queryCondition); + List userIdList = xhpcCardMapper.selectUserIdsByUserType(queryCondition.getUserType()); + List appUserList = xhpcAppUserMapper.selectByCondition(queryCondition, userIdList); + Long allCount = xhpcAppUserMapper.selectCount(queryCondition, userIdList); searchCardResponse.setTotalItems(allCount); for (XhpcAppUser xhpcAppUser : appUserList) { SearchCardResponse.DataDTO dataDTO = new SearchCardResponse.DataDTO(); @@ -256,10 +261,11 @@ public class XhpcCardServiceImpl implements IXhpcCardService { dataDTO.setUserType(0); searchCardResponse.getData().add(dataDTO); } - break; + return R.ok(searchCardResponse); case 2: - List xhpcCommunityPersonnelList = xhpcCommunityPersonnelMapper.selectByCondition(queryCondition); - Long allCount1 = xhpcCommunityPersonnelMapper.selectCount(queryCondition); + List userIdList1 = xhpcCardMapper.selectUserIdsByUserType(queryCondition.getUserType()); + List xhpcCommunityPersonnelList = xhpcCommunityPersonnelMapper.selectByCondition(queryCondition, userIdList1); + Long allCount1 = xhpcCommunityPersonnelMapper.selectCount(queryCondition, userIdList1); searchCardResponse.setTotalItems(allCount1); for (XhpcCommunityPersonnel xhpcCommunityPersonnel : xhpcCommunityPersonnelList) { SearchCardResponse.DataDTO dataDTO = new SearchCardResponse.DataDTO(); @@ -267,10 +273,11 @@ public class XhpcCardServiceImpl implements IXhpcCardService { dataDTO.setUserType(2); searchCardResponse.getData().add(dataDTO); } - break; + return R.ok(searchCardResponse); case 3: - List xhpcCustomersPersonnelList = xhpcCustomersPersonnelMapper.selectByCondition(queryCondition); - Long allCount2 = xhpcCustomersPersonnelMapper.selectCount(queryCondition); + List userIdList2 = xhpcCardMapper.selectUserIdsByUserType(queryCondition.getUserType()); + List xhpcCustomersPersonnelList = xhpcCustomersPersonnelMapper.selectByCondition(queryCondition, userIdList2); + Long allCount2 = xhpcCustomersPersonnelMapper.selectCount(queryCondition, userIdList2); searchCardResponse.setTotalItems(allCount2); for (XhpcCustomersPersonnel xhpcCustomersPersonnel : xhpcCustomersPersonnelList) { SearchCardResponse.DataDTO dataDTO = new SearchCardResponse.DataDTO(); @@ -278,7 +285,7 @@ public class XhpcCardServiceImpl implements IXhpcCardService { dataDTO.setUserType(3); searchCardResponse.getData().add(dataDTO); } - break; + return R.ok(searchCardResponse); default: return R.fail("没有此用户类型"); } @@ -291,8 +298,9 @@ public class XhpcCardServiceImpl implements IXhpcCardService { //2社区用户 3 B端用户) switch (queryCondition.getUserType()) { case 2: - List xhpcCommunityPersonnelList = xhpcCommunityPersonnelMapper.selectByOperatorId(operatorId, queryCondition.getCurrentPage(), queryCondition.getItems()); - Long allCount1 = xhpcCommunityPersonnelMapper.selectCountByOperatorId(operatorId); + List userIdList = xhpcCardMapper.selectUserIdsByUserType(queryCondition.getUserType()); + List xhpcCommunityPersonnelList = xhpcCommunityPersonnelMapper.selectByOperatorId(operatorId, queryCondition.getCurrentPage(), queryCondition.getItems(), userIdList); + Long allCount1 = xhpcCommunityPersonnelMapper.selectCountByOperatorId(operatorId, userIdList); searchCardResponse.setTotalItems(allCount1); for (XhpcCommunityPersonnel xhpcCommunityPersonnel : xhpcCommunityPersonnelList) { SearchCardResponse.DataDTO dataDTO = new SearchCardResponse.DataDTO(); @@ -300,10 +308,11 @@ public class XhpcCardServiceImpl implements IXhpcCardService { dataDTO.setUserType(2); searchCardResponse.getData().add(dataDTO); } - break; + return R.ok(searchCardResponse); case 3: - List xhpcCustomersPersonnelList = xhpcCustomersPersonnelMapper.selectByOperatorId(operatorId, queryCondition.getCurrentPage(), queryCondition.getItems()); - Long allCount2 = xhpcCustomersPersonnelMapper.selectCountByOperatorId(operatorId); + List userIdList2 = xhpcCardMapper.selectUserIdsByUserType(queryCondition.getUserType()); + List xhpcCustomersPersonnelList = xhpcCustomersPersonnelMapper.selectByOperatorId(operatorId, queryCondition.getCurrentPage(), queryCondition.getItems(), userIdList2); + Long allCount2 = xhpcCustomersPersonnelMapper.selectCountByOperatorId(operatorId, userIdList2); searchCardResponse.setTotalItems(allCount2); for (XhpcCustomersPersonnel xhpcCustomersPersonnel : xhpcCustomersPersonnelList) { SearchCardResponse.DataDTO dataDTO = new SearchCardResponse.DataDTO(); @@ -311,7 +320,7 @@ public class XhpcCardServiceImpl implements IXhpcCardService { dataDTO.setUserType(3); searchCardResponse.getData().add(dataDTO); } - break; + return R.ok(searchCardResponse); default: return R.fail("没有此用户类型"); } @@ -328,14 +337,40 @@ public class XhpcCardServiceImpl implements IXhpcCardService { } //build an association XhpcIcCardInfo xhpcIcCardInfo = new XhpcIcCardInfo(); + SysUser sysUser = tokenService.getLoginUser().getSysUser(); + String tenantId = sysUser.getTenantId(); + xhpcIcCardInfo.setTenantId(tenantId); + //获取指定用户类型的id + switch (bindCardInfo.getUserType()) { + case 0: + XhpcAppUser xhpcAppUser = xhpcAppUserMapper.selectByPhone(bindCardInfo.getUserAccount()); + Long appUserId = xhpcAppUser.getAppUserId(); + xhpcIcCardInfo.setUserId(appUserId); + break; + case 2: + XhpcCommunityPersonnel xhpcCommunityPersonnel = xhpcCommunityPersonnelMapper.selectByAccount(bindCardInfo.getUserAccount()); + Long communityPersonnelId = xhpcCommunityPersonnel.getCommunityPersonnelId(); + xhpcIcCardInfo.setUserId(communityPersonnelId); + break; + case 3: + XhpcCustomersPersonnel xhpcCustomersPersonnel = xhpcCustomersPersonnelMapper.selectByAccount(bindCardInfo.getUserAccount()); + Long customersId = xhpcCustomersPersonnel.getCustomersId(); + xhpcCustomersPersonnel.setCustomersId(customersId); + break; + default: + return R.fail("没有此用户类型"); + } xhpcIcCardInfo.setTIccardInfoId(String.valueOf(bindCardInfo.getCardRecordId())); xhpcIcCardInfo.setUseStatus(1L); xhpcIcCardInfo.setCreateTime(new Date()); - TIccardInfo tIccardInfo = tIccardInfoMapper.selectByPrimaryKey(bindCardInfo.getCardRecordId()); - xhpcIcCardInfo.setUserId(Long.valueOf(tIccardInfo.getUserindex())); xhpcIcCardInfo.setUserAccount(bindCardInfo.getUserAccount()); xhpcIcCardInfo.setUserType(bindCardInfo.getUserType()); + TIccardInfo tIccardInfo = new TIccardInfo(); + tIccardInfo.setId(bindCardInfo.getCardRecordId()); + tIccardInfo.setStatus(1); + tIccardInfoMapper.updateByPrimaryKeySelective(tIccardInfo); xhpcCardMapper.insertSelective(xhpcIcCardInfo); + //todo 增加绑定日志 return R.ok(); } @@ -615,6 +650,7 @@ public class XhpcCardServiceImpl implements IXhpcCardService { //1.find card record according card id //2.完成联网卡表的状态改变 //3.完成朱老师那边的卡表状态改变 + //4.释放关联用户 //4.写日志到log表中 XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.selectBytCardId(String.valueOf(cardRecordId)); if (xhpcIcCardInfo.getDelFlag() == 1) { diff --git a/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardInfoMapper.xml b/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardInfoMapper.xml index 2d6adae6..03fe30d0 100644 --- a/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardInfoMapper.xml +++ b/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardInfoMapper.xml @@ -94,6 +94,7 @@ + order by t_card.id desc limit #{currentPage},#{items} @@ -51,11 +57,17 @@ from xhpc_app_user - - and phone = #{userAccount} + + and phone like concat('%',#{queryCondition.userAccount},'%') + + + and app_user_id not in + + #{userId} + - limit #{currentPage},#{items} + limit #{queryCondition.currentPage},#{queryCondition.items} + \ No newline at end of file diff --git a/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCommunityPersonnelMapper.xml b/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCommunityPersonnelMapper.xml index b1955ad3..6d5413aa 100644 --- a/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCommunityPersonnelMapper.xml +++ b/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCommunityPersonnelMapper.xml @@ -54,18 +54,30 @@ from xhpc_community_personnel - - and account = #{userAccount} + + and account like concat('%',#{queryCondition.userAccount},'%') + + + and communitiy_personnel_id not in + + #{userId} + - limit #{currentPage},#{items} + limit #{queryCondition.currentPage},#{queryCondition.items} @@ -73,14 +85,27 @@ select from xhpc_community_personnel - where create_type = 2 and create_id = #{operatorId} + where create_type = 2 + and create_id = #{operatorId} + + and community_personnel_id not in + + #{userId} + + limit #{currentPage},#{items} @@ -74,13 +86,25 @@ from xhpc_customers_personnel where create_type = 2 and create_id = #{operatorId} + + and customers_personnel_id not in + + #{userId} + + limit #{currentPage},#{items}