|
@@ -15,7 +15,6 @@ import com.ywt.mg.domain.models.ExcelDataMap;
|
|
|
import com.ywt.mg.domain.models.enums.*;
|
|
|
import com.ywt.mg.domain.models.nutrimeal.MealOrderInfo;
|
|
|
import com.ywt.mg.domain.models.pojo.CustomExcelItem;
|
|
|
-import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
|
|
|
import com.ywt.mg.params.mealOrder.MealOrderListRequest;
|
|
|
import com.ywt.mg.web.common.ExcelDownloadSrvOld;
|
|
|
import org.slf4j.Logger;
|
|
@@ -412,9 +411,10 @@ public class MealOrderService {
|
|
|
int size = userMealOrderViews.size();
|
|
|
// List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal);
|
|
|
// downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
|
|
|
+ int bill = 0;
|
|
|
List<CustomExcelItem> itemList = getStatisticsData(userMealOrderViews, shopList);
|
|
|
downloadRecordService.createMealFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map,
|
|
|
- needStat ? itemList : null, size);
|
|
|
+ needStat ? itemList : null, size, bill);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
logger.error("/mealOrder/downloadMealOrderList(): {}", e.getMessage(), e);
|
|
@@ -822,10 +822,10 @@ public class MealOrderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- List<CustomExcelItem> itemList = getStatisticsData(userMealOrderViews, shopList);
|
|
|
+ int bill = 1;
|
|
|
+ List<CustomExcelItem> itemList = getStatisticsBillData(userMealOrderViews, rowSize);
|
|
|
downloadRecordService.createMealFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map,
|
|
|
- itemList, rowSize);
|
|
|
+ itemList, rowSize, bill);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
logger.error("/mealOrder/downloadMealOrderBillsList(): {}", e.getMessage(), e);
|
|
@@ -841,35 +841,183 @@ 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)}));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ private List<CustomExcelItem> getStatisticsBillData(List<UserMealOrderView> orders, int startRows) {
|
|
|
+ startRows = startRows + 3;
|
|
|
+
|
|
|
+ int startColumn = 3;
|
|
|
+ List<CustomExcelItem> customExcelItemList = new ArrayList<>();
|
|
|
+ // 按店铺统计
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ 4、总成本=微信点单成本+金币点单成本+现场点单成本(也等于各个菜品成本价乘以份数的相加的总额) ;
|
|
|
+ 5、微信点单成本:支付方式是”微信支付“的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单) ;
|
|
|
+ 金币点单成本:支付方式是”微信+金币“的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单) ;
|
|
|
+ 现场点单成本:支付方式是”现场支付“的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单) ;*/
|
|
|
+
|
|
|
+ List<UserMealOrderView> wechatSinglePointCostList = orders.stream()
|
|
|
+ .filter(p -> p.getPayType() == OrderPayTypeEnum.WECHAT.getValue()
|
|
|
+ && RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(p.getRefundStatus()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ int wechatSinglePointCostInt = orderDishService.getAllDishCostPriceSumByUserMealOrderViewList(wechatSinglePointCostList);
|
|
|
+ List<UserMealOrderView> coinSinglePointCostList = orders.stream()
|
|
|
+ .filter(p -> p.getPayType() == OrderPayTypeEnum.COIN.getValue()
|
|
|
+ && RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(p.getRefundStatus()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ int coinSinglePointCostInt = orderDishService.getAllDishCostPriceSumByUserMealOrderViewList(coinSinglePointCostList);
|
|
|
+ List<UserMealOrderView> p2fSinglePointCostList = orders.stream()
|
|
|
+ .filter(p -> p.getPayType() == OrderPayTypeEnum.F2F.getValue()
|
|
|
+ && RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(p.getRefundStatus()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ int p2fSinglePointCostInt = orderDishService.getAllDishCostPriceSumByUserMealOrderViewList(p2fSinglePointCostList);
|
|
|
+ String wechatSinglePointCost = FormatUtil.intShrink100ToStr(wechatSinglePointCostInt);
|
|
|
+ String coinSinglePointCost = FormatUtil.intShrink100ToStr(coinSinglePointCostInt);
|
|
|
+ String p2fSinglePointCost = FormatUtil.intShrink100ToStr(p2fSinglePointCostInt);
|
|
|
+ String allCost = FormatUtil.intShrink100ToStr(wechatSinglePointCostInt + coinSinglePointCostInt + p2fSinglePointCostInt);
|
|
|
+
|
|
|
+ // 总计
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "退款总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "实际支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+// customExcelItemList.add(new CustomExcelItem(startColumn + 7, startRows, "总成本", null));
|
|
|
+// customExcelItemList.add(new CustomExcelItem(startColumn + 8, startRows, allCost, null));
|
|
|
+ startRows += 1;
|
|
|
+ // 微信支付
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "微信支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getWechatPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "微信退款总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getWechatPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "微信实际支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getWechatPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+// customExcelItemList.add(new CustomExcelItem(startColumn + 7, startRows, "微信点单成本", null));
|
|
|
+// customExcelItemList.add(new CustomExcelItem(startColumn + 8, startRows, wechatSinglePointCost, null));
|
|
|
+ startRows += 1;
|
|
|
+ // 金币支付
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "金币支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getCoinPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "金币退款总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getCoinPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "金币实际支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getCoinPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+// customExcelItemList.add(new CustomExcelItem(startColumn + 7, startRows, "金币点单成本", null));
|
|
|
+// customExcelItemList.add(new CustomExcelItem(startColumn + 8, startRows, coinSinglePointCost, null));
|
|
|
+ startRows += 1;
|
|
|
+ // 现场支付
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "现场支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getF2fPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "现场退款总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getF2fPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "现场实际支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getF2fPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+// customExcelItemList.add(new CustomExcelItem(startColumn + 7, startRows, "现场点单成本", null));
|
|
|
+// customExcelItemList.add(new CustomExcelItem(startColumn + 8, startRows, p2fSinglePointCost, null));
|
|
|
+ startRows += 1;
|
|
|
+ // 洗碗费
|
|
|
+ // 目前只计算有金币支付的订单,不包括纯微信支付及现场支付订单。计算的规则是符合条件的订单的微信支付金额总和。
|
|
|
+ // 等同这个 SQL 语句:
|
|
|
+ // select sum(wechat_pay_amount) from nutrimeal.meal_order where deleted = 0 and pay_type = 4 and (refund_status is null or refund_status != 1) and wechat_pay_amount is not null ;
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "2元洗碗费总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> OrderPayTypeEnum.COIN.getValue() == Checker.getIntegerValue(v.getPayType()) &&
|
|
|
+ RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getWechatPayAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ startRows += 2;
|
|
|
+ // v1.3.1_nfyybyfy 新增职工统计
|
|
|
+ // 职工支付
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "职工支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> Checker.getIntegerValue(v.getStaffId()) > 0)
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "退款总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> Checker.getIntegerValue(v.getStaffId()) > 0)
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "实际支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> Checker.getIntegerValue(v.getStaffId()) > 0)
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ startRows += 1;
|
|
|
+ // 非职工支付
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "非职工支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> Checker.getIntegerValue(v.getStaffId()) <= 0)
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "退款总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> Checker.getIntegerValue(v.getStaffId()) <= 0)
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "实际支付总额", null));
|
|
|
+ customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
|
|
|
+ FormatUtil.intShrink100ToStr(orders.stream()
|
|
|
+ .filter(v -> Checker.getIntegerValue(v.getStaffId()) <= 0)
|
|
|
+ .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
|
|
|
+ .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
|
|
|
+ .sum()), null));
|
|
|
+ startRows += 2;
|
|
|
+
|
|
|
+
|
|
|
return customExcelItemList;
|
|
|
}
|
|
|
}
|