From bd6f2e5aef6762cb918933bca0dc927d50ba404a Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期四, 20 六月 2024 16:50:50 +0800
Subject: [PATCH] zjh 2024/06/20-2

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java |   99 ++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 81 insertions(+), 18 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
index a720dbe..d71ee6b 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -1035,11 +1035,18 @@
             /*璋冪敤his鎺ュ彛*/
             String config = configService.selectConfigByKey("sfkqdyhis");
             if(null !=config && config.equals("Y")){
-                hisApiMethod.HisApiMethods(tjCustomer,tjOrder.getOrderId());
+                AjaxResult result = hisApiMethod.HisApiMethods(tjCustomer, tjOrder.getOrderId());
+                if(!result.get("code").toString().equals("200")){
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("鎸傚彿澶辫触!"+result.get("msg").toString());
+                }
+            }else {
+            tjCustomer.setCardId(tjOrder.getTjNumber());
+            tjCustomerService.updateById(tjCustomer);
+            transitionService.updateCardIdByTjNumAndIdCard(tjCustomer.getCusIdcard(),tjOrder.getTjNumber(),tjOrder.getTjNumber());
+            tjOrder.setCardId(tjOrder.getTjNumber());
+             tjOrderService.updateById(tjOrder);
             }
-//            tjCustomer.setCardId("0");
-//            tjCustomerService.updateById(tjCustomer);
-
             return AjaxResult.success(tjNumber);
         }
         return AjaxResult.error();
@@ -1625,14 +1632,16 @@
 
 
         if (null != tbTransitionList && tbTransitionList.size() > 0) {
-            if (redisCache.hasKey(cardId + cusId)) {
-                redisCache.deleteObject(cardId + cusId);
-                redisCache.setCacheList(cardId + cusId, tbTransitionList);
-                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
-            } else {
-                redisCache.setCacheList(cardId + cusId, tbTransitionList);
-                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
-            }
+//            if (redisCache.hasKey(cardId + cusId)) {
+//                redisCache.deleteObject(cardId + cusId);
+//                redisCache.setCacheList(cardId + cusId, tbTransitionList);
+//                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
+//            } else {
+//                redisCache.setCacheList(cardId + cusId, tbTransitionList);
+//                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
+//            }
+            List<Map<String, Object>> map1 = getMap(cusId, cardId, tbTransitionList);
+            return AjaxResult.success(map1);
         }
         return AjaxResult.success();
     }
@@ -1686,7 +1695,7 @@
                     for (TjOrder order : list) {
                         TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                         if (null != tjCustomer) {
-                            order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                            order.setTjCustomerName(tjCustomer.getCusName());
                             order.setTjCustomerSex(tjCustomer.getCusSex());
                             order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                             order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
@@ -1740,7 +1749,7 @@
             for (TjOrder order : list) {
                 TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                 if (null != tjCustomer) {
-                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                    order.setTjCustomerName(tjCustomer.getCusName());
                     order.setTjCustomerSex(tjCustomer.getCusSex());
                     order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                     order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
@@ -1902,6 +1911,55 @@
 //            transitionList = redisCache.getCacheList(cardId + cusId);
 //        } else {
         transitionList = transitionService.getTbTransitionListByCusId(cusId, cardId);
+//        }
+        if (null == transitionList) return null;
+        Map<Long, List<TbTransition>> collect = transitionList.stream().collect(Collectors.groupingBy(TbTransition::getParentProId));
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (Map.Entry<Long, List<TbTransition>> entry : collect.entrySet()) {
+            Map<String, Object> map = new HashMap<>();
+            Long pacId = entry.getValue().get(0).getPacId();
+            if (null != pacId) {
+                TjPackage aPackage = tjPackageService.getById(entry.getValue().get(0).getPacId());
+                map.put("pacName", aPackage.getPacName());
+                TjProject tjProject = projectService.getById(entry.getKey());
+//                TjPackageProject project = tjPackageProjectService.getOne(new LambdaQueryWrapper<TjPackageProject>().eq(TjPackageProject::getPacId, pacId)
+//                        .eq(TjPackageProject::getProId, entry.getKey()));
+                map.put("ordPrice", tjProject.getProPrice());
+//                if (null != project) {
+//                    map.put("nowPrice", project.getPriceNow());
+//                } else {
+//                    map.put("nowPrice", tjProject.getProPrice());
+//                }
+                map.put("nowPrice", transitionService.getTbTransitionDxPriceByPac(cusId, entry.getKey(), cardId, pacId));
+            } else {
+                map.put("pacName", "鍗曢」");
+                List<TbTransition> tbTransitionList = entry.getValue();
+                if (null != tbTransitionList && tbTransitionList.size() > 0) {
+                    BigDecimal money1 = new BigDecimal("0.00");
+                    BigDecimal money2 = new BigDecimal("0.00");
+                    for (TbTransition tbTransition : tbTransitionList) {
+                        money1 = money1.add(tbTransition.getOrdPrice());
+                        money2 = money2.add(tbTransition.getNowPrice());
+                    }
+                    map.put("ordPrice", money1);
+                    map.put("nowPrice", money2);
+                }
+            }
+            map.put("parentName", projectService.getById(entry.getKey()).getProName());
+            map.put("list", entry.getValue());
+            list.add(map);
+        }
+        return list;
+    }
+
+
+    private List<Map<String, Object>> getMap(String cusId, String cardId,List<TbTransition> transitionList) {
+
+//        List<TbTransition> transitionList = null;
+//        if (redisCache.hasKey(cardId + cusId)) {
+//            transitionList = redisCache.getCacheList(cardId + cusId);
+//        } else {
+//        transitionList = transitionService.getTbTransitionListByCusId(cusId, cardId);
 //        }
         if (null == transitionList) return null;
         Map<Long, List<TbTransition>> collect = transitionList.stream().collect(Collectors.groupingBy(TbTransition::getParentProId));
@@ -2326,16 +2384,21 @@
 
         TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
         if (null != order) {
-            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
-            if (null != payByTjNum) {
-                return AjaxResult.success("璇ョ敤鎴峰凡鏀惰垂涓嶅彲鎾ら攢绛惧埌!");
-            }
+//            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
+//            if (null != payByTjNum) {
+//                return AjaxResult.error("璇ョ敤鎴峰凡鏀惰垂涓嶅彲鎾ら攢绛惧埌!");
+//            }
             tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
             tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
             remarkService.deletedOrderRemarkByTjNum(tjNum);
             tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
             transitionService.deletedTbTransitionByTjNum(tjNum);
             transitionService.updateTbTransitionByTjNum(tjNum);
+            TjCustomer customer = tjCustomerService.getById(order.getUserId());
+            if(null !=customer){
+                customer.setCardId("0");
+                tjCustomerService.updateById(customer);
+            }
             String configByKey = configService.selectConfigByKey("sfkqdyhis");
             if (configByKey.equals("Y")){
                 HashMap<String, Object> map = new HashMap<>();

--
Gitblit v1.8.0