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