yumeng 1 year ago
parent
commit
ad2eac21ed

+ 7 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouRuleSettlementDataController.java

@@ -101,6 +101,13 @@ public class KuaishouRuleSettlementDataController extends BaseController {
         return getDataTable(list);
     }
 
+    @GetMapping("/getSettlementListV2")
+    public TableDataInfo getSettlementListV2(String statDate, Long promoterId, String promoterName) {
+        Long date = Long.valueOf(statDate.replace("-", ""));
+        startPage();
+        List<JSONObject> list = kuaishouRuleSettlementDataService.getSettlementDataV2(date, promoterId, promoterName);
+        return getDataTable(list);
+    }
 
     @RequestMapping(value = "/exportSettlementList")
     @ResponseBody

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouRuleSettlementDataMapper.java

@@ -94,4 +94,6 @@ public interface KuaishouRuleSettlementDataMapper {
     Integer selectPromoterIncentiveLog(Long promoterId);
 
     void replacePromoterIncentiveLog(@Param("promoterId") Long promoterId, @Param("ruleId") Long ruleId, @Param("incentivizedCount") Integer incentivizedCount, @Param("lastIncentivizedCount") Integer lastIncentivizedCount);
+
+    List<JSONObject> getSettlementDataV2(@Param("date") Long date, @Param("promoterId") Long promoterId, @Param("promoterName") String promoterName);
 }

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouRuleSettlementDataService.java

@@ -78,5 +78,7 @@ public interface IKuaishouRuleSettlementDataService {
     JSONObject getData();
 
     void promoterData(Long statDate, JSONArray data);
+
+    List<JSONObject> getSettlementDataV2(Long date, Long promoterId, String promoterName);
 }
 

+ 12 - 9
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouRuleSettlementDataServiceImpl.java

@@ -126,7 +126,7 @@ public class KuaishouRuleSettlementDataServiceImpl implements IKuaishouRuleSettl
                 Integer rule_type = dataJson.getInteger("rule_type");
                 JSONObject ruleData = new JSONObject();
                 if (rule_type == 1) {
-                    ruleData = getRuleData(relateId, promoterId, ruleId,  validOrderNum);
+                    ruleData = getRuleData(relateId, promoterId, ruleId, validOrderNum);
 
                 } else if (rule_type == 2) {
                     ruleData = getOrderRuleData(relateId, promoterId, ruleId, validOrderNum);
@@ -184,9 +184,9 @@ public class KuaishouRuleSettlementDataServiceImpl implements IKuaishouRuleSettl
                 Integer rule_type = dataJson.getInteger("rule_type");
                 JSONObject ruleData = new JSONObject();
                 if (rule_type == 3) {
-                    ruleData = getPromoterRuleData(relateId, promoterId, ruleId,  validOrderNum);
+                    ruleData = getPromoterRuleData(relateId, promoterId, ruleId, validOrderNum);
 
-                } else  {
+                } else {
                     continue;
                 }
                 settlementData.setRuleId(ruleId);
@@ -214,7 +214,10 @@ public class KuaishouRuleSettlementDataServiceImpl implements IKuaishouRuleSettl
         }
     }
 
-
+    @Override
+    public List<JSONObject> getSettlementDataV2(Long date, Long promoterId, String promoterName) {
+        return kuaishouRuleSettlementDataMapper.getSettlementDataV2(date, promoterId, promoterName);
+    }
 
 
     // 按区间结算
@@ -500,11 +503,11 @@ public class KuaishouRuleSettlementDataServiceImpl implements IKuaishouRuleSettl
         }
         Integer itemCount = ruleJson.getInteger("startItemCount"); // 规则单数
         BigDecimal ruleAnchorAmount = ruleJson.getBigDecimal("anchorAmount"); // 规则达人激励金额
-        if(Check.isNull(ruleAnchorAmount)){
+        if (Check.isNull(ruleAnchorAmount)) {
             ruleAnchorAmount = new BigDecimal(0);
         }
         BigDecimal ruleReferenceAmount = ruleJson.getBigDecimal("referenceAmount"); // 规则达人激励金额
-        if(Check.isNull(ruleReferenceAmount)){
+        if (Check.isNull(ruleReferenceAmount)) {
             ruleReferenceAmount = new BigDecimal(0);
         }
 
@@ -577,11 +580,11 @@ public class KuaishouRuleSettlementDataServiceImpl implements IKuaishouRuleSettl
         }
         Integer itemCount = ruleJson.getInteger("startItemCount"); // 规则单数
         BigDecimal ruleAnchorAmount = ruleJson.getBigDecimal("anchorAmount"); // 规则达人激励金额
-        if(Check.isNull(ruleAnchorAmount)){
+        if (Check.isNull(ruleAnchorAmount)) {
             ruleAnchorAmount = new BigDecimal(0);
         }
         BigDecimal ruleReferenceAmount = ruleJson.getBigDecimal("referenceAmount"); // 规则达人激励金额
-        if(Check.isNull(ruleReferenceAmount)){
+        if (Check.isNull(ruleReferenceAmount)) {
             ruleReferenceAmount = new BigDecimal(0);
         }
 
@@ -607,7 +610,7 @@ public class KuaishouRuleSettlementDataServiceImpl implements IKuaishouRuleSettl
             BigDecimal referenceIncentiveAmount = count.multiply(ruleReferenceAmount); // 推荐人奖励
             anchorAmount = anchorAmount.add(promoterIncentiveAmount);
             referenceAmount = referenceAmount.add(referenceIncentiveAmount);
-            kuaishouRuleSettlementDataMapper.replacePromoterIncentiveLog( promoterId, ruleId, incentivizedCount, lastIncentivizedCount);
+            kuaishouRuleSettlementDataMapper.replacePromoterIncentiveLog(promoterId, ruleId, incentivizedCount, lastIncentivizedCount);
             returnJson.put("sonRuleId", ruleJson.getLong("id"));
             returnJson.put("ruleName", kuaishouSettlementRules.getRuleName());
             returnJson.put("anchorAmount", anchorAmount);

+ 34 - 31
ruixuan-live/src/main/resources/mapper/isc/KuaishouRuleSettlementDataMapper.xml

@@ -211,16 +211,16 @@
         from kuaishou_rule_detail where rule_id = #{ruleId}
     </select>
     <select id="lastRule" resultType="com.alibaba.fastjson.JSONObject">
-        select son_rule_id  as 'sonRuleId',
-        (select  sort_count  from kuaishou_rule_detail where  id = t1.son_rule_id) as 'sortCount',
-         IFNULL(valid_order_num,0)  as 'validOrderNum'
-        from  kuaishou_rule_settlement_data t1
+        select son_rule_id as 'sonRuleId',
+        (select sort_count from kuaishou_rule_detail where id = t1.son_rule_id) as 'sortCount',
+        IFNULL(valid_order_num,0) as 'validOrderNum'
+        from kuaishou_rule_settlement_data t1
         where 1 = 1
         <if test="relateId != null and relateId != ''">
-         and   relate_id = #{relateId}
+            and relate_id = #{relateId}
         </if>
-        and  promoter_id = #{promoterId}
-        and  rule_id = #{ruleId}
+        and promoter_id = #{promoterId}
+        and rule_id = #{ruleId}
         and settlement_status != 1
         order by create_time desc limit 1
     </select>
@@ -244,7 +244,6 @@
     </select>
 
 
-
     <insert id="replaceIncentiveLog">
         replace into kuaishou_rule_incentive_log (
         relate_id,
@@ -279,7 +278,6 @@
     </insert>
 
 
-
     <select id="getTotalByCountAndRuleId" resultType="com.alibaba.fastjson.JSONObject">
         select
         ifnull(round(sum(anchor_amount) * #{incentivizedCount}, 2),0)    as 'anchorAmount',
@@ -292,26 +290,9 @@
 
     </select>
     <select id="getSettlementDate" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
-        <!--        select t.* from (
-                select
-                promoter_id as 'promoterId',
-                promoter_name as 'promoterName',
-                sum(anchor_amount) as 'anchorAmount',
-                sum(reference_amount) as 'referenceAmount'
-                from kuaishou_rule_settlement_data
-                where stat_date = #{statDate}
-                and settlement_status != 3
-                <if test="promoterId != null and promoterId != '' ">
-                    and promoter_id = #{promoterId}
-                </if>
-                <if test="promoterName != null and promoterName != '' ">
-                    AND promoter_name LIKE CONCAT('%', #{promoterName}, '%')
-                </if>
-                group by promoter_id) t order by t.anchorAmount desc-->
-
         select t.*, t2.item_title as 'itemName',
-         t2.user_name as  'itemUserName',
-        (select  user_name  from  kuaishou_promoter where promoter_id = t.promoterId limit 1) as 'promoterUserName'
+        t2.user_name as 'itemUserName',
+        (select user_name from kuaishou_promoter where promoter_id = t.promoterId limit 1) as 'promoterUserName'
         from (select id as 'id',
         rule_name as 'ruleName',
         item_ids as 'itemIds',
@@ -326,9 +307,9 @@
         settlement_status as 'settlementStatus',
         (
         case
-         when settlement_status = 1 then '未达到结算规则'
-         when settlement_status = 2 then '待结算'
-         when settlement_status = 3 then '已结算'
+        when settlement_status = 1 then '未达到结算规则'
+        when settlement_status = 2 then '待结算'
+        when settlement_status = 3 then '已结算'
         else '-'
         end
         ) as 'settlementStatusDesc'
@@ -347,6 +328,28 @@
         left join kuaishou_item_list t2 on t.itemId = t2.item_id
         order by t.settlementStatus asc
     </select>
+
+    <select id="getSettlementDataV2" resultType="com.alibaba.fastjson.JSONObject">
+        select t.* from (
+        select
+        promoter_id as 'promoterId',
+
+        promoter_name as 'promoterName',
+        sum(anchor_amount) as 'anchorAmount',
+        sum(reference_amount) as 'referenceAmount'
+        from kuaishou_rule_settlement_data
+        where stat_date = #{statDate}
+        and settlement_status != 3
+        <if test="promoterId != null and promoterId != '' ">
+            and promoter_id = #{promoterId}
+        </if>
+        <if test="promoterName != null and promoterName != '' ">
+            AND promoter_name LIKE CONCAT('%', #{promoterName}, '%')
+        </if>
+        group by promoter_id) t order by t.anchorAmount desc
+    </select>
+
+
     <select id="getPromoterSettlementDetail" resultType="com.alibaba.fastjson.JSONObject">
         select
         id as 'id',

+ 3 - 2
ruixuan-live/src/main/resources/mapper/jiaoyang/JiaoYangReportMapper.xml

@@ -79,6 +79,8 @@
     <select id="promoter" resultType="com.alibaba.fastjson.JSONObject">
         select t.*,
         tt.head_img as 'headImg',
+        tt.video_count as 'videoCount',
+        tt.video_show as 'videoShow',
         ttt.type as 'type',
         ttt.user_name as 'userName'
         from (
@@ -121,8 +123,7 @@
             </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(DATE_ADD(NOW(), INTERVAL -1 DAY),'%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 != '' ">