Browse Source

feature:营养餐对账

wuyongyi 2 years ago
parent
commit
78dabafc3e

+ 42 - 4
src/main/java/com/ywt/mg/services/MealOrderService.java

@@ -659,6 +659,8 @@ public class MealOrderService {
             ExcelDataMap map = new ExcelDataMap(columns);
             List<UserMealOrderView> userMealOrderViews = queryDownLoadMealOrderList(request);
 //        List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByMealOrderList(userMealOrderViews);
+            Map<String, Integer> statisticalDataMap = new HashMap<>();
+            int payTotal = 0, refundTotal = 0, rowSize = 0;
             List<MealOrderInfo> list = new ArrayList<>();
             if (!Checker.isNone(userMealOrderViews)) {
                 for (UserMealOrderView p : userMealOrderViews) {
@@ -770,9 +772,11 @@ public class MealOrderService {
                                 map.getStringListSafely(col3).add(paymentTimeStr);
                                 map.getStringListSafely(col4).add(orderNo);
                                 map.getStringListSafely(col5).add(typeName);
+                                rowSize++;
 //                            ExcelHelper.settingMainBodyLabelCell(sheet, cellFormat2, n, bodyStr);
 //                            n++;
 
+
                             }
                         }
                     }
@@ -807,16 +811,18 @@ public class MealOrderService {
                                 map.getStringListSafely(col3).add(refundTimeStr);
                                 map.getStringListSafely(col4).add(orderNo);
                                 map.getStringListSafely(col5).add(typeName);
+                                rowSize++;
                             }
                         }
                     }
 
                 }
             }
-            int size = list.size();
-            List<ExcelCollectPojo> itemList = new ArrayList<>();
-            int bill = 0;
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size, bill);
+
+
+            List<CustomExcelItem> itemList = getStatisticsData(userMealOrderViews, shopList);
+            downloadRecordService.createMealFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map,
+                     itemList, rowSize);
 
         } catch (Exception e) {
             logger.error("/mealOrder/downloadMealOrderBillsList(): {}", e.getMessage(), e);
@@ -831,4 +837,36 @@ public class MealOrderService {
         }
         return new ArrayList<>();
     }
+
+    private List<ExcelCollectPojo> getStatisticsData(int size, int payTotal, int refundTotal, Map<String, Integer> statisticalDataMap) {
+        int startRows = size + 3;
+        int startColumn = 0;
+
+        List<ExcelCollectPojo> customExcelItemList = new ArrayList<>();
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows + 1, new String[]{"支付总额", FormatUtil.intShrink100ToStr(payTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows + 1, new String[]{"退款总额", FormatUtil.intShrink100ToStr(refundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows + 1, new String[]{"实际支付总额", FormatUtil.intShrink100ToStr(payTotal - refundTotal)}));
+        PaymentChannelEnum[] paymentChannelList = PaymentChannelEnum.values();
+        startRows++;
+
+        if (!Checker.isNone(paymentChannelList)) {
+            for (int i = 0, j = paymentChannelList.length; i < j; i++) {
+                int paymentChannel = paymentChannelList[i].getValue();
+                if (paymentChannel <= 0) continue;
+                String paymentChannelName = paymentChannelList[i].getDisplayName();
+                String payKey = ConstantDef.PAY_KEY_PREFIX + paymentChannel;
+                String refundKey = ConstantDef.REFUND_KEY_PREFIX + paymentChannel;
+                // 按支付渠道统计
+                int payValue = statisticalDataMap.getOrDefault(payKey, 0);
+                int refundValue = statisticalDataMap.getOrDefault(refundKey, 0);
+                if (payValue > 0 || refundValue > 0) {
+                    startRows += 1;
+                    customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{paymentChannelName + "支付总额", FormatUtil.intShrink100ToStr(payValue)}));
+                    customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows , new String[]{paymentChannelName + "退款总额", FormatUtil.intShrink100ToStr(refundValue)}));
+                    customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows , new String[]{paymentChannelName + "实际支付总额", FormatUtil.intShrink100ToStr(payValue - refundValue)}));
+                }
+            }
+        }
+        return customExcelItemList;
+    }
 }

+ 7 - 0
src/main/java/com/ywt/mg/web/common/ExcelDownloadSrv.java

@@ -537,10 +537,17 @@ public class ExcelDownloadSrv {
                 }
                 // 最后一页,添加汇总,同时关闭流
                 if (currentSheetIndex == sheetAmount - 1) {
+                    int n = 0;
                     if (!Checker.isNone(collectList)) {
                         for (CustomExcelItem item : collectList) {
                             sheet.addCell(new Label(item.getColumn(), item.getRow() - sheetMaxSize * currentSheetIndex, item.getContent(), item.getCellFormat() == null ? cellFormat : item.getCellFormat()));
+                            n = item.getRow() - sheetMaxSize * currentSheetIndex;
                         }
+                        n = n + 1;
+                        Label labelRemark = new Label(1, n, "注意:如果需把excel表导入院内系统, 可按需把上面的“数据汇总表格”和“支付渠道列”删除并保存后,再导入", cellFormat);
+                        sheet.mergeCells(1, n, 6, n);
+                        sheet.addCell(labelRemark);
+
                     }
                     // 写入流
                     workbook.write();