From f8b23a28a212c4946c97f94c0540ed12f89c4e07 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期四, 16 五月 2024 08:55:02 +0800
Subject: [PATCH] zjh 2024/05/16-1

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java |  335 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 201 insertions(+), 134 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 0327b17..71b9fac 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
@@ -10,6 +10,7 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import cn.hutool.core.codec.Base64;
@@ -53,6 +54,7 @@
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpRequest;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -407,7 +409,7 @@
                     order.setTjCustomerSex(tjCustomer.getCusSex());
                     order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                     order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
-                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                    order.setTjCustomerName(tjCustomer.getCusName());
                     order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
 //                    order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
                     order.setTjCusIdCard(tjCustomer.getCusIdcard());
@@ -460,35 +462,39 @@
                 }
                 List<TjOrder> collect = null;
                 if (list.size() > 0) {
-                    for (TjOrder order : list) {
-                        TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
-                        if (null != tjCustomer) {
-                            order.setTjCustomerSex(tjCustomer.getCusSex());
-                            order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
-                            order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
-                            order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
-                            order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
+
+                    for (int i = 0; i < list.size(); i++) {
+                        TjCustomer tjCustomer = tjCustomerService.getById(list.get(i).getUserId());
+                        if (null == tjCustomer) {
+                            list.remove(list.get(i));
+                            continue;
                         }
-                        String firmId = order.getFirmId();
-                        if (firmId != null && null != iDictCompService.getById(String.valueOf(order.getFirmId()))) {
-                            order.setDictCompName(iDictCompService.getById(String.valueOf(order.getFirmId())).getCnName());
+                        list.get(i).setTjCustomerSex(tjCustomer.getCusSex());
+                        list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
+                        list.get(i).setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                        list.get(i).setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
+                        list.get(i).setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
+
+                        String firmId = list.get(i).getFirmId();
+                        if (firmId != null && null != iDictCompService.getById(String.valueOf(list.get(i).getFirmId()))) {
+                            list.get(i).setDictCompName(iDictCompService.getById(String.valueOf(list.get(i).getFirmId())).getCnName());
                         }
-                        if (null != order.getPacId()) {
-                            if (null != tjPackageService.getById(order.getPacId())) {
-                                order.setPacName(tjPackageService.getById(order.getPacId()).getPacName());
+                        if (null != list.get(i).getPacId()) {
+                            if (null != tjPackageService.getById(list.get(i).getPacId())) {
+                                list.get(i).setPacName(tjPackageService.getById(list.get(i).getPacId()).getPacName());
                             }
-                            if (null != dwDeptService.getById(order.getPacId())) {
-                                order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName());
+                            if (null != dwDeptService.getById(list.get(i).getPacId())) {
+                                list.get(i).setPacName(dwDeptService.getById(list.get(i).getPacId()).getDwDeptName());
                             }
                         }
                         //浠庢墦鍗拌褰曟煡鍑烘渶鏂版墦鍗版椂闂�
                         LambdaQueryWrapper<TjReportPrint> wqqq = new LambdaQueryWrapper<>();
-                        wqqq.eq(TjReportPrint::getTjNumber, order.getTjNumber());
+                        wqqq.eq(TjReportPrint::getTjNumber, list.get(i).getTjNumber());
                         wqqq.orderByDesc(TjReportPrint::getPrintTime);
                         wqqq.last("limit 1");
                         TjReportPrint one = tjReportPrintService.getOne(wqqq);
                         if (one != null) {
-                            order.setPrintLastTime(one.getPrintTime());
+                            list.get(i).setPrintLastTime(one.getPrintTime());
                         }
 
                     }
@@ -518,37 +524,40 @@
         Page<TjOrder> page2 = tjOrderService.page(page1, wq);
         List<TjOrder> list = page2.getRecords();
         if (list != null) {
-            for (TjOrder order : list) {
-                TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
-                if (null != tjCustomer) {
-                    order.setTjCustomerSex(tjCustomer.getCusSex());
-                    order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
-                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
-                    order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
-                    if (tjCustomer.getCusIdcard() != null) {
-                        order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
-                    }
+            for (int i = 0; i < list.size(); i++) {
+                TjCustomer tjCustomer = tjCustomerService.getById(list.get(i).getUserId());
+                if (null == tjCustomer) {
+                    list.remove(list.get(i));
+                    continue;
                 }
-                String firmId = order.getFirmId();
-                if (firmId != null && null != iDictCompService.getById(String.valueOf(order.getFirmId()))) {
-                    order.setDictCompName(iDictCompService.getById(String.valueOf(order.getFirmId())).getCnName());
+                list.get(i).setTjCustomerSex(tjCustomer.getCusSex());
+                list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
+                list.get(i).setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
+                list.get(i).setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
+                if (tjCustomer.getCusIdcard() != null) {
+                    list.get(i).setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
                 }
-                if (null != order.getPacId()) {
-                    if (null != tjPackageService.getById(order.getPacId())) {
-                        order.setPacName(tjPackageService.getById(order.getPacId()).getPacName());
+
+                String firmId = list.get(i).getFirmId();
+                if (firmId != null && null != iDictCompService.getById(String.valueOf(list.get(i).getFirmId()))) {
+                    list.get(i).setDictCompName(iDictCompService.getById(String.valueOf(list.get(i).getFirmId())).getCnName());
+                }
+                if (null != list.get(i).getPacId()) {
+                    if (null != tjPackageService.getById(list.get(i).getPacId())) {
+                        list.get(i).setPacName(tjPackageService.getById(list.get(i).getPacId()).getPacName());
                     }
-                    if (null != dwDeptService.getById(order.getPacId())) {
-                        order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName());
+                    if (null != dwDeptService.getById(list.get(i).getPacId())) {
+                        list.get(i).setPacName(dwDeptService.getById(list.get(i).getPacId()).getDwDeptName());
                     }
                 }
                 //浠庢墦鍗拌褰曟煡鍑烘渶鏂版墦鍗版椂闂�
                 LambdaQueryWrapper<TjReportPrint> wqqq = new LambdaQueryWrapper<>();
-                wqqq.eq(TjReportPrint::getTjNumber, order.getTjNumber());
+                wqqq.eq(TjReportPrint::getTjNumber, list.get(i).getTjNumber());
                 wqqq.orderByDesc(TjReportPrint::getPrintTime);
                 wqqq.last("limit 1");
                 TjReportPrint one = tjReportPrintService.getOne(wqqq);
                 if (one != null) {
-                    order.setPrintLastTime(one.getPrintTime());
+                    list.get(i).setPrintLastTime(one.getPrintTime());
                 }
             }
         }
@@ -810,12 +819,12 @@
         wqq.eq(TjOrder::getUserId, tjOrder.getUserId());
         wqq.eq(TjOrder::getCheckStatus, 0);
         wqq.isNull(TjOrder::getFinishTime);
-        if(!tjCustomer.getCardId().equals("0")){
-            wqq.eq(TjOrder::getCardId,tjCustomer.getCardId());
+        if (!tjCustomer.getCardId().equals("0")) {
+            wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
         }
         TjOrder order = tjOrderService.getOne(wqq);
         if (null != order) {
-            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(),tjCustomer.getCardId());
+            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
             return AjaxResult.error("涓嶅彲閲嶅鐧昏");
         }
         LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>();
@@ -839,7 +848,7 @@
             if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo());
             if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId());
             if (null != tjReservation.getTjCategory()) tjOrder.setTjCategory(tjReservation.getTjCategory());
-            if (null != tjReservation.getGroupingId()){
+            if (null != tjReservation.getGroupingId()) {
                 tjOrder.setGroupId(tjReservation.getGroupingId());
                 tjOrder.setFirmDeptId(tjReservation.getPacId());
             }
@@ -879,9 +888,9 @@
         tjOrder.setCardId(tjCustomer.getCardId());
         if (tjOrderService.save(tjOrder)) {
             //淇濆瓨鏀惰揣鍦板潃
-            if ("2".equals(tjOrder.getGetType())){
+            if ("2".equals(tjOrder.getGetType())) {
                 final TjReportGetAddress address = tjOrder.getAddAddress();
-                if (address!=null){
+                if (address != null) {
                     address.setTjNumber(tjNumber);
                     tjReportGetAddressService.save(address);
                 }
@@ -902,9 +911,9 @@
             //鏍规嵁閰嶇疆璋冨彇瀛樺偍杩囩▼ 灏嗕复鏃惰〃鏁版嵁瀛樺叆棰勭害琛�2023.12.12
             final String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData");
             final String isPay = configService.selectConfigByKey("isPay");
-            if ("Y".equals(getInfoFromSqlData)){
+            if ("Y".equals(getInfoFromSqlData)) {
                 LtkjMiddleHead middleHead = headService.getMiddleHeadByPartId(tjCustomer.getCardId());
-                if(null !=middleHead){
+                if (null != middleHead) {
                     tjFlowingWater.setPayStasus(1L);
                 }
             }
@@ -912,7 +921,13 @@
             Date date1 = new Date(System.currentTimeMillis());
             String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
             tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
-            if(isPay.equals("true")){
+
+
+            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
+            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
+            tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
+
+            if (isPay.equals("true")) {
                 if (null != mallOrder) {
                     if (mallOrder.getOrderStatus().equals(201L)) {
                         tjFlowingWater.setCopeWith(mallOrder.getActualPrice());
@@ -933,7 +948,8 @@
                         mallOrder.setOrderStatus(301L);
                         mallOrderService.updateById(mallOrder);
                     }
-                } else {
+                }
+                else {
                     tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
                     tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
                     tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
@@ -943,17 +959,16 @@
             if (tjFlowingWaterService.save(tjFlowingWater)) {
                 tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                 tjOrderService.updateById(tjOrder);
+
+
             }
 
             //鍥綋
             if ("1".equals(tjOrder.getTjType())) {
                 asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
             }
-
-
             //涓汉
             if ("2".equals(tjOrder.getTjType())) {
-
                 //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                 newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
             }
@@ -1045,32 +1060,36 @@
             proIds = JSON.parseArray(proIds1.toString(), Long.class);
         }
         TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusId);
-        String cardId ="0";
-        if(null !=tjCustomer){
-             cardId = tjCustomer.getCardId();
+        String cardId = "0";
+        if (null != tjCustomer) {
+            cardId = tjCustomer.getCardId();
         }
         if ((null == proIds || proIds.size() == 0) && (null == packId || packId.equals(""))) {
             transitionService.deletedTbTransitionByCusId(cusId);
-            if (redisCache.hasKey(cusId)) redisCache.deleteObject(cusId);
-            if (redisCache.hasKey(cardId+cusId + "cusId")) redisCache.deleteCacheMapValue(cardId+cusId + "cusId", cardId+cusId);
-
+            if (redisCache.hasKey(cardId + cusId)) {
+                redisCache.deleteObject(cardId + cusId);
+            }
+            if (redisCache.hasKey(cardId + cusId + "cusId")) {
+                redisCache.deleteCacheMapValue(cardId + cusId + "cusId", cardId + cusId);
+            }
         }
         List<TbTransition> tbTransitionList = null;
-        if (!redisCache.hasKey(cardId+cusId)) {
+        if (!redisCache.hasKey(cardId + cusId)) {
             tbTransitionList = new ArrayList<>();
         } else {
-            tbTransitionList = redisCache.getCacheList(cardId+cusId);
+            tbTransitionList = redisCache.getCacheList(cardId + cusId);
         }
         //濂楅
         if (null != packId && !packId.equals("")) {
             Long pacId = Long.valueOf(packId.toString());
             List<TbTransition> list = transitionService.getTbTransitionListByCusIdAndPac(cusId, String.valueOf(pacId));
             if (null == list || list.size() == 0) {
-                transitionService.deletedTbTransitionListByCusIdAndPac(cusId,cardId);
-                if (redisCache.hasKey(cardId+cusId + "cusId")) redisCache.deleteCacheMapValue(cardId+cusId + "cusId", cardId+cusId);
-                if (redisCache.hasKey(cardId+cusId)) {
+                transitionService.deletedTbTransitionListByCusIdAndPac(cusId, cardId);
+                if (redisCache.hasKey(cardId + cusId + "cusId"))
+                    redisCache.deleteCacheMapValue(cardId + cusId + "cusId", cardId + cusId);
+                if (redisCache.hasKey(cardId + cusId)) {
                     tbTransitionList = new ArrayList<>();
-                    redisCache.deleteObject(cardId+cusId);
+                    redisCache.deleteObject(cardId + cusId);
                 }
                 List<TjPackageProject> ppList = tjPackageProjectService.getTjPackageProjectListByPacId(String.valueOf(pacId));
                 if (null != ppList && ppList.size() > 0) {
@@ -1080,7 +1099,13 @@
                     for (TjPackageProject tjPackageProject : ppList) {
                         TjProject project = projectService.getTjProjectById(String.valueOf(tjPackageProject.getProId()));
                         if (null != project) {
-                            BigDecimal divide = tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
+
+                            BigDecimal divide = BigDecimal.valueOf(0);
+                            if(tjPackageProject.getPriceNow().compareTo(BigDecimal.valueOf(0))==0 || project.getProPrice().compareTo(BigDecimal.valueOf(0))==0 ){
+                                divide=BigDecimal.valueOf(0);
+                            }else {
+                                divide=tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
+                            }
                             List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
                             if (null != tjProSonList && tjProSonList.size() > 0) {
                                 //addRedisTransitionPac(cusId, tbTransitionList, pacId, tjPackageProject, project, divide, tjProSonList);
@@ -1143,7 +1168,7 @@
                     tbTransition.setParentProId(tjProject.getProParentId());
                     if (tjProject.getProParentId() != null) {
                         TjProject byId = projectService.getById(tjProject.getProParentId());
-                        if(null !=byId){
+                        if (null != byId) {
                             tbTransition.setParentProName(byId.getProName());
                         }
                     }
@@ -1159,14 +1184,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));
+            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));
+                redisCache.setCacheList(cardId + cusId, tbTransitionList);
+                redisCache.setCacheMapValue(cardId + cusId + "cusId", cardId + cusId, getMaps(cusId, cardId));
             }
         }
         return AjaxResult.success();
@@ -1181,11 +1208,11 @@
             return AjaxResult.success(list);
         }
         TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusId);
-        String cardId ="0";
-        if(null !=tjCustomer){
+        String cardId = "0";
+        if (null != tjCustomer) {
             cardId = tjCustomer.getCardId();
         }
-        List<Map<String, Object>> list = getMaps(cusId,cardId);
+        List<Map<String, Object>> list = getMaps(cusId, cardId);
         return AjaxResult.success(list);
     }
 
@@ -1318,9 +1345,9 @@
             for (TjOrderRemark remark : remarkList) {
                 TjProject project = projectService.getTjProjectById(String.valueOf(remark.getProId()));
                 if (null != project) {
-                    if ("N".equals(project.getNeedReport())){
-                        continue;
-                    }
+//                    if ("N".equals(project.getNeedReport())) {
+//                        continue;
+//                    }
                     remark.setProCheckType(project.getProCheckType());
                     remark.setProName(project.getProName());
                 }
@@ -1402,19 +1429,20 @@
         if (!handleOption.isCanship()) {
             return AjaxResult.error("璁㈠崟涓嶈兘鏍搁攢");
         }
+        Date date = new Date();
         order.setOrderStatus(OrderUtil.STATUS_SHIP.longValue());
-        order.setShipTime(new Date());
-        order.setConfirmTime(new Date());
+        order.setShipTime(date);
+        order.setConfirmTime(date);
 
         MallCheckLog checkLog = new MallCheckLog();
-        String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date());
+        String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date);
         checkLog.setCheckBy(String.valueOf(SecurityUtils.getUserId()));
         checkLog.setUserId(order.getUserId());
         checkLog.setConsignee(order.getConsignee());
         checkLog.setIdCard(order.getIdCard());
         checkLog.setOrderId(String.valueOf(order.getId()));
         checkLog.setOrderSn(order.getOrderSn());
-        checkLog.setCheckTime(new Date());
+        checkLog.setCheckTime(date);
         checkLog.setShipSn("HX" + s1);
         mallCheckLogService.save(checkLog);
         mallOrderService.updateById(order);
@@ -1422,14 +1450,14 @@
     }
 
 
-    private List<Map<String, Object>> getMaps(String cusId,String cardId) {
+    private List<Map<String, Object>> getMaps(String cusId, String cardId) {
 
         List<TbTransition> transitionList = null;
-        if (redisCache.hasKey(cardId+cusId)) {
-            transitionList = redisCache.getCacheList(cardId+cusId);
-        } else {
-            transitionList = transitionService.getTbTransitionListByCusId(cusId,cardId);
-        }
+//        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));
         List<Map<String, Object>> list = new ArrayList<>();
@@ -1439,35 +1467,32 @@
             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<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());
-//                    if (tbTransition.getOrdPrice().compareTo(BigDecimal.valueOf(0)) == 0 || tbTransition.getNowPrice().compareTo(BigDecimal.valueOf(0)) == 0) {
-//                        tbTransition.setDiscount("0");
-//                    } else {
-//                        tbTransition.setDiscount((tbTransition.getNowPrice()).divide(tbTransition.getOrdPrice(), BigDecimal.ROUND_CEILING).toString());
-//                    }
-//                    if (null != tbTransition.getPacId()) {
-//                        tbTransition.setPacPrice(tjPackageService.getById(tbTransition.getPacId()).getPrice());
-//                    }
-//                    if (null != tbTransition.getParentProId()) {
-//                        tbTransition.setPacPrice(projectService.getTjProjectById(String.valueOf(tbTransition.getParentProId())).getProPrice());
-//                    }
-                }
-//                map.put("ordPrice", money1.setScale(Integer.parseInt(configService.selectConfigByKey("sys.price.save")), Integer.parseInt(configService.selectConfigByKey("sys.price"))));
-//                map.put("nowPrice", money2.setScale(Integer.parseInt(configService.selectConfigByKey("sys.price.save")), Integer.parseInt(configService.selectConfigByKey("sys.price"))));
-                map.put("ordPrice", money1);
-                map.put("nowPrice", money2);
-            }
             list.add(map);
         }
         return list;
@@ -1687,8 +1712,9 @@
     public void newSaveextracted(TjOrder tjOrder, TjCustomer tjCustomer, BigDecimal discount, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) {
         tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
         tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
+        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
         //淇敼姣忛」鐨勫師浠风幇浠� //淇敼涓存椂琛ㄤ綋妫�鍙�
-        transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount,tjOrder.getTjNumber());
+        transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount, tjOrder.getTjNumber());
         //娣诲姞remark琛ㄦ暟鎹�
         remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
         //鍒ゆ柇鏄惁浜ら挶
@@ -1701,6 +1727,11 @@
         if (tjFlowingWater.getPayStasus() == 1L) {
             tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                     sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
+            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
+            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
+            tjFlowingWater.setPayType(4L);
+            tjFlowingWaterService.updateById(tjFlowingWater);
+            asyncService.addTjChargingStandard(tjOrder, transitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(), tjOrder.getCardId()), sysUser);
         }
 //        System.out.println("杩欐浠g爜鏃堕棿" + (System.currentTimeMillis() - l));
     }
@@ -1716,7 +1747,7 @@
             byId.setHeshouDoctor(UserHoder.getLoginUser().getUserId());
             byId.setHeshouTime(new DateTime());
             final boolean b = tjOrderService.updateById(byId);
-            if (!b){
+            if (!b) {
                 return AjaxResult.error("鏍告敹澶辫触");
             }
         }
@@ -1728,11 +1759,11 @@
     @Transactional
     public AjaxResult getHistryTjOrderByCusIdCard(@RequestParam String cusIdCard) {
         TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdCard);
-        List<HistoryTjOrder> list=new ArrayList<>();
-        if(null !=tjCustomer){
+        List<HistoryTjOrder> list = new ArrayList<>();
+        if (null != tjCustomer) {
             List<TjOrder> orderList = tjOrderService.getTjOrderListByCusId(tjCustomer.getCusId());
             for (TjOrder order : orderList) {
-                HistoryTjOrder historyTjOrder=new HistoryTjOrder();
+                HistoryTjOrder historyTjOrder = new HistoryTjOrder();
                 historyTjOrder.setUserName(tjCustomer.getCusName());
                 historyTjOrder.setTjNum(order.getTjNumber());
                 historyTjOrder.setTjTime(order.getCreateTime());
@@ -1749,48 +1780,48 @@
     @Transactional
     public AjaxResult getHistryTjOrderProByCusIdCard(@RequestParam String cusIdCard) {
         TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(cusIdCard);
-        if(null !=tjCustomer){
-            TjOrder order= tjOrderService.getLastTjOrderListByCusId(tjCustomer.getCusId());
-            if(null !=order){
+        if (null != tjCustomer) {
+            TjOrder order = tjOrderService.getLastTjOrderListByCusId(tjCustomer.getCusId());
+            if (null != order) {
                 List<Map<String, Object>> list = new ArrayList<>();
-                if(order.getPacId().equals("o")){
+                if (order.getPacId().equals("o")) {
                     List<Long> longList = remarkService.getTjProIdsByTjNum(order.getTjNumber());
                     for (Long aLong : longList) {
                         Map<String, Object> map = new HashMap<>();
                         map.put("pacName", "鍗曢」");
-                        map.put("proId",aLong);
-                        map.put("pacId",null);
+                        map.put("proId", aLong);
+                        map.put("pacId", null);
                         map.put("parentName", projectService.getById(aLong).getProName());
-                        map.put("list",projectService.getTjProjectListBySoneId(String.valueOf(aLong)));
+                        map.put("list", projectService.getTjProjectListBySoneId(String.valueOf(aLong)));
                         BigDecimal proPrice = projectService.getById(aLong).getProPrice();
                         map.put("ordPrice", proPrice);
                         map.put("nowPrice", proPrice);
                         list.add(map);
                     }
                 }
-                if(!order.getPacId().equals("o")){
-                    List<Long> longList = remarkService.getTjProIdsByTjNumAndPacIc(order.getTjNumber(),order.getPacId());
+                if (!order.getPacId().equals("o")) {
+                    List<Long> longList = remarkService.getTjProIdsByTjNumAndPacIc(order.getTjNumber(), order.getPacId());
                     TjPackage aPackage = tjPackageService.getById(order.getPacId());
                     for (Long aLong : longList) {
                         Map<String, Object> map = new HashMap<>();
-                        map.put("pacName",aPackage.getPacName());
-                        map.put("pacId",String.valueOf(aPackage.getPacId()));
+                        map.put("pacName", aPackage.getPacName());
+                        map.put("pacId", String.valueOf(aPackage.getPacId()));
                         map.put("parentName", projectService.getById(aLong).getProName());
-                        map.put("list",projectService.getTjProjectListBySoneId(String.valueOf(aLong)));
+                        map.put("list", projectService.getTjProjectListBySoneId(String.valueOf(aLong)));
                         BigDecimal proPrice = projectService.getById(aLong).getProPrice();
                         map.put("ordPrice", proPrice);
-                        map.put("nowPrice",tjPackageProjectService.getPacProPriceByPacIdAndPro(aLong,order.getPacId()));
+                        map.put("nowPrice", tjPackageProjectService.getPacProPriceByPacIdAndPro(aLong, order.getPacId()));
                         list.add(map);
                     }
 
-                    List<Long> longList1 = remarkService.getTjProIdsByTjNumAndPacIc(order.getTjNumber(),order.getPacId());
+                    List<Long> longList1 = remarkService.getTjProIdsByTjNumAndPacIc(order.getTjNumber(), order.getPacId());
                     for (Long aLong : longList1) {
                         Map<String, Object> map = new HashMap<>();
                         map.put("pacName", "鍗曢」");
-                        map.put("proId",aLong);
-                        map.put("pacId",null);
+                        map.put("proId", aLong);
+                        map.put("pacId", null);
                         map.put("parentName", projectService.getById(aLong).getProName());
-                        map.put("list",projectService.getTjProjectListBySoneId(String.valueOf(aLong)));
+                        map.put("list", projectService.getTjProjectListBySoneId(String.valueOf(aLong)));
                         BigDecimal proPrice = projectService.getById(aLong).getProPrice();
                         map.put("ordPrice", proPrice);
                         map.put("nowPrice", proPrice);
@@ -1803,4 +1834,40 @@
         return AjaxResult.success("鏆傛棤鍘嗗彶璁板綍");
     }
 
+
+    @GetMapping("/getHistryTjOrderByCusId")
+    @ApiOperation(value = "鏍规嵁瀹㈡埛id鏌ョ湅鍘嗗彶浣撴璁板綍")
+    @Transactional
+    public AjaxResult getHistryTjOrderByCusId(@RequestParam String cusId) {
+        TjCustomer tjCustomer = tjCustomerService.getById(cusId);
+        List<HistoryTjOrder> list = new ArrayList<>();
+        if (null != tjCustomer) {
+            List<TjOrder> orderList = tjOrderService.getTjOrderListByCusId(tjCustomer.getCusId());
+            for (TjOrder order : orderList) {
+                HistoryTjOrder historyTjOrder = new HistoryTjOrder();
+                historyTjOrder.setUserName(tjCustomer.getCusName());
+                historyTjOrder.setTjNum(order.getTjNumber());
+                historyTjOrder.setTjTime(order.getCreateTime());
+                historyTjOrder.setTjProName(tjOrderService.getHistoryTjOrderProByTjNum(order.getTjNumber()));
+
+                //鏌ユ祦姘�
+                BigDecimal res = new BigDecimal(0);
+                LambdaQueryWrapper<TjFlowingWater> wqq = new LambdaQueryWrapper<>();
+                wqq.eq(TjFlowingWater::getOrderId, order.getOrderId());
+                final List<TjFlowingWater> list1 = tjFlowingWaterService.list(wqq);
+                if (list1 != null) {
+                    for (TjFlowingWater tjFlowingWater : list1) {
+                        if (tjFlowingWater!=null && tjFlowingWater.getPaidIn()!=null){
+                            res.add(tjFlowingWater.getPaidIn());
+                        }
+                    }
+                }
+                historyTjOrder.setPaidIn(res);
+                list.add(historyTjOrder);
+            }
+        }
+        return AjaxResult.success(list);
+    }
+
 }
+

--
Gitblit v1.8.0