Forráskód Böngészése

达人结算数据

yumeng 2 éve
szülő
commit
820c88782f

+ 55 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/settlementJob.java

@@ -0,0 +1,55 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouSupplyChainService;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class settlementJob {
+
+
+    @Autowired
+    private IKuaishouSupplyChainService ikuaishouSupplyChainService;
+
+
+    /**
+     * 自定义创建监测链接预警
+     */
+    @XxlJob("cleanSettlementData")
+    public void cleanSettlementData() {
+        String url = "http://ruixuan.api.tjyourong.com.cn/settlement/data";
+        String date = DateUtils.getLastDay(DateUtils.date2Str(), 1);
+        Long statDate = Long.valueOf(date.replace("-", ""));
+        List<JSONObject> list = ikuaishouSupplyChainService.getDataList(statDate);
+
+        if (Check.isNull(list)) {
+            return;
+
+        }
+        List<List<JSONObject>> partition = Lists.partition(list, 1000);
+        for (int i = 0; i < partition.size(); i++) {
+            List<JSONObject> jsonObjects = partition.get(i);
+            Map<String, Object> param = new HashMap<>();
+            param.put("statDate", date);
+            param.put("data", jsonObjects);
+            HttpUtils.httpPostRequest(url, param, null);
+        }
+
+    }
+
+
+
+
+}

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouSupplyChainMapper.java

@@ -22,4 +22,6 @@ public interface KuaishouSupplyChainMapper extends BaseMapper<KuaishouSupplyChai
     List<JSONObject>  getCookie();
 
     void replaceSettlement(@Param(value = "adds") List<KuaishouSupplyChainSettlement> supplyChains);
+
+    List<JSONObject> getDataList(@Param("statDate") Long statDate);
 }

+ 24 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouSupplyChainMapper.xml

@@ -86,5 +86,29 @@
         select  id ,cookie  from ruixuan.kuaishou_supply_chain_cookie
 
     </select>
+    <select id="getDataList" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
+     select  *  from (
+      select t1.relate_id                      as 'relateId',
+       1                        as 'ruleId',
+       group_concat(t1.item_id)          as 'itemIds',
+       t1.promoter_id                    as 'promoterId',
+       t1.promoter_name                  as 'promoterName',
+       t1.item_create_id                 as 'itemCreateId',
+       t1.item_create_name               as 'itemCreateName',
+       t1.promoter_create_id             as 'promoterCreateId',
+       t1.promoter_create_name           as 'promoterCreateName',
+       ifnull(sum(t1.order_num),0)                 as 'orderNum',
+       ifnull(sum(t1.valid_order_num),0 )         as 'validOrderNum',
+       ifnull(sum(t1.yesterday_order_num),0 )      as 'yesterdayOrderNum',
+       ifnull(sum(t1.yesterday_valid_order_num),0) as 'yesterdayValidOrderNum',
+       t1.stat_date                      as 'statDate'
+       from ruixuan.kuaishou_rule_order_data t1
+         left join ruixuan.kuaishou_item_list t2 on t1.item_id = t2.item_id
+      where t1.stat_date = #{statDate}
+      and t2.rule_id is   null
+      and t1.relate_id is not null
+      group by t1.relate_id, t1.promoter_id ) t order by t.validOrderNum
+
+    </select>
 
 </mapper>

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouSupplyChainService.java

@@ -19,4 +19,6 @@ public interface IKuaishouSupplyChainService extends IService<KuaishouSupplyChai
     List<JSONObject> getCookie();
 
     void getSettlementData(String cookie, Integer offset, Long orderCreateTimeStart, Long orderCreateTimeEnd) throws Exception;
+
+    List<JSONObject> getDataList(Long statDate);
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouSupplyChainServiceImpl.java

@@ -184,6 +184,11 @@ public class KuaishouSupplyChainServiceImpl extends ServiceImpl<KuaishouSupplyCh
         }
     }
 
+    @Override
+    public List<JSONObject> getDataList(Long statDate) {
+        return supplyChainMapper.getDataList(statDate);
+    }
+
     public static String filterSupplement(String content) {
         StringBuilder sb = new StringBuilder();
         for (char ch : content.toCharArray()) {