소스 검색

Merge remote-tracking branch 'origin/test' into test

zhouzeyu@c-top.com.cn 3 년 전
부모
커밋
16122592a3

+ 9 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/ExportReportController.java

@@ -35,4 +35,13 @@ public class ExportReportController {
     }
     }
 
 
 
 
+    @ApiOperation(value = "财务结算-结算单导出-快手", notes = "财务结算-结算单导出-快手")
+    @GetMapping(value = "/settlementReportKuaiShou")
+    public Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
+
+        return reportSettlementService.settlementReportKuaiShou(paramsVo,response);
+
+    }
+
+
 }
 }

+ 90 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SettlementReportKuaiShouVo.java

@@ -0,0 +1,90 @@
+package org.jeecg.ctop.finance.settlement.entity.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *
+ * @description: 快手 结算单
+ * @return:
+ * @author: zianY
+ */
+@Data
+public class SettlementReportKuaiShouVo implements Serializable {
+
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @ApiModelProperty(value = "账户ID")
+    private String accountId;
+    /**
+     * 时间
+     */
+    @ApiModelProperty(value = "时间")
+    private String date;
+    /**
+     * 总花费(元)
+     */
+    @ApiModelProperty(value = "总花费(元)")
+    private String dailyCharge;
+    /**
+     * 充值话费(元)
+     */
+    @ApiModelProperty(value = "充值花费(元)")
+    private String realCharged;
+    /**
+     * 框返花费(元)
+     */
+    @ApiModelProperty(value = "框返花费(元)")
+    private String contractRebateRealCharged;
+    /**
+     * 激励花费(元)
+     */
+    @ApiModelProperty(value = "激励花费(元)")
+    private String directRebateRealCharged;
+    /**
+     * 转入(元)
+     */
+    @ApiModelProperty(value = "转入(元)")
+    private String dailyTransferIn;
+    /**
+     * 转出(元)
+     */
+    @ApiModelProperty(value = "转出(元)")
+    private String dailyTransferOut;
+    /**
+     * 日终结余(元)
+     */
+    @ApiModelProperty(value = "日终结余(元)")
+    private String balance;
+    /**
+     * 充值转入(元)
+     */
+    @ApiModelProperty(value = "充值转入(元)")
+    private String realRecharged;
+    /**
+     * 框返转入(元)
+     */
+    @org.jeecgframework.poi.excel.annotation.Excel(name = "框返转入(元)", width = 15)
+    @ApiModelProperty(value = "框返转入(元)")
+    private String contractRebateRealRecharged;
+    /**
+     * 激励转入(元)
+     */
+    @ApiModelProperty(value = "激励转入(元)")
+    private String directRebateRealRecharged;
+
+    private String ksId;
+
+
+
+}

+ 9 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -5,6 +5,7 @@ import io.lettuce.core.dynamic.annotation.Param;
 import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.pojo.ctopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -26,6 +27,13 @@ public interface ReportSettlementMapper {
      */
      */
     List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance(SettlementFileParamsVo paramsVo);
     List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance(SettlementFileParamsVo paramsVo);
 
 
+    /**
+     * 获取快手 账户 日流水信息 根据账户id 和 年月 查询数据
+     * @param paramsVo
+     * @return
+     */
+    List<SettlementReportKuaiShouVo> getAccountTransactionDayKuaiShou(SettlementFileParamsVo paramsVo);
+
 
 
     /**
     /**
      * 查询 头条 账户id
      * 查询 头条 账户id
@@ -35,7 +43,7 @@ public interface ReportSettlementMapper {
 
 
     /**
     /**
      * 查询 头条 账户 图片
      * 查询 头条 账户 图片
-     * @param paramsVo
+     * @param accountId
      * @return
      * @return
      */
      */
    List<String> getAccountImagesBytedance(String accountId);
    List<String> getAccountImagesBytedance(String accountId);

+ 22 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml

@@ -51,6 +51,28 @@
 
 
 
 
 
 
+    <!-- 获取快手 账户 日流水信息 -->
+    <select id="getAccountTransactionDayKuaiShou" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
+        select t.*,c.auth_name as accountName,
+               base.user_id as ksId from (select id,
+                                                           account_id,
+                                                        date,DATE_FORMAT(date,'%Y-%m') as uploadYears,
+                                                        daily_charge,real_charged,contract_rebate_real_charged,direct_rebate_real_charged,
+                                                        daily_transfer_in,daily_transfer_out,balance,
+                                                        real_recharged,contract_rebate_real_recharged,direct_rebate_real_recharged,
+                                                      create_time
+                                                    from
+                                                        ctop_kuaishou_daily_flows
+                                                    where account_id = #{accountId}
+                                                   )t
+                                                       LEFT JOIN ctop_user_allocation c on t.account_id = c.account_id
+                                                       LEFT JOIN ctop_kuaishou_advertiser_base_info base on base.account_id = t.account_id
+        where uploadYears = #{uploadYears}
+    </select>
+
+
+
+
 
 
 
 
 </mapper>
 </mapper>

+ 2 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/IReportSettlementService.java

@@ -16,4 +16,6 @@ public interface IReportSettlementService {
 
 
     Result settlementReportBytedance(SettlementFileParamsVo paramsVo,HttpServletResponse response);
     Result settlementReportBytedance(SettlementFileParamsVo paramsVo,HttpServletResponse response);
 
 
+    Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo,HttpServletResponse response);
+
 }
 }

+ 189 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java

@@ -9,6 +9,7 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo;
 import org.jeecg.ctop.finance.settlement.mapper.ReportSettlementMapper;
 import org.jeecg.ctop.finance.settlement.mapper.ReportSettlementMapper;
 import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
 import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
 import org.jeecg.ctop.finance.utils.createExcelByTemplate;
 import org.jeecg.ctop.finance.utils.createExcelByTemplate;
@@ -206,7 +207,194 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             response.setHeader("Pragma", "no-cache");
             response.setHeader("Pragma", "no-cache");
             response.setHeader("Cache-Control", "no-cache");
             response.setHeader("Cache-Control", "no-cache");
             response.setDateHeader("Expires", 0);
             response.setDateHeader("Expires", 0);
-            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("文件名称.xlsx", "UTF-8"));
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(paramsVo.getUploadYears()+"头条结算单.xlsx", "UTF-8"));
+            OutputStream output = response.getOutputStream();
+            BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
+            wb.write(bufferedOutPut);
+            bufferedOutPut.flush();
+            bufferedOutPut.close();
+            output.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("====>>>>", e.getMessage());
+            return Result.errorMsg(e.getMessage());
+        }
+        return null;
+    }
+
+
+
+    @Override
+    public Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
+
+        try {
+
+            //第一步创建workbook
+            HSSFWorkbook wb = new HSSFWorkbook();
+
+            //设置样式
+            HSSFCellStyle style = wb.createCellStyle();
+            style.setAlignment(HorizontalAlignment.CENTER);//水平居中
+
+            //设置字体
+            HSSFFont font = wb.createFont();
+            font.setFontName("黑体");
+            font.setFontHeightInPoints((short) 12);//设置字体大小
+            style.setFont(font);
+
+            //查询 账户id
+            List<String> accountIdList = reportSettlementMapper.getAccountIdBytedance(paramsVo);
+
+            if (Check.isNull(accountIdList)){
+                return Result.errorMsg("该广告主和产品下无法查询到绑定的快手账户信息。");
+            }
+
+            int num = 0;
+
+            for (int k = 0; k < accountIdList.size(); k++) {
+
+                String accountId = accountIdList.get(k);
+                paramsVo.setAccountId(accountId);
+
+                //获取账户 日流水数据  根据账户id 和 年月 查询数据
+                List<SettlementReportKuaiShouVo> settlementList = reportSettlementMapper.getAccountTransactionDayKuaiShou(paramsVo);
+                if (Check.isNull(settlementList)){
+                    num++;
+                    continue;
+                }
+
+                //2:创建sheet 设置sheet名称
+                HSSFSheet sheet = wb.createSheet(accountId);
+
+                //画图的顶级管理器,一个sheet只能获取一个 (插入图片时 使用)
+                HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
+
+                //3:添加 第一行单元格
+                HSSFRow row0 = sheet.createRow(0);
+                HSSFCell cell0 = row0.createCell(0);
+                //设置 第一行 表头
+                cell0.setCellValue(paramsVo.getUploadYears()+"-快手结算单");
+                CellRangeAddress region = new CellRangeAddress(0, 0, 0, 10);
+                sheet.addMergedRegion(region);//合并行
+                cell0.setCellStyle(style);
+
+                //4:添加表头2行
+                HSSFRow row = sheet.createRow(1);
+
+                //5:创建第2行的单元格
+                HSSFCell cell = row.createCell(0);     //第一个单元格
+                cell.setCellValue("   日期   ");         //设定值
+                cell.setCellStyle(style);          //内容居中
+
+                cell = row.createCell(1);
+                cell.setCellValue("      账户快手ID      ");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(2);
+                cell.setCellValue("      广告主账户ID      ");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(3);
+                cell.setCellValue("      日总花费      ");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(4);
+                cell.setCellValue("      充值花费      ");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(5);
+                cell.setCellValue("框返花费");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(6);
+                cell.setCellValue("激励花费");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(7);
+                cell.setCellValue("充值转入");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(8);
+                cell.setCellValue("框返转入");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(9);
+                cell.setCellValue("激励转入");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(10);
+                cell.setCellValue("总转入");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(11);
+                cell.setCellValue("转出");
+                cell.setCellStyle(style);
+
+                cell = row.createCell(12);
+                cell.setCellValue("日终结余");
+                cell.setCellStyle(style);
+
+
+
+
+                for (int i = 0; i < settlementList.size(); i++) {
+                    SettlementReportKuaiShouVo vo = settlementList.get(i);
+                    //创建行 (表头占0-1行 所以 从 2开始)
+                    row = sheet.createRow(i + 2);
+                    sheet.autoSizeColumn(0, true);
+                    sheet.autoSizeColumn(i + 1, true);
+                    //创建单元格并且添加数据
+                    row.createCell(0).setCellValue(vo.getDate());
+                    row.createCell(1).setCellValue(vo.getKsId());
+                    row.createCell(2).setCellValue(vo.getAccountId());
+                    row.createCell(3).setCellValue(vo.getDailyCharge());
+                    row.createCell(4).setCellValue(vo.getRealCharged());
+                    row.createCell(5).setCellValue(vo.getContractRebateRealCharged());
+                    row.createCell(6).setCellValue(vo.getDirectRebateRealCharged());
+                    row.createCell(7).setCellValue(vo.getRealRecharged());
+                    row.createCell(8).setCellValue(vo.getContractRebateRealRecharged());
+                    row.createCell(9).setCellValue(vo.getDirectRebateRealRecharged());
+                    row.createCell(10).setCellValue(vo.getDailyTransferIn());
+                    row.createCell(11).setCellValue(vo.getDailyTransferOut());
+                    row.createCell(12).setCellValue(vo.getBalance());
+                }
+
+                //先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray
+                ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+
+                //查询 图片 url
+                List<String> imageUrlList = reportSettlementMapper.getAccountImagesBytedance(accountId);
+
+                if (!Check.isNull(imageUrlList)){
+                    for (int j = 0; j < imageUrlList.size(); j++) {
+                        String imagePath = imageUrlList.get(j);
+                        //通过图片网络地址 获取输入流
+                        InputStream is = createExcelByTemplate.getInputStreamByUrl(imagePath);
+                        BufferedImage bufferImg = ImageIO.read(is);
+                        ImageIO.write(bufferImg, imagePath.substring(imagePath.lastIndexOf(".") + 1), byteArrayOut);
+                        //anchor主要用于设置图片的属性
+                        int startIndex = settlementList.size()+7;
+
+                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 255, 255, (short) 2, startIndex+(5*j)+50*j, (short) 10, startIndex+(5*j)+50*(j+1));
+                        //HSSFClientAnchor anchor2 = new HSSFClientAnchor(0, 0, 255, 255, (short) 5, settlementList.size() + 40, (short) 10, 40 * 2);
+                        anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
+                        //插入图片
+                        patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG));
+                    }
+                }
+
+            }
+
+            if(accountIdList.size() == num){
+                return Result.errorMsg("暂无数据。");
+            }
+
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+            response.setHeader("Pragma", "no-cache");
+            response.setHeader("Cache-Control", "no-cache");
+            response.setDateHeader("Expires", 0);
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(paramsVo.getUploadYears()+"快手结算单.xlsx", "UTF-8"));
             OutputStream output = response.getOutputStream();
             OutputStream output = response.getOutputStream();
             BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
             BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
             wb.write(bufferedOutPut);
             wb.write(bufferedOutPut);