| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- namespace App\Http\Controllers\Config;
- use App\Http\Controllers\AdminBaseController;
- use App\Models\ExpenseMoney;
- use App\Models\OrderAccountsSet;
- use App\Repositories\Eloquent\ConfigRepositoryEloquent;
- use App\Servers\CommonServer;
- use App\Validators\ConfigValidator;
- use App\Http\Requests\ConfigUpdateRequest;
- use App\Models\Config;
- use App\Models\ShopSet;
- use Prettus\Validator\Exceptions\ValidatorException;
- /**
- * Class CommentTagsController.
- *
- * @package namespace App\Http\Controllers;
- */
- class ConfigsController extends AdminBaseController
- {
- protected $repository;
- protected $validator;
- /**
- * CommentTagsController constructor.
- *
- */
- public function __construct(ConfigRepositoryEloquent $repository, ConfigValidator $validator)
- {
- parent::__construct($repository, $validator);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function index_new()
- {
- $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');
- return view('admins.configs.index',['configs'=>$configs]);
- }
- function use_expense(){
- if(request()->isMethod('post')){
- $data=request()->all();
- if(isset($data['_token']))unset($data['_token']);
- ExpenseMoney::where('id',1)->update($data);
- return $this->response(self::SUCCESS_MSG,'success','',route('admin.config.on_order_set'));
- }else{
- $configs=ExpenseMoney::where('id',1)->first();
- return view('admins.configs.use_expense',['configs'=>$configs]);
- }
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function about_us()
- {
- $configs=Config::whereIn('key',['about_us','privacy_protocol'])->pluck('value','key');
- return view('admins.configs.about_us',['configs'=>$configs]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function agreement()
- {
- $configs=Config::where('key','agreement')->pluck('value','key');
- return view('admins.configs.agreement',['configs'=>$configs]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function beans()
- {
- $configs=Config::where('key','beans')->pluck('value','key');
- return view('admins.configs.beans',['configs'=>$configs]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function order_set()
- {
- $configs=Config::whereIn('key',['order_affirm','order_finish'])->pluck('value','key');
- return view('admins.configs.order_set',['configs'=>$configs]);
- }
- function consume(){
- $configs=Config::whereIn('key',['consume_money','consume_for','consume_give'])->pluck('value','key');
- return view('admins.configs.consume',['configs'=>$configs]);
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function on_order_set()
- {
- if(request()->isMethod('post')){
- $data=request()->all();
- if(isset($data['_token']))unset($data['_token']);
- if(($data['province_num']+$data['city_num']+$data['area_num']+$data['sales_num']+$data['shop_num']+$data['user_num'])!=100){
- return $this->response('分佣比列之和必须是100','erroe');
- }
- Config::where('key','expense_num')->update(['value' =>$data['expense_num'] ]);
- OrderAccountsSet::where('id',1)->update($data);
- OrderAccountsSet::where('id','<>',1)->update(['server_num'=>$data['server_num']]);
- return $this->response(self::SUCCESS_MSG,'success','',route('admin.config.on_order_set'));
- }else{
- $configs=OrderAccountsSet::where('id',1)->first();
- $configs->{'expense_num'}=CommonServer::creatServer()->getConfigValue('expense_num');
- return view('admins.configs.on_order_set',['configs'=>$configs]);
- }
- }
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function indexDown()
- {
- $configs=Config::pluck('value','key');
- return view('admins.configs.indexDown',['configs'=>$configs]);
- }
- function update_new1(){
- foreach ( request()->all() as $key => $value ){
- // 查找当前数据是否存在
- if( Config::where('key', $key)->where('value', $value)->count() ){ continue; }
- Config::where('key', $key)->update([ 'value' => $value ]);
- if(in_array($key,['province_num','city_num','area_num','sales_num','shop_num','member_num','purchases_num','fans_num','member_cash'])){
- ShopSet::where('shop_id','>',0)->update([$key=>$value]);
- }
- }
- return $this->response(self::SUCCESS_MSG,'success','');
- }
- }
|