Browse Source

Merge remote-tracking branch 'origin/master'

jiequan.bi 4 years ago
parent
commit
137d670198

+ 184 - 136
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceMusicInfoController.java

@@ -1,9 +1,9 @@
 package org.jeecg.modules.ctop.controller;
 
-import cn.com.ctop.common.module.utils.ResultMapUtils;
-import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.common.module.service.IFileInfoService;
 import cn.com.ctop.crawler.modules.music.entity.BytedanceMusicInfo;
 import cn.com.ctop.crawler.modules.music.service.IBytedanceMusicInfoService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,157 +16,205 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
 import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
 
 /**
  * 音乐信息
+ *
  * @author jeecg-boot
- * @date   2020-10-28
  * @version V1.0
+ * @date 2020-10-28
  */
 @Slf4j
-@Api(tags="音乐信息")
+@Api(tags = "音乐信息")
 @RestController
 @RequestMapping("/ctop/bytedanceMusicInfo")
 public class BytedanceMusicInfoController {
-	@Autowired
-	private IBytedanceMusicInfoService bytedanceMusicInfoService;
+    @Autowired
+    private IBytedanceMusicInfoService bytedanceMusicInfoService;
+    @Autowired
+    private IFileInfoService fileInfoService;
 
-	 @GetMapping(value = "/downLoad")
-	 public Map<String,Object> downLoad(Long id) {
-		Map<String,Object>result = new HashMap<>();
-		if(null == id||id == 0){
-			ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
-			return result;
-		}
-		BytedanceMusicInfo musicInfo = bytedanceMusicInfoService.getById(id);
-		if(null == musicInfo){
-			ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
-			return result;
-		}
-		musicInfo.setDownloadNum(musicInfo.getDownloadNum()+1);
-		bytedanceMusicInfoService.updateById(musicInfo);
-		ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
-		return result;
-	 }
+    @PostMapping(value = "/netEaseDownLoad")
+    public void netEasedownLoad(JSONObject data, HttpServletResponse response) throws Exception {
+        String fileName = data.getString("musicName");
+        String fileUrl = data.getString("musicUrl");
+        String filePath = fileInfoService.downLoadByUrl(fileUrl);
+        File file = new File(filePath);
+        InputStream fis = new BufferedInputStream(new FileInputStream(filePath));
+        byte[] buffer = new byte[fis.available()];
+        fis.read(buffer);
+        fis.close();
+        response.reset();
+        response.setCharacterEncoding("UTF-8");
+        fileName = URLEncoder.encode(fileName, "UTF-8");
+        response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
+        response.addHeader("Content-Length", file.length()+ "");
+        OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
+        response.setContentType("audio/mp3");
+        toClient.write(buffer);
+        toClient.flush();
+        toClient.close();
+    }
 
-	/**
-	  * 分页列表查询
-	 * @param bytedanceMusicInfo
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	@ApiOperation(value="音乐信息-分页列表查询", notes="音乐信息-分页列表查询")
-	@GetMapping(value = "/list")
-	public Result<IPage<BytedanceMusicInfo>> queryPageList(BytedanceMusicInfo bytedanceMusicInfo,
-														   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-														   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-														   HttpServletRequest req) {
-		Result<IPage<BytedanceMusicInfo>> result = new Result<>();
-		QueryWrapper<BytedanceMusicInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceMusicInfo, req.getParameterMap());
-		Page<BytedanceMusicInfo> page = new Page<>(pageNo, pageSize);
-		IPage<BytedanceMusicInfo> pageList = bytedanceMusicInfoService.page(page, queryWrapper);
-		result.setSuccess(true);
-		result.setResult(pageList);
-		return result;
-	}
+    @GetMapping(value = "/downLoad")
+    public void downLoad(Long id, HttpServletResponse response) throws Exception {
+        if (null == id || id == 0) {
+            log.error("抖音音乐文件下载异常:参数异常");
+            return;
+        }
+        BytedanceMusicInfo musicInfo = bytedanceMusicInfoService.getById(id);
+        if (null == musicInfo) {
+            log.error("抖音音乐文件下载异常:音乐数据不存在");
+            return;
+        }
+        musicInfo.setDownloadNum(musicInfo.getDownloadNum() + 1);
+        bytedanceMusicInfoService.updateById(musicInfo);
+        String author = musicInfo.getAuthor();
+        String name = musicInfo.getName();
+        String fileName = author + "-" + name + ".mp3";
+        String filePath = fileInfoService.downLoadByUrl(musicInfo.getMusicUrl());
+        File file = new File(filePath);
+        InputStream fis = new BufferedInputStream(new FileInputStream(filePath));
+        byte[] buffer = new byte[fis.available()];
+        fis.read(buffer);
+        fis.close();
+        response.reset();
+        response.setCharacterEncoding("UTF-8");
+        fileName = URLEncoder.encode(fileName, "UTF-8");
+        response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
+        response.addHeader("Content-Length", buffer.length + "");
+        OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
+        response.setContentType("audio/mp3");
+        toClient.write(buffer);
+        toClient.flush();
+        toClient.close();
+    }
 
-	/**
-	  *   添加
-	 * @param bytedanceMusicInfo
-	 * @return
-	 */
-	@ApiOperation(value="音乐信息-添加", notes="音乐信息-添加")
-	@PostMapping(value = "/add")
-	public Result<BytedanceMusicInfo> add(@RequestBody BytedanceMusicInfo bytedanceMusicInfo) {
-		Result<BytedanceMusicInfo> result = new Result<>();
-		try {
-			bytedanceMusicInfoService.save(bytedanceMusicInfo);
-			result.success("添加成功!");
-		} catch (Exception e) {
-			log.error(e.getMessage(),e);
-			result.error500("操作失败");
-		}
-		return result;
-	}
+    /**
+     * 分页列表查询
+     *
+     * @param bytedanceMusicInfo
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @ApiOperation(value = "音乐信息-分页列表查询", notes = "音乐信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<BytedanceMusicInfo>> queryPageList(BytedanceMusicInfo bytedanceMusicInfo,
+                                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                           HttpServletRequest req) {
+        Result<IPage<BytedanceMusicInfo>> result = new Result<>();
+        QueryWrapper<BytedanceMusicInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceMusicInfo, req.getParameterMap());
+        Page<BytedanceMusicInfo> page = new Page<>(pageNo, pageSize);
+        IPage<BytedanceMusicInfo> pageList = bytedanceMusicInfoService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
 
-	/**
-	  *  编辑
-	 * @param bytedanceMusicInfo
-	 * @return
-	 */
-	@ApiOperation(value="音乐信息-编辑", notes="音乐信息-编辑")
-	@PutMapping(value = "/edit")
-	public Result<BytedanceMusicInfo> edit(@RequestBody BytedanceMusicInfo bytedanceMusicInfo) {
-		Result<BytedanceMusicInfo> result = new Result<BytedanceMusicInfo>();
-		BytedanceMusicInfo bytedanceMusicInfoEntity = bytedanceMusicInfoService.getById(bytedanceMusicInfo.getId());
-		if(bytedanceMusicInfoEntity==null) {
-			result.error500("未找到对应实体");
-		}else {
-			boolean ok = bytedanceMusicInfoService.updateById(bytedanceMusicInfo);
-			if(ok) {
-				result.success("修改成功!");
-			}
-		}
+    /**
+     * 添加
+     *
+     * @param bytedanceMusicInfo
+     * @return
+     */
+    @ApiOperation(value = "音乐信息-添加", notes = "音乐信息-添加")
+    @PostMapping(value = "/add")
+    public Result<BytedanceMusicInfo> add(@RequestBody BytedanceMusicInfo bytedanceMusicInfo) {
+        Result<BytedanceMusicInfo> result = new Result<>();
+        try {
+            bytedanceMusicInfoService.save(bytedanceMusicInfo);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
 
-		return result;
-	}
+    /**
+     * 编辑
+     *
+     * @param bytedanceMusicInfo
+     * @return
+     */
+    @ApiOperation(value = "音乐信息-编辑", notes = "音乐信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<BytedanceMusicInfo> edit(@RequestBody BytedanceMusicInfo bytedanceMusicInfo) {
+        Result<BytedanceMusicInfo> result = new Result<BytedanceMusicInfo>();
+        BytedanceMusicInfo bytedanceMusicInfoEntity = bytedanceMusicInfoService.getById(bytedanceMusicInfo.getId());
+        if (bytedanceMusicInfoEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = bytedanceMusicInfoService.updateById(bytedanceMusicInfo);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
 
-	/**
-	  *   通过id删除
-	 * @param id
-	 * @return
-	 */
-	@ApiOperation(value="音乐信息-通过id删除", notes="音乐信息-通过id删除")
-	@DeleteMapping(value = "/delete")
-	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
-		try {
-			bytedanceMusicInfoService.removeById(id);
-		} catch (Exception e) {
-			log.error("删除失败",e.getMessage());
-			return Result.error("删除失败!");
-		}
-		return Result.ok("删除成功!");
-	}
+        return result;
+    }
 
-	/**
-	  *  批量删除
-	 * @param ids
-	 * @return
-	 */
-	@ApiOperation(value="音乐信息-批量删除", notes="音乐信息-批量删除")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<BytedanceMusicInfo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		Result<BytedanceMusicInfo> result = new Result<>();
-		if(ids==null || "".equals(ids.trim())) {
-			result.error500("参数不识别!");
-		}else {
-			this.bytedanceMusicInfoService.removeByIds(Arrays.asList(ids.split(",")));
-			result.success("删除成功!");
-		}
-		return result;
-	}
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "音乐信息-通过id删除", notes = "音乐信息-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            bytedanceMusicInfoService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
 
-	/**
-	  * 通过id查询
-	 * @param id
-	 * @return
-	 */
-	@ApiOperation(value="音乐信息-通过id查询", notes="音乐信息-通过id查询")
-	@GetMapping(value = "/queryById")
-	public Result<BytedanceMusicInfo> queryById(@RequestParam(name="id",required=true) String id) {
-		Result<BytedanceMusicInfo> result = new Result<>();
-		BytedanceMusicInfo bytedanceMusicInfo = bytedanceMusicInfoService.getById(id);
-		if(bytedanceMusicInfo==null) {
-			result.error500("未找到对应实体");
-		}else {
-			result.setResult(bytedanceMusicInfo);
-			result.setSuccess(true);
-		}
-		return result;
-	}
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "音乐信息-批量删除", notes = "音乐信息-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<BytedanceMusicInfo> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<BytedanceMusicInfo> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.bytedanceMusicInfoService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "音乐信息-通过id查询", notes = "音乐信息-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<BytedanceMusicInfo> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<BytedanceMusicInfo> result = new Result<>();
+        BytedanceMusicInfo bytedanceMusicInfo = bytedanceMusicInfoService.getById(id);
+        if (bytedanceMusicInfo == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(bytedanceMusicInfo);
+            result.setSuccess(true);
+        }
+        return result;
+    }
 }

+ 0 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ImageCostController.java

@@ -37,7 +37,6 @@ public class ImageCostController {
 
     @PostMapping("bytedance/cost/export")
     public void bytedanceImageCostExport(@RequestBody JSONObject data, HttpServletResponse response) throws IOException {
-
         SheetInfoVo vo = imageReportDailyService.getbytedanceImageCostVo(data);
         OutputStream outputStream = response.getOutputStream();
         String date = DateUtils.formatDate(new Date());

+ 36 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ImageReportDailyServiceImpl.java

@@ -31,6 +31,14 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
     @Override
     public Map<String,Object> bytedanceImageCost(JSONObject data) {
         Map<String,Object>result = new HashMap<>();
+        String order = data.getString("order");
+        if(null == order|| "".equals(order.trim())){
+            order = "desc";
+        }
+        String target = data.getString("target");
+        if(null == target|| "".equals(target.trim())){
+            target = "cost";
+        }
         String startDate = data.getString("startDate");
         if(null == startDate|| "".equals(startDate.trim())){
             startDate = null;
@@ -56,7 +64,7 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
             pageSize = 10;
         }
         PageHelper.startPage(pageNumber,pageSize);
-        List<BytedanceImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code);
+        List<BytedanceImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code,order,target);
         PageInfo<BytedanceImageCostVO> pageInfo = new PageInfo<>(vos);
         result.put("data",pageInfo);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
@@ -66,6 +74,14 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
     @Override
     public SheetInfoVo getbytedanceImageCostVo(JSONObject data) {
         SheetInfoVo sheetInfoVo = new SheetInfoVo<BytedanceImageCostVOEntity>();
+        String order = data.getString("order");
+        if(null == order|| "".equals(order.trim())){
+            order = "desc";
+        }
+        String target = data.getString("target");
+        if(null == target|| "".equals(target.trim())){
+            target = "cost";
+        }
         String startDate = data.getString("startDate");
         if(null == startDate|| "".equals(startDate.trim())){
             startDate = null;
@@ -82,7 +98,7 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
         if(null == code|| "".equals(code.trim())){
             code = null;
         }
-        List<BytedanceImageCostVOEntity>details = bytedanceReportMaterialDailyMapper.bytedanceImageCostEntity(startDate,endDate,accountList,code);
+        List<BytedanceImageCostVOEntity>details = bytedanceReportMaterialDailyMapper.bytedanceImageCostEntity(startDate,endDate,accountList,code,order,target);
         sheetInfoVo.setDetails(details);
         return sheetInfoVo;
     }
@@ -90,6 +106,14 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
     @Override
     public Map<String, Object> kuaishouImageCost(JSONObject data) {
         Map<String,Object>result = new HashMap<>();
+        String order = data.getString("order");
+        if(null == order|| "".equals(order.trim())){
+            order = "desc";
+        }
+        String target = data.getString("target");
+        if(null == target|| "".equals(target.trim())){
+            target = "cost";
+        }
         String startDate = data.getString("startDate");
         if(null == startDate|| "".equals(startDate.trim())){
             startDate = null;
@@ -115,7 +139,7 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
             pageSize = 10;
         }
         PageHelper.startPage(pageNumber,pageSize);
-        List<KuaishouImageCostVO> vos = kuaishouReportDailyImageMapper.imageCost(startDate,endDate,accountList,code);
+        List<KuaishouImageCostVO> vos = kuaishouReportDailyImageMapper.imageCost(startDate,endDate,accountList,code,order,target);
         PageInfo<KuaishouImageCostVO> pageInfo = new PageInfo<>(vos);
         result.put("data",pageInfo);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
@@ -125,6 +149,14 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
     @Override
     public SheetInfoVo getkuaishouImageCostVo(JSONObject data) {
         SheetInfoVo sheetInfoVo = new SheetInfoVo<KuaishouImageCostVOEntity>();
+        String order = data.getString("order");
+        if(null == order|| "".equals(order.trim())){
+            order = "desc";
+        }
+        String target = data.getString("target");
+        if(null == target|| "".equals(target.trim())){
+            target = "cost";
+        }
         String startDate = data.getString("startDate");
         if(null == startDate|| "".equals(startDate.trim())){
             startDate = null;
@@ -142,7 +174,7 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
             code = null;
         }
         sheetInfoVo.setSheetName("快手图片消耗统计");
-        List<KuaishouImageCostVOEntity> details = kuaishouReportDailyImageMapper.imageCostEntity(startDate,endDate,accountList,code);
+        List<KuaishouImageCostVOEntity> details = kuaishouReportDailyImageMapper.imageCostEntity(startDate,endDate,accountList,code,order,target);
         sheetInfoVo.setDetails(details);
         return sheetInfoVo;
     }

+ 1 - 1
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -156,7 +156,7 @@ jeecg:
     #webapp文件路径
     webapp: /mnt/webapp
     video-upload: /mnt/upload/video/
-    image-upload: /mnt/upload/image/
+    image-upload: D://data//image//
     kuaishou-agent-image: D://temp.png
     kuaishou-account-captcha-image: D://captcha.png
     chrome-driver: D://chromedriver.exe

File diff suppressed because it is too large
+ 12 - 24
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java


+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/BytedanceImageCostVO.java

@@ -17,4 +17,7 @@ public class BytedanceImageCostVO implements Serializable {
     private Long convert;
     private String userId;
     private String userName;
+    private BigDecimal clickRate;
+    private BigDecimal convertRate;
+    private BigDecimal convertCost;
 }

+ 39 - 9
module-common/src/main/java/cn/com/ctop/common/module/vo/BytedanceImageCostVOEntity.java

@@ -8,23 +8,29 @@ import java.math.BigDecimal;
 public class BytedanceImageCostVOEntity extends BaseRowModel {
     @ExcelProperty(index = 1, value = "图片链接")
     private String imageUrl;
-    @ExcelProperty(index = 1, value = "上传时间")
+    @ExcelProperty(index = 2, value = "上传时间")
     private String statDate;
-    @ExcelProperty(index = 1, value = "图片标识")
+    @ExcelProperty(index = 3, value = "图片标识")
     private String signature;
-    @ExcelProperty(index = 1, value = "项目名称")
+    @ExcelProperty(index = 4, value = "项目名称")
     private String projectName;
-    @ExcelProperty(index = 1, value = "消耗")
+    @ExcelProperty(index = 5, value = "消耗")
     private BigDecimal cost;
-    @ExcelProperty(index = 1, value = "点击数")
+    @ExcelProperty(index = 6, value = "点击数")
     private Long click;
-    @ExcelProperty(index = 1, value = "展示数")
+    @ExcelProperty(index = 7, value = "展示数")
     private Long showNum;
-    @ExcelProperty(index = 1, value = "转化数")
+    @ExcelProperty(index = 8, value = "转化数")
     private Long convert;
-    @ExcelProperty(index = 1, value = "平面id")
+    @ExcelProperty(index = 9, value = "点击率")
+    private BigDecimal clickRate;
+    @ExcelProperty(index = 10, value = "转化率")
+    private BigDecimal convertRate;
+    @ExcelProperty(index = 11, value = "转化成本")
+    private BigDecimal convertCost;
+    @ExcelProperty(index = 12, value = "平面id")
     private String userId;
-    @ExcelProperty(index = 1, value = "平面名称")
+    @ExcelProperty(index = 10, value = "平面名称")
     private String userName;
 
     public BytedanceImageCostVOEntity() {
@@ -120,4 +126,28 @@ public class BytedanceImageCostVOEntity extends BaseRowModel {
     public void setUserName(String userName) {
         this.userName = userName;
     }
+
+    public BigDecimal getClickRate() {
+        return clickRate;
+    }
+
+    public void setClickRate(BigDecimal clickRate) {
+        this.clickRate = clickRate;
+    }
+
+    public BigDecimal getConvertRate() {
+        return convertRate;
+    }
+
+    public void setConvertRate(BigDecimal convertRate) {
+        this.convertRate = convertRate;
+    }
+
+    public BigDecimal getConvertCost() {
+        return convertCost;
+    }
+
+    public void setConvertCost(BigDecimal convertCost) {
+        this.convertCost = convertCost;
+    }
 }

+ 7 - 1
module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouImageCostVO.java

@@ -10,9 +10,15 @@ public class KuaishouImageCostVO implements Serializable {
     String imageUrl;
     String signature;
     String projectName;
-    BigDecimal charge;
+    BigDecimal cost;
     Long photoClick;
+    BigDecimal photoClickRate;
     Long photoShow;
+    BigDecimal photoShowCost;
+    Long aclick;
+    BigDecimal aclickCost;
+    Long bclick;
+    BigDecimal bclickRate;
     Long activation;
     Long eventRegister;
     Long eventPay;

+ 78 - 18
module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouImageCostVOEntity.java

@@ -13,28 +13,96 @@ public class KuaishouImageCostVOEntity extends BaseRowModel {
     @ExcelProperty(index = 3, value = "所属项目")
     String projectName;
     @ExcelProperty(index = 4, value = "消耗")
-    BigDecimal charge;
+    BigDecimal cost;
     @ExcelProperty(index = 5, value = "封面点击数")
     Long photoClick;
-    @ExcelProperty(index = 6, value = "封面曝光数")
+    @ExcelProperty(index = 6, value = "封面点击率")
+    BigDecimal photoClickRate;
+    @ExcelProperty(index = 7, value = "封面曝光数")
     Long photoShow;
-    @ExcelProperty(index = 7, value = "激活数")
+    @ExcelProperty(index = 8, value = "千次封面曝光花费")
+    BigDecimal photoShowCost;
+    @ExcelProperty(index = 9, value = "素材曝光数")
+    Long aclick;
+    @ExcelProperty(index = 10, value = "千次素材曝光花费")
+    BigDecimal aclickCost;
+    @ExcelProperty(index = 11, value = "行为数")
+    Long bcilck;
+    @ExcelProperty(index = 12, value = "行为率")
+    BigDecimal bclickRate;
+    @ExcelProperty(index = 13, value = "激活数")
     Long activation;
-    @ExcelProperty(index = 8, value = "注册数")
+    @ExcelProperty(index = 14, value = "注册数")
     Long eventRegister;
-    @ExcelProperty(index = 9, value = "付费数")
+    @ExcelProperty(index = 15, value = "付费数")
     Long eventPay;
-    @ExcelProperty(index = 10, value = "表单提交数")
+    @ExcelProperty(index = 16, value = "表单提交数")
     Long formCount;
-    @ExcelProperty(index = 11, value = "完件数")
+    @ExcelProperty(index = 17, value = "完件数")
     Long eventJinJianApp;
-    @ExcelProperty(index = 12, value = "授信数")
+    @ExcelProperty(index = 18, value = "授信数")
     Long eventCreditGrantApp;
-    @ExcelProperty(index = 13, value = "所属平面id")
+    @ExcelProperty(index = 19, value = "所属平面id")
     String userId;
-    @ExcelProperty(index = 14, value = "所属平面")
+    @ExcelProperty(index = 20, value = "所属平面")
     String userName;
 
+    public BigDecimal getCost() {
+        return cost;
+    }
+
+    public void setCost(BigDecimal cost) {
+        this.cost = cost;
+    }
+
+    public BigDecimal getPhotoClickRate() {
+        return photoClickRate;
+    }
+
+    public void setPhotoClickRate(BigDecimal photoClickRate) {
+        this.photoClickRate = photoClickRate;
+    }
+
+    public BigDecimal getPhotoShowCost() {
+        return photoShowCost;
+    }
+
+    public void setPhotoShowCost(BigDecimal photoShowCost) {
+        this.photoShowCost = photoShowCost;
+    }
+
+    public Long getAclick() {
+        return aclick;
+    }
+
+    public void setAclick(Long aclick) {
+        this.aclick = aclick;
+    }
+
+    public BigDecimal getAclickCost() {
+        return aclickCost;
+    }
+
+    public void setAclickCost(BigDecimal aclickCost) {
+        this.aclickCost = aclickCost;
+    }
+
+    public Long getBcilck() {
+        return bcilck;
+    }
+
+    public void setBcilck(Long bcilck) {
+        this.bcilck = bcilck;
+    }
+
+    public BigDecimal getBclickRate() {
+        return bclickRate;
+    }
+
+    public void setBclickRate(BigDecimal bclickRate) {
+        this.bclickRate = bclickRate;
+    }
+
     public KuaishouImageCostVOEntity() {
     }
 
@@ -62,14 +130,6 @@ public class KuaishouImageCostVOEntity extends BaseRowModel {
         this.projectName = projectName;
     }
 
-    public BigDecimal getCharge() {
-        return charge;
-    }
-
-    public void setCharge(BigDecimal charge) {
-        this.charge = charge;
-    }
-
     public Long getPhotoClick() {
         return photoClick;
     }

+ 13 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyImageMapper.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.vo.KuaishouImageCostVOEntity;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyImage;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -18,11 +19,21 @@ public interface KuaishouReportDailyImageMapper extends BaseMapper<KuaishouRepor
 
     void loadImageDailyReport(Long accountId, String localPath);
 
-    List<KuaishouImageCostVO> imageCost(String startDate, String endDate, JSONArray accountList, String code);
+    List<KuaishouImageCostVO> imageCost(@Param(value = "startDate") String startDate,
+                                        @Param(value = "endDate")String endDate,
+                                        @Param(value = "accountList")JSONArray accountList,
+                                        @Param(value = "code")String code,
+                                        @Param(value = "order")String order,
+                                        @Param(value = "target")String target);
 
     void updateImageReportCode();
 
-    List<KuaishouImageCostVOEntity> imageCostEntity(String startDate, String endDate, JSONArray accountList, String code);
+    List<KuaishouImageCostVOEntity> imageCostEntity(@Param(value = "startDate") String startDate,
+                                                    @Param(value = "endDate")String endDate,
+                                                    @Param(value = "accountList")JSONArray accountList,
+                                                    @Param(value = "code")String code,
+                                                    @Param(value = "order")String order,
+                                                    @Param(value = "target")String target);
 
     void updateImageReportUserId();
 

+ 59 - 31
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyImageMapper.xml

@@ -105,20 +105,34 @@
           set account_id = #{accountId}
     </insert>
     <select id="imageCost" resultType="cn.com.ctop.common.module.vo.KuaishouImageCostVO">
-        select
-        report.cover_url as 'image_url' ,
+        select * from (select
+        report.cover_url as 'imageUrl' ,
         report.cover_id as 'signature',
-        group_concat(distinct p.project_name) AS 'project_name',
-        sum(report.charge) AS 'charge',
-        sum(report.photo_click) AS 'photo_click',
-        sum(report.photo_show) AS 'photo_show',
+        group_concat(distinct p.project_name) AS 'projectName',
+        sum(report.charge) AS 'cost',
+        sum(report.photo_click) AS 'photoClick',
+        (case when sum(report.photo_show)!=0 and sum(report.photo_click)!=0
+        then round(sum(photo_click)/sum(photo_show)*100,2)
+        else 0 end)as 'photoClickRate',
+        sum(report.photo_show) AS 'photoShow',
+        (case when sum(report.charge)!=0 and sum(report.photo_show)!=0
+        then round(sum(charge)/sum(photo_show)*1000,2)
+        else 0 end)as 'photoShowCost',
+        sum(report.aclick) as 'aclick',
+        sum(report.bclick) as 'bclick',
+        (case when sum(report.bclick)!=0 and sum(report.aclick)!=0
+        then round(sum(bclick)/sum(aclick)*100,2)
+        else 0 end)as 'bclickRate',
+        (case when sum(report.charge)!=0 and sum(report.aclick)!=0
+        then round(sum(charge)/sum(aclick)*1000,2)
+        else 0 end)as 'aclickCost',
         sum(report.activation) AS 'activation',
-        sum(report.event_register) AS 'event_register',
-        sum(report.event_pay) AS 'event_pay',
-        sum(report.form_count) AS 'form_count',
-        sum(report.event_jin_jian_app) AS 'event_jin_jian_app',
-        sum(report.event_credit_grant_app) AS 'event_credit_grant_app',
-        report.realname as 'user_name'
+        sum(report.event_register) AS 'eventRegister',
+        sum(report.event_pay) AS 'eventPay',
+        sum(report.form_count) AS 'formCount',
+        sum(report.event_jin_jian_app) AS 'eventJinJianApp',
+        sum(report.event_credit_grant_app) AS 'eventCreditGrantApp',
+        report.realname as 'userName'
         from ctop_kuaishou_report_daily_image report
         left join ctop_user_allocation allocation on allocation.account_id = report.account_id
         left join ctop_project p on p.id = allocation.project_id
@@ -141,31 +155,45 @@
         <if test="code!=null">
             and report.cover_id = #{code}
         </if>
-        group by report.cover_id
-        order by sum(report.charge) desc
+        group by report.cover_id)a
+        order by a.${target} ${order}
     </select>
     <select id="imageCostEntity" resultType="cn.com.ctop.common.module.vo.KuaishouImageCostVOEntity">
-        select
-        report.cover_url as 'image_url' ,
-        report.code as 'signature',
-        group_concat(distinct p.project_name) AS 'project_name',
-        sum(report.charge) AS 'charge',
-        sum(report.photo_click) AS 'photo_click',
-        sum(report.photo_show) AS 'photo_show',
+        select * from (select
+        report.cover_url as 'imageUrl' ,
+        report.cover_id as 'signature',
+        group_concat(distinct p.project_name) AS 'projectName',
+        sum(report.charge) AS 'cost',
+        sum(report.photo_click) AS 'photoClick',
+        (case when sum(report.photo_show)!=0 and sum(report.photo_click)!=0
+        then round(sum(photo_click)/sum(photo_show)*100,2)
+        else 0 end)as 'photoClickRate',
+        sum(report.photo_show) AS 'photoShow',
+        (case when sum(report.charge)!=0 and sum(report.photo_show)!=0
+        then round(sum(charge)/sum(photo_show)*1000,2)
+        else 0 end)as 'photoShowCost',
+        sum(report.aclick) as 'aclick',
+        sum(report.bclick) as 'bclick',
+        (case when sum(report.bclick)!=0 and sum(report.aclick)!=0
+        then round(sum(bclick)/sum(aclick)*100,2)
+        else 0 end)as 'bclickRate',
+        (case when sum(report.charge)!=0 and sum(report.aclick)!=0
+        then round(sum(charge)/sum(aclick)*1000,2)
+        else 0 end)as 'aclickCost',
         sum(report.activation) AS 'activation',
-        sum(report.event_register) AS 'event_register',
-        sum(report.event_pay) AS 'event_pay',
-        sum(report.form_count) AS 'form_count',
-        sum(report.event_jin_jian_app) AS 'event_jin_jian_app',
-        sum(report.event_credit_grant_app) AS 'event_credit_grant_app',
-        report.realname as 'user_name'
+        sum(report.event_register) AS 'eventRegister',
+        sum(report.event_pay) AS 'eventPay',
+        sum(report.form_count) AS 'formCount',
+        sum(report.event_jin_jian_app) AS 'eventJinJianApp',
+        sum(report.event_credit_grant_app) AS 'eventCreditGrantApp',
+        report.realname as 'userName'
         from ctop_kuaishou_report_daily_image report
         left join ctop_user_allocation allocation on allocation.account_id = report.account_id
         left join ctop_project p on p.id = allocation.project_id
         where
         1=1
         and
-        report.code is not null
+        report.cover_id is not null
         <if test="startDate!=null">
             and report.stat_date &gt;= #{startDate}
         </if>
@@ -179,10 +207,10 @@
             </foreach>
         </if>
         <if test="code!=null">
-            and report.code = #{code}
+            and report.cover_id = #{code}
         </if>
-        group by report.code
-        order by sum(report.charge) desc
+        group by report.cover_id)a
+        order by a.${target} ${order}
     </select>
 
     <update id="updateImageReportCode">

+ 6 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java

@@ -35,7 +35,9 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
     List<BytedanceImageCostVO> bytedanceImageCost(@Param("startDate")String startDate,
                                                   @Param("endDate")String endDate,
                                                   @Param("accountList")JSONArray accountList,
-                                                  @Param("code")String code);
+                                                  @Param("code")String code,
+                                                  @Param("order")String order,
+                                                  @Param("target")String target);
 
     void replaceImageBatch(@Param("infos")List<BytedanceReportMaterialDaily> bytedanceReportImageDailyList);
     void updateImageReportCode();
@@ -47,5 +49,7 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
     List<BytedanceImageCostVOEntity> bytedanceImageCostEntity(@Param("startDate")String startDate,
                                                               @Param("endDate")String endDate,
                                                               @Param("accountList")JSONArray accountList,
-                                                              @Param("code")String code);
+                                                              @Param("code")String code,
+                                                              @Param("order")String order,
+                                                              @Param("target")String target);
 }

+ 45 - 24
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml

@@ -239,16 +239,27 @@
         where status = 0
     </select>
     <select id="bytedanceImageCost" resultType="cn.com.ctop.common.module.vo.BytedanceImageCostVO">
-        select round(sum(report.cost),2)                              as 'cost',
-        sum(report.click)                                             as 'click',
-        sum(report.show_material)                                     as 'show_num',
-        sum(report.convert_material)                                  as 'convert',
-        report.image_url                                           as 'image_url',
-        report.material_id                                           as 'signature',
-        group_concat(distinct report.project_name)                    as 'project_name',
-        report.stat_datetime                                          as 'stat_date',
-        report.plane_id as 'user_id',
-        report.plane_name as 'user_name'
+        select * from (
+        select
+        round(sum(report.cost), 2)                 as 'cost',
+        sum(report.click)                          as 'click',
+        (case when sum(report.show_material)!=0 and sum(report.click)!=0
+        then round(sum(report.click)/sum(report.show_material)*100,2)
+        else 0 end)                       as 'clickRate',
+        sum(report.show_material)                  as 'showNum',
+        sum(report.convert_material)               as 'convert',
+        (case when sum(report.convert_material)!=0 and sum(report.click)!=0
+        then round(sum(report.convert_material)/sum(report.click)*100,2)
+        else 0 end)                       as 'convertRate',
+        (case when sum(report.cost)!=0 and sum(report.convert_material)!=0
+        then round(sum(report.cost)/sum(report.convert_material),2)
+        else 0 end)                       as 'convertCost',
+        report.image_url                           as 'imageUrl',
+        report.material_id                         as 'signature',
+        group_concat(distinct report.project_name) as 'projectName',
+        report.stat_datetime                       as 'statDate',
+        report.plane_id                            as 'userId',
+        report.plane_name                          as 'userName'
             from ctop_bytedance_report_image_daily report
             left join ctop_bytedance_image_info imageInfo on imageInfo.material_id = report.material_id
         where
@@ -269,8 +280,7 @@
         <if test="code!=null">
             and report.material_id = #{code}
         </if>
-        group by report.material_id
-        order by sum(report.cost) desc
+        group by report.material_id)a order by a.${target} ${order}
     </select>
 
     <update id="updateImageReportCode">
@@ -328,17 +338,29 @@ where a.plane_id is not null and a.plane_name is null
         and end_date = #{retry.endDate}
     </update>
     <select id="bytedanceImageCostEntity" resultType="cn.com.ctop.common.module.vo.BytedanceImageCostVOEntity">
-        select round(sum(report.cost),2)                              as 'cost',
-        sum(report.click)                                             as 'click',
-        sum(report.show_material)                                     as 'show_num',
-        sum(report.convert_material)                                  as 'convert',
-        report.image_url                                           as 'image_url',
-        report.material_id                                           as 'signature',
-        group_concat(distinct report.project_name)                    as 'project_name',
-        report.stat_datetime                                          as 'stat_date',
-        report.plane_id as 'user_id',
-        report.plane_name as 'user_name'
+        select * from (
+        select
+        round(sum(report.cost), 2)                 as 'cost',
+        sum(report.click)                          as 'click',
+        (case when sum(report.show_material)!=0 and sum(report.click)!=0
+        then round(sum(report.click)/sum(report.show_material)*100,2)
+        else 0 end)                       as 'clickRate',
+        sum(report.show_material)                  as 'showNum',
+        sum(report.convert_material)               as 'convert',
+        (case when sum(report.convert_material)!=0 and sum(report.click)!=0
+        then round(sum(report.convert_material)/sum(report.click)*100,2)
+        else 0 end)                       as 'convertRate',
+        (case when sum(report.cost)!=0 and sum(report.convert_material)!=0
+        then round(sum(report.cost)/sum(report.convert_material),2)
+        else 0 end)                       as 'convertCost',
+        report.image_url                           as 'imageUrl',
+        report.material_id                         as 'signature',
+        group_concat(distinct report.project_name) as 'projectName',
+        report.stat_datetime                       as 'statDate',
+        report.plane_id                            as 'userId',
+        report.plane_name                          as 'userName'
         from ctop_bytedance_report_image_daily report
+        left join ctop_bytedance_image_info imageInfo on imageInfo.material_id = report.material_id
         where
         1=1
         and report.material_id is not null
@@ -357,8 +379,7 @@ where a.plane_id is not null and a.plane_name is null
         <if test="code!=null">
             and report.material_id = #{code}
         </if>
-        group by report.material_id
-        order by sum(report.cost) desc
+        group by report.material_id)a order by a.${target} ${order}
     </select>
 
     <insert id="replaceIntoVideoMaterialBatch">