123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <?php
- namespace App\Http\Controllers\Web\Share;
- use App\Http\Controllers\Web\WebBaseController;
- use Illuminate\Support\Facades\Auth;
- use App\Repositories\PmsRepository;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Http\Request;
- class ApiController extends WebBaseController
- {
- protected $user;
- protected $pmsRepository;
- public function __construct(PmsRepository $pmsRepository)
- {
- header('Access-Control-Allow-Origin:*');
- header('Access-Control-Allow-Methods:GET,POST,PUT,DELETE');
- header('Access-Control-Allow-Headers:Origin, Content-Type, Cookie, Accept');
- header('Access-Control-Allow-Credentials:true');
- $this->pmsRepository = $pmsRepository;
- }
- public function getUser()
- {
- $res['isLogin'] = 1;
- $res['status'] = 1;
- $res['user'] = [
- 'name' => '郑明炜',
- 'pmsNum' => 5
- ];
- return json_encode($res);
- $user = parent::getLoginUser();
- $res = [];
- if(!$user){
- $res['isLogin'] = 0;
- $res['status'] = 1;
- $res['user'] = null;
- }else{
- $condition4 = [
- 'msgtouid' => $user->id,
- 'utype' => $user->utype,
- 'new'=>1,
- ];
- $pms = $this->pmsRepository->getPmsCount($condition4);
- switch ($user->utype){
- case '1':
- $name = $user->companyname;
- break;
- case '2':
- $memberService=app('App\Services\Person\MemberService');
- $name = $memberService->getName();
- break;
- }
- $res['isLogin'] = 1;
- $res['status'] = 1;
- $res['user'] = [
- 'name' => $name,
- 'pmsNum' => $pms
- ];
- }
- return json_encode($res);
- }
- public function getSelectData()
- {
- $trade = DB::table('share_trade')->get();
- $result = [];
- foreach ($trade as $k => $v){
- $sub = DB::table('share_job')->where('trade',$v->id)->get()->toArray();
- $sub_opt = [];
- foreach($sub as $key => $val){
- $item = [
- 'value' => $val->id,
- 'label' => $val->name
- ];
- array_push($sub_opt,$item);
- }
- $item = [
- 'value' => $v->id,
- 'label' => $v->name,
- 'sub' => $sub_opt
- ];
- array_push($result,$item);
- }
- return json_encode($result);
- }
- public function getShareHallData(Request $request)
- {
- $type = intval($request->input('type'));
- $trade = intval($request->input('trade'));
- $job = intval($request->input('job'));
- $page = intval($request->input('page'));
- $where = [
- ['id','>=',1]
- ];
- if($type > 0){
- $where[] = ['role','=',$type];
- }
- if($trade > 0){
- $where[] = ['trade','=',$trade];
- }
- if($job > 0){
- $where[] = ['pro','=',$job];
- }
- $list = DB::table('share')->where($where)->paginate(10);
- $result = [
- 'total' => $list->total(),
- 'data' => []
- ];
- if($list->total() > 0){
- $trade = DB::table('share_trade')->pluck('name', 'id');
- $job = DB::table('share_job')->pluck('name', 'id');
- foreach($list as $k => $v){
- if($v->utype == 1){
- $info = DB::table('member_infos')->where('uid',$v->uid)->first();
- }else{
- $info = DB::table('companys')->where('id',$v->uid)->first();
- }
- $item = [];
- $item['name'] = $v->utype == 1 ? substr($info->realname,0,3) . ($info->sex == 1 ? '先生' : '女士') : $info->companyname;
- $item['utype'] = $v->utype == 1 ? "个人" : "企业";
- $item['role'] = $v->role == 1 ? "供应" : "需求";
- switch($v->type){
- case 1:
- $item['type'] = '小时工';
- break;
- case 2:
- $item['type'] = '劳务派遣';
- break;
- case 3:
- $item['type'] = '委托招聘';
- break;
- case 4:
- $item['type'] = '服务外包';
- break;
- case 5:
- $item['type'] = '其它';
- break;
- }
- $item['trade'] = $trade[$v->trade];
- $item['job'] = $job[$v->pro];
- $item['area'] = $v->area;
- $item['time'] = $v->time;
- $item['salary'] = $v->salary;
- $item['number'] = stripos($v->number,'人') ? $v->number : $v->number . '人';
- $item['remark'] = $v->remark;
- $item['contact'] = [
- 'name' => $item['name'],
- 'email' => $info->email,
- 'phone' => $info->mobile
- ];
- array_push($result['data'],$item);
- }
- }
- return json_encode($result);
- }
- public function getMyData()
- {
- $list = DB::table('share')->where('uid',59412)->get();
- $user = parent::getLoginUser();
- }
- }
|