From 2cad0284bd59efd17be1da8b122a983d9cbdbac5 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期五, 28 六月 2024 17:04:06 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateCtrl.java |  109 +++++++++++++++++++++++++++++++++---------------------
 1 files changed, 66 insertions(+), 43 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 bb54a18..404e0c2 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
@@ -1,5 +1,7 @@
 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;
@@ -9,8 +11,10 @@
 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.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.converter.RechargeDtoMapper;
 import com.dy.pipIrrSell.cardOperate.dto.*;
 import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM;
@@ -134,7 +138,9 @@
         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) ;
@@ -194,15 +200,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 = "reissue", consumes = MediaType.APPLICATION_JSON_VALUE)
     @Transactional(rollbackFor = Exception.class)
     @SsoAop()
@@ -218,6 +215,7 @@
          * cardId           鍘熸按鍗★紙鎸傚け姘村崱锛塈D锛岃浆绉讳綑棰濆悗闇�瑕佹洿鏂板崱浣欓涓�0
          * moeny            浣欓锛屾寕澶辨椂浣跨敤
          * cardCost         鍗$墖璐圭敤
+         * reissueAmount    閫�杩橀噾棰�
          * paymentId        鏀粯鏂瑰紡缂栧彿
          * remarks          澶囨敞
          * operator         鎿嶄綔浜虹紪鍙�
@@ -227,15 +225,32 @@
         String clientNum = "";
         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();
+        String protocol = null;
 
-        // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶卞叾鏈ˉ鍗$殑鍙互琛ュ崱
+        // 濡傛灉浼犲叆鐨勬槸10浣嶇殑姘村崱缂栧彿锛屽崌涓�17浣嶆按鍗$紪鍙�
+        String cardNumS = String.valueOf(cardNum).trim();
+        if(cardNumS.length() == 10) {
+            cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6);
+            protocol = "p206V1_0_1";
+        }
+        cardNum = Long.valueOf(cardNumS);
+
+        // 鍒ゆ柇褰撳墠姘村崱鏄惁涓烘寕澶辩姸鎬佷笖鏈ˉ鍗★紝浠呭凡缁忔寕澶变笖鏈ˉ鍗$殑鍙互琛ュ崱
         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) {
+            Double tradeAmount = cardOperateSv.getTradeAmountByCardNo(cardNum);
+            if(tradeAmount != null) {
+                return BaseResponseUtils.buildErrorMsg(SellResultCode.THE_FEE_CANNOT_BE_REFUNDED.getMessage());
+            }
         }
 
         /**
@@ -243,7 +258,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());
         }
         clientNum = map.get("clientNum").toString();
         cardId = Long.parseLong(map.get("cardId").toString());
@@ -251,18 +266,22 @@
         /**
          * 濡傛灉鏄ˉ鍗¤皟鐢ㄧ殑寮�鍗′笖杞Щ浜嗛��杩橀噾棰濓紝闇�淇敼鎸傚け鍗′綑棰濅负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.setProtocol(protocol);
         dtoActiveCard.setCardAddr(cardAddr);
         dtoActiveCard.setClientNum(clientNum);
-        dtoActiveCard.setOriginalCardId(cardNum);
+        dtoActiveCard.setOriginalCardId(cardId);
+        //dtoActiveCard.setOriginalCardId(cardNum);
         dtoActiveCard.setCardCost(cardCost);
         dtoActiveCard.setAmount(reissueAmount);
         dtoActiveCard.setPaymentId(paymentId);
@@ -271,14 +290,17 @@
         BaseResponse<java.lang.Boolean> baseResponse_addActive = add_active(dtoActiveCard, 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) ;
     }
@@ -411,15 +433,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 = "loss", consumes = MediaType.APPLICATION_JSON_VALUE)
     @Transactional(rollbackFor = Exception.class)
     @SsoAop()
@@ -431,7 +444,7 @@
         /**
          * cardId           姘村崱缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛�
          * clientId         鍐滄埛缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛�
-         * cardNum          姘村崱缂栧彿
+         * cardNum          瑕佹寕澶辩殑姘村崱缂栧彿
          * money            浣欓
          * refund           閫�娆鹃噾棰�
          * remarks          澶囨敞
@@ -441,16 +454,23 @@
         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();
 
+        // 濡傛灉浼犲叆鐨勬槸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());
         }
 
         /**
@@ -458,15 +478,17 @@
          */
         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);
@@ -476,11 +498,12 @@
         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);
@@ -494,7 +517,7 @@
         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) ;

--
Gitblit v1.8.0