| | |
| | | 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.pipIrrSell.cardOperate.converter.RechargeDtoMapper; |
| | | 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.dto.*; |
| | | import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; |
| | | import com.dy.pipIrrSell.cardOperate.qo.*; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | * @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 = "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 = String.valueOf(cardOperateSv.getAreaCodeByNum(po.getClientNum())); |
| | | Long areaCodeL = cardOperateSv.getAreaCodeById(clientId); |
| | | if(areaCodeL == null) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.AREA_CODE_MISTAKE.getMessage()); |
| | | } |
| | | String areaCode = String.valueOf(areaCodeL); |
| | | |
| | | /** |
| | | * 根据行政区划串(areaCode)在水卡表中针对水卡编号(cardNum)进行模糊查询 |
| | | * 如果4位顺序号已经达到最大值,提示用户联系系统管理员 |
| | | * 如果4位顺序号未达到最大值,则加1 |
| | | * 如果顺序号已经达到最大值,提示用户联系系统管理员 |
| | | * 如果顺序号未达到最大值,则加1 |
| | | * cardNum为新的卡号 |
| | | */ |
| | | String cardNum = Optional.ofNullable(cardOperateSv.getCardNumOfMax(areaCode)).orElse(""); |
| | | if(cardNum != null && cardNum.trim().length() > 0) { |
| | | Integer number = Integer.parseInt(cardNum.substring(12)); |
| | | number = number + 1; |
| | | if(number > 9999) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); |
| | | if(number > 65535) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); |
| | | } |
| | | cardNum = cardNum.substring(0, 12) + String.format("%04d", number); |
| | | cardNum = cardNum.substring(0, 12) + String.format("%05d", number); |
| | | } else { |
| | | cardNum = areaCode + "0001"; |
| | | 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); |
| | | |
| | | /** |
| | | * 添加农户卡记录,退还金额作为当前余额 |
| | |
| | | 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) ; |
| | | if(cardId == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.ACTIVE_FAIL_WRITE_CLIENT_CARD_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()); |
| | |
| | | seCardOperate.setOperateDt(activeTime); |
| | | Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_WRITE_ACTIVE_CARD_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.ACTIVE_FAIL_WRITE_ACTIVE_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * 如果操作人员开卡时输入了充值金额,则开卡后调用充值功能 |
| | | * 补卡除外,补卡的退还金额是从挂失卡中转移过来的,没有实际金钱交易 |
| | | */ |
| | | 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); |
| | | BaseResponse<Boolean> job = cardOperateSv.addRecharge(dtoRecharge); |
| | | if(!job.getCode().equals("0001")) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.ACTIVE_FAIL_RECHARGE_EXCEPTION.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.ACTIVE_FAIL_RECHARGE_EXCEPTION.getMessage()); |
| | | } |
| | | } |
| | | |
| | | Map map = new HashMap(); |
| | | map.put("projectCode", Constant.projectCode_ym); |
| | | map.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map.put("orderNumber", rec); |
| | | map.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map) ; |
| | | } |
| | |
| | | * @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 cardAddr = po.getCardAddr(); |
| | | String clientNum = ""; |
| | | Long clientId = 0L; |
| | | 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(); |
| | | |
| | | // 判断当前水卡是否为挂失状态且未补卡,仅已经挂失其未补卡的可以补卡 |
| | | // 判断当前水卡是否为挂失状态且未补卡,仅已经挂失且未补卡的可以补卡 |
| | | 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 && reissueAmount > 0) { |
| | | 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()); |
| | | clientId = Long.parseLong(map.get("clientId").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.setCardAddr(cardAddr); |
| | | dtoActiveCard.setClientNum(clientNum); |
| | | dtoActiveCard.setOriginalCardId(cardNum); |
| | | 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.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 = "recharge", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | * @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 = "cancel", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> add_cancel(@RequestBody @Valid DtoCancel po, BindingResult bindingResult){ |
| | | DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | |
| | | // 验证水卡状态是否支持当前操作 |
| | | 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()); |
| | |
| | | seClientCard.setLastoper(LastOperateENUM.CANCEL.getCode()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); |
| | | if(rec_updateClientCard == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.CANCEL_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CANCEL_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.CANCEL_FAIL_WRITE_CANCELL_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CANCEL_FAIL_WRITE_CANCELL_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map_response.put("orderNumber", rec); |
| | | 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(); |
| | |
| | | // 验证水卡状态是否支持当前操作 |
| | | 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) ; |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map_response.put("orderNumber", rec); |
| | | 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 = "reversal", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | // 验证水卡状态是否支持当前操作 |
| | | 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()); |
| | |
| | | seClientCard.setLastoper(LastOperateENUM.REVERSAL.getCode()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); |
| | | if(rec_updateClientCard == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | seCardOperate.setOperateDt(reversalTime); |
| | | Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.REVERSAL_FAIL_WRITE_REVERSAL_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.REVERSAL_FAIL_WRITE_REVERSAL_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map_response.put("orderNumber", rec); |
| | | 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 = "refund", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | |
| | | // 验证水卡状态是否支持当前操作 |
| | | 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()); |
| | |
| | | seClientCard.setLastoper(LastOperateENUM.REFUND.getCode()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); |
| | | if(rec_updateClientCard == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.RECHARGE_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | seCardOperate.setCardId(cardId); |
| | | seCardOperate.setClientId(clientId); |
| | | seCardOperate.setMoney(money); |
| | | //seCardOperate.setNoTradeAmount(refund); |
| | | seCardOperate.setRefundAmount(refund); |
| | | seCardOperate.setOperateType(OperateTypeENUM.REFUND.getCode()); |
| | | seCardOperate.setRemarks(remarks); |
| | |
| | | seCardOperate.setOperateDt(refundTime); |
| | | Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.REFUND_FAIL_WRITE_REFUND_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.REFUND_FAIL_WRITE_REFUND_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | |
| | | * @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 = "unlock", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> add_unlock(@RequestBody @Valid DtoUnlock po, BindingResult bindingResult){ |
| | | DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | |
| | | |
| | | // 判断当前水卡是否为挂失状态且未补卡,仅已经挂失其未补卡的可以解锁 |
| | | 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()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | 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()); |
| | |
| | | seClientCard.setLastoper(LastOperateENUM.UNLOCK.getCode()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); |
| | | if(rec_updateClientCard == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.UNLOCK_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.UNLOCK_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | seCardOperate.setOperateDt(unlockTime); |
| | | Long rec = Optional.ofNullable(cardOperateSv.add(seCardOperate)).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.UNLOCK_FAIL_WRITE_UNLOCK_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.UNLOCK_FAIL_WRITE_UNLOCK_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", Integer.parseInt(cardOperateSv.getProjectNo()))); |
| | | map_response.put("orderNumber", rec); |
| | | map_response.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map_response) ; |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | public BaseResponse<QueryResultVo<List<VoRecharge>>> get(QoRecharge vo){ |
| | | try { |
| | | QueryResultVo<List<VoRecharge>> res = cardOperateSv.getRecharges(vo); |
| | | if(res.itemTotal == 0) { |
| | | return BaseResponseUtils.buildFail(SellResultCode.No_RECHARGES.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取充值记录异常", e); |