You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB
PHP

<?php
namespace Base\Service;
use Base\Facade\Request;
class PromoteCompanyService
{
const BELONG_INSIDE = 0;
const BELONG_OUTSIDE = 1;
const BELONG_OUTSIDE_SP = 2;
const BELONG_NONE = 3;
public static $belongs = [
0 => '内团',
1 => '外团',
2 => '外团-分发',
3 => '无',
];
public function getOutBelongs()
{
return [
self::BELONG_OUTSIDE => self::$belongs[self::BELONG_OUTSIDE],
self::BELONG_OUTSIDE_SP => self::$belongs[self::BELONG_OUTSIDE_SP],
];
}
public function getCompanies(array $ids = null, $fields = '*')
{
$map = [];
if (is_null($ids)) {
$map['_string'] = '1=1';
} elseif (count($ids) == 0) {
return [];
} else {
$map['id'] = ['in', $ids];
}
$rules = M('promote_company', 'tab_')->field($fields)->where($map)->select();
return index_by_column('id', $rules);
}
public function getCompaniesByBelong($belong = null, $fields = '*')
{
$map = [];
if (is_null($belong)) {
$map['_string'] = '1=1';
} else {
$map['company_belong'] = $belong;
}
$rules = M('promote_company', 'tab_')->field($fields)->where($map)->select();
return index_by_column('id', $rules);
}
}