| | |
| | | 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.*; |
| | |
| | | @Autowired |
| | | private SeManagerCardMapper seManagerCardMapper; |
| | | |
| | | @Autowired |
| | | private SeManagementCardMapper seManagementCardMapper; |
| | | |
| | | @Value("${project.projectNo}") |
| | | private Integer projectNo; |
| | | |
| | | /** |
| | | * 根据水卡地址判断该卡是否可以开卡 |
| | | * |
| | | * @param cardAddr |
| | | * @return true:可以开卡 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以充值 |
| | | * |
| | | * @param po |
| | | * @return true:可以充值 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以挂失 |
| | | * |
| | | * @param po |
| | | * @return true:可以报失 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以解锁 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | map.put("content", card); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以补卡 |
| | | * |
| | | * @param po |
| | | * @return true:可以补卡 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以注销 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以补扣 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号判断该卡是否可以返还 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据农户编号获取5级行政区划串areaCode,补卡过程中开新卡使用 |
| | | * |
| | | * @param clientId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 开卡附加充值 |
| | | * |
| | | * @param po |
| | | * @param cardNum |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 激活或补卡 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 充值 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 补卡 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 挂失 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | 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 |
| | | */ |
| | |
| | | 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 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 补扣 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 返还 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 操作回调 |
| | | * |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 如果补卡时退还了金额,清空挂失卡余额 |
| | | * |
| | | * @param orderNumber |
| | | */ |
| | | public Integer emptyCardBalance(String orderNumber) { |
| | |
| | | |
| | | /** |
| | | * 修改注销水卡表的记录及余额(0) |
| | | * |
| | | * @param orderNumber |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改补扣水卡表记录及余额 |
| | | * |
| | | * @param cardId |
| | | * @param orderNumber |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 修改返还水卡表记录及余额 |
| | | * |
| | | * @param cardId |
| | | * @param orderNumber |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 判断指定水卡是否为挂失状态且无补卡记录 |
| | | * |
| | | * @param cardNum |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 读取水卡信息 |
| | | * |
| | | * @param cardAddr |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据指定条件获取水卡列表 |
| | | * |
| | | * @param vo 查询条件 |
| | | * @return 水卡列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 获取已挂失的水卡列表 |
| | | * |
| | | * @param vo 查询条件 |
| | | * @return 已挂失的水卡列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据水卡编号获取卡信息 |
| | | * |
| | | * @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(); |
| | | |
| | | // 参考termActiveCard逻辑:生成唯一ID,使用时间戳 |
| | | Long id = System.currentTimeMillis(); |
| | | 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()) |
| | | .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; |
| | | } |
| | | } |