Przeglądaj źródła

Merge branch 'master' of zcb/kmall-pt-general into master

张创标 4 lat temu
rodzic
commit
07d336ba4e

+ 234 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/ExportExcelController.java

@@ -0,0 +1,234 @@
+package com.kmall.admin.controller;
+
+import com.kmall.admin.dto.ExportExcelDto;
+import com.kmall.admin.dto.TaxDetailDto;
+import com.kmall.admin.entity.OrderEntity;
+import com.kmall.admin.service.OrderService;
+import com.kmall.admin.service.SalesDataUploadService;
+import com.kmall.admin.utils.ParamUtils;
+import com.kmall.common.constant.Dict;
+import com.kmall.common.utils.DateUtils;
+import com.kmall.common.utils.R;
+import com.kmall.common.utils.excel.ExcelExport;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author zhangchuangbiao
+ * @version 1.0
+ * 2020-12-22 13:59
+ */
+@RestController
+@RequestMapping("exportExcel")
+public class ExportExcelController {
+    private static String  ISO = "iso-8859-1";
+    private static String  UTF = "utf-8";
+    private static final Logger LOGGER = LoggerFactory.getLogger(ExportExcelController.class);
+
+    @Autowired
+    private OrderService orderService;
+    @Autowired
+    private SalesDataUploadService salesDataUploadService;
+
+
+
+    @RequestMapping(value = "/exportSalesExcel")
+    public R exportOffilineOrder(@RequestParam Map<String, Object> params, HttpServletResponse response, HttpServletRequest request) throws ParseException {
+        ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
+
+        // 账单日期
+        String billDate = (String) params.get("billDate");
+        params = ParamUtils.setTimeMap(params);
+
+        try {
+            billDate = new String(billDate.getBytes(ISO), UTF);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        billDate = DateUtils.getDate(billDate);
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date sDate = sdf.parse(billDate);
+
+        Calendar c = Calendar.getInstance();
+        c.setTime(sDate);
+        c.add(Calendar.DAY_OF_MONTH, 1);//利用Calendar 实现 Date日期+1天
+        sDate = c.getTime();
+        // 汇总日期
+        String summaryDate = sdf.format(sDate);
+
+
+
+        params.put("isOnfiilineOrder", Dict.isOnfflineOrder.item_1.getItem());
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+        ExcelExport ee = new ExcelExport("CW保税 新零售销售额统计_"+format.format(new Date()));
+
+        // ==================================第一个sheet-销售总额===============================================
+        ExportExcelDto exportExcelDto = orderService.querySumAmount(billDate,"");
+
+
+        Map<String,String> firstSheetFirstRowValue = new HashMap<>();
+//        "汇总日期","账单日期","销售含税总额","当期退T-1日前金额","销售含税净额","销售税前总额","税款总额","当期退T-1日前税款","当期税款金额","成功订单数"
+        firstSheetFirstRowValue.put("汇总日期",summaryDate); // 汇总日期
+        firstSheetFirstRowValue.put("账单日期",billDate); // 账单日期
+        firstSheetFirstRowValue.put("销售含税总额",exportExcelDto.getTotalAmount()); // 销售含税总额
+        firstSheetFirstRowValue.put("当期退T-1日前金额",exportExcelDto.getRefundPreviousAmount()); // 当期退T-1日前金额
+        firstSheetFirstRowValue.put("销售含税净额",exportExcelDto.getNetAmount()); // 销售含税净额
+        firstSheetFirstRowValue.put("销售税前总额",exportExcelDto.getPreTaxTotalAmount()); // 销售税前总额
+        firstSheetFirstRowValue.put("税款总额",exportExcelDto.getTotalTax()); // 税款总额
+        firstSheetFirstRowValue.put("当期退T-1日前税款",exportExcelDto.getPreviousTax()); // 当前退T-1日前税款
+        firstSheetFirstRowValue.put("当期税款金额",exportExcelDto.getCurrentTax()); // 当期税款金额
+        firstSheetFirstRowValue.put("成功订单数",exportExcelDto.getSuccessNumber()); // 成功订单数
+
+        Map<String,String> firstSheetSecondRowValue = new HashMap<>();
+//        "汇总日期","账单日期","当期退当天金额(销售总额已减扣)","当期退当天订单数","退T-1日前订单总额(销售总额已减扣)","退T-1日前订单总数","当期退单总额(销售总额已减扣)","当日退款总单数"
+        firstSheetSecondRowValue.put("汇总日期",summaryDate); // 汇总日期
+        firstSheetSecondRowValue.put("账单日期",billDate); // 账单日期
+        firstSheetSecondRowValue.put("当期退当天金额(销售总额已减扣)",exportExcelDto.getRefundCurrentAmount()); // 当期退当天金额(销售总额已减扣)
+        firstSheetSecondRowValue.put("当期退当天订单数",exportExcelDto.getRefundCurrentCount()); // 当期退当天订单数
+        firstSheetSecondRowValue.put("退T-1日前订单总额(销售总额已减扣)",exportExcelDto.getRefundPreviousAmount()); // 退T-1日前订单总额(销售总额已减扣)
+        firstSheetSecondRowValue.put("退T-1日前订单总数",exportExcelDto.getRefundPreviousCount()); // 退T-1日前订单总数
+        firstSheetSecondRowValue.put("当期退单总额(销售总额已减扣)",exportExcelDto.getRefundAmount()); // 当期退单总额(销售总额已减扣)
+        firstSheetSecondRowValue.put("当日退款总单数",exportExcelDto.getRefundCount()); // 当日退款总单数
+
+
+
+        // ==================================第二个sheet-销售订单金额===========================================
+        String[] saleHeader = new String[]{"订单编号", "操作店员", "购买类型", "订单业务类型", "订单状态",
+                "付款状态",  "实际支付", "订单总价","下单时间", "付款时间", "退T-1日前订单金额", "T-1日前订单生成时间"};
+        Map<String,List<OrderEntity>> orderEntityListMap = orderService.querySaleOrderList(billDate,"");
+        // 当期的订单
+        List<OrderEntity> orderEntityList = orderEntityListMap.get("current");
+        List<Map<String, Object>> list = new LinkedList<>();
+        if (orderEntityList != null && orderEntityList.size() > 0) {
+            for (OrderEntity orderEntity :  orderEntityList) {
+
+                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
+                // 订单业务类型
+                String orderBizType = orderEntity.getOrderBizType();
+                // 订单状态
+                Integer orderStatus = orderEntity.getOrderStatus();
+                // 付款状态
+                Integer payStatus = orderEntity.getPayStatus();
+
+                map.put("订单编号", orderEntity.getOrderSn());
+                map.put("操作店员", orderEntity.getUserName());
+                map.put("购买类型", Dict.isOnfflineOrder.item_1.getItem().equals(orderEntity.getIsOnfflineOrder()) ? "线下购买" : "线上购买");
+                map.put("订单业务类型", StringUtils.isEmpty(orderBizType)?"":Dict.orderBizType.valueOf("item_"+orderBizType).getItemName());
+                map.put("订单状态", Dict.orderStatus.valueOf("item_"+orderStatus).getItemName());
+                map.put("付款状态", Dict.payStatus.valueOf("item_"+payStatus).getItemName());
+                map.put("实际支付", orderEntity.getActualPrice());
+                map.put("订单总价", orderEntity.getOrderPrice());
+                map.put("下单时间", orderEntity.getAddTime());
+                map.put("付款时间", orderEntity.getPayTime());
+                map.put("退T-1日前订单金额", orderEntity.getPayTime());
+                map.put("T-1日前订单生成时间", orderEntity.getPayTime());
+
+                list.add(map);
+            }
+        }
+        // 前期的订单
+        List<OrderEntity> previousList = orderEntityListMap.get("previous");
+        if (previousList != null && previousList.size() > 0) {
+            for (OrderEntity orderEntity :  previousList) {
+
+                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
+                // 订单业务类型
+                String orderBizType = orderEntity.getOrderBizType();
+                // 订单状态
+                Integer orderStatus = orderEntity.getOrderStatus();
+                // 付款状态
+                Integer payStatus = orderEntity.getPayStatus();
+
+                map.put("订单编号", orderEntity.getOrderSn());
+                map.put("操作店员", orderEntity.getUserName());
+                map.put("购买类型", Dict.isOnfflineOrder.item_1.getItem().equals(orderEntity.getIsOnfflineOrder()) ? "线下购买" : "线上购买");
+                map.put("订单业务类型", StringUtils.isEmpty(orderBizType)?"":Dict.orderBizType.valueOf("item_"+orderBizType).getItemName());
+                map.put("订单状态", Dict.orderStatus.valueOf("item_"+orderStatus).getItemName());
+                map.put("付款状态", Dict.payStatus.valueOf("item_"+payStatus).getItemName());
+                map.put("实际支付", orderEntity.getActualPrice());
+                map.put("订单总价", orderEntity.getOrderPrice());
+                map.put("下单时间", "");
+                map.put("付款时间", "");
+                map.put("退T-1日前订单金额", orderEntity.getActualPrice());
+                map.put("T-1日前订单生成时间", orderEntity.getPayTime());
+
+                list.add(map);
+            }
+        }
+
+
+        // ==================================第三个sheet-订单税款明细===========================================
+        String[] taxDetailHeader = new String[]{"订单编号", "门店编号", "门店名称", "商品编码", "完税总价格",
+                "进口增值税率(%)", "进口从价消费税率(%)", "应征增值税", "应征消费税", "总税额",
+                "税单接收时间","退T-1日前应征增值税","退T-1日前应征消费税","退T-1日前总税额","T-1日前生成时间"};
+        Map<String,List<TaxDetailDto>> TaxDetailEntityListMap = orderService.queryTaxDetailList(billDate,"");
+        List<Map<String,Object>> taxList = new LinkedList<>();
+        // 获取当前税率
+        List<TaxDetailDto> current = TaxDetailEntityListMap.get("current");
+        if (current != null && current.size() > 0) {
+
+            for (TaxDetailDto taxDetailDto : current) {
+                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
+
+                map.put("订单编号", taxDetailDto.getOrderSn());
+                map.put("门店编号", taxDetailDto.getStoreSn());
+                map.put("门店名称", taxDetailDto.getStoreName());
+                map.put("商品编码", taxDetailDto.getSku());
+                map.put("完税总价格", taxDetailDto.getPretaxPrice());
+                map.put("进口增值税率(%)", taxDetailDto.getVatRate());
+                map.put("进口从价消费税率(%)", taxDetailDto.getSaleTaxRate());
+                map.put("应征增值税", taxDetailDto.getVat());
+                map.put("应征消费税", taxDetailDto.getSaleTax());
+                map.put("总税额", taxDetailDto.getTax());
+                map.put("税单接收时间", taxDetailDto.getReceiveTaxTime());
+                taxList.add(map);
+            }
+        }
+
+        List<TaxDetailDto> previous = TaxDetailEntityListMap.get("previous");
+        if (previous != null && previous.size() > 0) {
+
+            for (TaxDetailDto taxDetailDto : previous) {
+                LinkedHashMap<String, Object> map = new LinkedHashMap<>();
+
+                map.put("订单编号", taxDetailDto.getOrderSn());
+                map.put("门店编号", taxDetailDto.getStoreSn());
+                map.put("门店名称", taxDetailDto.getStoreName());
+                map.put("商品编码", taxDetailDto.getSku());
+                map.put("完税总价格", taxDetailDto.getPretaxPrice());
+                map.put("进口增值税率(%)", taxDetailDto.getVatRate());
+                map.put("进口从价消费税率(%)", taxDetailDto.getSaleTaxRate());
+                map.put("退T-1日前应征增值税", taxDetailDto.getPreVat());
+                map.put("退T-1日前应征消费税", taxDetailDto.getPreSaleTax());
+                map.put("退T-1日前总税额", taxDetailDto.getPreTax());
+                map.put("T-1日前生成时间", taxDetailDto.getPreTaxTime());
+                taxList.add(map);
+            }
+        }
+
+
+
+        ee.addSalesFirstSheet("销售总额", firstSheetFirstRowValue, firstSheetSecondRowValue);
+        ee.addSheetByMap("销售订单金额", list, saleHeader);
+        ee.addSheetByMap("订单税款明细", taxList, taxDetailHeader);
+        ee.export(response);
+
+
+        return R.ok();
+    }
+
+
+}

+ 6 - 6
kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java

@@ -1327,12 +1327,12 @@ public class OrderController {
 
                     // 设置综合税额
                     BigDecimal totalSalesIncTax = new BigDecimal(systemFormat.getTotalSalesInclTax());
-//                    BigDecimal taxRate = new BigDecimal(systemFormat.getTaxRate());
-                    GoodsEntity goodsEntity = goodsService.queryObject(systemFormat.getGoodsId());
-                    BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,totalSalesIncTax.divide(unitSold,2,RoundingMode.HALF_UP),goodsService).setScale(3,RoundingMode.HALF_UP);
-                    goodsTax = goodsTax.multiply(unitSold).setScale(2,RoundingMode.HALF_UP);
-
-                    systemFormat.setSales(totalSalesIncTax.subtract(goodsTax).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
+                    BigDecimal taxRate = new BigDecimal(systemFormat.getTaxRate());
+//                    GoodsEntity goodsEntity = goodsService.queryObject(systemFormat.getGoodsId());
+//                    BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,totalSalesIncTax.divide(unitSold,2,RoundingMode.HALF_UP),goodsService).setScale(3,RoundingMode.HALF_UP);
+//                    goodsTax = goodsTax.multiply(unitSold).setScale(2,RoundingMode.HALF_UP);
+                    String goodsTax = systemFormat.getTaxPrice();
+                    systemFormat.setSales(totalSalesIncTax.subtract(new BigDecimal(goodsTax)).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                     systemFormat.setTaxAmount(totalSalesIncTax.subtract(new BigDecimal(systemFormat.getSales())).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
 
                     // 设置实际销售额

+ 19 - 3
kmall-admin/src/main/java/com/kmall/admin/dao/OrderDao.java

@@ -1,8 +1,6 @@
 package com.kmall.admin.dao;
 
-import com.kmall.admin.dto.OrderRecognitionDto;
-import com.kmall.admin.dto.SendTempDto;
-import com.kmall.admin.dto.SystemFormatDto;
+import com.kmall.admin.dto.*;
 import com.kmall.admin.entity.OrderEntity;
 import com.kmall.admin.entity.PurchaseSalesInStockDetail;
 import com.kmall.admin.entity.RealtimeSalesDetection;
@@ -154,4 +152,22 @@ public interface OrderDao extends BaseDao<OrderEntity> {
      * @return
      */
     List<SystemFormatDto> queryExportSystemFormatList(Map<String, Object> params);
+
+    ExportExcelDto totalAmount(@Param("billDate") String billDate, @Param("storeId") String storeId);
+
+    ExportExcelDto refundCurrentAmount(@Param("billDate") String billDate, @Param("storeId") String storeId);
+
+    ExportExcelDto refundPreviousAmount(@Param("billDate") String billDate, @Param("storeId") String storeId);
+
+    ExportExcelDto currentTax(@Param("billDate") String billDate, @Param("storeId") String storeId);
+
+    ExportExcelDto refundPreviousTax(@Param("billDate") String billDate, @Param("storeId") String storeId);
+
+    List<OrderEntity> queryRefundPreviousOrderList(@Param("billDate") String billDate, @Param("storeId") String storeId);
+
+    List<OrderEntity> queryCurrentPreviousOrderList(@Param("billDate") String billDate, @Param("storeId") String storeId);
+
+    List<TaxDetailDto> queryCurrentTaxDetailList(@Param("billDate") String billDate, @Param("storeId") String storeId);
+
+    List<TaxDetailDto> queryRefundPreviousTaxDetailList(@Param("billDate") String billDate, @Param("storeId") String storeId);
 }

+ 141 - 0
kmall-admin/src/main/java/com/kmall/admin/dto/ExportExcelDto.java

@@ -0,0 +1,141 @@
+package com.kmall.admin.dto;
+
+import java.io.Serializable;
+
+/**
+ * @author zhangchuangbiao
+ * @version 1.0
+ * 2020-12-23 14:49
+ */
+public class ExportExcelDto   implements Serializable {
+
+
+    private String totalAmount;
+    private String totalCount;
+    private String refundCurrentAmount;
+    private String refundCurrentCount;
+    private String refundPreviousAmount;
+    private String refundPreviousCount;
+    private String currentTax;
+    private String previousTax;
+
+    private String netAmount;
+    private String preTaxTotalAmount;
+    private String totalTax;
+    private String successNumber;
+    private String refundAmount;
+    private String refundCount;
+
+
+    public String getTotalAmount() {
+        return totalAmount;
+    }
+
+    public void setTotalAmount(String totalAmount) {
+        this.totalAmount = totalAmount;
+    }
+
+    public String getTotalCount() {
+        return totalCount;
+    }
+
+    public void setTotalCount(String totalCount) {
+        this.totalCount = totalCount;
+    }
+
+    public String getRefundCurrentAmount() {
+        return refundCurrentAmount;
+    }
+
+    public void setRefundCurrentAmount(String refundCurrentAmount) {
+        this.refundCurrentAmount = refundCurrentAmount;
+    }
+
+    public String getRefundCurrentCount() {
+        return refundCurrentCount;
+    }
+
+    public void setRefundCurrentCount(String refundCurrentCount) {
+        this.refundCurrentCount = refundCurrentCount;
+    }
+
+    public String getRefundPreviousAmount() {
+        return refundPreviousAmount;
+    }
+
+    public void setRefundPreviousAmount(String refundPreviousAmount) {
+        this.refundPreviousAmount = refundPreviousAmount;
+    }
+
+    public String getRefundPreviousCount() {
+        return refundPreviousCount;
+    }
+
+    public void setRefundPreviousCount(String refundPreviousCount) {
+        this.refundPreviousCount = refundPreviousCount;
+    }
+
+    public String getTotalTax() {
+        return totalTax;
+    }
+
+    public void setTotalTax(String totalTax) {
+        this.totalTax = totalTax;
+    }
+
+    public String getPreviousTax() {
+        return previousTax;
+    }
+
+    public void setPreviousTax(String previousTax) {
+        this.previousTax = previousTax;
+    }
+
+    public String getNetAmount() {
+        return netAmount;
+    }
+
+    public void setNetAmount(String netAmount) {
+        this.netAmount = netAmount;
+    }
+
+    public String getPreTaxTotalAmount() {
+        return preTaxTotalAmount;
+    }
+
+    public void setPreTaxTotalAmount(String preTaxTotalAmount) {
+        this.preTaxTotalAmount = preTaxTotalAmount;
+    }
+
+    public String getCurrentTax() {
+        return currentTax;
+    }
+
+    public void setCurrentTax(String currentTax) {
+        this.currentTax = currentTax;
+    }
+
+    public String getSuccessNumber() {
+        return successNumber;
+    }
+
+    public void setSuccessNumber(String successNumber) {
+        this.successNumber = successNumber;
+    }
+
+    public String getRefundAmount() {
+        return refundAmount;
+    }
+
+    public void setRefundAmount(String refundAmount) {
+        this.refundAmount = refundAmount;
+    }
+
+    public String getRefundCount() {
+        return refundCount;
+    }
+
+    public void setRefundCount(String refundCount) {
+        this.refundCount = refundCount;
+    }
+}

+ 10 - 0
kmall-admin/src/main/java/com/kmall/admin/dto/SystemFormatDto.java

@@ -46,6 +46,8 @@ public class SystemFormatDto implements Serializable {
 
     private String orderStatus;//订单状态
 
+    private String taxPrice; // 税费
+
 
     public String getOrderStatus() {
         return orderStatus;
@@ -318,4 +320,12 @@ public class SystemFormatDto implements Serializable {
     public void setGoodsId(Integer goodsId) {
         this.goodsId = goodsId;
     }
+
+    public String getTaxPrice() {
+        return taxPrice;
+    }
+
+    public void setTaxPrice(String taxPrice) {
+        this.taxPrice = taxPrice;
+    }
 }

+ 156 - 0
kmall-admin/src/main/java/com/kmall/admin/dto/TaxDetailDto.java

@@ -0,0 +1,156 @@
+package com.kmall.admin.dto;
+
+import java.io.Serializable;
+
+/**
+ * @author zhangchuangbiao
+ * @version 1.0
+ * 2020-12-24 10:06
+ */
+public class TaxDetailDto implements Serializable {
+
+    private String orderSn;
+    private String storeSn;
+    private String storeName;
+    private String sku;
+    private String pretaxPrice;
+    private String postTaxPrice;
+    private String vatRate;
+    private String saleTaxRate;
+    private String vat;
+    private String saleTax;
+    private String tax;
+    private String receiveTaxTime;
+    private String preVat;
+    private String preSaleTax;
+    private String preTax;
+    private String preTaxTime;
+
+    public String getOrderSn() {
+        return orderSn;
+    }
+
+    public void setOrderSn(String orderSn) {
+        this.orderSn = orderSn;
+    }
+
+    public String getStoreSn() {
+        return storeSn;
+    }
+
+    public void setStoreSn(String storeSn) {
+        this.storeSn = storeSn;
+    }
+
+    public String getStoreName() {
+        return storeName;
+    }
+
+    public void setStoreName(String storeName) {
+        this.storeName = storeName;
+    }
+
+    public String getSku() {
+        return sku;
+    }
+
+    public void setSku(String sku) {
+        this.sku = sku;
+    }
+
+    public String getPretaxPrice() {
+        return pretaxPrice;
+    }
+
+    public void setPretaxPrice(String pretaxPrice) {
+        this.pretaxPrice = pretaxPrice;
+    }
+
+    public String getVatRate() {
+        return vatRate;
+    }
+
+    public void setVatRate(String vatRate) {
+        this.vatRate = vatRate;
+    }
+
+    public String getSaleTaxRate() {
+        return saleTaxRate;
+    }
+
+    public void setSaleTaxRate(String saleTaxRate) {
+        this.saleTaxRate = saleTaxRate;
+    }
+
+    public String getVat() {
+        return vat;
+    }
+
+    public void setVat(String vat) {
+        this.vat = vat;
+    }
+
+    public String getSaleTax() {
+        return saleTax;
+    }
+
+    public void setSaleTax(String saleTax) {
+        this.saleTax = saleTax;
+    }
+
+    public String getTax() {
+        return tax;
+    }
+
+    public void setTax(String tax) {
+        this.tax = tax;
+    }
+
+    public String getReceiveTaxTime() {
+        return receiveTaxTime;
+    }
+
+    public void setReceiveTaxTime(String receiveTaxTime) {
+        this.receiveTaxTime = receiveTaxTime;
+    }
+
+    public String getPreVat() {
+        return preVat;
+    }
+
+    public void setPreVat(String preVat) {
+        this.preVat = preVat;
+    }
+
+    public String getPreSaleTax() {
+        return preSaleTax;
+    }
+
+    public void setPreSaleTax(String preSaleTax) {
+        this.preSaleTax = preSaleTax;
+    }
+
+    public String getPreTax() {
+        return preTax;
+    }
+
+    public void setPreTax(String preTax) {
+        this.preTax = preTax;
+    }
+
+    public String getPreTaxTime() {
+        return preTaxTime;
+    }
+
+    public void setPreTaxTime(String preTaxTime) {
+        this.preTaxTime = preTaxTime;
+    }
+
+    public String getPostTaxPrice() {
+        return postTaxPrice;
+    }
+
+    public void setPostTaxPrice(String postTaxPrice) {
+        this.postTaxPrice = postTaxPrice;
+    }
+}

+ 10 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/OrderGoodsEntity.java

@@ -74,6 +74,8 @@ public class OrderGoodsEntity implements Serializable {
 
 	private BigDecimal tax;
 
+	private BigDecimal taxPrice;
+
 	public String getPlu() {
 		return plu;
 	}
@@ -366,4 +368,12 @@ public class OrderGoodsEntity implements Serializable {
 	public void setTax(BigDecimal tax) {
 		this.tax = tax;
 	}
+
+	public BigDecimal getTaxPrice() {
+		return taxPrice;
+	}
+
+	public void setTaxPrice(BigDecimal taxPrice) {
+		this.taxPrice = taxPrice;
+	}
 }

+ 13 - 3
kmall-admin/src/main/java/com/kmall/admin/service/OrderService.java

@@ -1,8 +1,6 @@
 package com.kmall.admin.service;
 
-import com.kmall.admin.dto.OrderExpressDto;
-import com.kmall.admin.dto.OrderRecognitionDto;
-import com.kmall.admin.dto.SystemFormatDto;
+import com.kmall.admin.dto.*;
 import com.kmall.admin.entity.*;
 import com.kmall.admin.fromcomm.entity.SysUserEntity;
 import com.kmall.common.utils.Query;
@@ -190,4 +188,16 @@ public interface OrderService {
     List<SystemFormatDto> queryExportSystemFormatList(Map<String, Object> params);
 
     List<OrderEntity> queryLastDayOrder();
+
+    /**
+     * 查询CW保税+新零售销售报表第一个sheet
+     * @param billDate
+     * @param storeId
+     * @return
+     */
+    ExportExcelDto querySumAmount(String billDate, String storeId);
+
+    Map<String,List<OrderEntity>> querySaleOrderList(String billDate, String storeId);
+
+    Map<String, List<TaxDetailDto>> queryTaxDetailList(String billDate, String storeId);
 }

+ 159 - 4
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -13,9 +13,7 @@ import com.kmall.admin.dao.mk.store.StoreTopicDao;
 import com.kmall.admin.dao.vip.Mall2MemberConsumptionRecordsDao;
 import com.kmall.admin.dao.vip.Mall2MemberPointsDao;
 import com.kmall.admin.dao.vip.Mall2PointsRulesDao;
-import com.kmall.admin.dto.OrderExpressDto;
-import com.kmall.admin.dto.OrderRecognitionDto;
-import com.kmall.admin.dto.SystemFormatDto;
+import com.kmall.admin.dto.*;
 import com.kmall.admin.entity.*;
 import com.kmall.admin.entity.OrderProcessRecordEntity;
 import com.kmall.admin.entity.alarm.Mall2LowPriceWarningEntity;
@@ -2527,7 +2525,7 @@ public class OrderServiceImpl implements OrderService {
     // TODO  退款的代码
     @Override
     @Transactional
-    public R orderRefund(OrderEntity order, String sessionId) throws Exception {
+    public synchronized R orderRefund(OrderEntity order, String sessionId) throws Exception {
         String payFlag = order.getPayFlag();
 
         boolean needUpdateStock = true;
@@ -2703,6 +2701,153 @@ public class OrderServiceImpl implements OrderService {
         return orderDao.queryOffilineOrderList(map);
     }
 
+    /**
+     * 查询CW保税+新零售销售报表第一个sheet
+     *
+     * @param billDate
+     * @param storeId
+     * @return
+     */
+    @Override
+    public ExportExcelDto querySumAmount(String billDate, String storeId) {
+        ExportExcelDto exportExcelDto = new ExportExcelDto();
+        ExportExcelDto totalAmount = orderDao.totalAmount(billDate,storeId);
+        ExportExcelDto refundCurrentAmount = orderDao.refundCurrentAmount(billDate,storeId);
+        ExportExcelDto refundPreviousAmount = orderDao.refundPreviousAmount(billDate,storeId);
+        ExportExcelDto currentTax = orderDao.currentTax(billDate,storeId);
+        ExportExcelDto refundPreviousTax = orderDao.refundPreviousTax(billDate,storeId);
+
+        // 以下是直接从数据库中查出来的
+        exportExcelDto.setTotalAmount(totalAmount.getTotalAmount()); // 总销售额
+        exportExcelDto.setTotalCount(totalAmount.getTotalCount()); // 总销售数
+        exportExcelDto.setRefundCurrentAmount(refundCurrentAmount.getRefundCurrentAmount()); // 当期退款额
+        exportExcelDto.setRefundCurrentCount(refundCurrentAmount.getRefundCurrentCount()); // 当期退款数
+        exportExcelDto.setRefundPreviousAmount(refundPreviousAmount.getRefundPreviousAmount()); // 退前期销售额
+        exportExcelDto.setRefundPreviousCount(refundPreviousAmount.getRefundPreviousCount()); // 退前期销售数
+        exportExcelDto.setCurrentTax(currentTax.getCurrentTax()); // 当前税额
+        exportExcelDto.setPreviousTax(refundPreviousTax.getPreviousTax()); // 前期税额
+
+        // 以下是通过计算的出来的
+        // 销售净额
+        exportExcelDto.setNetAmount( new BigDecimal(exportExcelDto.getTotalAmount()).subtract(new BigDecimal(exportExcelDto.getRefundPreviousAmount())).setScale(2,RoundingMode.HALF_UP).toString() );
+        // 总税额
+        exportExcelDto.setTotalTax(new BigDecimal(exportExcelDto.getCurrentTax()).add(new BigDecimal(exportExcelDto.getPreviousTax())).setScale(2,RoundingMode.HALF_UP).toString());
+        // 税前总额
+        exportExcelDto.setPreTaxTotalAmount(new BigDecimal(exportExcelDto.getNetAmount()).subtract(new BigDecimal(exportExcelDto.getTotalTax())).setScale(2,RoundingMode.HALF_UP).toString());
+        // 成功单数
+        exportExcelDto.setSuccessNumber(new BigDecimal(exportExcelDto.getTotalCount()).subtract(new BigDecimal(exportExcelDto.getRefundPreviousCount())).setScale(2,RoundingMode.HALF_UP).toString());
+        // 退款总额
+        exportExcelDto.setRefundAmount(new BigDecimal(exportExcelDto.getRefundCurrentAmount()).add(new BigDecimal(exportExcelDto.getRefundPreviousAmount())).setScale(2,RoundingMode.HALF_UP).toString());
+        // 退单单数
+        exportExcelDto.setRefundCount(new BigDecimal(exportExcelDto.getRefundCurrentCount()).add(new BigDecimal(exportExcelDto.getRefundPreviousCount())).setScale(2,RoundingMode.HALF_UP).toString());
+
+        return exportExcelDto;
+    }
+
+    @Override
+    public Map<String,List<OrderEntity>> querySaleOrderList(String billDate, String storeId) {
+        Map<String,List<OrderEntity>> result = new HashMap<>();
+        // 查询当天所有订单
+        List<OrderEntity> orderEntityList = orderDao.queryCurrentPreviousOrderList(billDate,storeId);
+        result.put("current",orderEntityList);
+        // 查询当天退前期订单
+        List<OrderEntity> refundPreviousOrderList = orderDao.queryRefundPreviousOrderList(billDate,storeId);
+        result.put("previous",refundPreviousOrderList);
+
+        return result;
+    }
+
+    @Override
+    public Map<String, List<TaxDetailDto>> queryTaxDetailList(String billDate, String storeId) {
+        Map<String,List<TaxDetailDto>> result = new HashMap<>();
+        // 查询当天所有订单税单
+        List<TaxDetailDto> taxDetailList = orderDao.queryCurrentTaxDetailList(billDate,storeId);
+
+        // 计算税前价,增值税,消费税
+        BigDecimal discountRate = new BigDecimal(0.7);
+        if(taxDetailList != null && taxDetailList.size() != 0){
+            for (TaxDetailDto taxDetailDto : taxDetailList) {
+                // 获取实际支付价格
+                String postTaxPrice = taxDetailDto.getPostTaxPrice();
+                // 获取总税额
+                String  taxStr = taxDetailDto.getTax();
+                // 税前金额
+                BigDecimal tax = new BigDecimal(taxStr);
+                BigDecimal pretaxPrice = new BigDecimal(postTaxPrice).subtract(tax).setScale(2, RoundingMode.HALF_UP);
+                // 计算综合税率
+                BigDecimal taxRate = tax.divide(pretaxPrice, 4, RoundingMode.HALF_UP);
+                // 消费税率
+                BigDecimal saleTaxRate = new BigDecimal(taxDetailDto.getSaleTaxRate()).divide(new BigDecimal(100),2,RoundingMode.HALF_UP);
+                // 综合税率
+                BigDecimal vatRate = new BigDecimal(taxDetailDto.getVatRate()).divide(new BigDecimal(100),2,RoundingMode.HALF_UP);
+//              消费税 = (明细商品总价 / (1-消费税税率)) * 消费税税率
+//              增值税 = (明细商品总价 + 消费税) * 增值税税率
+//              订单该商品总税费 = (商品消费税 + 商品增值税)* 0.7
+                // 如果大于,要算消费税
+                BigDecimal saleTax = new BigDecimal(0);
+                BigDecimal vat = new BigDecimal(0);
+                if(taxRate.compareTo(new BigDecimal("0.23")) > 0){
+                    saleTax = pretaxPrice.divide(new BigDecimal(1).subtract(saleTaxRate), 2, RoundingMode.HALF_UP).multiply(saleTaxRate).
+                            setScale(2, RoundingMode.HALF_UP);
+                    vat = pretaxPrice.add(saleTax).multiply(vatRate).
+                            multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+                    saleTax = saleTax.multiply(discountRate).setScale(2,RoundingMode.HALF_UP);
+
+                }else{
+                    // 不需要算消费税,增值税计算
+                    vat = pretaxPrice.multiply(vatRate).multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+                }
+                taxDetailDto.setSaleTax(saleTax.toString());
+                taxDetailDto.setVat(vat.toString());
+            }
+        }
+
+        result.put("current",taxDetailList);
+        // 查询当天退前期订单税单
+        List<TaxDetailDto> refundPrevioustaxDetailList = orderDao.queryRefundPreviousTaxDetailList(billDate,storeId);
+
+        // 计算税前价,增值税,消费税
+        if(refundPrevioustaxDetailList != null && refundPrevioustaxDetailList.size() != 0){
+            for (TaxDetailDto taxDetailDto : refundPrevioustaxDetailList) {
+                // 获取实际支付价格
+                String postTaxPrice = taxDetailDto.getPostTaxPrice();
+                // 获取总税额
+                String  taxStr = taxDetailDto.getTax();
+                // 税前金额
+                BigDecimal tax = new BigDecimal(taxStr);
+                BigDecimal pretaxPrice = new BigDecimal(postTaxPrice).subtract(tax).setScale(2, RoundingMode.HALF_UP);
+                // 计算综合税率
+                BigDecimal taxRate = tax.divide(pretaxPrice, 4, RoundingMode.HALF_UP);
+                // 消费税率
+                BigDecimal saleTaxRate = new BigDecimal(taxDetailDto.getSaleTaxRate()).divide(new BigDecimal(100),2,RoundingMode.HALF_UP);
+                // 综合税率
+                BigDecimal vatRate = new BigDecimal(taxDetailDto.getVatRate()).divide(new BigDecimal(100),2,RoundingMode.HALF_UP);
+//              消费税 = (明细商品总价 / (1-消费税税率)) * 消费税税率
+//              增值税 = (明细商品总价 + 消费税) * 增值税税率
+//              订单该商品总税费 = (商品消费税 + 商品增值税)* 0.7
+                // 如果大于,要算消费税
+                BigDecimal saleTax = new BigDecimal(0);
+                BigDecimal vat = new BigDecimal(0);
+                if(taxRate.compareTo(new BigDecimal("0.23")) > 0){
+                    saleTax = pretaxPrice.divide(new BigDecimal(1).subtract(saleTaxRate), 2, RoundingMode.HALF_UP).multiply(saleTaxRate).
+                            multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+                    vat = pretaxPrice.add(saleTax).multiply(vatRate).
+                            multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+
+                }else{
+                    // 不需要算消费税,增值税计算
+                    vat = pretaxPrice.multiply(vatRate).multiply(discountRate).setScale(2, RoundingMode.HALF_UP);
+                }
+                taxDetailDto.setPreSaleTax(saleTax.toString());
+                taxDetailDto.setPreVat(vat.toString());
+            }
+        }
+
+        result.put("previous",refundPrevioustaxDetailList);
+
+        return result;
+    }
+
 
     /**
      * 设置订单数据
@@ -2822,6 +2967,9 @@ public class OrderServiceImpl implements OrderService {
         orderGoodsVo.setGoodsRate(goodsDto.getGoodsRate());
         orderGoodsVo.setSku(goodsDto.getSku());
 
+
+
+
         BigDecimal number = new BigDecimal(Long.valueOf(goodsDto.getGoodsNumber()));
         BigDecimal goodsTotal = goodsDto.getRetailPrice().multiply(number);//单商品总价
         BigDecimal rate = goodsTotal.divide(orderInfo.getGoods_price(), 2, BigDecimal.ROUND_HALF_UP);//当前商品总价/订单总价(不含运费、不含优惠券)
@@ -2852,6 +3000,13 @@ public class OrderServiceImpl implements OrderService {
             orderGoodsVo.setSettlePrice(settlePrice);//商品结算平摊价格
         }
 
+
+        // 计算税费
+        GoodsEntity goodsEntity = goodsService.queryObject(goodsDto.getId().intValue());
+        BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,goodsDto.getActualPaymentAmount().divide(number,2,RoundingMode.HALF_UP),goodsService).setScale(3,RoundingMode.HALF_UP);
+        goodsTax = goodsTax.multiply(number).setScale(2,RoundingMode.HALF_UP);
+        orderGoodsVo.setTaxPrice(goodsTax);
+
         return orderGoodsVo;
     }
 

+ 185 - 2
kmall-admin/src/main/resources/mybatis/mapper/OrderDao.xml

@@ -1772,7 +1772,6 @@
         o.id,
         o.order_sn,
         u.username as userName,
-
         o.pay_name,
         o.mobile,
         o.is_onffline_order,
@@ -1816,6 +1815,7 @@
         <if test="endTime != null and endTime != ''">
             AND o.add_time <![CDATA[ <  ]]> #{endTime}
         </if>
+
     </select>
     <select id="queryMasterExportOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
         SELECT distinct
@@ -1896,6 +1896,14 @@
         <if test="endTime != null and endTime != ''">
             AND o.add_time <![CDATA[ <  ]]> #{endTime}
         </if>
+        <if test="billDate != null and billDate != ''">
+            AND DATE_FORMAT(o.add_time,'%Y-%m-%d') = #{billDate}
+        </if>
+        <if test="storeId != null and storeId != ''">
+            AND o.store_id = #{storeId}
+        </if>
+        order by o.order_status
+
     </select>
     <select id="queryMasterExportList" resultType="com.kmall.admin.entity.OrderEntity">
         SELECT DISTINCT
@@ -2058,7 +2066,8 @@
         gs.goods_rate as taxRate,
         '专柜单品' as productCategory,
         sup.child_supplier_name as supplierName,
-        o.order_status as orderStatus
+        o.order_status as orderStatus,
+        g.tax_price as taxPrice
         FROM
         mall_order o
         LEFT JOIN mall_order_goods g ON o.id = g.order_id
@@ -2123,4 +2132,178 @@
         AND a.order_sn = #{orderSn}
     </update>
 
+    <select id="totalAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
+        select
+        ifnull(sum(actual_price),0) as totalAmount
+            ,ifnull(count(1),0) as totalCount
+        from
+            mall_order
+        where
+            order_status = 300
+            and DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
+            <if test="storeId != ''">
+                and store_id = #{storeId}
+            </if>
+    </select>
+
+    <select id="refundCurrentAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
+        select
+        ifnull(sum(actual_price),0) as refundCurrentAmount,
+        ifnull(count(1),0) as refundCurrentCount
+        from
+            mall_order
+        where
+            DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
+            and id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
+        <if test="storeId != ''">
+            and store_id = #{storeId}
+        </if>
+    </select>
+
+    <select id="refundPreviousAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
+        select
+        ifnull(sum(actual_price),0) as refundPreviousAmount
+            ,ifnull(count(1),0) as refundPreviousCount
+        from
+            mall_order
+        where
+            DATE_FORMAT(pay_time,'%Y-%m-%d') != #{billDate}
+        and id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
+        <if test="storeId != ''">
+            and store_id = #{storeId}
+        </if>
+    </select>
+
+    <select id="currentTax" resultType="com.kmall.admin.dto.ExportExcelDto">
+        select
+        ifnull(sum(tax_price),0) as currentTax
+        from
+            mall_order_goods t1
+        where
+            DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate}
+        and order_id in (
+            select id  from mall_order where order_status = 300 and DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
+        <if test="storeId != ''">
+            and store_id = #{storeId}
+        </if>
+        )
+    </select>
+
+    <select id="refundPreviousTax" resultType="com.kmall.admin.dto.ExportExcelDto">
+        select
+            ifnull(sum(tax_price),0)  as previousTax
+        from
+            mall_order_goods t1
+        where
+            DATE_FORMAT(create_time,'%Y-%m-%d') != #{billDate}
+        and order_id in (
+            select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate}
+        <if test="storeId != ''">
+            and store_id = #{storeId}
+        </if>
+        )
+    </select>
+
+
+    <select id="queryCurrentPreviousOrderList" resultType="com.kmall.admin.entity.OrderEntity">
+        SELECT distinct
+        o.id,
+        o.order_sn,
+        u.username as userName,
+
+        o.pay_name,
+        o.mobile,
+        o.is_onffline_order,
+        o.order_biz_type,
+        o.order_status,
+        o.pay_status,
+        o.coupon_name,
+        o.coupon_price,
+        if(o.order_status=401,concat("-",o.actual_price),o.actual_price) as actualPrice
+        , if(o.order_status=401,concat("-",o.order_price),o.order_price) as orderPrice,
+        o.pay_time,
+        o.pay_flag,
+        u.username AS userName,
+
+        s.store_name storeName
+        FROM
+        mall_order o
+
+
+        LEFT JOIN mall_order_goods g ON o.id = g.order_id
+        left join mall_store s on o.store_id = s.id
+        LEFT JOIN mall_goods gs ON g.goods_id = gs.id
+        left join mall_sale_record record on record.order_sn = o.order_sn
+        LEFT JOIN sys_user u ON record.saller_id = u.user_id
+        WHERE
+        (DATE_FORMAT(o.create_time,'%Y-%m-%d') = #{billDate})
+        <if test="storeId != ''">
+            and o.store_id = #{storeId}
+        </if>
+        order by o.order_status
+    </select>
+
+    <select id="queryRefundPreviousOrderList"  resultType="com.kmall.admin.entity.OrderEntity">
+        SELECT distinct
+        o.id,
+        o.order_sn,
+        u.username as userName,
+
+        o.pay_name,
+        o.mobile,
+        o.is_onffline_order,
+        o.order_biz_type,
+        o.order_status,
+        o.pay_status,
+        o.coupon_name,
+        o.coupon_price,
+        if(o.order_status=401,concat("-",o.actual_price),o.actual_price) as actualPrice
+        , if(o.order_status=401,concat("-",o.order_price),o.order_price) as orderPrice,
+        o.pay_time,
+        o.pay_flag,
+        u.username AS userName,
+
+        s.store_name storeName
+        FROM
+        mall_order o
+
+
+        LEFT JOIN mall_order_goods g ON o.id = g.order_id
+        left join mall_store s on o.store_id = s.id
+        LEFT JOIN mall_goods gs ON g.goods_id = gs.id
+        left join mall_sale_record record on record.order_sn = o.order_sn
+        LEFT JOIN sys_user u ON record.saller_id = u.user_id
+        WHERE
+        (DATE_FORMAT(o.create_time,'%Y-%m-%d') != #{billDate})
+        and o.id in (select r.order_id from mall_order_refund r where (DATE_FORMAT(r.create_time,'%Y-%m-%d') = #{billDate}))
+        <if test="storeId != ''">
+            and o.store_id = #{storeId}
+        </if>
+        order by o.order_status
+    </select>
+
+    <select id="queryCurrentTaxDetailList" resultType="com.kmall.admin.dto.TaxDetailDto">
+        select o.order_sn as orderSn,s.id as storeId, s.store_name as storeName,g.goods_sn as sku,
+        imp_consum_tax_rate as saleTaxRate , value_added_tax_rate as vatRate,
+        og.tax_price as tax , o.mod_time as receiveTaxTime,og.actual_payment_amount as postTaxPrice
+
+        from mall_order o ,mall_order_goods og , mall_goods g , mall_store s  where o.id = og.order_id and og.sku = g.goods_sn and o.store_id = s.id  and o.order_status = 300
+        and DATE_FORMAT(o.pay_time,'%Y-%m-%d') = #{billDate}
+        <if test="storeId != ''">
+            and o.store_id = #{storeId}
+        </if>
+    </select>
+
+    <select id="queryRefundPreviousTaxDetailList" resultType="com.kmall.admin.dto.TaxDetailDto">
+        select o.order_sn as orderSn,s.id as storeId, s.store_name as storeName,g.goods_sn as sku,
+        imp_consum_tax_rate as preSaleTax , value_added_tax_rate as preVat,
+        og.tax_price as preTax , o.mod_time as preTaxTime,og.actual_payment_amount as postTaxPrice
+
+        from mall_order o ,mall_order_goods og , mall_goods g , mall_store s  where o.id = og.order_id and og.sku = g.goods_sn and o.store_id = s.id
+        and DATE_FORMAT(o.pay_time,'%Y-%m-%d') != #{billDate} and o.id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
+        <if test="storeId != ''">
+            and o.store_id = #{storeId}
+        </if>
+    </select>
+
 </mapper>

+ 3 - 0
kmall-admin/src/main/resources/mybatis/mapper/OrderGoodsDao.xml

@@ -14,6 +14,7 @@
         <result property="number" column="number"/>
         <result property="marketPrice" column="market_price"/>
         <result property="retailPrice" column="retail_price"/>
+        <result property="taxPrice" column="tax_price"/>
         <result property="goodsSpecificationNameValue" column="goods_specification_name_value"/>
         <result property="isReal" column="is_real"/>
         <result property="goodsSpecificationIds" column="goods_specification_ids"/>
@@ -102,6 +103,7 @@
         `goods_specification_ids`,
         `list_pic_url`,
         is_dist_sell_scan,
+        tax_price,
         store_topic_id,
         <if test="goodsRate != null" >
             goods_rate,
@@ -149,6 +151,7 @@
         #{goods_specification_ids},
         #{list_pic_url},
         0,
+        #{taxPrice},
         #{storeTopicId},
         <if test="goodsRate != null" >
             #{goodsRate},

+ 8 - 2
kmall-admin/src/main/webapp/WEB-INF/page/shop/offilineOrderList.html

@@ -46,6 +46,12 @@
                 #end
                 <i-button type="primary" @click="exportSystemFormat"><i class="fa fa-cloud-download"></i>&nbsp;Daily sales report 导出</i-button>
             </div>
+            <div>
+                <i-col span="3">
+                    <Date-picker v-model="q.billDate" placeholder="账单时间"/>
+                </i-col>
+                <i-button type="primary" @click="exportSaleReportExcel"><i class="fa fa-cloud-download"></i>&nbsp;销售报表导出</i-button>
+            </div>
            <!-- TODO req_hidden_20200610 #if($shiro.hasPermission("order:wxMicropayPay"))
             <div class="buttons-group">
                 <i-button type="error" @click="showInputAuthCode">微信付款</i-button>
@@ -206,8 +212,8 @@
                         </td>
                         <td align="center">¥{{item.number * item.marketPrice}}</td>
                         <td align="center">¥{{item.number * item.discountedPrice}}</td>
-                        <td align="center">¥{{item.number * item.actualPaymentAmount}}</td>
-                        <td align="center">¥{{item.number * item.actualPaymentAmount}}</td>
+                        <td align="center">¥{{item.actualPaymentAmount}}</td>
+                        <td align="center">¥{{item.actualPaymentAmount}}</td>
                         <td align="center">¥{{item.tax}}</td>
                     </tr>
                     <tr>

+ 12 - 1
kmall-admin/src/main/webapp/js/shop/offilineOrderList.js

@@ -195,6 +195,7 @@ let vm = new Vue({
             startTime: '',
             endTime: '',
             goodsSn:'',
+            billDate:'',
         },
         refundMoney: 0,
         shipping: {},
@@ -252,6 +253,7 @@ let vm = new Vue({
                     'startTime': vm.q.startTime,
                     'endTime': vm.q.endTime,
                     'goodsSn':vm.q.goodsSn,
+                    'billDate':vm.q.billDate,
                 },
                 page: page
             }).trigger("reloadGrid");
@@ -261,7 +263,10 @@ let vm = new Vue({
                 orderSn: '',
                 orderStatus: '',
                 orderType: '',
-                goodsSn:''
+                goodsSn:'',
+                billDate:'',
+                startTime:'',
+                endTime:'',
             };
         },
         lookDetail: function (rowId) { //第三步:定义编辑操作
@@ -515,6 +520,12 @@ let vm = new Vue({
             params.startTime=vm.q.startTime;
             params.endTime=vm.q.endTime;
             exportFile('#rrapp', '../order/exportSystemFormat', params);
+        },
+        exportSaleReportExcel:function(){
+            var params = {};
+            params.billDate = vm.q.billDate;
+            exportFile('#rrapp', '../exportExcel/exportSalesExcel', params);
+
         }
     },
     created: function () {

+ 10 - 0
kmall-api/src/main/java/com/kmall/api/entity/OrderGoodsVo.java

@@ -72,6 +72,8 @@ public class OrderGoodsVo implements Serializable {
     // 实际支付价
     private BigDecimal actualPaymentAmount;
 
+    private BigDecimal taxPrice;
+
 
 
     public BigDecimal getDiscountedPrice() {
@@ -306,4 +308,12 @@ public class OrderGoodsVo implements Serializable {
     public void setActivity(String activity) {
         this.activity = activity;
     }
+
+    public BigDecimal getTaxPrice() {
+        return taxPrice;
+    }
+
+    public void setTaxPrice(BigDecimal taxPrice) {
+        this.taxPrice = taxPrice;
+    }
 }

+ 85 - 0
kmall-common/src/main/java/com/kmall/common/utils/excel/ExcelExport.java

@@ -20,6 +20,8 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.util.HSSFColor;
 import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.RegionUtil;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
@@ -243,6 +245,89 @@ public class ExcelExport {
 
     }
 
+
+    /**
+     * 主要功能:在EXCEL中添加一个Sheet
+     * 注意事项:添加Sheet 并将List<Object[]> 中的数据填充
+     *
+     * @param sheetName  表单名字
+     * @param firstMap
+     * @param secondMap
+     */
+    public void addSalesFirstSheet(String sheetName, Map<String, String> firstMap,
+                                   Map<String, String> secondMap) {
+
+        // 创建表单
+        Sheet sheet;
+
+        if (StringUtils.isNullOrEmpty(sheetName)) {
+            sheet = workBook.createSheet();
+        } else {
+            sheet = workBook.createSheet(sheetName);
+        }
+
+        // 生成标题行 (表头)
+        // 默认第一行
+        Row row = sheet.createRow(0);
+        row.setHeight((short) 400);
+        // 按列生成表头
+        Cell cell = row.createCell(0);
+        cell.setCellStyle(getStyle("title"));
+        cell.setCellType(CellType.STRING);
+        cell.setCellValue("CW保税+新零售销售额统计");
+        CellRangeAddress region = new CellRangeAddress(0, 0, 0, 5);
+        sheet.addMergedRegion(region);
+        RegionUtil.setBorderTop(1, region, sheet, workBook);
+        RegionUtil.setBorderBottom(1, region, sheet, workBook);
+        RegionUtil.setBorderLeft(1, region, sheet, workBook);
+        RegionUtil.setBorderRight(1, region, sheet, workBook);
+
+        // 第二行
+        Row secondRow = sheet.createRow(1);
+        Row secondRowValue = sheet.createRow(2);
+        String[] secondTitleNames = {"汇总日期","账单日期","销售含税总额","当期退T-1日前金额","销售含税净额","销售税前总额","税款总额","当期退T-1日前税款","当期税款金额","成功订单数"};
+        for(int i = 0 ; i < secondTitleNames.length ; i++){
+            Cell secondCell = secondRow.createCell(i);
+            secondCell.setCellStyle(getStyle("title"));
+            secondCell.setCellType(CellType.STRING);
+            secondCell.setCellValue(secondTitleNames[i]);
+            sheet.setColumnWidth(i,secondTitleNames[i].getBytes().length*2*256);
+
+            if("当期退T-1日前金额".equals(secondTitleNames[i]) || "当期退T-1日前税款".equals(secondTitleNames[i])){
+                Cell se = secondRowValue.createCell(i);
+                se.setCellValue(firstMap.get(secondTitleNames[i]).equals("0.00")?firstMap.get(secondTitleNames[i]):"-"+firstMap.get(secondTitleNames[i]));
+
+            }else{
+                Cell se = secondRowValue.createCell(i);
+                se.setCellValue(firstMap.get(secondTitleNames[i]));
+            }
+
+        }
+
+        // 第二行
+        Row thirdRow = sheet.createRow(4);
+        Row thirdRowValue = sheet.createRow(5);
+        String[] thirdTitleNames = {"汇总日期","账单日期","当期退当天金额(销售总额已减扣)","当期退当天订单数","退T-1日前订单总额(销售总额已减扣)","退T-1日前订单总数","当期退单总额(销售总额已减扣)","当日退款总单数"};
+        for(int i = 0 ; i < thirdTitleNames.length ; i++){
+            Cell thirdCell = thirdRow.createCell(i);
+            thirdCell.setCellStyle(getStyle("title"));
+            thirdCell.setCellType(CellType.STRING);
+            thirdCell.setCellValue(thirdTitleNames[i]);
+            sheet.setColumnWidth(i,thirdTitleNames[i].getBytes().length*256+20);
+
+            if("当期退当天金额(销售总额已减扣)".equals(thirdTitleNames[i]) || "当期退单总额(销售总额已减扣)".equals(thirdTitleNames[i])
+            ||"退T-1日前订单总额(销售总额已减扣)".equals(thirdTitleNames[i])){
+                Cell se = thirdRowValue.createCell(i);
+                se.setCellValue(secondMap.get(thirdTitleNames[i]).equals("0.00")?secondMap.get(thirdTitleNames[i]):"-"+secondMap.get(thirdTitleNames[i]));
+            }else{
+                Cell se = thirdRowValue.createCell(i);
+                se.setCellValue(secondMap.get(thirdTitleNames[i]));
+            }
+
+        }
+
+    }
+
     /**
      * 主要功能:在EXCEL中添加一个Sheet
      * 注意事项:添加Sheet 并将List<Object[]> 中的数据填充