完成查询用户信息接口
This commit is contained in:
parent
69cf2dd3e6
commit
a9ac2b784e
@ -108,5 +108,17 @@ public class XhpcCardController extends BaseController {
|
|||||||
return xhpcCardService.onlineCardBind(bindCardInfo);
|
return xhpcCardService.onlineCardBind(bindCardInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看完整用户信息接口
|
||||||
|
*
|
||||||
|
* @param userAccount 用户账号
|
||||||
|
* @param userType 用户类型( 0 C端用户 1 流量方用户 2社区用户 3B端用户,10离线用户)
|
||||||
|
*/
|
||||||
|
@GetMapping("/user")
|
||||||
|
public R<CardUserInfo> queryWholeUserInfo(@RequestParam String userAccount, @RequestParam Integer userType) {
|
||||||
|
|
||||||
|
return xhpcCardService.queryWholeUserInfo(userAccount, userType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,60 @@
|
|||||||
|
package com.xhpc.card.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储返回数据的实体类
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class CardUserInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户类型( 0 C端用户 1 流量方用户 2社区用户 3B端用户,10离线用户)
|
||||||
|
*/
|
||||||
|
@JsonProperty("userType")
|
||||||
|
private Integer userType;
|
||||||
|
@JsonProperty("userAge")
|
||||||
|
private Integer userAge;
|
||||||
|
@JsonProperty("userName")
|
||||||
|
private String userName;
|
||||||
|
/**
|
||||||
|
* 性别(0男,1女)
|
||||||
|
*/
|
||||||
|
@JsonProperty("userSex")
|
||||||
|
private Integer userSex;
|
||||||
|
@JsonProperty("idCardNumber")
|
||||||
|
private String idCardNumber;
|
||||||
|
@JsonProperty("phoneNumber")
|
||||||
|
private String phoneNumber;
|
||||||
|
@JsonProperty("licencePlate")
|
||||||
|
private String licencePlate;
|
||||||
|
@JsonProperty("cardSerialNumber")
|
||||||
|
private String cardSerialNumber;
|
||||||
|
@JsonProperty("cardPhysicalNumber")
|
||||||
|
private String cardPhysicalNumber;
|
||||||
|
@JsonProperty("grantOperatorName")
|
||||||
|
private String grantOperatorName;
|
||||||
|
/**
|
||||||
|
* 卡类型(0 平台,1 运营商)
|
||||||
|
*/
|
||||||
|
@JsonProperty("cardType")
|
||||||
|
private Integer cardType;
|
||||||
|
/**
|
||||||
|
* 卡分类(0.离线卡; 1.联网卡)
|
||||||
|
*/
|
||||||
|
@JsonProperty("cardClassification")
|
||||||
|
private Integer cardClassification;
|
||||||
|
@JsonProperty("cashPledge")
|
||||||
|
private Integer cashPledge;
|
||||||
|
@JsonProperty("balance")
|
||||||
|
private Integer balance;
|
||||||
|
@JsonProperty("userAccount")
|
||||||
|
private String userAccount;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -50,4 +50,15 @@ public interface TIccardInfoMapper {
|
|||||||
*/
|
*/
|
||||||
Long selectTotalCountBy(QueryConditions queryConditions);
|
Long selectTotalCountBy(QueryConditions queryConditions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询离线用户信息
|
||||||
|
*
|
||||||
|
* @param userAccount 用户账户
|
||||||
|
* @return 返回用户信息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/2/11 17:15
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
Map<String, Object> selectByPhone(String userAccount);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -4,6 +4,8 @@ import com.xhpc.card.pojo.XhpcIcCardInfo;
|
|||||||
import com.xhpc.common.domain.IccardInfo;
|
import com.xhpc.common.domain.IccardInfo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface XhpcCardMapper {
|
public interface XhpcCardMapper {
|
||||||
|
|
||||||
IccardInfo getIccardInfoCardno(@Param("cardno") String cardno);
|
IccardInfo getIccardInfoCardno(@Param("cardno") String cardno);
|
||||||
@ -22,5 +24,22 @@ public interface XhpcCardMapper {
|
|||||||
|
|
||||||
int updateByPrimaryKey(XhpcIcCardInfo record);
|
int updateByPrimaryKey(XhpcIcCardInfo record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* query record of xhpc_ic_card_info by id of t_iccard_info
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/2/10 13:28
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
XhpcIcCardInfo selectBytCardId(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询非联网卡用户信息
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/2/11 19:27
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
Map<String, Object> selectByAccount(@Param("userAccount") String userAccount, @Param("userType") Integer userType);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -85,4 +85,16 @@ public interface IXhpcCardService {
|
|||||||
*/
|
*/
|
||||||
R<Object> onlineCardBind(BindCardInfo bindCardInfo);
|
R<Object> onlineCardBind(BindCardInfo bindCardInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询绑卡用户信息
|
||||||
|
*
|
||||||
|
* @param userAccount 用户信息
|
||||||
|
* @param userType 用户类型
|
||||||
|
* @return 卡用户的完整信息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/2/9 17:50
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
R<CardUserInfo> queryWholeUserInfo(String userAccount, Integer userType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,14 +9,15 @@ import com.xhpc.common.api.CardHistoryOrderService;
|
|||||||
import com.xhpc.common.core.constant.Constants;
|
import com.xhpc.common.core.constant.Constants;
|
||||||
import com.xhpc.common.core.domain.R;
|
import com.xhpc.common.core.domain.R;
|
||||||
import com.xhpc.common.domain.IccardInfo;
|
import com.xhpc.common.domain.IccardInfo;
|
||||||
|
import com.xhpc.common.security.service.TokenService;
|
||||||
|
import com.xhpc.common.util.UserTypeUtil;
|
||||||
|
import com.xhpc.system.api.domain.SysUser;
|
||||||
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,16 +45,18 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
|
|||||||
private XhpcCommunityPersonnelMapper xhpcCommunityPersonnelMapper;
|
private XhpcCommunityPersonnelMapper xhpcCommunityPersonnelMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private XhpcCustomersPersonnelMapper xhpcCustomersPersonnelMapper;
|
private XhpcCustomersPersonnelMapper xhpcCustomersPersonnelMapper;
|
||||||
|
@Resource
|
||||||
|
TokenService tokenService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R cardStartup(String cardno, String serialNumber,String rateModelId) {
|
public R cardStartup(String cardno, String serialNumber, String rateModelId) {
|
||||||
|
|
||||||
IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno);
|
IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno);
|
||||||
if(iccardInfo !=null){
|
if (iccardInfo != null) {
|
||||||
if(iccardInfo.getCardtype()==0){
|
if (iccardInfo.getCardtype() == 0) {
|
||||||
return R.fail(Constants.OFFLINE_CARD);
|
return R.fail(Constants.OFFLINE_CARD);
|
||||||
}
|
}
|
||||||
if(iccardInfo.getStatus()==0){
|
if (iccardInfo.getStatus() == 0) {
|
||||||
return R.fail(Constants.ZERO_CARD);
|
return R.fail(Constants.ZERO_CARD);
|
||||||
}
|
}
|
||||||
if(iccardInfo.getStatus()==2){
|
if(iccardInfo.getStatus()==2){
|
||||||
@ -130,49 +133,63 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<CardList> queryCardListBy(QueryConditions queryConditions) {
|
public R<CardList> queryCardListBy(QueryConditions queryConditions) {
|
||||||
//todo 最后再做
|
//获取登录用户
|
||||||
|
LoginUser loginUser = tokenService.getLoginUser();
|
||||||
|
//获取登录用户类型
|
||||||
|
SysUser sysUser = loginUser.getSysUser();
|
||||||
|
String loginUserType = sysUser.getUserType();
|
||||||
|
//判断登录用户类型
|
||||||
|
//如果是运营商 01 03 都是运营商
|
||||||
|
if (UserTypeUtil.SYS_USER_TYPE_ONE.equals(loginUserType) || UserTypeUtil.SYS_USER_TYPE_THREE.equals(loginUserType)) {
|
||||||
|
//设置运营商id
|
||||||
|
queryConditions.setLoginUserId(Long.valueOf(loginUserType));
|
||||||
|
//平台
|
||||||
|
} else if (UserTypeUtil.SYS_USER_TYPE_ZERO.equals(loginUserType)) {
|
||||||
|
//平台可能会选中多个授权运营商
|
||||||
|
String grantOperatorIds = (String) queryConditions.getGrantOperatorIds();
|
||||||
|
if (!"".equals(grantOperatorIds)) {
|
||||||
|
String[] splitGrantOperatorIds = grantOperatorIds.split(",");
|
||||||
|
List<String> idsList = Arrays.asList(splitGrantOperatorIds);
|
||||||
|
queryConditions.setGrantOperatorIds(idsList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//获取登录用户的租户id
|
||||||
|
String tenantId = sysUser.getTenantId();
|
||||||
|
queryConditions.setTenantId(tenantId);
|
||||||
//计算分页索引
|
//计算分页索引
|
||||||
long startIndex = MyPagingUtil.calculateStartIndex(queryConditions.getCurrentPage(), queryConditions.getItems());
|
long startIndex = MyPagingUtil.calculateStartIndex(queryConditions.getCurrentPage(), queryConditions.getItems());
|
||||||
queryConditions.setCurrentPage(startIndex);
|
queryConditions.setCurrentPage(startIndex);
|
||||||
CardList cardList = new CardList();
|
CardList cardList = new CardList();
|
||||||
cardList.setTotalItems(0);
|
cardList.setTotalItems(0L);
|
||||||
cardList.setData(new ArrayList<>());
|
cardList.setData(new ArrayList<>());
|
||||||
List<TIccardInfo> tIccardInfoList2 = tIccardInfoMapper.selectAllBy(queryConditions);
|
List<Map<String, Object>> listData = tIccardInfoMapper.selectAllBy(queryConditions);
|
||||||
List<TIccardInfo> tIccardInfoList = tIccardInfoMapper.selectAll();
|
Long totalCount = tIccardInfoMapper.selectTotalCountBy(queryConditions);
|
||||||
if (tIccardInfoList.isEmpty()) {
|
cardList.setTotalItems(totalCount);
|
||||||
return R.ok(cardList);
|
if (listData.isEmpty()) {
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
//1.遍历卡记录
|
//1.遍历卡记录
|
||||||
for (TIccardInfo tIccardInfo : tIccardInfoList) {
|
for (Map<String, Object> data : listData) {
|
||||||
//2.封装通用数据
|
//2.封装通用数据
|
||||||
CardList.DataDTO dataDTO = new CardList.DataDTO();
|
CardList.DataDTO dataDTO = new CardList.DataDTO();
|
||||||
dataDTO.setCardSerialNumber(tIccardInfo.getCardid());
|
dataDTO.setCardSerialNumber((String) data.get("cardID"));
|
||||||
dataDTO.setCardPhysicalNumber(tIccardInfo.getCardno());
|
dataDTO.setCardPhysicalNumber((String) data.get("cardNo"));
|
||||||
//获取授权商id
|
//授权商名称
|
||||||
String corpno = tIccardInfo.getCorpno();
|
dataDTO.setGrantOperator((String) data.get("name"));
|
||||||
XhpcOperator xhpcOperator = xhpcOperatorMapper.selectByPrimaryKey(Long.valueOf(corpno));
|
dataDTO.setClassification((Integer) data.get("cardType"));
|
||||||
dataDTO.setGrantOperator(xhpcOperator.getName());
|
dataDTO.setCardRecordId((Integer) data.get("id"));
|
||||||
dataDTO.setClassification(tIccardInfo.getCardtype());
|
dataDTO.setCardType((Integer) data.get("is_platform"));
|
||||||
|
dataDTO.setCardStatus((Integer) data.get("status"));
|
||||||
|
dataDTO.setUserAccount((String) data.get("user_account"));
|
||||||
//3.判断是否是离线卡,离线卡处理逻辑
|
//3.判断是否是离线卡,离线卡处理逻辑
|
||||||
if (dataDTO.getClassification() == 0) {
|
if (dataDTO.getClassification() == 0) {
|
||||||
dataDTO.setCardType(1);
|
//离线用户类型为10
|
||||||
//获取卡用户索引,为null表示没有该卡没有绑用户
|
dataDTO.setUserType(10L);
|
||||||
Integer userIndex = tIccardInfo.getUserindex();
|
|
||||||
if (userIndex == null) {
|
|
||||||
dataDTO.setCardStatus(1);
|
|
||||||
} else {
|
|
||||||
dataDTO.setCardStatus(0);
|
|
||||||
dataDTO.setUserType(10);
|
|
||||||
TIccardUsers tIccardUsers = tIccardUsersMapper.selectByPrimaryKey(userIndex);
|
|
||||||
dataDTO.setUserAccount(tIccardUsers.getPhone());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//联网卡处理逻辑
|
dataDTO.setUserType((Long) data.get("user_type"));
|
||||||
dataDTO.setCardStatus(0);
|
|
||||||
Integer isPlatform = tIccardInfo.getIsPlatform();
|
|
||||||
dataDTO.setCardType(isPlatform);
|
|
||||||
}
|
}
|
||||||
cardList.getData().add(dataDTO);
|
cardList.getData().add(dataDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
return R.ok(cardList);
|
return R.ok(cardList);
|
||||||
}
|
}
|
||||||
@ -314,4 +331,45 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<CardUserInfo> queryWholeUserInfo(String userAccount, Integer userType) {
|
||||||
|
|
||||||
|
CardUserInfo cardUserInfo = new CardUserInfo();
|
||||||
|
//离线用户
|
||||||
|
if (userType == 10) {
|
||||||
|
cardUserInfo.setUserType(userType);
|
||||||
|
Map<String, Object> userData = tIccardInfoMapper.selectByPhone(userAccount);
|
||||||
|
if (userData == null) {
|
||||||
|
return R.fail("没有此类型用户");
|
||||||
|
}
|
||||||
|
cardUserInfo.setUserAge((Integer) userData.get("userAge"));
|
||||||
|
cardUserInfo.setUserName((String) userData.get("userName"));
|
||||||
|
cardUserInfo.setUserSex((Integer) userData.get("userSex"));
|
||||||
|
cardUserInfo.setIdCardNumber((String) userData.get("idNumber"));
|
||||||
|
cardUserInfo.setPhoneNumber((String) userData.get("phone"));
|
||||||
|
cardUserInfo.setLicencePlate((String) userData.get("licencePlate"));
|
||||||
|
fillUserInfo(cardUserInfo, userData);
|
||||||
|
cardUserInfo.setBalance((Integer) userData.get("balance"));
|
||||||
|
return R.ok(cardUserInfo);
|
||||||
|
} else {
|
||||||
|
//联网卡用户
|
||||||
|
cardUserInfo.setUserType(userType);
|
||||||
|
Map<String, Object> userData = xhpcCardMapper.selectByAccount(userAccount, userType);
|
||||||
|
cardUserInfo.setUserAccount((String) userData.get("user_account"));
|
||||||
|
fillUserInfo(cardUserInfo, userData);
|
||||||
|
return R.ok(cardUserInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillUserInfo(CardUserInfo cardUserInfo, Map<String, Object> userData) {
|
||||||
|
|
||||||
|
cardUserInfo.setCardSerialNumber((String) userData.get("cardID"));
|
||||||
|
cardUserInfo.setCardPhysicalNumber((String) userData.get("cardNo"));
|
||||||
|
cardUserInfo.setGrantOperatorName((String) userData.get("name"));
|
||||||
|
cardUserInfo.setCardType((Integer) userData.get("is_platform"));
|
||||||
|
cardUserInfo.setCardClassification((Integer) userData.get("cardType"));
|
||||||
|
cardUserInfo.setCashPledge((Integer) userData.get("cashPledge"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,6 +146,25 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectByPhone" resultType="java.util.Map">
|
||||||
|
SELECT users.userAge,
|
||||||
|
users.userName,
|
||||||
|
users.userSex,
|
||||||
|
users.idNumber,
|
||||||
|
users.phone,
|
||||||
|
users.licencePlate,
|
||||||
|
info.cardID,
|
||||||
|
info.cardNo,
|
||||||
|
operator.`name`,
|
||||||
|
info.is_platform,
|
||||||
|
info.cardType,
|
||||||
|
info.cashPledge,
|
||||||
|
info.balance
|
||||||
|
FROM t_iccard_users users
|
||||||
|
LEFT JOIN t_iccard_info info ON users.id = info.userIndex
|
||||||
|
LEFT JOIN xhpc_operator operator ON info.corpNo = operator.operator_id
|
||||||
|
WHERE users.phone = #{userAccount}
|
||||||
|
</select>
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||||
delete
|
delete
|
||||||
from t_iccard_info
|
from t_iccard_info
|
||||||
|
|||||||
@ -17,12 +17,13 @@
|
|||||||
<result column="user_phone" jdbcType="VARCHAR" property="userPhone"/>
|
<result column="user_phone" jdbcType="VARCHAR" property="userPhone"/>
|
||||||
<result column="user_vehicle" jdbcType="VARCHAR" property="userVehicle"/>
|
<result column="user_vehicle" jdbcType="VARCHAR" property="userVehicle"/>
|
||||||
<result column="del_flag" jdbcType="BIGINT" property="delFlag"/>
|
<result column="del_flag" jdbcType="BIGINT" property="delFlag"/>
|
||||||
|
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
ic_card_info_id
|
ic_card_info_id
|
||||||
, t_iccard_info_id, use_status, create_time, user_id, user_account,
|
, t_iccard_info_id, use_status, create_time, user_id, user_account,
|
||||||
user_type, user_name, user_id_card, user_age, user_sex, user_phone, user_vehicle,
|
user_type, user_name, user_id_card, user_age, user_sex, user_phone, user_vehicle,
|
||||||
del_flag
|
del_flag,tenant_id
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
@ -211,4 +212,25 @@
|
|||||||
and del_flag = 0
|
and del_flag = 0
|
||||||
order by create_time desc limit 1
|
order by create_time desc limit 1
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectBytCardId" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from xhpc_ic_card_info
|
||||||
|
where t_iccard_info_id = #{id}
|
||||||
|
</select>
|
||||||
|
<select id="selectByAccount" resultType="java.util.Map">
|
||||||
|
SELECT o.user_type,
|
||||||
|
o.user_account,
|
||||||
|
info.cardID,
|
||||||
|
info.cardNo,
|
||||||
|
oper.`name`,
|
||||||
|
info.is_platform,
|
||||||
|
info.cardType,
|
||||||
|
info.cashPledge
|
||||||
|
FROM xhpc_ic_card_info o
|
||||||
|
LEFT JOIN t_iccard_info info ON o.t_iccard_info_id = info.id
|
||||||
|
LEFT JOIN xhpc_operator oper ON oper.operator_id = info.corpNo
|
||||||
|
WHERE o.user_account = #{userAccount}
|
||||||
|
AND o.user_type = #{userType}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user