ConfigsController.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. namespace App\Http\Controllers\Config;
  3. use App\Http\Controllers\AdminBaseController;
  4. use App\Models\ExpenseMoney;
  5. use App\Models\Level;
  6. use App\Models\OrderAccountsSet;
  7. use App\Repositories\Eloquent\ConfigRepositoryEloquent;
  8. use App\Servers\CommonServer;
  9. use App\Validators\ConfigValidator;
  10. use App\Http\Requests\ConfigUpdateRequest;
  11. use App\Models\Config;
  12. use App\Models\ShopSet;
  13. use Prettus\Validator\Exceptions\ValidatorException;
  14. /**
  15. * Class CommentTagsController.
  16. *
  17. * @package namespace App\Http\Controllers;
  18. */
  19. class ConfigsController extends AdminBaseController
  20. {
  21. protected $repository;
  22. protected $validator;
  23. /**
  24. * CommentTagsController constructor.
  25. *
  26. */
  27. public function __construct(ConfigRepositoryEloquent $repository, ConfigValidator $validator)
  28. {
  29. parent::__construct($repository, $validator);
  30. }
  31. /**
  32. * Display a listing of the resource.
  33. *
  34. * @return \Illuminate\Http\Response
  35. */
  36. public function index_new()
  37. {
  38. $configs=Config::whereIn('key',['exchange_money','receive_mix','receive_max','receive_level_id','receive_user_max','receive_address','open_sys','common_address','sediment_address','common_num','common_bnb','common_db'])->pluck('value','key');
  39. $level_list = $this->getLevelList($configs->get('receive_level_id'));
  40. return view('admins.configs.index',['configs'=>$configs,'levelList' => json_encode($level_list, JSON_UNESCAPED_SLASHES)]);
  41. }
  42. /**
  43. * 获取层级菜单组件
  44. * @return array
  45. */
  46. private function getLevelList($level = '0')
  47. {
  48. $option = [
  49. 'checked' => $level . '',
  50. 'attr' => [
  51. [
  52. 'value' => '0',
  53. 'label' => "L0",
  54. 'disabled' => false,
  55. 'notice' => '*'
  56. ],
  57. ]
  58. ];
  59. $levels=Level::select(['id','name'])->get();
  60. foreach ($levels as $level){
  61. $option['attr'][]=[
  62. 'value' => $level->{'id'}.'',
  63. 'label' => $level->{'name'},
  64. 'disabled' => false,
  65. 'notice' => '*'
  66. ];
  67. }
  68. return $option;
  69. }
  70. function use_expense(){
  71. if(request()->isMethod('post')){
  72. $data=request()->all();
  73. if(isset($data['_token']))unset($data['_token']);
  74. ExpenseMoney::where('id',1)->update($data);
  75. return $this->response(self::SUCCESS_MSG,'success','',route('admin.config.on_order_set'));
  76. }else{
  77. $configs=ExpenseMoney::where('id',1)->first();
  78. return view('admins.configs.use_expense',['configs'=>$configs]);
  79. }
  80. }
  81. /**
  82. * Display a listing of the resource.
  83. *
  84. * @return \Illuminate\Http\Response
  85. */
  86. public function about_us()
  87. {
  88. $configs=Config::whereIn('key',['about_us','privacy_protocol'])->pluck('value','key');
  89. return view('admins.configs.about_us',['configs'=>$configs]);
  90. }
  91. /**
  92. * Display a listing of the resource.
  93. *
  94. * @return \Illuminate\Http\Response
  95. */
  96. public function agreement()
  97. {
  98. $configs=Config::where('key','agreement')->pluck('value','key');
  99. return view('admins.configs.agreement',['configs'=>$configs]);
  100. }
  101. /**
  102. * Display a listing of the resource.
  103. *
  104. * @return \Illuminate\Http\Response
  105. */
  106. public function beans()
  107. {
  108. $configs=Config::where('key','beans')->pluck('value','key');
  109. return view('admins.configs.beans',['configs'=>$configs]);
  110. }
  111. /**
  112. * Display a listing of the resource.
  113. *
  114. * @return \Illuminate\Http\Response
  115. */
  116. public function order_set()
  117. {
  118. $configs=Config::whereIn('key',['order_affirm','order_finish'])->pluck('value','key');
  119. return view('admins.configs.order_set',['configs'=>$configs]);
  120. }
  121. function consume(){
  122. $configs=Config::whereIn('key',['consume_money','consume_for','consume_give'])->pluck('value','key');
  123. return view('admins.configs.consume',['configs'=>$configs]);
  124. }
  125. /**
  126. * Display a listing of the resource.
  127. *
  128. * @return \Illuminate\Http\Response
  129. */
  130. public function indexDown()
  131. {
  132. $configs=Config::pluck('value','key');
  133. return view('admins.configs.indexDown',['configs'=>$configs]);
  134. }
  135. function update_new1(){
  136. foreach ( request()->all() as $key => $value ){
  137. // 查找当前数据是否存在
  138. if( Config::where('key', $key)->where('value', $value)->count() ){ continue; }
  139. Config::where('key', $key)->update([ 'value' => $value ]);
  140. }
  141. return $this->response(self::SUCCESS_MSG,'success','');
  142. }
  143. }