Procházet zdrojové kódy

添加凭证导入(未测试) 及订单详情表头增加账户名称、账户余额、信用额度及特殊订单,可以编辑行金额,根据行金额自动算单价(若编辑单价,则自动算金额)

hu před 2 roky
rodič
revize
2edbb63645

+ 8 - 0
src/custom/restcontroller/R.java

@@ -4687,6 +4687,14 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20230506162603 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230506162703 {
+        public static class v1 {
+        }
+    }
 
 
 }

+ 302 - 0
src/custom/restcontroller/sale/cashbill/IncomeExportExcel.java

@@ -0,0 +1,302 @@
+package restcontroller.sale.cashbill;
+
+
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+
+import java.awt.*;
+
+public class IncomeExportExcel {
+	 /**
+     * 设置标题单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle1(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.RED.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorGrey = new XSSFColor(new Color(217, 225, 242));
+        cellStyle.setFillForegroundColor(colorGrey);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.LEFT); // 居左
+        return cellStyle;
+    }
+    /**
+     * 设置中文提示信息样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle2(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.WHITE.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorBlue = new XSSFColor(new Color(48, 84, 150));
+        cellStyle.setFillForegroundColor(colorBlue);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.LEFT); // 居左
+        return cellStyle;
+    }
+    /**
+     * 设置中文提示信息样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle3(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.WHITE.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorBlue = new XSSFColor(new Color(48, 84, 150));
+        cellStyle.setFillForegroundColor(colorBlue);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER); // 居左
+        return cellStyle;
+    }
+
+    /**
+     * 设置正文单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createBodyCellStyle(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+		font.setFontName("微软雅黑");// 设置标题字体
+       // font.setFontName(HSSFFont.FONT_ARIAL);// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.LEFT); // 居左
+        return cellStyle;
+    } 
+     /**
+     * 2022-07-14 17:41:39
+               * 设置表格宽度(导入模板)
+     * **/
+    public static void setBatchDetailSheetColumn1(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5500);// 设置 经销商编码 宽度
+        sheet.setColumnWidth((short) 1, (short) 5500);// 设置 账户名称 宽度
+        sheet.setColumnWidth((short) 2, (short) 5500);// 设置 金额 宽度
+        sheet.setColumnWidth((short) 3, (short) 5500);// 设置 分类 宽度
+        sheet.setColumnWidth((short) 4, (short) 5500);// 设置 分类明细 宽度
+        sheet.setColumnWidth((short) 5, (short) 11000);// 设置 备注 宽度
+    }
+    
+    
+    /**
+     * 2022-07-14 17:41:39
+              * 设置表格宽度(返回错误Excel的样式)
+     * **/
+    public static void setBatchDetailSheetColumn2(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5500);// 设置 经销商编码 宽度
+        sheet.setColumnWidth((short) 1, (short) 5500);// 设置 账户名称 宽度
+        sheet.setColumnWidth((short) 2, (short) 5500);// 设置 金额 宽度
+        sheet.setColumnWidth((short) 3, (short) 5500);// 设置 分类 宽度
+        sheet.setColumnWidth((short) 4, (short) 5500);// 设置 分类明细 宽度
+        sheet.setColumnWidth((short) 5, (short) 11000);// 设置 备注 宽度
+        sheet.setColumnWidth((short) 6, (short) 8000);// 设置 错误信息 宽度
+    }
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * cellStyle1 中文提示信息样式
+     * cellStyle2 标题提示信息样式
+     * cellStyle3 正文提示信息样式
+     * **/
+    public static void batchDetail(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFCellStyle cellStyle4,XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+        
+        cellStyle2.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle2.setWrapText(true);
+
+   	 /*第一行*/
+       sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 5));
+
+       /*第一行塞值*/
+       row = sheet.createRow(0);
+       cell = row.createCell(0);// ID
+       cell.setCellStyle(cellStyle4);
+       cell.setCellValue("收入凭证导入");
+       /*第二行*/
+       sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 5));
+       /*第二行塞值*/
+       row = sheet.createRow(1);
+       cell = row.createCell(0);// ID
+       cell.setCellStyle(cellStyle1);
+       cell.setCellValue("注意:①请按照以下示例填写收入凭证;②收入凭证最多不超过5000行;③收入凭证导入前,请记得删除示例行!");
+       /*第三行塞值*/
+
+        row = sheet.createRow(2);
+       cell = row.createCell(0);
+       cell.setCellStyle(cellStyle2);
+       cell.setCellValue("经销商编码(必填)");
+
+       cell = row.createCell(1);
+       cell.setCellStyle(cellStyle2);
+       cell.setCellValue("账户名称(必填)");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue(" 收入金额(必填)");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("分类(必填)");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue(" 分类明细");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("备注");
+       
+
+        /*第四行塞值*/
+        row = sheet.createRow(3);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("1111");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("现金账户");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("100");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("货款");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("分类明细");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("备注");
+        
+    }
+    
+    
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * **/
+    public static void batchDetailErr(XSSFSheet sheet, XSSFCellStyle cellStyle1,XSSFCellStyle cellStyle2,XSSFCellStyle cellStyle3,XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+        
+        
+
+      	 /*第一行*/
+          sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
+
+          /*第一行塞值*/
+          row = sheet.createRow(0);
+          cell = row.createCell(0);// ID
+          cell.setCellStyle(cellStyle3);
+          cell.setCellValue("收入凭证导入");
+          /*第二行*/
+          sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 6));
+          /*第二行塞值*/
+          row = sheet.createRow(1);
+          cell = row.createCell(0);// ID
+          cell.setCellStyle(cellStyle1);
+          cell.setCellValue("注意:①请按照以下示例填写收入凭证;②收入凭证最多不超过5000行;③收入凭证导入前,请记得删除示例行!");
+          /*第三行塞值*/
+          row = sheet.createRow(2);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("经销商编码(必填)");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("账户名称(必填)");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue(" 收入金额(必填)");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("分类(必填)");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue(" 分类明细");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("备注");
+
+          cell = row.createCell(6);
+          cell.setCellStyle(cellStyle2);
+          cell.setCellValue("错误信息");         
+      
+    }
+}

+ 302 - 0
src/custom/restcontroller/sale/cashbill/PayExportExcel.java

@@ -0,0 +1,302 @@
+package restcontroller.sale.cashbill;
+
+
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+
+import java.awt.*;
+
+public class PayExportExcel {
+	 /**
+     * 设置标题单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle1(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.RED.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorGrey = new XSSFColor(new Color(217, 225, 242));
+        cellStyle.setFillForegroundColor(colorGrey);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.LEFT); // 居左
+        return cellStyle;
+    }
+    /**
+     * 设置中文提示信息样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle2(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.WHITE.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorBlue = new XSSFColor(new Color(48, 84, 150));
+        cellStyle.setFillForegroundColor(colorBlue);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.LEFT); // 居左
+        return cellStyle;
+    }
+    /**
+     * 设置中文提示信息样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle3(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.WHITE.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorBlue = new XSSFColor(new Color(48, 84, 150));
+        cellStyle.setFillForegroundColor(colorBlue);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER); // 居左
+        return cellStyle;
+    }
+
+    /**
+     * 设置正文单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createBodyCellStyle(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+		font.setFontName("微软雅黑");// 设置标题字体
+       // font.setFontName(HSSFFont.FONT_ARIAL);// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.LEFT); // 居左
+        return cellStyle;
+    } 
+     /**
+     * 2022-07-14 17:41:39
+               * 设置表格宽度(导入模板)
+     * **/
+    public static void setBatchDetailSheetColumn1(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5500);// 设置 经销商编码 宽度
+        sheet.setColumnWidth((short) 1, (short) 5500);// 设置 账户名称 宽度
+        sheet.setColumnWidth((short) 2, (short) 5500);// 设置 金额 宽度
+        sheet.setColumnWidth((short) 3, (short) 5500);// 设置 分类 宽度
+        sheet.setColumnWidth((short) 4, (short) 5500);// 设置 分类明细 宽度
+        sheet.setColumnWidth((short) 5, (short) 11000);// 设置 备注 宽度
+    }
+    
+    
+    /**
+     * 2022-07-14 17:41:39
+              * 设置表格宽度(返回错误Excel的样式)
+     * **/
+    public static void setBatchDetailSheetColumn2(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5500);// 设置 经销商编码 宽度
+        sheet.setColumnWidth((short) 1, (short) 5500);// 设置 账户名称 宽度
+        sheet.setColumnWidth((short) 2, (short) 5500);// 设置 金额 宽度
+        sheet.setColumnWidth((short) 3, (short) 5500);// 设置 分类 宽度
+        sheet.setColumnWidth((short) 4, (short) 5500);// 设置 分类明细 宽度
+        sheet.setColumnWidth((short) 5, (short) 11000);// 设置 备注 宽度
+        sheet.setColumnWidth((short) 6, (short) 8000);// 设置 错误信息 宽度
+    }
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * cellStyle1 中文提示信息样式
+     * cellStyle2 标题提示信息样式
+     * cellStyle3 正文提示信息样式
+     * **/
+    public static void batchDetail(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFCellStyle cellStyle4,XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+        
+        cellStyle2.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle2.setWrapText(true);
+
+   	 /*第一行*/
+       sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 5));
+
+       /*第一行塞值*/
+       row = sheet.createRow(0);
+       cell = row.createCell(0);// ID
+       cell.setCellStyle(cellStyle4);
+       cell.setCellValue("支出凭证导入");
+       /*第二行*/
+       sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 5));
+       /*第二行塞值*/
+       row = sheet.createRow(1);
+       cell = row.createCell(0);// ID
+       cell.setCellStyle(cellStyle1);
+       cell.setCellValue("注意:①请按照以下示例填写支出凭证;②支出凭证最多不超过5000行;③支出凭证导入前,请记得删除示例行!");
+       /*第三行塞值*/
+
+        row = sheet.createRow(2);
+       cell = row.createCell(0);
+       cell.setCellStyle(cellStyle2);
+       cell.setCellValue("经销商编码(必填)");
+
+       cell = row.createCell(1);
+       cell.setCellStyle(cellStyle2);
+       cell.setCellValue("账户名称(必填)");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue(" 支出金额(必填)");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("分类(必填)");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue(" 分类明细");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("备注");
+       
+
+        /*第四行塞值*/
+        row = sheet.createRow(3);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("1111");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("现金账户");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("100");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("货款");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("分类明细");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("备注");
+        
+    }
+    
+    
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * **/
+    public static void batchDetailErr(XSSFSheet sheet, XSSFCellStyle cellStyle1,XSSFCellStyle cellStyle2,XSSFCellStyle cellStyle3,XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+        
+        
+
+      	 /*第一行*/
+          sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
+
+          /*第一行塞值*/
+          row = sheet.createRow(0);
+          cell = row.createCell(0);// ID
+          cell.setCellStyle(cellStyle3);
+          cell.setCellValue("支出凭证导入");
+          /*第二行*/
+          sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 6));
+          /*第二行塞值*/
+          row = sheet.createRow(1);
+          cell = row.createCell(0);// ID
+          cell.setCellStyle(cellStyle1);
+          cell.setCellValue("注意:①请按照以下示例填写支出凭证;②支出凭证最多不超过5000行;③支出凭证导入前,请记得删除示例行!");
+          /*第三行塞值*/
+          row = sheet.createRow(2);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("经销商编码(必填)");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("账户名称(必填)");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("支出金额(必填)");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("分类(必填)");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue(" 分类明细");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("备注");
+
+          cell = row.createCell(6);
+          cell.setCellStyle(cellStyle2);
+          cell.setCellValue("错误信息");         
+      
+    }
+}

+ 387 - 3
src/custom/restcontroller/sale/cashbill/cashbill.java

@@ -3,25 +3,33 @@ package restcontroller.sale.cashbill;
 import beans.clear.ClearData;
 import beans.data.BatchDeleteErr;
 import beans.datacontrllog.DataContrlLog;
+import beans.datateam.DataTeam;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.sun.xml.internal.xsom.impl.Ref;
 import common.Controller;
 import common.YosException;
 import common.annotation.API;
 import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
+import common.annotation.cm;
+import common.data.*;
 import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.*;
 import restcontroller.R;
+import restcontroller.system.attachment.Attachment;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
+import static restcontroller.webmanage.saletool.orderclue.orderclue.isBigDecimal;
+
 public class cashbill extends Controller {
 
     public cashbill(JSONObject arg0) throws YosException {
@@ -29,6 +37,251 @@ public class cashbill extends Controller {
         // TODO Auto-generated constructor stub
     }
 
+
+    /**
+     * 下载凭证导入单模板
+     *
+     * @return
+     */
+    @API(title = "下载凭证导入单模板", apiversion = R.ID20230506162603.v1.class)
+    public String downloadCashbillExcel() throws YosException {
+        ExcelFactory excelFactory = new ExcelFactory("ImportTemplateForCashbill");
+
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("Sheet1");
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+        CellStyle style = xssfFWorkbook.createCellStyle();
+        // 设置为文本格式,防止身份证号变成科学计数法
+        DataFormat format = xssfFWorkbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
+        sheet.setDefaultColumnStyle(0, style);
+        sheet.setDefaultColumnStyle(1, style);
+        sheet.setDefaultColumnStyle(2, style);
+        if(content.getString("type").equals("收入")){
+            IncomeExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
+            XSSFCellStyle titleCellStyle1 = IncomeExportExcel.createTitleCellStyle1(xssfFWorkbook);
+            XSSFCellStyle titleCellStyle2 = IncomeExportExcel.createTitleCellStyle2(xssfFWorkbook);
+            XSSFCellStyle titleCellStyle3 = IncomeExportExcel.createBodyCellStyle(xssfFWorkbook);
+            XSSFCellStyle titleCellStyle4 = IncomeExportExcel.createTitleCellStyle3(xssfFWorkbook);
+            IncomeExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
+                    xssfFWorkbook);// 写入标题
+
+        }else if(content.getString("type").equals("支出")){
+            PayExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
+            XSSFCellStyle titleCellStyle1 = PayExportExcel.createTitleCellStyle1(xssfFWorkbook);
+            XSSFCellStyle titleCellStyle2 = PayExportExcel.createTitleCellStyle2(xssfFWorkbook);
+            XSSFCellStyle titleCellStyle3 = PayExportExcel.createBodyCellStyle(xssfFWorkbook);
+            XSSFCellStyle titleCellStyle4 = PayExportExcel.createTitleCellStyle3(xssfFWorkbook);
+            PayExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
+                    xssfFWorkbook);// 写入标题
+        }else{
+            return getErrReturnObject().setErrMsg("凭证类型不匹配,无法下载导入文件").toString();
+        }
+
+        Rows aa = uploadExcelToObs(excelFactory);
+        String url = "";
+        if (!aa.isEmpty()) {
+            url = aa.get(0).getString("url");
+        }
+        return getSucReturnObject().setData(url).toString();
+
+    }
+
+    /**
+     * 导入凭证
+     *
+     * @return
+     */
+    @API(title = "导入凭证", apiversion = R.ID20230506162703.v1.class)
+    @CACHEING_CLEAN(apiClass = cashbill.class)
+    public String uploadCashbillByExcel() throws YosException {
+
+        ExcelFactory e;
+        try {
+
+            // 华为云
+            //e = getPostExcelFactory(content.getLong("attachmentid"));
+            // 本地
+            e = getPostExcelFactory();
+
+            // Rows keyRow = dbConnect.runSqlQuery("select fagentnum,faddress from tagents
+            // where 1=2");
+            // Rows row1 = e.getSheetRows(1, keyRow, 1);
+            ArrayList<String> keys = new ArrayList<>();
+            ArrayList<String> sqllist = new ArrayList<>();
+            keys.add("agentnum");
+            keys.add("accountname");
+            keys.add("amount");
+            keys.add("type");
+            keys.add("typemx");
+            keys.add("remarks");
+            Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid,accountname from sa_accountclass where siteid='"+siteid+"' and isused=1");
+            RowsMap accountclassRowsMap = accountclassRows.toRowsMap("accountname");
+
+            Rows agentRows = dbConnect.runSqlQuery("select agentnum,sys_enterpriseid from sa_agents where siteid='"+siteid+"'");
+            RowsMap agentRowsMap = agentRows.toRowsMap("agentnum");
+            if (!(content.getString("type") + "凭证导入")
+                    .equals(((String) getCellFormatValue(e.getSheet(0).getRow(0).getCell(0))).replace(" ", ""))) {
+                return getErrReturnObject().setErrMsg("导入失败,不符合" + content.getString("type") + "凭证导入要求").toString();
+            }
+            Rows rows = e.getSheetRows(0, keys, 3);
+            int a = 1;
+            int i = 0;
+            // String msg = "";
+            boolean iserr = false;
+            Rows rowserr = new Rows();
+            Rows rowssuc = new Rows();
+            for (Row row : rows) {
+                String msg = "";
+                if (StringUtils.isEmpty(row.getString("agentnum"))) {
+                    iserr = true;
+                    msg =msg + "【经销商编码为空】";
+                }
+                if (StringUtils.isEmpty(row.getString("accountname"))) {
+                    iserr = true;
+                    msg = msg +"【账户名称为空】";
+
+                }
+                if (!isBigDecimal(row.getString("amount"))) {
+                    iserr = true;
+                    msg = msg + "【金额错误:" + row.getString("amount") + "】";
+
+                }
+                if (StringUtils.isEmpty(row.getString("type"))) {
+                    iserr = true;
+                    msg = msg +"【分类为空】";
+
+                }
+                if(!agentRowsMap.containsKey(row.getString("agentnum"))){
+                    msg = msg +"【该经销商编码找不到匹配的经销商】";
+                }else{
+                    if(agentRowsMap.get(row.getString("agentnum")).isEmpty()){
+                        msg = msg +"【该经销商编码找不到匹配的经销商】";
+                    }
+                }
+
+                if(!accountclassRowsMap.containsKey(row.getString("accountname"))){
+                    msg = msg +"【该账户名称找不到匹配的账户】";
+                }else{
+                    if(accountclassRowsMap.get(row.getString("accountname")).isEmpty()){
+                        msg = msg +"【该账户名称找不到匹配的账户】";
+                    }
+                }
+
+                if (iserr) {
+                    row.put("msg", "错误信息:" + msg);
+                    rowserr.add(row);
+                } else {
+                    rowssuc.add(row);
+                }
+
+//				if (!msg.equals("111")) {
+//					XSSFWorkbook xssfFWorkbook = e.getXssfWorkbook();
+//					XSSFCellStyle cellStyle = xssfFWorkbook.createCellStyle();
+//
+//					XSSFFont font = xssfFWorkbook.createFont();
+//
+//					font.setColor((short) 0xa);
+//					font.setFontHeightInPoints((short) 8);
+//					font.setBold(true);
+//					cellStyle.setFont(font);
+//					datarow.createCell(8).setCellValue("错误信息:" + msg);
+//					datarow.getCell(8).setCellStyle(cellStyle);
+//
+//				}
+
+            }
+            long[] sa_cashbillid = createTableID("sa_cashbill",
+                    rowssuc.size());
+            if (!rowssuc.isEmpty()) {
+                for (Row row : rowssuc) {
+                    SQLFactory sqlFactoryupload = new SQLFactory(this, "收支凭证新增");
+                    sqlFactoryupload.addParameter("sa_cashbillid", sa_cashbillid[i]);
+                    sqlFactoryupload.addParameter("billno", createBillCode("cashbill"));
+                    if(agentRowsMap.containsKey(row.getString("agentnum"))){
+                        sqlFactoryupload.addParameter("sys_enterpriseid", agentRowsMap.get(row.getString("agentnum")).get(0).getLong("sys_enterpriseid"));
+                    }else {
+                        continue;
+                    }
+                    if(accountclassRowsMap.containsKey(row.getString("accountname"))){
+                        sqlFactoryupload.addParameter("sa_accountclassid", accountclassRowsMap.get(row.getString("accountname")).get(0).getLong("sa_accountclassid"));
+                    }else {
+                        continue;
+                    }
+                    if(content.getString("type").equals("收入")){
+                        sqlFactoryupload.addParameter("type", 1);
+                    }else{
+                        sqlFactoryupload.addParameter("type", 0);
+                    }
+                    sqlFactoryupload.addParameter("siteid", siteid);
+                    sqlFactoryupload.addParameter("remarks", row.getString("remarks"));
+                    sqlFactoryupload.addParameter("amount",  row.getString("amount"));
+                    sqlFactoryupload.addParameter("subclass", row.getString("typemx"));
+                    sqlFactoryupload.addParameter("class", row.getString("type"));
+                    sqlFactoryupload.addParameter("userid", userid);
+                    sqlFactoryupload.addParameter("username", username);
+                    sqlFactoryupload.addParameter("ownertable", "");
+                    sqlFactoryupload.addParameter("ownerid", 0);
+                    sqlFactoryupload.addParameter("source", "");
+                    sqlFactoryupload.addParameter("sourcenote", "");
+                    sqllist.add(sqlFactoryupload.getSQL());
+                    i++;
+                }
+            }
+            if (iserr) {
+                ExcelFactory excelFactory = new ExcelFactory("sa_cashbillerr");
+                HashMap<String, String> map = new HashMap<String, String>();
+                map.put("agentnum", "经销商编码");
+                map.put("accountname", "账户名称");
+                map.put("amount", "金额");
+                map.put("type", "分类");
+                map.put("typemx", "分类明细");
+                map.put("remarks", "备注");
+                map.put("msg", "错误信息");
+                ArrayList<String> colNameList = new ArrayList<String>();
+                HashMap<String, Class> keytypemap = new HashMap<String, Class>();
+                colNameList.add("agentnum");
+                colNameList.add("accountname");
+                colNameList.add("amount");
+                colNameList.add("type");
+                colNameList.add("typemx");
+                colNameList.add("remarks");
+                colNameList.add("msg");
+                keytypemap.put("agentnum", String.class);
+                keytypemap.put("accountname", String.class);
+                keytypemap.put("amount", String.class);
+                keytypemap.put("type", String.class);
+                keytypemap.put("typemx", String.class);
+                keytypemap.put("remarks", String.class);
+                keytypemap.put("msg", String.class);
+                rowserr.setFieldList(colNameList);
+                rowserr.setFieldTypeMap(keytypemap);
+                if(content.getString("type").equals("收入")){
+                    addSheetIncome(excelFactory, "Sheet1", rowserr, map);
+                }else {
+                    addSheetPay(excelFactory, "Sheet1", rowserr, map);
+                }
+
+
+                Rows aa = uploadExcelToObs(excelFactory);
+                String url = "";
+                if (!aa.isEmpty()) {
+                    url = aa.get(0).getString("url");
+                }
+                return getSucReturnObject().setData(url).toString();
+
+            }
+        } catch (Exception e1) {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+            return getErrReturnObject().setErrMsg(e1.getMessage()).toString();
+        }
+        return getSucReturnObject().toString();
+
+    }
+
+
+
     @API(title = "收支凭证新建更新", apiversion = R.ID20221009102803.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20230111103403.v1.class})
     public String insertormodify_creditbill() throws YosException {
@@ -545,4 +798,135 @@ public class cashbill extends Controller {
         content.put("sa_cashbillid", offsettingCashbillid);
         return queryCashbillMain();
     }
+
+    public Object getCellFormatValue(Cell cell) {
+        Object cellValue = null;
+        if (cell != null) {
+            // 判断cell类型
+            CellType cellType = cell.getCellType();
+            switch (cellType) {
+                case NUMERIC: {
+                    if (DateUtil.isCellDateFormatted(cell)) {
+                        short num = cell.getCellStyle().getDataFormat();
+                        String format = "YYYY-mm-dd";
+                        SimpleDateFormat df = new SimpleDateFormat(format);
+                        cellValue = df.format(cell.getDateCellValue());
+                    } else {
+                        cell.setCellType(CellType.STRING); // 将数值型cell设置为string型
+                        cellValue = cell.getStringCellValue();
+                    }
+                    break;
+                }
+                case FORMULA: {
+                    // 判断cell是否为日期格式
+                    if (DateUtil.isCellDateFormatted(cell)) {
+                        // 转换为日期格式YYYY-mm-dd
+                        cellValue = cell.getDateCellValue();
+                    } else {
+                        // 数字
+                        cellValue = String.valueOf(cell.getNumericCellValue());
+                    }
+                    break;
+                }
+                case STRING: {
+                    cellValue = cell.getRichStringCellValue().getString();
+                    break;
+                }
+                default:
+                    cellValue = cell.getRichStringCellValue().getString();
+                    break;
+            }
+        } else {
+            cellValue = "";
+        }
+        return cellValue;
+    }
+
+    public XSSFSheet addSheetIncome(ExcelFactory excelFactory, String sheetname, Rows datarows,
+                              HashMap<String, String> titlemap) {
+        ArrayList<String> keylist = datarows.getFieldList();
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+
+        XSSFCellStyle xssfCellStyle1 = xssfFWorkbook.createCellStyle();
+        XSSFFont font = xssfFWorkbook.createFont();
+
+        font.setColor((short) 0xa);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        xssfCellStyle1.setFont(font);
+
+        IncomeExportExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = IncomeExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = IncomeExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = IncomeExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        IncomeExportExcel.batchDetailErr(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, xssfFWorkbook);// 写入标题
+
+        for (int n = 0; n < datarows.size(); n++) {
+            Row row = datarows.get(n);
+            XSSFRow datarow = sheet.createRow(n + 3);
+            for (int i1 = 0; i1 < keylist.size(); i1++) {
+                Class fieldclazztype = datarows.getFieldMeta(keylist.get(i1)).getFieldtype();
+                if (fieldclazztype == Integer.class) {
+                    datarow.createCell(i1).setCellValue(row.getInteger((String) keylist.get(i1)).intValue());
+                } else if (fieldclazztype == Long.class) {
+                    datarow.createCell(i1).setCellValue(row.getLong((String) keylist.get(i1)));
+                } else if (fieldclazztype == Float.class) {
+                    datarow.createCell(i1).setCellValue(row.getFloat((String) keylist.get(i1)));
+                } else if (fieldclazztype == Double.class) {
+                    datarow.createCell(i1).setCellValue(row.getDouble((String) keylist.get(i1)));
+                } else {
+                    datarow.createCell(i1).setCellValue(row.getString((String) keylist.get(i1)));
+                }
+                if (i1 == 6) {
+                    datarow.getCell(i1).setCellStyle(xssfCellStyle1);
+                }
+            }
+        }
+        return sheet;
+    }
+
+    public XSSFSheet addSheetPay(ExcelFactory excelFactory, String sheetname, Rows datarows,
+                                    HashMap<String, String> titlemap) {
+        ArrayList<String> keylist = datarows.getFieldList();
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+
+        XSSFCellStyle xssfCellStyle1 = xssfFWorkbook.createCellStyle();
+        XSSFFont font = xssfFWorkbook.createFont();
+
+        font.setColor((short) 0xa);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        xssfCellStyle1.setFont(font);
+
+        PayExportExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = PayExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = PayExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = PayExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        PayExportExcel.batchDetailErr(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, xssfFWorkbook);// 写入标题
+
+        for (int n = 0; n < datarows.size(); n++) {
+            Row row = datarows.get(n);
+            XSSFRow datarow = sheet.createRow(n + 3);
+            for (int i1 = 0; i1 < keylist.size(); i1++) {
+                Class fieldclazztype = datarows.getFieldMeta(keylist.get(i1)).getFieldtype();
+                if (fieldclazztype == Integer.class) {
+                    datarow.createCell(i1).setCellValue(row.getInteger((String) keylist.get(i1)).intValue());
+                } else if (fieldclazztype == Long.class) {
+                    datarow.createCell(i1).setCellValue(row.getLong((String) keylist.get(i1)));
+                } else if (fieldclazztype == Float.class) {
+                    datarow.createCell(i1).setCellValue(row.getFloat((String) keylist.get(i1)));
+                } else if (fieldclazztype == Double.class) {
+                    datarow.createCell(i1).setCellValue(row.getDouble((String) keylist.get(i1)));
+                } else {
+                    datarow.createCell(i1).setCellValue(row.getString((String) keylist.get(i1)));
+                }
+                if (i1 == 6) {
+                    datarow.getCell(i1).setCellStyle(xssfCellStyle1);
+                }
+            }
+        }
+        return sheet;
+    }
 }

+ 16 - 4
src/custom/restcontroller/webmanage/sale/order/OrderItems.java

@@ -194,16 +194,28 @@ public class OrderItems extends Controller {
 //                    return getErrReturnObject().setErrMsg("调整价格不可小于协议价").toString();
 //                }
             }
-
+            if(type.equals("特殊订单")){
+                if(item.getBigDecimalValue("price").compareTo(BigDecimal.ZERO)>0 && item.getBigDecimalValue("amount").compareTo(BigDecimal.ZERO)<=0){
+                    sqlFactory.addParameter("price", item.getBigDecimalValue("price"));
+                    //折前金额(元)
+                    sqlFactory.addParameter("amount", price.multiply(qty));
+                }else if(item.getBigDecimalValue("price").compareTo(BigDecimal.ZERO)<=0 && item.getBigDecimalValue("amount").compareTo(BigDecimal.ZERO)>0){
+                    sqlFactory.addParameter("price",item.getBigDecimalValue("amount").divide(qty,4));
+                    //折前金额(元)
+                    sqlFactory.addParameter("amount", item.getBigDecimalValue("amount"));
+                }
+            }else {
+                sqlFactory.addParameter("price", price);
+                //折前金额(元)
+                sqlFactory.addParameter("amount", price.multiply(qty));
+            }
             //单价,折后价(元),取合同价
             sqlFactory.addParameter("defaultprice", defaultprice);
             //金额,折后金额(元)
             sqlFactory.addParameter("defaultamount", defaultprice.multiply(qty));
             //牌价、市场价(元),标准订单牌价取商品价格,项目订单取合同里的牌价
             sqlFactory.addParameter("marketprice", itemPrice.getMarketprice());
-            sqlFactory.addParameter("price", price);
-            //折前金额(元)
-            sqlFactory.addParameter("amount", price.multiply(qty));
+
 
             sqlList.add(sqlFactory.getSQL());
         }

+ 6 - 1
src/custom/restcontroller/webmanage/sale/order/SQL/订单_详情.sql

@@ -51,7 +51,10 @@ SELECT t1.sa_orderid,
        t12.remarks                                                                                         optiontyperemarks,
        t13.remarks                                                                                         saletyperemarks,
        t1.projectnote,
-       t8.erpbillno
+       t8.erpbillno,
+       t15.accountname,
+       t14.creditquota,
+       t14.balance
 FROM sa_order t1
          LEFT JOIN sys_enterprise t2 ON t2.sys_enterpriseid = t1.sys_enterpriseid and t2.siteid = t1.siteid
          LEFT JOIN sa_brand t3 ON t3.sa_brandid = t1.sa_brandid
@@ -78,5 +81,7 @@ FROM sa_order t1
                     WHERE optiontypeid in (SELECT optiontypeid from sys_optiontype WHERE typename = 'saletype')) t13
                    ON t1.saletype = t13.value
 
+         left join sa_accountbalance t14 on t1.sys_enterpriseid=t14.sys_enterpriseid and t1.sa_accountclassid=t14.sa_accountclassid and t1.siteid=t14.siteid
+         left join sa_accountclass t15 on t1.sa_accountclassid=t15.sa_accountclassid and t1.siteid=t15.siteid
 WHERE t1.sa_orderid = $sa_orderid$
   AND t1.siteid = $siteid$