| | |
| | | import com.dy.pipIrrGlobal.pojoBa.BaClient; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClientCard; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeManagerCard; |
| | | import com.dy.pipIrrGlobal.util.AmountToChinese; |
| | | import com.dy.pipIrrGlobal.voSe.VoActiveCard; |
| | | import com.dy.pipIrrGlobal.voSe.VoOperate; |
| | |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | |
| | | private final CardOperateSv cardOperateSv; |
| | | private final ClientCardSv clientCardSv; |
| | | |
| | | @Value("${project.divisionCode}") |
| | | private String divisionCode; |
| | | |
| | | @Value("${project.projectNo}") |
| | | private Integer projectNo; |
| | | /** |
| | | * 开卡 |
| | | * @param po 开卡传入对象 |
| | |
| | | public BaseResponse<Boolean> add_active(@RequestBody @Valid ActiveCard po, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | // 依据水卡地址判断该卡是否可以开卡,未开过卡或不是正常状态、挂失状态的可开卡 |
| | | if(!cardOperateSv.canActiveCard(po.getCardAddr())) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.ACTIVE_FAIL_CARD_ESIST.getMessage()); |
| | | } |
| | | |
| | | Long clientId = po.getClientId(); |
| | |
| | | } |
| | | |
| | | Map map = new HashMap(); |
| | | map.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | // map.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map.put("projectNo", String.format("%02x", projectNo)); |
| | | map.put("orderNumber", rec); |
| | | map.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map) ; |
| | |
| | | } |
| | | |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map_response.put("projectNo", String.format("%02x", projectNo)); |
| | | map_response.put("orderNumber", rec); |
| | | map_response.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map_response) ; |
| | |
| | | } |
| | | |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map_response.put("projectNo", String.format("%02x", projectNo)); |
| | | map_response.put("orderNumber", rec); |
| | | map_response.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map_response) ; |
| | |
| | | } |
| | | |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map_response.put("projectNo", String.format("%02x", projectNo)); |
| | | map_response.put("orderNumber", rec); |
| | | map_response.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map_response) ; |
| | |
| | | } |
| | | |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map_response.put("projectNo", String.format("%02x", projectNo)); |
| | | map_response.put("orderNumber", rec); |
| | | map_response.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map_response) ; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 创建管理卡 |
| | | * @param po |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "create_manager_card", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> createManagerCard(@RequestBody @Valid ManagerCard po, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | /** |
| | | * 根据行政区划串(divisionCode)在管理卡表中针对卡片编号(cardNum)进行模糊查询 |
| | | * 如果顺序号已经达到最大值,提示用户联系系统管理员 |
| | | * 如果顺序号未达到最大值,则加1 |
| | | * cardNum为新的卡号 |
| | | */ |
| | | String cardNum = Optional.ofNullable(cardOperateSv.getManagerCardNumOfMax(divisionCode)).orElse(""); |
| | | if(cardNum != null && cardNum.trim().length() > 0) { |
| | | Integer number = Integer.parseInt(cardNum.substring(12)); |
| | | number = number + 1; |
| | | if(number > 65535) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); |
| | | } |
| | | cardNum = cardNum.substring(0, 12) + String.format("%05d", number); |
| | | } else { |
| | | cardNum = divisionCode + "00001"; |
| | | } |
| | | |
| | | SeManagerCard seManagerCard = new SeManagerCard(); |
| | | seManagerCard.setCardAddr(po.getCardAddr()); |
| | | seManagerCard.setCardNum(cardNum); |
| | | seManagerCard.setCardType(po.getCardType()); |
| | | seManagerCard.setCreateTime(new Date()); |
| | | seManagerCard.setRemarks(po.getRemarks()); |
| | | Long managerCardId = cardOperateSv.addManagerCard(seManagerCard); |
| | | if(managerCardId == 0) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CREATE_MANAGER_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(cardNum); |
| | | |
| | | //Map map = new HashMap(); |
| | | //map.put("cardNum", cardNum); |
| | | //return BaseResponseUtils.buildSuccess(map) ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取充值记录 |
| | |
| | | public BaseResponse<QueryResultVo<List<VoActiveCard>>> getActiveCards(QoActiveCard vo){ |
| | | try { |
| | | QueryResultVo<List<VoActiveCard>> res = cardOperateSv.getActiveCards(vo); |
| | | if(res.itemTotal == 0) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.No_ActiveCards.getMessage()); |
| | | } |
| | | // if(res.itemTotal == 0) { |
| | | // return BaseResponseUtils.buildErrorMsg(SellResultCode.No_ActiveCards.getMessage()); |
| | | // } |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取开卡记录异常", e); |
| | |
| | | public BaseResponse<QueryResultVo<List<VoReissueCard>>> getReissueCards(QoReissueCard vo){ |
| | | try { |
| | | QueryResultVo<List<VoReissueCard>> res = cardOperateSv.getReissueCards(vo); |
| | | if(res.itemTotal == 0) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.No_ReissueCards.getMessage()); |
| | | } |
| | | // if(res.itemTotal == 0) { |
| | | // return BaseResponseUtils.buildErrorMsg(SellResultCode.No_ReissueCards.getMessage()); |
| | | // } |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取补卡记录异常", e); |
| | |
| | | |
| | | try { |
| | | QueryResultVo<List<VoOperate>> res = cardOperateSv.getCommonOperations(vo); |
| | | if(res.itemTotal == 0) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.No_CANCELS.getMessage()); |
| | | } |
| | | // if(res.itemTotal == 0) { |
| | | // return BaseResponseUtils.buildErrorMsg(SellResultCode.No_CANCELS.getMessage()); |
| | | // } |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取开卡记录异常", e); |
| | |
| | | @SsoAop() |
| | | public BaseResponse<Map> getReceipts(QoReceipt vo){ |
| | | try { |
| | | Map res = Optional.ofNullable(cardOperateSv.getReceipts(vo)).orElse(new HashMap()); |
| | | if(res.size() == 0) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.No_RECEIPTS.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | // Map res = Optional.ofNullable(cardOperateSv.getReceipts(vo)).orElse(new HashMap()); |
| | | // if(res.size() == 0) { |
| | | // return BaseResponseUtils.buildErrorMsg(SellResultCode.No_RECEIPTS.getMessage()); |
| | | // } |
| | | return BaseResponseUtils.buildSuccess(cardOperateSv.getReceipts(vo)); |
| | | } catch (Exception e) { |
| | | log.error("获取电子钱包账户记录", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |