SettingModel.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. namespace app\common\model;
  3. class SettingModel extends BaseModel
  4. {
  5. // 设置表名
  6. protected $name = 'setting';
  7. // 短信配置
  8. const SMS = [
  9. 'sms_chuanglan_appkey',
  10. 'sms_chuanglan_secret',
  11. 'sms_type',
  12. 'sms_verify_expire',
  13. ];
  14. const SYSTEM = [
  15. 'site_name',
  16. ];
  17. const SMS_TYPE = [
  18. ['value' => '\\chuanglan\\Chuanglan', 'text' => '创蓝短信'],
  19. ];
  20. const TALENT = [
  21. 'talent_level_1',
  22. 'talent_level_2',
  23. 'talent_level_3',
  24. 'talent_level_4',
  25. 'talent_level_5',
  26. 'talent_level_6',
  27. 'talent_level_7',
  28. 'talent_industry_trade',
  29. 'talent_industry_goods',
  30. 'talent_industry_clothing',
  31. 'talent_industry_drug',
  32. 'talent_industry_medical',
  33. 'talent_industry_hotel',
  34. 'talent_industry_traffic',
  35. 'talent_industry_other',
  36. 'talent_age_1',
  37. 'talent_age_2',
  38. 'talent_age_3',
  39. 'talent_age_4',
  40. 'talent_education_1',
  41. 'talent_education_2',
  42. 'talent_education_3',
  43. 'talent_problem_total',
  44. 'talent_problem_deal',
  45. 'talent_problem_talent',
  46. 'talent_problem_determine',
  47. 'talent_problem_traffic',
  48. 'talent_problem_house',
  49. 'talent_problem_activity',
  50. 'talent_problem_children',
  51. 'talent_problem_spouse',
  52. 'talent_problem_other',
  53. 'talent_channel_call',
  54. 'talent_channel_wechat',
  55. 'talent_channel_door',
  56. 'talent_channel_scene',
  57. 'talent_channel_other',
  58. 'talent_total',
  59. ];
  60. const ODD_JOB = [
  61. 'obb_job_deal_num',
  62. 'obb_job_deal_money',
  63. 'obb_job_service_num',
  64. ];
  65. const INDUSTRY = [
  66. 'industry_institution_num',
  67. 'industry_institution_turnover',
  68. 'industry_institution_employee',
  69. 'industry_institution_type_software',
  70. 'industry_institution_type_consult',
  71. 'industry_institution_type_train',
  72. 'industry_institution_type_flexible',
  73. 'industry_institution_type_dispatch',
  74. 'industry_institution_type_talent',
  75. 'industry_institution_type_evaluation',
  76. 'industry_institution_type_labor',
  77. 'industry_institution_type_insurance',
  78. 'industry_institution_type_other',
  79. 'industry_enterprise_num',
  80. 'industry_service_num',
  81. ];
  82. const INDUSTRY_TYPE = ['软件技术', '管理咨询', '培训教育', '灵活用工', '派遣外包', '人才猎聘', '测评背调', '劳务输出','商业保险','其他'];
  83. public static function getConfigValue($code)
  84. {
  85. $res = [];
  86. if (is_array($code)) {
  87. $list = self::where('code', 'in', $code)->select();
  88. if ($list->isEmpty()) {
  89. return [];
  90. }
  91. foreach ($list as $v) {
  92. $res[$v['code']] = $v['value'];
  93. }
  94. } elseif (is_string($code)) {
  95. $info = self::where('code', $code)->find();
  96. if (empty($info)) {
  97. return '';
  98. }
  99. $res = $info['value'];
  100. }
  101. return $res;
  102. }
  103. public static function setConfigValue($code, $value = '')
  104. {
  105. if (is_array($code)) {
  106. foreach ($code as $k => $v) {
  107. self::setConfigValueSingle($k, $v);
  108. }
  109. } elseif (is_string($code)) {
  110. self::setConfigValueSingle($code, $value);
  111. }
  112. }
  113. public static function setConfigValueSingle($code, $value = '')
  114. {
  115. $info = self::where('code', $code)->find();
  116. if (empty($info)) {
  117. self::create(['code' => $code, 'value' => $value]);
  118. } else {
  119. $info->value = $value;
  120. $info->save();
  121. }
  122. }
  123. }