JobfairCompanyRepository.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2019/1/24
  6. * Time: 17:29
  7. */
  8. namespace App\Repositories\Jobfair;
  9. use App\Models\Jobfair\JobfairCompany;
  10. use function foo\func;
  11. use Illuminate\Support\Facades\DB;
  12. use Prettus\Repository\Eloquent\BaseRepository;
  13. class JobfairCompanyRepository extends BaseRepository
  14. {
  15. public function model()
  16. {
  17. return JobfairCompany::class;
  18. }
  19. public function findPositionCount($positionArr)
  20. {
  21. return $this->model->whereIn('position_id', $positionArr)->get();
  22. }
  23. public function getJobfair($com_id)
  24. {
  25. return $this->model->with(['jobfair'=>function ($query) {
  26. $query->where([['holddate_end', '>', time()]]);
  27. }])->whereHas('jobfair',function ($query){
  28. $query->where([['holddate_end', '>', time()]]);
  29. })->where(['company_id'=>$com_id])->where('audit','<>',3)->get();
  30. }
  31. public function findList($com_id)
  32. {
  33. return $this->model->whereHas('jobfair')->where(['company_id'=>$com_id])->orderby('created_at', 'desc')->paginate(10);
  34. }
  35. public function findCompany($where, $offset = 0, $limit = 10)
  36. {
  37. return $this->model->webJoinFloorplanStand()->whereHas('companys')->with(['jobfair'=>function ($query) {
  38. $query->where('showendtime', '>=', time())->orWhere('showendtime', 0);
  39. },'companys','jobfairPutJob'])
  40. ->selectRaw('jobfair_companys.*')
  41. ->where($where)
  42. ->offset($limit*$offset)
  43. ->limit($limit)
  44. // ->groupBy('company_id')
  45. ->orderByRaw('jobfair_floorplan_stands.sortindex')
  46. ->get();
  47. }
  48. public function findCompany2($where)
  49. {
  50. return $this->model->webJoinFloorplanStand()->with(['jobfair'=>function ($query) {
  51. $query->where('showendtime', '>=', time())->orWhere('showendtime', 0);
  52. },'companys'])
  53. ->selectRaw('jobfair_companys.*')
  54. ->where($where)
  55. // ->groupBy('company_id')
  56. ->orderByRaw('jobfair_floorplan_stands.sortindex')
  57. ->paginate(20);
  58. }
  59. public function aioFindCompany($where, $page)
  60. {
  61. return $this->model->with(['jobfair'=>function ($query) {
  62. $query->where('showendtime', '>=', time())->orWhere('showendtime', 0);
  63. }])->whereHas('companys')->selectRaw('*,group_concat(position) as position_arr,group_concat(id) as id_arr')->where($where)->groupBy('company_id')->paginate($page);
  64. }
  65. public function findCom($where)
  66. {
  67. return $this->model->with(['companys','jobfairPutJob'=>function($query){
  68. $query->with('jobs');
  69. }])->where($where)->first();
  70. }
  71. public function findComApi($where)
  72. {
  73. return $this->model->with(['companys'=>function($query){
  74. $query->select('id','companyname','short_name','address');
  75. },'jobfairPutJob'=>function($query){
  76. $query->with('jobs');
  77. }])->where($where)->first();
  78. }
  79. public function findOneCom($where)
  80. {
  81. return $this->model->with(['companys','jobfairPutJob'=>function($query){
  82. $query->with('jobs');
  83. }])->where($where)->selectRaw('*,group_concat(position) as position_arr,group_concat(id) as id_arr')->groupBy('company_id')->first();
  84. }
  85. public function getComList($where)
  86. {
  87. return $this->model->where($where)->select(['company_id'])->groupBy('company_id')->get();
  88. }
  89. /**
  90. * @param $where
  91. * @param $keyinput
  92. * @return mixed
  93. */
  94. public function findJob($where)
  95. {
  96. return $this->model->with(['jobfair'=>function ($query) {
  97. $query->where('showendtime', '>=', time())->orWhere('showendtime', 0);
  98. }])->with('companys')->where($where)->get();
  99. }
  100. public function getManyBlackCompany()
  101. {
  102. return $this->model->whereHas('jobfair', function ($query) {
  103. $query->where('holddate_end', '<', time());
  104. })->where('audit', 1)->whereIn('type', [1,2,3])->where('black_status', 0)
  105. ->where('created_at', '>', date('Y-m-d H:i:s', strtotime('-30 days')))
  106. ->selectRaw('count(*) as count,company_id')->groupBy('company_id')->get();
  107. }
  108. public function getBlacklistCompany()
  109. {
  110. return $this->model->whereHas('jobfair', function ($query) {
  111. $query->where('holddate_end', '<', time());
  112. })->where('type', 0)->where('black_status', 0)->where('audit', 1)
  113. ->where('created_at', '>', date('Y-m-d H:i:s', strtotime('-30 days')))->get();
  114. }
  115. public function getComCount($jobfair_id)
  116. {
  117. return $this->model->with('jobfair')->where(['jobfair_id'=>$jobfair_id,'audit'=>1])->groupBy('company_id')->get();
  118. }
  119. public function getCounts($jobfair_id)
  120. {
  121. return $this->model->where(['jobfair_id'=>$jobfair_id,'audit'=>1])->count();
  122. }
  123. public function getOne($where)
  124. {
  125. return $this->model->with('jobfair')->where($where)->first();
  126. }
  127. public function updateInfo($where,$data)
  128. {
  129. return $this->model->where($where)->update($data);
  130. }
  131. //手机端下滑分页
  132. public function getComPage($where,$limit,$page){
  133. return $this->model->with('companys')->where($where)
  134. ->selectRaw('*,group_concat(position) as position_arr')
  135. ->where($where)
  136. ->groupBy('company_id')
  137. ->paginate($limit,['*'],'page',$page);
  138. }
  139. public function getCount($where, $subsite_id)
  140. {
  141. return $this->model->when($subsite_id,function ($query) use($subsite_id) {
  142. $query->whereHas('jobfair', function ($query) use($subsite_id) {
  143. $query->where($subsite_id);
  144. });
  145. })->where($where)->count();
  146. }
  147. /**
  148. * 根据条件删除
  149. * @param $where
  150. * @return mixed
  151. */
  152. public function delJobs($column, $ids)
  153. {
  154. return $this->model->whereIn($column, $ids)->delete();
  155. }
  156. public function getStatisticsCompanyCount($where, $whereIn = array())
  157. {
  158. $res = $this->model->where($where);
  159. if ($whereIn) {
  160. foreach ($whereIn as $k => $v) {
  161. $res->whereIn($k, $v);
  162. }
  163. }
  164. return $res->count();
  165. }
  166. public function findListOption($com_id)
  167. {
  168. return $this->model->whereHas('jobfair')->where(['company_id'=>$com_id])->groupBy('jobfair_id')->orderby('created_at', 'desc')->get();
  169. }
  170. public function getCrmJobfairExhibitors($where, $whereIn = [], $order_by = '', $offset = '', $limit = '')
  171. {
  172. $rst = $this->model->with(['jobfair','jobfairPutJob','jobfairFloorPlanStands', 'companys'])->where($where);
  173. if ($whereIn) {
  174. foreach ($whereIn as $k => $v) {
  175. $rst->whereIn($k, $v);
  176. }
  177. }
  178. if ($order_by) {
  179. $rst->orderByRaw($order_by);
  180. }
  181. if ($offset !='' && $limit!='') {
  182. $rst->offset($offset)->limit($limit);
  183. };
  184. return $rst->get();
  185. }
  186. public function getCrmExhibitorNum($where, $whereIn)
  187. {
  188. $rst = $this->model->where($where);
  189. if ($whereIn) {
  190. foreach ($whereIn as $k => $v) {
  191. $rst->whereIn($k, $v);
  192. }
  193. }
  194. return $rst->count();
  195. }
  196. public function getValue($where,$column)
  197. {
  198. return $this->model->where($where)->value($column);
  199. }
  200. public function getPluck($where,$column)
  201. {
  202. return $this->model->where($where)->pluck($column);
  203. }
  204. public function getJobfaitCompany($where)
  205. {
  206. return $this->model->where($where)->get();
  207. }
  208. }