Browse Source

图片素材消耗模块改版

syh 4 years ago
parent
commit
df6275d100

+ 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;
     }

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">