From a7485c9f9b16ece4f12f0b3f6d6a8c90370f5ae4 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 09 四月 2025 16:08:30 +0800
Subject: [PATCH] 灌溉计划详情信息增加取水口命令发布失败数量

---
 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java |  200 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 139 insertions(+), 61 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..3e6b1fd 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,21 +1,24 @@
 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.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.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.*;
@@ -43,15 +46,125 @@
     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());
+        }
+        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 +177,6 @@
      * @return
      */
     @GetMapping(path = "/getVcById")
-    @SsoAop()
     public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){
         try {
             return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId));
@@ -72,55 +184,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 +203,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 +260,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 +317,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 +330,18 @@
             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()) ;
+        }
+    }
 }

--
Gitblit v1.8.0