From 1e8a803dbad5f77fecc9a6f6bfe82432c8d233f3 Mon Sep 17 00:00:00 2001 From: wen <1455474577@qq.com> Date: Wed, 9 Feb 2022 17:40:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BB=91=E5=AE=9A=E8=81=94?= =?UTF-8?q?=E7=BD=91=E5=8D=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/controller/XhpcCardController.java | 15 +- .../com/xhpc/card/domain/BindCardEcho.java | 5 + .../com/xhpc/card/domain/BindCardInfo.java | 62 +++++ .../com/xhpc/card/mapper/XhpcCardMapper.java | 26 +- .../com/xhpc/card/pojo/XhpcIcCardInfo.java | 88 +++++++ .../xhpc/card/service/IXhpcCardService.java | 13 +- .../service/impl/XhpcCardServiceImpl.java | 118 +++++---- .../main/resources/mapper/XhpcCardMapper.xml | 245 +++++++++++++++--- 8 files changed, 479 insertions(+), 93 deletions(-) create mode 100644 xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/BindCardInfo.java create mode 100644 xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/pojo/XhpcIcCardInfo.java diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java index acd98aa3..a2249f37 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java @@ -72,19 +72,19 @@ public class XhpcCardController extends BaseController { } /** - * 绑定联网卡回显信息接口 + * 绑定联网卡时回显信息接口 * * @author WH * @date 2022/1/26 10:37 * @since version-1.0 */ @GetMapping("/non-bind/{cardId}") - public R bindCard(@PathVariable("cardId") Long cardId) { + public R noBindCard(@PathVariable("cardId") Long cardId) { if (cardId == null) { return R.fail("cardId不能为null"); } - return xhpcCardService.bindCard(cardId); + return xhpcCardService.noBindCardInfo(cardId); } /** @@ -100,5 +100,14 @@ public class XhpcCardController extends BaseController { return xhpcCardService.searchCardUser(queryCondition); } + /** + * 绑定联网卡 + */ + @PostMapping("/online/bind") + public R onlineCardBind(@RequestBody BindCardInfo bindCardInfo) { + + return xhpcCardService.onlineCardBind(bindCardInfo); + } + } diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/BindCardEcho.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/BindCardEcho.java index 4c9849ee..6c36cf54 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/BindCardEcho.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/BindCardEcho.java @@ -53,5 +53,10 @@ public class BindCardEcho { */ @JsonProperty("cashPledge") private Long cashPledge; + /** + * 卡记录id + */ + @JsonProperty("cardRecordId") + private Integer cardRecordId; } diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/BindCardInfo.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/BindCardInfo.java new file mode 100644 index 00000000..dc78731d --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/BindCardInfo.java @@ -0,0 +1,62 @@ +package com.xhpc.card.domain; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@NoArgsConstructor +@Data +public class BindCardInfo { + + /** + * 用户类型 + * ( 0 C端用户 1 流量方用户 2社区用户 3 B端用户) + */ + @JsonProperty("userType") + @NotNull(message = "userType的参数名不正确或者userType的值为空,请检查传入参数") + private Integer userType; + /** + * 用户账号 + */ + @JsonProperty("userAccount") + @NotNull(message = "userAccount的参数名不正确或者userAccount的值为空,请检查传入参数") + @NotBlank(message = "userAccount的参数不能为''字符串,请检查传入参数") + private String userAccount; + /** + * 卡序列号 + */ + @JsonProperty("cardId") + @NotNull(message = "cardId的参数名不正确或者cardId的值为空,请检查传入参数") + @NotBlank(message = "cardId的参数不能为''字符串,请检查传入参数") + private String cardId; + /** + * 卡编号 + */ + @JsonProperty("cardNo") + @NotNull(message = "cardNo的参数名不正确或者cardNo的值为空,请检查传入参数") + @NotBlank(message = "cardNo的参数不能为''字符串,请检查传入参数") + private String cardNo; + /** + * 卡类型(离线还是联网 0,离线,1联网) + */ + @JsonProperty("cardType") + @NotNull(message = "cardType的参数名不正确或者cardType的值为空,请检查传入参数") + private Integer cardType; + /** + * 卡分类 0表示平台,1表示运营商 + */ + @JsonProperty("cardClassification") + @NotNull(message = "cardClassification的参数名不正确或者cardClassification的值为空,请检查传入参数") + private Integer cardClassification; + /** + * 卡记录id + */ + @JsonProperty("cardRecordId") + @NotNull(message = "cardRecordId的参数名不正确或者cardRecordId的值为空,请检查传入参数") + private Integer cardRecordId; + +} 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 fcab1a1b..3aa43ec0 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 @@ -1,16 +1,26 @@ package com.xhpc.card.mapper; +import com.xhpc.card.pojo.XhpcIcCardInfo; import com.xhpc.common.domain.IccardInfo; -import com.xhpc.common.domain.XhpcIcCardInfo; import org.apache.ibatis.annotations.Param; -/** - * @author yuyang - * @date 2022/1/20 13:45 - */ public interface XhpcCardMapper { - IccardInfo getIccardInfoCardno(@Param("cardno")String cardno); + IccardInfo getIccardInfoCardno(@Param("cardno") String cardno); - XhpcIcCardInfo getXhpcIcCardInfo(@Param("tIccardInfoId")String tIccardInfoId); -} + XhpcIcCardInfo getXhpcIcCardInfo(@Param("tIccardInfoId") String tIccardInfoId); + + int deleteByPrimaryKey(Long icCardInfoId); + + int insert(XhpcIcCardInfo record); + + int insertSelective(XhpcIcCardInfo record); + + XhpcIcCardInfo selectByPrimaryKey(Long icCardInfoId); + + int updateByPrimaryKeySelective(XhpcIcCardInfo record); + + int updateByPrimaryKey(XhpcIcCardInfo record); + + +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/pojo/XhpcIcCardInfo.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/pojo/XhpcIcCardInfo.java new file mode 100644 index 00000000..fc64f9c4 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/pojo/XhpcIcCardInfo.java @@ -0,0 +1,88 @@ +package com.xhpc.card.pojo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * xhpc_ic_card_info + * + * @author + */ +@Data +public class XhpcIcCardInfo implements Serializable { + + /** + * 记录id + */ + private Long icCardInfoId; + + /** + * t_iccard_info表中的卡记录的id + */ + private String tIccardInfoId; + + /** + * 卡使用状态(0未使用,1已绑定) + */ + private Long useStatus; + + /** + * 绑卡日期 + */ + private Date createTime; + + /** + * 用户id + */ + private Integer userId; + + /** + * 用户账户 + */ + private String userAccount; + + /** + * 用户类型(0 C端用户 1 流量方用户 2社区用户 3B端用户) + */ + private Long userType; + + /** + * 用户姓名 + */ + private String userName; + + /** + * 用户身份证 + */ + private String userIdCard; + + /** + * 用户年龄 + */ + private Long userAge; + + /** + * 用户性别(0女,1男) + */ + private Long userSex; + + /** + * 用户手机号码 + */ + private String userPhone; + + /** + * 用户车牌号码 + */ + private String userVehicle; + + /** + * 逻辑删除字段(默认为0,1为删除) + */ + private Long delFlag; + + private static final long serialVersionUID = 1L; + +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java index 91274a72..c6307c48 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java @@ -61,7 +61,7 @@ public interface IXhpcCardService { * @date 2022/1/28 10:44 * @since version-1.0 */ - R bindCard(Long cardId); + R noBindCardInfo(Long cardId); /** * 平台、运营商选择用户时,查询指定类型下的所有用户数据 @@ -74,4 +74,15 @@ public interface IXhpcCardService { */ R searchCardUser(SearchCardUserQueryCondition queryCondition); + /** + * 联网卡绑定 + * + * @param bindCardInfo 要绑定的联网卡信息 + * @return 操作结果 + * @author WH + * @date 2022/2/9 10:48 + * @since version-1.0 + */ + R onlineCardBind(BindCardInfo bindCardInfo); + } 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 1e044c3f..02110334 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 @@ -6,15 +6,14 @@ import com.xhpc.card.pojo.*; import com.xhpc.card.service.IXhpcCardService; import com.xhpc.card.utils.MyPagingUtil; 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.domain.XhpcIcCardInfo; 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.stream.Collectors; @@ -27,7 +26,6 @@ public class XhpcCardServiceImpl implements IXhpcCardService { @Resource private XhpcCardMapper xhpcCardMapper; - @Resource private CardHistoryOrderService cardHistoryOrderService; @Resource @@ -46,47 +44,53 @@ public class XhpcCardServiceImpl implements IXhpcCardService { private XhpcCustomersPersonnelMapper xhpcCustomersPersonnelMapper; - /** - * 卡启动充电判断 - * - * @param cardno - * @param serialNumber - * @return - */ + ///** + // * 卡启动充电判断 + // * + // * @param cardno + // * @param serialNumber + // * @return + // */ + //@Override + //public R cardStartup(String cardno, String serialNumber) { + // + // IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno); + // if(iccardInfo !=null){ + // if(iccardInfo.getCardtype()==0){ + // return R.fail(Constants.OFFLINE_CARD); + // } + // if(iccardInfo.getStatus()==0){ + // return R.fail(Constants.ZERO_CARD); + // } + // if(iccardInfo.getStatus()==2){ + // return R.fail(Constants.TWO_CARD); + // } + // if(iccardInfo.getStatus()==3){ + // return R.fail(Constants.THREE_CARD); + // } + // if(iccardInfo.getStatus()==4){ + // return R.fail(Constants.FOUR_CARD); + // } + // }else{ + // return R.fail(Constants.LNVALID_CARD); + // } + // //查询卡号对应的用户 + // XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.getXhpcIcCardInfo(iccardInfo.getId().toString()); + // if (xhpcIcCardInfo == null) { + // return R.fail(Constants.LNVALID_USER); + // } + // Long userId = xhpcIcCardInfo.getUserId(); + // Integer userType = xhpcIcCardInfo.getUserType(); + // String tenantId = xhpcIcCardInfo.getTenantId(); + // Integer type = 1; + // String grantOperator = xhpcIcCardInfo.getGrantOperatorId(); + // return cardHistoryOrderService.cardStartup(userId, serialNumber, userType, tenantId, type, grantOperator); + //} + @Override public R cardStartup(String cardno, String serialNumber) { - IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno); - if(iccardInfo !=null){ - if(iccardInfo.getCardtype()==0){ - return R.fail(Constants.OFFLINE_CARD); - } - if(iccardInfo.getStatus()==0){ - return R.fail(Constants.ZERO_CARD); - } - if(iccardInfo.getStatus()==2){ - return R.fail(Constants.TWO_CARD); - } - if(iccardInfo.getStatus()==3){ - return R.fail(Constants.THREE_CARD); - } - if(iccardInfo.getStatus()==4){ - return R.fail(Constants.FOUR_CARD); - } - }else{ - return R.fail(Constants.LNVALID_CARD); - } - //查询卡号对应的用户 - XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.getXhpcIcCardInfo(iccardInfo.getId().toString()); - if (xhpcIcCardInfo == null) { - return R.fail(Constants.LNVALID_USER); - } - Long userId = xhpcIcCardInfo.getUserId(); - Integer userType = xhpcIcCardInfo.getUserType(); - String tenantId = xhpcIcCardInfo.getTenantId(); - Integer type = 1; - String grantOperator = xhpcIcCardInfo.getGrantOperatorId(); - return cardHistoryOrderService.cardStartup(userId, serialNumber, userType, tenantId, type, grantOperator); + return null; } @Override @@ -183,7 +187,7 @@ public class XhpcCardServiceImpl implements IXhpcCardService { } @Override - public R bindCard(Long cardId) { + public R noBindCardInfo(Long cardId) { BindCardEcho bindCardEcho = new BindCardEcho(); TIccardInfo tIccardInfo = tIccardInfoMapper.selectByPrimaryKey(Math.toIntExact(cardId)); @@ -209,6 +213,8 @@ public class XhpcCardServiceImpl implements IXhpcCardService { List userType = Arrays.stream(userTypeArray).boxed().collect(Collectors.toList()); bindCardEcho.setUserType(userType); } + bindCardEcho.setCashPledge(Long.valueOf(tIccardInfo.getCashpledge())); + bindCardEcho.setCardRecordId(tIccardInfo.getId()); return R.ok(bindCardEcho); } @@ -258,9 +264,8 @@ public class XhpcCardServiceImpl implements IXhpcCardService { } break; default: - break; + return R.fail("没有此用户类型"); } - return R.ok(searchCardResponse); } else if (queryCondition.getCardClassification() == 1) { XhpcOperator operator = xhpcOperatorMapper.selectByName(queryCondition.getGrantOperatorName()); if (operator == null) { @@ -292,11 +297,30 @@ public class XhpcCardServiceImpl implements IXhpcCardService { } break; default: - break; + return R.fail("没有此用户类型"); } - return R.ok(searchCardResponse); } return R.fail("没有此卡类型"); } + @Override + @Transactional(rollbackFor = Exception.class) + public R onlineCardBind(BindCardInfo bindCardInfo) { + //check card type is online card + if (bindCardInfo.getCardType() != 1) { + R.fail("该卡不是联网卡"); + } + //build an association + XhpcIcCardInfo xhpcIcCardInfo = new XhpcIcCardInfo(); + xhpcIcCardInfo.setTIccardInfoId(String.valueOf(bindCardInfo.getCardRecordId())); + xhpcIcCardInfo.setUseStatus(1L); + xhpcIcCardInfo.setCreateTime(new Date()); + TIccardInfo tIccardInfo = tIccardInfoMapper.selectByPrimaryKey(bindCardInfo.getCardRecordId()); + xhpcIcCardInfo.setUserId(tIccardInfo.getUserindex()); + xhpcIcCardInfo.setUserAccount(bindCardInfo.getUserAccount()); + xhpcIcCardInfo.setUserType(Long.valueOf(bindCardInfo.getUserType())); + xhpcCardMapper.insertSelective(xhpcIcCardInfo); + return R.ok(); + } + } diff --git a/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCardMapper.xml b/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCardMapper.xml index cd31fad0..6813b532 100644 --- a/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCardMapper.xml +++ b/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcCardMapper.xml @@ -1,37 +1,214 @@ - - + + + + + + + + + + + + + + + + + + + + + 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 + + + + delete + from xhpc_ic_card_info + where ic_card_info_id = #{icCardInfoId,jdbcType=BIGINT} + + + insert into xhpc_ic_card_info (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) + values (#{tIccardInfoId,jdbcType=VARCHAR}, #{useStatus,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, + #{userId,jdbcType=INTEGER}, #{userAccount,jdbcType=VARCHAR}, #{userType,jdbcType=BIGINT}, + #{userName,jdbcType=VARCHAR}, #{userIdCard,jdbcType=VARCHAR}, #{userAge,jdbcType=BIGINT}, + #{userSex,jdbcType=BIGINT}, #{userPhone,jdbcType=VARCHAR}, #{userVehicle,jdbcType=VARCHAR}, + #{delFlag,jdbcType=BIGINT}) + + + insert into xhpc_ic_card_info + + + 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, + + + + + #{tIccardInfoId,jdbcType=VARCHAR}, + + + #{useStatus,jdbcType=BIGINT}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{userId,jdbcType=INTEGER}, + + + #{userAccount,jdbcType=VARCHAR}, + + + #{userType,jdbcType=BIGINT}, + + + #{userName,jdbcType=VARCHAR}, + + + #{userIdCard,jdbcType=VARCHAR}, + + + #{userAge,jdbcType=BIGINT}, + + + #{userSex,jdbcType=BIGINT}, + + + #{userPhone,jdbcType=VARCHAR}, + + + #{userVehicle,jdbcType=VARCHAR}, + + + #{delFlag,jdbcType=BIGINT}, + + + + + update xhpc_ic_card_info + + + t_iccard_info_id = #{tIccardInfoId,jdbcType=VARCHAR}, + + + use_status = #{useStatus,jdbcType=BIGINT}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + user_id = #{userId,jdbcType=INTEGER}, + + + user_account = #{userAccount,jdbcType=VARCHAR}, + + + user_type = #{userType,jdbcType=BIGINT}, + + + user_name = #{userName,jdbcType=VARCHAR}, + + + user_id_card = #{userIdCard,jdbcType=VARCHAR}, + + + user_age = #{userAge,jdbcType=BIGINT}, + + + user_sex = #{userSex,jdbcType=BIGINT}, + + + user_phone = #{userPhone,jdbcType=VARCHAR}, + + + user_vehicle = #{userVehicle,jdbcType=VARCHAR}, + + + del_flag = #{delFlag,jdbcType=BIGINT}, + + + where ic_card_info_id = #{icCardInfoId,jdbcType=BIGINT} + + + update xhpc_ic_card_info + set t_iccard_info_id = #{tIccardInfoId,jdbcType=VARCHAR}, + use_status = #{useStatus,jdbcType=BIGINT}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + user_id = #{userId,jdbcType=INTEGER}, + user_account = #{userAccount,jdbcType=VARCHAR}, + user_type = #{userType,jdbcType=BIGINT}, + user_name = #{userName,jdbcType=VARCHAR}, + user_id_card = #{userIdCard,jdbcType=VARCHAR}, + user_age = #{userAge,jdbcType=BIGINT}, + user_sex = #{userSex,jdbcType=BIGINT}, + user_phone = #{userPhone,jdbcType=VARCHAR}, + user_vehicle = #{userVehicle,jdbcType=VARCHAR}, + del_flag = #{delFlag,jdbcType=BIGINT} + where ic_card_info_id = #{icCardInfoId,jdbcType=BIGINT} + - - - - - - - - - - - - - - - - - - + - - - - - - - - + + \ No newline at end of file