ServiceController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 17812
  5. * Date: 2020/4/28
  6. * Time: 10:07
  7. */
  8. namespace app\frontend\modules\member\controllers;
  9. use app\common\components\ApiController;
  10. class ServiceController extends ApiController
  11. {
  12. public function index()
  13. {
  14. $res = [];
  15. if (app('plugins')->isEnabled('customer-service')) {
  16. $set = array_pluck(\Setting::getAllByGroup('customer-service')->toArray(), 'value', 'key');
  17. if ($set['is_open'] == 1) {
  18. if (request()->type == 2) {
  19. $arr = $this->miniSetting($set);
  20. }else{
  21. $arr = $this->getSetting($set);
  22. }
  23. $res = $arr;
  24. }
  25. }
  26. return $res;
  27. }
  28. public function supplier_set($uid,$type)
  29. {
  30. $res = ['mark'=>false];
  31. if (app('plugins')->isEnabled('customer-service')) {
  32. $set = array_pluck(\Setting::getAllByGroup('customer-service')->toArray(), 'value', 'key');
  33. if ($set['is_open'] == 1) {
  34. $supplierSet = \Setting::get('plugin.supplier.customer[' . $uid . ']');
  35. if($supplierSet['is_open'] == 1)
  36. {
  37. if ($type == 2) {
  38. $arr = $this->miniSetting($supplierSet);
  39. }else{
  40. $arr = $this->getSetting($supplierSet);
  41. }
  42. }else{
  43. if ($type == 2) {
  44. $arr = $this->miniSetting($set);
  45. }else{
  46. $arr = $this->getSetting($set);
  47. }
  48. }
  49. $res = array_merge($arr,['mark'=>true]);
  50. }
  51. }
  52. return $res;
  53. }
  54. public function store_set($store_ID,$type)
  55. {
  56. $res = ['mark'=>false];
  57. if (app('plugins')->isEnabled('customer-service')) {
  58. $set = array_pluck(\Setting::getAllByGroup('customer-service')->toArray(), 'value', 'key');
  59. if ($set['is_open'] == 1) {
  60. $storeSet = \Setting::get('plugin.store.customer[' . $store_ID . ']');
  61. if($storeSet['is_open'] == 1)
  62. {
  63. if ($type == 2) {
  64. $arr = $this->miniSetting($storeSet);
  65. }else{
  66. $arr = $this->getSetting($storeSet);
  67. }
  68. }else{
  69. if ($type == 2) {
  70. $arr = $this->miniSetting($set);
  71. }else{
  72. $arr = $this->getSetting($set);
  73. }
  74. }
  75. $res = array_merge($arr,['mark'=>true]);
  76. }
  77. }
  78. return $res;
  79. }
  80. public function getSetting($set)
  81. {
  82. return [
  83. 'cservice'=>$set['link'],
  84. 'service_QRcode' => yz_tomedia($set['QRcode']),
  85. 'service_mobile' => $set['mobile']
  86. ];
  87. }
  88. public function miniSetting($set)
  89. {
  90. return [
  91. 'cservice'=>$set['mini_link'],
  92. 'customer_open'=>$set['mini_open'],
  93. 'service_QRcode' => yz_tomedia($set['mini_QRcode']),
  94. 'service_mobile' => $set['mini_mobile']
  95. ];
  96. }
  97. }