123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace app\common\api;
- use app\common\api\CompanyApi;
- use think\facade\Db;
- use app\admin\model\Enterprise;
- class EnterpriseApi {
- public static function getOne($id){
- return Enterprise::findOrEmpty($id);
- }
- public static function getList($request) {
- $companyId = session('user')['companyId'];
- $company_info = CompanyApi::getOne($companyId);
- $where = [];
- if($company_info['code'] != 'super'){
- $where[] = ['type','=',session('user')['type']];
- if(session('user')['type'] == 1){
- $list = Db::table('sys_enterprisetype_properties')->where('companyIds','like',$companyId)->select()->toArray();
- $talentType = [];
- foreach ($list as $k => $v){
- array_push($talentType,$v['talentType']);
- }
- $where[] = ['enterpriseTag','in',$talentType];
- }
- }
- $offset = trim($request->param("offset")) ?: 0;
- $limit = trim($request->param("limit")) ?: 10;
- $name = trim($request->param("name"));
- $idCard = trim($request->param("idCard"));
- $legal = trim($request->param("legal"));
- $ephone = trim($request->param("ephone"));
- $agentName = trim($request->param("agentName"));
- $agentPhone = trim($request->param("agentPhone"));
- $checkState = trim($request->param("checkState"));
- $active = trim($request->param("active"));
- $street = trim($request->param("street"));
- $enterpriseTag = trim($request->param("enterpriseTag"));
- $industryFieldNew = trim($request->param("industryFieldNew"));
- if ($name) {
- $where[] = ["name", "like", "%{$name}%"];
- }
- if ($idCard) {
- $where[] = ["idCard", "like", "%{$idCard}%"];
- }
- if ($legal) {
- $where[] = ["legal", "like", "%{$legal}%"];
- }
- if ($ephone) {
- $where[] = ["ephone", "like", "%{$ephone}%"];
- }
- if ($agentName) {
- $where[] = ["agentName", "like", "%{$agentName}%"];
- }
- if ($agentPhone) {
- $where[] = ["agentPhone", "like", "%{$agentPhone}%"];
- }
- if ($checkState) {
- $where[] = ["checkState", "=", "{$checkState}"];
- }
- if ($active) {
- $where[] = ["active", "=", "{$active}"];
- }
- if ($street) {
- $where[] = ["street", "=", "{$street}"];
- }
- if ($enterpriseTag) {
- $where[] = ["enterpriseTag", "=", "{$enterpriseTag}"];
- }
- if ($industryFieldNew) {
- $where[] = ["industryFieldNew", "=", "{$industryFieldNew}"];
- }
- $count = Enterprise::where($where)->count();
- if($count > 0){
- $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
- $industryFieldNewList = DictApi::selectByParentCode("industry_field");
- $industryFieldOldList = DictApi::selectByParentCode("industry_field");
- //dd($talentTypeList);
- $list = Enterprise::where($where)->limit($offset, $limit)->order("createTime", 'desc')->select()->toArray();
- foreach ($list as $k => &$v){
- unset($v['password']);
- $v['enterpriseTagName'] = $talentTypeList[$v['enterpriseTag']];//此处旧字段为talentType,新字段为enterpriseTag,为防止数据污染与丢失,因而这样写
- $v['industryFieldNewName'] = $industryFieldNewList[$v['industryFieldNew']];
- $v['industryFieldNewName'] = $industryFieldNewList[$v['industryFieldNew']];
- }
- }else{
- $list = [];
- }
- return ["total" => $count, "rows" => $list];
- }
- public static function updateById($data){
- return Enterprise::update($data);
- }
- }
|