完成查询用户信息接口
This commit is contained in:
parent
69cf2dd3e6
commit
a9ac2b784e
@ -108,5 +108,17 @@ public class XhpcCardController extends BaseController {
|
||||
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);
|
||||
|
||||
/**
|
||||
* 查询离线用户信息
|
||||
*
|
||||
* @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 org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface XhpcCardMapper {
|
||||
|
||||
IccardInfo getIccardInfoCardno(@Param("cardno") String cardno);
|
||||
@ -22,5 +24,22 @@ public interface XhpcCardMapper {
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* 查询绑卡用户信息
|
||||
*
|
||||
* @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.domain.R;
|
||||
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.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -44,16 +45,18 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
|
||||
private XhpcCommunityPersonnelMapper xhpcCommunityPersonnelMapper;
|
||||
@Resource
|
||||
private XhpcCustomersPersonnelMapper xhpcCustomersPersonnelMapper;
|
||||
@Resource
|
||||
TokenService tokenService;
|
||||
|
||||
@Override
|
||||
public R cardStartup(String cardno, String serialNumber,String rateModelId) {
|
||||
public R cardStartup(String cardno, String serialNumber, String rateModelId) {
|
||||
|
||||
IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno);
|
||||
if(iccardInfo !=null){
|
||||
if(iccardInfo.getCardtype()==0){
|
||||
if (iccardInfo != null) {
|
||||
if (iccardInfo.getCardtype() == 0) {
|
||||
return R.fail(Constants.OFFLINE_CARD);
|
||||
}
|
||||
if(iccardInfo.getStatus()==0){
|
||||
if (iccardInfo.getStatus() == 0) {
|
||||
return R.fail(Constants.ZERO_CARD);
|
||||
}
|
||||
if(iccardInfo.getStatus()==2){
|
||||
@ -130,49 +133,63 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
|
||||
|
||||
@Override
|
||||
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());
|
||||
queryConditions.setCurrentPage(startIndex);
|
||||
CardList cardList = new CardList();
|
||||
cardList.setTotalItems(0);
|
||||
cardList.setTotalItems(0L);
|
||||
cardList.setData(new ArrayList<>());
|
||||
List<TIccardInfo> tIccardInfoList2 = tIccardInfoMapper.selectAllBy(queryConditions);
|
||||
List<TIccardInfo> tIccardInfoList = tIccardInfoMapper.selectAll();
|
||||
if (tIccardInfoList.isEmpty()) {
|
||||
return R.ok(cardList);
|
||||
List<Map<String, Object>> listData = tIccardInfoMapper.selectAllBy(queryConditions);
|
||||
Long totalCount = tIccardInfoMapper.selectTotalCountBy(queryConditions);
|
||||
cardList.setTotalItems(totalCount);
|
||||
if (listData.isEmpty()) {
|
||||
return R.ok();
|
||||
}
|
||||
//1.遍历卡记录
|
||||
for (TIccardInfo tIccardInfo : tIccardInfoList) {
|
||||
for (Map<String, Object> data : listData) {
|
||||
//2.封装通用数据
|
||||
CardList.DataDTO dataDTO = new CardList.DataDTO();
|
||||
dataDTO.setCardSerialNumber(tIccardInfo.getCardid());
|
||||
dataDTO.setCardPhysicalNumber(tIccardInfo.getCardno());
|
||||
//获取授权商id
|
||||
String corpno = tIccardInfo.getCorpno();
|
||||
XhpcOperator xhpcOperator = xhpcOperatorMapper.selectByPrimaryKey(Long.valueOf(corpno));
|
||||
dataDTO.setGrantOperator(xhpcOperator.getName());
|
||||
dataDTO.setClassification(tIccardInfo.getCardtype());
|
||||
dataDTO.setCardSerialNumber((String) data.get("cardID"));
|
||||
dataDTO.setCardPhysicalNumber((String) data.get("cardNo"));
|
||||
//授权商名称
|
||||
dataDTO.setGrantOperator((String) data.get("name"));
|
||||
dataDTO.setClassification((Integer) data.get("cardType"));
|
||||
dataDTO.setCardRecordId((Integer) data.get("id"));
|
||||
dataDTO.setCardType((Integer) data.get("is_platform"));
|
||||
dataDTO.setCardStatus((Integer) data.get("status"));
|
||||
dataDTO.setUserAccount((String) data.get("user_account"));
|
||||
//3.判断是否是离线卡,离线卡处理逻辑
|
||||
if (dataDTO.getClassification() == 0) {
|
||||
dataDTO.setCardType(1);
|
||||
//获取卡用户索引,为null表示没有该卡没有绑用户
|
||||
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());
|
||||
}
|
||||
//离线用户类型为10
|
||||
dataDTO.setUserType(10L);
|
||||
} else {
|
||||
//联网卡处理逻辑
|
||||
dataDTO.setCardStatus(0);
|
||||
Integer isPlatform = tIccardInfo.getIsPlatform();
|
||||
dataDTO.setCardType(isPlatform);
|
||||
dataDTO.setUserType((Long) data.get("user_type"));
|
||||
}
|
||||
cardList.getData().add(dataDTO);
|
||||
|
||||
}
|
||||
return R.ok(cardList);
|
||||
}
|
||||
@ -314,4 +331,45 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
|
||||
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>
|
||||
</where>
|
||||
</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
|
||||
from t_iccard_info
|
||||
|
||||
@ -17,12 +17,13 @@
|
||||
<result column="user_phone" jdbcType="VARCHAR" property="userPhone"/>
|
||||
<result column="user_vehicle" jdbcType="VARCHAR" property="userVehicle"/>
|
||||
<result column="del_flag" jdbcType="BIGINT" property="delFlag"/>
|
||||
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
ic_card_info_id
|
||||
, 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,
|
||||
del_flag
|
||||
del_flag,tenant_id
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -211,4 +212,25 @@
|
||||
and del_flag = 0
|
||||
order by create_time desc limit 1
|
||||
</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>
|
||||
Loading…
x
Reference in New Issue
Block a user