123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <?php
- namespace app\admin\controller;
- use app\admin\BaseController;
- use app\common\model\Worker as WorkerModel;
- use app\common\model\Demand as DemandModel;
- use app\common\model\DemandCate as DemandCateModel;
- use app\common\model\DemandLog as DemandLogModel;
- use app\common\validate\Demand as DemandValidate;
- use think\exception\ValidateException;
- use think\facade\Db;
- class Demand extends BaseController
- {
-
-
- // 报名记录
- public function logList()
- {
- $workerlist = WorkerModel::with('demand')->order(['id'=>'desc'])->select();
- return view('demand/loglist',[
- 'workerlist' => $workerlist
- ]);
- }
-
- public function delLog()
- {
- $idarr = input('idarr/a');
- $log = DemandLogModel::whereIn('id',$idarr)->select();
- $result = $log->delete();
- if ($result){
- exit(json_encode(array(
- 'code' => 0,
- 'msg' => ""
- )));
- }
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => "删除失败,请稍后重试"
- )));
- }
-
- public function fieldLog()
- {
- $id = input('id/d',0);
- $log = DemandLogModel::findOrEmpty($id);
- if ($log->isEmpty()){
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => "信息不存在"
- )));
- }else{
- $log->save([
- input('field/s') => input('value')
- ]);
- }
- exit(json_encode(array(
- 'code' => 0
- )));
- }
-
- public function listLog()
- {
- $limit = input('limit/d',20);
- $page = input('page/d',1);
- $map = array();
- $workerdemandarr = explode(",", input('workerdemand/s'));
- $workerid = isset($workerdemandarr[0]) ? $workerdemandarr[0] : 0;
- $demandid = isset($workerdemandarr[1]) ? $workerdemandarr[1] : 0;
- if (!empty($workerid)){
- $map[] = ['workerid', '=', $workerid];
- }
- if (!empty($demandid)){
- $map[] = ['demandid', '=', $demandid];
- }
- $list = DemandLogModel::with(['gworker','worker','demand'])->where($map)->order('id','DESC')->limit($limit)->page($page)->select();
- $count = DemandLogModel::where($map)->count();
- if ($count==0){
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => "未查询到数据"
- )));
- }
- exit(json_encode(array(
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list
- )));
- }
-
- public function exportLog()
- {
- $map = array();
- $workerdemandarr = explode(",", input('workerdemand/s'));
- $workerid = isset($workerdemandarr[0]) ? $workerdemandarr[0] : 0;
- $demandid = isset($workerdemandarr[1]) ? $workerdemandarr[1] : 0;
- if (!empty($workerid)){
- $map[] = ['workerid', '=', $workerid];
- }
- if (!empty($demandid)){
- $map[] = ['demandid', '=', $demandid];
- }
- $xlsData = DemandLogModel::with(['gworker','worker','demand'])->where($map)->order('id','DESC')->select()->toArray();
- $xlsCell = array(
- array('id','表ID'),
- array('gworker.title','接单公司名称'),
- array('gworker.realname','接单公司联系人姓名'),
- array('gworker.mobile','接单公司联系人手机号'),
- array('worker.title','发单公司'),
- array('demand.title','订单标题'),
- array('createtime','接单时间'),
- );
- export_excel("接单报名记录",$xlsCell,$xlsData);
- }
-
-
- // 企业招聘
- public function demandList()
- {
- $workerlist = WorkerModel::order(['id'=>'desc'])->select();
- $catelist = DemandCateModel::order(['priority'=>'desc','id'=>'desc'])->select();
- return view('demand/demandlist',[
- 'workerlist' => $workerlist,
- 'catelist' => $catelist
- ]);
- }
-
- public function demandForm()
- {
- $id = input('id/d, 0');
- $demand = DemandModel::findOrEmpty($id);
- $workerlist = WorkerModel::order(['id'=>'desc'])->select();
- $catelist = DemandCateModel::order(['priority'=>'desc','id'=>'desc'])->select();
- return view('demand/demandform',[
- 'catelist' => $catelist,
- 'workerlist' => $workerlist,
- 'demand' => $demand
- ]);
- }
-
- public function editDemand()
- {
- $id = input('id/d', 0);
- $wtype = input('wtype/d', 1);
- $zwagall = $wtype==1 ? input('zwagall/s', "") : '';
- $data = [
- 'workerid' => input('workerid/d', 0),
- 'title' => input('title/s', ""),
- 'cateid' => input('cateid/d', 0),
- 'province' => input('province/s', ""),
- 'city' => input('city/s', ""),
- 'district' => input('district/s', ""),
- 'agegroup' => input('agegroup/s', ""),
- 'tags' => input('tags/a', array()),
- 'enddate' => input('enddate/s', ""),
- 'requirement' => input('requirement/s', ""),
- 'comdetails' => input('comdetails/s', ""),
- 'wtype' => $wtype,
- 'bwagall' => input('bwagall/s', ""),
- 'zwagall' => $zwagall,
- 'ftype' => input('ftype/d', 1),
- 'fwagall' => input('fwagall/s', ""),
- 'telephone' => input('telephone/s', ""),
- 'remark' => input('remark/s', ""),
- 'status' => input('status/d', 1),
- 'isfree' => input('isfree/d', 1),
- 'priority' => input('priority/d', 0),
- 'updatetime' => input('updatetime/s', ""),
- 'createtime' => input('createtime/s', ""),
- 'volume' => input('volume/d', 0)
- ];
- try {
- validate(DemandValidate::class)->check($data);
- } catch (ValidateException $e) {
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => $e->getError()
- )));
- }
- if (empty($id)){
- $data['telearr'] = array();
- $data['video'] = input('new_video/s', "");
- $demand = DemandModel::create($data);
- }else{
- $old_video = input('old_video/s','');
- $new_video = input('new_video/s','');
- if(!empty($new_video)){
- $data['video'] = $new_video;
- }else{
- if(!empty($old_video))
- {
- $data['video'] = $old_video;
- }
- }
- $demand = DemandModel::find($id);
- DemandLogModel::update([ 'workerid' => input('workerid/d', 0) ],['demandid'=>$demand->id]);
- $demand->save($data);
- }
- exit(json_encode(array(
- 'code' => 0
- )));
- }
-
- public function fieldDemand()
- {
- $id = input('id/d',0);
- $demand = DemandModel::findOrEmpty($id);
- if ($demand->isEmpty()){
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => "信息不存在"
- )));
- }else{
- $demand->save([
- input('field/s') => input('value')
- ]);
- }
- exit(json_encode(array(
- 'code' => 0
- )));
- }
-
- public function delDemand()
- {
- $idarr = input('idarr/a');
- DemandLogModel::whereIn('demandid',$idarr)->delete();
- $result = Db::name('demand')->whereIn('id',$idarr)->update(['deletetime'=>time()]);
- if ($result){
- exit(json_encode(array(
- 'code' => 0,
- 'msg' => ""
- )));
- }
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => "删除失败,请稍后重试"
- )));
- }
-
- public function listDemand()
- {
- $limit = input('limit/d',20);
- $page = input('page/d',1);
- $map = array();
- $keywords = input('keywords/s', "");
- if (!empty($keywords)){
- $map[] =['title', 'like', '%'.$keywords.'%'];
- }
- $workerid = input('workerid/d', 0);
- if (!empty($workerid)){
- $map[] = ['workerid', '=', $workerid];
- }
- $cateid = input('cateid/d', 0);
- if (!empty($cateid)){
- $map[] = ['cateid', '=', $cateid];
- }
- $wtype = input('wtype/d');
- if (!empty($wtype)){
- $map[] = ['wtype', '=', $wtype];
- }
- $ftype = input('ftype/d');
- if (!empty($ftype)){
- $map[] = ['ftype', '=', $ftype];
- }
- $status = input('status/d');
- if (!empty($status)){
- $map[] = ['status', '=', $status];
- }
- $isfree = input('isfree/d',0);
- if (!empty($isfree)){
- $map[] = ['isfree', '=', $isfree];
- }
- $daterange = input('daterange/s', "");
- if (!empty($daterange)){
- $daterangearr = explode("~", $daterange);
- $map[] = ['createtime', '>= time', trim($daterangearr[0])];
- $map[] = ['createtime', '<= time', trim($daterangearr[1])];
- }
- $list = DemandModel::with(['worker','demandCate'])->withCount(['demandLog'])->where($map)->order(['priority'=>'desc','id'=>'desc',])->limit($limit)->page($page)->append(['wtype_text','ftype_text','status_text','isfree_text'])->select();
- $count = DemandModel::where($map)->count();
- if ($count==0){
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => "未查询到数据"
- )));
- }
- exit(json_encode(array(
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list
- )));
- }
-
- // 岗位类型
- public function cateList()
- {
- return view('demand/catelist');
- }
-
- public function cateForm()
- {
- $id = input('id/d', 0);
- $cate = DemandCateModel::findOrEmpty($id);
- return view('demand/cateform',[
- 'cate' => $cate
- ]);
- }
-
- public function listCate()
- {
- $limit = input('limit');
- $page = input('page');
- $list = DemandCateModel::order(['priority'=>'desc','id'=>'desc'])->limit($limit)->page($page)->select();
- $count = DemandCateModel::count();
- if ($count==0){
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => "未查询到数据"
- )));
- }
- exit(json_encode(array(
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list
- )));
- }
-
- public function fieldCate()
- {
- $id = input('id/d', 0);
- $info = DemandCateModel::find($id);
- $info->save([
- input('field/s') => input('value/s', "")
- ]);
- exit(json_encode(array(
- 'code' => 0
- )));
- }
-
- public function editCate()
- {
- $id = input('id/d');
- if (empty($id)){
- $cate = DemandCateModel::create([
- 'title' => input('title/s', ""),
- 'priority' => input('priority/d', 0)
- ]);
- }else{
- $cate = DemandCateModel::find($id);
- $cate->save([
- 'title' => input('title/s', ""),
- 'priority' => input('priority/d', 0)
- ]);
- }
- exit(json_encode(array(
- 'code' => 0
- )));
- }
-
- public function delCate()
- {
- $id = input('id/d');
- $cate = DemandCateModel::where('id',$id)->select();
- $result = $cate->delete();
- if ($result){
- exit(json_encode(array(
- 'code' => 0,
- 'msg' => ""
- )));
- }
- exit(json_encode(array(
- 'code' => 1,
- 'msg' => "删除失败,请稍后重试"
- )));
- }
-
- }
|