Parcourir la source

头条预警 添加项目维度

zhaoxian il y a 2 ans
Parent
commit
f6c6ca82bc

+ 46 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/MediaSendAlarmRecord.java

@@ -0,0 +1,46 @@
+package org.jeecg.modules.bytedance.advertise.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * @Description: 媒体预警发送表
+ */
+@Data
+@TableName("ctop_media_send_alarm_record")
+@Accessors(chain = true)
+@ApiModel(value = "ctop_media_send_alarm_record对象", description = "媒体预警发送表")
+public class MediaSendAlarmRecord {
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    private Long accountId;
+    private Long planId;
+    private Long projectId;
+    private String userId;
+    private String alarmDetail;
+    private String mediaType;
+    /**
+     * createTime
+     */
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    private Date updateTime;
+
+    public MediaSendAlarmRecord(Long accountId, String mediaType, String alarmDetail) {
+        this.accountId = accountId;
+        this.mediaType = mediaType;
+        this.alarmDetail = alarmDetail;
+    }
+
+    public MediaSendAlarmRecord() {
+    }
+}

+ 3 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceCreativeMapper.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreative;
+import org.jeecg.modules.bytedance.advertise.entity.MediaSendAlarmRecord;
 
 import java.util.List;
 
@@ -18,4 +19,6 @@ public interface ByteDanceCreativeMapper extends BaseMapper<ByteDanceCreative> {
     void replaceBatch(@Param(value = "creatives") List<ByteDanceCreative> creatives);
 
     List<JSONObject> getBytedanceOcpxTypeList();
+
+    void insertSendRecord(MediaSendAlarmRecord record);
 }

+ 19 - 3
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceCreativeMapper.xml

@@ -47,10 +47,26 @@
     </insert>
 
     <select id="getBytedanceOcpxTypeList" resultType="com.alibaba.fastjson.JSONObject">
-        select
-               ocpx_action_type as 'ocpxActionType',
-               ocpx_action_name as 'ocpxActionName'
+        select ocpx_action_type as 'ocpxActionType', ocpx_action_name as 'ocpxActionName'
         from ctop_bytedance_ocpx_action_type_config
     </select>
 
+    <insert id="insertSendRecord">
+        insert into ctop_media_send_alarm_record(id,
+                                                 account_id,
+                                                 plan_id,
+                                                 project_id,
+                                                 user_id,
+                                                 alarm_detail,
+                                                 media_type)
+        values (#{id},
+                #{accountId},
+                #{planId},
+                #{projectId},
+                #{userId},
+                #{alarmDetail},
+                #{mediaType})
+
+    </insert>
+
 </mapper>

+ 15 - 3
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -8,6 +8,7 @@ import org.jeecg.modules.bytedance.advertise.entity.ByteDanceAdvertisePlan;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreative;
 import org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo;
 import org.jeecg.modules.bytedance.advertise.entity.BytedanceImageInfo;
+import org.jeecg.modules.bytedance.advertise.entity.MediaSendAlarmRecord;
 import org.jeecg.modules.bytedance.advertise.mapper.ByteDanceCreativeMapper;
 import org.jeecg.modules.bytedance.advertise.mapper.MonitorBytedanceActionTrackUrlMapper;
 import org.jeecg.modules.bytedance.advertise.service.IByteDanceAdvertisePlanService;
@@ -259,6 +260,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
         JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
         if (null == data || data.isEmpty()) {
+            log.error("获取广告计划结果为空==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
             return;
         }
         Long accountId = token.getAccountId();
@@ -431,12 +433,15 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     }
 
     private void sendMsg(Long accountId, Long planId, String text, String type) {
+        MediaSendAlarmRecord record = new MediaSendAlarmRecord(accountId,"1",text);
         //关停计划
         CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
         if ("plan".equals(type)) {
-            marketingServiceImpl.updPlanStatus(token, Arrays.asList(planId), "disable");
+//TODO            marketingServiceImpl.updPlanStatus(token, Arrays.asList(planId), "disable");
+            record.setPlanId(planId);
         } else {
-            marketingServiceImpl.updProjectStatus(token, planId, "DISABLE");
+//            marketingServiceImpl.updProjectStatus(token, planId, "DISABLE");
+            record.setProjectId(planId);
         }
         log.info(">预警<,账户:{}=>计划:{}现已【关停】---> {}", accountId, planId, text);
         try {
@@ -444,14 +449,21 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
             String userId = "";
             if (!Check.isNull(account)) {
                 userId = account.getUserId();
+                record.setUserId(userId);
             }
             JSONObject jsonObject = monitorBytedanceActionTrackUrlMapper.getWChatIdByUserId(userId);
-            corpWexinUtils.sendMessageByWeChatId(jsonObject, text);
+//TODO            corpWexinUtils.sendMessageByWeChatId(jsonObject, text);
+            insertSendRecord(record);
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
+    //添加记录 ctop_media_send_alarm_record
+    public void insertSendRecord(MediaSendAlarmRecord record){
+        creativeMapper.insertSendRecord(record);
+    }
+
     //转化方式错误消息生成
     private String getBidTypeText(String projectName, Long advertiserId, Long unitId, String unit_name, String msgType) {
         StringBuilder text = new StringBuilder();