From 70f3c8b6f457c579ea042ad42259942dfb66e353 Mon Sep 17 00:00:00 2001 From: wenhui <1455474577@qq.com> Date: Wed, 2 Mar 2022 11:16:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtradebill=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E5=8D=A1=E6=9F=A5=E8=AF=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=E6=9F=A5=E8=AF=A2=E4=B8=8E=E7=BB=91=E5=AE=9A=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xhpc/card/mapper/XhpcAppUserMapper.java | 5 +- .../com/xhpc/card/mapper/XhpcCardMapper.java | 10 +++ .../mapper/XhpcCommunityPersonnelMapper.java | 8 +-- .../mapper/XhpcCustomersPersonnelMapper.java | 8 +-- .../service/impl/XhpcCardServiceImpl.java | 70 ++++++++++++++----- .../resources/mapper/TIccardInfoMapper.xml | 1 + .../resources/mapper/XhpcAppUserMapper.xml | 22 ++++-- .../main/resources/mapper/XhpcCardMapper.xml | 6 ++ .../mapper/XhpcCommunityPersonnelMapper.xml | 39 +++++++++-- .../mapper/XhpcCustomersPersonnelMapper.xml | 36 ++++++++-- .../XhpcTradebillApplication.java | 2 +- 11 files changed, 161 insertions(+), 46 deletions(-) rename xhpc-modules/xhpc-tradebill/src/main/java/com/xhpc/{tradebill => }/XhpcTradebillApplication.java (97%) 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}