Browse Source

规则引擎,修改bug

zhaoxian 3 years ago
parent
commit
14884aebd0

+ 24 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -527,7 +527,12 @@ 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)) {
                     if (("up".equals(operationType) && oldBid.compareTo(new BigDecimal(maxValue)) == 0) || ("down".equals(operationType) && oldBid.compareTo(new BigDecimal(minValue)) == 0)) {
                         continue;
                         continue;
                     }
                     }
-                    Long newBid = calculatedValue(oldBid, operationType, operationValue, operationThreshold, maxValue, minValue);
+                    Long newBid = 0L;
+                    if ("to".equals(operationType)) {
+                        newBid = Long.valueOf(operationThreshold);
+                    } else {
+                        newBid = calculatedValue(oldBid, operationType, operationValue, operationThreshold, maxValue, minValue);
+                    }
                     //TODO
                     //TODO
                     String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), new BigDecimal(newBid.toString()), null, null);
                     String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), new BigDecimal(newBid.toString()), null, null);
                     String message = "success";
                     String message = "success";
@@ -544,7 +549,12 @@ 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)) {
                     if (("up".equals(operationType) && oldBudget.compareTo(new BigDecimal(maxValue)) == 0) || ("down".equals(operationType) && oldBudget.compareTo(new BigDecimal(minValue)) == 0)) {
                         continue;
                         continue;
                     }
                     }
-                    Long newBudget = calculatedValue(oldBudget, operationType, operationValue, operationThreshold, maxValue, minValue);
+                    Long newBudget = 0L;
+                    if ("to".equals(operationType)) {
+                        newBudget = Long.valueOf(operationThreshold);
+                    } else {
+                        newBudget = calculatedValue(oldBudget, operationType, operationValue, operationThreshold, maxValue, minValue);
+                    }
                     //TODO
                     //TODO
                     String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, null, newBudget);
                     String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, null, newBudget);
                     String message = "success";
                     String message = "success";
@@ -589,7 +599,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     if (("up".equals(operationType) && oldBid - Long.valueOf(maxValue) == 0) || ("down".equals(operationType) && oldBid - Long.valueOf(minValue) == 0)) {
                     if (("up".equals(operationType) && oldBid - Long.valueOf(maxValue) == 0) || ("down".equals(operationType) && oldBid - Long.valueOf(minValue) == 0)) {
                         continue;
                         continue;
                     }
                     }
-                    Long newBid = calculatedValue(new BigDecimal(oldBid.toString()), operationType, operationValue, operationThreshold, maxValue, minValue);
+                    Long newBid = 0L;
+                    if ("to".equals(operationType)) {
+                        newBid = Long.valueOf(operationThreshold);
+                    } else {
+                        newBid = calculatedValue(new BigDecimal(oldBid.toString()), operationType, operationValue, operationThreshold, maxValue, minValue);
+                    }
                     JSONObject unitJson = new JSONObject();
                     JSONObject unitJson = new JSONObject();
                     unitJson.put("advertiser_id", accountId);
                     unitJson.put("advertiser_id", accountId);
                     unitJson.put("unit_id", unitId);
                     unitJson.put("unit_id", unitId);
@@ -625,7 +640,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     if (("up".equals(operationType) && oldBudget - Long.valueOf(maxValue) == 0) || ("down".equals(operationType) && oldBudget - Long.valueOf(minValue) == 0)) {
                     if (("up".equals(operationType) && oldBudget - Long.valueOf(maxValue) == 0) || ("down".equals(operationType) && oldBudget - Long.valueOf(minValue) == 0)) {
                         continue;
                         continue;
                     }
                     }
-                    Long newBudget = calculatedValue(new BigDecimal(oldBudget.toString()), operationType, operationValue, operationThreshold, maxValue, minValue);
+                    Long newBudget = 0L;
+                    if ("to".equals(operationType)) {
+                        newBudget = Long.valueOf(operationThreshold);
+                    } else {
+                        newBudget = calculatedValue(new BigDecimal(oldBudget.toString()), operationType, operationValue, operationThreshold, maxValue, minValue);
+                    }
                     Map<String, Object> updateMap = kuaiShouUpdateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, newBudget, "规则引擎修改预算");
                     Map<String, Object> updateMap = kuaiShouUpdateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, newBudget, "规则引擎修改预算");
                     String message = "success";
                     String message = "success";
                     if ((Integer) updateMap.get("code") == 0) {
                     if ((Integer) updateMap.get("code") == 0) {