common.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------------------------------
  4. * GouGuOPEN [ 左手研发,右手开源,未来可期!]
  5. +-----------------------------------------------------------------------------------------------
  6. * @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
  7. +-----------------------------------------------------------------------------------------------
  8. * @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
  9. +-----------------------------------------------------------------------------------------------
  10. * @Author 勾股工作室 <hdm58@qq.com>
  11. +-----------------------------------------------------------------------------------------------
  12. */
  13. /**
  14. ======================
  15. *模块数据获取公共文件
  16. ======================
  17. */
  18. use think\facade\Db;
  19. //客户查看编辑数据权限判断
  20. function customer_auth($uid,$customer_id)
  21. {
  22. $customer = Db::name('Customer')->where(['id' => $customer_id])->find();
  23. if($customer['belong_uid']==0){
  24. return $customer;
  25. }
  26. //是否是客户管理员
  27. $auth = isAuth($uid,'customer_admin','conf_1');
  28. $role= 0;
  29. if($auth==1){
  30. //可见部门数据
  31. $dids = get_role_departments($uid);
  32. if(in_array($customer['belong_did'],$dids)){
  33. $role= 1;
  34. }
  35. }
  36. else if($auth==0){
  37. $auth_array=[];
  38. if(!empty($customer['share_ids'])){
  39. $share_ids = explode(",",$customer['share_ids']);
  40. $auth_array = array_merge($auth_array,$share_ids);
  41. }
  42. array_push($auth_array,$customer['belong_uid']);
  43. //部门负责人
  44. $dids = get_leader_departments($uid);
  45. if(in_array($uid,$auth_array) || in_array($customer['belong_did'],$dids)){
  46. $role= 1;
  47. }
  48. }
  49. if($role == 0){
  50. throw new \think\exception\HttpException(405, '无权限访问');
  51. }
  52. else{
  53. return $customer;
  54. }
  55. }
  56. //读取联系人
  57. function customer_contact($cid)
  58. {
  59. $contact = Db::name('CustomerContact')->where(['delete_time' => 0,'cid'=>$cid])->select()->toArray();
  60. return $contact;
  61. }
  62. //读取销售机会
  63. function customer_chance($cid)
  64. {
  65. $chance = Db::name('CustomerChance')->where(['delete_time' => 0,'cid'=>$cid])->select()->toArray();
  66. return $chance;
  67. }