master
ELF 5 years ago
parent 4419030b1a
commit e5a21b9224

@ -17,14 +17,24 @@ class PromoteLimitRuleController extends ThinkController
$companyId = I('company_id', 0); $companyId = I('company_id', 0);
$promoteId = I('promote_id', 0); $promoteId = I('promote_id', 0);
$query = M('promote_limit_rules', 'tab_')->where('1=1'); $conditions = [];
$promoteIds = [];
if ($promoteId !== 0) { if ($promoteId !== 0) {
$query->where(['promote_id' => $promoteId]); $promoteIds = [$promoteId];
} }
if ($companyId !== 0) { if ($companyId !== 0) {
$promoteIds = M('promote', 'tab_')->field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true); $companyPromoteIds = M('promote', 'tab_')->field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true);
$query->where(['promote_id' => ['in', $promoteIds]]); if (count($companyPromoteIds) > 0) {
$promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds;
$promoteIds[] = 0;
} else {
$promoteIds = [0];
}
}
if (count($promoteIds)) {
$conditions['promote_id'] = ['in', $promoteIds];
} }
$query = M('promote_limit_rules', 'tab_')->where($conditions);
$countQuery = clone $query; $countQuery = clone $query;
$rules = $query->page($page, $row)->select(); $rules = $query->page($page, $row)->select();
@ -46,6 +56,7 @@ class PromoteLimitRuleController extends ThinkController
0 => '内团', 0 => '内团',
1 => '外团', 1 => '外团',
2 => '外团-分发联盟', 2 => '外团-分发联盟',
3 => '无'
]; ];
$records = []; $records = [];
@ -111,6 +122,10 @@ class PromoteLimitRuleController extends ThinkController
$startedAt = $startedAt === '' ? null : $startedAt; $startedAt = $startedAt === '' ? null : $startedAt;
$endedAt = $endedAt === '' ? null : $endedAt; $endedAt = $endedAt === '' ? null : $endedAt;
if (empty($promoteId)) {
return $this->error('请选择会长');
}
if ($startedAt && $endedAt && strtotime($startedAt) > strtotime($endedAt)) { if ($startedAt && $endedAt && strtotime($startedAt) > strtotime($endedAt)) {
return $this->error('开始时间不能大于结束时间'); return $this->error('开始时间不能大于结束时间');
} }

Loading…
Cancel
Save