浏览代码

头条-代理商账户流水修改

yangzian 2 年之前
父节点
当前提交
9b97219d93

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

@@ -10,6 +10,7 @@ import java.util.List;
 public interface CtopAccountTransactionDayMapper {
 public interface CtopAccountTransactionDayMapper {
 
 
     List<String> getAdvertiserIdByDate(@Param("date") String date, @Param("advertiserId") String advertiserId);
     List<String> getAdvertiserIdByDate(@Param("date") String date, @Param("advertiserId") String advertiserId);
+    void deleteAccountTransactionById( @Param("id") String id);
 
 
     void saveAccountTransactionDay(@Param("list") List<TransactionDay> list, @Param("date") String date);
     void saveAccountTransactionDay(@Param("list") List<TransactionDay> list, @Param("date") String date);
 
 

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

@@ -24,7 +24,11 @@
     </insert>
     </insert>
 
 
     <select id="getAdvertiserIdByDate" parameterType="String" resultType="String">
     <select id="getAdvertiserIdByDate" parameterType="String" resultType="String">
-        select t.advertiser_id from ctop_account_transaction_day t where t.date=#{date} and t.advertiser_id=#{advertiserId}
+        select t.id from ctop_account_transaction_day t where t.date=#{date} and t.advertiser_id=#{advertiserId} ORDER BY date
+    </select>
+
+    <select id="deleteAccountTransactionById">
+        delete  from ctop_account_transaction_day t where id = #{id}
     </select>
     </select>
 
 
 </mapper>
 </mapper>

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

@@ -21,7 +21,14 @@
    </sql>
    </sql>
     <!--获取所有账户-->
     <!--获取所有账户-->
     <select id="getAllAccountId" resultType="String">
     <select id="getAllAccountId" resultType="String">
-        select account_id from ctop_agent_account where state=0
+        SELECT
+            a.account_id
+        FROM
+            ctop_agent_account a
+                LEFT JOIN ctop_user_allocation u ON a.account_id = u.account_id
+        WHERE
+            a.state = 0
+          AND u.account_status = 0
     </select>
     </select>
     <!-- 根据账户id修改账户状态-->
     <!-- 根据账户id修改账户状态-->
     <update id="updateAccountState">
     <update id="updateAccountState">

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

@@ -5,7 +5,7 @@ import org.jeecg.common.api.vo.Result;
 
 
 public interface AgentManagementService {
 public interface AgentManagementService {
     //获取TOKEN
     //获取TOKEN
-    public String getToken();
+    public String getToken(long advertiserId);
 
 
     //查询代理商下账户
     //查询代理商下账户
     public  JSONObject selectAgentAdvertiser(int pageNum, int pageSize,String account);
     public  JSONObject selectAgentAdvertiser(int pageNum, int pageSize,String account);

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

@@ -256,7 +256,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      */
      */
     @Override
     @Override
     public Result synchronousAccountTransactionDay(String startDate, String endDate) {
     public Result synchronousAccountTransactionDay(String startDate, String endDate) {
-        log.info("开始同步账号日流水");
+        log.info("开始同步账号日流水---日期{}---{}",startDate,endDate);
         Result result = new Result();
         Result result = new Result();
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
         Calendar ca = Calendar.getInstance();
         Calendar ca = Calendar.getInstance();
@@ -265,6 +265,8 @@ public class AgentManagementServiceImpl implements AgentManagementService {
 
 
         try {
         try {
             List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
             List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
+//            List<String> accountIdList = new ArrayList<>();
+//            accountIdList.add("1732060564940808");
             if (!accountIdList.isEmpty()) {
             if (!accountIdList.isEmpty()) {
                 accountIdList.stream().forEach(str -> {
                 accountIdList.stream().forEach(str -> {
                     List<TransactionDay> transactionDetailsList = new ArrayList<>();
                     List<TransactionDay> transactionDetailsList = new ArrayList<>();
@@ -291,6 +293,11 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                                 dataList.stream().forEach(ob -> {
                                 dataList.stream().forEach(ob -> {
                                     TransactionDay transactionDay = JSONObject.toJavaObject((JSON) ob, TransactionDay.class);
                                     TransactionDay transactionDay = JSONObject.toJavaObject((JSON) ob, TransactionDay.class);
                                     List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
                                     List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
+
+                                    if (advertiserIdList.size() > 1){
+                                        ctopAccountTransactionDayMapper.deleteAccountTransactionById(advertiserIdList.get(0));
+                                        log.info("----------->删除重复数据。accountId:{},date:{}",transactionDay.getAdvertiserId(),transactionDay.getDate());
+                                    }
                                     //订单号不存在
                                     //订单号不存在
                                     if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
                                     if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
                                         transactionDetailsList.add(transactionDay);
                                         transactionDetailsList.add(transactionDay);
@@ -309,6 +316,10 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                                             TransactionDay transactionDay = JSONObject.toJavaObject((JSON) obj, TransactionDay.class);
                                             TransactionDay transactionDay = JSONObject.toJavaObject((JSON) obj, TransactionDay.class);
                                             List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
                                             List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
 
 
+                                            if (advertiserIdList.size() > 1){
+                                                ctopAccountTransactionDayMapper.deleteAccountTransactionById(advertiserIdList.get(0));
+                                            }
+
                                             //订单号不存在
                                             //订单号不存在
                                             if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
                                             if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
                                                 transactionDetailsList.add(transactionDay);
                                                 transactionDetailsList.add(transactionDay);
@@ -401,8 +412,9 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @create: 2021-07-14
      * @create: 2021-07-14
      */
      */
     @Override
     @Override
-    public String getToken() {
-        CtopOauthToken ctopOauthToken = ctopAgentAccountMapper.selectByAccountId(Long.parseLong(ADVERTISER_ID));
+    public String getToken(long advertiserId) {
+//        CtopOauthToken ctopOauthToken = ctopAgentAccountMapper.selectByAccountId(Long.parseLong(ADVERTISER_ID));
+        CtopOauthToken ctopOauthToken = ctopAgentAccountMapper.selectByAccountId(advertiserId);
         if (ctopOauthToken != null) {
         if (ctopOauthToken != null) {
             return ctopOauthToken.getAccessToken();
             return ctopOauthToken.getAccessToken();
         } else {
         } else {
@@ -441,7 +453,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @create: 2021-07-14
      * @create: 2021-07-14
      */
      */
     public JSONObject sendHttpRequest(Map data, String apiUrl) {
     public JSONObject sendHttpRequest(Map data, String apiUrl) {
-        String access_token = getToken();
+        String access_token = getToken(Long.parseLong(data.get("advertiser_id").toString()));
         // 构造请求
         // 构造请求
         HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
         HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
             @Override
             @Override