| | |
| | | package com.dy.pipIrrWechat.virtualCard; |
| | | |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; |
| | | import com.dy.pipIrrGlobal.voSe.VoVcRecharge; |
| | | import com.dy.pipIrrGlobal.voSe.VoVirtualCard; |
| | | import com.dy.pipIrrWechat.util.PayHelper; |
| | | import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM; |
| | | import com.dy.pipIrrWechat.result.WechatResultCode; |
| | | import com.dy.pipIrrWechat.util.PayHelper; |
| | | import com.dy.pipIrrWechat.virtualCard.dto.DtoRegist; |
| | | import com.dy.pipIrrWechat.virtualCard.dto.DtoVcRecharge; |
| | | import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | private final PayHelper payHelper; |
| | | |
| | | /** |
| | | * 获取农户全部虚拟卡 |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/get") |
| | | @SsoAop() |
| | | public BaseResponse<List<VoVirtualCard>> getVCs(Long clientId){ |
| | | try { |
| | | List<VoVirtualCard> res = virtualCardSv.getVCs(clientId); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("获取支付方式记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据虚拟卡ID获取虚拟卡对象 |
| | | * @param vcId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getVcById") |
| | | @SsoAop() |
| | | public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId)); |
| | | } catch (Exception e) { |
| | | log.error("获取支付方式记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 虚拟卡账号注册 |
| | | * 注册虚拟卡 |
| | | * @param po |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "add_vc") |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult){ |
| | | public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist 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(virtualCardSv.getAreaCodeById(clientId)); |
| | | Long areaCodeL = virtualCardSv.getAreaCodeById(clientId); |
| | | if(areaCodeL == null) { |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.AREA_CODE_MISTAKE.getMessage()); |
| | | } |
| | | String areaCode = String.valueOf(areaCodeL); |
| | | |
| | | /** |
| | | * 根据行政区划串(areaCode)在虚拟卡表中针对虚拟卡编号(vcNum)进行模糊查询 |
| | | * 如果5位顺序号已经达到最大值,提示用户联系系统管理员 |
| | |
| | | Integer number = Integer.parseInt(vcNum.substring(12)); |
| | | number = number + 1; |
| | | if(number > 65535) { |
| | | return BaseResponseUtils.buildFail(WechatResultCode.CARD_NUMBER_OVERRUN.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.CARD_NUMBER_OVERRUN.getMessage()); |
| | | } |
| | | vcNum = vcNum.substring(0, 12) + String.format("%05d", number); |
| | | } else { |
| | |
| | | seVirtualCard.setCreateTime(new Date()); |
| | | Long rec = virtualCardSv.insertVirtualCard(seVirtualCard); |
| | | if(rec == null) { |
| | | return BaseResponseUtils.buildFail(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | |
| | | /** |
| | | * 获取农户全部虚拟卡 |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/get") |
| | | public BaseResponse<List<VoVirtualCard>> getVCs(Long clientId){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(virtualCardSv.getVCs(clientId)); |
| | | } catch (Exception e) { |
| | | log.error("获取支付方式记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据虚拟卡ID获取虚拟卡对象 |
| | | * @param vcId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getVcById") |
| | | public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId)); |
| | | } catch (Exception e) { |
| | | log.error("获取支付方式记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | //}) |
| | | //@PostMapping(path = "add_refund", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | //@SsoAop() |
| | | //public BaseResponse<Boolean> addRefund(@RequestBody @Valid DtoRefund po, BindingResult bindingResult){ |
| | | // if(bindingResult != null && bindingResult.hasErrors()){ |
| | | // return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | |
| | | //}) |
| | | //@PostMapping(path = "audit_refund", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | //@SsoAop() |
| | | //public BaseResponse<Boolean> auditRefund(@RequestBody @Valid DtoAudit po, BindingResult bindingResult) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, SignatureException, InvalidKeyException { |
| | | // if(bindingResult != null && bindingResult.hasErrors()){ |
| | | // return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getVcRechargeRecords") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoVcRecharge>>> getVcRechargeRecords(DtoVcRecharge dtoVcRecharge){ |
| | | try { |
| | | QueryResultVo<List<VoVcRecharge>> res = virtualCardSv.getVcRechargeRecords(dtoVcRecharge); |