| | |
| | | package com.dy.pipIrrSell.cardOperate; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | |
| | | import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClientCard; |
| | | import com.dy.pipIrrGlobal.util.AmountToChinese; |
| | | import com.dy.pipIrrGlobal.util.Constant; |
| | | import com.dy.pipIrrGlobal.voSe.*; |
| | | import com.dy.pipIrrGlobal.voSe.VoActiveCard; |
| | | 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; |
| | |
| | | seClientCard.setClientid(clientId); |
| | | seClientCard.setMoney(amount); |
| | | seClientCard.setState(CardStateENUM.NORMAL.getCode()); |
| | | seClientCard.setOriginalCardId(originalCardId); |
| | | if(originalCardId != null) { |
| | | seClientCard.setOriginalCardId(originalCardId); |
| | | } |
| | | seClientCard.setCreatedt(activeTime); |
| | | seClientCard.setLastoper(LastOperateENUM.ACTIVE.getCode()); |
| | | Long cardId = Optional.ofNullable(clientCardSv.add(seClientCard)).orElse(0L) ; |
| | |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @Operation(summary = "补卡", description = "补卡") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "操作结果:true:成功,false:失败(BaseResponse.content)", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = Boolean.class))} |
| | | ) |
| | | }) |
| | | @PostMapping(path = "reissue", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | * cardId 原水卡(挂失水卡)ID,转移余额后需要更新卡余额为0 |
| | | * moeny 余额,挂失时使用 |
| | | * cardCost 卡片费用 |
| | | * reissueAmount 退还金额 |
| | | * paymentId 支付方式编号 |
| | | * remarks 备注 |
| | | * operator 操作人编号 |
| | |
| | | String clientNum = ""; |
| | | Long cardNum = po.getCardNum(); |
| | | Long cardId = 0L; |
| | | Integer cardCost = po.getCardCost(); |
| | | Integer cardCost = Optional.ofNullable(po.getCardCost()).orElse(0); |
| | | Float reissueAmount = po.getReissueAmount(); |
| | | Long paymentId = po.getPaymentId(); |
| | | String remarks = po.getRemarks(); |
| | | Long operator = po.getOperator(); |
| | | String protocol = null; |
| | | |
| | | // 判断当前水卡是否为挂失状态且未补卡,仅已经挂失其未补卡的可以补卡 |
| | | // 如果传入的是10位的水卡编号,升为17位水卡编号 |
| | | String cardNumS = String.valueOf(cardNum).trim(); |
| | | if(cardNumS.length() == 10) { |
| | | cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); |
| | | protocol = "p206V1_0_1"; |
| | | } |
| | | cardNum = Long.valueOf(cardNumS); |
| | | |
| | | // 判断当前水卡是否为挂失状态且未补卡,仅已经挂失且未补卡的可以补卡 |
| | | if(!cardOperateSv.isLostAndUnreplaced(cardNum)) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); |
| | | } |
| | | |
| | | // 如果传入了退还金额,需要判断老卡(被挂失的水卡)挂失时是否已经退款,无论退款多少都提示用户挂失时已退款 |
| | | if(reissueAmount != null) { |
| | | Double tradeAmount = cardOperateSv.getTradeAmountByCardNo(cardNum); |
| | | if(tradeAmount != null) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_FEE_CANNOT_BE_REFUNDED.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); |
| | | if(map == null || map.size() <= 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); |
| | | } |
| | | clientNum = map.get("clientNum").toString(); |
| | | cardId = Long.parseLong(map.get("cardId").toString()); |
| | |
| | | /** |
| | | * 如果是补卡调用的开卡且转移了退还金额,需修改挂失卡余额为0 |
| | | */ |
| | | SeClientCard seClientCard = new SeClientCard(); |
| | | seClientCard.setId(cardId); |
| | | seClientCard.setMoney(0f); |
| | | cardOperateSv.updateClientCard(seClientCard); |
| | | if(reissueAmount != null) { |
| | | SeClientCard seClientCard = new SeClientCard(); |
| | | seClientCard.setId(cardId); |
| | | seClientCard.setMoney(0f); |
| | | cardOperateSv.updateClientCard(seClientCard); |
| | | } |
| | | |
| | | /** |
| | | * 添加开卡记录,退还金额冲到新卡中 |
| | | */ |
| | | DtoActiveCard dtoActiveCard = new DtoActiveCard(); |
| | | dtoActiveCard.setProtocol(protocol); |
| | | dtoActiveCard.setCardAddr(cardAddr); |
| | | dtoActiveCard.setClientNum(clientNum); |
| | | dtoActiveCard.setOriginalCardId(cardNum); |
| | | dtoActiveCard.setOriginalCardId(cardId); |
| | | //dtoActiveCard.setOriginalCardId(cardNum); |
| | | dtoActiveCard.setCardCost(cardCost); |
| | | dtoActiveCard.setAmount(reissueAmount); |
| | | dtoActiveCard.setPaymentId(paymentId); |
| | |
| | | BaseResponse<java.lang.Boolean> baseResponse_addActive = add_active(dtoActiveCard, null); |
| | | |
| | | if(!baseResponse_addActive.getCode().equals("0001")) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); |
| | | } |
| | | |
| | | String theContent = String.valueOf(baseResponse_addActive.getContent()); |
| | | cardNum = Long.parseLong(theContent.substring(theContent.indexOf("=") + 1, theContent.indexOf(","))); |
| | | JSONObject job_content = (JSONObject) JSON.toJSON( baseResponse_addActive.getContent()); |
| | | cardNum = job_content.getLong("cardNum"); |
| | | String orderNumber = job_content.getString("orderNumber"); |
| | | String projectNo = job_content.getString("projectNo"); |
| | | |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectCode", Constant.projectCode_ym); |
| | | map_response.put("projectNo", projectNo); |
| | | map_response.put("orderNumber", orderNumber); |
| | | map_response.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map_response) ; |
| | | } |
| | |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @Operation(summary = "添加挂失记录", description = "添加挂失记录") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "操作结果:true:成功,false:失败(BaseResponse.content)", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = Boolean.class))} |
| | | ) |
| | | }) |
| | | @PostMapping(path = "loss", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | /** |
| | | * cardId 水卡编号(非传入参数,由cardNum反查) |
| | | * clientId 农户编号(非传入参数,由cardNum反查) |
| | | * cardNum 水卡编号 |
| | | * cardNum 要挂失的水卡编号 |
| | | * money 余额 |
| | | * refund 退款金额 |
| | | * remarks 备注 |
| | |
| | | Long cardId = 0L; |
| | | Long clientId = 0L; |
| | | Long cardNum = po.getCardNum(); |
| | | Float money = po.getMoney(); |
| | | Float refund = po.getRefund(); |
| | | Float money = Optional.ofNullable(po.getMoney()).orElse(0f); |
| | | Float refund = Optional.ofNullable(po.getRefund()).orElse(0f); |
| | | String remarks = po.getRemarks(); |
| | | Long operator = po.getOperator(); |
| | | Date lossTime = new Date(); |
| | | |
| | | // 如果传入的是10位的水卡编号,升为17位水卡编号 |
| | | String cardNumS = String.valueOf(cardNum).trim(); |
| | | if(cardNumS.length() == 10) { |
| | | cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); |
| | | } |
| | | cardNum = Long.valueOf(cardNumS); |
| | | |
| | | // 验证水卡状态是否支持当前操作 |
| | | String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); |
| | | if(stateName.length() == 0 || !stateName.equals("正常")) { |
| | | return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap()); |
| | | if(map == null || map.size() <= 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_MISTAKE.getMessage()); |
| | | } |
| | | cardId = Long.parseLong(map.get("cardId").toString()); |
| | | clientId = Long.parseLong(map.get("clientId").toString()); |
| | | |
| | | /** |
| | | * 修改农户卡信息: |
| | | * 挂失时间 |
| | | * 最后操作类型-4 |
| | | * 余额 |
| | | * 挂失时间 |
| | | * 状态 |
| | | * 最后操作类型-6 |
| | | */ |
| | | SeClientCard seClientCard = new SeClientCard(); |
| | | seClientCard.setId(cardId); |
| | |
| | | seClientCard.setLastoper(LastOperateENUM.LOSS.getCode()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); |
| | | if(rec_updateClientCard == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.LOSS_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.LOSS_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * 添加挂失记录 |
| | | * 如果退款金额不为空,则传入负值 |
| | | */ |
| | | SeCardOperate seCardOperate = new SeCardOperate(); |
| | | seCardOperate.setCardId(cardId); |
| | |
| | | seCardOperate.setOperateDt(lossTime); |
| | | Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.LOSS_FAIL_WRITE_LOSS_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.LOSS_FAIL_WRITE_LOSS_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(true) ; |