123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- <?php
- namespace app\mainapp\controller;
- use think\facade\Session;
- use app\mainapp\BaseController;
- use app\common\model\Demand as DemandModel;
- use app\common\model\DemandCate as DemandCateModel;
- use app\common\model\DemandLog as DemandLogModel;
- use app\common\model\Param as ParamModel;
- use app\common\model\User as UserModel;
- use app\common\model\Worker as WorkerModel;
- use app\common\model\UserIntegral as UserIntegralModel;
- use app\common\validate\Demand as DemandValidate;
- use think\exception\ValidateException;
- class Wdemand extends BaseController
- {
-
- public function pageWdemandLog()
- {
- $demandid = input('demandid/d', 0);
- $workerid = input('workerid/d', 0);
- $demand = DemandModel::where(['workerid'=>$workerid])->append(['ftype_text'])->findOrEmpty($demandid);
- if ( $demand->isEmpty() ){
- page_result(1, "招聘订单信息不存在。");
- }
- $logcount = DemandLogModel::where(['demandid'=>$demandid])->count();
- page_result(0, "", array(
- 'demand' => $demand,
- 'logcount' => $logcount
- ));
- }
-
- public function wdemandLogList()
- {
- $ppage = input('ppage/d', 1);
- $psize = input('psize/d', 20);
- $map = array();
- $workerid = input('workerid/d', 0);
- $map[] = ['workerid','=',$workerid];
- $demandid = input('demandid/d', 0);
- $map[] = ['demandid','=',$demandid];
- $plist = DemandLogModel::with(['gworker'])->where($map)->order(['createtime'=>'desc', 'id'=>'desc'])->page($ppage)->limit($psize)->select();
- page_result(0, "", array(
- 'plist' => $plist,
- 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
- ));
- }
-
-
-
- public function pageComlog()
- {
- $workerid = input('workerid/d', 0);
- $demandlist = DemandModel::where(['workerid'=>$workerid])->order(['updatetime'=>'desc', 'createtime'=>'desc', 'id'=>'desc'])->field('id as value,title')->select()->toArray();
- array_unshift( $demandlist, array('id'=>0,'value'=>'全部') );
- page_result(0, "", array(
- 'demandlist' => $demandlist,
- 'statuslist' => array( ['value'=>0,'title'=>"全部"], ['value'=>1,'title'=>"未跟进"], ['value'=>2,'title'=>"未面试"], ['value'=>3,'title'=>"面试通过"], ['value'=>4,'title'=>"面试未通过"], ['value'=>5,'title'=>"用户放弃"], ['value'=>6,'title'=>"已入职"], ['value'=>7,'title'=>"已离职"] )
- ));
- }
-
- public function listComlog()
- {
- $ppage = input('ppage/d', 1);
- $psize = input('psize/d', 20);
- $map = array();
- $workerid = input('workerid/d', 0);
- $map[] = ['workerid','=',$workerid];
- $status = input('status/d', 0);
- if (!empty($status)){
- $map[] = ['status','=',$status];
- }
- $demandid = input('demandid/d', 0);
- if (!empty($demandid)){
- $map[] = ['demandid','=',$demandid];
- }
- $plist = DemandLogModel::with(['demand','user'])->where($map)->order(['createtime'=>'desc', 'id'=>'desc'])->page($ppage)->limit($psize)->append(['status_text'])->select();
- page_result(0, "", array(
- 'plist' => $plist,
- 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
- ));
- }
-
- public function delLog()
- {
- $userid = input('userid/d', 0);
- $workerid = input('workerid/d', 0);
- $user = UserModel::where(1)->findOrEmpty($userid);
- $worker = WorkerModel::where(['userid'=>$userid])->findOrEmpty($workerid);
- if ( $user->isEmpty() || $worker->isEmpty() ){
- page_result(1, "用户或公司信息不存在。");
- }
- $logid = input('logid/d', 0);
- $demandlog = DemandLogModel::where(['workerid'=>$workerid])->findOrEmpty($logid);
- if ( $demandlog->isEmpty() ){
- page_result(1, "报名记录信息不存在。");
- }
- $demandlog->delete();
- page_result(0, "", array());
- }
-
- public function statusLog()
- {
- $userid = input('userid/d', 0);
- $workerid = input('workerid/d', 0);
- $user = UserModel::where(1)->findOrEmpty($userid);
- $worker = WorkerModel::where(['userid'=>$userid])->findOrEmpty($workerid);
- if ( $user->isEmpty() || $worker->isEmpty() ){
- page_result(1, "用户或公司信息不存在。");
- }
- $logid = input('logid/d', 0);
- $demandlog = DemandLogModel::with(['demand','user'])->where(['workerid'=>$workerid])->append(['status_text'])->findOrEmpty($logid);
- if ( $demandlog->isEmpty() ){
- page_result(1, "报名记录信息不存在。");
- }
- $status = input('status/d', 1);
- $demandlog->save([
- 'status' => $status
- ]);
- page_result(0, "", array(
- 'demandlog' => $demandlog
- ));
- }
-
-
- public function statusDemand()
- {
- $userid = input('userid/d', 0);
- $workerid = input('workerid/d', 0);
- $user = UserModel::where(1)->findOrEmpty($userid);
- $worker = WorkerModel::where(['userid'=>$userid])->findOrEmpty($workerid);
- if ( $user->isEmpty() || $worker->isEmpty() ){
- page_result(1, "用户或公司信息不存在。");
- }
- $demandid = input('demandid/d', 0);
- $demand = DemandModel::where(1)->findOrEmpty($demandid);
- if ( $demand->isEmpty() ){
- page_result(1, "招聘订单信息不存在。");
- }
- $status = input('status/d', 3);
- if ( $status==3 && time()>strtotime($demand->enddate)+86400 ){
- page_result(1, "招聘时间已截止,请先编辑招聘订单截止日期。");
- }
- $demand->save([
- 'status' => $status
- ]);
- page_result(0, "", array());
- }
-
- public function updateDemand()
- {
- $userid = input('userid/d', 0);
- $workerid = input('workerid/d', 0);
- $user = UserModel::where(1)->findOrEmpty($userid);
- $worker = WorkerModel::where(['userid'=>$userid])->findOrEmpty($workerid);
- if ( $user->isEmpty() || $worker->isEmpty() ){
- page_result(1, "用户或公司信息不存在。");
- }
- $param = ParamModel::where(1)->findOrEmpty();
- if ($user->integral < $param->topdemand){
- page_result(1, "每次置顶招聘订单信息需要扣除".$param->topdemand."聘豆,你当前聘豆不足。");
- }
- $demandid = input('demandid/d', 0);
- $demand = DemandModel::where(1)->findOrEmpty($demandid);
- if ( $demand->isEmpty() ){
- page_result(1, "招聘信息不存在。");
- }
- $demand->save(['updatetime'=>time()]);
- $intdata = array(
- 'userid' => $userid,
- 'title' => "置顶招聘订单信息扣除",
- 'intvalue' => 0 - $param->topdemand,
- 'intmoney' => 0.00,
- 'onlycontent' => "",
- 'remark' => input('title/s', ""),
- 'itype' => 5,
- 'status' => 2,
- 'createtime' => date("Y-m-d H:i:s"),
- 'yeartime' => date("Y"),
- 'monthtime' => date("Ym")
- );
- UserIntegralModel::create($intdata);
- $integral = intval($user->integral) - intval($param->topdemand);
- $user->save([
- 'integral' => $integral
- ]);
- page_result(0, "", array());
- }
-
- public function listDemand()
- {
- $status = input('status/d', 1);
- $workerid = input('workerid/d', 0);
- $ppage = input('ppage/d', 1);
- $psize = input('psize/d', 20);
- $map = array();
- $map[] = ['workerid','=',$workerid];
- if (!empty($status)){
- $map[] = ['status','=',$status];
- }
- $orderby = array('updatetime'=>'desc', 'createtime'=>'desc', 'id'=>'desc');
- $plist = DemandModel::with(['demandCate'])->where($map)->order($orderby)->page($ppage)->limit($psize)->append(['ftype_text'])->select();
- $param = ParamModel::where(1)->findOrEmpty();
- page_result(0, "", array(
- 'param' => $param,
- 'plist' => $plist,
- 'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
- ));
- }
-
- public function getDemand()
- {
- $workerid = input('workerid/d', 0);
- $demandid = input('demandid/d', 0);
- $demand = DemandModel::where('workerid','=',$workerid)->where('id','=',$demandid)->findOrEmpty();
- if ($demand->isEmpty()){
- $demand = "NULL";
- }else{
- $demand->tags = implode(" ", $demand->tags);
- }
- $catelist = DemandCateModel::order(['priority'=>'desc','id'=>'desc'])->select()->toArray();
- page_result(0, "", array(
- 'demand' => $demand,
- 'catelist' => $catelist
- ));
- }
-
-
- public function editDemand()
- {
- $userid = input('userid/d', 0);
- $workerid = input('workerid/d', 0);
- $user = UserModel::where(1)->findOrEmpty($userid);
- $worker = WorkerModel::where(['userid'=>$userid])->findOrEmpty($workerid);
- if ( $user->isEmpty() || $worker->isEmpty() ){
- page_result(1, "用户或公司信息不存在。");
- }
- $param = ParamModel::where(1)->findOrEmpty();
- $id = input('id/d', 0);
- $wtype = input('wtype/d', 1);
- $picall = input('picall/s', "");
- $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' => explode(" ", input('tags/s', "")),
- 'enddate' => input('enddate/s', ""),
- 'requirement' => input('requirement/s', ""),
- 'comdetails' => input('comdetails/s', ""),
- 'picall' => empty($picall) ? array() : explode(",", $picall),
- 'video' => input('video/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', ""),
- ];
- try {
- validate(DemandValidate::class)->check($data);
- } catch (ValidateException $e) {
- page_result(1, $e->getError());
- }
- if ($id==0) {
- $data = array_merge( $data, [
- 'status' => 1,
- 'priority' => 0,
- 'updatetime' => date("Y-m-d H:i:s"),
- 'createtime' => date("Y-m-d H:i:s"),
- 'volume' => 0,
- 'telearr' => array()
- ]);
- if ($user->integral < $param->adddemand){
- page_result(1, "每次发布招聘订单信息需要扣除".$param->adddemand."聘豆,你当前聘豆不足。");
- }
- $demand = DemandModel::create($data);
- $intdata = array(
- 'userid' => $userid,
- 'title' => "发布招聘订单信息扣除",
- 'intvalue' => 0 - $param->adddemand,
- 'intmoney' => 0.00,
- 'onlycontent' => "",
- 'remark' => input('title/s', ""),
- 'itype' => 5,
- 'status' => 2,
- 'createtime' => date("Y-m-d H:i:s"),
- 'yeartime' => date("Y"),
- 'monthtime' => date("Ym")
- );
- UserIntegralModel::create($intdata);
- $integral = intval($user->integral) - intval($param->adddemand);
- $user->save([
- 'integral' => $integral
- ]);
- }else{
- $demand = DemandModel::where('id','=',$id)->findOrEmpty();
- $demand->save($data);
- }
- page_result(0, "", array(
- 'demand' => $demand
- ));
- }
-
- }
|