|
@@ -167,12 +167,15 @@ class BehaviorRepository
|
|
|
$count = 0;
|
|
|
if (count($rule) == count($rule, 1)) {
|
|
|
$count = array_sum($rule);
|
|
|
+ $request['allotted_quantity_rule'] = array_map('intval', $request['allotted_quantity_rule']);
|
|
|
if ($count > $rainbow_beans) {
|
|
|
throw new HttpException(500, '唯一行为-分配总数不能大于行为生成彩虹豆总数');
|
|
|
}
|
|
|
} else {
|
|
|
- foreach ($rule as $value) {
|
|
|
+ foreach ($request['allotted_quantity_rule'] as $key => $value) {
|
|
|
$count += $value['bean'];
|
|
|
+ $request['allotted_quantity_rule'][$key] = array_map('intval', $value);
|
|
|
+
|
|
|
}
|
|
|
if ($count > $rainbow_beans) {
|
|
|
throw new HttpException(500, '多级行为-分配总数不能大于行为生成彩虹豆总数');
|
|
@@ -190,8 +193,8 @@ class BehaviorRepository
|
|
|
'behavior_cycle' => isset($request['behavior_cycle']) ? $request['behavior_cycle'] : '',
|
|
|
'behavior_binding_users' => isset($request['behavior_binding_users']) ? $request['behavior_binding_users'] : 0,
|
|
|
'physical_strength' => isset($request['physical_strength']) ? $request['physical_strength'] : 0,
|
|
|
- 'rainbow_beans' => isset($request['rainbow_beans']) ? $request['rainbow_beans'] : '',
|
|
|
- 'grant_rainbow_beans' => isset($request['grant_rainbow_beans']) ? $request['grant_rainbow_beans'] : '',
|
|
|
+ 'rainbow_beans' => isset($request['rainbow_beans']) ? $request['rainbow_beans'] : 0,
|
|
|
+ 'grant_rainbow_beans' => isset($request['grant_rainbow_beans']) ? $request['grant_rainbow_beans'] : 0,
|
|
|
'remarks' => isset($request['remarks']) ? $request['remarks'] : '',
|
|
|
'behavioral_cycle_start_time' => isset($request['behavioral_cycle_start_time']) ? $request['behavioral_cycle_start_time'] : null,
|
|
|
'behavioral_cycle_end_time' => isset($request['behavioral_cycle_end_time']) ? $request['behavioral_cycle_end_time'] : null,
|
|
@@ -243,6 +246,30 @@ class BehaviorRepository
|
|
|
if ($behavior_id->is_open == 1) {
|
|
|
throw new HttpException(500, '无法编辑已经在记录的行为');
|
|
|
}
|
|
|
+ if (isset($request['allotted_quantity_rule']) && isset($request['rainbow_beans'])) {
|
|
|
+
|
|
|
+ $rule = $request['allotted_quantity_rule'];
|
|
|
+ $rainbow_beans = $request['rainbow_beans'];
|
|
|
+ $count = 0;
|
|
|
+ if (count($rule) == count($rule, 1)) {
|
|
|
+ $count = array_sum($rule);
|
|
|
+ $request['allotted_quantity_rule'] = array_map('intval', $request['allotted_quantity_rule']);
|
|
|
+ if ($count > $rainbow_beans) {
|
|
|
+ throw new HttpException(500, '唯一行为-分配总数不能大于行为生成彩虹豆总数');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ foreach ($request['allotted_quantity_rule'] as $key => $value) {
|
|
|
+ $count += $value['bean'];
|
|
|
+ $request['allotted_quantity_rule'][$key] = array_map('intval', $value);
|
|
|
+
|
|
|
+ }
|
|
|
+ if ($count > $rainbow_beans) {
|
|
|
+ throw new HttpException(500, '多级行为-分配总数不能大于行为生成彩虹豆总数');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$update_bahavior = [
|
|
|
'virus_behavior_id' => $request['virus_behavior_id'],
|
|
|
'name' => $request['name'],
|
|
@@ -252,8 +279,8 @@ class BehaviorRepository
|
|
|
'behavior_cycle' => isset($request['behavior_cycle']) ? $request['behavior_cycle'] : '',
|
|
|
'behavior_binding_users' => isset($request['behavior_binding_users']) ? $request['behavior_binding_users'] : 0,
|
|
|
'physical_strength' => isset($request['physical_strength']) ? $request['physical_strength'] : 0,
|
|
|
- 'rainbow_beans' => isset($request['rainbow_beans']) ? $request['rainbow_beans'] : '',
|
|
|
- 'grant_rainbow_beans' => isset($request['grant_rainbow_beans']) ? $request['grant_rainbow_beans'] : '',
|
|
|
+ 'rainbow_beans' => isset($request['rainbow_beans']) ? $request['rainbow_beans'] : 0,
|
|
|
+ 'grant_rainbow_beans' => isset($request['grant_rainbow_beans']) ? $request['grant_rainbow_beans'] : 0,
|
|
|
'remarks' => isset($request['remarks']) ? $request['remarks'] : '',
|
|
|
'behavioral_cycle_start_time' => isset($request['behavioral_cycle_start_time']) ? $request['behavioral_cycle_start_time'] : null,
|
|
|
'behavioral_cycle_end_time' => isset($request['behavioral_cycle_end_time']) ? $request['behavioral_cycle_end_time'] : null,
|