Parcourir la source

头条项目出价预警

zxa il y a 3 ans
Parent
commit
920ef1d2d7

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.bytedance.advertise.mapper;
 
+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;
@@ -15,4 +16,6 @@ import java.util.List;
 public interface ByteDanceCreativeMapper extends BaseMapper<ByteDanceCreative> {
 
     void replaceBatch(@Param(value = "creatives") List<ByteDanceCreative> creatives);
+
+    List<JSONObject> getBytedanceOcpxTypeList();
 }

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

@@ -45,4 +45,12 @@
             )
         </foreach>
     </insert>
+
+    <select id="getBytedanceOcpxTypeList" resultType="com.alibaba.fastjson.JSONObject">
+        select
+               ocpx_action_type as 'ocpxActionType',
+               ocpx_action_name as 'ocpxActionName'
+        from ctop_bytedance_ocpx_action_type_config
+    </select>
+
 </mapper>

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

@@ -324,6 +324,11 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         //操作状态
         String optStatus = detail.getString("opt_status");
         if ("AD_STATUS_ENABLE".equals(optStatus) && !"AD_STATUS_DISABLE".equals(status)) { // 操作状态为‘启用’,广告计划投放状态 非‘暂停’
+            Map<String, String> textMap = new HashMap<>();
+            List<JSONObject> lists = creativeMapper.getBytedanceOcpxTypeList();
+            for (JSONObject da : lists) {
+                textMap.put(da.getString("ocpxActionType"), da.getString("ocpxActionName"));
+            }
             String msgType = "";
             String msgBid = "";
 
@@ -338,12 +343,13 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
                 //通过转化目标没有查询到转化出价,判断为转化目标不一致,触发关停
                 if (Check.isNull(ocpxBid)) {
                     typeFalg = false;
-                    msgType = "转化:" + ocpxActionType;
+                    String msg = Check.isNull(textMap.get(ocpxActionType)) ? ocpxActionType : textMap.get(ocpxActionType);
+                    msgType = "计划转化:" + msg;
                 } else {
                     //未查询到转化出价,说明出价不一致,触发出价关停。
                     if (Check.isNull(cpaBid)) {
                         bidFalg = false;
-                        msgBid = "出价为空";
+                        msgBid = "计划出价为空";
                     } else {
                         BigDecimal cpa = new BigDecimal(cpaBid);
                         BigDecimal ocpx = new BigDecimal(ocpxBid);
@@ -362,19 +368,20 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
                     if (Check.isNull(deepBid)) {
                         //通过key未获取值,说明不包含该目标,进行关停
                         typeFalg = false;
-                        msgType = "(深度)转化:" + deepConversionType;
+                        String msg = Check.isNull(textMap.get(deepConversionType)) ? deepConversionType : textMap.get(deepConversionType);
+                        msgType = "计划(深度)转化:" + msg;
                     } else {
                         //未查询到转化出价,说明出价不一致,触发出价关停。
                         if (Check.isNull(deepConversionBid)) {
                             bidFalg = false;
-                            msgBid = "(深度)出价为空";
+                            msgBid = "计划(深度)出价为空";
                         } else {
                             BigDecimal cpa = new BigDecimal(deepConversionBid);
                             BigDecimal ocpx = new BigDecimal(deepBid);
                             if (cpa.compareTo(ocpx) == 1) {
                                 //计划转化出价cpa 大于 项目设置最大转化出价,则关停
                                 bidFalg = false;
-                                msgBid = "(深度)计划出价:" + cpaBid;
+                                msgBid = "计划(深度)出价:" + deepConversionBid;
                             }
                         }
                     }
@@ -418,7 +425,8 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
                 .append("下的账户:").append(advertiserId + ",").append("<br/>")
                 .append("广告计划id:").append(unitId).append("<br/>")
                 .append("广告计划名称:").append(unit_name).append("<br/>")
-                .append("出价方式设置错误。").append(msgType).append("<br/>")
+                .append("出价方式设置错误。").append("<br/>")
+                .append(msgType).append("<br/>")
                 .append("系统已执行暂停此计划,请您及时查看!");
         return text.toString();
     }
@@ -431,7 +439,8 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
                 .append("下的账户:").append(accountId + ",").append("<br/>")
                 .append("广告计划id为:").append(planId).append("<br/>")
                 .append("广告计划名称为:").append(planName).append("<br/>")
-                .append("出价设置过高。").append(msgBid).append("<br/>")
+                .append("出价设置过高。").append("<br/>")
+                .append(msgBid).append("<br/>")
                 .append("系统已执行暂停此计划,请您及时查看!");
         return text.toString();
     }