yumeng 1 gadu atpakaļ
vecāks
revīzija
724eea6e6b

+ 1 - 2
ruixuan-live/src/main/java/com/ruixuan/bytedance/controller/BytedancePromoterOrderListController.java

@@ -564,8 +564,7 @@ public class BytedancePromoterOrderListController extends BaseController {
             @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
             @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
             @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
-            @ApiParam("用户ID") @RequestParam(value = "userId", required = false) String userId
-    ) throws IOException {
+            @ApiParam("用户ID") @RequestParam(value = "userId", required = false) String userId) throws IOException {
         Map<String, Object> requestMap = new HashMap<>();
         if (!Check.isNull(orderStartDate)) {
             Integer start = DateUtils.getIntegerTime(orderStartDate);

+ 63 - 1
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/controller/JiaoYangReportController.java

@@ -5,6 +5,7 @@ import com.ruixuan.common.core.controller.BaseController;
 import com.ruixuan.common.core.page.TableDataInfo;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.DateUtils;
+import com.ruixuan.data.utils.ExportExcelUtils;
 import com.ruixuan.jiaoyang.service.IJiaoYangReportService;
 import com.ruixuan.system.service.ISysDeptService;
 import com.ruixuan.system.service.ISysRoleService;
@@ -12,12 +13,18 @@ import com.ruixuan.system.service.ISysUserService;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.SneakyThrows;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -268,7 +275,7 @@ public class JiaoYangReportController extends BaseController {
     public JSONObject promoterStatistics(
             @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
             @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
-            @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,Long userId) {
+            @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate, Long userId) {
         Map<String, Object> requestMap = new HashMap<>();
         String roleId = sysRoleService.getRoleBYUserId(userId);
         if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId)) {
@@ -312,6 +319,45 @@ public class JiaoYangReportController extends BaseController {
     }
 
 
+    @GetMapping("/exportClipCooperation")
+    public void exportClipCooperation(HttpServletRequest request, HttpServletResponse response, String statDate, Long promoterId, String promoterName) throws IOException {
+        Long date = Long.valueOf(statDate.replace("-", ""));
+        List<JSONObject> list = jiaoYangReportService.getClipCooperation(date, promoterId, promoterName);
+        List<List<Object>> exportList = new ArrayList<>();
+        if (!Check.isNull(list)) {
+            for (int i = 0; i < list.size(); i++) {
+                JSONObject data = list.get(i);
+                List<Object> export = new ArrayList();
+                export.add(data.getString("clipId"));
+                export.add(data.getString("clipName"));
+                export.add(data.getString("commissionRateView"));
+                export.add(data.getString("fansNum"));
+                export.add(data.getString("status"));
+                export.add(data.getString("shopScore"));
+                export.add(data.getString("clipGmv30d"));
+                export.add(data.getString("authItemGmv30d"));
+                export.add(data.getString("videoCount"));
+                export.add(data.getString("videoShow"));
+                export.add(data.getString("terminationReason"));
+                exportList.add(export);
+            }
+        }
+        String[] headers = {"达人ID", "达人名称", "佣金率", "粉丝数", "状态", "口碑评分", "二创GMV", "授权商品GMV", "二创作者挂车短视频发布量", "二创作者挂车短视频曝光量", "状态备注"};
+        OutputStream os = response.getOutputStream();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        eeu.exportExcel(workbook, 0, "二创信息", headers, exportList);
+        this.setResponseHeader(response, "二创信息.xls");
+        try {
+            workbook.write(os);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        os.flush();
+        os.close();
+    }
+
+
     @GetMapping("/getClipCooperation")
     public TableDataInfo list(String statDate, Long promoterId, String promoterName) {
         Long date = Long.valueOf(statDate.replace("-", ""));
@@ -751,5 +797,21 @@ public class JiaoYangReportController extends BaseController {
         return timeIntervalRatioJson;
     }
 
+    //发送响应流方法
+    public void setResponseHeader(HttpServletResponse response, String fileName) {
+        try {
+            try {
+                fileName = new String(fileName.getBytes(), "ISO8859-1");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            response.setContentType("application/octet-stream;charset=ISO8859-1");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.addHeader("Pargam", "no-cache");
+            response.addHeader("Cache-Control", "no-cache");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
 
 }

+ 13 - 18
ruixuan-live/src/main/resources/mapper/jiaoyang/JiaoYangReportMapper.xml

@@ -69,7 +69,8 @@
             and clip_nick_name like concat(concat('%',#{promoterNickName}),'%')
         </if>
         group by clip_user_id) t
-        left join (select clip_id,head_img as 'headImg' from jy_clip_cooperation where stat_date = DATE_FORMAT(NOW(),'%Y%m%d') ) tt on t.promoterId = tt.clip_id
+        left join (select clip_id,head_img as 'headImg' from jy_clip_cooperation where stat_date =
+        DATE_FORMAT(NOW(),'%Y%m%d') ) tt on t.promoterId = tt.clip_id
         left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
         order by t.orderNum desc
 
@@ -120,7 +121,8 @@
             </foreach>
         </if>
         group by clip_user_id) t
-        left join ( select *  from jy_clip_cooperation where stat_date = DATE_FORMAT(NOW(),'%Y%m%d')) tt on t.promoterId = tt.clip_id
+        left join ( select * from jy_clip_cooperation where stat_date = DATE_FORMAT(NOW(),'%Y%m%d')) tt on t.promoterId
+        = tt.clip_id
         left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
         where 1 = 1
         <if test="type != null and type != '' ">
@@ -200,10 +202,7 @@
         order by t.stat_date asc
     </select>
     <select id="getClipCooperation" resultType="com.alibaba.fastjson.JSONObject">
-        select t1.*,
-        ifnull(t2.videoCount30d,0) as 'frontVideoCount30d',
-        ifnull(t1.videoCount30d - t2.videoCount30d,0) as 'groundingCount'
-        from (select clip_id as 'clipId',
+        select clip_id as 'clipId',
         clip_name as 'clipName',
         head_img as 'headImg',
         fans_num as 'fansNum',
@@ -224,21 +223,17 @@
         shop_score as 'shopScore',
         clip_gmv_30d as 'clipGmv30d',
         auth_item_gmv_30d as 'authItemGmv30d',
-        video_count_30d as 'videoCount30d',
+        video_count as 'videoCount',
+        video_count as 'videoShow',
         stat_date as 'statDate'
         from jy_clip_cooperation
-        where stat_date = #{date}) t1
-        left join (select clip_id as 'clipId',
-        video_count_30d as 'videoCount30d'
-        from jy_clip_cooperation
-        where stat_date = date_format(date_sub(#{date}, interval 1 day), '%Y%m%d')) t2
-        on t1.clipId = t2.clipId
-        where 1 = 1
+        where
+        stat_date = #{date}
         <if test="promoterId != null and promoterId != ''">
-            and t1.clipId = #{promoterId}
+            and clipId = #{promoterId}
         </if>
         <if test="promoterName != null and promoterName != ''">
-            and t1.clipName like concat(concat('%',#{promoterName}),'%')
+            and clipName like concat(concat('%',#{promoterName}),'%')
         </if>
     </select>
     <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
@@ -614,8 +609,8 @@
     <select id="getPromoterIdsByUserIds" resultType="java.lang.Long">
         select promoter_id from jy_kuaishou_promoter where
         1 = 1
-        and  user_id in
-        <foreach collection="userIds" item="userId" separator=","  open="(" close=")">
+        and user_id in
+        <foreach collection="userIds" item="userId" separator="," open="(" close=")">
             #{userId}
         </foreach>
     </select>