123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace app\common\service;
- use app\common\model\Param;
- use app\common\model\RensheCode;
- use app\common\model\Comjobs as ComjobsModel;
- use app\common\model\ComjobsCate as ComjobsCateModel;
- class ComjobsService extends BaseService
- {
- public function importComjobs($file_url, $worker_id)
- {
- $data = ['title', 'cate', 'address', 'community', 'agegroup', 'enddate', 'comdetails', 'requirement', 'wtype', 'zwagall', 'telephone', 'remark', 'recruit_num', 'education'];
- $list = importExecl($file_url, $data, 1);
- $data = [];
- $wtype = ['按月' => 1, '按时' => 2, '按件' => 3, '按项目' => 4, '其他' => 5];
- $rensheCode = RensheCode::select();
- $renshe = [];
- foreach ($rensheCode as $v) {
- $renshe[$v['type']][$v['name']] = $v['code'];
- }
- $cateList = ComjobsCateModel::column('id', 'title');
- foreach ($list as $k => $v) {
- $empty_check = [
- 'title' => '标题',
- 'cate' => '岗位',
- 'address' => '地址',
- 'community' => '社区',
- 'agegroup' => '招工年龄',
- 'enddate' => '截止日期',
- 'wtype' => '结算类型',
- 'zwagall' => '薪酬',
- 'telephone' => '咨询电话',
- 'recruit_num' => '招聘人数',
- 'education' => '最低学历',
- ];
- foreach ($empty_check as $key => $value) {
- if (empty($v[$key])) {
- return $this->error('第' . ($k + 2) . '行的' . $value . '不能为空');
- }
- }
- $item = [];
- if (empty($cateList[$v['cate']])) {
- return $this->error('第' . ($k + 2) . '行的岗位选择有误');
- }
- $item['cateid'] = $cateList[$v['cate']];
- $item['title'] = $v['title'];
- $item['province'] = '福建省';
- $item['city'] = '泉州市';
- $item['district'] = '晋江市';
- $item['address'] = $v['address'];
- if (empty($renshe['community'][$v['community']])) {
- return $this->error('第' . ($k + 2) . '行的社区选择有误');
- }
- $item['community'] = $renshe['community'][$v['community']];
- $item['agegroup'] = $v['agegroup'];
- $enddate = strtotime($v['enddate']);
- if ($enddate <= 0) {
- return $this->error('第' . ($k + 2) . '行的截止日期填写错误,格式2022-10-20');
- }
- $item['enddate'] = strtotime($v['enddate']);
- $item['comdetails'] = $v['comdetails'];
- $item['requirement'] = $v['requirement'];
- if (empty($wtype[$v['wtype']])) {
- return $this->error('第' . ($k + 2) . '行的结算类型选择有误');
- }
- $item['wtype'] = $wtype[$v['wtype']];
- $item['zwagall'] = $item['bwagall'] = $v['zwagall'];
- if (empty($renshe['education'][$v['education']])) {
- return $this->error('第' . ($k + 2) . '行的最低学历选择有误');
- }
- $item['telephone'] = $v['telephone'];
- $item['remark'] = $v['remark'];
- if ($v['recruit_num'] < 1) {
- return $this->error('第' . ($k + 2) . '行的招聘人数需要大于等于1');
- }
- $item['recruit_num'] = (int)$v['recruit_num'];
- $item['education'] = $v['education'];
- $item['is_worry'] = 0;
- $item['picall'] = [];
- $item['tags'] = [];
- $item['emp_time'] = [];
- $item['companydetails'] = '';
- $item['video'] = '';
- $item['priority'] = 0;
- $item['status'] = 3;
- $item['createtime'] = $item['updatetime'] = time();
- $item['workerid'] = $worker_id;
- $data[] = $item;
- }
- foreach ($data as $v) {
- ComjobsModel::create($v);
- }
- return $this->success('导入成功');
- }
- public function dealCommission($broker_id, $value)
- {
- //门店抽成
- $agent_commission_percent = Param::value('agent_commission');
- if (((int)$agent_commission_percent) == 0) {
- $agent_commission = 0;
- } else {
- $agent_commission = $value * $agent_commission_percent / 100;
- $agent_commission = round($agent_commission, 2);
- $agentMoney = new AgentMoneyService();
- $agentMoney->add($broker_id, $agent_commission, '悬赏招聘', '悬赏招聘推荐入职成功后奖励');
- }
- //经纪人抽成
- $comjobs_commission_percent = Param::value('comjobs_commission');
- if (((int)$comjobs_commission_percent) != 0) {
- $comjobs_commission = $value * (1 - $comjobs_commission_percent / 100);
- $comjobs_commission = round($comjobs_commission, 2);
- $comjobs_commission -= $agent_commission;
- $incomeService = new IncomeService();
- $incomeService->add($broker_id, $comjobs_commission, '悬赏招聘', '悬赏招聘推荐入职成功后奖励');
- }
- return $this->success('处理成功');
- }
- }
|