소스 검색

切片毛利测算修改

yumeng 1 년 전
부모
커밋
1ba870430b

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

@@ -159,7 +159,7 @@ public class JiaoYangReportController extends BaseController {
 
     @GetMapping("/profitData")
     @ApiOperation(value = "商品列表")
-    public JSONObject profitData(String date) throws ParseException {
+    public JSONObject profitData(String date,Integer dataType) throws ParseException {
 
         JSONObject returnJson = new JSONObject();
 
@@ -169,7 +169,7 @@ public class JiaoYangReportController extends BaseController {
             // date 为本月结束时间
             String lastMonthFirstDate = DateUtils.getLastMonthFirstDayByDate(date);// 上个月开始时间
             String lastMonthEndDate = DateUtils.getLastMonthNowDay(date);// 上个月结束时间
-            JSONObject dayData = jiaoYangReportService.dayData(DateUtils.strDateTimsToInt(date), DateUtils.strDateTimsToInt(lastDate));
+            JSONObject dayData = jiaoYangReportService.dayData(DateUtils.strDateTimsToInt(date), DateUtils.strDateTimsToInt(lastDate),dataType);
             JSONArray dayArray = new JSONArray();
             JSONObject obj1 = new JSONObject();
             obj1.put("date", dayData.getString("date"));
@@ -204,7 +204,7 @@ public class JiaoYangReportController extends BaseController {
             dayArray.add(obj3);
             dayArray.add(new JSONObject());
 
-            JSONObject monthData = jiaoYangReportService.monthData(DateUtils.strDateTimsToInt(firstDateByMonth), DateUtils.strDateTimsToInt(date), DateUtils.strDateTimsToInt(lastMonthFirstDate), DateUtils.strDateTimsToInt(lastMonthEndDate));
+            JSONObject monthData = jiaoYangReportService.monthData(DateUtils.strDateTimsToInt(firstDateByMonth), DateUtils.strDateTimsToInt(date), DateUtils.strDateTimsToInt(lastMonthFirstDate), DateUtils.strDateTimsToInt(lastMonthEndDate),dataType);
 
 
             JSONObject obj4 = new JSONObject();

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

@@ -44,9 +44,9 @@ public interface JiaoYangReportMapper {
 
     List<Long> getPromoterIdsByUserIds(@Param("userIds") List<Long> userIds);
 
-    JSONObject dayData(@Param("date") Long date, @Param("lastDate") Long lastDate);
+    JSONObject dayData(@Param("date") Long date, @Param("lastDate") Long lastDate, @Param("dataType") Integer dataType);
 
-    JSONObject monthData(@Param("nowMonthStartDate") Long nowMonthStartDate, @Param("nowMonthEndDate") Long nowMonthEndDate, @Param("lastMonthStartDate") Long lastMonthStartDate, @Param("lastMonthEndDate") Long lastMonthEndDate);
+    JSONObject monthData(@Param("nowMonthStartDate") Long nowMonthStartDate, @Param("nowMonthEndDate") Long nowMonthEndDate, @Param("lastMonthStartDate") Long lastMonthStartDate, @Param("lastMonthEndDate") Long lastMonthEndDate, @Param("dataType") Integer dataType);
 
     List<JSONObject> getTopItem(@Param("date") Long date, @Param("promoterId") Long promoterId, @Param("fieId") String fieId, @Param("sort") String sort);
 

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

@@ -42,9 +42,9 @@ public interface IJiaoYangReportService {
 
     List<Long> getPromoterIdsByUserIds(List<Long> userIds);
 
-    JSONObject dayData(Long date, Long lastDate);
+    JSONObject dayData(Long date, Long lastDate, Integer dataType);
 
-    JSONObject monthData(Long nowMonthStartDate, Long nowMonthEndDate, Long lastMonthStartDate, Long lastMonthEndDate);
+    JSONObject monthData(Long nowMonthStartDate, Long nowMonthEndDate, Long lastMonthStartDate, Long lastMonthEndDate, Integer dataType);
 
     List<JSONObject> getTopItem(Long date, Long promoterId, String fieId, String sort);
 

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

@@ -113,13 +113,13 @@ public class JiaoYangReportServiceImpl implements IJiaoYangReportService {
     }
 
     @Override
-    public JSONObject dayData(Long date, Long lastDate) {
-        return jiaoYangReportMapper.dayData(date, lastDate);
+    public JSONObject dayData(Long date, Long lastDate,Integer dataType) {
+        return jiaoYangReportMapper.dayData(date, lastDate,dataType);
     }
 
     @Override
-    public JSONObject monthData(Long nowMonthStartDate, Long nowMonthEndDate, Long lastMonthStartDate, Long lastMonthEndDate) {
-        return jiaoYangReportMapper.monthData(nowMonthStartDate, nowMonthEndDate, lastMonthStartDate, lastMonthEndDate);
+    public JSONObject monthData(Long nowMonthStartDate, Long nowMonthEndDate, Long lastMonthStartDate, Long lastMonthEndDate,Integer dataType) {
+        return jiaoYangReportMapper.monthData(nowMonthStartDate, nowMonthEndDate, lastMonthStartDate, lastMonthEndDate,dataType);
     }
 
     @Override

+ 112 - 60
ruixuan-live/src/main/resources/mapper/jiaoyang/JiaoYangReportMapper.xml

@@ -36,7 +36,9 @@
 
     </insert>
     <delete id="deleteAuthItem">
-        delete  from jy_auth_order where  1 = 1
+        delete
+        from jy_auth_order
+        where 1 = 1
     </delete>
 
     <select id="item" resultType="com.alibaba.fastjson.JSONObject">
@@ -653,75 +655,123 @@
     </select>
     <select id="dayData" resultType="com.alibaba.fastjson.JSONObject">
         select *,
-       t1.gmv - t2.lastGmv                               as 'gvmGap',
-       t1.orderNum - t2.lastOrderNum                     as 'orderNumGap',
-       t1.validGmv - t2.lastValidGmv                     as 'validGmvGap',
-       t1.validOrderNUm - t2.lastValidOrderNUm           as 'validOrderNumGap',
-       t1.mcnPromotionAmount - t2.lastMcnPromotionAmount as 'mcnPromotionAmountGap',
-       t1.grossMargin - t2.lastGrossMargin               as 'grossMarginGap'
-from (select date_format(#{date},'%Y/%m/%d')                                                                   as 'date',
-             round(sum(pay_amount) / 100, 2)                                              as 'gmv',
-             count(oid)                                                                   as 'orderNum',
-             round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'validGmv',
-             sum(case when order_status != 80 then 1 else 0 end)                          as 'validOrderNum',
-             round(sum(mcn_promotion_amount) / 100, 2)                                    as 'mcnPromotionAmount',
-             round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2)                  as 'grossMargin'
-      from  jy_order_list t1 left join jy_kuaishou_promoter t2
-     on t1.clip_user_id = t2.promoter_id
-      where t1.stat_date = #{date}
-      and t2.type = 1
-      ) t1
-         join (select date_format(#{lastDate} ,'%Y/%m/%d')                                                                       as 'lastDate',
-                      round(sum(pay_amount) / 100, 2)                                              as 'lastGmv',
-                      count(oid)                                                                   as 'lastOrderNum',
-                      round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'lastValidGmv',
-                      sum(case when order_status != 80 then 1 else 0 end)                          as 'lastValidOrderNum',
-                      round(sum(mcn_promotion_amount) / 100, 2)                                    as 'lastMcnPromotionAmount',
-                      round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2)                  as 'lastGrossMargin'
-               from jy_order_list t1 left join jy_kuaishou_promoter t2
-               on t1.clip_user_id = t2.promoter_id
-               where t1.stat_date = #{lastDate}
-               and t2.type = 1
-               ) t2
+        t1.gmv - t2.lastGmv as 'gvmGap',
+        t1.orderNum - t2.lastOrderNum as 'orderNumGap',
+        t1.validGmv - t2.lastValidGmv as 'validGmvGap',
+        t1.validOrderNUm - t2.lastValidOrderNUm as 'validOrderNumGap',
+        t1.mcnPromotionAmount - t2.lastMcnPromotionAmount as 'mcnPromotionAmountGap',
+        t1.grossMargin - t2.lastGrossMargin as 'grossMarginGap'
+        from (select date_format(#{date},'%Y/%m/%d') as 'date',
+        round(sum(pay_amount) / 100, 2) as 'gmv',
+        count(oid) as 'orderNum',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'validGmv',
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNum',
+        round(sum(mcn_promotion_amount) / 100, 2) as 'mcnPromotionAmount',
+        round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
+        from ruixuan.jy_order_list t1
+        where t1.stat_date = #{date}
+        <if test='dataType == "1" '>
+            and t1.clip_user_id in (
+            select promoter_id from ruixuan.jy_kuaishou_promoter
+            where `type` = 1
+            group by promoter_id
+            )
+        </if>
+        <if test=' dataType == "2" '>
+            and t1.clip_user_id not in (
+            select promoter_id from ruixuan.jy_kuaishou_promoter
+            where `type` = 1
+            group by promoter_id
+            )
+        </if>
+        ) t1
+        join (select date_format(#{lastDate} ,'%Y/%m/%d') as 'lastDate',
+        round(sum(pay_amount) / 100, 2) as 'lastGmv',
+        count(oid) as 'lastOrderNum',
+        round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'lastValidGmv',
+        sum(case when order_status != 80 then 1 else 0 end) as 'lastValidOrderNum',
+        round(sum(mcn_promotion_amount) / 100, 2) as 'lastMcnPromotionAmount',
+        round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'lastGrossMargin'
+        from ruixuan.jy_order_list t1
+        where t1.stat_date = #{lastDate}
+        <if test='dataType == "1"'>
+            and t1.clip_user_id in (
+            select promoter_id from ruixuan.jy_kuaishou_promoter
+            where `type` = 1
+            group by promoter_id
+            )
+        </if>
+        <if test='dataType == "2" '>
+            and t1.clip_user_id not in (
+            select promoter_id from ruixuan.jy_kuaishou_promoter
+            where `type` = 1
+            group by promoter_id
+            )
+        </if>
+        ) t2
 
     </select>
     <select id="monthData" resultType="com.alibaba.fastjson.JSONObject">
 
         select *,
-        concat(ROUND((t1.gmv - t2.lastGmv) / t2.lastGmv * 100, 2)         ,'%')       as 'gvmRadio',
+        concat(ROUND((t1.gmv - t2.lastGmv) / t2.lastGmv * 100, 2) ,'%') as 'gvmRadio',
         concat(ROUND((t1.orderNum - t2.lastOrderNum) / t2.lastOrderNum * 100, 2),'%') as 'orderNumRadio',
         concat(ROUND((t1.validGmv - t2.lastValidGmv) / t2.lastValidGmv * 100, 2) ,'%')as 'validGmvRadio',
         concat(ROUND((t1.validOrderNUm - t2.lastValidOrderNUm) / t2.lastValidOrderNUm * 100,
-        2)                                                          ,'%')as 'validOrderNumRadio',
+        2) ,'%')as 'validOrderNumRadio',
         concat(ROUND((t1.mcnPromotionAmount - t2.lastMcnPromotionAmount) / t2.lastMcnPromotionAmount * 100,
-        2)                                                          ,'%')as 'mcnPromotionAmountRadio',
+        2) ,'%')as 'mcnPromotionAmountRadio',
         ROUND((t1.grossMargin - t2.lastGrossMargin) / t2.lastGrossMargin * 100,
-        2)                                                         as 'grossMarginRadio'
-        from (select CONCAT(date_format(#{nowMonthEndDate} ,'%Y/%m/%d') , '合计')                                                     as 'date',
-        round(sum(pay_amount) / 100, 2)                                              as 'gmv',
-        count(oid)                                                                   as 'orderNum',
+        2) as 'grossMarginRadio'
+        from (select CONCAT(date_format(#{nowMonthEndDate} ,'%Y/%m/%d') , '合计') as 'date',
+        round(sum(pay_amount) / 100, 2) as 'gmv',
+        count(oid) as 'orderNum',
         round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'validGmv',
-        sum(case when order_status != 80 then 1 else 0 end)                          as 'validOrderNum',
-        round(sum(mcn_promotion_amount) / 100, 2)                                    as 'mcnPromotionAmount',
-        round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2)                  as 'grossMargin'
-        from jy_order_list t1 left join jy_kuaishou_promoter t2
-        on t1.clip_user_id = t2.promoter_id
+        sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNum',
+        round(sum(mcn_promotion_amount) / 100, 2) as 'mcnPromotionAmount',
+        round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
+        from jy_order_list t1
         where t1.stat_date >= #{nowMonthStartDate}
         and t1.stat_date &lt;= #{nowMonthEndDate}
-        and t2.type = 1
+        <if test='dataType == "1"'>
+            and t1.clip_user_id in (
+            select promoter_id from jy_kuaishou_promoter
+            where `type` = 1
+            group by promoter_id
+            )
+        </if>
+        <if test='dataType == "2" '>
+            and t1.clip_user_id not in (
+            select promoter_id from jy_kuaishou_promoter
+            where `type` = 1
+            group by promoter_id
+            )
+        </if>
         ) t1
-        join (select  CONCAT(date_format(#{lastMonthEndDate} ,'%Y/%m/%d')  , '合计')                                                                   as 'lastDate',
-        round(sum(pay_amount) / 100, 2)                                              as 'lastGmv',
-        count(oid)                                                                   as 'lastOrderNum',
+        join (select CONCAT(date_format(#{lastMonthEndDate} ,'%Y/%m/%d') , '合计') as 'lastDate',
+        round(sum(pay_amount) / 100, 2) as 'lastGmv',
+        count(oid) as 'lastOrderNum',
         round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'lastValidGmv',
-        sum(case when order_status != 80 then 1 else 0 end)                          as 'lastValidOrderNum',
-        round(sum(mcn_promotion_amount) / 100, 2)                                    as 'lastMcnPromotionAmount',
-        round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2)                  as 'lastGrossMargin'
-        from jy_order_list t1 left join jy_kuaishou_promoter t2
-        on t1.clip_user_id = t2.promoter_id
+        sum(case when order_status != 80 then 1 else 0 end) as 'lastValidOrderNum',
+        round(sum(mcn_promotion_amount) / 100, 2) as 'lastMcnPromotionAmount',
+        round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'lastGrossMargin'
+        from jy_order_list t1
         where t1.stat_date >= #{lastMonthStartDate}
-        and t1.stat_date &lt;=  #{lastMonthEndDate}
-        and t2.type = 1
+        and t1.stat_date &lt;= #{lastMonthEndDate}
+        <if test='dataType == "1"'>
+            and t1.clip_user_id in (
+            select promoter_id from jy_kuaishou_promoter
+            where `type` = 1
+            group by promoter_id
+            )
+        </if>
+        <if test='dataType == "2"'>
+            and t1.clip_user_id not in (
+            select promoter_id from jy_kuaishou_promoter
+            where `type` = 1
+            group by promoter_id
+            )
+        </if>
         ) t2
     </select>
     <select id="getTopItem" resultType="com.alibaba.fastjson.JSONObject">
@@ -762,18 +812,20 @@ from (select date_format(#{date},'%Y/%m/%d')
         order by ${fieId} ${sort}
     </select>
     <select id="getTopItemUser" resultType="com.alibaba.fastjson.JSONObject">
-        select id,name  from jy_fx_top_item_config
+        select id, name
+        from jy_fx_top_item_config
     </select>
     <select id="getDataByDate" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
         select stat_hour as 'time', round(sum(order_amount) / 100, 2) as 'charge'
-from jy_order_list
-where stat_date = #{date}
-group by stat_hour
-order by stat_hour
+        from jy_order_list
+        where stat_date = #{date}
+        group by stat_hour
+        order by stat_hour
 
     </select>
     <select id="getJiaoYangCookie" resultType="java.lang.String">
-        select  cookie  from jy_fx_cookie limit 1
+        select cookie
+        from jy_fx_cookie limit 1
     </select>
     <select id="getAuthItemList" resultType="com.alibaba.fastjson.JSONObject">
         select