CustomerLogic.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * 客户逻辑类
  4. *
  5. * @author qifan
  6. * @date 2020-01-18
  7. */
  8. namespace app\crm\logic;
  9. use think\Db;
  10. class CustomerLogic
  11. {
  12. /**
  13. * 获取员工角色ID
  14. *
  15. * @param $userId
  16. * @return array|false|string
  17. */
  18. public function getEmployeeGroups($userId)
  19. {
  20. return Db::name('admin_access')->where('user_id', $userId)->column('group_id');
  21. }
  22. /**
  23. * 获取员工角色下的规则ID
  24. *
  25. * @param $groupIds
  26. * @return array|false|string
  27. */
  28. public function getEmployeeRules($groupIds)
  29. {
  30. return Db::name('admin_group')->whereIn('id', $groupIds)->column('rules');
  31. }
  32. /**
  33. * 获取公海管理规则数据
  34. *
  35. * @return bool|\PDOStatement|string|\think\Collection
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\ModelNotFoundException
  38. * @throws \think\exception\DbException
  39. */
  40. public function getPoolRules()
  41. {
  42. # 公海管理查询条件
  43. $poolRuleWhere['types'] = 2;
  44. $poolRuleWhere['title'] = '公海管理';
  45. $poolRuleWhere['name'] = 'customer';
  46. $poolRuleWhere['level'] = 2;
  47. # 查询公海管理ID
  48. $poolRuleId = Db::name('admin_rule')->where($poolRuleWhere)->value('id');
  49. return Db::name('admin_rule')->field(['id', 'name'])->where('pid', $poolRuleId)->select();
  50. }
  51. }