| | |
| | | import com.dy.pipIrrGlobal.voSe.VoOperate; |
| | | import com.dy.pipIrrGlobal.voSe.VoRecharge; |
| | | import com.dy.pipIrrGlobal.voSe.VoReissueCard; |
| | | import com.dy.pipIrrSell.cardOperate.converter.RechargeDtoMapper; |
| | | import com.dy.pipIrrSell.cardOperate.dto.*; |
| | | import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; |
| | | import com.dy.pipIrrSell.cardOperate.qo.*; |
| | |
| | | @PostMapping(path = "active", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> add_active(@RequestBody @Valid DtoActiveCard po, BindingResult bindingResult){ |
| | | public BaseResponse<Boolean> add_active(@RequestBody @Valid ActiveCard po, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Long clientId = po.getClientId(); |
| | | |
| | | // 获取5级行政区划串areaCode |
| | | String areaCode = cardOperateSv.getAreaCodeByNum(po.getClientNum()); |
| | | if(areaCode.trim().length() == 0) { |
| | | Long areaCodeL = cardOperateSv.getAreaCodeById(clientId); |
| | | if(areaCodeL == null) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.AREA_CODE_MISTAKE.getMessage()); |
| | | } |
| | | |
| | | // p206V1_0_1协议,取行政区划的后6位 |
| | | if(po.getProtocol() != null && po.getProtocol().trim().equals("p206V1_0_1")) { |
| | | areaCode = areaCode.substring(6); |
| | | } |
| | | String areaCode = String.valueOf(areaCodeL); |
| | | |
| | | /** |
| | | * 根据行政区划串(areaCode)在水卡表中针对水卡编号(cardNum)进行模糊查询 |
| | |
| | | * cardNum为新的卡号 |
| | | */ |
| | | String cardNum = Optional.ofNullable(cardOperateSv.getCardNumOfMax(areaCode)).orElse(""); |
| | | if(po.getProtocol().trim().equals("p206V1_0_1")) { |
| | | if(cardNum != null && cardNum.trim().length() > 0) { |
| | | Integer number = Integer.parseInt(cardNum.substring(6)); |
| | | number = number + 1; |
| | | if(number > 9999) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); |
| | | } |
| | | cardNum = cardNum.substring(0, 6) + String.format("%04d", number); |
| | | } else { |
| | | cardNum = areaCode + "0001"; |
| | | } |
| | | }else { |
| | | if(cardNum != null && cardNum.trim().length() > 0) { |
| | | Integer number = Integer.parseInt(cardNum.substring(12)); |
| | | number = number + 1; |
| | |
| | | } else { |
| | | cardNum = areaCode + "00001"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * cardAddr 水卡地址(仅仅写入,无业务) |
| | | * clientNum 农户编号 |
| | | * cardCost 卡片费用 |
| | | * originalCardId 原水卡ID |
| | | * amount 充值金额,充值接口为输入参数,补卡接口为原卡退还金额 |
| | | * reissueAmount 补卡金额,补卡时使用 |
| | | * paymentId 支付方式编号 |
| | |
| | | * activeTime 开卡时间 |
| | | */ |
| | | String cardAddr = po.getCardAddr(); |
| | | String clientNum = po.getClientNum(); |
| | | Integer cardCost = po.getCardCost(); |
| | | Long originalCardId = po.getOriginalCardId(); |
| | | Float amount = po.getAmount(); |
| | |
| | | String remarks = po.getRemarks(); |
| | | Long operator = po.getOperator(); |
| | | Date activeTime = new Date(); |
| | | |
| | | /** |
| | | * 根据农户编号获取农户ID |
| | | */ |
| | | Long clientId = cardOperateSv.getClientIdByNum(clientNum); |
| | | if(clientId == null) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CLIENT_NUM_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * 添加农户卡记录,退还金额作为当前余额 |
| | |
| | | SeCardOperate seCardOperate = new SeCardOperate(); |
| | | seCardOperate.setCardId(cardId); |
| | | seCardOperate.setClientId(clientId); |
| | | seCardOperate.setMoney(amount); |
| | | seCardOperate.setMoney(0f); |
| | | seCardOperate.setCardCost(cardCost); |
| | | seCardOperate.setPaymentId(paymentId); |
| | | seCardOperate.setOperateType(OperateTypeENUM.ACTIVE.getCode()); |
| | |
| | | * 如果操作人员开卡时输入了充值金额,则开卡后调用充值功能 |
| | | * 补卡除外,补卡的退还金额是从挂失卡中转移过来的,没有实际金钱交易 |
| | | */ |
| | | po.setCardNum(Long.parseLong(cardNum)); |
| | | if(amount != null && amount > 0 && originalCardId == null) { |
| | | po.setClientId(clientId); |
| | | DtoRecharge dtoRecharge = RechargeDtoMapper.INSTANCT.po2vo(po); |
| | | DtoRecharge dtoRecharge = new DtoRecharge(); |
| | | dtoRecharge.setCardNum(Long.parseLong(cardNum)); |
| | | dtoRecharge.setAmount(amount); |
| | | dtoRecharge.setPaymentId(paymentId); |
| | | dtoRecharge.setRemarks(remarks); |
| | | dtoRecharge.setOperator(operator); |
| | | dtoRecharge.setMoney(0f); |
| | | dtoRecharge.setGift(0f); |
| | | dtoRecharge.setPrice(0f); |
| | |
| | | |
| | | String cardAddr = po.getCardAddr(); |
| | | String clientNum = ""; |
| | | Long clientId = 0L; |
| | | Long cardNum = po.getCardNum(); |
| | | Long cardId = 0L; |
| | | Integer cardCost = Optional.ofNullable(po.getCardCost()).orElse(0); |
| | |
| | | Long paymentId = po.getPaymentId(); |
| | | String remarks = po.getRemarks(); |
| | | Long operator = po.getOperator(); |
| | | String protocol = null; |
| | | |
| | | // 判断当前水卡是否为挂失状态且未补卡,仅已经挂失且未补卡的可以补卡 |
| | | if(!cardOperateSv.isLostAndUnreplaced(cardNum)) { |
| | |
| | | } |
| | | clientNum = map.get("clientNum").toString(); |
| | | cardId = Long.parseLong(map.get("cardId").toString()); |
| | | clientId = Long.parseLong(map.get("clientId").toString()); |
| | | |
| | | /** |
| | | * 如果是补卡调用的开卡且转移了退还金额,需修改挂失卡余额为0 |
| | |
| | | /** |
| | | * 添加开卡记录,退还金额冲到新卡中 |
| | | */ |
| | | if(String.valueOf(cardNum).trim().length() == 10) { |
| | | protocol = "p206V1_0_1"; |
| | | } |
| | | DtoActiveCard dtoActiveCard = new DtoActiveCard(); |
| | | dtoActiveCard.setProtocol(protocol); |
| | | dtoActiveCard.setCardAddr(cardAddr); |
| | | dtoActiveCard.setClientNum(clientNum); |
| | | dtoActiveCard.setOriginalCardId(cardId); |
| | | dtoActiveCard.setCardCost(cardCost); |
| | | dtoActiveCard.setAmount(reissueAmount); |
| | | dtoActiveCard.setPaymentId(paymentId); |
| | | dtoActiveCard.setRemarks(remarks); |
| | | dtoActiveCard.setOperator(operator); |
| | | BaseResponse<java.lang.Boolean> baseResponse_addActive = add_active(dtoActiveCard, null); |
| | | ActiveCard activeCard = new ActiveCard(); |
| | | activeCard.setCardAddr(cardAddr); |
| | | activeCard.setClientId(clientId); |
| | | activeCard.setOriginalCardId(cardId); |
| | | activeCard.setCardCost(cardCost); |
| | | activeCard.setAmount(reissueAmount); |
| | | activeCard.setPaymentId(paymentId); |
| | | activeCard.setRemarks(remarks); |
| | | activeCard.setOperator(operator); |
| | | BaseResponse<java.lang.Boolean> baseResponse_addActive = add_active(activeCard, null); |
| | | |
| | | if(!baseResponse_addActive.getCode().equals("0001")) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); |