From 2a9830a14c30bbddc9d8de727b8c0b31b760ebc4 Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期三, 27 十二月 2023 11:36:41 +0800
Subject: [PATCH] 2023-12-27 朱宝民 项目编号记录在配置文件中,开卡成功一并返回

---
 pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/loss/LossCtrl.java |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/loss/LossCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/loss/LossCtrl.java
index 08bf5b2..ab59e5b 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/loss/LossCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/loss/LossCtrl.java
@@ -10,6 +10,7 @@
 import com.dy.pipIrrGlobal.voSe.VoLoss;
 import com.dy.pipIrrSell.clientCard.ClientCardSv;
 import com.dy.pipIrrSell.clientCard.LastOperateENUM;
+import com.dy.pipIrrSell.result.SellResultCode;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.media.Content;
@@ -25,11 +26,7 @@
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 
-import java.time.format.DateTimeFormatter;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
 
 /**
  * @author ZhuBaoMin
@@ -56,9 +53,9 @@
                             schema = @Schema(implementation = VoLoss.class))}
             )
     })
-    @GetMapping(path = "/getLosses", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @GetMapping(path = "/getLosses")
     @SsoAop()
-    public BaseResponse<QueryResultVo<List<VoLoss>>> getLosses(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) QueryVo vo){
+    public BaseResponse<QueryResultVo<List<VoLoss>>> getLosses(QueryVo vo){
         try {
             QueryResultVo<List<VoLoss>> res = lossSv.getLosses(vo);
             return BaseResponseUtils.buildSuccess(res);
@@ -81,15 +78,14 @@
     @Transactional(rollbackFor = Exception.class)
     @SsoAop()
     public BaseResponse<Boolean> add(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid DtoLoss po, @Parameter(hidden = true) 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());
         }
 
         /**
-         * cardId           姘村崱缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardAddr鍙嶆煡锛�
-         * cardAddr         姘村崱鍦板潃
-         * clientId         鍐滄埛缂栧彿
+         * cardId           姘村崱缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛�
+         * clientId         鍐滄埛缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardNum鍙嶆煡锛�
+         * cardNum          姘村崱缂栧彿
          * money            浣欓
          * refund           閫�娆鹃噾棰�
          * remarks          澶囨敞
@@ -97,8 +93,8 @@
          * lossTime         鎸傚け鏃堕棿
          */
         Long cardId = 0L;
-        String cardAddr = po.getCardAddr();
-        Long clientId = po.getClientId();
+        String cardNum = po.getCardNum();
+        Long clientId = 0L;
         Float money = po.getMoney();
         Float refund = po.getRefund();
         String remarks = po.getRemarks();
@@ -106,12 +102,14 @@
         Date lossTime = new Date();
 
         /**
-         * 渚濇嵁姘村崱鍦板潃鑾峰彇姘村崱缂栧彿锛堜富閿級
+         * 渚濇嵁姘村崱缂栧彿鑾峰彇姘村崱琛ㄤ富閿強鍐滄埛缂栧彿
          */
-        cardId = Optional.ofNullable(clientCardSv.getCardIdByAddr(cardAddr)).orElse(0L);
-        if(cardId == 0) {
-            return BaseResponseUtils.buildFail("鍗″彿閿欒锛岃鍗′笉瀛樺湪");
+        Map map = Optional.ofNullable(clientCardSv.getCardIdAndClientNum(cardNum)).orElse(new HashMap());
+        if(map == null || map.size() <= 0) {
+            return BaseResponseUtils.buildFail(SellResultCode.CARD_NUMBER_MISTAKE.getMessage());
         }
+        cardId = Long.parseLong(map.get("cardId").toString());
+        clientId = Long.parseLong(map.get("clientId").toString());
 
         /**
          * 淇敼鍐滄埛鍗′俊鎭細
@@ -124,13 +122,15 @@
         seClientCard.setLastoper(LastOperateENUM.LOSS.getCode());
         Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0);
         if(rec_updateClientCard == 0) {
-            return BaseResponseUtils.buildFail("鎸傚け澶辫触-鍐滄埛鍗℃寕澶卞紓甯�");
+            return BaseResponseUtils.buildFail(SellResultCode.LOSS_FAIL_WRITE_CLIENT_CARD_ERROR.getMessage());
         }
 
         /**
          * 娣诲姞鎸傚け璁板綍
          */
         SeLoss seLoss = new SeLoss();
+        //seLoss.setCardnum(cardNum);
+        //seLoss.setClientnum(clientNum);
         seLoss.setCardid(cardId);
         seLoss.setClientid(clientId);
         seLoss.setMoney(money);
@@ -140,7 +140,7 @@
         seLoss.setOperatedt(lossTime);
         Long rec = Optional.ofNullable(lossSv.add(seLoss)).orElse(0L);
         if(rec == 0) {
-            return BaseResponseUtils.buildFail("鎸傚け澶辫触-鎸傚け璁板綍鍐欏叆寮傚父");
+            return BaseResponseUtils.buildFail(SellResultCode.LOSS_FAIL_WRITE_LOSS_ERROR.getMessage());
         }
 
         return BaseResponseUtils.buildSuccess(true) ;

--
Gitblit v1.8.0