|
@@ -532,12 +532,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
if ("to".equals(operationType)) {
|
|
|
//金额直接赋值
|
|
|
if ("price".equals(operationValue)) {
|
|
|
- newBid = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
|
|
|
+ newBid = new BigDecimal(operationThreshold).longValue();
|
|
|
} else {//百分比需计算
|
|
|
newBid = new BigDecimal(operationThreshold).multiply(oldBid).longValue();
|
|
|
}
|
|
|
} else {
|
|
|
- newBid = calculatedValue(oldBid, operationType, operationValue, operationThreshold, maxValue, minValue);
|
|
|
+ newBid = calculatedValue(oldBid, operationType, operationValue, operationThreshold, maxValue, minValue, 1);
|
|
|
}
|
|
|
//TODO
|
|
|
String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), new BigDecimal(newBid.toString()), null, null);
|
|
@@ -559,12 +559,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
if ("to".equals(operationType)) {
|
|
|
//金额直接赋值
|
|
|
if ("price".equals(operationValue)) {
|
|
|
- newBudget = new BigDecimal(operationThreshold).multiply(new BigDecimal(1000 + "")).longValue();
|
|
|
+ newBudget = new BigDecimal(operationThreshold).longValue();
|
|
|
} else {//百分比需计算
|
|
|
newBudget = new BigDecimal(operationThreshold).multiply(oldBudget).longValue();
|
|
|
}
|
|
|
} else {
|
|
|
- newBudget = calculatedValue(oldBudget, operationType, operationValue, operationThreshold, maxValue, minValue);
|
|
|
+ newBudget = calculatedValue(oldBudget, operationType, operationValue, operationThreshold, maxValue, minValue, 1);
|
|
|
}
|
|
|
//TODO
|
|
|
String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, null, newBudget);
|
|
@@ -620,7 +620,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
newBid = new BigDecimal(operationThreshold).multiply(oldBidDecimal).longValue();
|
|
|
}
|
|
|
} else {
|
|
|
- newBid = calculatedValue(oldBidDecimal, operationType, operationValue, operationThreshold, maxValue, minValue);
|
|
|
+ newBid = calculatedValue(oldBidDecimal, operationType, operationValue, operationThreshold, maxValue, minValue, 2);
|
|
|
}
|
|
|
JSONObject unitJson = new JSONObject();
|
|
|
unitJson.put("advertiser_id", accountId);
|
|
@@ -634,6 +634,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
}
|
|
|
JSONObject jsonObject = kuaiShouUpdateService.updateUnit(token.getAccessToken(), unitJson);
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
+ BigDecimal divide = new BigDecimal(newBid + "").divide(new BigDecimal(1000 + ""));
|
|
|
String message = "success";
|
|
|
if (code == 0) {
|
|
|
alreadyOperatedList.add(obj);
|
|
@@ -648,9 +649,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
|
|
|
} else {
|
|
|
message = "fail," + jsonObject.getString("message");
|
|
|
- log.error("(快手)规则引擎修改出价失败,accountId={},unitId={},{}", accountId, unitId, jsonObject.getString("message"));
|
|
|
+ log.error("(快手)规则引擎修改出价失败,accountId={},unitId={},出价={},{}", accountId, unitId, divide, jsonObject.getString("message"));
|
|
|
}
|
|
|
- recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, unitId, null, operationThreshold, oldBid.toString(), newBid.toString(), message, "快手");
|
|
|
+ recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, unitId, null, operationThreshold, oldBid.toString(), divide.toString(), message, "快手");
|
|
|
//修改预算
|
|
|
} else if ("BUDGET".equals(operate)) {
|
|
|
Long oldBudget = Check.isNull(kuaiShouGroup.getDayBudget()) ? 0L : kuaiShouGroup.getDayBudget();
|
|
@@ -667,18 +668,19 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
newBudget = new BigDecimal(operationThreshold).multiply(oldBudgetDecimal).longValue();
|
|
|
}
|
|
|
} else {
|
|
|
- newBudget = calculatedValue(oldBudgetDecimal, operationType, operationValue, operationThreshold, maxValue, minValue);
|
|
|
+ newBudget = calculatedValue(oldBudgetDecimal, operationType, operationValue, operationThreshold, maxValue, minValue, 2);
|
|
|
}
|
|
|
Map<String, Object> updateMap = kuaiShouUpdateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, newBudget, "规则引擎修改预算");
|
|
|
+ BigDecimal divide = new BigDecimal(newBudget + "").divide(new BigDecimal(1000 + ""));
|
|
|
String message = "success";
|
|
|
if ((Integer) updateMap.get("code") == 0) {
|
|
|
alreadyOperatedList.add(obj);
|
|
|
kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
|
|
|
} else {
|
|
|
message = "fail," + updateMap.get("message");
|
|
|
- log.error("(快手)规则引擎修改预算失败,accountId={},unitId={},{}", accountId, unitId, updateMap.get("message"));
|
|
|
+ log.error("(快手)规则引擎修改预算失败,accountId={},unitId={},预算={},{}", accountId, unitId, divide.toString(), updateMap.get("message"));
|
|
|
}
|
|
|
- recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, unitId, null, operationThreshold, oldBudget.toString(), newBudget.toString(), message, "快手");
|
|
|
+ recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, unitId, null, operationThreshold, oldBudget.toString(), divide.toString(), message, "快手");
|
|
|
//修改投放时间
|
|
|
} else if ("TIME".equals(operate)) {
|
|
|
String newScheduleTime = getNewScheduleTime(operationThreshold);
|
|
@@ -796,37 +798,68 @@ 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) {
|
|
|
+ private static Long 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);
|
|
|
BigDecimal value = null;
|
|
|
- //操作金额
|
|
|
- if ("price".equals(operationValue)) {
|
|
|
- if ("up".equals(operationType)) {
|
|
|
- value = goal.add(threshold);
|
|
|
- } else if ("down".equals(operationType)) {
|
|
|
- value = goal.subtract(threshold);
|
|
|
- } else if ("to".equals(operationType)) {
|
|
|
- value = threshold;
|
|
|
+ //头条
|
|
|
+ if (1 == type) {
|
|
|
+ //操作金额
|
|
|
+ if ("price".equals(operationValue)) {
|
|
|
+ if ("up".equals(operationType)) {
|
|
|
+ value = goal.add(threshold);
|
|
|
+ } else if ("down".equals(operationType)) {
|
|
|
+ value = goal.subtract(threshold);
|
|
|
+ } else if ("to".equals(operationType)) {
|
|
|
+ value = threshold;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //操作百分数
|
|
|
+ if ("up".equals(operationType)) {
|
|
|
+ value = goal.add(goal.multiply(threshold));
|
|
|
+ } else if ("down".equals(operationType)) {
|
|
|
+ value = goal.subtract(goal.multiply(threshold));
|
|
|
+ } else if ("to".equals(operationType)) {
|
|
|
+ value = goal.multiply(threshold);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (value.compareTo(maxValue) == 1) {
|
|
|
+ value = maxValue;
|
|
|
+ }
|
|
|
+ if (value.compareTo(minValue) == -1) {
|
|
|
+ value = minValue;
|
|
|
}
|
|
|
+ return value.longValue();
|
|
|
} else {
|
|
|
- //操作百分数
|
|
|
- if ("up".equals(operationType)) {
|
|
|
- value = goal.add(goal.multiply(threshold));
|
|
|
- } else if ("down".equals(operationType)) {
|
|
|
- value = goal.subtract(goal.multiply(threshold));
|
|
|
- } else if ("to".equals(operationType)) {
|
|
|
- value = goal.multiply(threshold);
|
|
|
+ goal = goal.divide(new BigDecimal(1000 + ""));
|
|
|
+ //操作金额
|
|
|
+ if ("price".equals(operationValue)) {
|
|
|
+ if ("up".equals(operationType)) {
|
|
|
+ value = goal.add(threshold);
|
|
|
+ } else if ("down".equals(operationType)) {
|
|
|
+ value = goal.subtract(threshold);
|
|
|
+ } else if ("to".equals(operationType)) {
|
|
|
+ value = threshold;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //操作百分数
|
|
|
+ if ("up".equals(operationType)) {
|
|
|
+ value = goal.add(goal.multiply(threshold));
|
|
|
+ } else if ("down".equals(operationType)) {
|
|
|
+ value = goal.subtract(goal.multiply(threshold));
|
|
|
+ } else if ("to".equals(operationType)) {
|
|
|
+ value = goal.multiply(threshold);
|
|
|
+ }
|
|
|
}
|
|
|
+ if (value.compareTo(maxValue) == 1) {
|
|
|
+ value = maxValue;
|
|
|
+ }
|
|
|
+ if (value.compareTo(minValue) == -1) {
|
|
|
+ value = minValue;
|
|
|
+ }
|
|
|
+ return value.multiply(new BigDecimal(1000 + "")).longValue();
|
|
|
}
|
|
|
- if (value.compareTo(maxValue) == 1) {
|
|
|
- value = maxValue;
|
|
|
- }
|
|
|
- if (value.compareTo(minValue) == -1) {
|
|
|
- value = minValue;
|
|
|
- }
|
|
|
- return value.multiply(new BigDecimal(1000 + "")).longValue();
|
|
|
}
|
|
|
|
|
|
/**
|