Ver código fonte

骄阳数据

yumeng 1 ano atrás
pai
commit
fdbf948074

+ 253 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/controller/JiaoYangReportController.java

@@ -0,0 +1,253 @@
+package com.ruixuan.jiaoyang.controller;
+
+import com.alibaba.fastjson.JSONObject;
+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.jiaoyang.service.IJiaoYangReportService;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+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 java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/jy/report")
+public class JiaoYangReportController extends BaseController {
+    @Autowired
+    private IJiaoYangReportService jiaoYangReportService;
+
+
+    /**
+     * 商品数据
+     *
+     * @param itemId
+     * @param itemTitle
+     * @param orderStartDate
+     * @param orderEndDate
+     * @param fieId
+     * @param sort
+     * @return
+     */
+    @GetMapping("/item")
+    @ApiOperation(value = "商品列表")
+    public TableDataInfo item(
+            @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
+            @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("排序字段") @RequestParam(value = "fieId", required = false) String fieId,
+            @ApiParam("排序方式") @RequestParam(value = "sort", required = false) String sort) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Long start = DateUtils.strDateToInt(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Long end = DateUtils.strDateToInt(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(itemId)) {
+            requestMap.put("itemId", itemId);
+        }
+        if (!Check.isNull(itemTitle)) {
+            requestMap.put("itemTitle", itemTitle);
+        }
+
+        requestMap.put("fieId", fieId);
+        requestMap.put("sort", sort);
+
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(-1);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = jiaoYangReportService.item(requestMap);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 商品详情
+     *
+     * @param itemId
+     * @param orderStartDate
+     * @param orderEndDate
+     * @param promoterId
+     * @param promoterNickName
+     * @return
+     */
+    @GetMapping("/itemDetail")
+    @ApiOperation(value = "商品详情")
+    public TableDataInfo itemDetail(
+            @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId,
+            @ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+            @ApiParam("达人Id") @RequestParam(value = "promoterId", required = false) String promoterId,
+            @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Long start = DateUtils.strDateToInt(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Long end = DateUtils.strDateToInt(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(promoterId)) {
+            requestMap.put("promoterId", promoterId);
+        }
+        if (!Check.isNull(itemId)) {
+            requestMap.put("itemId", itemId);
+        }
+        if (!Check.isNull(promoterNickName)) {
+            requestMap.put("itemTitle", promoterNickName);
+        }
+
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(-1);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = jiaoYangReportService.itemDetail(requestMap);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 达人数据
+     *
+     * @param orderStartDate
+     * @param orderEndDate
+     * @param promoterNickName
+     * @param promoterId
+     * @return
+     */
+    @GetMapping("/promoter")
+    @ApiOperation(value = "达人订单")
+    public TableDataInfo promoter(@ApiParam("订单开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+                                   @ApiParam("订单结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+                                   @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName,
+                                   @ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId) {
+
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Long start = DateUtils.strDateToInt(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Long end = DateUtils.strDateToInt(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(promoterNickName)) {
+            requestMap.put("promoterNickName", promoterNickName);
+        }
+        if (!Check.isNull(promoterId)) {
+            requestMap.put("promoterId", promoterId);
+        }
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(-1);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = jiaoYangReportService.promoter(requestMap);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 达人带货详情
+     *
+     * @param promoterId
+     * @param orderStartDate
+     * @param orderEndDate
+     * @param itemTitle
+     * @param itemId
+     * @return
+     */
+    @GetMapping("/promoterDetail")
+    @ApiOperation(value = "达人带货详情")
+    public TableDataInfo promoterDetail(
+            @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,
+            @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
+            @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) String itemId) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Long start = DateUtils.strDateToInt(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Long end = DateUtils.strDateToInt(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(promoterId)) {
+            requestMap.put("promoterId", promoterId);
+        }
+        if (!Check.isNull(itemId)) {
+            requestMap.put("itemId", itemId);
+        }
+        if (!Check.isNull(itemTitle)) {
+            requestMap.put("itemTitle", itemTitle);
+        }
+
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(-1);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = jiaoYangReportService.anchorOrderDetail(requestMap);
+        return getDataTable(list);
+    }
+
+
+    @GetMapping("/promoterStatistics")
+    @ApiOperation(value = "订单统计")
+    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) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Long start = DateUtils.strDateToInt(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Long end = DateUtils.strDateToInt(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(promoterId)) {
+            requestMap.put("promoterId", promoterId);
+        }
+
+        JSONObject returnJson = new JSONObject();
+        if (Check.isNullMap(requestMap)) {
+            returnJson.put("code", -1);
+            returnJson.put("message", "入参不能为空");
+
+            return returnJson;
+        }
+        List<JSONObject> list = jiaoYangReportService.promoterStatistics(requestMap);
+        returnJson.put("code", 0);
+        returnJson.put("data", list);
+        return returnJson;
+    }
+
+
+}

+ 18 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/mapper/JiaoYangReportMapper.java

@@ -0,0 +1,18 @@
+package com.ruixuan.jiaoyang.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+import java.util.Map;
+
+public interface JiaoYangReportMapper {
+    List<JSONObject> item(Map<String, Object> requestMap);
+
+    List<JSONObject> itemDetail(Map<String, Object> requestMap);
+
+    List<JSONObject> promoter(Map<String, Object> requestMap);
+
+    List<JSONObject> anchorOrderDetail(Map<String, Object> requestMap);
+
+    List<JSONObject> promoterStatistics(Map<String, Object> requestMap);
+}

+ 18 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/service/IJiaoYangReportService.java

@@ -0,0 +1,18 @@
+package com.ruixuan.jiaoyang.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IJiaoYangReportService {
+    List<JSONObject> item(Map<String, Object> requestMap);
+
+    List<JSONObject> itemDetail(Map<String, Object> requestMap);
+
+    List<JSONObject> promoter(Map<String, Object> requestMap);
+
+    List<JSONObject> anchorOrderDetail(Map<String, Object> requestMap);
+
+    List<JSONObject> promoterStatistics(Map<String, Object> requestMap);
+}

+ 41 - 0
ruixuan-live/src/main/java/com/ruixuan/jiaoyang/service/impl/JiaoYangReportServiceImpl.java

@@ -0,0 +1,41 @@
+package com.ruixuan.jiaoyang.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.jiaoyang.mapper.JiaoYangReportMapper;
+import com.ruixuan.jiaoyang.service.IJiaoYangReportService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class JiaoYangReportServiceImpl implements IJiaoYangReportService {
+    @Autowired
+    private JiaoYangReportMapper jiaoYangReportMapper;
+
+    @Override
+    public List<JSONObject> item(Map<String, Object> requestMap) {
+        return jiaoYangReportMapper.item(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> itemDetail(Map<String, Object> requestMap) {
+        return jiaoYangReportMapper.itemDetail(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> promoter(Map<String, Object> requestMap) {
+        return jiaoYangReportMapper.promoter(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> anchorOrderDetail(Map<String, Object> requestMap) {
+        return jiaoYangReportMapper.anchorOrderDetail(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> promoterStatistics(Map<String, Object> requestMap) {
+        return jiaoYangReportMapper.promoterStatistics(requestMap);
+    }
+}

+ 183 - 0
ruixuan-live/src/main/resources/mapper/jiaoyang/JiaoYangReportMapper.xml

@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruixuan.jiaoyang.mapper.JiaoYangReportMapper">
+
+    <select id="item" resultType="com.alibaba.fastjson.JSONObject">
+        select t.* from (
+        select
+        t1.item_id as 'itemId',
+        t1.reserve_price as 'reservePrice',
+        t1.item_title as 'itemTitle',
+        t1.image_url as 'imageUrl',
+        count(t1.oid) as 'orderNum',
+        sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
+        sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
+        t1.order_status != 80 then 1 else 0 end), 4) as 'deliveryRadio',
+        t1.commission_rate as 'itemCommissionRate'
+        from jy_order_list t1
+        where 1 = 1
+        <if test="start != null and start != ''">
+            and t1.stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and t1.stat_date &lt;= #{end}
+        </if>
+        <if test="itemId != null and itemId != ''">
+            and t1.item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and t1.item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        group by t1.item_id) t
+        order by ${fieId} ${sort}
+    </select>
+    <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,tt.headImg,ttt.type,ttt.user_name as 'userName'
+        from (
+        select
+        clip_nick_name as 'promoterNickName',
+        clip_user_id as 'promoterId',
+        count(oid) as 'orderNum',
+        sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
+        regimental_promotion_rate as 'regimentalPromotionRate',
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
+        sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
+        then 1 else 0 end),4) as 'deliveryRadio'
+        from jy_order_list
+        where 1= 1
+        <if test="itemId != null and itemId != ''">
+            and item_id = #{itemId}
+        </if>
+        <if test="start != null and start != ''">
+            and stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and stat_date &lt;= #{end}
+        </if>
+        <if test="promoterId != null and promoterId != ''">
+            and clip_user_id = #{promoterId}
+        </if>
+        <if test="promoterNickName != null and promoterNickName != ''">
+            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 ) tt on t.promoterId = tt.clip_id
+        left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
+        order by t.orderNum desc
+
+
+    </select>
+    <select id="promoter" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*,
+        tt.head_img as 'headImg',
+        ttt.type as 'type',
+        ttt.user_name as 'userName'
+        from (
+        select clip_user_id as 'promoterId',
+        clip_nick_name as 'promoterNickName',
+        count(oid) as 'orderNum',
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
+        sum(pay_amount) as 'payAmount',
+        sum(case when order_status != 80 then pay_amount else 0
+        end) as 'validPayAmount',
+        sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(
+        sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
+        when order_status != 80
+        then 1
+        else 0 end),
+        4) as 'deliveryRadio',
+        sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount'
+        from jy_order_list
+        where 1 = 1
+        <if test="start != null and start != '' ">
+            and stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != '' ">
+            and stat_date &lt;= #{end}
+        </if>
+        <if test="promoterId != null and promoterId != '' ">
+            and clip_user_id = #{promoterId}
+        </if>
+        <if test="promoterNickName != null and promoterNickName != '' ">
+            and clip_nick_name like concat(concat('%',#{promoterNickName}),'%')
+        </if>
+        group by clip_user_id) t
+        left join jy_clip_cooperation 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 != '' ">
+            and ttt.type = #{type}
+        </if>
+        order by t.orderNum desc
+    </select>
+    <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
+        select t.*
+        from (select
+        item_title as 'itemTitle',
+        item_id as 'itemId',
+        reserve_price as 'reservePrice',
+        image_url 'imageUrl',
+        count(oid) as 'orderNum',
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
+        sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
+        regimental_promotion_rate as 'regimentalPromotionRate',
+        sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
+        then 1 else 0 end),4) as 'deliveryRadio'
+        from jy_order_list
+        where 1= 1
+        <if test="promoterId != null and promoterId != ''">
+            and clip_user_id = #{promoterId}
+        </if>
+
+        <if test="start != null and start != ''">
+            and stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and stat_date &lt;= #{end}
+        </if>
+        <if test="itemId != null and itemId != ''">
+            and item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        group by item_id) t
+        order by t.orderNum desc
+    </select>
+    <select id="promoterStatistics" resultType="com.alibaba.fastjson.JSONObject">
+        select date_format(t.stat_date, '%Y-%m-%d') as 'date',
+        count(t.oid) as 'orderNum'
+        from (select oid,
+        stat_date
+        from jy_order_list
+        where 1 = 1
+        <if test="promoterId != null and promoterId != ''">
+            and clip_user_id = #{promoterId}
+        </if>
+        <if test="start != null and start != ''">
+            and stat_date &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and stat_date &lt;= #{end}
+        </if>
+        ) t
+        group by t.stat_date
+        order by t.stat_date asc
+    </select>
+
+
+</mapper>