ComjobsService.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. namespace app\common\service;
  3. use app\common\model\Param;
  4. use app\common\model\RensheCode;
  5. use app\common\model\Comjobs as ComjobsModel;
  6. use app\common\model\ComjobsCate as ComjobsCateModel;
  7. class ComjobsService extends BaseService
  8. {
  9. public function importComjobs($file_url, $worker_id)
  10. {
  11. $data = ['title', 'cate', 'address', 'community', 'agegroup', 'enddate', 'comdetails', 'requirement', 'wtype', 'zwagall', 'telephone', 'remark', 'recruit_num', 'education'];
  12. $list = importExecl($file_url, $data, 1);
  13. $data = [];
  14. $wtype = ['按月' => 1, '按时' => 2, '按件' => 3, '按项目' => 4, '其他' => 5];
  15. $rensheCode = RensheCode::select();
  16. $renshe = [];
  17. foreach ($rensheCode as $v) {
  18. $renshe[$v['type']][$v['name']] = $v['code'];
  19. }
  20. $cateList = ComjobsCateModel::column('id', 'title');
  21. foreach ($list as $k => $v) {
  22. $empty_check = [
  23. 'title' => '标题',
  24. 'cate' => '岗位',
  25. 'address' => '地址',
  26. 'community' => '社区',
  27. 'agegroup' => '招工年龄',
  28. 'enddate' => '截止日期',
  29. 'wtype' => '结算类型',
  30. 'zwagall' => '薪酬',
  31. 'telephone' => '咨询电话',
  32. 'recruit_num' => '招聘人数',
  33. 'education' => '最低学历',
  34. ];
  35. foreach ($empty_check as $key => $value) {
  36. if (empty($v[$key])) {
  37. return $this->error('第' . ($k + 2) . '行的' . $value . '不能为空');
  38. }
  39. }
  40. $item = [];
  41. if (empty($cateList[$v['cate']])) {
  42. return $this->error('第' . ($k + 2) . '行的岗位选择有误');
  43. }
  44. $item['cateid'] = $cateList[$v['cate']];
  45. $item['title'] = $v['title'];
  46. $item['province'] = '福建省';
  47. $item['city'] = '泉州市';
  48. $item['district'] = '晋江市';
  49. $item['address'] = $v['address'];
  50. if (empty($renshe['community'][$v['community']])) {
  51. return $this->error('第' . ($k + 2) . '行的社区选择有误');
  52. }
  53. $item['community'] = $renshe['community'][$v['community']];
  54. $item['agegroup'] = $v['agegroup'];
  55. $enddate = strtotime($v['enddate']);
  56. if ($enddate <= 0) {
  57. return $this->error('第' . ($k + 2) . '行的截止日期填写错误,格式2022-10-20');
  58. }
  59. $item['enddate'] = strtotime($v['enddate']);
  60. $item['comdetails'] = $v['comdetails'];
  61. $item['requirement'] = $v['requirement'];
  62. if (empty($wtype[$v['wtype']])) {
  63. return $this->error('第' . ($k + 2) . '行的结算类型选择有误');
  64. }
  65. $item['wtype'] = $wtype[$v['wtype']];
  66. $item['zwagall'] = $item['bwagall'] = $v['zwagall'];
  67. if (empty($renshe['education'][$v['education']])) {
  68. return $this->error('第' . ($k + 2) . '行的最低学历选择有误');
  69. }
  70. $item['telephone'] = $v['telephone'];
  71. $item['remark'] = $v['remark'];
  72. if ($v['recruit_num'] < 1) {
  73. return $this->error('第' . ($k + 2) . '行的招聘人数需要大于等于1');
  74. }
  75. $item['recruit_num'] = (int)$v['recruit_num'];
  76. $item['education'] = $v['education'];
  77. $item['is_worry'] = 0;
  78. $item['picall'] = [];
  79. $item['tags'] = [];
  80. $item['emp_time'] = [];
  81. $item['companydetails'] = '';
  82. $item['video'] = '';
  83. $item['priority'] = 0;
  84. $item['status'] = 3;
  85. $item['createtime'] = $item['updatetime'] = time();
  86. $item['workerid'] = $worker_id;
  87. $data[] = $item;
  88. }
  89. foreach ($data as $v) {
  90. ComjobsModel::create($v);
  91. }
  92. return $this->success('导入成功');
  93. }
  94. public function dealCommission($broker_id, $value)
  95. {
  96. //门店抽成
  97. $agent_commission_percent = Param::value('agent_commission');
  98. if (((int)$agent_commission_percent) == 0) {
  99. $agent_commission = 0;
  100. } else {
  101. $agent_commission = $value * $agent_commission_percent / 100;
  102. $agent_commission = round($agent_commission, 2);
  103. $agentMoney = new AgentMoneyService();
  104. $agentMoney->add($broker_id, $agent_commission, '悬赏招聘', '悬赏招聘推荐入职成功后奖励');
  105. }
  106. //经纪人抽成
  107. $comjobs_commission_percent = Param::value('comjobs_commission');
  108. if (((int)$comjobs_commission_percent) != 0) {
  109. $comjobs_commission = $value * (1 - $comjobs_commission_percent / 100);
  110. $comjobs_commission = round($comjobs_commission, 2);
  111. $comjobs_commission -= $agent_commission;
  112. $incomeService = new IncomeService();
  113. $incomeService->add($broker_id, $comjobs_commission, '悬赏招聘', '悬赏招聘推荐入职成功后奖励');
  114. }
  115. return $this->success('处理成功');
  116. }
  117. }