ConfigsController.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace App\Http\Controllers\Config;
  3. use App\Http\Controllers\AdminBaseController;
  4. use App\Models\ExpenseMoney;
  5. use App\Models\OrderAccountsSet;
  6. use App\Repositories\Eloquent\ConfigRepositoryEloquent;
  7. use App\Servers\CommonServer;
  8. use App\Validators\ConfigValidator;
  9. use App\Http\Requests\ConfigUpdateRequest;
  10. use App\Models\Config;
  11. use App\Models\ShopSet;
  12. use Prettus\Validator\Exceptions\ValidatorException;
  13. /**
  14. * Class CommentTagsController.
  15. *
  16. * @package namespace App\Http\Controllers;
  17. */
  18. class ConfigsController extends AdminBaseController
  19. {
  20. protected $repository;
  21. protected $validator;
  22. /**
  23. * CommentTagsController constructor.
  24. *
  25. */
  26. public function __construct(ConfigRepositoryEloquent $repository, ConfigValidator $validator)
  27. {
  28. parent::__construct($repository, $validator);
  29. }
  30. /**
  31. * Display a listing of the resource.
  32. *
  33. * @return \Illuminate\Http\Response
  34. */
  35. public function index_new()
  36. {
  37. $configs=Config::whereIn('key',['delay_time','service_num','province_num','city_num','area_num','sales_num','shop_num','member_cash','beans_modulus','member_num','fans_num','purchases_num','than_column','service_type','promotion_num','replenish_date'])->pluck('value','key');
  38. return view('admins.configs.index',['configs'=>$configs]);
  39. }
  40. function use_expense(){
  41. if(request()->isMethod('post')){
  42. $data=request()->all();
  43. if(isset($data['_token']))unset($data['_token']);
  44. ExpenseMoney::where('id',1)->update($data);
  45. return $this->response(self::SUCCESS_MSG,'success','',route('admin.config.on_order_set'));
  46. }else{
  47. $configs=ExpenseMoney::where('id',1)->first();
  48. return view('admins.configs.use_expense',['configs'=>$configs]);
  49. }
  50. }
  51. /**
  52. * Display a listing of the resource.
  53. *
  54. * @return \Illuminate\Http\Response
  55. */
  56. public function about_us()
  57. {
  58. $configs=Config::whereIn('key',['about_us','privacy_protocol'])->pluck('value','key');
  59. return view('admins.configs.about_us',['configs'=>$configs]);
  60. }
  61. /**
  62. * Display a listing of the resource.
  63. *
  64. * @return \Illuminate\Http\Response
  65. */
  66. public function agreement()
  67. {
  68. $configs=Config::where('key','agreement')->pluck('value','key');
  69. return view('admins.configs.agreement',['configs'=>$configs]);
  70. }
  71. /**
  72. * Display a listing of the resource.
  73. *
  74. * @return \Illuminate\Http\Response
  75. */
  76. public function beans()
  77. {
  78. $configs=Config::where('key','beans')->pluck('value','key');
  79. return view('admins.configs.beans',['configs'=>$configs]);
  80. }
  81. /**
  82. * Display a listing of the resource.
  83. *
  84. * @return \Illuminate\Http\Response
  85. */
  86. public function order_set()
  87. {
  88. $configs=Config::whereIn('key',['order_affirm','order_finish'])->pluck('value','key');
  89. return view('admins.configs.order_set',['configs'=>$configs]);
  90. }
  91. function consume(){
  92. $configs=Config::whereIn('key',['consume_money','consume_for','consume_give'])->pluck('value','key');
  93. return view('admins.configs.consume',['configs'=>$configs]);
  94. }
  95. /**
  96. * Display a listing of the resource.
  97. *
  98. * @return \Illuminate\Http\Response
  99. */
  100. public function on_order_set()
  101. {
  102. if(request()->isMethod('post')){
  103. $data=request()->all();
  104. if(isset($data['_token']))unset($data['_token']);
  105. if(($data['province_num']+$data['city_num']+$data['area_num']+$data['sales_num']+$data['shop_num']+$data['user_num'])!=100){
  106. return $this->response('分佣比列之和必须是100','erroe');
  107. }
  108. Config::where('key','expense_num')->update(['value' =>$data['expense_num'] ]);
  109. OrderAccountsSet::where('id',1)->update($data);
  110. OrderAccountsSet::where('id','<>',1)->update(['server_num'=>$data['server_num']]);
  111. return $this->response(self::SUCCESS_MSG,'success','',route('admin.config.on_order_set'));
  112. }else{
  113. $configs=OrderAccountsSet::where('id',1)->first();
  114. $configs->{'expense_num'}=CommonServer::creatServer()->getConfigValue('expense_num');
  115. return view('admins.configs.on_order_set',['configs'=>$configs]);
  116. }
  117. }
  118. /**
  119. * Display a listing of the resource.
  120. *
  121. * @return \Illuminate\Http\Response
  122. */
  123. public function indexDown()
  124. {
  125. $configs=Config::pluck('value','key');
  126. return view('admins.configs.indexDown',['configs'=>$configs]);
  127. }
  128. function update_new1(){
  129. foreach ( request()->all() as $key => $value ){
  130. // 查找当前数据是否存在
  131. if( Config::where('key', $key)->where('value', $value)->count() ){ continue; }
  132. Config::where('key', $key)->update([ 'value' => $value ]);
  133. if(in_array($key,['province_num','city_num','area_num','sales_num','shop_num','member_num','purchases_num','fans_num','member_cash'])){
  134. ShopSet::where('shop_id','>',0)->update([$key=>$value]);
  135. }
  136. }
  137. return $this->response(self::SUCCESS_MSG,'success','');
  138. }
  139. }