|
@@ -446,7 +446,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
} else if ("dayBudget".equals(cindicatorCode)) {
|
|
|
if ("cost".equals(indicatorCode)) {
|
|
|
//倍数计算, 转化成本 高于or低于当前倍数时,预警
|
|
|
- threshold = new BigDecimal(String.valueOf(byteDancePlan.getBudget())).multiply(new BigDecimal(threshold)).toString();
|
|
|
+ othreshold = byteDancePlan.getBudget().multiply(new BigDecimal(threshold)).toString();
|
|
|
}
|
|
|
} else {
|
|
|
othreshold = threshold;
|
|
@@ -522,25 +522,25 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
if (("up".equals(operationType) && oldBid.compareTo(new BigDecimal(maxValue)) == 0) || ("down".equals(operationType) && oldBid.compareTo(new BigDecimal(minValue)) == 0)) {
|
|
|
continue;
|
|
|
}
|
|
|
- Long newBid = 0L;
|
|
|
+ BigDecimal newBid = null;
|
|
|
if ("to".equals(operationType)) {
|
|
|
//金额直接赋值
|
|
|
if ("price".equals(operationValue)) {
|
|
|
- newBid = new BigDecimal(operationThreshold).longValue();
|
|
|
+ newBid = new BigDecimal(operationThreshold);
|
|
|
} else {//百分比需计算
|
|
|
- newBid = new BigDecimal(operationThreshold).multiply(oldBid).longValue();
|
|
|
+ newBid = new BigDecimal(operationThreshold).multiply(oldBid);
|
|
|
}
|
|
|
} else {
|
|
|
newBid = calculatedValue(oldBid, operationType, operationValue, operationThreshold, maxValue, minValue, 1);
|
|
|
}
|
|
|
//TODO
|
|
|
- String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), new BigDecimal(newBid.toString()), null, null);
|
|
|
+ Integer code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), newBid, null, null);
|
|
|
String message = "success";
|
|
|
- if (code.equals("")) {
|
|
|
+ if (code == 0) {
|
|
|
alreadyOperatedList.add(obj);
|
|
|
} else {
|
|
|
message = "fail";
|
|
|
- log.error("(头条)规则引擎修改出价失败,accountId={},unitId={}", accountId, planId);
|
|
|
+ log.error("(头条)规则引擎修改出价失败,accountId={},planId={}", accountId, planId);
|
|
|
}
|
|
|
recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, null, planId, operationThreshold, oldBid.toString(), newBid.toString(), message, "头条");
|
|
|
//修改预算
|
|
@@ -549,37 +549,37 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
if (("up".equals(operationType) && oldBudget.compareTo(new BigDecimal(maxValue)) == 0) || ("down".equals(operationType) && oldBudget.compareTo(new BigDecimal(minValue)) == 0)) {
|
|
|
continue;
|
|
|
}
|
|
|
- Long newBudget = 0L;
|
|
|
+ BigDecimal newBudget = null;
|
|
|
if ("to".equals(operationType)) {
|
|
|
//金额直接赋值
|
|
|
if ("price".equals(operationValue)) {
|
|
|
- newBudget = new BigDecimal(operationThreshold).longValue();
|
|
|
+ newBudget = new BigDecimal(operationThreshold);
|
|
|
} else {//百分比需计算
|
|
|
- newBudget = new BigDecimal(operationThreshold).multiply(oldBudget).longValue();
|
|
|
+ newBudget = new BigDecimal(operationThreshold).multiply(oldBudget);
|
|
|
}
|
|
|
} else {
|
|
|
newBudget = calculatedValue(oldBudget, operationType, operationValue, operationThreshold, maxValue, minValue, 1);
|
|
|
}
|
|
|
//TODO
|
|
|
- String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, null, newBudget);
|
|
|
+ Integer code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, null, newBudget);
|
|
|
String message = "success";
|
|
|
- if (code.equals("")) {
|
|
|
+ if (code == 0) {
|
|
|
alreadyOperatedList.add(obj);
|
|
|
} else {
|
|
|
message = "fail";
|
|
|
- log.error("(头条)规则引擎修改预算失败,accountId={},unitId={}", accountId, planId);
|
|
|
+ log.error("(头条)规则引擎修改预算失败,accountId={},planId={}", accountId, planId);
|
|
|
}
|
|
|
recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, null, planId, operationThreshold, oldBudget.toString(), newBudget.toString(), message, "头条");
|
|
|
//修改投放时间
|
|
|
} else if ("TIME".equals(operate) && !byteDancePlan.getScheduleTime().equals(operationThreshold)) {
|
|
|
//TODO
|
|
|
- String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, operationThreshold, null);
|
|
|
+ Integer code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, operationThreshold, null);
|
|
|
String message = "success";
|
|
|
- if (code.equals("")) {
|
|
|
+ if (code == 0) {
|
|
|
alreadyOperatedList.add(obj);
|
|
|
} else {
|
|
|
message = "fail";
|
|
|
- log.error("规则引擎修改投放时间段失败,accountId={},unitId={}", accountId, planId);
|
|
|
+ log.error("规则引擎修改投放时间段失败,accountId={},planId={}", accountId, planId);
|
|
|
}
|
|
|
recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, null, planId, operationThreshold, byteDancePlan.getScheduleTime(), operationThreshold, message, "头条");
|
|
|
}
|
|
@@ -614,7 +614,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
newBid = new BigDecimal(operationThreshold).multiply(oldBidDecimal).longValue();
|
|
|
}
|
|
|
} else {
|
|
|
- newBid = calculatedValue(oldBidDecimal, operationType, operationValue, operationThreshold, maxValue, minValue, 2);
|
|
|
+ newBid = calculatedValue(oldBidDecimal, operationType, operationValue, operationThreshold, maxValue, minValue, 2).longValue();
|
|
|
}
|
|
|
JSONObject unitJson = new JSONObject();
|
|
|
unitJson.put("advertiser_id", accountId);
|
|
@@ -662,7 +662,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
newBudget = new BigDecimal(operationThreshold).multiply(oldBudgetDecimal).longValue();
|
|
|
}
|
|
|
} else {
|
|
|
- newBudget = calculatedValue(oldBudgetDecimal, operationType, operationValue, operationThreshold, maxValue, minValue, 2);
|
|
|
+ newBudget = calculatedValue(oldBudgetDecimal, operationType, operationValue, operationThreshold, maxValue, minValue, 2).longValue();
|
|
|
}
|
|
|
Map<String, Object> updateMap = kuaiShouUpdateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, newBudget, "规则引擎修改预算");
|
|
|
BigDecimal divide = new BigDecimal(newBudget + "").divide(new BigDecimal("1000"));
|
|
@@ -792,7 +792,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
* @return
|
|
|
* @throws
|
|
|
*/
|
|
|
- private static Long calculatedValue(BigDecimal goal, String operationType, String operationValue, String operationThreshold, String fmaxValue, String fminValue, Integer type) {
|
|
|
+ private static BigDecimal calculatedValue(BigDecimal goal, String operationType, String operationValue, String operationThreshold, String fmaxValue, String fminValue, Integer type) {
|
|
|
BigDecimal threshold = new BigDecimal(operationThreshold);
|
|
|
BigDecimal maxValue = new BigDecimal(fmaxValue);
|
|
|
BigDecimal minValue = new BigDecimal(fminValue);
|
|
@@ -830,7 +830,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
value = goal.multiply(threshold);
|
|
|
}
|
|
|
}
|
|
|
- return value.longValue();
|
|
|
+ return value;
|
|
|
} else {
|
|
|
goal = goal.divide(new BigDecimal("1000"));
|
|
|
//操作金额
|
|
@@ -864,7 +864,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
value = goal.multiply(threshold);
|
|
|
}
|
|
|
}
|
|
|
- return value.multiply(new BigDecimal("1000")).longValue();
|
|
|
+ return value.multiply(new BigDecimal("1000"));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1161,15 +1161,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
private boolean groupThresholdFromIndicator(JSONObject thresholdJson, String operate) {
|
|
|
if ("SEND".equals(operate) || "PAUSE".equals(operate)) {
|
|
|
return false;
|
|
|
- }
|
|
|
- RuleBase base = ruleBaseMapper.selectById(thresholdJson.getLong("ruleId"));
|
|
|
- String code = base.getIndicatorCode();
|
|
|
- if ("BID".equals(operate)) {
|
|
|
- return "charge".equals(code) || "cost".equals(code);
|
|
|
- } else if ("BUDGET".equals(operate)) {
|
|
|
- return "convertCost".equals(code);
|
|
|
- } else if ("TIME".equals(operate)) {
|
|
|
- return "scheduleTime".equals(code);
|
|
|
+ } else if ("BID".equals(operate) || "BUDGET".equals(operate) || "TIME".equals(operate)) {
|
|
|
+ return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|