CommonService.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace app\common\service;
  3. use app\common\constant\ApplyConstant;
  4. use app\common\constant\CommonConstant;
  5. use app\common\constant\ContractConstant;
  6. use app\common\constant\EvectionConstant;
  7. use app\common\constant\LeaveConstant;
  8. use app\common\constant\MaintainConstant;
  9. use app\common\constant\OfferConstant;
  10. use think\cache\driver\Redis;
  11. /**
  12. * 公共服务类
  13. */
  14. class CommonService
  15. {
  16. /**
  17. * 拼接查询字段
  18. *
  19. * @param string $field
  20. * @param string $aliasName
  21. */
  22. public static function getAliasField($field, $aliasName)
  23. {
  24. $field = explode(',', $field);
  25. foreach ($field as &$value) {
  26. $value = $aliasName . $value;
  27. }
  28. return $field;
  29. }
  30. /**
  31. * 判断用户是否是物业主管或信息负责人
  32. *
  33. * @param mixed $user 用户信息
  34. **/
  35. public static function isMaintain($user){
  36. if (in_array($user['title'], MaintainConstant::get_type_title_list())) {
  37. return true;
  38. }
  39. return false;
  40. }
  41. /**
  42. * 类型数据
  43. */
  44. public static function get_data()
  45. {
  46. $module_list = get_one_two_array(CommonConstant::get_module_list(), 'id', 'name');
  47. $degree_list = get_one_two_array(OfferConstant::get_degree_list(), 'id', 'name');
  48. $pay_type_list = get_one_two_array(ApplyConstant::get_pay_type_list(), 'id', 'name');
  49. $time_list = get_one_two_array(LeaveConstant::get_time_list(), 'id', 'name');
  50. $data1 = get_one_two_array(ApplyConstant::get_type_list(), 'id', 'name');
  51. $data2 = get_one_two_array(OfferConstant::get_type_list(), 'id', 'name');
  52. $data5 = get_one_two_array(EvectionConstant::get_type_list(), 'id', 'name');
  53. $data6 = get_one_two_array(LeaveConstant::get_type_list(), 'id', 'name');
  54. $data8 = get_one_two_array(MaintainConstant::get_type_list(), 'id', 'name');
  55. $data9 = get_one_two_array(ContractConstant::get_type_list(), 'id', 'name');
  56. return compact("module_list", "degree_list", "pay_type_list", "time_list", "data1", "data2", "data5", "data6", "data8", "data9");
  57. }
  58. /**
  59. * 根据模块获取审批流项
  60. *
  61. * @param integer $module
  62. **/
  63. public static function get_item_list($module){
  64. $get_item_list = [];
  65. switch ($module){
  66. case CommonConstant::MODULE_5:
  67. $get_item_list = EvectionConstant::get_type_list();
  68. break;
  69. case CommonConstant::MODULE_6:
  70. $get_item_list = LeaveConstant::get_time_list();
  71. break;
  72. case CommonConstant::MODULE_8:
  73. $get_item_list = MaintainConstant::get_type_list();
  74. break;
  75. }
  76. return $get_item_list;
  77. }
  78. /**
  79. * 根据模块获取类型列表
  80. *
  81. * @param integer $module
  82. **/
  83. public static function get_type_list($module){
  84. $list = [];
  85. switch ($module) {
  86. case CommonConstant::MODULE_1:
  87. $list = ApplyConstant::get_type_list();
  88. break;
  89. case CommonConstant::MODULE_2:
  90. $list = OfferConstant::get_type_list();
  91. break;
  92. case CommonConstant::MODULE_5:
  93. $list = EvectionConstant::get_type_list();
  94. break;
  95. case CommonConstant::MODULE_6:
  96. $list = LeaveConstant::get_type_list();
  97. break;
  98. case CommonConstant::MODULE_8:
  99. $list = MaintainConstant::get_type_list();
  100. break;
  101. case CommonConstant::MODULE_9:
  102. $list = ContractConstant::get_type_list();
  103. break;
  104. }
  105. return $list;
  106. }
  107. }