| | |
| | | package com.dy.pipIrrTerminal.card; |
| | | |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoPr.PrWaterPriceMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.*; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClientCard; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeManagementCard; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeRechargeHistory; |
| | | import com.dy.pipIrrGlobal.voSe.*; |
| | | import com.dy.pipIrrTerminal.card.dto.*; |
| | | import com.dy.pipIrrTerminal.card.qo.QoCards; |
| | | import com.dy.pipIrrTerminal.card.qo.QoLostCards; |
| | | import com.dy.pipIrrTerminal.card.enums.CardStateENUM; |
| | | import com.dy.pipIrrTerminal.card.enums.LastOperateENUM; |
| | | import com.dy.pipIrrTerminal.card.enums.ManagementCardStateENUM; |
| | | import com.dy.pipIrrTerminal.card.enums.OperateTypeENUM; |
| | | import com.dy.pipIrrTerminal.card.enums.RechargeTypeENUM; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.dy.common.util.IDLongGenerator; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | @Autowired |
| | | private SeManagerCardMapper seManagerCardMapper; |
| | | |
| | | @Autowired |
| | | private SeManagementCardMapper seManagementCardMapper; |
| | | |
| | | @Autowired |
| | | private IDLongGenerator idLongGenerator; |
| | | |
| | | @Value("${project.projectNo}") |
| | | private Integer projectNo; |
| | | |
| | | /** |
| | | * 根据水卡地址判断该卡是否可以开卡 |
| | | * |
| | | * @param cardAddr |
| | | * @return true:可以开卡 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以充值 |
| | | * |
| | | * @param po |
| | | * @return true:可以充值 |
| | | */ |
| | |
| | | |
| | | String stateName = Optional.ofNullable(seClientCardMapper.getCardStateByCardNum(po.getCardNum())).orElse(""); |
| | | // 单独充值时卡片必须为正常 |
| | | if((po.getRechargeType() == RechargeTypeENUM.RECHARGE.getCode()) && !stateName.equals("正常")) { |
| | | if ((po.getRechargeType() == RechargeTypeENUM.RECHARGE.getCode()) && !stateName.equals("正常")) { |
| | | map.put("msg", stateName + ", " + "水卡状态不支持当前操作"); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以挂失 |
| | | * |
| | | * @param po |
| | | * @return true:可以报失 |
| | | */ |
| | |
| | | |
| | | Long cardNum = po.getCardNum(); |
| | | String stateName = seClientCardMapper.getCardStateByCardNum(cardNum); |
| | | if(stateName == null || stateName.equals("") || !stateName.equals("正常")) { |
| | | if (stateName == null || stateName.equals("") || !stateName.equals("正常")) { |
| | | map.put("msg", stateName + ", " + "水卡状态不支持当前操作"); |
| | | return map; |
| | | } |
| | |
| | | CardSimple card = new CardSimple(); |
| | | card.setCardId(Long.parseLong(map_card.get("cardId").toString())); |
| | | card.setClientId(Long.parseLong(map_card.get("clientId").toString())); |
| | | //card.setProtocol(map_card.get("protocol").toString()); |
| | | // card.setProtocol(map_card.get("protocol").toString()); |
| | | |
| | | map.put("success", true); |
| | | map.put("content", card); |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以解锁 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | map.put("content", card); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以补卡 |
| | | * |
| | | * @param po |
| | | * @return true:可以补卡 |
| | | */ |
| | |
| | | Long cardNum = po.getCardNum(); |
| | | Integer lostCount = seClientCardMapper.getLostCount(cardNum); |
| | | Integer replacedCount = seClientCardMapper.getReplacedCount(cardNum); |
| | | if(lostCount == 0 || replacedCount > 0) { |
| | | if (lostCount == 0 || replacedCount > 0) { |
| | | map.put("msg", "水卡未挂失或已补卡,不能补卡"); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以注销 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | Long cardNum = po.getCardNum(); |
| | | String stateName = seClientCardMapper.getCardStateByCardNum(cardNum); |
| | | if(stateName == null || stateName.equals("") || !stateName.equals("正常")) { |
| | | if (stateName == null || stateName.equals("") || !stateName.equals("正常")) { |
| | | map.put("msg", stateName + ", " + "水卡状态不支持当前操作"); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以补扣 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | Long cardNum = po.getCardNum(); |
| | | String stateName = seClientCardMapper.getCardStateByCardNum(cardNum); |
| | | if(stateName == null || stateName.equals("") || !stateName.equals("正常")) { |
| | | if (stateName == null || stateName.equals("") || !stateName.equals("正常")) { |
| | | map.put("msg", stateName + ", " + "水卡状态不支持当前操作"); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以返还 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | Long cardNum = po.getCardNum(); |
| | | String stateName = seClientCardMapper.getCardStateByCardNum(cardNum); |
| | | if(stateName == null || stateName.equals("") || !stateName.equals("正常")) { |
| | | if (stateName == null || stateName.equals("") || !stateName.equals("正常")) { |
| | | map.put("msg", stateName + ", " + "水卡状态不支持当前操作"); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据农户编号获取5级行政区划串areaCode,补卡过程中开新卡使用 |
| | | * |
| | | * @param clientId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 开卡附加充值 |
| | | * |
| | | * @param po |
| | | * @param cardNum |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 激活或补卡 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | } |
| | | |
| | | Map map_cardNum = generateCardNum(po.getClientId()); |
| | | if(map_cardNum.get("success").equals(false)) { |
| | | if (map_cardNum.get("success").equals(false)) { |
| | | map.put("msg", map_cardNum.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | String orderNo = generateOrderNo(); |
| | | Map map_addCardAndOperate = addCardAndOperate(po, cardNum, orderNo); |
| | | if(map_addCardAndOperate.get("success").equals(false)) { |
| | | if (map_addCardAndOperate.get("success").equals(false)) { |
| | | map.put("msg", map_addCardAndOperate.get("msg").toString()); |
| | | return map; |
| | | } |
| | | |
| | | if (amount != null && amount > 0 && originalCardId == null) { |
| | | Map map_plusRecharge = plusRecharge(po, cardNum, orderNo); |
| | | if(map_plusRecharge.get("success").equals(false)) { |
| | | if (map_plusRecharge.get("success").equals(false)) { |
| | | map.put("msg", map_plusRecharge.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 充值 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | map.put("content", null); |
| | | |
| | | Map map_canRecharge = canRecharge(po); |
| | | if(map_canRecharge.get("success").equals(false)) { |
| | | if (map_canRecharge.get("success").equals(false)) { |
| | | map.put("msg", map_canRecharge.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | } |
| | | Long cardId = Long.parseLong(map_cardAndClient.get("cardId").toString()); |
| | | Long clientId = Long.parseLong(map_cardAndClient.get("clientId").toString()); |
| | | if(orderNo == null || orderNo.length() <= 0) { |
| | | if (orderNo == null || orderNo.length() <= 0) { |
| | | orderNo = generateOrderNo(); |
| | | } |
| | | |
| | |
| | | voTermRecharge.setProjectNo(projectNo); |
| | | voTermRecharge.setCardNum(po.getCardNum()); |
| | | voTermRecharge.setOrderNo(orderNo); |
| | | voTermRecharge.setBalance(afterRecharge); |
| | | |
| | | map.put("success", true); |
| | | map.put("msg", "操作成功"); |
| | |
| | | |
| | | /** |
| | | * 补卡 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | map.put("content", null); |
| | | |
| | | Map map_canReissue = canReissue(po); |
| | | if(map_canReissue.get("success").equals(false)) { |
| | | if (map_canReissue.get("success").equals(false)) { |
| | | map.put("msg", map_canReissue.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 挂失 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | map.put("content", null); |
| | | |
| | | Map map_canReportLoss = canReportLoss(po); |
| | | if(map_canReportLoss.get("success").equals(false)) { |
| | | if (map_canReportLoss.get("success").equals(false)) { |
| | | map.put("msg", map_canReportLoss.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | seClientCard.setLossdtdt(new Date()); |
| | | seClientCard.setState(CardStateENUM.LOSS.getCode()); |
| | | seClientCard.setLastoper(LastOperateENUM.LOSS.getCode()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(seClientCardMapper.updateByPrimaryKeySelective(seClientCard)).orElse(0); |
| | | Integer rec_updateClientCard = Optional.ofNullable(seClientCardMapper.updateByPrimaryKeySelective(seClientCard)) |
| | | .orElse(0); |
| | | if (rec_updateClientCard == 0) { |
| | | map.put("msg", "挂失失败-农户卡修改异常"); |
| | | return map; |
| | |
| | | |
| | | /** |
| | | * 解锁 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | map.put("content", null); |
| | | |
| | | Map map_canUnlock = canUnlock(po); |
| | | if(map_canUnlock.get("success").equals(false)) { |
| | | if (map_canUnlock.get("success").equals(false)) { |
| | | map.put("msg", map_canUnlock.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 修改农户卡信息: |
| | | * 挂失时间 |
| | | * 最后操作类型-4 |
| | | * 挂失时间 |
| | | * 最后操作类型-4 |
| | | */ |
| | | SeClientCard seClientCard = new SeClientCard(); |
| | | seClientCard.setId(cardId); |
| | |
| | | seClientCard.setMoney(po.getMoney()); |
| | | seClientCard.setState(CardStateENUM.NORMAL.getCode()); |
| | | seClientCard.setLastoper(LastOperateENUM.UNLOCK.getCode()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(seClientCardMapper.updateByPrimaryKeySelective(seClientCard)).orElse(0); |
| | | Integer rec_updateClientCard = Optional.ofNullable(seClientCardMapper.updateByPrimaryKeySelective(seClientCard)) |
| | | .orElse(0); |
| | | if (rec_updateClientCard == 0) { |
| | | map.put("msg", "解锁失败-农户卡修改异常"); |
| | | return map; |
| | |
| | | |
| | | /** |
| | | * 销卡 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | map.put("content", null); |
| | | String orderNo = generateOrderNo(); |
| | | |
| | | Map map_canCancel = canCancel(po); |
| | | if(map_canCancel.get("success").equals(false)) { |
| | | Map map_canCancel = canCancel(po); |
| | | if (map_canCancel.get("success").equals(false)) { |
| | | map.put("msg", map_canCancel.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 补扣 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | Date operateTime = new Date(); |
| | | Double waterPrice = Optional.ofNullable(prWaterPriceMapper.getPrice()).orElse(0.0); |
| | | |
| | | Map map_canRepay = canRepay(po); |
| | | if(map_canRepay.get("success").equals(false)) { |
| | | Map map_canRepay = canRepay(po); |
| | | if (map_canRepay.get("success").equals(false)) { |
| | | map.put("msg", map_canRepay.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 返还 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | Date operateTime = new Date(); |
| | | Double waterPrice = Optional.ofNullable(prWaterPriceMapper.getPrice()).orElse(0.0); |
| | | |
| | | Map map_canSupplement = canSupplement(po); |
| | | if(map_canSupplement.get("success").equals(false)) { |
| | | Map map_canSupplement = canSupplement(po); |
| | | if (map_canSupplement.get("success").equals(false)) { |
| | | map.put("msg", map_canSupplement.get("msg").toString()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 操作回调 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | return map; |
| | | } |
| | | |
| | | if(operateType == 1) { |
| | | if (operateType == 1) { |
| | | /** |
| | | * 开卡操作执行通知 |
| | | * 1.依据订单号将无效状态的操作记录改为有效 |
| | | * 2.依据水卡ID将无效状态的水卡记录改为有效 |
| | | * 3.如果开卡同步充值 |
| | | * 修改充值操作记录为有效 |
| | | * 修改充值历史记录为有效 |
| | | * 修改水卡表的操作信息 |
| | | * 1.依据订单号将无效状态的操作记录改为有效 |
| | | * 2.依据水卡ID将无效状态的水卡记录改为有效 |
| | | * 3.如果开卡同步充值 |
| | | * 修改充值操作记录为有效 |
| | | * 修改充值历史记录为有效 |
| | | * 修改水卡表的操作信息 |
| | | */ |
| | | Integer rec_ope = turnOperateValidByOrderNumber(orderNumber); |
| | | Integer rec_card = turnCardValidByOrderNumber(orderNumber); |
| | |
| | | return map; |
| | | } |
| | | |
| | | if(isMergeRecharge(cardId)) { |
| | | if (isMergeRecharge(cardId)) { |
| | | turnOperateValidByOrderNumber(orderNumber + "p"); |
| | | turnRechargeHistoryValidByOrderNumber(orderNumber); |
| | | updateCard(cardId, orderNumber+"p"); |
| | | updateCard(cardId, orderNumber + "p"); |
| | | } |
| | | } else if (operateType == 2) { |
| | | /** |
| | |
| | | */ |
| | | turnOperateValidByOrderNumber(orderNumber + "p"); |
| | | turnRechargeHistoryValidByOrderNumber(orderNumber); |
| | | updateCard(cardId, orderNumber+"p"); |
| | | }else if (operateType == 3) { |
| | | updateCard(cardId, orderNumber + "p"); |
| | | } else if (operateType == 3) { |
| | | /** |
| | | * 销卡操作执行通知 |
| | | * 1. 操作记录改为有效 |
| | |
| | | * 1. 新水卡记录改为有效 |
| | | * 2. 开卡操作记录改为有效 |
| | | * 3. 如果存在退还金额 |
| | | * 清空原卡余额 |
| | | * 清空原卡余额 |
| | | */ |
| | | Integer rec_card = turnCardValidByOrderNumber(orderNumber); |
| | | Integer rec_ope = turnOperateValidByOrderNumber(orderNumber); |
| | |
| | | |
| | | /** |
| | | * 如果补卡时退还了金额,清空挂失卡余额 |
| | | * |
| | | * @param orderNumber |
| | | */ |
| | | public Integer emptyCardBalance(String orderNumber) { |
| | | Integer rec_empty = 0; |
| | | Float noTradeAmount = seCardOperateMapper.getNoTradeAmount(orderNumber); |
| | | if(noTradeAmount != null && noTradeAmount > 0) { |
| | | if (noTradeAmount != null && noTradeAmount > 0) { |
| | | rec_empty = seClientCardMapper.emptyCardBalance(orderNumber); |
| | | } |
| | | return rec_empty; |
| | |
| | | |
| | | /** |
| | | * 修改注销水卡表的记录及余额(0) |
| | | * |
| | | * @param orderNumber |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改补扣水卡表记录及余额 |
| | | * |
| | | * @param cardId |
| | | * @param orderNumber |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 修改返还水卡表记录及余额 |
| | | * |
| | | * @param cardId |
| | | * @param orderNumber |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 判断指定水卡是否为挂失状态且无补卡记录 |
| | | * |
| | | * @param cardNum |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 读取水卡信息 |
| | | * |
| | | * @param cardAddr |
| | | * @return |
| | | */ |
| | | public VoTermCard readCard(String cardAddr) { |
| | | VoTermCard voTermCard = seClientCardMapper.getTermCardInfo(cardAddr); |
| | | if(voTermCard != null) { |
| | | if (voTermCard != null) { |
| | | return voTermCard; |
| | | } |
| | | |
| | | VoTermCard voTermManagerCard = seManagerCardMapper.getTermManagerCardInfo(cardAddr); |
| | | if(voTermManagerCard != null) { |
| | | if (voTermManagerCard != null) { |
| | | return voTermManagerCard; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 根据指定条件获取水卡列表 |
| | | * |
| | | * @param vo 查询条件 |
| | | * @return 水卡列表 |
| | | */ |
| | | public QueryResultVo<List<VoCards>> getCards(QoCards vo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo); |
| | | Long itemTotal = seClientCardMapper.getCardsCount(params); |
| | | |
| | | QueryResultVo<List<VoCards>> rsVo = new QueryResultVo<>(); |
| | | rsVo.pageSize = vo.pageSize; |
| | | rsVo.pageCurr = vo.pageCurr; |
| | | |
| | | if (itemTotal > 0) { |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | List<VoCards> list = seClientCardMapper.getCards(params); |
| | | rsVo.obj = list; |
| | | } else { |
| | | rsVo.obj = new ArrayList<>(); |
| | | rsVo.itemTotal = 0L; |
| | | } |
| | | |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 获取已挂失的水卡列表 |
| | | * |
| | | * @param vo 查询条件 |
| | | * @return 已挂失的水卡列表 |
| | | */ |
| | | public QueryResultVo<List<VoCards>> getLostCards(QoLostCards vo) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("pageCurr", vo.pageCurr); |
| | | params.put("pageSize", vo.pageSize); |
| | | params.put("state", 2); // 挂失状态 |
| | | |
| | | Long itemTotal = seClientCardMapper.getLostCardsCount(params); |
| | | |
| | | QueryResultVo<List<VoCards>> rsVo = new QueryResultVo<>(); |
| | | rsVo.pageSize = vo.pageSize; |
| | | rsVo.pageCurr = vo.pageCurr; |
| | | |
| | | if (itemTotal > 0) { |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | List<VoCards> list = seClientCardMapper.getLostCards(params); |
| | | rsVo.obj = list; |
| | | } else { |
| | | rsVo.obj = new ArrayList<>(); |
| | | rsVo.itemTotal = 0L; |
| | | } |
| | | |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 根据水卡编号获取卡信息 |
| | | * |
| | | * @param cardNum 水卡编号 |
| | | * @return 卡信息 |
| | | */ |
| | | public VoCardByClientNum getCardByCardNum(String cardNum) { |
| | | return seClientCardMapper.getCardByCardNum(cardNum); |
| | | } |
| | | |
| | | /** |
| | | * 创建管理卡 |
| | | * |
| | | * @param dto 创建管理卡DTO |
| | | * @return 创建结果 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Map<String, Object> createManagementCard(CreateManagementCardDto dto) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("success", false); |
| | | |
| | | try { |
| | | // 检查卡地址是否已存在 |
| | | if (isCardAddrExists(dto.getCardAddr())) { |
| | | result.put("msg", "创建失败-此卡地址已存在"); |
| | | return result; |
| | | } |
| | | |
| | | // 参考termActiveCard逻辑:生成订单号 |
| | | String orderNo = generateOrderNo(); |
| | | |
| | | // 使用IDLongGenerator生成唯一ID |
| | | Long id = idLongGenerator.generate(); |
| | | Date createTime = new Date(); |
| | | |
| | | // 构建管理卡对象 |
| | | SeManagementCard managementCard = SeManagementCard.builder() |
| | | .id(id) |
| | | .protocol(dto.getProtocol()) |
| | | .cardAddr(dto.getCardAddr()) |
| | | .securityCode(dto.getSecurityCode()) |
| | | .cardType(dto.getCardType()) |
| | | .createTime(createTime) |
| | | .orderNo(orderNo) |
| | | .districtCode(dto.getDistrictCode()) |
| | | .projectNo(dto.getProjectNo() != null ? dto.getProjectNo() : this.projectNo) |
| | | .ip(dto.getIp()) |
| | | .domain(dto.getDomain()) |
| | | .openClostTime(dto.getOpenClostTime()) |
| | | .remarks(dto.getRemarks()) |
| | | .state(ManagementCardStateENUM.NORMAL.getCode()) // 默认状态为正常 |
| | | .build(); |
| | | |
| | | // 插入数据库 |
| | | int insertResult = seManagementCardMapper.insertSelective(managementCard); |
| | | |
| | | if (insertResult > 0) { |
| | | result.put("success", true); |
| | | result.put("content", orderNo); // 返回订单号 |
| | | result.put("msg", "请求成功"); |
| | | } else { |
| | | result.put("msg", "管理卡创建失败-数据库插入异常"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("创建管理卡异常: {}", e.getMessage(), e); |
| | | result.put("msg", "管理卡创建失败: " + e.getMessage()); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 检查卡片地址是否已存在 |
| | | * |
| | | * @param cardAddr 卡片地址 |
| | | * @return true-已存在,false-不存在 |
| | | */ |
| | | public boolean isCardAddrExists(String cardAddr) { |
| | | // 使用一次查询检查两个表中是否存在该卡地址 |
| | | // 1. 管理卡表:所有记录都检查 |
| | | // 2. 农户水卡表:只检查正常(1)和挂失(3)状态的记录 |
| | | Long totalCount = seClientCardMapper.checkCardAddrExists(cardAddr); |
| | | return totalCount != null && totalCount > 0; |
| | | } |
| | | } |