|
@@ -332,11 +332,41 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
private void addGroupV2(Long advertiserId, JSONArray details) {
|
|
|
|
|
|
JSONObject json = warningOperationService.getBidTypeAndMaxBid(advertiserId);
|
|
|
- Long maxBid = json.getLong("maxBid");// 最高出价
|
|
|
- String bidTypeStr = json.getString("bidType"); // 出价方式
|
|
|
- JSONArray bidTypeArr = JSONArray.parseArray(bidTypeStr);
|
|
|
- String ocpxActionTypeStr = json.getString("ocpxActionType"); // 优化目标
|
|
|
- JSONArray ocpxArr = JSONArray.parseArray(ocpxActionTypeStr);
|
|
|
+ if (Check.isNull(json) || Check.isNull(details)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 最高出价
|
|
|
+ Long maxBid = json.getLong("maxBid");
|
|
|
+
|
|
|
+ //优化目标集
|
|
|
+ List<Integer> bidList = null;
|
|
|
+ String bidTypeStr = json.getString("bidType");
|
|
|
+ if (!Check.isNull(bidTypeStr)) {
|
|
|
+ bidList = JSONArray.parseArray(bidTypeStr, Integer.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ //转化目标map
|
|
|
+ Map<Integer, Long> ocpxMap = new HashMap<>();
|
|
|
+ String ocpxTypeStr = json.getString("ocpxActionType");
|
|
|
+ if (!Check.isNull(ocpxTypeStr)) {
|
|
|
+ JSONArray ocpxArr = JSONArray.parseArray(ocpxTypeStr);
|
|
|
+ for (int i = 0; i < ocpxArr.size(); i++) {
|
|
|
+ JSONObject obj = ocpxArr.getJSONObject(i);
|
|
|
+ ocpxMap.put(obj.getInteger("ocpxCode"), obj.getLong("maxValue"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //深度转化目标map
|
|
|
+ Map<Integer, Long> deepMap = new HashMap<>();
|
|
|
+ String deepTypeStr = json.getString("deepConversionType");
|
|
|
+ if (!Check.isNull(deepTypeStr)) {
|
|
|
+ JSONArray deepArr = JSONArray.parseArray(deepTypeStr);
|
|
|
+ for (int i = 0; i < deepArr.size(); i++) {
|
|
|
+ JSONObject obj = deepArr.getJSONObject(i);
|
|
|
+ ocpxMap.put(obj.getInteger("deepCode"), obj.getLong("deepValue"));
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!Check.isNull(details)) {
|
|
|
List<KuaiShouGroup> groups = new ArrayList<>();
|
|
|
List<KuaiShouAppInfo> appInfos = new ArrayList<>();
|
|
@@ -345,98 +375,103 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
for (int i = 0; i < details.size(); i++) {
|
|
|
JSONObject detail = JSONObject.parseObject(details.get(i).toString());
|
|
|
if (!Check.isNull(detail)) {
|
|
|
- Integer bid_type = detail.getInteger("bid_type");
|
|
|
+ //优化目标
|
|
|
+ Integer bidType = detail.getInteger("bid_type");
|
|
|
+ //优化出价(只有单击时,才有值)
|
|
|
Long bid = detail.getLong("bid");
|
|
|
- Long cpa_bid = detail.getLong("cpa_bid");
|
|
|
- Long day_budget = detail.getLong("day_budget");
|
|
|
- Integer ocpx_action_type = detail.getInteger("ocpx_action_type");
|
|
|
+ //转化目标
|
|
|
+ Integer ocpxActionType = detail.getInteger("ocpx_action_type");
|
|
|
+ //转化目标出价
|
|
|
+ Long cpaBid = detail.getLong("cpa_bid");
|
|
|
+ //深度转化目标
|
|
|
+ Integer deepConversionType = detail.getInteger("deep_conversion_type");
|
|
|
+ //深度转化目标出价
|
|
|
+ Long deepConversionBid = detail.getLong("deep_conversion_bid");
|
|
|
+ //单日预算
|
|
|
+ Long dayBudget = detail.getLong("day_budget");
|
|
|
+ //组ID
|
|
|
Long unitId = detail.getLong("unit_id");
|
|
|
- String unit_name = detail.getString("unit_name");
|
|
|
+ //组名称
|
|
|
+ String unitName = detail.getString("unit_name");
|
|
|
+ //状态
|
|
|
Integer status = detail.getInteger("status");
|
|
|
- Integer put_status = detail.getInteger("put_status");
|
|
|
- if (put_status == 1) { // 组状态为 投放中的
|
|
|
- if (status != 15) { // 广告组状态为非暂停
|
|
|
- Boolean bidTypeTrueOrFalse = false;
|
|
|
- for (int j = 0; j < bidTypeArr.size(); j++) {
|
|
|
- Integer bidType = (Integer) bidTypeArr.get(j);
|
|
|
- if (bidType.equals(bid_type)) {
|
|
|
- bidTypeTrueOrFalse = true;
|
|
|
- break;
|
|
|
+ //投放状态
|
|
|
+ Integer putStatus = detail.getInteger("put_status");
|
|
|
+ if (putStatus == 1 && status != 15) { // 组状态为 投放中的 and 广告组状态为非暂停
|
|
|
+ Boolean typeFalg = true;
|
|
|
+ Boolean bidFalg = true;
|
|
|
+
|
|
|
+ //优化目标
|
|
|
+ if (!bidList.isEmpty()) {
|
|
|
+ if (!bidList.contains(bidType)) {
|
|
|
+ //项目不包含该优化目标,则关停
|
|
|
+ typeFalg = false;
|
|
|
+ } else if (bidType == 2 && bid > maxBid) {
|
|
|
+ //若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
|
|
|
+ bidFalg = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //转化目标
|
|
|
+ if (!Check.isNull(ocpxActionType) && ocpxActionType != 0) {
|
|
|
+ //!=0是设置过转化目标
|
|
|
+ if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
|
|
|
+ // 转化目标为2行为数,并且预算大于500 或者不限,则关停
|
|
|
+ typeFalg = false;
|
|
|
+ } else if (!Check.isNullMap(ocpxMap)) {
|
|
|
+ Long ocpxBid = ocpxMap.get(ocpxActionType);
|
|
|
+ if (Check.isNull(ocpxBid)) {
|
|
|
+ //通过key未获取值,说明不包含该目标,进行关停
|
|
|
+ typeFalg = false;
|
|
|
+ } else {
|
|
|
+ if (cpaBid > ocpxBid) {
|
|
|
+ //组转化出价 大于 项目设置最大转化出价,则关停
|
|
|
+ bidFalg = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- Boolean ocpxTrueOrFalse = false;
|
|
|
- if (ocpx_action_type == 0) {
|
|
|
- ocpxTrueOrFalse = true;
|
|
|
+ //转化目标
|
|
|
+ if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !Check.isNullMap(ocpxMap)) {
|
|
|
+ Long deepBid = deepMap.get(deepConversionType);
|
|
|
+ if (Check.isNull(deepBid)) {
|
|
|
+ //通过key未获取值,说明不包含该目标,进行关停
|
|
|
+ typeFalg = false;
|
|
|
} else {
|
|
|
- for (int j = 0; j < ocpxArr.size(); j++) {
|
|
|
- Integer ocpxActionType = ocpxArr.getInteger(j);;
|
|
|
- if (ocpxActionType.equals(ocpx_action_type)) {
|
|
|
- ocpxTrueOrFalse = true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (deepConversionBid > deepBid) {
|
|
|
+ //组深度转化出价 大于 项目设置最大转化出价,则关停
|
|
|
+ bidFalg = false;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- if (!bidTypeTrueOrFalse || !ocpxTrueOrFalse) { // 出价方式设置非法
|
|
|
- if (day_budget > 500 * 1000 || day_budget == 0) { // 预算大于500 或者不限制预算 需要发送通知 并且进行暂停操作
|
|
|
- executorBidTypeService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (!typeFalg) { // 出价方式设置非法
|
|
|
+ executorBidTypeService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unitName);
|
|
|
}
|
|
|
- }
|
|
|
- if (bid > maxBid || cpa_bid > maxBid) {
|
|
|
- executorMaxBidService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!bidFalg) {
|
|
|
+ executorMaxBidService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unitName);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- KuaiShouGroup group = new KuaiShouGroup();
|
|
|
+ KuaiShouGroup group = JSONObject.parseObject(detail.toJSONString(), KuaiShouGroup.class);
|
|
|
group.setId("" + advertiserId + unitId);
|
|
|
group.setAccountId(advertiserId);
|
|
|
- group.setCampaignId(detail.getLong("campaign_id"));
|
|
|
- group.setUnitId(unitId);
|
|
|
- group.setUnitName(unit_name);
|
|
|
- group.setStatus(status);
|
|
|
- group.setPutStatus(put_status);
|
|
|
- group.setCreateChannel(detail.getInteger("create_channel"));
|
|
|
- group.setReviewDetail(detail.getString("review_detail"));
|
|
|
- group.setBidType(bid_type);
|
|
|
- group.setBid(bid);
|
|
|
- group.setCpaBid(detail.getLong("cpa_bid"));
|
|
|
- group.setOcpxActionType(ocpx_action_type);
|
|
|
- group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
|
|
|
- group.setDeepConversionBid(detail.getLong("deep_conversion_bid"));
|
|
|
- group.setDayBudget(detail.getLong("day_budget"));
|
|
|
- group.setSpeed(detail.getInteger("speed"));
|
|
|
- group.setBeginTime(detail.getString("begin_time"));
|
|
|
- group.setEndTime(detail.getString("end_time"));
|
|
|
- group.setScheduleTime(detail.getString("schedule_time"));
|
|
|
- group.setSceneId(detail.getJSONArray("scene_id") + "");
|
|
|
- group.setShowMode(detail.getInteger("show_mode"));
|
|
|
- group.setUnitType(detail.getInteger("unit_type"));
|
|
|
- group.setUrlType(detail.getInteger("url_type"));
|
|
|
- group.setUrl(detail.getString("url"));
|
|
|
- group.setSchemaUri(detail.getString("schema_uri"));
|
|
|
- group.setAppId(detail.getLong("app_id"));
|
|
|
- group.setAppIconUrl(detail.getString("app_icon_url"));
|
|
|
group.setGroupCreateTime(detail.getString("create_time"));
|
|
|
group.setGroupUpdateTime(detail.getString("update_time"));
|
|
|
- group.setConvertId(detail.getLong("convert_id"));
|
|
|
- group.setUseAppMarket(detail.getInteger("use_app_market"));
|
|
|
- group.setAppStore(detail.getJSONArray("app_store") + "");
|
|
|
group.setCreateTime(new Date());
|
|
|
group.setUpdateTime(new Date());
|
|
|
groups.add(group);
|
|
|
+
|
|
|
// 添加应用信息
|
|
|
JSONObject diverseJson = detail.getJSONObject("diverse_data");
|
|
|
if (!Check.isNull(diverseJson)) {
|