From e8937f27fce194d015ce6c27d286e7fc89f5e580 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期三, 23 四月 2025 17:29:47 +0800 Subject: [PATCH] 查询开关阀记录相关修改 --- pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java | 233 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 168 insertions(+), 65 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java index e53ea94..0005593 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java @@ -1,29 +1,31 @@ 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.SeVcOperate; import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; +import com.dy.pipIrrGlobal.voIr.VoPlanDetails; +import com.dy.pipIrrGlobal.voSe.VoRechargeProfile; 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.Client; +import com.dy.pipIrrWechat.virtualCard.dto.DtoCancel; import com.dy.pipIrrWechat.virtualCard.dto.DtoRegist; -import com.dy.pipIrrWechat.virtualCard.dto.DtoVcRecharge; +import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM; +import com.dy.pipIrrWechat.virtualCard.qo.QoVcRecharge; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.Date; -import java.util.List; -import java.util.Objects; -import java.util.Optional; +import java.util.*; /** * @author ZhuBaoMin @@ -43,15 +45,132 @@ private final PayHelper payHelper; /** + * 娉ㄥ唽铏氭嫙鍗� + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "add_vc") + @Transactional(rollbackFor = Exception.class) + public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult) { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Map map_result = virtualCardSv.addVC(po.getClientId(), 0D); + if(map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess() ; + + //Long clientId = po.getClientId(); + // + //// 鑾峰彇5绾ц鏀垮尯鍒掍覆areaCode + //Long areaCodeL = virtualCardSv.getAreaCodeById(clientId); + //if(areaCodeL == null) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.AREA_CODE_MISTAKE.getMessage()); + //} + //String areaCode = String.valueOf(areaCodeL); + // + ///** + // * 鏍规嵁琛屾斂鍖哄垝涓诧紙areaCode锛夊湪铏氭嫙鍗¤〃涓拡瀵硅櫄鎷熷崱缂栧彿锛坴cNum锛夎繘琛屾ā绯婃煡璇� + // * 濡傛灉5浣嶉『搴忓彿宸茬粡杈惧埌鏈�澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛� + // * 濡傛灉5浣嶉『搴忓彿鏈揪鍒版渶澶у�硷紝鍒欏姞1 + // * cardNum涓烘柊鐨勫崱鍙� + // */ + //String vcNum = Optional.ofNullable(virtualCardSv.getVcCardNumOfMax(areaCode)).orElse(""); + //if(vcNum != null && vcNum.trim().length() > 0) { + // Integer number = Integer.parseInt(vcNum.substring(12)); + // number = number + 1; + // if(number > 65535) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.CARD_NUMBER_OVERRUN.getMessage()); + // } + // vcNum = vcNum.substring(0, 12) + String.format("%05d", number); + //} else { + // vcNum = areaCode + "00001"; + //} + // + //// 鐢熸垚铏氭嫙鍗¤褰� + //SeVirtualCard seVirtualCard = new SeVirtualCard(); + //seVirtualCard.setVcNum(Long.parseLong(vcNum)); + //seVirtualCard.setClientId(clientId); + //seVirtualCard.setMoney(0d); + //seVirtualCard.setState((byte)1); + //seVirtualCard.setLastOperate(LastOperateENUM.OPEN_ACCOUNT.getCode()); + //seVirtualCard.setLastOperateTime(new Date()); + //seVirtualCard.setInUse((byte) 0); + //seVirtualCard.setCreateTime(new Date()); + //Long vcId = virtualCardSv.insertVirtualCard(seVirtualCard); + //if(vcId == null) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); + //} + // + //// 鐢熸垚铏氭嫙鍗℃搷浣滆褰曪紝娉ㄥ唽铏氭嫙鍗℃搷浣滀汉涓哄啘鎴� + //SeVcOperate seVcOperate = new SeVcOperate(); + //seVcOperate.setVcId(vcId); + //seVcOperate.setClientId(clientId); + //seVcOperate.setOperateType(LastOperateENUM.OPEN_ACCOUNT.getCode()); + //seVcOperate.setOperator(clientId); + //seVcOperate.setOperateTime(new Date()); + //Long vcOperateId = virtualCardSv.insertVcOperate(seVcOperate); + //if(vcOperateId == null) { + // return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); + //} + // + //return BaseResponseUtils.buildSuccess(true) ; + } + + /** + * 鏍规嵁铏氭嫙鍗D娉ㄩ攢铏氭嫙鍗� + * @param po + * @param bindingResult + * @return + */ + @PostMapping(path = "cancel") + @Transactional(rollbackFor = Exception.class) + public BaseResponse<Boolean> cancelVC(@RequestBody @Valid DtoCancel po, BindingResult bindingResult) { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Long clientId = po.getClientId(); + Long vcId = po.getVcId(); + + // 鏍规嵁鍐滄埛ID鍙婅櫄鎷熷崱Id鍒ゆ柇鏄惁瀛樺湪姝e父鐘舵�侊紙鍙敞閿�锛夌殑铏氭嫙鍗� + SeVirtualCard seVirtualCard = virtualCardSv.getVcByClientIdAndVcId(clientId, vcId); + if(seVirtualCard == null) { + return BaseResponseUtils.buildErrorMsg(WechatResultCode.NO_VC_FIT_THE_BILL.getMessage()); + } + + // 娉ㄩ攢铏氭嫙鍗� + Integer rec = virtualCardSv.cancelVc(clientId, vcId); + if(rec == null || rec == 0) { + return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_CANCEL_FAIL.getMessage()); + } + + // 鐢熸垚铏氭嫙鍗℃搷浣滆褰曪紝娉ㄥ唽铏氭嫙鍗℃搷浣滀汉涓哄啘鎴� + SeVcOperate seVcOperate = new SeVcOperate(); + seVcOperate.setVcId(vcId); + seVcOperate.setClientId(clientId); + seVcOperate.setOperateType(LastOperateENUM.CLOSING_ACCOUNT.getCode()); + seVcOperate.setOperator(clientId); + seVcOperate.setOperateTime(new Date()); + Long vcOperateId = virtualCardSv.insertVcOperate(seVcOperate); + if(vcOperateId == null) { + return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); + } + + return BaseResponseUtils.buildSuccess(true) ; + } + + /** * 鑾峰彇鍐滄埛鍏ㄩ儴铏氭嫙鍗� * @return */ @GetMapping(path = "/get") - @SsoAop() public BaseResponse<List<VoVirtualCard>> getVCs(Long clientId){ try { - List<VoVirtualCard> res = virtualCardSv.getVCs(clientId); - return BaseResponseUtils.buildSuccess(res); + return BaseResponseUtils.buildSuccess(virtualCardSv.getVCs(clientId)); } catch (Exception e) { log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e); return BaseResponseUtils.buildException(e.getMessage()) ; @@ -64,7 +183,6 @@ * @return */ @GetMapping(path = "/getVcById") - @SsoAop() public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){ try { return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId)); @@ -72,55 +190,6 @@ 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){ - 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)); - /** - * 鏍规嵁琛屾斂鍖哄垝涓诧紙areaCode锛夊湪铏氭嫙鍗¤〃涓拡瀵硅櫄鎷熷崱缂栧彿锛坴cNum锛夎繘琛屾ā绯婃煡璇� - * 濡傛灉5浣嶉『搴忓彿宸茬粡杈惧埌鏈�澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛� - * 濡傛灉5浣嶉『搴忓彿鏈揪鍒版渶澶у�硷紝鍒欏姞1 - * cardNum涓烘柊鐨勫崱鍙� - */ - String vcNum = Optional.ofNullable(virtualCardSv.getVcCardNumOfMax(areaCode)).orElse(""); - if(vcNum != null && vcNum.trim().length() > 0) { - Integer number = Integer.parseInt(vcNum.substring(12)); - number = number + 1; - if(number > 65535) { - return BaseResponseUtils.buildFail(WechatResultCode.CARD_NUMBER_OVERRUN.getMessage()); - } - vcNum = vcNum.substring(0, 12) + String.format("%05d", number); - } else { - vcNum = areaCode + "00001"; - } - - SeVirtualCard seVirtualCard = new SeVirtualCard(); - seVirtualCard.setVcNum(Long.parseLong(vcNum)); - seVirtualCard.setClientId(clientId); - seVirtualCard.setMoney(0d); - seVirtualCard.setLastOperate(LastOperateENUM.OPEN_ACCOUNT.getCode()); - seVirtualCard.setLastOperateTime(new Date()); - seVirtualCard.setInUse((byte) 0); - seVirtualCard.setCreateTime(new Date()); - Long rec = virtualCardSv.insertVirtualCard(seVirtualCard); - if(rec == null) { - return BaseResponseUtils.buildFail(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); - } - return BaseResponseUtils.buildSuccess(true) ; } /** @@ -140,7 +209,6 @@ //}) //@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()); @@ -198,7 +266,6 @@ //}) //@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()); @@ -256,9 +323,12 @@ * @return */ @GetMapping(path = "/getVcRechargeRecords") - @SsoAop() - public BaseResponse<QueryResultVo<List<VoVcRecharge>>> getVcRechargeRecords(DtoVcRecharge dtoVcRecharge){ + public BaseResponse<QueryResultVo<List<VoVcRecharge>>> getVcRechargeRecords(QoVcRecharge dtoVcRecharge){ try { + if(dtoVcRecharge.getVcId() == null) { + return BaseResponseUtils.buildErrorMsg("铏氭嫙鍗′笉鑳戒负绌�"); + } + QueryResultVo<List<VoVcRecharge>> res = virtualCardSv.getVcRechargeRecords(dtoVcRecharge); return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { @@ -266,4 +336,37 @@ return BaseResponseUtils.buildException(e.getMessage()) ; } } + + /** + * 鑾峰彇铏氭嫙鍗″父鐢ㄥ厖鍊奸噾棰濋厤缃� + * @return + */ + @GetMapping(path = "/gerRechargeProfiles") + public BaseResponse<List<VoRechargeProfile>> gerRechargeProfiles(){ + try { + return BaseResponseUtils.buildSuccess(virtualCardSv.gerRechargeProfiles()); + } catch (Exception e) { + log.error("鑾峰彇铏氭嫙鍗″父鐢ㄥ厖鍊奸噾棰濋厤缃紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 缁戝畾铏氭嫙鍗″埌鍙栨按鍙� + * @return + */ + @PostMapping(path = "linkVcToIntake") + @Transactional(rollbackFor = Exception.class) + public BaseResponse<Boolean> linkVcToIntake(@RequestBody @Valid Client client, BindingResult bindingResult) { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Long clientId = client.getClientId(); + Map map_result = virtualCardSv.linkVcToIntake(clientId); + if(map_result.get("success").equals(false)) { + return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); + } + return BaseResponseUtils.buildSuccess() ; + } } -- Gitblit v1.8.0