From 7a2fa8d7481a3eb0a39dc9e434776b7ae05013b0 Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期三, 03 七月 2024 08:44:16 +0800
Subject: [PATCH] 2024-07-03 朱宝民 获取充值记录兼容10位水卡编号

---
 pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java |  120 ++++++++++++++++++++++++++---------------------------------
 1 files changed, 53 insertions(+), 67 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java
index 404e0c2..cb6bb55 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java
@@ -38,7 +38,6 @@
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 /**
@@ -311,15 +310,6 @@
      * @param bindingResult
      * @return
      */
-    @Operation(summary = "鍏呭��", description = "鍏呭��")
-    @ApiResponses(value = {
-            @ApiResponse(
-                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
-                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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()
@@ -336,20 +326,10 @@
      * @param bindingResult
      * @return
      */
-    @Operation(summary = "娣诲姞娉ㄩ攢璁板綍", description = "娣诲姞娉ㄩ攢璁板綍")
-    @ApiResponses(value = {
-            @ApiResponse(
-                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
-                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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());
         }
@@ -373,10 +353,17 @@
         Long operator = po.getOperator();
         Date cancelTime = 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("姝e父")) {
-            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
+            return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
         }
 
         /**
@@ -384,7 +371,7 @@
          */
         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());
@@ -402,7 +389,7 @@
         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());
         }
 
         /**
@@ -421,7 +408,7 @@
 
         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) ;
@@ -529,15 +516,6 @@
      * @param bindingResult
      * @return
      */
-    @Operation(summary = "娣诲姞鍐叉璁板綍", description = "娣诲姞鍐叉璁板綍")
-    @ApiResponses(value = {
-            @ApiResponse(
-                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
-                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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()
@@ -565,10 +543,17 @@
         Long operator = po.getOperator();
         Date reversalTime = 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("姝e父")) {
-            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
+            return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
         }
 
         /**
@@ -576,7 +561,7 @@
          */
         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());
@@ -593,7 +578,7 @@
         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());
         }
 
         /**
@@ -610,7 +595,7 @@
         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) ;
@@ -622,15 +607,6 @@
      * @param bindingResult
      * @return
      */
-    @Operation(summary = "琛ユ墸", description = "琛ユ墸")
-    @ApiResponses(value = {
-            @ApiResponse(
-                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
-                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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()
@@ -658,10 +634,17 @@
         Long operator = po.getOperator();
         Date refundTime = 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("姝e父")) {
-            return BaseResponseUtils.buildFail(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
+            return BaseResponseUtils.buildErrorMsg(stateName + ", " + SellResultCode.THE_CARD_NOT_SUPPORT_THIS_OPERATION.getMessage());
         }
 
         /**
@@ -669,7 +652,7 @@
          */
         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());
@@ -686,7 +669,7 @@
         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());
         }
 
         /**
@@ -704,7 +687,7 @@
         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) ;
@@ -716,20 +699,10 @@
      * @param bindingResult
      * @return
      */
-    @Operation(summary = "娣诲姞瑙i攣璁板綍", description = "娣诲姞瑙i攣璁板綍")
-    @ApiResponses(value = {
-            @ApiResponse(
-                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
-                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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());
         }
@@ -751,9 +724,16 @@
         Long operator = po.getOperator();
         Date unlockTime = 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);
+
         // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶卞叾鏈ˉ鍗$殑鍙互瑙i攣
         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());
         }
 
         /**
@@ -761,7 +741,7 @@
          */
         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());
@@ -779,7 +759,7 @@
         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());
         }
 
         /**
@@ -795,7 +775,7 @@
         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) ;
@@ -818,11 +798,17 @@
     @GetMapping(path = "/getRecharges")
     @SsoAop()
     public BaseResponse<QueryResultVo<List<VoRecharge>>> get(QoRecharge vo){
+        // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙�
+        if(vo != null && vo.getCardNum() != null) {
+            String cardNumS = String.valueOf(vo.getCardNum()).trim();
+            if(cardNumS.length() == 10) {
+                cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6);
+                vo.setCardNum(Long.parseLong(cardNumS));
+            }
+        }
+
         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);

--
Gitblit v1.8.0