|
@@ -12,6 +12,7 @@ import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouScheduleMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IWarningOperationService;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -260,8 +261,19 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
|
|
|
}
|
|
|
|
|
|
+ static ExecutorService executorBidTypeService = Executors.newFixedThreadPool(20);
|
|
|
+ static ExecutorService executorMaxBidService = Executors.newFixedThreadPool(5);
|
|
|
+ @Autowired
|
|
|
+ private IWarningOperationService warningOperationService;
|
|
|
|
|
|
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 bidArr = JSONArray.parseArray(ocpxActionTypeStr);
|
|
|
if (!Check.isNull(details)) {
|
|
|
List<KuaiShouGroup> groups = new ArrayList<>();
|
|
|
List<KuaiShouAppInfo> appInfos = new ArrayList<>();
|
|
@@ -270,21 +282,69 @@ 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)) {
|
|
|
- KuaiShouGroup group = new KuaiShouGroup();
|
|
|
+ Integer bid_type = 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");
|
|
|
Long unitId = detail.getLong("unit_id");
|
|
|
+ String unit_name = detail.getString("unit_name");
|
|
|
+ Integer status = detail.getInteger("status");
|
|
|
+ Integer put_status = detail.getInteger("put_status");
|
|
|
+ if (put_status == 1) { // 组状态为 投放中的
|
|
|
+ if (status != 15) { // 广告组状态为非暂停
|
|
|
+ Boolean ocpxTrueOrFalse = false;
|
|
|
+ for (int j = 0; j < bidArr.size(); j++) {
|
|
|
+ Integer ocpxActionType = (Integer) bidArr.get(j);
|
|
|
+ if (ocpxActionType.equals(ocpx_action_type)) {
|
|
|
+ ocpxTrueOrFalse = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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 (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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ KuaiShouGroup group = new KuaiShouGroup();
|
|
|
group.setId("" + advertiserId + unitId);
|
|
|
group.setAccountId(advertiserId);
|
|
|
group.setCampaignId(detail.getLong("campaign_id"));
|
|
|
group.setUnitId(unitId);
|
|
|
- group.setUnitName(detail.getString("unit_name"));
|
|
|
- group.setStatus(detail.getInteger("status"));
|
|
|
- group.setPutStatus(detail.getInteger("put_status"));
|
|
|
+ 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(detail.getInteger("bid_type"));
|
|
|
- group.setBid(detail.getLong("bid"));
|
|
|
+ group.setBidType(bid_type);
|
|
|
+ group.setBid(bid);
|
|
|
group.setCpaBid(detail.getLong("cpa_bid"));
|
|
|
- group.setOcpxActionType(detail.getInteger("ocpx_action_type"));
|
|
|
+ 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"));
|