Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

yumeng před 2 roky
rodič
revize
5d577cb894

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java

@@ -52,5 +52,7 @@ public interface MaterialInfoMapper extends BaseMapper<MaterialInfo> {
 
     List<String> getDuxiaomanMaterialInfoByStatus(@Param("status") Integer status);
 
+    List<String> getDuxiaomanMaterialInfoByTime();
+
     // List<MaterialInfo> getListByParams(String tagCode, String type, Integer status, String materialName, String code, String startDate, String endDate, List<Long> projectIds, String ascription, String clipId, String shotId, String planId, Integer offlineFlag);
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -211,6 +211,11 @@
         WHERE `status` = #{status}
     </select>
 
+    <select id="getDuxiaomanMaterialInfoByTime" resultType="java.lang.String">
+        SELECT id FROM ctop_duxiaoman_material_info
+        WHERE confirm_time >= DATE_FORMAT(now(), '%Y-%m-%d')
+    </select>
+
     <select id="getBytedanceCountByCode" resultType="java.lang.Integer">
         SELECT count(1)  from  ctop_bytedance_video_info WHERE signature = #{code}
     </select>

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -96,4 +96,6 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
     void updateByteDanceByCode(String s);
 
     List<String> getDuxiaomanMaterialInfoByStatus(Integer status);
+
+    List<String> getDuxiaomanMaterialInfoByTime();
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -896,6 +896,11 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     }
 
     @Override
+    public List<String> getDuxiaomanMaterialInfoByTime() {
+        return baseMapper.getDuxiaomanMaterialInfoByTime();
+    }
+
+    @Override
     public JSONArray getIdListByProject(Long projectId) {
         return materialInfoMapper.getIdListByProject(projectId);
     }

+ 2 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/DuxiaomanJob.java

@@ -72,6 +72,8 @@ public class DuxiaomanJob {
 
         //0-待审核,1-待上传,2-审批中,3-审核通过,4-审核不通过,5-预审核,6-预审核拒绝,7-上传成功,8-上传失败
         List<String> idList = materialInfoService.getDuxiaomanMaterialInfoByStatus(2);
+        List<String> idList2 = materialInfoService.getDuxiaomanMaterialInfoByTime();
+        idList.addAll(idList2);
         if (Check.isNull(idList)) {
             return;
         }

+ 28 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/SynchronousAccountTransactionJob.java

@@ -4,12 +4,14 @@ import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import cn.com.ctop.toutiao.modules.agent.service.AgentManagementService;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
 
 @Component
 @Slf4j
@@ -42,4 +44,30 @@ public class SynchronousAccountTransactionJob {
         }
 
     }
+
+    /**
+     * 同步头条账户交易流水
+     * 获取前3天数据
+     */
+    @XxlJob("synchronousAccountTransactionNew")
+    public void synchronousAccountTransactionNew() throws Exception {
+
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+
+        String yesterda1 = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        String yesterda2 = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -2);
+        String yesterda3 = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -3);
+
+        try {
+            agentManagementService.synchronousAccount();
+
+            agentManagementService.synchronousAccountTransactionDayNew(yesterda1,yesterda1,1,1000);
+            agentManagementService.synchronousAccountTransactionDayNew(yesterda2,yesterda2,1,1000);
+            agentManagementService.synchronousAccountTransactionDayNew(yesterda3,yesterda3,1,1000);
+
+        } catch (Exception e) {
+            log.info("同步完成");
+        }
+
+    }
 }

+ 1 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/mapper/CtopAccountTransactionDayMapper.java

@@ -13,5 +13,6 @@ public interface CtopAccountTransactionDayMapper {
     void deleteAccountTransactionById( @Param("id") String id);
 
     void saveAccountTransactionDay(@Param("list") List<TransactionDay> list, @Param("date") String date);
+    void replaceAccountTransactionDay(@Param("list") List<TransactionDay> list);
 
 }

+ 22 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/mapper/xml/CtopAccountTransactionDayMapper.xml

@@ -18,7 +18,28 @@
             #{item.sharedWalletCost},
             #{item.transferIn},
             #{item.transferOut},
-            #{date}
+            NOW()
+            )
+        </foreach>
+    </insert>
+ <!-- 批量插入新增数据-->
+    <insert id="replaceAccountTransactionDay">
+        REPLACE into ctop_account_transaction_day (advertiser_id,date,balance,cash_cost,cost,frozen,income,reward_cost,
+        shared_wallet_cost,transfer_in,transfer_out,create_time) values
+        <foreach collection="list" item="item" index="index" separator=",">
+            (
+            #{item.advertiserId},
+            #{item.date},
+            #{item.balance},
+            #{item.cashCost},
+            #{item.cost},
+            #{item.frozen},
+            #{item.income},
+            #{item.rewardCost},
+            #{item.sharedWalletCost},
+            #{item.transferIn},
+            #{item.transferOut},
+            NOW()
             )
         </foreach>
     </insert>

+ 1 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/service/AgentManagementService.java

@@ -25,4 +25,5 @@ public interface AgentManagementService {
 
     //同步账户日流水
     public Result synchronousAccountTransactionDay(String startDate, String endDate);
+    public void synchronousAccountTransactionDayNew(String startDate, String endDate,int pageNum, int pageSize);
 }

+ 59 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/service/impl/AgentManagementServiceImpl.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.agent.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.toutiao.modules.agent.entity.TransactionDay;
 import cn.com.ctop.toutiao.modules.agent.entity.TransactionDetails;
 import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDayMapper;
@@ -8,7 +9,9 @@ import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDetailsMap
 import cn.com.ctop.toutiao.modules.agent.mapper.CtopAgentAccountMapper;
 import cn.com.ctop.toutiao.modules.agent.service.AgentManagementService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import javafx.beans.binding.When;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.CloseableHttpResponse;
@@ -268,9 +271,9 @@ public class AgentManagementServiceImpl implements AgentManagementService {
         ca.add(Calendar.DATE, -1);
 
         try {
-//            List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
-            List<String> accountIdList = new ArrayList<>();
-            accountIdList.add("1744115510360071");
+            List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
+//            List<String> accountIdList = new ArrayList<>();
+            //accountIdList.add("1744115510360071");
             if (!accountIdList.isEmpty()) {
                 accountIdList.stream().forEach(str -> {
                     List<TransactionDay> transactionDetailsList = new ArrayList<>();
@@ -353,6 +356,59 @@ public class AgentManagementServiceImpl implements AgentManagementService {
 
 
         return result;
+    } /**
+     * 同步账户日流水
+     *
+     * @author zzy
+     * @create: 2021-07-15
+     */
+    @Override
+    public void synchronousAccountTransactionDayNew(String startDate, String endDate,int page, int pageSize) {
+
+        List<TransactionDay> list = new ArrayList<>();
+        List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
+
+//        List<String> accountIdList = new ArrayList<>();
+//        accountIdList.add("1735775204994062");
+//        accountIdList.add("1744114166675533");
+//        accountIdList.add("1744114166069261");
+
+        for (String accountId : accountIdList) {
+            page = 1;
+            log.info("同步头条账户流水信息{}:开始时间{},结束时间{},第{}页" ,accountId,startDate,endDate,page);
+
+            JSONObject jsonObject = queryAccountTransactionDay(accountId, page, 1000, startDate, endDate);
+            JSONObject data = null;
+            int code = 1;
+            if (jsonObject != null) {
+                data = (JSONObject) jsonObject.get("data");
+                code = (int) jsonObject.get("code");
+            } else {
+                log.info("头条账户流水信心为空,数据jsonObject为null");
+                continue;
+            }
+            if (code != 0) {
+                log.info("获取头条账户流水返回数据:" + jsonObject.toJSONString() + ":" + accountId);
+                continue;
+            }
+            if (data != null) {
+                List<Object> dataList = (List<Object>) data.get("list");
+                if (dataList != null && !dataList.isEmpty()) {
+                    dataList.stream().forEach(ob -> {
+                        TransactionDay transactionDay = JSONObject.toJavaObject((JSON) ob, TransactionDay.class);
+                        list.add(transactionDay);
+                    });
+                }
+            }
+            ctopAccountTransactionDayMapper.replaceAccountTransactionDay(list);
+            log.info("获取头条账户:{}流水信息{}条" ,accountId,list.size());
+            page++;
+            int totalPage = jsonObject.getJSONObject("data").getJSONObject("page_info").getInteger("total_page");
+            if (page <= totalPage) {
+                synchronousAccountTransactionDayNew(startDate, endDate, page, 1000);
+            }
+        }
+
     }
 
     /**