Browse Source

版本切换

彭俊 6 năm trước cách đây
mục cha
commit
12e2887789
100 tập tin đã thay đổi với 24760 bổ sung0 xóa
  1. 33 0
      .env.example
  2. 5 0
      .gitattributes
  3. 22 0
      .gitignore
  4. 95 0
      CHANGELOG.md
  5. 54 0
      README.md
  6. 153 0
      app/Console/Commands/createModule.php
  7. 42 0
      app/Console/Kernel.php
  8. 36 0
      app/Events/Event.php
  9. 36 0
      app/Events/MoneyRecharge.php
  10. 53 0
      app/Exceptions/Handler.php
  11. 195 0
      app/Http/Controllers/Admin/AdminRoleController.php
  12. 86 0
      app/Http/Controllers/Admin/AdminlogController.php
  13. 214 0
      app/Http/Controllers/Admin/AdminmanageController.php
  14. 164 0
      app/Http/Controllers/Admin/AdminrootController.php
  15. 188 0
      app/Http/Controllers/Admin/AdvertController.php
  16. 152 0
      app/Http/Controllers/Admin/AllowipController.php
  17. 188 0
      app/Http/Controllers/Admin/AriticleTypeController.php
  18. 268 0
      app/Http/Controllers/Admin/BankInfoController.php
  19. 172 0
      app/Http/Controllers/Admin/BankSetController.php
  20. 193 0
      app/Http/Controllers/Admin/BannerController.php
  21. 226 0
      app/Http/Controllers/Admin/BaseLeagueController.php
  22. 184 0
      app/Http/Controllers/Admin/BaseNoteListController.php
  23. 602 0
      app/Http/Controllers/Admin/BaseSetController.php
  24. 226 0
      app/Http/Controllers/Admin/BasketLeagueController.php
  25. 184 0
      app/Http/Controllers/Admin/BasketNoteListController.php
  26. 69 0
      app/Http/Controllers/Admin/CascadeController.php
  27. 236 0
      app/Http/Controllers/Admin/CompetitionController.php
  28. 148 0
      app/Http/Controllers/Admin/DatabaseCleanController.php
  29. 21 0
      app/Http/Controllers/Admin/DefaultController.php
  30. 297 0
      app/Http/Controllers/Admin/DemoController.php
  31. 188 0
      app/Http/Controllers/Admin/FeedbackController.php
  32. 234 0
      app/Http/Controllers/Admin/FundController.php
  33. 150 0
      app/Http/Controllers/Admin/FundlogController.php
  34. 147 0
      app/Http/Controllers/Admin/GjmatchController.php
  35. 197 0
      app/Http/Controllers/Admin/GradeController.php
  36. 497 0
      app/Http/Controllers/Admin/IndexController.php
  37. 228 0
      app/Http/Controllers/Admin/InfosController.php
  38. 164 0
      app/Http/Controllers/Admin/LabelController.php
  39. 205 0
      app/Http/Controllers/Admin/LogController.php
  40. 58 0
      app/Http/Controllers/Admin/LoginController.php
  41. 371 0
      app/Http/Controllers/Admin/ManagerController.php
  42. 172 0
      app/Http/Controllers/Admin/MatchController.php
  43. 139 0
      app/Http/Controllers/Admin/MatchcodeController.php
  44. 224 0
      app/Http/Controllers/Admin/MenuController.php
  45. 288 0
      app/Http/Controllers/Admin/MessageController.php
  46. 290 0
      app/Http/Controllers/Admin/MessageReadController.php
  47. 230 0
      app/Http/Controllers/Admin/MgGameController.php
  48. 1293 0
      app/Http/Controllers/Admin/MoneyController.php
  49. 224 0
      app/Http/Controllers/Admin/MoneyListController.php
  50. 741 0
      app/Http/Controllers/Admin/MoveDataController.php
  51. 236 0
      app/Http/Controllers/Admin/NoticeController.php
  52. 198 0
      app/Http/Controllers/Admin/PaymentController.php
  53. 110 0
      app/Http/Controllers/Admin/PrivController.php
  54. 155 0
      app/Http/Controllers/Admin/Priv_codeController.php
  55. 161 0
      app/Http/Controllers/Admin/Priv_roleController.php
  56. 93 0
      app/Http/Controllers/Admin/RechargeController.php
  57. 160 0
      app/Http/Controllers/Admin/RechargeDetailController.php
  58. 218 0
      app/Http/Controllers/Admin/RedReturnController.php
  59. 401 0
      app/Http/Controllers/Admin/RedbagController.php
  60. 120 0
      app/Http/Controllers/Admin/RedpackController.php
  61. 302 0
      app/Http/Controllers/Admin/RefundController.php
  62. 523 0
      app/Http/Controllers/Admin/RegulationController.php
  63. 358 0
      app/Http/Controllers/Admin/RemittanceController.php
  64. 255 0
      app/Http/Controllers/Admin/ReportController.php
  65. 97 0
      app/Http/Controllers/Admin/ReturnController.php
  66. 214 0
      app/Http/Controllers/Admin/ReturnmanageController.php
  67. 103 0
      app/Http/Controllers/Admin/RoutesCategoryController.php
  68. 119 0
      app/Http/Controllers/Admin/RoutesController.php
  69. 224 0
      app/Http/Controllers/Admin/SoccerLeagueController.php
  70. 282 0
      app/Http/Controllers/Admin/SoccerNoteListController.php
  71. 311 0
      app/Http/Controllers/Admin/SoccerStringNoteListController.php
  72. 132 0
      app/Http/Controllers/Admin/SpecialReportController.php
  73. 698 0
      app/Http/Controllers/Admin/SportsBaseController.php
  74. 692 0
      app/Http/Controllers/Admin/SportsBasketController.php
  75. 705 0
      app/Http/Controllers/Admin/SportsSoccerController.php
  76. 697 0
      app/Http/Controllers/Admin/SportsTennisController.php
  77. 340 0
      app/Http/Controllers/Admin/SportsbkController.php
  78. 177 0
      app/Http/Controllers/Admin/SportsbqController.php
  79. 361 0
      app/Http/Controllers/Admin/SportsfootController.php
  80. 194 0
      app/Http/Controllers/Admin/SportswqController.php
  81. 215 0
      app/Http/Controllers/Admin/SystemAppupdateController.php
  82. 456 0
      app/Http/Controllers/Admin/SystemController.php
  83. 171 0
      app/Http/Controllers/Admin/SystemRedController.php
  84. 230 0
      app/Http/Controllers/Admin/TakeController.php
  85. 227 0
      app/Http/Controllers/Admin/TennisLeagueController.php
  86. 184 0
      app/Http/Controllers/Admin/TennisNoteListController.php
  87. 22 0
      app/Http/Controllers/Admin/TestController.php
  88. 55 0
      app/Http/Controllers/Admin/TokenController.php
  89. 256 0
      app/Http/Controllers/Admin/TransferVerifyController.php
  90. 123 0
      app/Http/Controllers/Admin/TypeNameController.php
  91. 333 0
      app/Http/Controllers/Admin/UnsetController.php
  92. 1312 0
      app/Http/Controllers/Admin/UserController.php
  93. 217 0
      app/Http/Controllers/Admin/UserWaterController.php
  94. 209 0
      app/Http/Controllers/Admin/User_buyController.php
  95. 132 0
      app/Http/Controllers/Admin/UservipController.php
  96. 230 0
      app/Http/Controllers/Admin/WagentController.php
  97. 182 0
      app/Http/Controllers/Admin/WithController.php
  98. 131 0
      app/Http/Controllers/Api/SettlementController.php
  99. 825 0
      app/Http/Controllers/Api/WriteSportsController.php
  100. 32 0
      app/Http/Controllers/Auth/ForgotPasswordController.php

+ 33 - 0
.env.example

@@ -0,0 +1,33 @@
+APP_NAME=Laravel
+APP_ENV=local
+APP_KEY=
+APP_DEBUG=true
+APP_LOG_LEVEL=debug
+APP_URL=http://localhost
+
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=homestead
+DB_USERNAME=homestead
+DB_PASSWORD=secret
+
+BROADCAST_DRIVER=log
+CACHE_DRIVER=file
+SESSION_DRIVER=file
+QUEUE_DRIVER=sync
+
+REDIS_HOST=127.0.0.1
+REDIS_PASSWORD=null
+REDIS_PORT=6379
+
+MAIL_DRIVER=smtp
+MAIL_HOST=smtp.mailtrap.io
+MAIL_PORT=2525
+MAIL_USERNAME=null
+MAIL_PASSWORD=null
+MAIL_ENCRYPTION=null
+
+PUSHER_APP_ID=
+PUSHER_APP_KEY=
+PUSHER_APP_SECRET=

+ 5 - 0
.gitattributes

@@ -0,0 +1,5 @@
+* text=auto
+*.css linguist-vendored
+*.scss linguist-vendored
+*.js linguist-vendored
+CHANGELOG.md export-ignore

+ 22 - 0
.gitignore

@@ -0,0 +1,22 @@
+/node_modules
+/public/hot
+/public/storage
+/storage/*
+/.idea
+/.vagrant
+Homestead.json
+Homestead.yaml
+npm-debug.log
+yarn-error.log
+.env
+/.svn
+/.phpintel
+/storage/logs/laravel.log
+/vendor/*
+/config/database.php
+/.env
+/public/web.config
+.svn
+/app/Models/RedisOP.php
+./composer.json
+./composer.lock

+ 95 - 0
CHANGELOG.md

@@ -0,0 +1,95 @@
+# Release Notes
+
+## v5.5.0 (2017-08-30)
+
+### Added
+- Added `same_site` to `session.php` config ([#4168](https://github.com/laravel/laravel/pull/4168))
+- Added `TrustProxies` middleware ([e23a1d2](https://github.com/laravel/laravel/commit/e23a1d284f134bfce258cf736ea8667a407ba50c), [#4302](https://github.com/laravel/laravel/pull/4302))
+- Autoload commands ([5d54c21](https://github.com/laravel/laravel/commit/5d54c21ea869a7a5b503f0899307e4728feed11b))
+- Added Whoops ([#4364](https://github.com/laravel/laravel/pull/4364))
+
+### Changed
+- Refactored exception handler (_too many commits_)
+- Renamed `ModelFactory.php` to `UserFactory.php` to encourage separate files ([67a8a11](https://github.com/laravel/laravel/commit/67a8a1157004c4373663ec4a9398780feb6d6fa4))
+- Use `RefreshDatabase` trait ([a536402](https://github.com/laravel/laravel/commit/a536402228108da9423a0db1e0cf492f3f51c8b8), [#4373](https://github.com/laravel/laravel/pull/4373))
+- Use Composer's `@php` directive ([#4278](https://github.com/laravel/laravel/pull/4278))
+- Use `post-autoload-dump` ([2f4d726](https://github.com/laravel/laravel/commit/2f4d72699cdc9b7db953055287697a60b6d8b294))
+- Try to build session cookie name from app name ([#4305](https://github.com/laravel/laravel/pull/4305))
+ 
+### Fixed
+- Fixed Apache trailing slash redirect for subdirectory installs ([#4344](https://github.com/laravel/laravel/pull/4344))
+
+### Removed
+- Dropped `bootstrap/autoload.php` ([#4226](https://github.com/laravel/laravel/pull/4226), [#4227](https://github.com/laravel/laravel/pull/4227), [100f71e](https://github.com/laravel/laravel/commit/100f71e71a24fd8f339a7687557b77dd872b054b))
+- Emptied `$dontReport` array on exception handler ([758392c](https://github.com/laravel/laravel/commit/758392c30fa0b2651ca9409aebb040a64816dde4))
+- Removed `TinkerServiceProvider` ([6db0f35](https://github.com/laravel/laravel/commit/6db0f350fbaa21b2acf788d10961aba983a19be2)) 
+- Removed migrations from autoload classmap ([#4340](https://github.com/laravel/laravel/pull/4340))
+
+
+## v5.4.30 (2017-07-20)
+
+### Changed
+- Simplified mix require ([#4283](https://github.com/laravel/laravel/pull/4283))
+- Upgraded Laravel Mix to `^1.0` ([#4294](https://github.com/laravel/laravel/pull/4294))
+- Upgraded `axios` and `cross-env` package ([#4299](https://github.com/laravel/laravel/pull/4299))
+- Ignore Yarn error log ([#4322](https://github.com/laravel/laravel/pull/4322))
+
+### Fixed
+- Use `app()->getLocale()` ([#4282](https://github.com/laravel/laravel/pull/4282))
+- Use quotes in `app.scss` ([#4287](https://github.com/laravel/laravel/pull/4287))
+
+
+## v5.4.23 (2017-05-11)
+
+### Added
+- Added SQL Server connection ([#4253](https://github.com/laravel/laravel/pull/4253), [#4254](https://github.com/laravel/laravel/pull/4254))
+
+### Changed
+- Switch to using meta
+- Use CSRF token from `meta` tag, instead of `window.Laravel` object ([#4260](https://github.com/laravel/laravel/pull/4260))
+- Log console error if CSRF token cannot be found ([1155245](https://github.com/laravel/laravel/commit/1155245a596113dc2cd0e9083603fa11df2eacd9))
+
+### Fixed
+- Added missing `ipv4` and `ipv6` validation messages ([#4261](https://github.com/laravel/laravel/pull/4261))
+
+
+## v5.4.21 (2017-04-28)
+
+### Added
+- Added `FILESYSTEM_DRIVER` and `FILESYSTEM_CLOUD` environment variables ([#4236](https://github.com/laravel/laravel/pull/4236))
+
+### Changed
+- Use lowercase doctype ([#4241](https://github.com/laravel/laravel/pull/4241))
+
+
+## v5.4.19 (2017-04-20)
+
+### Added
+- Added `optimize-autoloader` to `config` in `composer.json` ([#4189](https://github.com/laravel/laravel/pull/4189))
+- Added `.vagrant` directory to `.gitignore` ([#4191](https://github.com/laravel/laravel/pull/4191))
+- Added `npm run development` and `npm run prod` commands ([#4190](https://github.com/laravel/laravel/pull/4190), [#4193](https://github.com/laravel/laravel/pull/4193))
+- Added `APP_NAME` environment variable ([#4204](https://github.com/laravel/laravel/pull/4204))
+
+### Changed
+- Changed Laravel Mix version to `0.*` ([#4188](https://github.com/laravel/laravel/pull/4188))
+- Add to axios defaults instead of overwriting them ([#4208](https://github.com/laravel/laravel/pull/4208))
+- Added `string` validation rule to `RegisterController` ([#4212](https://github.com/laravel/laravel/pull/4212))
+- Moved Vue inclusion from `bootstrap.js` to `app.js` ([17ec5c5](https://github.com/laravel/laravel/commit/17ec5c51d60bb05985f287f09041c56fcd41d9ce))
+- Only load libraries if present ([d905b2e](https://github.com/laravel/laravel/commit/d905b2e7bede2967d37ed7b260cd9d526bb9cabd))
+- Ignore the NPM debug log ([#4232](https://github.com/laravel/laravel/pull/4232))
+- Use fluent middleware definition in `LoginController` ([#4229](https://github.com/laravel/laravel/pull/4229))
+
+
+## v5.4.16 (2017-03-17)
+
+### Added
+- Added `unix_socket` to `mysql` in `config/database.php` ()[#4179](https://github.com/laravel/laravel/pull/4179))
+- Added Pusher example code to `bootstrap.js` ([31c2623](https://github.com/laravel/laravel/commit/31c262301899b6cd1a4ce2631ad0e313b444b131))
+
+### Changed
+- Use `smtp.mailtrap.io` as default `MAIL_HOST` ([#4182](https://github.com/laravel/laravel/pull/4182))
+- Use `resource_path()` in `config/view.php` ([#4165](https://github.com/laravel/laravel/pull/4165))
+- Use `cross-env` binary ([#4167](https://github.com/laravel/laravel/pull/4167))
+
+### Removed
+- Remove index from password reset `token` column ([#4180](https://github.com/laravel/laravel/pull/4180))

+ 54 - 0
README.md

@@ -0,0 +1,54 @@
+<p align="center"><img src="https://laravel.com/assets/img/components/logo-laravel.svg"></p>
+
+<p align="center">
+<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
+</p>
+
+## About Laravel
+
+Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as:
+
+- [Simple, fast routing engine](https://laravel.com/docs/routing).
+- [Powerful dependency injection container](https://laravel.com/docs/container).
+- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
+- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
+- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
+- [Robust background job processing](https://laravel.com/docs/queues).
+- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
+
+Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation give you tools you need to build any application with which you are tasked.
+
+## Learning Laravel
+
+Laravel has the most extensive and thorough documentation and video tutorial library of any modern web application framework. The [Laravel documentation](https://laravel.com/docs) is thorough, complete, and makes it a breeze to get started learning the framework.
+
+If you're not in the mood to read, [Laracasts](https://laracasts.com) contains over 900 video tutorials on a range of topics including Laravel, modern PHP, unit testing, JavaScript, and more. Boost the skill level of yourself and your entire team by digging into our comprehensive video library.
+
+## Laravel Sponsors
+
+We would like to extend our thanks to the following sponsors for helping fund on-going Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](http://patreon.com/taylorotwell):
+
+- **[Vehikl](http://vehikl.com)**
+- **[Tighten Co.](https://tighten.co)**
+- **[British Software Development](https://www.britishsoftware.co)**
+- **[Styde](https://styde.net)**
+- [Fragrantica](https://www.fragrantica.com)
+- [SOFTonSOFA](https://softonsofa.com/)
+- [User10](https://user10.com)
+- [Soumettre.fr](https://soumettre.fr/)
+- [CodeBrisk](https://codebrisk.com)
+
+## Contributing
+
+Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions).
+
+## Security Vulnerabilities
+
+If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
+
+## License
+
+The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

+ 153 - 0
app/Console/Commands/createModule.php

@@ -0,0 +1,153 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\File;
+define("ROOT_PATH",dirname(dirname(dirname(__DIR__))));
+class createModule extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'module:create {name} {module?} {app?}';
+    protected $root=ROOT_PATH;
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'create module or model or controller or lib ';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $proj=$this->argument('name');
+        switch($proj){
+            case "module":
+                $this->cdir();                
+                break;
+            case "controller":
+                $this->cController();
+                break;
+            case "model":
+                $this->cModel();
+                break;
+            case "lib":
+                $this->cLib();
+                break;
+            default:
+                break;
+        }
+       
+    }
+    protected function cLib(){
+        $app=$this->argument('module');
+        $app=ucfirst($app);
+        $module=$this->root."/module/";
+        $path=$module."/Lib"."/";
+        if(!File::exists($path)){
+            File::makeDirectory($path);
+        }          
+        $path=$module."/Lib"."/".ucfirst($app).".php";
+        $content="<?php ".chr(9).chr(13).
+        "namespace Module\\Lib;".chr(9).chr(13).
+        "class ".ucfirst($app)." {".chr(9).chr(13).                     
+        "}";
+        File::put($path,$content);
+    }
+    protected function cController()
+    {
+        $proj=$this->argument('module');
+        $app=$this->argument('app');
+        $proj=ucfirst($proj);
+        $module=$this->root."/module/".$proj."/";       
+        $path=$module."/Controller"."/".ucfirst($app).".php";
+        $content="<?php ".chr(9).chr(13).
+        "namespace Module\\$proj\Controller;".chr(9).chr(13).
+        "class ".ucfirst($app)." extends BaseController{".chr(9).chr(13).   
+            "  function _init(){".chr(9).chr(13).
+            "  }".chr(9).chr(13).         
+        "}";
+        File::put($path,$content);
+    }
+
+    protected function cBaseController()
+    {
+        $proj=$this->argument('module');
+        $proj=ucfirst($proj);
+        $module=$this->root."/module/".$proj."/";       
+        $path=$module."/Controller"."/BaseController.php";
+        $content="<?php".chr(9).chr(13).
+        "namespace Module\\$proj\Controller;".chr(9).chr(13).
+        "class BaseController extends \\Module\\Controller{".chr(9).chr(13).     
+        "  function _init(){".chr(9).chr(13).
+        "  }".chr(9).chr(13).
+        "  function __construct(){".chr(9).chr(13).
+        "      \$this->_init();".chr(9).chr(13).
+        "  }".chr(9).chr(13).
+        "}";
+        File::put($path,$content);
+    }
+
+    protected function cBaseModel()
+    {
+        $proj=$this->argument('module');
+        $proj=ucfirst($proj);
+        $module=$this->root."/module/".$proj."/";       
+        $path=$module."/Model"."/BaseModel.php";
+        $content="<?php".chr(9).chr(13).
+        "namespace Module\\$proj\Model;".chr(9).chr(13).
+        "class BaseModel extends \Illuminate\Database\Eloquent\Model{".chr(9).chr(13).            
+        "}";
+        File::put($path,$content);
+    }
+    protected function cModel()
+    {
+        $proj=$this->argument('module');
+        $model=$this->argument('app');
+        $proj=ucfirst($proj);
+        $model=ucfirst($model);
+        $module=$this->root."/module/".$proj."/";       
+        $path=$module."/Model"."/$model.php";
+        $content="<?php".chr(9).chr(13).
+        "namespace Module\\$proj\Model;".chr(9).chr(13).
+        "class $model extends BaseModel{".chr(9).chr(13).            
+        "}";
+        File::put($path,$content);
+    }
+
+    protected function cdir()
+    {
+        $proj=$this->argument('module');
+        $proj=ucfirst($proj);
+        $module=$this->root."/module/".$proj."/";
+        File::makeDirectory($module);
+        $path=$module."/Model"."/";
+        File::makeDirectory($path);
+        $path=$module."/Controller"."/";
+        File::makeDirectory($path);
+        $path=$this->root."/resources/views/".lcfirst($proj)."/";
+        File::makeDirectory($path);
+        $this->cBaseController();
+        $this->cBaseModel();
+    }
+
+}

+ 42 - 0
app/Console/Kernel.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Console;
+
+use Illuminate\Console\Scheduling\Schedule;
+use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
+
+class Kernel extends ConsoleKernel
+{
+    /**
+     * The Artisan commands provided by your application.
+     *
+     * @var array
+     */
+    protected $commands = [
+        //
+    ];
+
+    /**
+     * Define the application's command schedule.
+     *
+     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
+     * @return void
+     */
+    protected function schedule(Schedule $schedule)
+    {
+        // $schedule->command('inspire')
+        //          ->hourly();
+    }
+
+    /**
+     * Register the commands for the application.
+     *
+     * @return void
+     */
+    protected function commands()
+    {
+        $this->load(__DIR__.'/Commands');
+
+        require base_path('routes/console.php');
+    }
+}

+ 36 - 0
app/Events/Event.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Events;
+
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Broadcasting\PrivateChannel;
+use Illuminate\Broadcasting\PresenceChannel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
+
+class Event
+{
+    use Dispatchable, InteractsWithSockets, SerializesModels;
+
+    /**
+     * Create a new event instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Get the channels the event should broadcast on.
+     *
+     * @return \Illuminate\Broadcasting\Channel|array
+     */
+    public function broadcastOn()
+    {
+        return new PrivateChannel('channel-name');
+    }
+}

+ 36 - 0
app/Events/MoneyRecharge.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Events;
+
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Broadcasting\PrivateChannel;
+use Illuminate\Broadcasting\PresenceChannel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
+
+class MoneyRecharge
+{
+    use Dispatchable, InteractsWithSockets, SerializesModels;
+    public $recharge;
+    /**
+     * Create a new event instance.
+     *
+     * @return void
+     */
+    public function __construct($recharge)
+    {
+        $this->recharge=$recharge;
+    }
+
+    /**
+     * Get the channels the event should broadcast on.
+     *
+     * @return \Illuminate\Broadcasting\Channel|array
+     */
+    public function broadcastOn()
+    {
+        return new PrivateChannel('money-recharge');
+    }
+}

+ 53 - 0
app/Exceptions/Handler.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace App\Exceptions;
+
+use Exception;
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+
+class Handler extends ExceptionHandler
+{
+    /**
+     * A list of the exception types that are not reported.
+     *
+     * @var array
+     */
+    protected $dontReport = [
+        //
+    ];
+
+    /**
+     * A list of the inputs that are never flashed for validation exceptions.
+     *
+     * @var array
+     */
+    protected $dontFlash = [
+        'password',
+        'password_confirmation',
+    ];
+
+    /**
+     * Report or log an exception.
+     *
+     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
+     *
+     * @param  \Exception  $exception
+     * @return void
+     */
+    public function report(Exception $exception)
+    {
+        parent::report($exception);
+    }
+
+    /**
+     * Render an exception into an HTTP response.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Exception  $exception
+     * @return \Illuminate\Http\Response
+     */
+    public function render($request, Exception $exception)
+    {
+        return parent::render($request, $exception);
+    }
+}

+ 195 - 0
app/Http/Controllers/Admin/AdminRoleController.php

@@ -0,0 +1,195 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+
+/**
+ *
+ */
+class AdminRoleController extends Controller {
+	/**
+	 * @return 管理员角色管理
+	 */
+	function index(Req $req) {
+		$id = $req->id;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/AdminRole/getRole?id=' . $id);
+		$dt->setLang('system_user');
+		$dt->addColsFields('id');
+		$dt->addColsFields('admin_name', array('sort' => false)); //管理员名称
+		$dt->addColsFields('role_name', array('sort' => false)); //角色名
+		$dt->enableCheckBox();
+		$dt->setPriKey('id');
+		// $dt->setToolBar(array('priv_role'), array('width' => '200'));
+		return view('admin.AdminRole/index', $dt->render());
+	}
+	function getRole(Req $req) {
+		$list = intval($req->list) ? $req->list : '';
+		$admin_id = $req->id;
+		$admin_name = $req->admin_name;
+		$role_name = $req->role_name;
+		$where = array();
+		if (!empty($admin_id)) {
+			$where[] = array('admin_id', '=', $admin_id);
+		}
+		if (!empty($admin_name)) {
+			$where[] = array('admin_name', '=', $admin_name);
+		}
+		if (!empty($role_name)) {
+			$where[] = array('role_name', '=', $role_name);
+		}
+//		print_r($where);
+//	    $filds=$req-
+		$db = new \App\Models\Role;
+		$data = $db->getRole($where, $list);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+
+	}
+	function getEditColsModel() {
+		return 'System_root';
+	}
+	function view(Req $req) {
+		return $this->Edit($req);
+	}
+
+	//修改权限信息
+	function Edit(Req $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$root_db = new \App\Models\System_root;
+		$menu = new \App\Models\NewMenu;
+		if (!$req->isMethod('post')) {
+			$root = $root_db->getRootDetails($id, 1);
+			$menudata = $menu->getMenuAll();
+			return view('admin.Adminroot/view', ['data' => $root, 'menu' => $menudata]);
+		} else {
+			$level = empty($req->level) ? '' : $req->level;
+			$rootname = empty($req->rootname) ? '' : $req->rootname;
+			$max_money = empty($req->max_money) ? '' : $req->max_money;
+			if (empty($level) || empty($rootname) || empty($max_money)) {
+				return responseToJson(-7010900102); //未提交修改信息
+			}
+			$data = array(
+				'level' => $level,
+				'name' => $rootname,
+				'settingmoney' => $max_money,
+			);
+			$res = $root_db->editRoot($id, $data);
+			return responseToJson($res);
+
+		}
+	}
+	function getlist(Req $req) {
+		$list = intval($req->limit) > 0 ? $req->limit : 10;
+		$db = new \App\Models\System_root;
+		$data = $db->getlist($list);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	/**
+	 * 批量删除
+	 * [delete description]
+	 * @return [type] [description]
+	 */
+	function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		// echo '敬请期待';die;
+		$rows = \App\Models\Role::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1); //id����
+	}
+
+	//添加角色
+	function addRole(Req $req){
+        $id = $req->id;
+        if(intval($id)<0){
+            abort(404);
+        }
+        $admin_db=new \App\Models\System_user;
+        $role_db=new \App\Models\Role;
+        $system_role=new \App\Models\System_root;
+        $data=$role_db->gethasRole($id);
+        $role_data=$system_role->getAllRole();
+        foreach ($role_data as $k=>$v){
+            if(in_array($v['id'],$data)){
+                unset($role_data[$k]);
+            }
+        }
+        $admin_info=$admin_db->getAdminInfo($id,1);
+        if (!$req->isMethod('post')) {
+            return view('admin.AdminRole/addRole',['admin'=>$admin_info,'data'=>$role_data]);
+        }else{
+            $role_id=$req->role_id;
+            if(intval($role_id)<0){
+                return responseToJson(-7082000322);//请选择添加角色
+            }
+            $role_info=$system_role->getInfo($role_id,1);
+            if($role_info<0){
+                return responseToJson($role_info);//请选择添加角色
+            }
+            $inset_data['role_id']=$role_info['id'];
+            $inset_data['role_name']=$role_info['name'];
+            $inset_data['admin_id']=$id;
+            $inset_data['admin_name']=$admin_info['loginname'];
+            $res=$role_db->addRole($inset_data);
+            if($res<0){
+                return responseToJson($res);
+            }
+            return responseToJson(1);
+        }
+    }
+    //获取管理员该管理员所有权限的数组
+    function getRoot(){
+	    $admin_id=session('adminInfo.admin_id');
+	    //获取所有角色的id
+        $role_db=new \App\Models\Role;
+        $role_ids=$role_db->gethasRole($admin_id);
+        if($role_ids<0){
+            return $role_ids;
+        }
+        //检验是否是超级管理员
+        $root_db=new \App\Models\System_root;
+        $res=$root_db->checkSupper($role_ids);
+        if($res>0){
+            return 1;
+        }
+        //获取权限代码ID
+        $code_role_db=new \App\Models\Priv_roleModel;
+        $code_ids=$code_role_db->getAllCode($role_ids);
+        if($code_ids<0){
+            return $code_ids;
+        }
+        $code_ids=array_unique($code_ids);
+        //获取权限代码
+        $code_db=new \App\Models\Priv_codeModel;
+        $code_data=$code_db->getCode($code_ids);
+        if($code_data<0){
+            return $code_data;
+        }
+        return $code_data;
+
+    }
+
+}
+
+?>

+ 86 - 0
app/Http/Controllers/Admin/AdminlogController.php

@@ -0,0 +1,86 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class AdminlogController extends Controller {
+	/**
+	 * @return 管理员日志管理
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['loginname'] = isset($req->loginname) ? trim($req->loginname) : null;
+		$request['ip'] = isset($req->ip) ? trim($req->ip) : null;
+		$request['operation'] = isset($req->operation) ? trim($req->operation) : null;
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/manager/systemLog');
+		$dt->setLang('system_user');
+		$dt->addColsFields('loginname', array('width' => 160));
+		$dt->addColsFields('ip', array('templet' => '#selectip', 'width' => 220));
+		$dt->addColsFields('operation_time', array('width' => 260));
+		$dt->addColsFields('operation', array('templet' => '#desc','width' => 710));
+		$dt->setToolBar();
+
+		return view('admin.SystemManage/LogList', $dt->render($request));
+	}
+
+	/**
+	 * 登录ip列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function logipDetail() {
+		$ip = Request::has('ip') ? Request::get('ip') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/manager/systemLog?ip=' . $ip);
+		$dt->setLang('system_user');
+		$dt->addColsFields('loginname', array('sort' => false, 'width' => 130));
+		$dt->addColsFields('ip', array('width' => 160));
+		$dt->addColsFields('operation_time', array('width' => 170));
+		$dt->addColsFields('operation', array('width' => 637));
+		return view('admin.SystemManage/Viewip', $dt->render());
+	}
+	//修改管理员密码
+	function ChangePwd(Req $req) {
+		$admin_id = session('adminInfo.admin_id');
+		if (!$req->isMethod('post')) {
+			return view('admin.login.edit', ['name' => session('adminInfo.admin_name')]);
+		} else {
+			$db = new \App\Models\System_user;
+			$pwd = $req->password;
+			$repwd = $req->repassword;
+			$data = array();
+			if (!empty($pwd)) {
+				if ($pwd != $repwd) {
+					return responseToJson(-7051010522); //两次密码不一致
+				}
+				$pwddata = GenPassword($pwd);
+				$data['password'] = $pwddata['password'];
+				$data['encryption'] = $pwddata['encryption'];
+			}
+			$twopwd = $req->password_2;
+			$retwopwd = $req->repassword_2;
+			if (!empty($twopwd)) {
+				if ($twopwd != $retwopwd) {
+					return responseToJson(-7051010622); //两次密码不一致
+				}
+				$twopwddata = GenPassword($twopwd);
+				$data['password_2'] = $twopwddata['password'];
+				$data['encryption_2'] = $twopwddata['encryption'];
+			}
+			$res = $db->updateInfo($data, $admin_id);
+			return responseToJson($res);
+		}
+	}
+
+}
+
+?>

+ 214 - 0
app/Http/Controllers/Admin/AdminmanageController.php

@@ -0,0 +1,214 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class AdminmanageController extends Controller {
+	/**
+	 * @return 管理员管理
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['loginname'] = isset($req->loginname) ? trim($req->loginname) : null;
+		$request['role_name'] = isset($req->role_name) ? trim($req->role_name) : null;
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/manager/adminInfo');
+		$dt->setLang('system_user');
+		$dt->addColsFields('loginname',array('sort'=>false));
+		$dt->addColsFields('role_name',array('sort'=>false));
+		$dt->addColsFields('status', array('sort'=>false,'templet' => '#closeTool'));
+		$dt->addColsFields('add_time');
+	//	$dt->enableCheckBox();
+		$dt->addColsFields('operation',array('templet'=>'#opt'));
+		// $dt->setToolBar(array('delete'));
+		return view('admin.Adminmanage/index', $dt->render($request));
+	}
+
+	/**
+	 * 关闭管理员接口
+	 */
+	function GameClose() {
+		$status = Request::has('status') ? Request::get('status') : '';
+		$loginname = Request::has('loginname') ? Request::get('loginname') : '';
+		if (empty($loginname)) {
+			return responseToJson(-5030002031);
+		}
+		if ($status < 0) {
+			return responseToJson(-5030002032);
+		}
+
+		$db = new \App\Models\System_user;
+		$data = array(
+			'status' => $status,
+		);
+		if ($status) {
+			$data['status'] = 1;
+		} else {
+			$data['token'] = '';
+			$data['status'] = '0';
+		}
+		$res = $db->closeGame($data, $loginname);
+		return responseToJson($res);
+	}
+
+	//修改管理员信息
+	function Edit(Req $req) {
+		$id = $req->id;
+		$list = isset($req->limit) ? $req->limit : 10;
+		if (empty($id)) {
+			abort(404);
+		}
+		$db = new \App\Models\System_user;
+		$root_db = new \App\Models\System_root;
+		if (!$req->isMethod('post')) {
+			$data = $db->getAdminInfo($id, 1);
+			$root = $root_db->getlist($list);
+
+//			$data['name'] = $root['name'];
+			return view('admin.Adminmanage/edit', ['data' => $data, 'root' => $root['data']]);
+		} else {
+			$loginname = $req->loginname;
+			$pwd = $req->password;
+			$repwd = $req->repassword;
+
+			$twopwd = $req->password_2;
+			$retwopwd = $req->repassword_2;
+			$data = array(
+				'status' => $req->status,
+			);
+			if (!empty($req->root_id)) {
+				$data['root_id'] = $req->root_id?intval($req->root_id):4;
+			}
+			if (!empty($pwd)) {
+				if ($pwd != $repwd) {
+					return responseToJson(-7010000522); //两次密码不一致
+				}
+				$pwddata = GenPassword($pwd);
+				$data['password'] = $pwddata['password'];
+				$data['encryption'] = $pwddata['encryption'];
+			}
+			if (!empty($twopwd)) {
+				if ($twopwd != $retwopwd) {
+					return responseToJson(-7010000522); //两次密码不一致
+				}
+				$twopwddata = GenPassword($twopwd);
+				$data['password_2'] = $twopwddata['password'];
+				$data['encryption_2'] = $twopwddata['encryption'];
+			}
+			$res = $db->updateInfo($data, $id);
+			$log = array(
+				session('adminInfo.admin_name'),
+				$loginname,
+			);
+			OperationLog(session('adminInfo.admin_id'), 'editAdmin', $log);
+			return responseToJson($res);
+		}
+	}
+
+	function Add(Req $req) {
+		$root_db = new \App\Models\System_root;
+		$list = isset($req->limit) ? $req->limit : 10;
+		if (!$req->isMethod('post')) {
+			$root = $root_db->getlist($list);
+			$data['root_id'] = '';
+			$data['status'] = 1;
+			return view('admin.Adminmanage/add', ['data' => $data, 'root' => $root['data'], 'dis' => 1]);
+		} else {
+			$loginname = $req->loginname;
+			$pwd = $req->password;
+			$repwd = $req->repassword;
+			$twopwd = $req->password_2;
+			$retwopwd = $req->repassword_2;
+			$level = $req->root_id?intval($req->root_id):4;
+			$status = $req->status;
+			if (empty($loginname) || empty($pwd) || empty($twopwd)) {
+				return responseToJson(-7010007022); //必填不能为空
+			}
+			if ($pwd != $repwd || $twopwd != $retwopwd) {
+				return responseToJson(-7010000522); //两次密码不一致
+			}
+			$data['loginname'] = $loginname;
+			$data['status'] = $status;
+			$data['root_id'] = $level;
+			$pwddata = GenPassword($pwd);
+			$data['password'] = $pwddata['password'];
+			$data['encryption'] = $pwddata['encryption'];
+			$twopwddata = GenPassword($pwd);
+			$data['password_2'] = $twopwddata['password'];
+			$data['encryption_2'] = $twopwddata['encryption'];
+			$data['add_time'] = date('Y-m-d H:i:s', time());
+			$checkname = \App\Models\System_user::checkAdminname($data['loginname']);
+			if($checkname<0){
+				return responseToJson($checkname);
+			}
+			$db = new \App\Models\System_user;
+			$res = $db->addAdmin($data);
+			$log = array(
+				session('adminInfo.admin_name'),
+				$loginname,
+			);
+			OperationLog(session('adminInfo.admin_id'), 'addAdmin', $log);
+			return responseToJson($res);
+
+		}
+
+	}
+
+	/**
+	 * 批量删除
+	 * [delete description]
+	 * @return [type] [description]
+	 */
+	function delete(Req $req) {
+		$loginname = '';
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$admin_users = \App\Models\System_user::whereIn('id', $ids)->get();
+		$rows = \App\Models\System_user::whereIn('id', $ids)->delete();
+		foreach ($admin_users as $key => $value) {
+			$loginname.=$value->loginname.',';
+		}
+		$log = array(
+				session('adminInfo.admin_name'),
+				$loginname,
+			);
+		OperationLog(session('adminInfo.admin_id'), 'deleteAdmin', $log);
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1); //id����
+	}
+	//获取权限代码
+	function getRootCode(){
+	    $admin_id=session('adminInfo.admin_id');
+	    $role_id=\App\Models\System_user::select('root_id')->where('id',$admin_id)->first();
+        $role_id=$role_id->toArray();
+        $role_id=$role_id['root_id'];
+        $data=\App\Models\Priv_roleModel::where('role_id',$role_id)->get();
+        return $data->toArray();
+//        dump($data->toArray());
+    }
+
+}
+
+?>

+ 164 - 0
app/Http/Controllers/Admin/AdminrootController.php

@@ -0,0 +1,164 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+
+/**
+ *
+ */
+class AdminrootController extends Controller {
+	/**
+	 * @return 管理员权限管理
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['level'] = isset($req->level) ? trim($req->level) : null;
+		$request['name'] = isset($req->name) ? trim($req->name) : null;
+		$request['money_small'] = isset($req->money_small) ? trim($req->money_small) : null;
+		$request['money_big'] = isset($req->money_big) ? trim($req->money_big) : null;
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Adminroot/getlist');
+		$dt->setLang('system_user');
+		$dt->addColsFields('id');
+		$dt->addColsFields('name', array('edit' => true, 'sort' => false, 'width' => '250')); //角色名称
+		$dt->addColsFields('level', array('edit' => true)); //权限等级
+		$dt->addColsFields('settingmoney', array('edit' => true, 'width' => '250')); //最大操作金额
+		$dt->addColsFields('priv_role', array('templet' => '#waterTool', 'sort' => false, 'width' => '350'));
+		$dt->enableCheckBox();
+		$dt->setPriKey('id');
+		// $dt->setToolBar(array('priv_role'), array('width' => '200'));
+		return view('admin.Adminroot/index', $dt->render($request));
+	}
+	function getEditColsModel() {
+		return 'System_root';
+	}
+	function view(Req $req) {
+		return $this->Edit($req);
+	}
+
+	//修改权限信息
+	function Edit(Req $req) {
+		$id = $req->id;
+		if ($id < 1) {
+			abort(404);
+		}
+		$root_db = new \App\Models\System_root;
+		$menu = new \App\Models\NewMenu;
+		if (!$req->isMethod('post')) {
+			$root = $root_db->getRootDetails($id, 1);
+			$menudata = $menu->getMenuAll();
+			return view('admin.Adminroot/view', ['data' => $root, 'menu' => $menudata]);
+		} else {
+			$level = empty($req->level) ? '' : $req->level;
+			$rootname = empty($req->rootname) ? '' : $req->rootname;
+			$max_money = empty($req->max_money) ? '' : $req->max_money;
+			if (empty($level) || empty($rootname) || empty($max_money)) {
+				return responseToJson(-7010900102); //未提交修改信息
+			}
+			$data = array(
+				'level' => $level,
+				'name' => $rootname,
+				'settingmoney' => $max_money,
+			);
+			$res = $root_db->editRoot($id, $data);
+			 $log = array(
+                session('adminInfo.admin_name'),
+                $rootname, 
+                $level,
+                $max_money
+            );
+            OperationLog(session('adminInfo.admin_id'), 'EditqxsystemAdd', $log);
+			return responseToJson($res);
+
+		}
+	}
+	function getlist(Req $req) {
+		$list = intval($req->limit) > 0 ? $req->limit : 10;
+		$page = !empty($req->page) ? $req->page : 1;
+		$field = !empty($req->field) ? $req->field : 'id';
+		$order = !empty($req->order) ? $req->order : 'asc';
+
+		$name = !empty($req->name) ? $req->name : '';
+		$level = $req->level;
+		$money_small = !empty($req->money_small) ? $req->money_small : '';
+		$money_big = !empty($req->money_big) ? $req->money_big : '';
+
+		$where = array();
+		if (!empty($name)) {
+			$where[] = array('name', 'like', "%" . $name . "%");
+		}
+		if ($level === 0 || ($level != '')) {
+			$where[] = array('level', '=', $level);
+		}
+
+		if (!empty($money_small)) {
+			$where[] = array('settingmoney', '>=', $money_small);
+		}
+		if (!empty($money_big)) {
+			$where[] = array('settingmoney', '<=', $money_big);
+		}
+
+		$db = new \App\Models\System_root;
+		$data = $db->getRootlist($where, 1, $list, $field, $order);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	/**
+	 * 批量删除
+	 * [delete description]
+	 * @return [type] [description]
+	 */
+	function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\System_root::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1); //id����
+	}
+
+	//修改权限信息
+	/*function Edit(Req $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$root_db = new \App\Model\System_root;
+		$menu = new \App\Model\NewMenu;
+		if (!$req->isMethod('post')) {
+			$root = $root_db->getRootDetails($id, 1);
+			$menudata = $menu->getMenuAll();
+			return view('admin.SystemManage/editroot', ['data' => $root, 'menu' => $menudata]);
+		} else {
+			$pwd = $req->password;
+			$data = array(
+				'status' => $req->status,
+			);
+			if (!empty($pwd)) {
+				$pwddata = GenPassword($pwd);
+				$data['password'] = $pwddata['password'];
+				$data['encryption'] = $pwddata['encryption'];
+			}
+
+		}
+	}*/
+}
+
+?>

+ 188 - 0
app/Http/Controllers/Admin/AdvertController.php

@@ -0,0 +1,188 @@
+<?php
+/**
+ * 系统设置
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+/**
+ *
+ */
+class AdvertController extends Controller {
+
+    /**
+     * 广告
+     */
+    function Index(Req $req) {
+
+        $request=array();
+
+        $request['title'] = isset($req->title) ? trim($req->title) : null;
+        $request['type'] = isset($req->type) ? trim($req->type) : null;
+        $request['status'] = isset($req->status) ? trim($req->status) : null;
+
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Advert/getArticle');
+        $dt->setLang('notice');
+        $dt->addColsFields('title');
+        $dt->addColsFields('type');
+        $dt->addColsFields('status');
+        $dt->enableCheckBox();
+        $dt->addColsFields('chakan', array('templet' => '#waterTool', 'sort' => false, 'width' => 155));
+        return view('admin.Advert/arictle',$dt->render($request));
+    }
+
+    //获取信息
+    //获取活动信息
+    function getArticle() {
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+
+        $title = Request::has('title') ? Request::get('title') : '';
+        $type = Request::has('type') ? Request::get('type') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+
+        $where = array();
+        if (!empty($title)) {
+            $where[] = array('title', 'like', '%' . $title . '%');
+        }
+        if (!empty($type)) {
+            $where[] = array('type', '=', $type);
+        }
+
+        if (!empty($status)) {
+            $where[] = array('status', '=', $status);
+        }
+
+        $db = new \App\Models\Advert();
+        $data = $db->getlist($limit, $where);
+        if (!($data < 0)) {
+            $langinfo = trans('status.advert');
+            $langstatus = trans('status.system_user.status');
+            foreach ($data['data'] as $k => $v) {
+                $data['data'][$k]['type'] = $langinfo[$v['type']];
+                $data['data'][$k]['status'] = $langstatus[$v['status']];
+                $data['data'][$k]['typeid'] = $v['type'];
+            }
+        }
+        $result=\App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+
+        if (empty($result)){
+            return '';
+        }
+        return $result;
+
+    }
+    function view(Req $req) {
+        return $this->Edit($req);
+    }
+
+    function Edit(Req $req) {
+        $id = $req->id;
+//        $id=Request::has('id')?Request::get('id'):'';
+        if (intval($id) < 1) {
+            abort(404);
+        }
+        $db = new \App\Models\Advert;
+        if (!$req->isMethod('post')) {
+            $data = $db->getDmsg($id, 1);
+            if (!$data) {
+                return responseToJson($data);
+            }
+            return view('admin.Advert/editNotice', ['data' => $data]);
+        } else {
+            $data['title'] = $req->input('title');
+            $data['type'] = $req->input('type');
+            $data['status'] = $req->input('status');
+            $res = $db->updateMsg($data, $id);
+           $log = array(
+               session('adminInfo.admin_name'),
+               $data['title']
+           );
+           OperationLog(session('adminInfo.admin_id'), 'edit_adv', $log);
+            return responseToJson(1);
+        }
+    }
+
+    /**
+     * 批量删除
+     * [delete description]
+     * @return [type] [description]
+     */
+    function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\Advert::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        $log = array(
+            session('adminInfo.admin_name'),
+        );
+        OperationLog(session('adminInfo.admin_id'), 'de_notice', $log);
+        return responseToJson(1); //id����
+    }
+
+    function addNotice(Req $req){
+
+        if (!$req->isMethod('post')) {
+            return view('admin.Advert/editNotice',['select'=>1]);
+        }else{
+            $data['title'] = $req->input('title');
+            $data['type'] =$req->type;
+            $data['status'] =$req->status;
+            $log = array(
+                session('adminInfo.admin_name'),
+                $data['title']
+            );
+            $data['add_time']=date('Y-m-d H:i:s');
+
+            $db = new \App\Models\Advert;
+
+            $res = $db->addNotice($data);
+
+            OperationLog(session('adminInfo.admin_id'), 'add_notice', $log);
+            return responseToJson(1);
+        }
+    }
+
+
+    function MessageView(){
+        $id = Request::has('id') ? Request::get('id') : '';
+        $admin_id=session('adminInfo.admin_id');
+        $where=[
+            'id',
+            $id
+        ];
+        $dataWhwew=[
+            'message_id'=>$id,
+            'account_identity'=>$admin_id,
+//            'add_time'=>time()
+        ];
+        $db = new \App\Models\Manager();
+        $dbRead = new \App\Models\MessageRead;
+        $data = $db->getlistd($where);
+        $dataRead = $dbRead->Messagelist($id,$admin_id);
+        if ($dataRead < 0){
+            $dat = $dbRead->addMessage($dataWhwew);
+        }
+        return view('admin.Manager/view',['data'=>$data]);
+    }
+}
+
+?>

+ 152 - 0
app/Http/Controllers/Admin/AllowipController.php

@@ -0,0 +1,152 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+class AllowipController extends Controller {
+
+	
+    public function __construct(){
+        $set = new \App\Models\Rgame_setting();
+        $where = 'kygame';
+        $set_obj  = $set->getGames($where);
+		if(empty($set_obj)){
+			return;
+		}
+        $this->agent = $set_obj->agent_name;
+        $this->game_type = $set_obj->game_type;
+        $this->pwd = $set_obj->agent_pwd;
+        $this->user_pre = $set_obj->user_prefix;
+        $this->lineCode = $set_obj->lineCode;
+         //解析扩展字段
+        $json = json_decode($set_obj->extend, true);
+        $this->host = $json['host1'];
+        $this->pay_host = $json['host2'];
+        $this->desKey = $json['desKey'];
+        $this->md5key = $json['md5key'];
+    }
+
+	public function index()	{
+		$request['ip'] = isset($req->ip) ? trim($req->ip) : null;
+		$request['operator'] = isset($req->operator) ? trim($req->operator) : null;
+		$request['time'] = isset($req->time) ? trim($req->time) : null;
+		$request['remark'] = isset($req->remark) ? trim($req->remark) : null;
+		$request['type'] = isset($req->type) ? trim($req->type) : null;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Allowip/data');
+		$dt->setLang('allowip');
+		$dt->addColsFields('ip', array('sort' => false));
+		$dt->addColsFields('operator',array('sort' => false));
+		$dt->addColsFields('time');
+		$dt->addColsFields('remark',array('sort' => false));
+		$dt->addColsFields('type',array('sort' => false));
+		$dt->setToolBar(array('edit'),array('sort' => false));
+		$dt->enableCheckBox();
+
+		return view('admin.allowip/index', $dt->render($request));
+
+	}
+
+	function getEditColsModel() {
+		return 'dc_allowip';
+	}
+
+	function add(Request $req) {
+		$model = new \App\Models\Allowip();
+		if (!$req->isMethod('post')) {
+			$data['type'] = 2;
+			return view('admin.allowip/add', array('data' => $data));
+		} else {
+			$model = new \App\Models\Allowip();
+			$model->ip = trim($req->input('ip'));
+			$model->operator = session('adminInfo.admin_name');
+			$model->time = date('Y-m-d H:i:s');
+			$model->remark = trim($req->input('remark'));
+			$model->type = trim($req->input('type'));
+			$model->save();
+			$log = array(
+	            session('adminInfo.admin_name'),
+	            $model->ip,
+	            $model->remark,
+	        );
+	        OperationLog(session('adminInfo.admin_id'), 'addallowip', $log);
+			return responseToJson(1);
+		}
+	}
+
+	function data() {
+		$db = new \App\Models\Allowip();
+		$data =  $db->getCode();
+		$langinfo = trans('status.allowip');
+		foreach ($data as $k => $v) {
+			$data[$k]['type'] = ($v['type'] == 0) ? $langinfo['type']['1'] : $langinfo['type'][$v['type']];
+		}
+		return \App\Lib\DataTable\DataTable::init()->toJson($data);
+
+	}
+
+	public function delete(Request $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			return responseToJson(-2001); //id不能为空
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id错误
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\Allowip::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id错误
+		}
+		$log = array(
+            session('adminInfo.admin_name'),
+        );
+
+        OperationLog(session('adminInfo.admin_id'), 'del_allowip', $log);
+		return responseToJson(1, trans('priv_code.delete_success')); //id错误
+
+	}
+
+	function edit(Request $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\Allowip::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+			return view('admin.allowip/edit', array('data' => $data));
+		} else {
+			$model = \App\Models\Allowip::where('id', $id)->first();
+			$model->ip = trim($req->input('ip'));
+			$model->operator = session('adminInfo.admin_name');
+			$model->time = date('Y-m-d H:i:s');
+			$model->remark = trim($req->input('remark'));
+			$model->type = trim($req->input('type'));
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+
+    function getC(){
+        $agent_money = \App\Models\Rgame_setting::where('game_type','kygame')->select('agent_money')->first()->toArray();
+        return responseToJson ($agent_money);
+    }
+
+
+}

+ 188 - 0
app/Http/Controllers/Admin/AriticleTypeController.php

@@ -0,0 +1,188 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+
+use App\Http\Controllers\Controller;
+use App\Models\ArticleType;
+use Illuminate\Http\Request as Req;
+
+class AriticleTypeController extends Controller
+{
+    /***
+     * @param Req $req
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     */
+    public function index(Req $req)
+    {
+        $request['title'] = isset($req->title) ? trim($req->title) : null;
+        $request['type'] = isset($req->type) ? trim($req->type) : null;
+
+        $acticle_type = new ArticleType();
+        $selectdata = $acticle_type->type();
+        $type = $this->getTree($selectdata);
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/System/getArticleType');
+        $dt->setLang('ariticle');
+        // $dt->addColsFields('id');
+        $dt->addColsFields('id');
+        // $dt->addColsFields('content');
+        $dt->addColsFields('cate_name');
+        $dt->addColsFields('parent_path');//层级
+        $dt->addColsFields('sort');
+        $dt->addColsFields('create_time');
+        $dt->enableCheckBox();
+        if (checkRriv('/admin/Notice/Edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 140));
+
+        $request["classtype"]    =   $type;
+
+        return view('admin.systemSet/ariticleTypelist', $dt->render($request));
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function add(Req $req)
+    {
+        //分类下拉框
+        $acticle_type = new ArticleType();
+        $selectdata = $acticle_type->type();
+        if (!$req->isMethod('post')) {
+            return view('admin.systemSet/articleType', ['select' => null, "selectdata" => $this->getTree($selectdata)]);
+        } else {
+            $pid = $req->input("type");
+            $pid = $pid ? $pid : 0;
+            $grade  =   $acticle_type->getGrade($pid);
+            //返回所有的父级
+          //  $from   =  $this->getFrom($selectdata,$pid,0);
+
+            $type_data = [
+                "parent_id" => $pid,
+                "cate_name" => $req->input("title"),
+
+                "parent_path" => $grade,
+
+                "sort" => $req->input("sort"),
+                "create_time" => date("Y-m-d H:i:s"),
+            ];
+            $addType = $acticle_type->addType($type_data);
+            $type_log = [
+                session('adminInfo.admin_name'),
+                $req['title']];
+            OperationLog(session('adminInfo.admin_id'), 'add_notice_type', $type_log);
+
+            return responseToJson(1);
+        }
+    }
+
+
+    public function edit(Req $req)
+    {
+        $id = $req->id;
+
+        if (empty($id)) {
+            abort(404);
+        }
+        $db = new ArticleType();
+        if (!$req->isMethod('post')) {
+            $data = $db->getIdData($id, 1);
+
+            $selectdata = $db->type();
+            return view('admin.systemSet/articleType', ['select' => $data["parent_id"], "selectdata" => $this->getTree($selectdata), 'data' => $data,]);
+        } else {
+            $pid = $req->input("type");
+            $grade  =   $db->getGrade($pid);
+            $type_data = [
+                "parent_id" => $pid ? $pid : 0,
+                "cate_name" => $req->input("title"),
+                "parent_path" =>$grade,
+                "sort" => $req->input("sort"),
+                "create_time" => date("Y-m-d H:i:s"),
+            ];
+
+            $addType = $db->updateIdData(intval($id), $type_data);
+            $type_log = [
+                session('adminInfo.admin_name'),
+                $req['title'] ];
+            OperationLog(session('adminInfo.admin_id'), 'edit_notice_type', $type_log);
+
+            return responseToJson(1);
+        }
+    }
+
+
+    public function delete(Req $req)
+    {
+        $forbid_ids =   [1,2,3,10,11,20,55];
+
+      //  return responseToJson("0","分类禁止删除");
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+
+                if (intval($v) < 1||in_array($v,$forbid_ids)) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+
+        $rows = \App\Models\ArticleType::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        $type_log = [
+            session('adminInfo.admin_name'),
+            $req['id']];
+       // OperationLog(session('adminInfo.admin_id'), 'del_notice_type', $type_log);
+        return responseToJson(1); //id����
+    }
+
+
+    private function getTree($array, $pid = 0, $cen = 0)
+    {
+        $arr = array();
+        $cen = ++$cen;
+        $str = "";
+        foreach ($array as $k => $v) {
+            if ($v['parent_id'] == $pid) {
+                $str = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", $cen - 1);
+                $arr[] = ["id" => $v["id"], "name" => ($cen - 1 ? $str . "└" . $v["cate_name"] : $v["cate_name"])];
+                unset($array[$k]);
+                $arr = array_merge($arr, $this->getTree($array, $v['id'], $cen));
+            }
+        }
+        return $arr;
+    }
+
+    private function getFrom($array,$pid,$cen){
+        $from   =   [];
+        $cen    = ++ $cen ;
+        foreach ($array as $k=>$v){
+            if($pid==$v["id"]){
+                unset($array[$k]);
+                $from[$cen]= $v["cate_name"];
+                $a =    $this->getFrom($array,$v["parent_id"],$cen);
+                $from   =   array_merge($a,$from);
+            }
+        }
+        return $from;
+    }
+
+    function view(Req $req)
+    {
+        return $this->Edit($req);
+    }
+}

+ 268 - 0
app/Http/Controllers/Admin/BankInfoController.php

@@ -0,0 +1,268 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class BankInfoController extends Controller {
+
+	function index() {
+		# code...
+	}
+function selectBetList(Req $req){
+	$game = $req->game;
+	$no = $req->no;
+	$list = $req->list;
+        if($game=='sixlottery'){
+            return \App\Models\SixMoneyBuy::BetList($game,$no,$list);
+        }
+        return \App\Models\MoneyBuy::BetList($game,$no,$list);
+    }
+	/**
+	 *银行卡信息
+	 * [Colse description]
+	 */
+	function infos(Req $req) {
+		$request=array();
+		$request['account']=isset($req->account)?trim($req->account):null;
+		$request['bank_name'] = isset($req->bank_name) ? trim($req->bank_name) : null;
+		$request['bank_number'] = isset($req->bank_number) ? trim($req->bank_number) : null;
+		$request['bank_address'] = isset($req->bank_address) ? trim($req->bank_address) : null;
+		$request['account_name'] = isset($req->account_name) ? trim($req->account_name) : null;
+		$request['startime'] = isset($req->startime) ? trim($req->startime) : null;
+		$request['endtime'] = isset($req->endtime) ? trim($req->endtime) : null;
+		$request['status'] = isset($req->status) ? trim($req->status) : null;
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/BankInfo/info');
+		$dt->setLang('bank_info');//'templet' => 'userdetail',
+		$dt->addColsFields('account', array('sort' => false, 'width' => 130));
+		$dt->addColsFields('bank_name', array( 'sort' => false));
+		$dt->addColsFields('bank_number', array('sort' => false));
+		$dt->addColsFields('bank_address', array( 'sort' => false));
+		$dt->addColsFields('band_time');
+		$dt->addColsFields('name', array('sort' => false, 'width' => 100));
+		$dt->addColsFields('status', array('templet' => '#closeTool', 'sort' => false, 'width' => 120));
+		$dt->setPriKey('identity');
+		if (checkRriv('/admin/BankInfo/Edit')) {
+			$dt->setToolBar(array('edit'), array('width' => 100,'align' => 'left'));
+		}
+		return view('admin.bankinfo/infos', $dt->render($request));
+	}
+
+	function getEditColsModel() {
+		return 'Account_bank';
+	}
+	function EditColsValidate($field, $value) {
+		$db = new \App\Models\Account_bank;
+		if ($field == "bank_number") {
+			if (count($value) > 20) {
+				return -8505012212; //银行卡长度有误
+			}
+		}
+		if ($re = $db->checkBank($field, $value)) {
+			return 1;
+		}
+		return -40255022;
+	}
+
+	/**
+	 * 关闭游戏接口
+	 */
+	function GameClose() {
+		$status = Request::has('status') ? Request::get('status') : '';
+		$game = Request::has('bank_number') ? Request::get('bank_number') : '';
+		if (empty($game)) {
+			return responseToJson(-5030002031);
+		}
+		if ($status < 0) {
+			return responseToJson(-5030002032);
+		}
+
+		$db = new \App\Models\Account_bank;
+		$data = array(
+			'status' => $status,
+		);
+		if ($status) {
+			$data['status'] = 1;
+		} else {
+			$data['status'] = '0';
+		}
+		$res = $db->closeGame($data, $game);
+		return responseToJson($res);
+	}
+	/**
+	 * 银行卡信息
+	 * 'FunctionName description'
+	 * @param string $value 'description'
+	 */
+	function info() {
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : '';
+
+		$account = Request::has('account') ? Request::get('account') : '';
+		$bank_name = Request::has('bank_name') ? Request::get('bank_name') : '';
+		$bank_number = Request::has('bank_number') ? Request::get('bank_number') : '';
+		$bank_address = Request::has('bank_address') ? Request::get('bank_address') : '';
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$startime = Request::get('startime') ? Request::get('startime').' 00:00:00' : '';
+		$endtime = Request::get('endtime') ? Request::get('endtime').' 23:59:59' : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+		$where = array();
+
+
+		if (!empty($bank_name)) {
+			$where[] = array('bank_name', 'like', '%' . $bank_name . '%');
+		}
+
+		if (!empty($bank_number)) {
+			$where[] = array('bank_number', '=', $bank_number);
+		}
+
+		if (!empty($bank_address)) {
+			$where[] = array('bank_address', 'like', '%' . $bank_address . '%');
+		}
+
+		if (!empty($account_name)) {
+			$where[] = array('account_name', 'like', '%' . $account_name . '%');
+		}
+
+		if (!empty($startime)) {
+			$startime = date('Y-m-d H:i:s', strtotime($startime));
+			$where[] = array('band_time', '>=', $startime);
+		}
+		if (!empty($endtime)) {
+			$endtime = date('Y-m-d H:i:s', strtotime($endtime));
+			$where[] = array('band_time', '<=', $endtime);
+		}
+		if (!empty($status)) {
+			if ($status == -1) {
+				$where[] = array('account_bank.status', '=', '0');
+			} else {
+				$where[] = array('account_bank.status', '=', $status);
+			}
+		}
+		if (!empty($account)) {
+			if (empty($sureblur) || $sureblur == '模糊') {
+				$where[] = array('account', 'like', '%' . $account . '%');
+			} else {
+				$where = array(array('account', '=', $account));
+			}
+		}
+		$db = new \App\Models\Account_bank;
+		$data = $db->account_bank($list, $page, $where);
+		$has_root = 0;
+		if(\App\Models\Role::hasRoot('/enable/show/bankcard') < 0){
+			$has_root = 1;
+		}
+		if(\App\Models\Role::hasRoot('/enable/show/name') < 0){
+			$has_root = 1;
+		}
+		if (!($data < 0)) {
+			foreach ($data['data'] as $k => $v) {
+				$has_root == 1 ? $data['data'][$k]['bank_number'] = bankHide($v['bank_number']) : null;
+				$has_root == 1 ? $data['data'][$k]['account'] = userHide($v['account']) : null;
+			}
+		}
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+/**
+ * 批量删除
+ * [delete description]
+ * @return [type] [description]
+ */
+	function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\Account_bank::whereIn('account_identity', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1, trans('menu.delete_success')); //id����
+	}
+
+	function Edit(Req $req) {
+		$id = $req->identity;
+		if (empty($id)) {
+			abort(404);
+		}
+		$u_db = new \App\Models\Account();
+		$bank = new \App\Models\Account_bank();
+		if (!$req->isMethod('post')) {
+			$data = $u_db::where('identity', $id)->first();
+			if (!$data) {
+				abort(404);
+			}
+			$data = $data->toArray();
+			$data_details['account'] = $data['account'];
+			$bank_data = $bank->getInfoByUid($data['identity']);
+			$data_details['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+			$data_details['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+			$data_details['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+			$data_details['name'] = isset($bank_data['name']) ? $bank_data['name'] : '';
+			$data_details['status'] = isset($bank_data['status']) ? $bank_data['status'] : '';
+			unset($data_details['password']);
+			return view('admin.menu/infoAdd', ['data' => $data_details]);
+		} else {
+			$data = $u_db::where('identity', $id)->first();
+			if (!$data) {
+				abort(404);
+			}
+			$data = $data->toArray();
+			$data_details = $bank->getInfoByUid($data['identity']);
+			$data['identity'] = $data_details['account_identity'];
+			$data = array(
+				'bank_name' => $req->input('bank_name'),
+				'bank_address' => $req->input('bank_address'),
+				'account_name' => $req->input('name'),
+				'bank_number' => $req->input('bank_number'),
+				'status' => $req->input('status'),
+			);
+			// print_r($data);die;
+			$res = $bank->updateOne($data, $id);
+			if($res<0){
+				return responseToJson($res);
+			}
+
+			$u_details = new \App\Models\Account_detailed();
+			$res = $u_details->updateInfo(array('name'=>$data['account_name']), $id);
+			$log = array(
+	            session('adminInfo.admin_name'),
+	            $req->input('account'),
+	            $req->input('bank_number'),
+	            $req->input('name'),
+	        );
+	        OperationLog(session('adminInfo.admin_id'), 'EditBank', $log);
+			return responseToJson($res);
+		}
+	}
+
+	/**
+	 * 银行卡信息添加
+	 * [demoAdd description]
+	 * @return [type] [description]
+	 */
+	function infoAdd() {
+		return view('admin.menu/infoAdd');
+	}
+
+}

+ 172 - 0
app/Http/Controllers/Admin/BankSetController.php

@@ -0,0 +1,172 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class BankSetController extends Controller {
+
+	function index(Req $req) {
+		$request['infoname'] = isset($req->infoname) ? trim($req->infoname) : null;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/BankSet/info');
+		$dt->setLang('bankset');
+		$dt->addColsFields('infoname', array('templet' => '#userdetail', 'sort' => false, 'width' => 160));
+		$dt->addColsFields('bank_num');
+		$dt->addColsFields('bank');
+		$dt->addColsFields('groups_names');
+		$dt->addColsFields('remark');
+		$dt->addColsFields('sort');
+		$dt->addColsFields('time');
+		$dt->addColsFields('status', array('templet' => '#status', 'sort' => false, 'width' => 150,'align' => 'left'));
+		$dt->enableCheckBox();
+		if (checkRriv('/admin/BankSet/edit')) {
+			$dt->setToolBar(array('edit'));
+		}
+		return view('admin.BankSet/index', $dt->render($request));
+	}
+
+	function info() {
+		$db = new \App\Models\System_bank();
+		$data = $db->getInfos();
+		return \App\Lib\DataTable\DataTable::init()->toJson($data);
+	}
+
+	//启用/禁用会员信息
+	function UserStart(Req $req) {
+		$id = $req->id;
+		$status = is_numeric($req->status) ? intval($req->status) : '';
+		if (empty($id) || !is_numeric($status)) {
+			return responseToJson(-2020100102);
+		}
+		$u_db = new \App\Models\System_bank;
+		$data = array(
+			'status' => $status,
+		);
+		$res = $u_db->updateInfos($data, $id);
+		return responseToJson($res);
+	}
+
+	function edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+        /***获取会员等级信息***/
+        $labelInfo=\App\Models\Account_group::getAllInfo();
+        /**********/
+		if (!$req->isMethod('post')) {
+			$data = \App\Models\System_bank::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+			return view('admin.SystemManage/BankSetEdit', array('data' => $data,'group'=>$labelInfo));
+		} else {
+            $groups=$req->groups?$req->groups:'';
+            //选择的组
+            $group_codes=array_keys($groups);
+            //获取组名的
+            $groups_names='| ';
+            foreach ($labelInfo as $k=>$v){
+                if(in_array($v['group_code'],$group_codes))
+                    $groups_names.=$v['group_name'].'| ';
+            }
+
+			$model = \App\Models\System_bank::where('id', $id)->first();
+			$model->infoname = trim($req->input('infoname'));
+			$model->bank_num = trim($req->input('bank_num'));
+			$model->bank = trim($req->input('bank'));
+			$model->remark = trim($req->input('remark'));
+            $model->groups='0,'.implode(',',$group_codes).',';
+            $model->groups_names=$groups_names;
+			$model->sort = trim($req->input('sort'));
+			$model->time = date('Y-m-d H:i:s');
+			$model->status = trim($req->input('status'));
+
+			$model->save();
+
+			$log = array(
+	            session('adminInfo.admin_name'),
+	            $model->infoname,
+	            $model->bank_num,
+	        );
+	        OperationLog(session('adminInfo.admin_id'), 'UserStart', $log);
+			return responseToJson(1);
+		}
+
+	}
+
+	function add(Req $req) {
+	    /***获取会员等级信息***/
+	    $labelInfo=\App\Models\Account_group::getAllInfo();
+        /***获取会员等级信息**/
+		if (!$req->isMethod('post')) {
+			$data['status'] = 1;
+            $data['type'] = 0;
+			return view('admin.SystemManage/BankSetEdit', ['data' => $data,'group'=>$labelInfo]);
+		} else {
+		    $groups=$req->groups?$req->groups:'';
+		    //选择的组
+            $group_codes=array_keys($groups);
+            //获取组名的
+            $groups_names='| ';
+            foreach ($labelInfo as $k=>$v){
+                if(in_array($v['group_code'],$group_codes))
+                $groups_names.=$v['group_name'].'| ';
+            }
+			$model = new \App\Models\System_bank();
+			$model->infoname = trim($req->input('infoname'));
+			$model->bank_num = trim($req->input('bank_num'));
+			$model->bank = trim($req->input('bank'));
+			$model->groups='0,'.implode(',',$group_codes).',';
+			$model->groups_names=$groups_names;
+			$model->remark = trim($req->input('remark'));
+			$model->sort = trim($req->input('sort'));
+			$model->time = date('Y-m-d H:i:s');
+			$model->status = 1;
+			$model->save();
+
+			$log = array(
+	            session('adminInfo.admin_name'),
+	            $model->infoname,
+	            $model->bank_num,
+	        );
+	        OperationLog(session('adminInfo.admin_id'), 'addStart', $log);
+			return responseToJson(1);
+		}
+	}
+
+	/**
+	 * 批量删除
+	 * [delete description]
+	 * @return [type] [description]
+	 */
+	function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\System_bank::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1); //id����
+	}
+}

+ 193 - 0
app/Http/Controllers/Admin/BannerController.php

@@ -0,0 +1,193 @@
+<?php
+/**
+ * 系统设置
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+/**
+ *
+ */
+class BannerController extends Controller {
+
+    /**
+     * 广告
+     */
+    function Index(Req $req) {
+
+        $request=array();
+
+        $request['banner_link'] = isset($req->banner_link) ? trim($req->banner_link) : null;
+        $request['banner_name'] = isset($req->banner_name) ? trim($req->banner_name) : null;
+        $request['banner_url'] = isset($req->banner_url) ? trim($req->banner_url) : null;
+        $request['advert_id'] = isset($req->advert_id) ? trim($req->advert_id) : null;
+        $request['add_time'] = isset($req->add_time) ? trim($req->add_time) : null;
+        //$request['status'] = isset($req->status) ? trim($req->status) : null;
+        $request['type'] = isset($req->type) ? trim($req->type) : null;
+        $id = isset($req->id) ? trim($req->id) : null;
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Banner/getArticle?ids='.$id.'&type='.$request['type']);
+        $dt->setLang('notice');
+        $dt->addColsFields('banner_link');
+        $dt->addColsFields('banner_name');
+        $dt->addColsFields('banner_url');
+        $dt->addColsFields('advert_id');
+        $dt->addColsFields('add_time');
+        $dt->addColsFields('sort');
+        $dt->addColsFields('status');
+        $dt->enableCheckBox();
+        $dt->addColsFields('chakan', array('templet' => '#waterTool', 'sort' => false, 'width' => 110));
+        return view('admin.Banner/arictle',$dt->render($request));
+    }
+
+    //获取信息
+    //获取活动信息
+    function getArticle(Req $req) {
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $banner_name = Request::has('banner_name') ? Request::get('banner_name') : '';
+        $id = Request::has('ids') ? Request::get('ids') : '';
+        $type = Request::has('type') ? Request::get('type') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+
+        $where = array();
+        if (!empty($banner_name)) {
+            $where[] = array('banner_name', 'like', '%' . $banner_name . '%');
+        }
+        if (!empty($type)) {
+            $where[] = array('type', '=', $type);
+        }
+        if (!empty($status)) {
+            $where[] = array('status', '=', $status);
+        }
+        //dump($where);exit;
+        $db = new \App\Models\Banner();
+        $data = $db->getlist($limit, $where);
+
+        if (!($data < 0)) {
+            $langinfo = trans('status.advert');
+            $langstatus = trans('status.system_user.status');
+            foreach ($data['data'] as $k => $v) {
+                $data['data'][$k]['advert_id'] = $langinfo[$v['type']];
+                //$data['data'][$k]['status'] = $langstatus[$v['status']];
+            }
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+    function view(Req $req) {
+        return $this->Edit($req);
+    }
+
+    function Edit(Req $req) {
+        $id = $req->id;
+//        $id=Request::has('id')?Request::get('id'):'';
+        if (intval($id) < 1) {
+            abort(404);
+        }
+        $db = new \App\Models\Banner;
+        if (!$req->isMethod('post')) {
+            $data = $db->getDmsg($id, 1);
+            if (!$data) {
+                return responseToJson($data);
+            }
+            return view('admin.Banner/editNotice', ['data' => $data]);
+        } else {
+            $data['banner_link'] = $req->input('banner_link');
+            $data['banner_name'] = $req->input('banner_name');
+            $data['banner_url'] = $req->input('banner_url');
+            $data['sort'] = $req->input('sort');
+            $data['status'] = $req->input('status');
+            $data['type'] = $req->input('type');
+            $res = $db->updateMsg($data, $id);
+//            $log = array(
+//                session('adminInfo.admin_name'),
+//            );
+//            OperationLog(session('adminInfo.admin_id'), 'edit_game', $log);
+            return responseToJson($res);
+        }
+    }
+
+    /**
+     * 批量删除
+     * [delete description]
+     * @return [type] [description]
+     */
+    function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\Banner::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1); //id����
+    }
+
+    function addNotice(Req $req){
+
+        if (!$req->isMethod('post')) {
+            $type = Request::has('type') ? Request::get('type') : '';
+            return view('admin.Banner/editNotice',['select'=>1,'type'=>$type]);
+        }else{
+            $data['banner_link'] = $req->input('banner_link');
+            $data['identity'] = UUID();
+            $data['banner_name'] = $req->input('banner_name');
+            $data['banner_url'] = $req->input('banner_url');
+            $data['status'] = $req->input('status');
+            $data['sort'] = $req->input('sort');
+            $data['type'] = $req->input('type');
+            $data['advert_id'] = $req->input('id');
+            $log = array(
+                session('adminInfo.admin_name'),
+                $data['banner_name']
+            );
+            $data['add_time']=date('Y-m-d H:i:s');
+
+            $db = new \App\Models\Banner;
+
+            $res = $db->addNotice($data);
+
+            OperationLog(session('adminInfo.admin_id'), 'add_notice', $log);
+            return responseToJson(1);
+        }
+    }
+
+
+    function MessageView(){
+        $id = Request::has('id') ? Request::get('id') : '';
+        $admin_id=session('adminInfo.admin_id');
+        $where=[
+            'id',
+            $id
+        ];
+        $dataWhwew=[
+            'message_id'=>$id,
+            'account_identity'=>$admin_id,
+//            'add_time'=>time()
+        ];
+        $db = new \App\Models\Manager();
+        $dbRead = new \App\Models\MessageRead;
+        $data = $db->getlistd($where);
+        $dataRead = $dbRead->Messagelist($id,$admin_id);
+        if ($dataRead < 0){
+            $dat = $dbRead->addMessage($dataWhwew);
+        }
+        return view('admin.Manager/view',['data'=>$data]);
+    }
+}
+
+?>

+ 226 - 0
app/Http/Controllers/Admin/BaseLeagueController.php

@@ -0,0 +1,226 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class BaseLeagueController extends Controller {
+
+    public function index(Req $req) {
+        //$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
+        $request['area_id'] = isset($req->area_id) ? trim($req->area_id) : '';
+        $request['country_id'] = isset($req->country_id) ? trim($req->country_id) : '';
+        $request['id'] = isset($req->id) ? trim($req->id) : '';
+        $request['status'] = isset($req->status) ? trim($req->status) : '0';
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $data = \App\Models\BaseLeague::select('id','lg_id','name_chinese')->get();
+        $area = \App\Models\StAreaCountry::where('pid',0)->get();
+        $country = \App\Models\StAreaCountry::where('pid','!=',0)->get();
+        $request['league'] = $data;
+        $request['area'] = $area;
+        $request['country'] = $country;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/BaseLeague/info');
+        $dt->setLang('sportsbase');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('area', array('sort' => false, 'width' => 180));
+        $dt->addColsFields('country', array('sort' => true, 'width' => 180));
+        $dt->addColsFields('league_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('utime', array('templet' => '#userdetail', 'sort' => false, 'width' => 160));
+        if (checkRriv('/admin/BaseLeague/edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 140));
+        $dt->enableCheckBox();
+        return view('sports/base_league', $dt->render($request));
+    }
+
+    function info(Req $req) {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+        $area_id = Request::has('area_id') ? Request::get('area_id') : '';
+        $country_id = Request::has('country_id') ? Request::get('country_id') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        if (!empty($name_chinese)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_bq_league.name_chinese', 'like', '%' . $name_chinese . '%');
+            }else{
+                $where[] = array('st_bq_league.name_chinese', '=', $name_chinese);
+            }
+        }
+//        if ($name_chinese != -1) {
+//            $where[] = array('st_bq_league.name_chinese', '=', $name_chinese);
+//        }
+        if(!empty($area_id)){
+            $where[] = array('st_bq_league.area_id', '=', $area_id);
+        }
+        if(!empty($country_id)){
+            $where[] = array('st_bq_league.country_id', '=', $country_id);
+        }
+        if($status != 0){
+            $where[] = array('st_bq_league.status', '=', $status);
+        }
+
+        $newapp = new \App\Models\BaseLeague();
+        $data = $newapp->getinfo($list, $page, $where);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    /**
+     *获取地区
+     */
+    function getarea() {
+        $area = \App\Models\StAreaCountry::where('pid',0)->get();
+        return $area;
+    }
+
+    /**
+     *获取该地区的所有国家
+     */
+    function getcountry() {
+        $pid = $_GET["id"];
+        $country = \App\Models\StAreaCountry::where('pid',$pid)->get();
+        return json_encode($country);
+    }
+
+    /**
+     *添加联赛
+     */
+    function add(Req $req) {
+        if (!$req->isMethod('post')) {
+            $areas = $this->getarea();
+            if (!$areas) {
+                return -2;
+            }
+            $data['area'] = $areas;
+            return view('sports.base_league_form', $data);
+        } else {
+            $model = new \App\Models\BaseLeague();
+            $model->name_chinese = $req->input('name_chinese');
+            $model->country_id = $req->input('country_id');
+            $model->area_id = $req->input('area_id');
+            $model->status = $req->input('status');
+            $model->lg_id = time();
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->source = 'user-defined';
+
+            $db = new \App\Models\Stbqlocalleague();
+            $db->source = 'user-defined';
+            $db->lg_id = $model->lg_id;
+
+            $model->save();
+            $db->save();
+            return responseToJson(1);
+
+        }
+    }
+
+    function view(Req $req) {
+        return $this->edit($req);
+    }
+
+    /**
+     *修改联赛
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+            $areas = $this->getarea();
+            if (!$areas) {
+                return -2;
+            }
+            $data = \App\Models\BaseLeague::where('id',$id)->first();
+            $areaname = \App\Models\StAreaCountry::where('id',$data->area_id)->first();
+            $countryname = \App\Models\StAreaCountry::where('id',$data->country_id)->first();
+            if(!empty($areaname)){
+                $data->area = $areaname->name;
+            }
+            if(!empty($countryname)){
+                $data->country = $countryname->name;
+            }
+
+            $data = $data->toArray();
+            $data['area'] = $areas;
+
+            return view('sports.base_league_form', $data);
+        } else {
+            $model = new \App\Models\BaseLeague();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            if(!empty($req->input('country_id'))){
+                $model->country_id = $req->input('country_id');
+            }else{
+                $model->country_id = 0;
+            }
+            if(!empty($req->input('area_id'))){
+                $model->area_id = $req->input('area_id');
+            }else{
+                $model->area_id = 0;
+            }
+            $model->status = $req->input('status');
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *删除联赛
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id???????
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id????
+        }
+        $id = array();
+        $localleague = \App\Models\Stbqlocalleague::get();
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+                $league = \App\Models\BaseLeague::where('id',$v)->first();
+                for($i=0;$i<count($localleague);$i++){
+                    if($localleague[$i]->lg_id == $league->lg_id){
+                        $id[] = $localleague[$i]->id;
+                    }
+                }
+            }
+        }
+
+
+        $rows = \App\Models\BaseLeague::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id????
+        }
+        if(count($id)>0) {
+            $row = \App\Models\Stbqlocalleague::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id????
+
+    }
+
+
+}

+ 184 - 0
app/Http/Controllers/Admin/BaseNoteListController.php

@@ -0,0 +1,184 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jonlin
+ * Date: 2019/4/9
+ * Time: 9:11
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class BaseNoteListController extends Controller
+{
+
+    public function notelist(Req $req)
+    {
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/BaseNoteList/info');
+        $dt->setLang('sportsnotelist');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('order_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
+        $dt->addColsFields('game', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('game_no', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('prize_note', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('water_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        //$dt->addColsFields('prize', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('settle_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('game_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('account_name', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('member_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        //$arr[] = 'view';
+        if (checkRriv('/admin/BaseNoteList/edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 70));
+        $dt->enableCheckBox();
+        return view('sports/sports_notelist', $dt->render($request));
+    }
+
+    function info()
+    {
+        $type = 'bq';
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+//        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        if (!empty($star_time)) {
+            if (!empty($end_time)){
+                $where[] = array('money_buy.money_time', '>', $star_time);
+                $where[] = array('money_buy.money_time', '<', $end_time);
+            }else{
+                $where[] = array('money_buy.money_time', '>', $star_time);
+            }
+        }else if(empty($star_time)){
+            if (!empty($end_time)){
+
+                $where[] = array('money_buy.money_time', '<', $end_time);
+            }
+        }
+        $newapp = new \App\Models\SportsNoteList();
+        $data = $newapp->getinfo($list, $page, $where,$type);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    /**
+     *修改订单
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $lange = trans('sportssoccer');
+        $data = \App\Models\SportsNoteList::where('id',$id)->first();
+        $data->order_time = $data->order_id.'     '.$data->money_time;
+        //for($i=0;$i<count($data);$i++){
+        $codes = json_decode($data->codes, true);
+        $data->content = '';
+        for($j=0;$j<count($codes);$j++){
+            $odds_only = $data->odds_only;
+            $res = DB::table('st_bq_odds_record')->where('odds_only',$odds_only)->first();
+            $result = DB::table('st_odds_code')->where('odds_code',$res['odds_code'])->first();
+            //$result = \App\Model\Matchcode::where('odds_code',$res->odds_code)->first();
+            $game = DB::table('st_game_type')->where('game_code',$data->game_name)->first();
+            $data->content = $data->content.$result['odds_name'].  '¥'.$codes[$j]['bet_amount'];
+            $data->game = $game->game_name;
+        }
+        //}
+
+        if (!$req->isMethod('post')) {
+
+
+            $data = $data->toArray();
+
+            return view('sports/sports_notelist_form', $data);
+        } else {
+            $model = new \App\Models\SportsNoteList();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            $model->water_status = $req->input('water_status');
+            $model->settle_status = $req->input('settle_status');
+            $model->game_status = $req->input('game_status');
+            //$model->utime = date('Y-m-d H:i:s',time());
+
+            $model->save();
+            return responseToJson(1);
+        }
+
+    }
+
+    /**
+     *订单审核
+     */
+    public function orderstatus(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+
+
+    /**
+     *删除订单
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+}

+ 602 - 0
app/Http/Controllers/Admin/BaseSetController.php

@@ -0,0 +1,602 @@
+<?php
+/**
+ * 系统设置
+ */
+
+namespace App\Http\Controllers\Admin;
+
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class BaseSetController extends SystemController {
+    /**
+     *
+     */
+    function Index() {
+        $db = new \App\Models\Setinfo();
+        $notice = $db->getInfo(8);//公告
+        $bank = $db->getInfos(10);//银行卡
+        $tan_box = $db->getInfo(6);//弹框内容
+        $tan_box['extinfo'] = explode(',', $tan_box['extinfo']);
+        $new_box = $db->getInfos(33);//新版弹框内容
+
+        //dump($tan_box);
+        $ser_qq = $db->getInfo(16);//QQ
+        $connectioninfo = $db->getInfos(1017);//联系我们
+        $agent = $db->getInfo(13);//代理
+        $plat = $db->getInfo(17);//平台
+        $game = $db->getInfo(15);//游戏
+        $run = $db->getInfo(9);//跑马灯
+        $two = $db->getInfo(20);//二级密码
+        $url = $db->getInfo(18);//api
+        $add_token = $db->getInfo(19);
+        $agent_box = $db->getInfo(21);
+        $quickUrl = $db->getInfo(22);    //快捷支付网关地址
+        $ipLimit = $db->getInfo(23);//IP设置
+        $net = $db->getInfos(24);//网站设置
+        $agentUrl = $db->getInfo(30);//网站设置
+        $nagentFxUrl = $db->getInfo(1018);//级差代理分享域名设置
+        $extension = $db->getInfo(31);//广告
+        $open = $db->getInfo(1000);//开奖token
+        $info = $db->getInfo(1024); //分享注册页面信息设置
+        $startup = $db->getInfo(1111); //启动页设置设置
+        $fsnum = $db->getInfo(1001); //启动页设置设置
+        $stsource = $db->getInfo(1002); //启动页设置设置
+        $wsport = $db->getInfo(9501);//websocket聊天服务器ip 端口设置
+        $jnd = $db->getInfo(40);//加拿大28维护
+        $playtest = $db->getInfo(2000);//试玩账号设置
+        $oggame = $db->getInfo(2001);//真人
+        $liao = $db->getInfo(2002);//聊天白名单
+        $word = $db->getInfo(2003);//敏感字
+        $imglink = $db->getInfo(2004);//图片服务器地址
+        $H5ShareLink = $db->getInfo(2005);//h5代理分享链接
+        $tokentime = $db->getInfo(100);//token前端处理失效时间
+        $updateOdds = $db->getInfo(1911);//是否更新赔率
+        $updateTime = $db->getInfo(1912);//缓存更新时间
+        $paymentCate = $db->getInfo(20060);//充值排序设置
+        $source = \App\Models\Stzqlocalleague::select('source')->groupby('source')->get()->toArray();//体育比分数据源设置
+        if(count($source)>1){
+            $source[] = Array("source" => "混合数据");
+        }
+        if (!empty($jnd['extinfo'])) {
+            $jnd['extinfo'] = explode('~', $jnd['extinfo']);
+        }
+        if (is_array($net) && count($net) > 0) {
+            $net = $this->netData($net);
+        }
+        if (is_array($connectioninfo) && count($connectioninfo) > 0) {
+            $connectioninfo = $this->netData($connectioninfo);
+        }
+        if (is_array($new_box) && count($new_box) > 0) {
+            $new_box = $this->netData($new_box);
+        }
+// var_dump($fsnum);die;//infotype
+        $db_reg = new \App\Models\Settings();
+        $reg = $db_reg->getSet();
+        return view('admin.baseSet/index', ['notice' => $notice, 'bank' => $bank, 'tan_box' => $tan_box, 'new_box' => $new_box, 'qq' => $ser_qq, 'connectioninfo' => $connectioninfo,
+            'agent' => $agent, 'plat' => $plat, 'game' => $game, 'run' => $run, 'two' => $two,
+            'url' => $url, 'reg' => $reg, 'add_token' => $add_token, 'agent_box' => $agent_box,
+            'quickUl' => $quickUrl, 'ip' => $ipLimit, 'net' => $net, 'agentUrl' => $agentUrl,
+            'extension' => $extension,'fsnum'=>$fsnum,'stsource'=>$stsource, 'open' => $open, 'nagentFxUrl' => $nagentFxUrl, 'regInfo' => $info,
+            'startup' => $startup, 'wsport' => $wsport, 'jnd' => $jnd, 'playtest' => $playtest,
+            'oggame' => $oggame, 'liao' => $liao, 'word' => $word, 'imglink' => $imglink, 'H5ShareLink' => $H5ShareLink,
+            'tokentime' => $tokentime, 'updateOdds' => $updateOdds, 'updateTime' => $updateTime,'paymentCate'=>$paymentCate,'source'=>$source]);
+    }
+
+    function info() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getInfos(10);//银行卡
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //处理网站设置数据
+    private function netData($data) {
+
+        $newarr = array();
+        foreach ($data as $key => $value) {
+            $newarr[$value['remarks']] = $value;
+        }
+        return $newarr;
+    }
+
+    function show() {
+        return view('admin.systemSet/setBase');
+    }
+
+    //更新设置数据
+    function updateInfo(Req $req) {
+        $data = $req->all();
+        $data = $data['data'];
+        if (empty($data) || count($data) < 1) {
+            return responseToJson(-5030002031);
+        }
+        if (isset($data['contentype'])) {
+            if ($data['contentype'] == 2) {
+                $data['remarks'] = strip_tags($data['remarks']);
+            }
+            $data['extinfo'] = $data['contentype'];
+            unset($data['contentype']);
+        }
+        $type = $data['type'];
+        unset($data['type']);
+        if (is_numeric($type)) {
+            $title = $data['infoname'];
+            $db = new \App\Models\Setinfo;
+            if ($type == 17) {
+                //密码校验
+                $res = $this->checkPwd($data['password']);
+                if ($res < 0) {
+                    return responseToJson($res);
+                }
+                $path = $this->getPath();
+                $status = $data['status'] == 1 ? 1 : 2;
+                //拼凑token
+                $suiji = GenEncryption();
+                $token = session('adminInfo.admin_name') . '||' . session('adminInfo.passwd') . '||' . $suiji . '||' . REMOTE_KEY;
+                $rtoken = md5(md5($token));
+                $url = $path . 'close?status=' . $status . '&token=' . session('adminInfo.admin_name') . '||' . $rtoken . '||' . $suiji;
+                $arrA = $this->getUrl($url);
+                if ($arrA) {
+                    return responseToJson(-200031);
+                }
+                unset($data['password']);
+            }
+
+            if ($type == 24) {
+                $netdata = array(
+                    'infoname' => $data['infoname'],
+                    'infotype' => $type,
+                );
+
+                $namedata = $netdata;
+                $namedata['infocontent'] = $data['netname'];
+                $namedata['remarks'] = 'netname';
+
+                $recedata = $netdata;
+                $recedata['infocontent'] = $data['recedata'];
+                $recedata['remarks'] = 'recedata';
+
+                $keywordsdata = $netdata;
+                $keywordsdata['infocontent'] = $data['netkeywords'];
+                $keywordsdata['remarks'] = 'netkeywords';
+
+                $descdata = $netdata;
+                $descdata['infocontent'] = $data['netdesc'];
+                $descdata['remarks'] = 'netdesc';
+
+                $logourl = $netdata;
+                $logourl['infocontent'] = $data['logourl'];
+                $logourl['remarks'] = 'logourl';
+
+                $loginlogo = $netdata;
+                $loginlogo['infocontent'] = $data['loginlogo'];
+                $loginlogo['remarks'] = 'loginlogo';
+
+
+                $quicklypay = $netdata;
+                $quicklypay['infocontent'] = $data['quickly_pay'];
+                $quicklypay['remarks'] = 'quickly_pay';
+
+                $appdownload = $netdata;
+                $appdownload['infocontent'] = $data['app_download'];
+                $appdownload['remarks'] = 'app_download';
+
+                //真人网址
+                $realperson = $netdata;
+                $realperson['infocontent'] = $data['real_person'];
+                $realperson['remarks'] = 'real_person';
+                /*	if(empty($data['recedataid'])||empty($data['recedataid'])){
+                        $res = $db->addInfo($namedata);
+                        $res = $db->addInfo($recedata);
+                        $res = $db->addInfo($keywordsdata);
+                        $res = $db->addInfo($descdata);
+                    }else{*/
+
+				//showhome //前台默认模板
+				$showhome = $netdata;
+				$showhome['infocontent'] = $data['showhome'];
+				$showhome['remarks'] = 'showhome';
+
+                $res = $db->checkdata($quicklypay, $data['quicklypayid']);
+                $res = $db->checkdata($appdownload, $data['appdownloadid']);
+                $res = $db->checkdata($logourl, $data['logourlid']);
+                $res = $db->checkdata($loginlogo, $data['loginlogoid']);
+                $res = $db->checkdata($namedata, $data['netnameid']);
+                $res = $db->checkdata($recedata, $data['recedataid']);
+                $res = $db->checkdata($keywordsdata, $data['netkeywordsid']);
+                $res = $db->checkdata($descdata, $data['netdescid']);
+                $res = $db->checkdata($realperson, $data['realpersonid']); //真人网址
+                $res = $db->checkdata($showhome, $data['showhomeid']);
+
+
+                /*}*/
+            } else if ($type == 33) {
+                $condata = array(
+                    'infoname' => $data['infoname'],
+                    'infotype' => $type,
+                );
+
+                // $newsdata = $condata;
+                // $newsdata['infocontent'] = $data['important_news'];
+                // $newsdata['remarks'] = 'important_news';
+
+                $sitedata = $condata;
+                $sitedata['infocontent'] = $data['site_navigation'];
+                $sitedata['remarks'] = 'site_navigation';
+
+                $contdata = $condata;
+                $contdata['infocontent'] = $data['contact_customer'];
+                $contdata['remarks'] = 'contact_customer';
+
+                $timeddata = $condata;
+                $timeddata['infocontent'] = $data['con_timed'];
+                $timeddata['remarks'] = 'con_timed';
+
+
+                if (!empty($newsdata['infocontent'])) $res = $db->checkdata($newsdata, $data['important_newsid']);
+                if (!empty($sitedata['infocontent'])) $res = $db->checkdata($sitedata, $data['site_navigationid']);
+                if (!empty($contdata['infocontent'])) $res = $db->checkdata($contdata, $data['contact_customerid']);
+                if (!empty($timeddata['infocontent'])) $res = $db->checkdata($timeddata, $data['con_timedid']);
+                /*}*/
+            } else if ($type == 1017) {
+                $condata = array(
+                    'infoname' => $data['infoname'],
+                    'infotype' => $type,
+                );
+
+                $teldata = $condata;
+                $teldata['infocontent'] = $data['con_tel'];
+                $teldata['remarks'] = 'con_tel';
+
+                $qqdata = $condata;
+                $qqdata['infocontent'] = $data['con_qq'];
+                $qqdata['remarks'] = 'con_qq';
+
+                $skypedata = $condata;
+                $skypedata['infocontent'] = $data['con_skype'];
+                $skypedata['remarks'] = 'con_skype';
+
+                $onlinesdata = $condata;
+                $onlinesdata['infocontent'] = $data['con_onlines'];
+                $onlinesdata['remarks'] = 'con_onlines';
+
+                $weixindata = $condata;
+                $weixindata['infocontent'] = $data['con_weixin'];
+                $weixindata['remarks'] = 'con_weixin';
+
+                $emaildata = $condata;
+                $emaildata['infocontent'] = $data['con_email'];
+                $emaildata['remarks'] = 'con_email';
+
+                if (!empty($teldata['infocontent'])) $res = $db->checkdata($teldata, $data['con_telid']);
+                if (!empty($qqdata['infocontent'])) $res = $db->checkdata($qqdata, $data['con_qqid']);
+                if (!empty($skypedata['infocontent'])) $res = $db->checkdata($skypedata, $data['con_skypeid']);
+                if (!empty($onlinesdata['infocontent'])) $res = $db->checkdata($onlinesdata, $data['con_onlinesid']);
+                if (!empty($weixindata['infocontent'])) $res = $db->checkdata($weixindata, $data['con_weixinid']);
+                if (!empty($emaildata['infocontent'])) $res = $db->checkdata($emaildata, $data['con_emailid']);
+
+                /*}*/
+            } else if ($type == 40) {//qtx 2018-12-12
+                /*if(!empty($data['starttime']) && !empty($data['endtime'] && date('H:i:s', strtotime($data['starttime']))  == $data['starttime'] && date('H:i:s', strtotime($data['endtime']))  == $data['endtime'])){}*/
+                //2018-12-26 anton liu 修改
+                $data['extinfo'] = $data['starttime'] . '~' . $data['endtime'];
+                unset($data['starttime']);
+                unset($data['endtime']);
+                $res = $db->updateInfo($data, $type);
+
+            } else if ($type == 1018) //2019-01-16 级差域名检测 anton liu
+            {
+                $dom = explode('||', $data['infocontent']);
+                foreach ($dom as $k => $v) {
+                    $isext = \App\Models\Nagent_detailed::checkDom($v, '');
+                    if ($isext) {
+                        return responseToJson(-1, $v . '已绑定专属代理');
+                    }
+                }
+                $res = $db->updateInfo($data, $type);
+            } else {
+                $res = $db->updateInfo($data, $type);
+            }
+            if ($type == 9501 || $type == 2003) {
+                $webSocket = array();
+                //聊天配置信息推送
+                if ($type == 9501) {   //服务器ip设置
+                    $word = $db->getInfo(2003);//敏感字
+                    $server = $data['infocontent'];
+                    $webSocket = [
+                        'sign' => md5(time() . $data['extinfo']),
+                        'time' => (int)time(),
+                        'word_info' => $word['infocontent'],
+                    ];
+                }
+                if ($type == 2003) { //聊天敏感字符
+                    $wsport = $db->getInfo(9501);//websocket聊天服务器ip 端口设置
+                    $server = $wsport['infocontent'];
+                    $webSocket = [
+                        'sign' => md5(time() . $wsport['extinfo']),
+                        'time' => (int)time(),
+                        'word_info' => $data['infocontent'],
+                    ];
+                }
+
+                // infocontent 值为ws:192.168.2.200:9501|wss:192.168.2.200:9501
+                $server = !empty($server) ? explode('||', $server) : '';
+                $server = !empty($server[0]) ? explode(':', $server[0]) : '';
+                if (empty($server[1])) {
+                    return responseToJson(-9501, '聊天服务器IP地址错误:' . $server[1]);
+                }
+                $server = count($server) > 2 ? $server[1] . ':' . $server[2] : $server[1];
+                $postUrls = $server . '/' . 'whiteList';
+                $chs = curl_init();//初始化curl
+                curl_setopt($chs, CURLOPT_URL, $postUrls);//抓取指定网页
+                curl_setopt($chs, CURLOPT_HEADER, 0);//设置header
+                curl_setopt($chs, CURLOPT_TIMEOUT, 15);
+                curl_setopt($chs, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
+                curl_setopt($chs, CURLOPT_POST, 1);//post提交方式
+                curl_setopt($chs, CURLOPT_POSTFIELDS, $webSocket);
+                curl_exec($chs);//运行curl
+                if (curl_errno($chs) != 0) {
+                    $status = -9501;
+                    $msg = '--聊天服务器IP地址错误--';
+                } else {
+                    $status = 1;
+                    $msg = '成功';
+                }
+                curl_close($chs);
+                return responseToJson($status, $msg);
+            }
+        } else {
+            $title = '会员注册设置';
+            $db_reg = new \App\Models\Settings();
+            $res = $db_reg->updateSet($data);
+        }
+
+        $log = array(
+            session('adminInfo.admin_name'),
+            $title,
+        );
+        OperationLog(session('adminInfo.admin_id'), 'editBaseSet', $log);
+        return responseToJson($res);
+    }
+
+    //检测密码
+    function checkPwd($password) {
+        $admin_id = session('adminInfo.admin_id');
+        $db = new \App\Models\System_user;
+        $admin_info = $db->getAdminInfo($admin_id, 1);
+        if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
+            return -7095167422;
+        }
+        return 1;
+    }
+
+    //访问接口
+    function getUrl($url) {
+        //初始化
+        $curl = curl_init();
+        //设置抓取的url
+        curl_setopt($curl, CURLOPT_URL, $url);
+        //设置头文件的信息作为数据流输出
+        curl_setopt($curl, CURLOPT_HEADER, 1);
+        //设置获取的信息以文件流的形式返回,而不是直接输出。
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+        //执行命令
+        $data = curl_exec($curl);
+        //关闭URL请求
+        curl_close($curl);
+//        显示获得的数据
+//        print_r($data);
+    }
+
+    function getPath() {
+        $data = \App\Models\Setinfo::getPath();
+        return $data;
+    }
+
+    //获取基础设置
+    function getBaseSet() {
+        $infoname = Request::has('infoname') ? Request::get('infoname') : '';
+        $infocontent = Request::has('infocontent') ? Request::get('infocontent') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+
+        $where = array();
+        if (!empty($infoname)) {
+            $where[] = array('infoname', 'like', '%' . $infoname . '%');
+        }
+        if (!empty($infocontent)) {
+            $where[] = array('infocontent', 'like', '%' . $infocontent . '%');
+        }
+        if (!empty($status)) {
+            if ($status == 2) {
+                $where[] = array('status', '=', '0');
+            } else {
+                $where[] = array('status', '=', $status);
+            }
+        }
+
+        $db = new \App\Models\Setinfo();
+        $data = $db->getAllSet($where);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data, count($data));
+    }
+
+    function Edit(Req $req) {
+        $infotype = $req->infotype;
+        if (empty($infotype)) {
+            abort(404);
+        }
+        $db = new \App\Models\Setinfo();
+        $arr = array(6, 16, 19, 9, 13); //含有设置框的infotype
+        if (!$req->isMethod('post')) {
+            $data = $db::where('infotype', $infotype)->first();
+            if (!$data) {
+                abort(404);
+            }
+            $data = $data->toArray();
+            return view('admin.systemSet/edit', ['data' => $data, 'arr' => $arr]);
+        } else {
+
+            $model = $db::where('infotype', $infotype)->first();
+            if (!empty($req->input('infocontent'))) {
+                $model->infocontent = $req->input('infocontent');
+            }
+            $model->status = $req->input('status');
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+
+    //玩法简介
+    function Playdesc() {
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/System/active');
+        $dt->setLang('notice');
+        $dt->addColsFields('id', array('width' => 170, 'fixed' => 'left'));
+        $dt->addColsFields('name');
+//        $dt->addColsFields('play_desc');
+        $dt->addColsFields('table_name');
+        $dt->setToolBar(array('view', 'edit'));
+        return view('admin.systemSet/arictle', $dt->render());
+    }
+
+    /**
+     * 公告显示
+     */
+    function Notice() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getNotice();
+        return responseToJson($data);
+    }
+
+
+    /**
+     * 弹框
+     */
+    function OutBox() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getBoxOut();
+        return responseToJson($data);
+    }
+
+
+    /**
+     * 客服QQ设置
+     */
+    function ServerQQ() {
+//        $data=DB::table('setinfo')->where('infotype',14)->get();
+        //        dump($data->toArray());
+        $db = new \App\Models\Setinfo();
+        $data = $db->getQQnumber();
+        return responseToJson($data);
+    }
+
+    /**
+     * 代理设置
+     */
+    function Agent() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getAgentSet();
+        return responseToJson($data);
+    }
+
+    function Fsnum() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getFsnumSet();
+        return responseToJson($data);
+    }
+
+    /**
+     * 平台维护
+     */
+    function PlatFrom() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getPlatSet();
+        return responseToJson($data);
+    }
+
+    /**
+     * 平台维护设置
+     */
+    function PlatFromSet() {
+
+    }
+
+    //虚拟游戏设置显示
+    function Flaseprize() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getPrizeSet();
+        return responseToJson($data);
+    }
+
+    //转账银行卡信息
+    function BankInfo() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getBankInfo();
+        return responseToJson($data);
+    }
+
+    //跑马灯公告
+    function RunNotice() {
+        $db = new \App\Models\Setinfo();
+        $data = $db->getRunNotice();
+        return responseToJson($data);
+    }
+
+    //注册设置信息
+    function RegisterSet() {
+        $db = new \App\Models\Settings();
+        $data = $db->getSet();
+        return responseToJson($data);
+    }
+
+    /**
+     * 游戏玩法说明消息
+     */
+    function Active() {
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $db = new \App\Models\GameType();
+        $data = $db->getDescList($list);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+//        return responseToJson($data);
+    }
+
+
+    /**
+     * 系统菜单列表
+     */
+    function SystemMenu() {
+        $db = new \App\Models\Menu();
+        $data = $db->getMenuAll();
+        return responseToJson($data);
+    }
+
+    /**
+     * 菜单
+     */
+    function MenuList() {
+        $data = config('menu');
+        return responseToJson($data);
+    }
+
+    //获取网站设置
+    function getWebTitle(Req $req) {
+        $data = \App\Models\Setinfo::getWebSet();
+        return responseToJson($data);
+    }
+
+    public function clearCache() {
+
+        $db = new \App\Models\Setinfo();
+        $rec = $db->where('infotype', '1912')->first();
+        if (!$rec) {
+            $ret = $db->addInfo(['infotype' => '1912','infoname'=>'缓存更新时间', 'infocontent' => date('Y-m-d H:i:s')]);
+        } else {
+            $ret = $db->where('infotype', '1912')->update(['infocontent' => date('Y-m-d H:i:s')]);
+        }
+
+        return responseToJson($ret ? 1 : -999, $ret ? '更新缓存时间成功' : '更新缓存时间失败');
+    }
+}
+

+ 226 - 0
app/Http/Controllers/Admin/BasketLeagueController.php

@@ -0,0 +1,226 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class BasketLeagueController extends Controller {
+
+    public function index(Req $req) {
+        //$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
+        $request['area_id'] = isset($req->area_id) ? trim($req->area_id) : '';
+        $request['country_id'] = isset($req->country_id) ? trim($req->country_id) : '';
+        $request['id'] = isset($req->id) ? trim($req->id) : '';
+        $request['status'] = isset($req->status) ? trim($req->status) : '0';
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $data = \App\Models\BasketLeague::select('id','lg_id','name_chinese')->get();
+        $area = \App\Models\StAreaCountry::where('pid',0)->get();
+        $country = \App\Models\StAreaCountry::where('pid','!=',0)->get();
+        $request['league'] = $data;
+        $request['area'] = $area;
+        $request['country'] = $country;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/BasketLeague/info');
+        $dt->setLang('sportsbase');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('area', array('sort' => false, 'width' => 180));
+        $dt->addColsFields('country', array('sort' => true, 'width' => 180));
+        $dt->addColsFields('league_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('utime', array('templet' => '#userdetail', 'sort' => false, 'width' => 160));
+        if (checkRriv('/admin/BasketLeague/edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 140));
+        $dt->enableCheckBox();
+        return view('sports/basket_league', $dt->render($request));
+    }
+
+    function info(Req $req) {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+        $area_id = Request::has('area_id') ? Request::get('area_id') : '';
+        $country_id = Request::has('country_id') ? Request::get('country_id') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        if (!empty($name_chinese)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_lq_league.name_chinese', 'like', '%' . $name_chinese . '%');
+            }else{
+                $where[] = array('st_lq_league.name_chinese', '=', $name_chinese);
+            }
+        }
+//        if ($name_chinese != -1) {
+//            $where[] = array('st_zq_league.name_chinese', '=', $name_chinese);
+//        }
+        if(!empty($area_id)){
+            $where[] = array('st_lq_league.area_id', '=', $area_id);
+        }
+        if(!empty($country_id)){
+            $where[] = array('st_lq_league.country_id', '=', $country_id);
+        }
+        if($status != 0){
+            $where[] = array('st_lq_league.status', '=', $status);
+        }
+
+        $newapp = new \App\Models\BasketLeague();
+        $data = $newapp->getinfo($list, $page, $where);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    /**
+     *获取地区
+     */
+    function getarea() {
+        $area = \App\Models\StAreaCountry::where('pid',0)->get();
+        return $area;
+    }
+
+    /**
+     *获取该地区的所有国家
+     */
+    function getcountry() {
+        $pid = $_GET["id"];
+        $country = \App\Models\StAreaCountry::where('pid',$pid)->get();
+        return json_encode($country);
+    }
+
+    /**
+     *添加联赛
+     */
+    function add(Req $req) {
+        if (!$req->isMethod('post')) {
+            $areas = $this->getarea();
+            if (!$areas) {
+                return -2;
+            }
+            $data['area'] = $areas;
+            return view('sports.basket_league_form', $data);
+        } else {
+            $model = new \App\Models\BasketLeague();
+            $model->name_chinese = $req->input('name_chinese');
+            $model->country_id = $req->input('country_id');
+            $model->area_id = $req->input('area_id');
+            $model->status = $req->input('status');
+            $model->lg_id = time();
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->source = 'user-defined';
+
+            $db = new \App\Models\Stlqlocalleague();
+            $db->source = 'user-defined';
+            $db->lg_id = $model->lg_id;
+
+            $model->save();
+            $db->save();
+            return responseToJson(1);
+
+        }
+    }
+
+    function view(Req $req) {
+        return $this->edit($req);
+    }
+
+    /**
+     *修改联赛地区,国家,联赛状态
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+            $areas = $this->getarea();
+            if (!$areas) {
+                return -2;
+            }
+            $data = \App\Models\BasketLeague::where('id',$id)->first();
+            $areaname = \App\Models\StAreaCountry::where('id',$data->area_id)->first();
+            $countryname = \App\Models\StAreaCountry::where('id',$data->country_id)->first();
+            if(!empty($areaname)){
+                $data->area = $areaname->name;
+            }
+            if(!empty($countryname)){
+                $data->country = $countryname->name;
+            }
+
+            $data = $data->toArray();
+            $data['area'] = $areas;
+
+            return view('sports.basket_league_form', $data);
+        } else {
+            $model = new \App\Models\BasketLeague();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            if(!empty($req->input('country_id'))){
+                $model->country_id = $req->input('country_id');
+            }else{
+                $model->country_id = 0;
+            }
+            if(!empty($req->input('area_id'))){
+                $model->area_id = $req->input('area_id');
+            }else{
+                $model->area_id = 0;
+            }
+            $model->status = $req->input('status');
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *删除联赛
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id???????
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id????
+        }
+        $id = array();
+        $localleague = \App\Models\Stlqlocalleague::get();
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+                $league = \App\Models\BasketLeague::where('id',$v)->first();
+                for($i=0;$i<count($localleague);$i++){
+                    if($localleague[$i]->lg_id == $league->lg_id){
+                        $id[] = $localleague[$i]->id;
+                    }
+                }
+            }
+        }
+
+
+        $rows = \App\Models\BasketLeague::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id????
+        }
+        if(count($id)>0) {
+            $row = \App\Models\Stlqlocalleague::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id????
+
+    }
+
+
+}

+ 184 - 0
app/Http/Controllers/Admin/BasketNoteListController.php

@@ -0,0 +1,184 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jonlin
+ * Date: 2019/4/9
+ * Time: 9:11
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class BasketNoteListController extends Controller
+{
+
+    public function notelist(Req $req)
+    {
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/BasketNoteList/info');
+        $dt->setLang('sportsnotelist');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('order_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
+        $dt->addColsFields('game', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('game_no', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('prize_note', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('water_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        //$dt->addColsFields('prize', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('settle_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('game_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('account_name', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('member_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        //$arr[] = 'view';
+        if (checkRriv('/admin/BasketNoteList/edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 70));
+        $dt->enableCheckBox();
+        return view('sports/sports_notelist', $dt->render($request));
+    }
+
+    function info()
+    {
+        $type = 'lq';
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+//        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        if (!empty($star_time)) {
+            if (!empty($end_time)){
+                $where[] = array('money_buy.money_time', '>', $star_time);
+                $where[] = array('money_buy.money_time', '<', $end_time);
+            }else{
+                $where[] = array('money_buy.money_time', '>', $star_time);
+            }
+        }else if(empty($star_time)){
+            if (!empty($end_time)){
+
+                $where[] = array('money_buy.money_time', '<', $end_time);
+            }
+        }
+        $newapp = new \App\Models\SportsNoteList();
+        $data = $newapp->getinfo($list, $page, $where,$type);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    /**
+     *修改订单
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $lange = trans('sportssoccer');
+        $data = \App\Models\SportsNoteList::where('id',$id)->first();
+        $data->order_time = $data->order_id.'     '.$data->money_time;
+        //for($i=0;$i<count($data);$i++){
+        $codes = json_decode($data->codes, true);
+        $data->content = '';
+        for($j=0;$j<count($codes);$j++){
+            $odds_only = $data->odds_only;
+            $res = DB::table('st_zq_odds_record')->where('odds_only',$odds_only)->first();
+            $result = DB::table('st_odds_code')->where('odds_code',$res['odds_code'])->first();
+            //$result = \App\Model\Matchcode::where('odds_code',$res->odds_code)->first();
+            $game = DB::table('st_game_type')->where('game_code',$data->game_name)->first();
+            $data->content = $data->content.$result['odds_name'].  '¥'.$codes[$j]['bet_amount'];
+            $data->game = $game->game_name;
+        }
+        //}
+
+        if (!$req->isMethod('post')) {
+
+
+            $data = $data->toArray();
+
+            return view('sports/sports_notelist_form', $data);
+        } else {
+            $model = new \App\Models\SportsNoteList();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            $model->water_status = $req->input('water_status');
+            $model->settle_status = $req->input('settle_status');
+            $model->game_status = $req->input('game_status');
+            //$model->utime = date('Y-m-d H:i:s',time());
+
+            $model->save();
+            return responseToJson(1);
+        }
+
+    }
+
+    /**
+     *订单审核
+     */
+    public function orderstatus(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+
+
+    /**
+     *删除订单
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\BasketNoteList::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+}

+ 69 - 0
app/Http/Controllers/Admin/CascadeController.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ * 级联关系
+ */
+class CascadeController extends Controller {
+	/**
+     * 获取级联关系
+     *
+     * @access public
+     * @param mixed $req 传入参数 rank等级 id当前ID gameType球类型
+	 * @return array JsonString
+	 */
+	public function index(Req $req) {
+        $code = 200;
+        $msg = '失败';
+        $data = '';
+        $rank = isset($req->rank) ? $req->rank : 0;
+        $id = isset($req->id) ? $req->id : 0;
+        $gameType = isset($req->gameType) ? $req->gameType : 0;
+		// 赛事种类获取
+        $gameTypeModel = new \App\Models\StGameType();
+        $getGameTypeSelect = ['id', 'game_name', 'game_code'];
+        $getGameTypeWhere['status'] = 1;
+        if (empty($gameType)) {
+            $msg = '运动类型为空';
+            return ['code' => $code, 'msg' => $msg, 'data' => ''];
+        }
+        $getGameTypeWhere['id'] = $gameType;
+        $getGameType = $gameTypeModel -> getGameType($getGameTypeSelect, $getGameTypeWhere);
+        // 获取级联数据
+        $cascadeModel = new \App\Models\Cascade();
+        /*$a = $cascadeModel -> getLeague('*', '', $getGameType[0]['game_code']);
+        echo json_encode($a);die;*/
+        $result = [];
+        switch ($rank) {
+            // 级联关系[0洲,1国家,2联赛,3球队]
+            case 0:
+                $getResultSelect = ['id', 'title', 'source'];
+                $result = $cascadeModel -> allArea($getResultSelect);
+                break;
+            case 1:
+                $getResultSelect = ['country_id', 'name_chinese', 'name_english', 'country_ico', 'country_area', 'id', 'source'];
+                $getResultWhere['country_area'] = $id;
+                $result = $cascadeModel -> getCountryByArea($getResultSelect, $getResultWhere, $getGameType[0]['game_code'], $gameType);
+                break;
+            case 2:
+                $getResultSelect = ['name_chinese', 'name_english', 'kind', 'league_pic', 'country_id', 'area_id', 'id', 'lg_id'];
+                $getResultWhere['country_id'] = $id;
+                $result = $cascadeModel -> league($getResultSelect, $getResultWhere, $getGameType[0]['game_code']);
+                break;
+            case 3:
+                $getResultSelect = ['id', 'home_team', 'guest_team', 'lg_id'];
+                $getResultWhere['lg_id'] = $id;
+                $result['competition'] = $cascadeModel -> getCompetition($getResultSelect, $getResultWhere, $getGameType[0]['game_code']);
+                break;
+        }
+        $msg = 'success';
+        return ['code' => $code, 'msg' => $msg, 'data' => $result];
+	}
+}
+
+?>

+ 236 - 0
app/Http/Controllers/Admin/CompetitionController.php

@@ -0,0 +1,236 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use Request;
+
+/**
+ *赛事场次管理
+ */
+class CompetitionController extends Controller {
+	public function Index(Req $req){
+        $request=array();
+        $request['match_id']=isset($req->match_id)?trim($req->match_id):null;//赛事id
+
+        $request['game']=isset($req->game)?trim($req->game):null;//游戏名
+        //开始时间
+        $request['start_time_a']=isset($req->start_time_a)?trim($req->start_time_a):null;
+        $request['start_time_b'] = isset($req->start_time_b) ? trim($req->start_time_b) : null;
+        //结束时间
+        $request['end_time_a'] = isset($req->end_time_a) ? trim($req->end_time_a) : null;
+        $request['end_time_b'] = isset($req->end_time_b) ? trim($req->end_time_b) : null;
+        //赛事名称
+        $request['info_name']=isset($req->info_name )?$req->info_name :null;
+        $request['sub_title']=isset($req->sub_title )?$req->sub_title :null;
+        $request['info_no']=isset($req->info_no )?$req->info_no :null;
+        //状态
+        $request['status']=isset($req->status)?$req->status:null;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Competition/dataSource?match_id='.$request['match_id']);
+        $dt->setLang('competition');
+        $dt->addColsFields('game_name', array('sort' => false,'width'=>150));
+        $dt->addColsFields('info_name', array('sort' => false,'width'=>150));
+        $dt->addColsFields('sub_title', array('sort' => false,'width'=>150));
+        $dt->addColsFields('info_no', array('sort' => false,'width'=>187));
+        $dt->addColsFields('start_time', array('sort' => false,'width'=>200));
+        $dt->addColsFields('end_time', array('sort' => false,'width'=>200));
+        $dt->addColsFields('status', array('templet'=>'#status'));
+        $dt->addColsFields('tools',array('templet' => '#tools'));
+        return view('admin.competition/index', $dt->render($request));
+	}
+	//数据源
+	function dataSource(Req $req){
+
+        $match_id=isset($req->match_id)?intval($req->match_id):'';//赛事id
+
+        $game=isset($req->game)?trim($req->game):null;//游戏名
+        //开始时间
+        $start_time_a=isset($req->start_time_a)?trim($req->start_time_a):null;
+        $start_time_b = isset($req->start_time_b) ? trim($req->start_time_b) : null;
+        //结束时间
+        $end_time_a = isset($req->end_time_a) ? trim($req->end_time_a) : null;
+        $end_time_b = isset($req->end_time_b) ? trim($req->end_time_b) : null;
+        //赛事名称
+        $info_name=isset($req->info_name)?$req->info_name:null;
+        //场次
+        $sub_title=isset($req->sub_title)?$req->sub_title:null;
+        $info_no=isset($req->info_no)?trim($req->info_no):null;
+        //状态
+        $status =isset($req->status)?$req->status:null;
+        //条数
+        $list=isset($req->limit)?intval($req->limit):10;
+        $where=array();//条件数组
+        if(!empty($match_id)){
+            $where[]=array('match_id','=',$match_id);
+        }
+        if(!empty($game)){
+            $where[]=array('game_name','=',$game);
+        }
+        if(!empty($start_time_a)){
+            $start_time_a=$start_time_a.' 00:00:00';
+            $where[]=array('start_time','>=',$start_time_a);
+        }
+        if(!empty($start_time_b)){
+            $start_time_b=$start_time_a.' 23:59:59';
+            $where[]=array('start_time','>=',$start_time_b);
+        }
+        if(!empty($end_time_a)){
+            $end_time_a=$end_time_a.' 00:00:00';
+            $where[]=array('end_time','>=',$end_time_a);
+        }
+        if(!empty($end_time_b)){
+            $end_time_b=$end_time_b.' 23:59:59';
+            $where[]=array('start_time','>=',$end_time_b);
+        }
+        if(!empty($info_name)){
+            $where[]=array('info_name','like','%'.$info_name.'%');
+        }
+        if(!empty($sub_title)){
+            $where[]=array('sub_title','like','%'.$sub_title.'%');
+        }
+        if(!empty($status)){
+            $where[]=array('status','=',$status);
+        }
+        if(!empty($info_no)){
+            $where[]=array('info_no','=',$info_no);
+        }
+      $data=\App\Models\Egame::getInfoList($where,$list);
+
+      return \App\Lib\DataTable\DataTable::init()->toJson($data['data'],$data['total']);
+    }
+
+    //详情查看
+    function View(Req $req){
+        $info_no=$req->info_no?trim($req->info_no):'';
+        if(empty($info_no)){
+            echo '没获取正确的区号';
+            return -1;
+        }
+        $data=\App\Models\Egame::getDetail($info_no);
+//        dump($data);
+        return view('/admin/competition/view',['data'=>$data]);
+
+    }
+
+    //新增游戏期数
+    function Add(Req $req){
+        $match_id=$req->match_id?intval($req->match_id):'';
+        $match_info=array();
+        $game=$req->game?trim($req->game):'';
+        if(empty($match_id)){
+            $match_info=\App\Models\Egame::getNowMatch($game);
+            if($match_info<0){
+                echo '没有对应赛事';
+                return -1;
+            }
+            $match_id=$match_info['match_id'];
+        }
+        if(!$req->isMethod('post')){
+
+            //获取赛事信息
+            $match_info=\App\Models\Egame_match::getInfoByID($match_id);
+            if(!empty($game)){
+                $match_info['game_name']=$game;
+            }
+
+            //获取赛事队伍
+            $team_info=\App\Models\Egame_team::getMatchTeam($match_id);
+            if($team_info<0||empty($team_info)){
+                echo '请先添加赛事参赛队伍';
+                return $team_info;
+            }
+            return view('admin.competition/add',['match'=>$match_info,'team'=>$team_info]);
+        }else{
+            $info_no=$req->info_no?trim($req->info_no):'';
+            $info_name=$req->info_name?trim($req->info_name):'';
+            $start_time=$req->start_time?$req->start_time:'';
+            $end_time=$req->end_time?$req->end_time:'';
+            $sub_title=$req->sub_title?trim($req->sub_title):'';
+            $sealingplate=$req->sealingplate?trim($req->sealingplate):'';
+            $game_name=$req->game_name?$req->game_name:'';
+            $video_url=$req->video_url?$req->video_url:'';
+            $team_a_identity=$req->team_a_identity?trim($req->team_a_identity):'';
+            $team_b_identity=$req->team_b_identity?trim($req->team_b_identity):'';
+            /****************************数据检测********************************/
+            if(empty($info_no)){
+                return responseToJson(-9040410422);
+            }
+            if(empty($info_name)){
+                return responseToJson(-9040410522);
+            }
+            if(empty($start_time)){
+                return responseToJson(-9040410622);
+            }
+            if(empty($end_time)){
+                return responseToJson(-9040410722);
+            }
+            if(empty($sealingplate)){
+                return responseToJson(-9040410822);
+            }
+            if(empty($sub_title)){
+                return responseToJson(-9040410922);
+            }
+            if(empty($game_name)){
+                return responseToJson(-9040411022);
+            }
+            if(empty($team_a_identity)||empty($team_b_identity)){
+                return responseToJson(-9040411122);
+            }
+            if($team_a_identity==$team_b_identity){
+                //选择了相同队伍
+                return responseToJson(-9040411222);
+            }
+            //检测期号是否重复
+            $check=\App\Models\Egame::checkNo($info_no);
+            if($check<0){
+                return responseToJson($check);
+            }
+            /***************************插入数据************************************/
+            DB::beginTransaction();
+            //egame
+            $data=array(
+                'info_no'=>$info_no,
+                'info_name'=>$info_name,
+                'start_time'=>$start_time,
+                'end_time'=>$end_time,
+                'sub_title'=>$sub_title,
+                'sealingplate'=>$sealingplate,
+                'game_name'=>$game_name,
+                'match_id'=>$match_id,
+            );
+            $res=\App\Models\Egame::addNew($data);
+            if($res<0){
+                DB::rollback();
+                return responseToJson($res);
+            }
+            //比赛队伍表
+            //获取队伍信息
+            $team_a_info=\App\Models\Egame_team::getInfoByID($team_a_identity);
+            $team_b_info=\App\Models\Egame_team::getInfoByID($team_b_identity);
+            $team_vs_data=array(
+                'team_a_code'=>'first',
+                'team_a_name'=>$team_a_info['team_name'],
+                'team_a_logo'=>$team_a_info['team_icon'],
+                'team_a_identity'=>$team_a_identity,
+                'team_b_code'=>'second',
+                'team_b_name'=>$team_b_info['team_name'],
+                'team_b_logo'=>$team_b_info['team_icon'],
+                'team_b_identity'=>$team_b_identity,
+                'info_no'=>$info_no,
+                'info_name'=>$info_name,
+                'video_url'=>$video_url
+            );
+            $res=\App\Models\Egame_info::addNewMatch($team_vs_data);
+            if($res<0){
+                DB::rollback();
+                return responseToJson($res);
+            }
+            DB::commit();
+            return responseToJson($res);
+        }
+    }
+
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 148 - 0
app/Http/Controllers/Admin/DatabaseCleanController.php


+ 21 - 0
app/Http/Controllers/Admin/DefaultController.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Request;
+
+/**
+ *
+ */
+class DefaultController extends Controller {
+	/**
+	 * @return 用户
+	 */
+	function index() {
+		return '404';
+	}
+	
+}
+
+?>

+ 297 - 0
app/Http/Controllers/Admin/DemoController.php

@@ -0,0 +1,297 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class DemoController extends Controller {
+
+	function index() {
+		# code...
+	}
+
+	/**
+	 * 试玩用户列表
+	 * [demos description]
+	 * @return [type] [description]
+	 */
+	function demos(Req $req) {
+		$request=array();
+		$request['account']=isset($req->account)?trim($req->account):null;
+		$request['register_ip'] = isset($req->register_ip) ? trim($req->register_ip) : null;
+		$request['last_ip'] = isset($req->last_ip) ? trim($req->last_ip) : null;
+		$request['register_url'] = isset($req->register_url) ? trim($req->register_url) : null;
+		$request['last_url'] = isset($req->last_url) ? trim($req->last_url) : null;
+		$request['statuss'] = isset($req->statuss) ? trim($req->statuss) : null;
+		$request['cash_small'] = isset($req->cash_small) ? trim($req->cash_small) : null;
+		$request['cash_big'] = isset($req->cash_big) ? trim($req->cash_big) : null;
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/demo/demo');
+		$dt->setLang('demo');
+		$dt->addColsFields('id', array('width' => 80));
+		$dt->addColsFields('account', array('templet' => '#userdetail', 'width' => 120));
+		$dt->addColsFields('register_time', array('width' => 180));
+		$dt->addColsFields('cash', array('templet' => '#moneyrecord', 'width' => 110));
+		$dt->addColsFields('register_log_ip', array('templet' => '#selectip', 'width' => 150, 'sort' => false));
+		$dt->addColsFields('register_log_url', array('templet' => '#selecturl', 'sort' => false));
+		$dt->addColsFields('statuss', array('width' => 100, 'sort' => false));
+		$dt->addColsFields('action_user', array('templet' => '#waterTool', 'sort' => false,'width' => 110));
+		$dt->setPriKey('id');
+		return view('admin.demo/demos', $dt->render($request));
+	}
+
+	/**
+	 * 注册ip列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function registipDetail() {
+		$register_ip = Request::has('register_ip') ? Request::get('register_ip') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/demo/demo?register_ip=' . $register_ip);
+		$dt->setLang('demo');
+		$dt->addColsFields('id');
+		$dt->addColsFields('account');
+		$dt->addColsFields('register_time');
+		$dt->addColsFields('cash');
+		$dt->addColsFields('register_log_ip', array('sort' => false));
+		$dt->addColsFields('register_log_url', array('sort' => false));
+		$dt->addColsFields('statuss', array('sort' => false));
+		$dt->setPriKey('id');
+		$dt->setToolBar(array('view'));
+		return view('admin.user/viewip', $dt->render());
+	}
+
+	/**
+	 * 最后登录ip列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function lastipDetail() {
+		$last_ip = Request::has('last_ip') ? Request::get('last_ip') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/demo/demo?last_ip=' . $last_ip);
+		$dt->setLang('demo');
+		$dt->addColsFields('id');
+		$dt->addColsFields('account');
+		$dt->addColsFields('register_time');
+		$dt->addColsFields('cash');
+		$dt->addColsFields('register_log_ip', array('sort' => false));
+		$dt->addColsFields('register_log_url', array('sort' => false));
+		$dt->addColsFields('statuss', array('sort' => false));
+		$dt->setToolBar(array('view'));
+		$dt->setPriKey('id');
+		return view('admin.user/viewip', $dt->render());
+	}
+
+	/**
+	 * 注册网址列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function registurlDetail() {
+		$register_url = Request::has('register_url') ? Request::get('register_url') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/demo/demo?register_url=' . $register_url);
+		$dt->setLang('demo');
+		$dt->addColsFields('id');
+		$dt->addColsFields('account');
+		$dt->addColsFields('register_time');
+		$dt->addColsFields('cash');
+		$dt->addColsFields('register_log_ip', array('sort' => false));
+		$dt->addColsFields('register_log_url', array('sort' => false));
+		$dt->addColsFields('statuss', array('sort' => false));
+		$dt->setPriKey('id');
+		$dt->setToolBar(array('view'));
+		return view('admin.user/viewip', $dt->render());
+	}
+
+	/**
+	 * 最后登录网址列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function lasturlDetail() {
+		$last_url = Request::has('last_url') ? Request::get('last_url') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/demo/demo?last_url=' . $last_url);
+		$dt->setLang('demo');
+		$dt->addColsFields('id');
+		$dt->addColsFields('account');
+		$dt->addColsFields('register_time');
+		$dt->addColsFields('cash');
+		$dt->addColsFields('register_log_ip', array('sort' => false));
+		$dt->addColsFields('register_log_url', array('sort' => false));
+		$dt->addColsFields('statuss', array('sort' => false));
+		$dt->setPriKey('id');
+		$dt->setToolBar(array('view'));
+		return view('admin.user/viewip', $dt->render());
+	}
+
+	/**
+	 * 试玩列表
+	 * 'demo description'
+	 * @return 'type' 'description'
+	 */
+	function demo() {
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$account = Request::has('account') ? Request::get('account') : '';
+		$register_ip = Request::has('register_ip') ? Request::get('register_ip') : '';
+		$last_ip = Request::has('last_ip') ? Request::get('last_ip') : '';
+		$regist_startime = Request::get('regist_startime') ? Request::get('regist_startime').' 00:00:00' : '';
+		$regist_endtime = Request::get('regist_endtime') ? Request::get('regist_endtime').' 23:59:59' : '';
+		$statuss = Request::has('statuss') ? Request::get('statuss') : '';
+		$cash_small = Request::has('cash_small') ? Request::get('cash_small') : '';
+		$cash_big = Request::has('cash_big') ? Request::get('cash_big') : '';
+		$sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+		$where = array();
+		if (!empty($account)) {
+			if (empty($sureblur) || $sureblur == '模糊') {
+				$where[] = array('account', 'like', '%' . $account . '%');
+			} else {
+				$where[] = array('account', '=', $account);
+			}
+		}
+		if (!empty($register_ip)) {
+			$where[] = array('register_ip', '=', $register_ip);
+		}
+		if (!empty($last_ip)) {
+			$where[] = array('last_ip', '=', $last_ip);
+		}
+		if (!empty($regist_startime)) {
+			$regist_startime = date('Y-m-d H:i:s', strtotime($regist_startime));
+			$where[] = array('register_time', '>=', $regist_startime);
+		}
+		if (!empty($regist_endtime)) {
+			$regist_endtime = date('Y-m-d H:i:s', strtotime($regist_endtime));
+			$where[] = array('register_time', '<=', $regist_endtime);
+		}
+		if (!empty($statuss)) {
+			$where[] = array('statuss', '=', $statuss);
+		}
+		if (!empty($cash_small)) {
+			$where[] = array('cash', '>=', $cash_small);
+		}
+		if (!empty($cash_big)) {
+			$where[] = array('cash', '<=', $cash_big);
+		}
+
+		$db = new \App\Models\Account;
+		$data = $db->demo_account($list, $page, $where);
+		if (!($data < 0)&&is_array($data)&&count($data)>0&&is_array($data['data'])&&count($data['data'])>0) {
+			$langinfo = trans('status.account_detailed.statuss');
+			foreach ($data['data'] as $k => $v) {
+				$data['data'][$k]['statuss'] = ($v['statuss']==0)?$langinfo[2]:$langinfo[$v['statuss']];
+				$data['data'][$k]['register_url'] = (empty($v['register_url'])) ? '' : $v['register_url'];
+				$data['data'][$k]['last_url'] = (empty($v['last_url'])) ? '' : $v['last_url'];
+				$data['data'][$k]['register_log_ip'] = $v['register_ip'] . '<br>' . $v['last_ip'];
+			}
+		}
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	/**
+	 * 批量删除
+	 * [delete description]
+	 * @return [type] [description]
+	 */
+	function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\Account::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1, trans('menu.delete_success')); //id����
+	}
+
+	function View(Req $req) {
+//	    $this->Edit($req);
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$u_db = new \App\Models\Account();
+		$u_details = new \App\Models\Account_detailed();
+		$bank = new \App\Models\Account_bank();
+		$data = $u_db::where('id', $id)->first();
+		if (!$data) {
+			abort(404);
+		}
+		$data = $data->toArray();
+		$data_details = $u_details->getInfoBy($data['identity']);
+		$data_details['account'] = $data['account'];
+		$data_details['remark'] = $data['remark'];
+		$bank_data = $bank->getInfoByUid($data['identity']);
+		$data_details['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+		$data_details['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+		$data_details['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+		unset($data_details['password']);
+		return view('admin.menu/userAdd', ['data' => $data_details, 'look' => '12']);
+	}
+	//修改会员信息
+	function Edit(Req $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$u_db = new \App\Models\Account();
+		$u_details = new \App\Models\Account_detailed();
+		$bank = new \App\Models\Account_bank();
+		if (!$req->isMethod('post')) {
+			$data = $u_db::where('id', $id)->first();
+			if (!$data) {
+				abort(404);
+			}
+			$data = $data->toArray();
+			$data_details = $u_details->getInfoBy($data['identity']);
+			$data_details['account'] = $data['account'];
+			$data_details['remark'] = $data['remark'];
+			$bank_data = $bank->getInfoByUid($data['identity']);
+			$data_details['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+			$data_details['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+			$data_details['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+			unset($data_details['password']);
+			return view('admin.menu/userAdd', ['data' => $data_details]);
+		} else {
+			$account = $u_db::where('id', $id)->first();
+			if (!$account) {
+				abort(404);
+			}
+			$account = $account->toArray();
+			$data = array(
+				'name' => $req->input('name'),
+				'email' => $req->input('email'),
+				'phone' => $req->input('phone'),
+				'grade' => $req->input('grade'),
+			);
+			$res = $u_details->updateInfo($data, $account['identity']);
+			return responseToJson(1);
+		}
+	}
+
+	function demoAdd() {
+		return view('admin.menu/demoAdd');
+	}
+
+}

+ 188 - 0
app/Http/Controllers/Admin/FeedbackController.php

@@ -0,0 +1,188 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class FeedbackController extends Controller {
+
+	function index() {
+		# code...
+	}
+
+	/**
+	 *用户反馈信息
+	 * [Colse description]
+	 */
+	function feedbacks(Req $req) {
+		$request=array();
+		$request['account']=isset($req->account)?trim($req->account):null;
+		$request['type'] = isset($req->type) ? trim($req->type) : null;
+		$request['content'] = isset($req->content) ? trim($req->content) : null;
+		$request['reply'] = isset($req->reply) ? trim($req->reply) : null;
+		$request['status'] = isset($req->status) ? trim($req->status) : null;
+		$request['startime'] = isset($req->startime) ? trim($req->startime) : null;
+		$request['endtime'] = isset($req->endtime) ? trim($req->endtime) : null;
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Feedback/feedback');
+		$dt->setLang('user');
+		$dt->addColsFields('account_name', array('templet' => '#userdetail', 'width' => 130, 'sort' => false));
+		$dt->addColsFields('type', array('width' => 110, 'sort' => false));
+		$dt->addColsFields('content', array('sort' => false));
+		$dt->addColsFields('submit_time', array('width' => 180));
+		$dt->addColsFields('status', array('width' => 110, 'sort' => false));
+		$dt->addColsFields('reply', array('sort' => false));
+		$dt->enableCheckBox();
+		if (checkRriv('/admin/Feedback/Edit')) {
+			$dt->setToolBar(array('edit'),array('width' => 100));
+		}
+		return view('admin.feedback/feedbacks', $dt->render($request));
+	}
+
+	/**
+	 * 用户反馈内容
+	 * 'feedback description'
+	 * @return 'type' 'description'
+	 */
+	function feedback() {
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : '';
+
+		$account = Request::has('account') ? Request::get('account') : '';
+		$type = Request::has('type') ? Request::get('type') : '';
+		$content = Request::has('content') ? Request::get('content') : '';
+		$reply = Request::has('reply') ? Request::get('reply') : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$startime = Request::get('startime') ? Request::get('startime').' 00:00:00' : '';
+		$endtime = Request::get('endtime') ? Request::get('endtime').' 23:59:59' : '';
+		$sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+		$where = array();
+		if (!empty($account)) {
+			if (empty($sureblur) || $sureblur == '模糊') {
+				$where[] = array('account_name', 'like', '%' . $account . '%');
+			} else {
+				$where[] = array('account_name', '=', $account);
+			}
+		}
+		if (!empty($type)) {
+			$where[] = array('type', '=', $type);
+		}
+		if (!empty($content)) {
+			$where[] = array('content', 'like', '%' . $content . '%');
+		}
+		if (!empty($reply)) {
+			$where[] = array('reply', 'like', '%' . $reply . '%');
+		}
+		if (!empty($status)) {
+			if ($status == 2) {
+				$where[] = array('status', '=', '0');
+			} else {
+				$where[] = array('status', '=', $status);
+			}
+		}
+		if (!empty($startime)) {
+			$startime = date('Y-m-d H:i:s', strtotime($startime));
+			$where[] = array('submit_time', '>=', $startime);
+		}
+		if (!empty($endtime)) {
+			$endtime = date('Y-m-d H:i:s', strtotime($endtime));
+			$where[] = array('submit_time', '<=', $endtime);
+		}
+
+		$db = new \App\Models\Feedback;
+		$data = $db->feedback($list, $page, $where);
+		if (!($data < 0)) {
+			$langinfo = trans('status.feedback.status');
+			foreach ($data['data'] as $k => $v) {
+				$data['data'][$k]['status'] = ($v['status'] == 0) ? $langinfo[2] : $langinfo[$v['status']];
+			}
+		}
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	//显示用户详情
+	function View(Req $req) {
+		$account = !empty($req->account) ? $req->account : '';
+		if (empty($account)) {
+			abort(404);
+		}
+		$u_db = new \App\Models\Account();
+		$u_details = new \App\Models\Account_detailed();
+		$bank = new \App\Models\Account_bank();
+		$data = $u_db::where('account', $account)->first();
+		if (!$data) {
+			abort(404);
+		}
+		$data = $data->toArray();
+		$data_details = $u_details->getInfoBy($data['identity']);
+		$data_details['account'] = $data['account'];
+		$bank_data = $bank->getInfoByUid($data['identity']);
+		$data_details['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+		$data_details['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+		$data_details['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+		$data_details['register_time'] = isset($data_details['register_time']) ? $data_details['register_time'] : '';
+		$data_details['register_ip'] = isset($data_details['register_ip']) ? $data_details['register_ip'] : '';
+		$data_details['last_ip'] = isset($data_details['last_ip']) ? $data_details['last_ip'] : '';
+		$data_details['cash'] = isset($data_details['cash']) ? $data_details['cash'] : '';
+		$data_details['email'] = isset($data_details['email']) ? $data_details['email'] : '';
+		$data_details['name'] = isset($data_details['name']) ? $data_details['name'] : '';
+		unset($data_details['password']);
+		return view('admin.feedback/view', ['data' => $data_details]);
+	}
+
+	//修改会员信息
+	function Edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			abort(404);
+		}
+		$db = new \App\Models\Feedback();
+		if (!$req->isMethod('post')) {
+			$data = $db->getCloseOne($id);
+			if (!$data) {
+				return responseToJson($data);
+			}
+			return view('admin.feedback/edit', ['data' => $data]);
+		} else {
+			$data['status'] = '1';
+			$data['reply'] = $req->input('reply');
+			$res = $db->updateOne($data, $id);
+			return responseToJson($res);
+		}
+	}
+
+	/**
+	 * 批量删除
+	 * [delete description]
+	 * @return [type] [description]
+	 */
+	function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\Feedback::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1, trans('menu.delete_success')); //id����
+	}
+
+}

+ 234 - 0
app/Http/Controllers/Admin/FundController.php

@@ -0,0 +1,234 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class FundController extends Controller {
+	/**
+	 * @return 财务管理
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['account_name']=isset($req->account_name)?trim($req->account_name):null;
+		$request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
+		$request['trade_type'] = isset($req->trade_type) ? trim($req->trade_type) : null;
+		$request['money_small'] = isset($req->money_small) ? trim($req->money_small) : null;
+		$request['money_big'] = isset($req->money_big) ? trim($req->money_big) : null;
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) : trans('status.default_time.atime');
+		$request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+        $request['status'] = isset($req->status) ? trim($req->status) : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/moneyList?account_name=' . $request['account_name'] );
+		$dt->setLang('money');
+		$dt->setPriKey('trade_id');
+		$dt->addColsFields('id', array('width' => 90));
+		$dt->addColsFields('account_name', array('sort' => false, 'templet' => '#usermoneyRecord', 'width' => 130));
+		$dt->addColsFields('money_time', array('templet' => '#orderid_time','width' => 240));
+		$dt->addColsFields('change_cash', array('templet' => '#money_aftercash','width' => 280));
+		//$dt->addColsFields('sysetem_user', array('templet' => '#sysetem_user','width' => 280));
+		$dt->addColsFields('systemuser_ordertype', array('templet' => '#systemuser_ordertype','sort' => false, 'width' => 170));
+		$dt->addColsFields('trade_desc', array('templet' => '#ordertype','sort' => false));
+
+		$dt->setToolBar(array('view'), array('width' => 100,'align' => 'left'));
+
+		return view('admin.Fund/index', $dt->render($request));
+	}
+	/**
+	 * 单用户存/取/反水列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function usermoneyRecord() {
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/moneyList?account_name=' . $account_name . '&sureblur=精确');
+		$dt->setLang('money');
+		$dt->setPriKey('trade_id');
+		$dt->addColsFields('id', array('width' => 100));
+		$dt->addColsFields('account_name', array('sort' => false, 'width' => 140));
+		$dt->addColsFields('money_time', array('width' => 220));
+		$dt->addColsFields('systemuser_ordertype', array('templet' => '#systemuser_ordertype','sort' => false, 'width' => 160));
+		$dt->addColsFields('money', array('width' => 120));
+		$dt->addColsFields('reason', array('sort' => false));
+		$dt->setToolBar(array('view'), array('width' => 100));
+		return view('admin.Fund/usermoneyRecord', $dt->render());
+	}
+
+	//查看存取反水
+	function View(Req $req) {
+		$order_id = $req->trade_id;
+		if (empty($order_id)) {
+			abort(404);
+		}
+		$money_db = new \App\Models\Money_details;
+		$bank_db = new \App\Models\Account_bank;
+		$data = $money_db->getOrderDetails($order_id, 3);
+		$bank_data = $bank_db->getInfoByUid($data['account_identity']);
+
+		$data['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+		$data['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+		$data['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+		$data['name'] = isset($bank_data['account_name']) ? $bank_data['account_name'] : '';
+		return view('admin.Fund/view', ['data' => $data]);
+	}
+	//获取按照类型统计
+	function getCount(Req $req) {
+		$startTime = $req->startTime;
+		$endTime = $req->endTime;
+		$type = $req->type;
+		$res = $this->getSumMoney($startTime, $endTime, $type);
+		return responseToJson($res);
+	}
+	//按照类型统计总金额
+	function getSumMoney($where, $type = '') {
+		$db = new \App\Models\Money_details;
+		$where[]=array('status','=',1);
+        return $db->totalTypeMoney($where);
+    }
+	//入款汇总
+	function getMoneySum($where, $type = '') {
+		$db = new \App\Models\Money_details;
+		$where = array();
+
+		if ($type) {
+			$where[] = array('trade_type', '=', $type);
+		} else {
+			//获取总存取反水金额
+			return $db->getIntoTotal($where);
+		}
+		//规定的类型总数
+		return $db->sumIntoMoney($where);
+	}
+	function getActive($where, $type) {
+		$db = new \App\Models\Money_details;
+		return $db->getActiveMoney($where, $type);
+	}
+	//统计总数
+	function allTotal(Req $req) {
+		$where = $req->where;
+		if (count($where) == 0) {
+            $where=array();
+		}
+		$data_odc=$this->getSumMoney($where);
+        $data = array();
+        //赋初值
+        $data['totalMoney']=0;
+        $data['onlineRecharge']=0;
+        $data['backstageRecharge']=0;
+        $data['remit']=0;
+        $data['rechargePrize']=0;
+        $data['active_add_money']=0;
+        $data['active_cut_money']=0;
+        $data['active_money']=0;
+        $data['back_water']=0;
+        $data['return_water']=0;
+        $data['take_money']=0;
+        $data['cut_money']=0;
+        $data['commission_addmoney']=0;
+        $data['nagentin'] = 0;	//代理代充充值
+        $data['nagentout'] = 0;	//代理代充
+		foreach ($data_odc as $k=>$v){
+		    if($v['trade_type']==6){
+                $data['onlineRecharge']=round($v['money'],2);
+            }
+            if($v['trade_type']==11){
+                $data['backstageRecharge']=round($v['money'],2);//后台充值
+            }
+            if($v['trade_type']==14){
+                $data['remit']=round($v['money'],2);
+            }
+            if($v['trade_type']==13){
+                $data['rechargePrize']=round($v['money'],2);
+            }
+            if($v['trade_type']==12&&$v['money_type']==1){
+                $data['active_add_money']=round($v['money'],2);
+                $data['active_money']+= $data['active_add_money'];
+            }
+            if($v['trade_type']==12&&$v['money_type']==2){
+                $data['active_cut_money']=round($v['money'],2);
+                $data['active_money']+=$data['active_cut_money'];
+            }
+            if($v['trade_type']==7){
+                $data['back_water']=round($v['money'],2);
+            }
+            if($v['trade_type']==8){
+                $data['return_water']=round($v['money'],2);
+            }
+            if($v['trade_type']==5){
+                $data['take_money'] =round($v['money'],2); //5前台提现
+            }
+            if($v['trade_type']==9){
+                $data['cut_money'] = round($v['money'],2); //管理员扣款
+            }
+            if($v['trade_type']==16&&$v['money_type']==1){
+                $data['reward_addmoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==16&&$v['money_type']==2){
+                $data['reward_reducemoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==19&&$v['money_type']==1){
+                $data['conversion_addmoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==19&&$v['money_type']==2){
+                $data['conversion_reducemoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==10&&$v['money_type']==1){
+                $data['commission_addmoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==22&&$v['money_type']==1){
+                $data['nagentin']=round($v['money'],2);
+            }
+            if($v['trade_type']==22&&$v['money_type']==2){
+                $data['nagentout']=round($v['money'],2);
+            }
+            $data['totalMoney']+=$v['money'];
+        }
+        if(empty($data['reward_addmoney'])){
+        	$data['reward_addmoney'] =0;
+        }
+        if(empty($data['reward_reducemoney'])){
+        	$data['reward_reducemoney'] =0;
+        }
+        if(empty($data['conversion_addmoney'])){
+        	$data['conversion_addmoney'] =0;
+        }
+        if(empty($data['conversion_reducemoney'])){
+        	$data['conversion_reducemoney'] =0;
+        }
+//		$data['totalMoney'] = $this->getSumMoney($where);
+//		$data['onlineRecharge'] = $this->getSumMoney($where, 6); //在线充值
+//		$data['backstageRecharge'] = $this->getSumMoney($where, 11); //后台充值
+//		$data['remit'] = $this->getSumMoney($where, 14); //14汇款
+//		$data['rechargePrize'] = $this->getSumMoney($where, 13); //13充值赠送
+		//活动金额
+//		$data['active_cut_money'] = $this->getActive($where, 2); //活动扣除
+//        $data['active_cut_money']=round($data['active_cut_money'],2);
+//        $data['totalMoney']+=$data['active_cut_money'];
+//		$data['active_add_money'] = $this->getActive($where, 1); //活动加款
+//        $data['active_add_money']=round($data['active_add_money'],2);
+//		$data['active_money'] = $this->getSumMoney($where, 12); //总活动
+
+//		$data['back_water'] = $this->getSumMoney($where, 7); //反水
+//		$data['return_water'] = $this->getSumMoney($where, 8); //回水
+//		$data['take_money'] = $this->getSumMoney($where, 5); //5前台提现
+//		$data['cut_money'] = $this->getSumMoney($where, 9); //管理员扣款
+		$data['intoTotalMoney'] = $data['onlineRecharge'] + $data['backstageRecharge'] + $data['remit'] + $data['nagentin']; //总入款扣除活动充值赠送
+		$data['cut_total_money'] = $data['cut_money'] + $data['take_money'] + $data['nagentout']; //扣款总额扣除活动充值赠送
+		$data['profit'] = $data['intoTotalMoney'] - $data['cut_total_money'];
+		$data['all_save_money'] = $data['intoTotalMoney'] + $data['active_add_money'] + $data['rechargePrize'] + $data['back_water'] + $data['return_water']; //总存款
+		$data['all_take_money'] = $data['take_money'] + $data['cut_money'] + $data['active_cut_money'] + $data['nagentout']; //总扣款
+//        $type= ['totalMoney', 'onlineRecharge', 'backstageRecharge','remit','rechargePrize','active_cut_money','active_add_money','active_money','back_water',
+//        'return_water','take_money','cut_money','intoTotalMoney','cut_total_money','profit','all_save_money','all_take_money'];
+//        $arr = arrayToNum($data,$type);
+		return responseToJson($data);
+	}
+
+}
+
+?>

+ 150 - 0
app/Http/Controllers/Admin/FundlogController.php

@@ -0,0 +1,150 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class FundlogController extends Controller {
+	/**
+	 * @return 财务日志
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['startime']=isset($req->startime)?trim($req->startime):trans('status.default_time.seven_day');
+		$request['endtime'] = isset($req->endtime) ? trim($req->endtime) : trans('status.default_time.etime');
+		$request['account_name'] = isset($req->account_name) ? trim($req->account_name) : null;
+		$request['loss_name'] = isset($req->loss_name) ? trim($req->loss_name) : null;
+		$request['agent_name'] = isset($req->agent_name) ? trim($req->agent_name) : null;
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/fundLog');
+		$dt->setLang('money');
+		$dt->setPriKey('account_identity');
+		$dt->addColsFields('account_name', array('sort' => false, 'templet' => '#username'));
+		$dt->addColsFields('sendmoney');
+		$dt->addColsFields('savemoney');
+		$dt->addColsFields('getmoney');
+		$dt->addColsFields('winmoney', array('templet' => '#usergetmoney'));
+		$dt->addColsFields('adminadd');
+		$dt->addColsFields('adminpull');
+		$dt->addColsFields('recharge_send');
+		$dt->addColsFields('back_return');
+
+		return view('admin.Fundlog/index', $dt->render($request));
+	}
+
+	/**
+	 * 单用户存/取/反水列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function usermoneyRecord() {
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/moneyList?account_name=' . $account_name . '&sureblur=精确');
+		$dt->setLang('money');
+		$dt->setPriKey('trade_id');
+		$dt->addColsFields('id', array('width' => 100));
+		$dt->addColsFields('account_name', array('width' => 140));
+		$dt->addColsFields('money_time', array('width' => 200));
+		$dt->addColsFields('systemuser_ordertype', array('sort' => false, 'width' => 160));
+		$dt->addColsFields('money', array('width' => 120));
+		$dt->addColsFields('reason', array('sort' => false));
+		$dt->setToolBar(array('view'), array('width' => 80));
+		return view('admin.view', $dt->render());
+	}
+
+	//查看存取反水
+	function View(Req $req) {
+		$order_id = $req->trade_id;
+		if (empty($order_id)) {
+			abort(404);
+		}
+		$money_db = new \App\Models\Money_details;
+		$bank_db = new \App\Models\Account_bank;
+		$data = $money_db->getOrderDetails($order_id, 3);
+		$bank_data = $bank_db->getInfoByUid($data['account_identity']);
+
+		$data['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+		$data['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+		$data['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+		$data['name'] = isset($bank_data['account_name']) ? $bank_data['account_name'] : '';
+		return view('admin.MoneyManage/moneyView', ['data' => $data]);
+	}
+	//获取按照类型统计
+	function getCount(Req $req) {
+		$startTime = $req->startTime;
+		$endTime = $req->endTime;
+		$type = $req->type;
+		$res = $this->getSumMoney($startTime, $endTime, $type);
+		return responseToJson($res);
+	}
+	//按照类型统计总金额
+	function getSumMoney($where, $type = '') {
+		$db = new \App\Models\Money_details;
+		if ($type) {
+			$where[] = array('trade_type', '=', $type);
+		} else {
+			//获取总存取反水金额
+			return $db->getTotal($where);
+		}
+		//规定的类型总数
+		return $db->sumMoney($where);
+	}
+	//入款汇总
+	function getMoneySum($where, $type = '') {
+		$db = new \App\Models\Money_details;
+		$where = array();
+		if ($type) {
+			$where[] = array('trade_type', '=', $type);
+		} else {
+			//获取总存取反水金额
+			return $db->getIntoTotal($where);
+		}
+		//规定的类型总数
+		return $db->sumIntoMoney($where);
+	}
+	function getActive($where, $type) {
+		$db = new \App\Models\Money_details;
+		return $db->getActiveMoney($where, $type);
+	}
+	//统计总数
+	function allTotal(Req $req) {
+		$startTime = date('Y-m-d 00:00:00');
+		$endTime = date('Y-m-d 23:59:59');
+		$data = array();
+		$where = $req->where;
+		if (count($where) == 0) {
+			$where[] = array('money_time', '>=', $startTime);
+			$where[] = array('money_time', '<=', $endTime);
+		}
+		$data['totalMoney'] = $this->getSumMoney($where);
+		$data['onlineRecharge'] = $this->getSumMoney($where, 6); //在线充值
+		$data['backstageRecharge'] = $this->getSumMoney($where, 11); //后台充值
+		$data['remit'] = $this->getSumMoney($where, 14); //14汇款
+		$data['rechargePrize'] = $this->getSumMoney($where, 13); //13充值赠送
+		//活动金额
+		$data['active_cut_money'] = $this->getActive($where, 2); //活动扣除
+		$data['active_add_money'] = $this->getActive($where, 1); //活动加款
+		$data['active_money'] = $this->getSumMoney($where, 12); //总活动
+
+		$data['back_water'] = $this->getSumMoney($where, 7); //反水
+		$data['return_water'] = $this->getSumMoney($where, 8); //回水
+		$data['take_money'] = $this->getSumMoney($where, 5); //5前台提现
+		$data['cut_money'] = $this->getSumMoney($where, 9); //管理员扣款
+		$data['intoTotalMoney'] = $data['onlineRecharge'] + $data['backstageRecharge'] + $data['remit']; //总入款扣除活动充值赠送
+		$data['cut_total_money'] = $data['cut_money'] + $data['take_money']; //扣款总额扣除活动充值赠送
+		$data['profit'] = $data['intoTotalMoney'] - $data['cut_total_money'];
+		$data['all_save_money'] = $data['intoTotalMoney'] + $data['active_add_money'] + $data['rechargePrize'] + $data['back_water'] + $data['return_water']; //总存款
+		$data['all_take_money'] = $data['take_money'] + $data['cut_money'] + $data['active_cut_money']; //总扣款
+		return responseToJson($data);
+	}
+
+}
+
+?>

+ 147 - 0
app/Http/Controllers/Admin/GjmatchController.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Models;
+use Request;
+
+/**
+ * 冠军赛事
+ */
+class GjmatchController extends Controller {
+
+	//
+	public function index(Req $req){
+		$request=array();
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['source'] = isset($req->source) ? $req->source : null;
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/gjmatch/info');
+        $dt->setLang('gjmatch');
+        $dt->addColsFields('id', array('templet' => '#home_team', 'sort' => false, 'width' => 60));
+        $dt->addColsFields('name_chinese', array('templet' => '#guest_team', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('game_name', array('templet' => '#home_rate', 'sort' => false, 'width' => 130));
+        $dt->addColsFields('ctime', array('templet' => '#home_rate', 'sort' => false, 'width' => 180));
+        $dt->addColsFields('utime', array('templet' => '#home_rate', 'sort' => false, 'width' => 180));
+        $dt->addColsFields('status', array('templet' => '#status', 'sort' => false, 'width' => 80));
+
+        if (checkRriv('/admin/gjmatch/edit')) {
+			$arr[] = 'edit';
+		}
+		$dt->setToolBar($arr, array('width' => 200));
+        $dt->enableCheckBox();
+
+		return view('admin/gjmatch/index',$dt->render($request));
+	}
+
+	//添加
+	public function add(Req $req) {
+		if (!$req->isMethod('post')) {
+            $lange = trans('menu');
+			$newapp = new \App\Models\SoccerLeague();
+			$league_data = $newapp->allleague();//联赛id
+
+            return view('admin.gjmatch/add',['data'=>$league_data]);
+        } else {
+            $model = new \App\Models\Stzqleagueresult();
+			$model->lg_id = trim($req->input('lg_id'));//联赛id
+			$model->game_name = trim($req->input('game_name'));
+			$model->result = json_encode(explode(',', trim($req->input('result'))),JSON_UNESCAPED_UNICODE);
+			$model->ctime = date("Y-m-d H:i:s");//创建时间
+			$model->status = trim($req->input('status'));
+			$model->save();
+			return responseToJson(1);
+        }
+	}
+
+	//编辑
+	public function edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\Stzqleagueresult::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+
+			$newapp = new \App\Models\SoccerLeague();
+			$league_data = $newapp->allleague();//所有联赛
+
+			//已选择的联赛相信
+			$only = $newapp->onlyleague($data['lg_id']);
+
+			return view('admin.gjmatch/edit', ['data'=>$data,'ldata'=>$league_data,'only'=>$only]);
+		} else {
+			$model = \App\Models\Stzqleagueresult::where('id', $id)->first();
+			$model->game_name = $req->input('game_name');
+			$model->utime = date("Y-m-d H:i:s");//更新时间
+			$model->lg_id = $req->input('lg_id');//赛事id
+			$model->status = $req->input('status');
+
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+	public function info(){
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblurs = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$status = Request::has('status') ? Request::get('status') : '';
+        $where = array();
+        if (!empty($home_team)) {
+			if (empty($sureblurs) || $sureblurs == 'off') {
+				$where[] = array('st_zq_league_result.game_name', 'like', '%' . $home_team . '%');
+			} else {
+				$where[] = array('st_zq_league_result.game_name', '=', $home_team);
+			}
+		}
+        if ($status != -1) {
+			$where[] = array('st_zq_league_result.status', '=', $status);
+		}
+		if (!empty($source)) {
+			$where[] = array('st_zq_league_result.source', '=', $source);
+		}
+		$newapp = new \App\Models\Stzqleagueresult();
+        $data = $newapp->resultlist($list, $page, $where);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	//删除
+	public function dele(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		// echo '敬请期待';die;
+		$rows = \App\Models\Stzqleagueresult::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); 
+		}
+		return responseToJson(1);
+	}
+
+}

+ 197 - 0
app/Http/Controllers/Admin/GradeController.php

@@ -0,0 +1,197 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Controller;
+
+
+class GradeController extends Controller
+{
+   //添加
+   function add(Request $req){
+        if(!$req->isMethod('post')){
+            return view('admin.Usergrade/add');
+        }else{           
+            $model=new \App\Models\User_grade();
+            $time=time();
+            $model->time=date('Y-m-d H:i:s', $time);
+            $model->name=trim($req->input('name'));
+            $model->grade=trim($req->input('grade'));
+            $model->rule=trim($req->input('rule'));
+            $time_type = trim($req->input('time_type'));
+            $rechargemoney = trim($req->input('rechargemoney'));
+            $bettingmoney = trim($req->input('bettingmoney'));
+            $day = trim($req->input('day'));
+            if($time_type =='day' || $time_type =='ymd'){
+                $model->rule_details=$time_type.','.$rechargemoney.','.$bettingmoney.','.$day;
+            }else{
+                $model->rule_details=$time_type.','.$rechargemoney.','.$bettingmoney;
+            }
+            $model->save();
+            $log = array(
+                session('adminInfo.admin_name'),
+                $req->input('name'),
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'add_grade', $log);
+            return responseToJson($res);
+        }        
+    }
+	//查看
+    function view(Request $req){
+       return $this->edit($req);
+    }
+    //修改
+    function edit(Request $req){
+        $id=$req->id;
+        if(intval($id)<1){
+            return responseToJson(-6000001);
+        }
+        if(!$req->isMethod('post')){
+           
+            $data=\App\Models\User_grade::where('id',$id)->first();
+            if(!$data){
+               return responseToJson(-6000002);
+            }
+            $data=$data->toArray();
+            $data['rule_details'] =explode(',',$data['rule_details']);
+            return view('admin.Usergrade/add',array('admin'=>$data));
+        }else{
+            $model=\App\Models\User_grade::where('id',$id)->first();
+            $model->name=trim($req->input('name'));
+			$model->grade=trim($req->input('grade'));
+            $model->rule=trim($req->input('rule'));
+            $time_type = trim($req->input('time_type'));
+            $rechargemoney = trim($req->input('rechargemoney'));
+            $bettingmoney = trim($req->input('bettingmoney'));
+            $day = trim($req->input('day'));
+            if($time_type =='day' || $time_type =='ymd'){
+                $model->rule_details=$time_type.','.$rechargemoney.','.$bettingmoney.','.$day;
+            }else{
+                $model->rule_details=$time_type.','.$rechargemoney.','.$bettingmoney;
+            }
+            $model->save();
+            $log = array(
+                session('adminInfo.admin_name'),
+                $req->input('name'),
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'edit_grade', $log);
+            return responseToJson($res);
+        }
+    }
+    //删除
+    public function delete(Request $req){
+        $id=$req->id;
+        if(empty($id)){
+            return responseToJson(-2001);//id不能为空
+        }
+        $ids=explode(',',$id);
+        if(!is_array($ids) && intval($ids)<0){
+            return responseToJson(-2002);//id错误
+        }
+        if(is_array($ids) && count($ids)>0)
+        {
+            foreach($ids as $k=>$v){
+                if(intval($v)<1){
+                    unset($ids[$k]);
+                }
+            }
+        }
+        //获取待删除等级信息
+        $gradeInfo = \App\Models\User_grade::whereIn('id',$ids)->get();
+        if(empty($gradeInfo)){
+            return responseToJson(-2002);//id错误
+        }
+        $gradeInfo = $gradeInfo->toArray();
+        $grades = array();
+        foreach ($gradeInfo as $key => $value) {
+            if($value['grade'] == 0){
+                return responseToJson(-2000100102);//id错误
+            }
+            $grades[] = $value['grade'];
+        }
+
+        $rows=\App\Models\User_grade::whereIn('id',$ids)->delete();
+        if(!$rows){
+             return responseToJson(-2003);//id错误
+        }
+        $updateGrade = \App\Models\Account_detailed::whereIn('grade',$grades)->update(['grade'=>'0']);
+        $log = array(
+            session('adminInfo.admin_name')
+        );
+        $res = OperationLog(session('adminInfo.admin_id'), 'del_grade', $log);
+        return responseToJson(1);
+
+    }
+
+
+    public function index(){
+       $dt=\App\Lib\DataTable\DataTable::init();
+       $dt->setLang('grade');
+       $dt->enableCheckBox();
+	   $dt->addColsFields('id');
+	   $dt->addColsFields('name');
+       $dt->addColsFields('grade');
+       //$dt->addColsFields('is_water');
+       $dt->addColsFields('time');
+       $dt->setToolBar(array('edit'));
+       return  view('admin.Usergrade/index',$dt->render());
+    }
+
+    public function dataSource(Request $req){
+        $name = isset($req->name) ? trim($req->name) : null;
+        $limit = isset($req->limit) ? trim($req->limit) : null;
+        $page = isset($req->page) ? trim($req->page) : null;
+        $grade = isset($req->grade) ? trim($req->grade) : null;
+        //$is_water = isset($req->is_water) ? trim($req->is_water) : null;
+        $regist_endtime = isset($req->create_at_start) ? trim($req->create_at_start) : null;
+        $regist_startime = isset($req->create_at_end) ? trim($req->create_at_end) : null;
+
+
+//        var_dump($name);
+
+        $model = \App\Models\User_grade::offset(($page - 1) * $limit)
+            ->limit($limit);
+        
+        if (!empty($name)) {
+            $model = $model->where('name', 'like', '%' . $name . '%');
+        }
+        /*if (!empty($is_water)) {
+            $model = $model->where('is_water', '=', $is_water);
+        }*/
+        if (!empty($grade)) {
+            if ($grade == -1) {
+                $model = $model->where('grade', '=', '0');
+            } else {
+                $model = $model->where('grade', '=', $grade);
+            }
+        }
+        if (!empty($regist_endtime)) {
+            $regist_endtime = date('Y-m-d H:i:s', strtotime($regist_endtime));
+            $model =$model->where('time', '<=', $regist_endtime);
+        }
+        if (!empty($regist_startime)) {
+            $regist_startime = date('Y-m-d H:i:s', strtotime($regist_startime));
+            $model =$model->where('time', '>=', $regist_startime);
+        }
+        $model=$model->orderBy('id', 'desc');
+        $data = $model->get();
+        if (!$data) {
+            return;
+        }
+        $data = $data->toArray();
+        if (!($data < 0)) {
+            $langinfo = trans('grade.manager');
+            foreach ($data as $k => $v) {
+                $data[$k]['is_water'] = $langinfo[$v['is_water']];
+            }
+        }
+
+
+        $count = \App\Models\User_grade::count();
+        return \App\Lib\DataTable\DataTable::init()->toJson($data, $count);
+
+    }
+}
+
+

+ 497 - 0
app/Http/Controllers/Admin/IndexController.php

@@ -0,0 +1,497 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\DB;
+
+/**
+ *
+ */
+class IndexController extends Controller {
+
+    function welcome() {
+        $total = array(
+            'total_user' => $this->countTodayUser(),
+            'total_bet' => $this->countBet(),
+            'today_take' => $this->countTodayTake(),
+            'today_recharge' => $this->countTodayRecharge(),
+            'today_return' => $this->countTodayReturn(),
+            'today_rimit' => $this->countTodayRimt(),
+        );
+        if (\App\Models\Role::hasRoot('/enable/show/get_money_count') < 0) {
+            $get_money_count = "*****";
+        } else {
+            $get_money_count = $total['today_recharge']['count'];
+        }
+        $notice = $this->getNotice();
+        $message = $this->Message();
+        return view('admin/welcome', ['total' => $total, 'notice' => $notice, 'message' => $message, 'get_money_count' => $get_money_count]);
+    }
+
+    //返回用户数量
+    function countUser() {
+        return \App\Models\Account_detailed::count();
+    }
+
+    //今日注册用户数量
+    function countTodayUser() {
+        $time1 = date('Y-m-d 00:00:00'); //今日0时
+        $time2 = date('Y-m-d 23:59:59'); //
+        $timearea = [$time1, $time2];
+        if (\App\Models\Role::hasRoot('/enable/show/today_user') < 0) {
+            $user_data['today_user'] = "*****";
+        } else {
+            $user_data['today_user'] = \App\Models\Account_detailed::whereBetween('register_time', $timearea)->join('account', 'account_detailed.account_identity', '=', 'account.identity')->where('status', '1')->count();
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/last_online') < 0) {
+            $user_data['last_online'] = "*****";
+        } else {
+            $user_data['last_online'] = \App\Models\Account_Token::whereBetween('last_time', $timearea)->count();
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/user_count') < 0) {
+            $user_data['user_count'] = "*****";
+        } else {
+            $user_data['user_count'] = \App\Models\Account_detailed::count();
+        }
+        return $user_data;
+    }
+
+    //注单总数量
+    function countBet() {
+        $time1 = date('Y-m-d 00:00:00'); //今日0时
+        $time2 = date('Y-m-d 23:59:59'); //
+        $timearea = [$time1, $time2];
+        if (\App\Models\Role::hasRoot('/enable/show/bet_count') < 0) {
+            $bet_count['count'] = "*****";
+        } else {
+            $bet_count['count'] = \App\Models\MoneyBuy::where('money_buy.status', '<>', 4)->join('account', 'money_buy.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type','1')->whereBetween('money_time', $timearea)->count();
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/bet_money') < 0) {
+            $bet_money = \App\Models\MoneyBuy::where('money_buy.status', '<>', 4)->join('account', 'money_buy.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type','1')->whereBetween('money_time', $timearea)->sum('money');
+            $bet_count['money_count'] = "*****";
+        } else {
+            $bet_money = \App\Models\MoneyBuy::where('money_buy.status', '<>', 4)->join('account', 'money_buy.account_identity', '=', 'account.identity')->where('account.status', '<>', '4')->where('account.user_type','1')->whereBetween('money_time', $timearea)->sum('money');
+            $bet_count['money_count'] = round($bet_money, 2);
+        }
+        // DB::connection()->enableQueryLog();
+        if (\App\Models\Role::hasRoot('/enable/show/countBet') < 0) {
+            $db = new \App\Models\MoneyBuy;
+            $bet_count['user_count'] = "*****";
+        } else {
+            $db = new \App\Models\MoneyBuy;
+            $bet_count['user_count'] = $db->countUser($timearea);
+        }
+        // $queries = DB::getQueryLog();
+        // print_r($queries);
+        return $bet_count;
+    }
+
+    //今日提现
+    function countTodayTake() {
+        $time1 = date('Y-m-d 00:00:00'); //今日0时
+        $time2 = date('Y-m-d 23:59:59'); //
+        $timearea = [$time1, $time2];
+
+        if (\App\Models\Role::hasRoot('/enable/show/count') < 0) {
+            $take_count['count'] = "*****";
+        } else {
+            $take_count['count'] = \App\Models\Money_take::whereBetween('apply_time', $timearea)->where('status', 1)->count();
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/money_count') < 0) {
+            $take_count['money_count'] = "*****";
+        } else {
+            $take_count['money_count'] = \App\Models\Money_take::whereBetween('apply_time', $timearea)->where('status', 1)->sum('money');
+        }
+//        DB::connection()->enableQueryLog();
+        if (\App\Models\Role::hasRoot('/enable/show/user_count') < 0) {
+            $db = new \App\Models\Money_take;
+            $take_count['user_count'] = "*****";
+        } else {
+            $db = new \App\Models\Money_take;
+            $take_count['user_count'] = $db->countUser($timearea);
+        }
+//        $queries = DB::getQueryLog();
+//        dump($queries);
+//        dump($take_count);
+        return $take_count;
+    }
+
+    //今日充值笔数
+    function countTodayRecharge() {
+        $time1 = date('Y-m-d 00:00:00'); //今日0时
+        $time2 = date('Y-m-d 23:59:59'); //
+        $timearea = [$time1, $time2];
+//        DB::connection()->enableQueryLog();
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge') < 0) {
+            $rech_data['count'] = "*****";
+        } else {
+            $rech_data['count'] = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->count();
+        }
+//        $queries = DB::getQueryLog();
+//        print_r($queries);
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge_money') < 0) {
+            $money_count = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->sum('money');
+            $rech_data['money_count'] = "*****";
+        } else {
+            $money_count = \App\Models\Money_details::whereBetween('money_time', $timearea)->whereIn('trade_type', array(6, 11))->where('status', 1)->sum('money');
+            $rech_data['money_count'] = round($money_count, 2);
+        }
+//        DB::connection()->enableQueryLog();
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayRecharge_user') < 0) {
+            $db = new \App\Models\Money_details;
+            $count = $db->countUser($timearea, array(6, 11));
+            $rech_data['user_count'] = "*****";
+        } else {
+            $db = new \App\Models\Money_details;
+            $count = $db->countUser($timearea, array(6, 11));
+            $rech_data['user_count'] = $count;
+        }
+//        $queries = DB::getQueryLog();
+//        dump($queries);
+        return $rech_data;
+    }
+
+    //	今日回水笔数
+    function countTodayReturn() {
+        $time1 = date('Y-m-d 00:00:00'); //今日0时
+        $time2 = date('Y-m-d 23:59:59'); //
+        $timearea = [$time1, $time2];
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn') < 0) {
+            $return['count'] = "*****";
+        } else {
+            $return['count'] = \App\Models\Money_return::whereBetween('processing_time', $timearea)->count();
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn_money') < 0) {
+            $return['money_count'] = "*****";
+        } else {
+            $return['money_count'] = \App\Models\Money_return::whereBetween('processing_time', $timearea)->sum('money');
+        }
+//		$return['user_count'] = \App\Model\Money_return::whereBetween('processing_time', $timearea)->groupBy('account_identity')->count();
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayReturn_user') < 0) {
+            $db = new \App\Models\Money_return;
+            $return['user_count'] = "*****";
+        } else {
+            $db = new \App\Models\Money_return;
+            $return['user_count'] = $db->countUser($timearea);
+        }
+        return $return;
+    }
+
+    //	今日反水笔数
+    function countTodayBack() {
+        $time1 = date('Y-m-d 00:00:00'); //今日0时
+        $time2 = date('Y-m-d 23:59:59'); //
+        $timearea = [$time1, $time2];
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayBack') < 0) {
+            $return['count'] = "*****";
+        } else {
+            $return['count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->count();
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayBack_money') < 0) {
+            $return['money_count'] = "*****";
+        } else {
+            $return['money_count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->sum('money');
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayBack_user') < 0) {
+            $return['user_count'] = "*****";
+        } else {
+            $return['user_count'] = \App\Models\Money_back::whereBetween('processing_time', $timearea)->groupBy('account_identity')->count();
+        }
+        return $return;
+    }
+
+    //今日汇款
+    function countTodayRimt() {
+        $time1 = date('Y-m-d 00:00:00'); //今日0时
+        $time2 = date('Y-m-d 23:59:59'); //
+        $timearea = [$time1, $time2];
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt') < 0) {
+            $rimit['count'] = "*****";
+        } else {
+            $rimit['count'] = \App\Models\Money_recharge::whereBetween('apply_time', $timearea)->where('recharge_type', '汇款')->where('status', 1)->count();
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt_money') < 0) {
+            $rimit['money_count'] = "*****";
+        } else {
+            $rimit['money_count'] = \App\Models\Money_recharge::whereBetween('apply_time', $timearea)->where('recharge_type', '汇款')->where('status', 1)->sum('money');
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/countTodayRimt_user') < 0) {
+            $db = new \App\Models\Money_recharge;
+            $rimit['user_count'] = "*****";
+        } else {
+            $db = new \App\Models\Money_recharge;
+            $rimit['user_count'] = $db->countRimitUser($timearea);
+        }
+        return $rimit;
+    }
+
+    //公告信息
+    function getNotice() {
+        $db = new \App\Models\Article();
+        $data = $db->getMsg(2, 2);
+        return $data;
+    }
+
+    //当前在线用户饼状图
+    function onlineUser() {
+//		$db = new \App\Model\Logfile;
+//		$db=new \App\Model\Account_Token;
+        $db = new \App\Models\Account_detailed;
+        $data_log = $db->getOnlineUser();
+//		$data_log = $db->getUser();
+
+        $array['data'] = $data_log;
+        if (empty($data_log)) {
+            $array['data'][0]['name'] = '没有';
+            $array['data'][0]['value'] = 0;
+        }
+
+        //组装标
+        $count = 0;
+        foreach ($array['data'] as $k => $v) {
+            $array['title'][$k] = trim($v['name']);
+            $array['data'][$k]['name'] = trim($v['name']);
+            $count += $v['value'];
+        }
+        //总在线数量、
+        $array['text'] = date('Y-m-d') . trans('common.today_user_num') . $count;
+        return responseToJson($array);
+//        dump($array);
+
+    }
+
+    //今日投注统计饼状图
+    function getBetUrl() {
+        $db = new \App\Models\OrderUrl;
+        $data = $db->getUrlBet();
+        $array['data'] = $data;
+        if (empty($data)) {
+            $array['data'][0]['name'] = '没有';
+            $array['data'][0]['value'] = 0;
+        }
+        //组装标
+        foreach ($array['data'] as $k => $v) {
+            $array['title'][$k] = $v['name'];
+        }
+        //添加标题
+        //总投注数量
+        $count = $db->gettotal();
+        $array['text'] = date('Y-m-d') . trans('common.today_bet_num') . $count;
+//        dump($array);
+        return responseToJson($array);
+    }
+
+    //时间区
+    function getTime() {
+        $time = array(
+            'addrss' => date_default_timezone_get(),
+            'time' => date("Y-m-d H:i:s", time() + 3600 * 8),
+        );
+        // print_r($time['time']);die;
+        return responseToJson($time);
+    }
+
+    //最近7天会员注册情况
+    function regUser() {
+        $time2 = date('Y-m-d H:i:s', time() - 60 * 60 * 24 * 30);
+        $time1 = date('Y-m-d H:i:s', time());
+        $timearea = [$time2, $time1];
+        // $rech_data['money_with'] = DB::table('account_detailed')->join('account', 'account.identity', '=', 'money_details.account_identity')->select(DB::Raw('sum(money) as with'))->whereBetween('money_time', $timearea)->groupBy('account')->where('trade_type', 5)->get();
+        $rimit = \App\Models\Account_list::where('account_status', 1)
+            ->select(DB::Raw('date(register_time) as name, count(identity) as value'))
+            ->whereBetween('register_time', $timearea)->orderBy(DB::Raw('date(register_time)'))->groupBy(DB::Raw('date(register_time)'))->get();
+        $data = $rimit->toArray();
+        foreach ($data as $k => $v) {
+            $array['title'][$k] = $v['name'];
+            $array['data']['num'][$k] = $v['value'];
+        }
+        $array['legend'][] = '最近注册用户记录';
+        return responseToJson($array);
+    }
+
+    //最近7天财务情况
+    function money() {
+        $res_array = array();
+
+        for ($i = 6; $i >= 0; $i--) {
+            $secondes = $i * 24 * 60 * 60;
+            $res_array['title'][] = date('Y-m-d', (time() - $secondes));
+            $res_array['data']['money_with'][] = 0;
+            $res_array['data']['money_recharge'][] = 0;
+            $res_array['data']['money_remittance'][] = 0;
+            $res_array['data']['money_trans'][] = 0;
+            $res_array['data']['profit'][] = 0;
+        }
+        $res_array['legend']['money_with'] = trans('user.money_with');
+        $res_array['legend']['money_recharge'] = trans('user.money_recharge');
+        $res_array['legend']['money_remittance'] = trans('user.money_remittance');
+        $res_array['legend']['money_trans'] = trans('user.money_trans');
+        $res_array['legend']['profit'] = '盈利';
+        $db = new \App\Models\Money_details;
+        $data = $db->getBet();
+        if ($data < 0) {
+            return responseToJson($res_array);
+        }
+
+        $trade_type = $this->getTradetype();
+        foreach ($data as $k => $v) {
+            foreach ($res_array['title'] as $tk => $tv) {
+                if ($v['date'] == $tv) {
+                    $res_array['data'][$trade_type[$v['trade_type']]][$tk] += $v['value'];
+                    $res_array['data'][$trade_type[1]][$tk] += ($v['trade_type'] == 5) ? -$v['value'] : +$v['value'];
+                    break;
+                }
+            }
+        }
+        return responseToJson($res_array);
+        /*print_r($data);exit;
+
+        $i = 0;
+        $array['title']=array();
+        foreach ($data as $k => $v) {
+            if (is_array($v) && count($v) > 0) {
+                foreach ($v as $ka => $va) {
+                    $array['title'][$i] = $va['date'];
+                    $temp[$k][$va['date']] = $va['value'];
+                    $i++;
+                }
+            } else {
+                $temp[$k] = array();
+            }
+            $array['legend'][$k] = trans('user.' . $k);
+        }
+        $array['title']=array_unique($array['title']);
+        asort($array['title']);
+        $tem=array();
+        foreach($array['title'] as $v){
+            $tem[]=$v;
+        }
+        $array['title']=$tem;
+        $te = array();
+        foreach ($array['title'] as $k => $v) {
+            if (array_key_exists($v, $temp['money_with'])) {
+                $te['money_with'][] = $temp['money_with'][$v];
+                $money_with=$temp['money_with'][$v];
+            } else {
+                $te['money_with'][] = 0;
+                $money_with=0;
+            }
+            if (array_key_exists($v, $temp['money_recharge'])) {
+                $te['money_recharge'][] = $temp['money_recharge'][$v];
+                $money_recharge=$temp['money_recharge'][$v];
+            } else {
+                $te['money_recharge'][] = 0;
+                $money_recharge=0;
+            }
+            if (array_key_exists($v, $temp['money_remittance'])) {
+                $te['money_remittance'][] = $temp['money_remittance'][$v];
+                $money_remittance=$temp['money_remittance'][$v];
+            } else {
+                $te['money_remittance'][] = 0;
+                $money_remittance=0;
+            }
+            if (array_key_exists($v, $temp['money_trans'])) {
+                $te['money_trans'][] = $temp['money_trans'][$v];
+                $money_trans=$temp['money_trans'][$v];
+            } else {
+                $te['money_trans'][] = 0;
+                $money_trans=0;
+            }
+            $te['profit'][]=$money_trans+$money_remittance+$money_recharge-$money_with;
+        }
+        $array['legend']['profit']='盈利';
+        $array['data'] = $te;
+        return responseToJson($array);*/
+    }
+
+    private function getTradetype() {
+        $tradetype = array(
+            '5' => 'money_with',
+            '6' => 'money_recharge',
+            '11' => 'money_trans',
+            '14' => 'money_remittance',
+            '1' => 'profit',
+        );
+        return $tradetype;
+    }
+
+    //每天每个游戏注单数
+    function TodayGameNote() {
+        $time1 = date('Y-m-d 00:00:00');//今日零时
+        $time2 = date('Y-m-d 23:59:59');//今日末时
+//        $time1='2017-09-14 00:00:00';
+//        $time2='2017-09-14 23:59:59';
+        $timearea = [$time1, $time2];
+        $data = \App\Models\MoneyBuy::select('game_name as name', DB::Raw('count(id) as value'))->whereBetween('money_time', $timearea)->groupBy('game_name')->get();
+        $data = $data->toArray();
+        if (count($data) == 0) {
+            $data = array(array('name' => 'no_bet', 'value' => 0));
+        }
+        $array = array();
+        foreach ($data as $k => $v) {
+            $data[$k]['name'] = trans('common.' . $v['name']);
+            $array['title'][$k] = trans('common.' . $v['name']);
+        }
+        $array['data'] = $data;
+        $array['text'] = '今日游戏注单数量:' . date('Y-m-d');
+        return responseToJson($array);
+    }
+
+    //拉时间
+    function pullTime() {
+        //获取前台域名
+        $setInfo = new \App\Models\Setinfo();
+        $info = $setInfo->getInfo(18);
+        if ($info < 0) {
+            return responseToJson($info);
+        }
+        //$a=file_get_contents($info['infocontent'].'api-common/getTime');
+        $url = $info['infocontent'] . 'api-common/getTime';
+        $timeout = 30;
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout - 2);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); //避免data数据过长问题
+        curl_setopt($ch, CURLOPT_POST, true);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, array());
+
+        $a = curl_exec($ch);
+        curl_close($ch);
+        echo $a;
+    }
+
+    //通知消息
+    function Message() {
+
+        $admin_id = session('adminInfo.admin_id');
+        $db = new \App\Models\MessageRead;
+        $dbs = new \App\Models\Manager;
+        $where = [
+            'type',
+            '4'
+        ];
+        $datas = $dbs->getlistd($where);
+        $data = $db->getlist($admin_id);
+        if (!empty($data)) {
+            foreach ($datas as $k => $v) {
+                foreach ($data as $val) {
+                    if ($v['id'] == $val['message_id']) {
+                        $datas[$k]['status'] = '1';
+                    }
+                }
+            }
+        }
+        return $datas;
+    }
+
+    //刷新缓存
+    public function refresh() {
+        return view('admin.refresh');
+    }
+}
+

+ 228 - 0
app/Http/Controllers/Admin/InfosController.php

@@ -0,0 +1,228 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class InfosController extends GameController {
+	/**
+	 * @return
+	 */
+	function Index(Req $req) {
+        $request['game']=$req->game ? $req->game : 'jspk10';
+        $request['no']=$req->no ? $req->no : '';
+        $request['star_time']=$req->star_time ? $req->star_time : date('Y-m-d');
+        $request['end_time']=$req->end_time ? $req->end_time : date('Y-m-d');
+        //$request['status'] = Request::has('status') ? Request::get('status') : 1;
+		$this->getGame();
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Infos/getMsg?game='.$request['game']);
+		$dt->setLang('game_prize');
+		$dt->addColsFields('name');
+		$dt->addColsFields('info_no');
+		$dt->addColsFields('codes');
+		$dt->addColsFields('open_time');
+		if (checkRriv('/admin/Infos/Edit')) {
+			$dt->addColsFields('edit',array('sort'=>false,'templet'=>'#edit'));
+			//$dt->setToolBar(array('edit'));
+		}
+		return view('admin.infos/openMoney', $dt->render($request));
+	}
+	//获取开奖数据信息
+	function getMsg(Req $req) {
+		$game = $req->game ? $req->game : 'jspk10';
+		$no = $req->no ? $req->no : '';
+        $star_time=$req->star_time ? $req->star_time.' 00:00:00' : date('Y-m-d 00:00:00');
+        $end_time=$req->end_time ? $req->end_time.' 23:59:59' :  date('Y-m-d 23:59:59');
+		$list = Request::has('limit') ? Request::get('limit') : '';
+		$page = Request::has('page') ? Request::get('page') : '1';
+        $fild = Request::has('fild') ? Request::get('fild') : 'open_time';
+        //$status = Request::get('status') ? Request::get('status') : 1;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+		if (empty($game)) {
+			return responseToJson(-5030025022);
+		}
+		$where=array();
+		/*if(!empty($game)){
+		    $where[]=array('game_name','=',$game);
+        }*/
+        if(!empty($no)){
+            $where[]=array('info_no',$no);
+        }
+        if(!empty($star_time)){
+            $where[]=array('open_time','>=',$star_time);
+        }
+        if(!empty($end_time)){
+            $where[]=array('open_time','<=',$end_time);
+        }
+       // $where[] = ($status==1)?array('status','<>',-1):array('status','-1');
+		$db = '\App\Models\GamePrize';
+		$data = $db::getMsgs($where,$game, $list,$fild,$order);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+
+	}
+	/**获取游戏名**/
+	function getGame() {
+		$db = new \App\Models\GamePrize;
+		$info = $db->getgame();
+		return responseToJson($info);
+	}
+	//修改
+	function Edit(Req $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$status = $req->status;
+		$status = empty($status)?2:$status;
+		$game = $req->game;
+		$db = '\App\Models\Game' . ucfirst($game);
+		$data = $db::where('id',$id)->first();
+        if(!$data){
+        	return responseToJson(-5030002922);//没有数据
+        }
+        $datas = $data->toArray();
+        $datas['game_name'] = $game;
+		if (!$req->isMethod('post')) {
+			return view('admin/infos/edit', ['data' => $datas]);
+		} else {
+			if (empty($req->info_no) || empty($req->codes) || empty($req->open_time)) {
+				return responseToJson(-5030012022);
+			}
+			$data = array(
+				'info_no' => $req->info_no,
+				'codes' => $req->codes,
+				'open_time' => $req->open_time,
+//                'time_area'=>date('Y-m-d H:i:s',time()),
+			);
+			$res = $db::where('id',$id)->where('status','<>',2)->update($data);
+	        if(!$res){
+	        	return responseToJson(-5030003022);//修改失败
+	        }
+			$log = array(
+				session('adminInfo.admin_name'),
+				trans('common.' . $datas['game_name']),
+				$req->info_no,
+				$req->codes,
+				$req->open_time,
+			);
+			OperationLog(session('adminInfo.admin_id'), 'edit_game_prize', $log);
+			return responseToJson($res);
+		}
+	}
+	//添加
+	function add(Req $req) {
+		$game = $req->game;
+		if (empty($game)) {
+			abort(404);
+		}
+		$model = "\App\Models\Game" . ucfirst($game);
+		$datas = ['game_name' => $game];
+		if (!$req->isMethod('post')) {
+		    //当前游戏下一期期号
+            $info_nos = $model::select('info_no')->orderBy('info_no','desc')->first();
+	        if(!$info_nos){
+	            $info_no = rand(1000, 2000);
+	        }else{
+            	$info_no = $info_nos['info_no']+1;
+            }
+            $datas['info_no']=$info_no;
+			return view('admin/infos/editinfo', ['data' => $datas,]);
+		} else {
+			if (empty($req->codes) || empty($req->open_time)) {
+				return responseToJson(-5030012022);
+			}
+			$time = strtotime($req->open_time) ? strtotime($req->open_time) : '';
+			if (empty($time)) {
+				return responseToJson(-5030014022); //请输入正确的时间格式
+			}
+			//获取期号
+            $info_no = $req->info_no;
+			if (empty($info_no) || !is_numeric($info_no)) {
+				return responseToJson(-5030013022); //请填写正确的期号
+			}
+			$data = array(
+				'identity' => UUID(),
+				'info_identity' => UUID(),
+				'info_no' => $info_no,
+				'codes' => $req->codes,
+				'open_time' => $req->open_time,
+                'time'=>date('Y-m-d H:i:s',time()),
+			);
+			$res = $this->insetMsg($data,$game);
+			$log = array(
+				session('adminInfo.admin_name'),
+				trans('common.' . $datas['game_name']),
+				$req->info_no,
+				$req->codes,
+				$req->open_time,
+			);
+			OperationLog(session('adminInfo.admin_id'), 'add_game_prize', $log);
+			return responseToJson($res);
+
+		}
+	}
+
+	//插入数据
+    function insetMsg($data,$game){
+    	$model = "\App\Models\Game" . ucfirst($game);
+    	$info = $model::where('info_no',$data['info_no'])->first();
+        if(!$info){
+            $res = $model::insert($data);
+        }else{
+            return -5030114122;	//当期游戏已存在
+        }
+
+        if(!$res){
+            return -5030003122;//添加失败
+        }
+        return 1;
+    }
+
+    //获取游戏最新期号
+	function getInfos(Req $req){
+        $game = $req->game;
+        if (empty($game)) {
+            return responseToJson(-5030012022);
+        }
+        $db = new \App\Models\GamePrize;
+        $info_no = $db->getInfoNo($game);
+        if ($info_no < 0) {
+            $info_no = rand(1000, 2000);
+        }
+        return responseToJson(1,'',$info_no);
+
+    }
+
+    //最后一期开奖时间
+    public function getGameLastOpenTime(Req $req)
+    {
+        $game = $req->game;
+        if (empty($game)) {
+            return responseToJson(-5030012022);
+        }
+        $data = $this->getGameTime($game);
+        $model = '\App\Models\Game'.ucfirst($data['table_name']);
+        $db = new $model;
+        $game_info = $db->getOne($game);
+        if ($game_info < 0) {
+            return responseToJson($game_info,'获取最后期数失败','');
+        }else{
+            $data['last_time'] = $game_info['open_time']; //最后一期已开奖开奖时间
+            $time = strtotime($game_info['open_time'])+$data['cycle_time']+10; //时间处理最后一期已开奖开奖时间+当前游戏开奖时间周期+10秒
+            $data['change_time'] = date('Y-m-d H:i:s',$time);
+        }
+        return responseToJson(1,'获取成功',$data);
+    }
+
+    //获取游戏周期秒数
+    public function getGameTime($game)
+    {
+        $db = new \App\Models\GameType;
+        return $db->getOpenTime($game);
+    }
+}

+ 164 - 0
app/Http/Controllers/Admin/LabelController.php

@@ -0,0 +1,164 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Controller;
+
+/****
+ * Class LabelController 用户分组标签
+ * @package App\Http\Controllers\Admin
+ */
+class LabelController extends Controller
+{
+    //首页
+    public function index(){
+        $dt=\App\Lib\DataTable\DataTable::init();
+        $dt->setLang('label');
+        $dt->enableCheckBox();
+        $dt->addColsFields('id');
+        $dt->addColsFields('group_name');
+        $dt->addColsFields('group_code');
+        $dt->addColsFields('sort');
+        $dt->addColsFields('create_at');
+//        $dt->setToolBar(array('edit'));
+        return  view('admin.Label/index',$dt->render());
+    }
+    //数据源
+    public function dataSource(Request $req){
+        $group_name = isset($req->group_name) ? trim($req->group_name) : null;
+        $group_code = isset($req->group_code) ? trim($req->group_code) : null;
+        $limit = isset($req->limit) ? trim($req->limit) : 20;
+        $page = isset($req->page) ? trim($req->page) : null;
+        $regist_endtime = isset($req->create_at_start) ? trim($req->create_at_start) : null;
+        $regist_startime = isset($req->create_at_end) ? trim($req->create_at_end) : null;
+        $where=array();
+        if (!empty($group_name)) {
+            $where[] = array('group_name', 'like', '%' . $group_name . '%');
+        }
+        if (!empty($group_code)) {
+            $where[] = array('group_code', '=',$group_code );
+        }
+
+//        var_dump($name);
+
+        $data = \App\Models\Account_group::getList($where,$limit);
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+
+    }
+   //添加
+   function add(Request $req){
+        if(!$req->isMethod('post')){
+            return view('admin.Label/add');
+        }else{
+            $group_name=$req->group_name?trim($req->group_name):'';
+            $group_code=$req->group_code?trim($req->group_code):'';
+            $sort=$req->sort?intval($req->sort):1;
+            if(empty($group_code)){
+                return responseToJson(-240005);
+            }
+            if(empty($group_name)){
+                return responseToJson(-240006);
+            }
+            $data=array(
+                'group_name'=>$group_name,
+                'group_code'=>$group_code,
+                'sort'=>$sort,
+            );
+            $model=\App\Models\Account_group::addGroup($data);
+            $log = array(
+               session('adminInfo.admin_name'),
+               $group_name,
+               $group_code,
+               $sort,
+            );
+            OperationLog(session('adminInfo.admin_id'), 'addLabel', $log);
+            return responseToJson($model);
+        }        
+    }
+	//查看
+    function view(Request $req){
+       return $this->edit($req);
+    }
+
+    //删除
+    public function delete(Request $req){
+        $id=$req->id;
+        if(empty($id)){
+            return responseToJson(-2001);//id不能为空
+        }
+        $ids=explode(',',$id);
+        if(!is_array($ids) && intval($ids)<0){
+            return responseToJson(-2002);//id错误
+        }
+        if(is_array($ids) && count($ids)>0)
+        {
+            foreach($ids as $k=>$v){
+                if(intval($v)<1){
+                    unset($ids[$k]);
+                }
+            }
+        }
+        if(in_array(1,$ids)){
+            return responseToJson(-240003);
+        }
+
+//        if (!$rows) {
+//            return responseToJson(-2003);
+//        }
+        /*******修改 改标签会员成为初级会员********/
+        $groupList=\App\Models\Account_group::getGroups($ids);//获取删除信息
+        $groups=array_column($groupList,'group_code');
+        $group_names=array_column($groupList,'group_name');
+        $putong=\App\Models\Account_group::getInfoByID(1);//普通会员信息
+
+        $data=array(
+            'group_name'=>'|'.$putong['group_name'].'|',
+            'group_code'=>'0,'.$putong['group_code'].','
+        );
+        foreach ($groups as $v){
+            $res=\App\Models\Account_detailed::changeToleve($v,$data);
+            if($res<0){
+                return responseToJson($res);
+            }
+        }
+        //修改银行卡显示==
+        \App\Models\System_bank::changeShow($groups,$group_names);
+        $rows = \App\Models\Account_group::whereIn('id', $ids)->delete();
+
+        /*************************************/
+        /**********删除权限相关信息*********/
+        $log = array(
+            session('adminInfo.admin_name')
+        );
+        $res = OperationLog(session('adminInfo.admin_id'), 'detaleLabel', $log);
+        return responseToJson(1);
+
+    }
+
+    //修改
+    function edit(Request $req){
+        $id=$req->id;
+        if(intval($id)<1){
+            return -1;
+        }
+        if(!$req->isMethod('post')){
+
+            $data=\App\Models\User_grade::where('id',$id)->first();
+            if(!$data){
+                return -2;
+            }
+            $data=$data->toArray();
+            return view('admin.Usergrade/add',array('admin'=>$data));
+        }else{
+            $model=\App\Models\User_grade::where('id',$id)->first();
+            $model->grade=trim($req->input('grade'));
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+
+}
+
+

+ 205 - 0
app/Http/Controllers/Admin/LogController.php

@@ -0,0 +1,205 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class LogController extends Controller {
+
+	function index() {
+		# code...
+	}
+
+	/**
+	 *会员登录日志
+	 * [Colse description]
+	 */
+	function logs(Req $req) {
+		$request=array();
+		$request['account']=isset($req->account)?trim($req->account):null;
+		$request['type'] = isset($req->type) ? trim($req->type) : null;
+		$request['register_ip'] = isset($req->register_ip) ? trim($req->register_ip) : null;
+		$request['url'] = isset($req->url) ? trim($req->url) : null;
+		$request['last_ip'] = isset($req->last_ip) ? trim($req->last_ip) : null;
+		$request['log_startime'] = isset($req->log_startime) ? trim($req->log_startime) : null;
+		$request['log_endtime'] = isset($req->log_endtime) ? trim($req->log_endtime) : null;
+		
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Log/log?page=' . $page . '&limit=' . $list);
+		$dt->setLang('user');
+		$dt->addColsFields('account', array('sort' => false));
+		$dt->addColsFields('type', array('sort' => false));
+		$dt->addColsFields('ip', array('templet' => '#selectip', 'sort' => false));
+		$dt->addColsFields('url', array('templet' => '#selecturl', 'sort' => false));
+		$dt->addColsFields('register_ip', array('templet' => '#selectregistip', 'sort' => false));
+		$dt->addColsFields('add_time');
+		return view('admin.log/logs', $dt->render($request));
+	}
+
+	/**
+	 * 注册ip列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function registipDetail() {
+		$register_ip = Request::has('register_ip') ? Request::get('register_ip') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Log/log?register_ip=' . $register_ip);
+		$dt->setLang('user');
+		$dt->addColsFields('account');
+		$dt->addColsFields('type', array('sort' => false));
+		$dt->addColsFields('ip', array('sort' => false));
+		$dt->addColsFields('url', array('sort' => false));
+		$dt->addColsFields('register_ip', array('sort' => false));
+		$dt->addColsFields('add_time');
+		return view('admin.user/viewip', $dt->render());
+	}
+
+	/**
+	 * 登录ip列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function logipDetail() {
+		$ip = Request::has('ip') ? Request::get('ip') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Log/log?last_ip=' . $ip);
+		$dt->setLang('user');
+		$dt->addColsFields('account');
+		$dt->addColsFields('type', array('sort' => false));
+		$dt->addColsFields('ip', array('sort' => false));
+		$dt->addColsFields('url', array('sort' => false));
+		$dt->addColsFields('register_ip', array('sort' => false));
+		$dt->addColsFields('add_time');
+		return view('admin.user/viewip', $dt->render());
+	}
+
+	/**
+	 * 登录网址列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function logurlDetail() {
+		$url = Request::has('url') ? Request::get('url') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Log/log?url=' . $url);
+		$dt->setLang('user');
+		$dt->addColsFields('account');
+		$dt->addColsFields('type', array('sort' => false));
+		$dt->addColsFields('ip', array('sort' => false));
+		$dt->addColsFields('url', array('sort' => false));
+		$dt->addColsFields('register_ip', array('sort' => false));
+		$dt->addColsFields('add_time');
+		return view('admin.user/viewip', $dt->render());
+	}
+
+	/**
+	 * 会员登录日志
+	 * 'log description'
+	 * @return 'type' 'description'
+	 */
+	function log() {
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : '';
+
+		$account = Request::has('account') ? Request::get('account') : '';
+		$type = Request::has('type') ? Request::get('type') : '';
+		$register_ip = Request::has('register_ip') ? Request::get('register_ip') : '';
+		$last_ip = Request::has('last_ip') ? Request::get('last_ip') : '';
+		$url = Request::has('url') ? Request::get('url') : '';
+		$log_startime = Request::get('log_startime') ? Request::get('log_startime').' 00:00:00' : '';
+		$log_endtime = Request::get('log_endtime') ? Request::get('log_endtime').' 23:59:59' : '';
+		$sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+		$where = array();
+		if (!empty($account)) {
+			if (empty($sureblur) || $sureblur == '模糊') {
+				$where[] = array('account', 'like', '%' . $account . '%');
+			} else {
+				$where[] = array('account', '=', $account);
+			}
+		}
+		if (!empty($type)) {
+			$where[] = array('type', '=', $type);
+		}
+		if (!empty($register_ip)) {
+			$where[] = array('register_ip', '=', $register_ip);
+		}
+		if (!empty($last_ip)) {
+			$where[] = array('ip', '=', $last_ip);
+		}
+		if (!empty($url)) {
+			$where[] = array('url', 'like', '%' . $url . '%');
+		}
+		if (!empty($log_startime)) {
+			$log_startime = date('Y-m-d H:i:s', strtotime($log_startime));
+			$where[] = array('add_time', '>=', $log_startime);
+		}
+		if (!empty($log_endtime)) {
+			$log_endtime = date('Y-m-d H:i:s', strtotime($log_endtime));
+			$where[] = array('add_time', '<=', $log_endtime);
+		}
+
+		$db = new \App\Models\Logfile;
+		$data = $db->log($list, $page, $where);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	//查看会员信息
+	function View(Req $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$db = new \App\Models\Account_detailed();
+		if (!$req->isMethod('post')) {
+			$data = $db::where('id', $id)->first();
+			if (!$data) {
+				abort(404);
+			}
+			$data = $data->toArray();
+			return view('admin.menu/userView', ['data' => $data]);
+		} else {
+			// $model = $db::where('id', $id)->first();
+			// $model->name = $req->input('menu_name');
+			// $model->href = $req->input('menu_url');
+			// $model->icon = $req->input('menu_icon');
+			// $model->sort = $req->input('menu_sort');
+			// $model->type = $req->input('type');
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+	//修改会员信息
+	function Edit(Req $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$db = new \App\Models\Account_detailed();
+		if (!$req->isMethod('post')) {
+			$data = $db::where('id', $id)->first();
+			if (!$data) {
+				abort(404);
+			}
+			$data = $data->toArray();
+			return view('admin.menu/userAdd', ['data' => $data]);
+		} else {
+			// $model = $db::where('id', $id)->first();
+			// $model->name = $req->input('menu_name');
+			// $model->href = $req->input('menu_url');
+			// $model->icon = $req->input('menu_icon');
+			// $model->sort = $req->input('menu_sort');
+			// $model->type = $req->input('type');
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+
+}

+ 58 - 0
app/Http/Controllers/Admin/LoginController.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+/**
+ *
+ */
+class LoginController extends Controller {
+
+    function _init(){
+
+    }
+
+    function aa() {
+        $zqRuleModel = new \App\Lib\Settlement\SettlementOrder;
+        $zqRuleModel -> ChuanOrder('20190507134301713489765');
+    }
+
+	function index(Request $req) {
+		if ($req->isMethod('post')) {
+			$user = new \App\Models\System_user;
+			$str = $user->adminLogin($_POST['account'], $_POST['password']);
+			if($str>0){
+                $token=refreshToken($str['admin_id']);
+                $str['token']=$token;
+				$req->session()->put('adminInfo',$str);
+				$str=1;
+			}
+			$log = array(
+            	session('adminInfo.admin_name'),
+            	$_POST['account']
+	        );
+	        OperationLog(session('adminInfo.admin_id'), 'login', $log);
+			return responseToJson($str);
+		}
+
+		return view('admin.login/index');
+	}
+
+	function logout(Request $req){
+		$log = array(
+	    	session('adminInfo.admin_name'),
+	    );
+	    OperationLog(session('adminInfo.admin_id'), 'logout', $log);
+		$req->session()->flush();
+        $req->session()->regenerate();
+		// header('location:/admin/login/index');
+		 return view('admin.login/index');
+	}
+
+	function Errors(){
+        return view('admin.login/error');
+    }
+
+}

+ 371 - 0
app/Http/Controllers/Admin/ManagerController.php

@@ -0,0 +1,371 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class ManagerController extends Controller {
+    /**
+     * @return 信息管理
+     */
+    function index() {
+
+        return view('admin.demo/index');
+    }
+
+    /**
+     * 权限设定添加
+     * [systemAdd description]
+     * @return [type] [description]
+     */
+    function systemAdd(Req $req) {
+        if (!$req->isMethod('post')) {
+            return view('admin.Manager/systemAdd');
+        } else {
+            $model = new \App\Models\System_root();
+            $data=$model->select('id')->orderBy('id','desc')->first();
+            $id=!empty($data->id)?$data->id:0;
+            $model->id=$id+1;
+            $model->level = trim($req->input('level'));
+
+            $model->name = trim($req->input('name'));
+
+            $model->settingmoney = trim($req->input('settingmoney'));
+          
+            $model->save();
+             $log = array(
+                session('adminInfo.admin_name'),
+                $model->level,
+                $model->name, 
+                $model->settingmoney
+            );
+            OperationLog(session('adminInfo.admin_id'), 'qxsystemAdd', $log);
+            return responseToJson(1);
+        }
+
+    }
+
+    //管理员信息
+    function adminInfo() {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 5;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+        $id = Request::get('id') ? Request::get('id') : ''; //管理员ID,返回对应管理信息
+        $adminlist = new \App\Models\System_user();
+        if (empty($id)) {
+            $loginname = Request::has('loginname') ? Request::get('loginname') : '';
+            $name = Request::has('name') ? Request::get('name') : '';
+            $status = Request::has('status') ? Request::get('status') : '';
+            $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+            $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+            $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+            $where = array();
+            if (!empty($loginname)) {
+                if (empty($sureblur) || $sureblur == '模糊') {
+                    $where[] = array('loginname', 'like', '%' . $loginname . '%');
+                } else {
+                    $where[] = array('loginname', '=', $loginname);
+                }
+            }
+            if (!empty($name)) {
+                $where[] = array('name', 'like', '%' . $name . '%');
+            }
+            if (!empty($status)) {
+                $where[] = array('status', '=', $status);
+                if ($status != 1) {
+                    $where[] = array('status', '<>', 1);
+                }
+            }
+            if (!empty($star_time)) {
+                $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+                $where[] = array('add_time', '>=', $star_time);
+            }
+            if (!empty($end_time)) {
+                $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+                $where[] = array('add_time', '<=', $end_time);
+            }
+
+            $data = $adminlist->getAdminlist($where, 1, $limit, $field, $order, 'system_root');
+            // if (!($data < 0)) {
+            //  $adminstatus = trans('status.system_user.status');
+            //  foreach ($data['data'] as $k => $v) {
+            //      $data['data'][$k]['status'] = ($v['status'] == 0) ? $adminstatus[2] : $adminstatus[$v['status']];
+            //  }
+            // }
+        } else {
+            $data = $adminlist->getAdminInfo($id, 1, 'system_root', 'root_id', 'id');
+        }
+        $role_db=new \App\Models\Role;
+        $datas = array();
+        foreach ($data['data'] as $k=>$v){
+            $datas[]=$v['id'];
+//            $role=$role_db->getRoleBy($v['id']);
+//            print_r($role);
+        }
+        $data_role=$role_db->getRoleIn($datas);
+        foreach ($data['data'] as $k=>$v){
+            $data['data'][$k]['role_name']='';
+            foreach ($data_role as  $ka=>$va){
+                if($va['admin_id']==$v['id']){
+                    $data['data'][$k]['role_name'].=$va['role_name'].',';
+                }
+            }
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //修改管理员信息
+    function adminEdit() {
+        $status = Request::has('status') ? Request::get('status') : 1;
+        $id = Request::has('id') ? Request::get('id') : ''; //管理员ID
+        $pwd = Request::has('password') ? Request::get('password') : ''; //管理员密码
+        $levelid = Request::has('levelid') ? Request::get('levelid') : ''; //管理员权限ID
+        $astatus = Request::has('status') ? Request::get('status') : ''; //管理员状态
+
+        if (empty($id)) {
+            return Rens(-7010000202); //未提交管理员ID
+        }
+        if (empty($pwd)) {
+            return Rens(-7010000302); //未提交管理员密码
+        }
+        if (empty($levelid)) {
+            return Rens(-7010000402); //未提交管理员权限ID
+        }
+        if (empty($astatus)) {
+            return Rens(-7010000502); //未提交管理员状态
+        }
+        $password = GenPassword($pwd);
+        $data = array
+            (
+            'password' => $password['password'],
+            'root_id' => $levelid,
+            'status' => $astatus,
+            'encryption' => $password['encryption'],
+        );
+        $res = $status; //修改管理员信息
+        if ($res == 1) {
+            return Rens($res);
+        }
+        return Rens(-7010000602); //修改管理员信息失败
+    }
+
+    //管理员权限信息
+    function adminLevel() {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 1;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+        $id = Request::has('id') ? Request::get('id') : ''; //管理员权限ID,返回对应管理员权限信息
+        $rootdetails = new \App\Models\System_root();
+        if (empty($id)) {
+            $name = Request::has('name') ? Request::get('name') : '';
+            $level = Request::has('level') ? Request::get('level') : '';
+            $money_small = Request::has('money_small') ? Request::get('money_small') : '';
+            $money_big = Request::has('money_big') ? Request::get('money_big') : '';
+            $where = array();
+            if (!empty($name)) {
+                $where[] = array('name', 'like', '%' . $name . '%');
+            }
+            if (!empty($level)) {
+                $where[] = array('level', '=', $level);
+                if ($level == -1) {
+                    $where[] = array('level', '=', '0');
+                }
+            }
+            if (!empty($money_small)) {
+                $where[] = array('settingmoney', '>=', $money_small);
+            }
+            if (!empty($money_big)) {
+                $where[] = array('settingmoney', '<=', $money_big);
+            }
+
+            $data = $rootdetails->getRootlist($where, 1, $limit, $field, $order);
+        } else {
+            $rootdetails = new \App\Models\System_column_root();
+            $data = $rootdetails->getRootmenulist($id, 2);
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //权限菜单信息
+    function rootMenu() {
+        $status = Request::has('status') ? Request::get('status') : 1;
+        $data = array
+            (
+            array(
+                'id' => 1,
+                'name' => '彩票注单管理',
+                'parentid' => '',
+                'haschild' => 1,
+                'child' => array(
+                    array(
+                        'id' => 2,
+                        'name' => '幸运28',
+                        'parentid' => 1,
+                        'haschild' => 2,
+                    ),
+                    array(
+                        'id' => 3,
+                        'name' => '加拿大28',
+                        'parentid' => 1,
+                        'haschild' => 2,
+                    ),
+                ),
+            ),
+            array(
+                'id' => 13,
+                'name' => '会员信息管理',
+                'parentid' => '',
+                'haschild' => 1,
+                'child' => array(
+                    array(
+                        'id' => 14,
+                        'name' => '会员列表',
+                        'parentid' => 13,
+                        'haschild' => 2,
+                    ),
+                    array(
+                        'id' => 50,
+                        'name' => '用户反馈意见',
+                        'parentid' => 13,
+                        'haschild' => 1,
+                        'child' => array(
+                            array(
+                                'id' => 127,
+                                'name' => '处理反馈信息',
+                                'parentid' => 50,
+                                'haschild' => 2,
+                            ),
+                            array(
+                                'id' => 128,
+                                'name' => '删除反馈信息',
+                                'parentid' => 50,
+                                'haschild' => 2,
+                            ),
+                        ),
+                    ),
+                ),
+            ),
+        );
+        if (empty($data)) {
+            return Rens(-7010000802); //没有数据
+        }
+        return Rens($data);
+    }
+
+    //修改权限信息
+    function rootEdit() {
+        $status = Request::has('status') ? Request::get('status') : 1; //1:成功 2:失败
+        $rootid = Request::has('rootid') ? Request::get('rootid') : ''; //权限ID
+        $level = Request::has('level') ? Request::get('level') : '';
+        $name = Request::has('name') ? Request::get('name') : '';
+        $maxmoney = Request::has('maxmoney') ? Request::get('maxmoney') : '';
+        $menu = Request::has('menu') ? Request::get('menu') : '';
+        if (empty($level)) {
+            return Rens(-7010000802); //权限等级不能为空
+        }
+        if (empty($name)) {
+            return Rens(-7010000902); //权限名不能为空
+        }
+        if (empty($maxmoney)) {
+            return Rens(-7010001002); //最大操作金额不能为空
+        }
+        $res = $status; //修改权限信息
+        $menulist = array('22', '21', '127');
+        if (!empty($menu)) {
+            $menu = json_decode($menu);
+            $res = $this->addmenu($menu, $menulist, $rootid);
+        }
+
+        if ($res == 1) {
+            return Rens($res);
+        }
+        return Rens(-7010001102); //设置权限失败
+
+    }
+
+    //删除管理员权限信息
+    function delLevel() {
+        $status = Request::has('status') ? Request::get('status') : 1;
+        $id = Request::has('id') ? Request::get('id') : ''; //管理员权限ID,返回对应管理员权限信息
+        if (empty($id)) {
+            return Rens(-7010000802); //未提交管理权限ID
+        }
+        $res = $status; //删除管理员权限及其对应权限菜单关联信息
+        if ($res == 1) {
+            return Rens($res);
+        }
+        return Rens(-7010000902); //删除管理员权限信息失败
+    }
+
+    //操作日志
+    function systemLog() {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 4;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $loginname = Request::has('loginname') ? Request::get('loginname') : '';
+        $ip = Request::has('ip') ? Request::get('ip') : '';
+        $operation = Request::has('operation') ? Request::get('operation') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+        $where = array();
+        if (!empty($loginname)) {
+            if (empty($sureblur) || $sureblur == '模糊') {
+                $where[] = array('loginname', 'like', '%' . $loginname . '%');
+            } else {
+                $where[] = array('loginname', '=', $loginname);
+            }
+        }
+        if (!empty($ip)) {
+            $where[] = array('ip', '=', $ip);
+        }
+        if (!empty($operation)) {
+            $where[] = array('operation', 'like', '%' . $operation . '%');
+        }
+        if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $where[] = array('operation_time', '>=', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $where[] = array('operation_time', '<=', $end_time);
+        }
+
+        $logdetails = new \App\Models\System_log();
+        $data = $logdetails->getLoglist($where, 1, $limit, $field, $order);
+        if (!($data < 0)) {
+            foreach ($data['data'] as $k => $v) {
+                $data['data'][$k]['ip'] = ($v['ip'] == null) ? '' : $v['ip'];
+            }
+        }
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //添加权限菜单
+    private function addmenu($menu, $menulist, $rootid) {
+        $data = array('root_id' => $rootid);
+        foreach ($menu as $v) {
+            if (!in_array($v['id'], $menulist)) {
+                $data['menu_id'] = $v['id'];
+                $res = 1; //新增权限菜单
+            }
+            if (!empty($v['child'])) {
+                $getres = $this->addmenu($v['child'], $menulist, $rootid);
+            }
+        }
+        return 1;
+    }
+
+}
+
+?>

+ 172 - 0
app/Http/Controllers/Admin/MatchController.php

@@ -0,0 +1,172 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+use Storage;
+/**
+ *
+ */
+class MatchController extends Controller {
+    function index(Req $req) {
+        $request['infoname'] = isset($req->infoname) ? trim($req->infoname) : null;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/BankSet/info');
+        $dt->setLang('bankset');
+        $dt->addColsFields('infoname', array('templet' => '#userdetail', 'sort' => false, 'width' => 160));
+        $dt->addColsFields('bank_num');
+        $dt->addColsFields('bank');
+        $dt->addColsFields('groups_names');
+        $dt->addColsFields('remark');
+        $dt->addColsFields('sort');
+        $dt->addColsFields('time');
+        $dt->addColsFields('status', array('templet' => '#status', 'sort' => false, 'width' => 150,'align' => 'left'));
+        $dt->enableCheckBox();
+        if (checkRriv('/admin/BankSet/edit')) {
+            $dt->setToolBar(array('edit'));
+        }
+        return view('admin.BankSet/index', $dt->render($request));
+    }
+
+    function info() {
+        $db = new \App\Models\System_bank();
+        $data = $db->getInfos();
+        return \App\Lib\DataTable\DataTable::init()->toJson($data);
+    }
+
+    //启用/禁用会员信息
+    function UserStart(Req $req) {
+        $id = $req->id;
+        $status = is_numeric($req->status) ? intval($req->status) : '';
+        if (empty($id) || !is_numeric($status)) {
+            return responseToJson(-2020100102);
+        }
+        $u_db = new \App\Models\System_bank;
+        $data = array(
+            'status' => $status,
+        );
+        $res = $u_db->updateInfos($data, $id);
+        return responseToJson($res);
+    }
+
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        /***获取会员等级信息***/
+        $labelInfo=\App\Models\Account_group::getAllInfo();
+        /**********/
+        if (!$req->isMethod('post')) {
+            $data = \App\Models\System_bank::where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+            $data = $data->toArray();
+            return view('admin.SystemManage/BankSetEdit', array('data' => $data,'group'=>$labelInfo));
+        } else {
+            $groups=$req->groups?$req->groups:'';
+            //选择的组
+            $group_codes=array_keys($groups);
+            //获取组名的
+            $groups_names='| ';
+            foreach ($labelInfo as $k=>$v){
+                if(in_array($v['group_code'],$group_codes))
+                    $groups_names.=$v['group_name'].'| ';
+            }
+
+            $model = \App\Models\System_bank::where('id', $id)->first();
+            $model->infoname = trim($req->input('infoname'));
+            $model->bank_num = trim($req->input('bank_num'));
+            $model->bank = trim($req->input('bank'));
+            $model->remark = trim($req->input('remark'));
+            $model->groups='0,'.implode(',',$group_codes).',';
+            $model->groups_names=$groups_names;
+            $model->sort = trim($req->input('sort'));
+            $model->time = date('Y-m-d H:i:s');
+            $model->status = trim($req->input('status'));
+
+            $model->save();
+
+            $log = array(
+                session('adminInfo.admin_name'),
+                $model->infoname,
+                $model->bank_num,
+            );
+            OperationLog(session('adminInfo.admin_id'), 'UserStart', $log);
+            return responseToJson(1);
+        }
+
+    }
+
+    function add(Req $req) {
+        /***获取会员等级信息***/
+        $labelInfo=\App\Models\Account_group::getAllInfo();
+        /***获取会员等级信息**/
+        if (!$req->isMethod('post')) {
+            $data['status'] = 1;
+            $data['type'] = 0;
+            return view('admin.SystemManage/BankSetEdit', ['data' => $data,'group'=>$labelInfo]);
+        } else {
+            $groups=$req->groups?$req->groups:'';
+            //选择的组
+            $group_codes=array_keys($groups);
+            //获取组名的
+            $groups_names='| ';
+            foreach ($labelInfo as $k=>$v){
+                if(in_array($v['group_code'],$group_codes))
+                    $groups_names.=$v['group_name'].'| ';
+            }
+            $model = new \App\Models\System_bank();
+            $model->infoname = trim($req->input('infoname'));
+            $model->bank_num = trim($req->input('bank_num'));
+            $model->bank = trim($req->input('bank'));
+            $model->groups='0,'.implode(',',$group_codes).',';
+            $model->groups_names=$groups_names;
+            $model->remark = trim($req->input('remark'));
+            $model->sort = trim($req->input('sort'));
+            $model->time = date('Y-m-d H:i:s');
+            $model->status = 1;
+            $model->save();
+
+            $log = array(
+                session('adminInfo.admin_name'),
+                $model->infoname,
+                $model->bank_num,
+            );
+            OperationLog(session('adminInfo.admin_id'), 'addStart', $log);
+            return responseToJson(1);
+        }
+    }
+
+    /**
+     * 批量删除
+     * [delete description]
+     * @return [type] [description]
+     */
+    function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\System_bank::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1); //id����
+    }
+
+}

+ 139 - 0
app/Http/Controllers/Admin/MatchcodeController.php

@@ -0,0 +1,139 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class MatchcodeController extends Controller {
+
+	function index(Req $req) {
+		$request=array();
+		$request['odds_code'] = isset($req->odds_code) ? trim($req->odds_code) : null;
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['game_code'] = isset($req->game_code) ? trim($req->game_code) : -1;
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/matchcode/info');
+        $dt->setLang('matchcode');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('game_code', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('odds_code', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('odds_name', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('p_id', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('type', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
+
+        if (checkRriv('/admin/matchcode/edit')) {
+			$arr[] = 'edit';
+		}
+		$dt->setToolBar($arr, array('width' => 200));
+        $dt->enableCheckBox();
+
+		return view('admin.matchcode/index', $dt->render($request));
+	}
+
+	function info(){
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$odds_code = Request::has('odds_code') ? Request::get('odds_code') : '';
+		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$game_code = Request::has('game_code') ? Request::get('game_code') : '';
+
+		$where = array();
+		if (!empty($odds_code)) {
+			if (empty($sureblur) || $sureblur == 'off') {
+				$where[] = array('odds_code', 'like', '%' . $odds_code . '%');
+			} else {
+				$where[] = array('odds_code', '=', $odds_code);
+			}
+		}
+		if (!empty($game_code)) {
+			$where[] = array('game_code', '=', $game_code);
+		}
+		$newapp = new \App\Models\Matchcode();
+        $data = $newapp->matchcodelist($list, $page, $where);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	function addmatchcode(Req $req) {
+		if (!$req->isMethod('post')) {
+            $lange = trans('menu');
+			$newapp = new \App\Models\Matchcode();
+	        $djid = $newapp->djlist();
+
+			return view('admin.matchcode/addmatchcode',['data'=>$djid]);
+		} else {
+			$model = new \App\Models\Matchcode();
+			$model->odds_code = trim($req->input('odds_code'));
+			$model->odds_name = trim($req->input('odds_name'));
+			$model->game_code = trim($req->input('game_code'));
+			$model->p_id = trim($req->input('p_id'));
+			$model->type = 1;
+
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+	function edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+			$data = \App\Models\Matchcode::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+
+			$newapp = new \App\Models\Matchcode();
+	        $djid = $newapp->djlist();
+
+			return view('admin.matchcode/edit', ['data' => $data, 'djid' => $djid]);
+		} else {
+			$model = \App\Models\Matchcode::where('id', $id)->first();
+			$model->odds_code = $req->input('odds_code');
+			$model->odds_name = $req->input('odds_name');
+			$model->game_code = $req->input('game_code');
+			$model->p_id = $req->input('p_id');
+			
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+
+	//删除
+	function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		// echo '敬请期待';die;
+		$rows = \App\Models\Matchcode::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); 
+		}
+		return responseToJson(1); 
+	}
+
+}

+ 224 - 0
app/Http/Controllers/Admin/MenuController.php

@@ -0,0 +1,224 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+class MenuController extends Controller {
+	//
+	public function top() {
+		$menu = \App\Models\NavsModel::getTopMenu();
+		$menus = array('data' => array());
+		if ($menu > 0) {
+			$menus['data'] = $menu;
+		}
+		return json_encode($menus);
+	}
+	public function left() {
+		$menu = \App\Models\NavsModel::getLeftMenu();
+		$menus = array('data' => array());
+		if ($menu > 0) {
+			$menus['data'] = $menu;
+		}
+		return json_encode($menus);
+	}
+	public function quick() {
+		$menu = \App\Models\NavsModel::getQuickMenu();
+		$menus = array('data' => array());
+		if ($menu > 0) {
+			$menus['data'] = $menu;
+		}
+		return json_encode($menus);
+	}
+
+	function getParent() {
+		$data = \App\Models\NavsModel::where('parent_id', '0')->get();
+		if (!$data) {
+			return;
+		}
+		return $data->toArray();
+	}
+	function add(Request $req) {
+		if (!$req->isMethod('post')) {
+			$data = $this->getParent();
+			$lange = trans('menu');
+			foreach ($data as $k => $v) {
+				$arr = trim($data[$k]['name']);
+				if (isset($lange[$arr])) {
+					$data[$k]['name']=$lange[$arr];
+				}
+			}
+			return view('vip.menu_form', array('parents' => $data));
+		} else {
+			$model = new \App\Models\NavsModel();
+			$model->name = $req->input('menu_name');
+			$model->href = $req->input('menu_url');
+			$model->icon = $req->input('menu_icon');
+			$model->sort = $req->input('menu_sort');
+			$model->parent_id = $req->input('parent_id');
+			$model->target = $req->input('target');
+
+			$model->type = $req->input('type');
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+	function view(Request $req) {
+		return $this->edit($req);
+	}
+	function edit(Request $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\NavsModel::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+			$data['parents'] = $this->getParent();
+
+
+			$lange = trans('menu');
+			foreach ($data['parents'] as $k => $v) {
+				$arr = trim($data['parents'][$k]['name']);
+				if (isset($lange[$arr])) {
+					$data['parents'][$k]['name']=$lange[$arr];
+				}
+			}
+
+			return view('vip.menu_form', $data);
+		} else {
+			$model = \App\Models\NavsModel::where('id', $id)->first();
+			$model->name = $req->input('menu_name');
+			$model->href = $req->input('menu_url');
+			$model->icon = $req->input('menu_icon');
+			$model->sort = $req->input('menu_sort');
+			$model->type = $req->input('type');
+			$model->parent_id = $req->input('parent_id');
+			$model->target = $req->input('target');
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+	public function delete(Request $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+
+		$rows = \App\Models\NavsModel::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1, trans('menu.delete_success')); //id����
+
+	}
+
+	public function dataSource(Request $req) {
+		$limit = intval($req->limit) > 0 ? $req->limit : 10;
+		$page = intval($req->page) > 0 ? $req->page : 1;
+		$field = empty($req->field) ? $req->field : '';
+		$order = empty($req->order) ? $req->order : '';
+
+		$name = $req->name ? $req->name : '';
+		$url = $req->href ? $req->href : '';
+		$type = $req->type ? $req->type : '';
+		$target = $req->target ? $req->target : '';
+		$model = \App\Models\NavsModel::offset(($page - 1) * $limit)
+			->limit($limit);
+		if (!empty($field) && !empty($order)) {
+			$model = $model->orderBy($field, $order);
+		}
+		if (!empty($name)) {
+			$model = $model->where('name', 'like', '%' . $name . '%');
+		}
+		if (!empty($url)) {
+			$model = $model->where('href', 'like', '%' . $url . '%');
+		}
+		if (!empty($type)) {
+			if ($type == -1) {
+				$model = $model->where('type', '=', '0');
+			} else {
+				$model = $model->where('type', '=', $type);
+			}
+		}
+		if (!empty($target)) {
+			if ($target == -1) {
+				$model = $model->where('target', '=', '0');
+			} else {
+				$model = $model->where('target', '=', $target);
+			}
+		}
+		$data = $model->get();
+		if (!$data) {
+			return;
+		}
+		$data = $data->toArray();
+		$parent = $this->getParent();
+		$parentgroup = array();
+		if (count($parent) > 0) {
+			foreach ($parent as $v) {
+				$parentgroup[$v['id']] = $v['name'];
+			}
+		}
+		if (!empty($data) && is_array($data)) {
+			$langinfo = trans('status.dc_navs');
+			$menu = trans('menu');
+			foreach ($data as $k => $v) {
+				$data[$k]['name'] = isset($menu[trim($v['name'])]) ? $menu[trim($v['name'])] : trim($v['name']);
+                $pname = ($v['parent_id'] == 0 || !isset($parentgroup[$v['parent_id']])) ? 'noparent' : $parentgroup[$v['parent_id']];
+                $data[$k]['parent_name'] = isset($menu[trim($pname)])?$menu[trim($pname)]:trim($pname);
+				$data[$k]['type'] = ($v['type'] == 0) ? $langinfo['type']['-1'] : $langinfo['type'][$v['type']];
+				$data[$k]['target'] = ($v['target'] == 0) ? $langinfo['target']['-1'] : $langinfo['target'][$v['target']];
+			}
+		}
+		$count = \App\Models\NavsModel::count();
+		return \App\Lib\DataTable\DataTable::init()->toJson($data, $count);
+	}
+
+	public function index(Request $req) {
+		$request['name'] = isset($req->name) ? trim($req->name) : null;
+		$request['href'] = isset($req->href) ? trim($req->href) : null;
+		$request['type'] = isset($req->type) ? trim($req->type) : null;
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setLang('menu');
+		$dt->addColsFields('id', array('sort' => false, 'width' => 100));
+		$dt->addColsFields('name', array('sort' => false, 'width' => 250, 'templet' => '#menudetail'));
+		//    $dt->addColsFields('icon');
+		$dt->addColsFields('href', array('sort' => false));
+		$dt->addColsFields('type', array('sort' => false, 'width' => 150));
+		$dt->addColsFields('sort', array('width' => 85));
+		$dt->addColsFields('parent_id', array('sort' => false, 'width' => 100));
+		$dt->addColsFields('parent_name', array('sort' => false, 'width' => 150));
+		$dt->addColsFields('target', array('sort' => false, 'width' => 150));
+		$dt->enableCheckBox();
+		$arr[] = 'view';
+		if (checkRriv('/admin/Menu/edit')) {
+			$arr[] = 'edit';
+		}
+		$dt->setToolBar($arr, array('width' => 200));
+		return view('vip.system_menu', $dt->render($request));
+	}
+	function getEditColsModel() {
+		return 'NavsModel';
+	}
+
+}

+ 288 - 0
app/Http/Controllers/Admin/MessageController.php

@@ -0,0 +1,288 @@
+<?php
+/**
+ * 系统设置
+ */
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\Account;
+use App\Models\Account_group;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use Request;
+
+/**
+ *
+ */
+class MessageController extends Controller
+{
+    /**
+     * 活动公告
+     */
+    function Index(Req $req)
+    {
+        $request = array();
+        $request['title'] = isset($req->title) ? trim ($req->title) : null;
+        $request['type'] = isset($req->type) ? trim ($req->type) : null;
+//        $request['message_type'] = isset($req->message_type) ? trim($req->message_type) : null;
+        $request['toname'] = isset($req->toname) ? trim ($req->toname) : null;
+        $request['fromname'] = isset($req->fromname) ? trim ($req->fromname) : null;
+
+        $dt = \App\Lib\DataTable\DataTable::init ();
+        $dt->setDataSource ('/admin/Message/getArticle');
+        $dt->setLang ('notice');
+        // $dt->addColsFields('id');
+        $dt->addColsFields ('title');
+        $dt->addColsFields ('toname');
+        $dt->addColsFields ('group_name');
+        $dt->addColsFields ('formname');
+        $dt->addColsFields ('add_type');
+        $dt->addColsFields ('is_show');
+        // $dt->addColsFields('content');
+        $dt->addColsFields ('add_time');
+//        $dt->addColsFields('message_type');
+        $dt->addColsFields ('type');
+        $dt->enableCheckBox ();
+        $arr[] = 'view';
+        $dt->setToolBar ($arr, array('width' => 140));
+        return view ('admin.Manager/arictle', $dt->render ($request));
+    }
+
+    //获取信息
+    //获取活动信息
+    function getArticle()
+    {
+        $limit = Request::has ('limit') ? Request::get ('limit') : 10;
+
+        $title = Request::has ('title') ? Request::get ('title') : '';
+        $content = Request::has ('content') ? Request::get ('content') : '';
+        $message_type = Request::has ('message_type') ? Request::get ('message_type') : '';
+        $type = Request::has ('type') ? Request::get ('type') : '';
+        $forname = Request::has ('forname') ? Request::get ('forname') : '';
+        $toname = Request::has ('toname') ? Request::get ('toname') : '';
+        $add_time = Request::has ('add_time') ? Request::get ('add_time') : '';
+
+
+        $where = array();
+        if (!empty($title)) {
+            $where[] = array('title', 'like', '%' . $title . '%');
+        }
+        if (!empty($type)) {
+            $where[] = array('type', '=', $type);
+        } else {
+            $where[] = array('type', '!=', 2);
+            $where[] = array('type', '!=', 4);
+        }
+        if (!empty($content)) {
+            $where[] = array('content', 'like', '%' . $content . '%');
+        }
+        if (!empty($forname)) {
+            $where[] = array('formname', 'like', '%' . $forname . '%');
+        }
+        if (!empty($toname)) {
+            $where[] = array('toname', 'like', '%' . $toname . '%');
+        }
+        if (!empty($add_time)) {
+            $add_time = date ('Y-m-d H:i:s', strtotime ($add_time));
+            $where[] = array('add_time', '<=', $add_time);
+        }
+
+        $db = new \App\Models\Manager();
+        $data = $db->getlist ($limit, $where);
+        if (!($data < 0)) {
+            $langinfo = trans ('status.manager');
+            $messged = trans ('notice.message_status');
+            $show = trans ('notice.show');
+            foreach ($data['data'] as $k => $v) {
+                $data['data'][$k]['type'] = $langinfo[$v['type']];
+                if (!empty($v['add_type'])) {
+                    $data['data'][$k]['add_type'] = $messged[$v['add_type']];
+                }
+                $data['data'][$k]['is_show'] = $show[$v['is_show']];
+            }
+        }
+        return \App\Lib\DataTable\DataTable::init ()->toJson ($data['data'], $data['total']);
+    }
+
+    function view(Req $req)
+    {
+        return $this->Edit ($req);
+    }
+
+    function Edit(Req $req)
+    {
+        $id = $req->id;
+//        $id=Request::has('id')?Request::get('id'):'';
+        if (intval ($id) < 1) {
+            abort (404);
+        }
+        $db = new \App\Models\Manager;
+        $groupdata = \App\Models\Account_group::getAllInfo ();
+        if (!$req->isMethod ('post')) {
+            $data = $db->getDmsg ($id, 1);
+            if (!$data) {
+                return responseToJson ($data);
+            }
+            return view ('admin.Manager/editNotice', ['data' => $data, 'group' => $groupdata]);
+        } else {
+            $data['title'] = $req->input ('title');
+            $data['content'] = $req->desc;
+            $res = $db->updateMsg ($data, $id);
+//            $log = array(
+//                session('adminInfo.admin_name'),
+//            );
+//            OperationLog(session('adminInfo.admin_id'), 'edit_game', $log);
+            return responseToJson ($res);
+        }
+    }
+
+    /**
+     * 批量删除
+     * [delete description]
+     * @return [type] [description]
+     */
+    function delete(Req $req)
+    {
+        $id = $req->input ('id');
+        if (empty($id)) {
+            return responseToJson (-2001); //id������
+        }
+        $ids = explode (',', $id);
+        if (!is_array ($ids) && intval ($ids) < 0) {
+            return responseToJson (-2002); //id����
+        }
+        if (is_array ($ids) && count ($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval ($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\Manager::whereIn ('id', $ids)->delete ();
+        if (!$rows) {
+            return responseToJson (-2003); //id����
+        }
+        $log = array(
+            session('adminInfo.admin_name'),
+        );
+        OperationLog(session('adminInfo.admin_id'), 'del_mess', $log);
+        return responseToJson (1); //id����
+    }
+
+    function MessageView()
+    {
+        $id = Request::has ('id') ? Request::get ('id') : '';
+        $admin_id = session ('adminInfo.admin_id');
+        $where = [
+            'id',
+            $id
+        ];
+        $dataWhwew = [
+            'message_id' => $id,
+            'account_identity' => $admin_id,
+//            'add_time'=>time()
+        ];
+        $db = new \App\Models\Manager();
+        $dbRead = new \App\Models\MessageRead;
+        $data = $db->getlistd ($where);
+        $dataRead = $dbRead->Messagelist ($id, $admin_id);
+        if ($dataRead < 0) {
+            $dat = $dbRead->addMessage ($dataWhwew);
+        }
+        return view ('admin.Manager/view', ['data' => $data]);
+    }
+
+    /**
+     * 添加消息
+     * @param Req $req
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
+     */
+    function addNotice(Req $req)
+    {
+        $groupdata = \App\Models\Account_group::getAllInfo ();
+
+        if (!$req->isMethod ('post')) {
+            $groupdatas = $groupdata;
+            return view ('admin.Manager/editNotice', ['select' => 1, 'group' => $groupdatas]);
+        } else {
+            $data['title'] = $req->input ('title');
+            $data['type'] = $req->type ? intval ($req->type) : '';
+            if (empty($data['type'])) {
+                return responseToJson (-3001341);
+            }
+            $data['content'] = $req->desc;
+            $log = array(
+                session ('adminInfo.admin_name'),
+                $data['title']
+            );
+            $data['add_time'] = date ('Y-m-d H:i:s');
+            $data['formname'] = $req->input ('formname');
+            $data['toname'] = str_replace (',', ',', strip_tags (trim ($req->input ('toname'))));
+            $data['add_type'] = isset($req->add_type) ? trim ($req->add_type) : '1';
+            $data['is_show'] = isset($req->is_show) ? trim ($req->is_show) : 0;  //首页是否弹出显示
+            $groups = $req->groups;
+            $send = [
+                'name' => $data['title'],
+                'from' => $data['formname'],
+                'content' => $data['content'],
+                'time' => $data['add_time'],
+                'type' => $data['type']
+            ];
+            $db = new \App\Models\Manager;
+            //普通消息
+            if ($data['type'] == 1) {
+                $dataName = explode (',', $data['toname']);
+                $send['to'] = $this->getIdBy ($dataName);//接收者列表
+            }
+            //系统消息
+            if ($data['type'] == 2) {
+                $data['formname'] = '系统消息';
+                //$data['toname'] = 'all';
+            }
+            //系统通知
+            if ($data['type'] == 3) {
+                $data['formname'] = '系统通知';
+                //获取发送用户组
+                if (is_array ($groups) && count ($groups) > 0) {
+                    $data['toname'] = 'groups';
+                    $data['group_code'] = '0,' . implode (',', $groups) . ',';
+                    $data['group_name'] = '|';
+                    foreach ($groupdata as $k => $v) {
+                        if (in_array ($v['group_code'], $groups)) {
+                            $data['group_name'] .= $v['group_name'] . '|';
+                        }
+                    }
+                }
+                $groupcode = isset($data['group_code']) ? $data['group_code'] : 'all';
+
+            }
+            if (!$data['toname']) {
+                $data['toname'] = 'all';
+            }
+            $res = $db->addNotice ($data);
+            if ($res < 0)
+                return responseToJson ($res);
+            OperationLog (session ('adminInfo.admin_id'), 'add_no', $log);
+
+            return responseToJson (1);
+        }
+    }
+
+
+    /**
+     * 根据用户账号查ID
+     * @param $names
+     * @return null
+     */
+    protected function getIdBy($names)
+    {
+        if (!is_array ($names)) $names = explode (',', $names);
+        $names = array_unique ($names);
+        if (!$names) return null;
+        $ids = (new Account())->whereIn ('account', $names)->pluck ('identity');
+        return $ids ? $ids->toArray () : null;
+    }
+
+
+}

+ 290 - 0
app/Http/Controllers/Admin/MessageReadController.php

@@ -0,0 +1,290 @@
+<?php
+/**
+ * 系统设置
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+/**
+ *
+ */
+class MessageReadController extends Controller {
+
+    /**
+     * 消息
+     */
+    function Index(Req $req) {
+
+        $request=array();
+
+
+        $request['title'] = isset($req->title) ? trim($req->title) : null;
+        $request['type'] = isset($req->type) ? trim($req->type) : null;
+        $request['status'] = isset($req->status) ? trim($req->status) : null;
+        $request['toname'] = isset($req->toname) ? trim($req->toname) : null;
+        $request['fromname'] = isset($req->fromname) ? trim($req->fromname) : null;
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/MessageRead/getArticle');
+        $dt->setLang('notice');
+        // $dt->addColsFields('id');
+        $dt->addColsFields('title');
+//        $dt->addColsFields('toname');
+        $dt->addColsFields('formname');
+
+
+         $dt->addColsFields('status',array('sort' => false, 'templet' => '#agent', 'width' => 80));
+        $dt->addColsFields('add_time');
+//        $dt->addColsFields('message_type');
+//        $dt->addColsFields('type');
+        $dt->enableCheckBox();
+        $arr[] = 'view';
+        $dt->setToolBar($arr, array('width' => 140));
+        return view('admin.ManagerRead/arictle',$dt->render($request));
+
+    }
+
+    //获取信息
+    //获取活动信息
+    function getArticle() {
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+
+        $title = Request::has('title') ? Request::get('title') : '';
+//        $content = Request::has('content') ? Request::get('content') : '';
+        $message_type = Request::has('message_type') ? Request::get('message_type') : '';
+        $type = Request::has('type') ? Request::get('type') : '';
+//        $forname = Request::has('forname') ? Request::get('forname') : '';
+//        $toname = Request::has('toname') ? Request::get('toname') : '';
+//        $add_time = Request::has('add_time') ? Request::get('add_time') : '';
+
+
+//        var_dump($type);
+        $where = array();
+        if (!empty($title)) {
+            $where[] = array('title', 'like', '%' . $title . '%');
+        }
+        if (empty($type)) {
+            $where[] = array('type', '=', '4');
+        }
+        if (empty($message_type)) {
+            $where[] = array('type', '=', '2');
+        }
+
+
+
+        $db = new \App\Models\Manager();
+        $data = $db->getlist($limit, $where);
+
+        $admin_id=session('adminInfo.admin_id');
+        $dbs = new \App\Models\MessageRead;
+        $datas=$dbs->getlist($admin_id);
+        if (!empty($datas)){
+
+            foreach ($data['data'] as $k=>$v){
+                foreach ($datas as $vv){
+                    if($vv['type'] == '1' && $v['id'] == $vv['message_id']){
+
+                        $data['data'][$k]['type']='1';
+                    }
+
+                }
+            }
+
+            foreach ($data['data'] as $k=>$v){
+                if($v['type'] == '2'){
+                    $dat[$k]=$v;
+                }
+            }
+
+            if (!empty($dat)){
+                $data['data']=  $dat;
+            }else{
+                $data['data']="";
+            }
+        }
+
+
+//        var_dump($dat);
+
+        if (!empty($data['data'])) {
+            foreach ($data['data'] as $k=>$v){
+                foreach ($datas as $val){
+                    if ($v['id'] == $val['message_id']){
+                        $data['data'][$k]['status']='1';
+                    }
+
+                }
+            }
+            $langinfo = trans('status.managerread');
+            foreach ($data['data'] as $k => $v) {
+                $data['data'][$k]['status'] = $langinfo[$v['status']];
+            }
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+    function view(Req $req) {
+        return $this->MessageView($req);
+    }
+
+    function Edit(Req $req) {
+        $id = $req->id;
+//        $id=Request::has('id')?Request::get('id'):'';
+        if (intval($id) < 1) {
+            abort(404);
+        }
+        $db = new \App\Models\Manager;
+        if (!$req->isMethod('post')) {
+            $data = $db->getDmsg($id, 1);
+            if (!$data) {
+                return responseToJson($data);
+            }
+            return view('admin.ManagerRead/editNotice', ['data' => $data]);
+        } else {
+            $data['title'] = $req->input('title');
+            $data['content'] = $req->desc;
+            $res = $db->updateMsg($data, $id);
+//            $log = array(
+//                session('adminInfo.admin_name'),
+//            );
+//            OperationLog(session('adminInfo.admin_id'), 'edit_game', $log);
+            return responseToJson($res);
+        }
+    }
+
+    /**
+     * 批量删除
+     * [delete description]
+     * @return [type] [description]
+     */
+    function delete(Req $req) {
+        $id = $req->input('id');
+        $admin_id=session('adminInfo.admin_id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+       $ids= explode(",",$id);
+
+        foreach ($ids as $va){
+        $rows = new \App\Models\MessageRead;
+        $rtt=$rows->Messagelist($va,$admin_id);
+        if($rtt > 0){
+            $data=[
+                'type'=>'1'
+            ];
+            $rowt=$rows->updateMsg($va,$admin_id,$data);
+            if (!$rowt) {
+                return responseToJson(-2003); //id
+            }
+        }else{
+            $dataWhwew=[
+                'message_id'=>$va,
+                'account_identity'=>$admin_id,
+                'type'=>'1',
+                'add_time'=>date("Y-m-d H:i",time())
+            ];
+            $dat = $rows->addMessage($dataWhwew);
+            if (!$dat) {
+                return responseToJson(-2003); //id
+            }
+          }
+        }
+
+        return responseToJson(1); //id
+    }
+
+    function addNotice(Req $req){
+//        $dataName=array();
+        if (!$req->isMethod('post')) {
+            return view('admin.Manager/editNotice',['select'=>1]);
+        }else{
+            $data['title'] = $req->input('title');
+            $data['type'] =$req->type;
+            $data['content'] = $req->desc;
+            $log = array(
+                session('adminInfo.admin_name'),
+                $data['title']
+            );
+            $data['add_time']=date('Y-m-d H:i:s');
+            $data['formname']=$req->input('formname');
+            $data['toname']=$req->input('toname');
+//            $data['message_type']=$req->input('message_type');
+            $db = new \App\Models\Manager;
+            $user = new \App\Models\Account;
+            //普通消息
+            if ($data['type'] == 2){
+                    $dataName=explode(',',$data['toname']);
+                    foreach ($dataName as $v){
+                        $data['toname']=$v;
+                        $res = $db->addNotice($data);
+                    }
+            }
+            //系统消息
+            if ($data['type'] == 1){
+                $data['formname']='system';
+                $data['toname']='all';
+                $db->addNotice($data);
+            }
+
+
+            //系统通知
+            if ($data['type'] == 3){
+                $data['formname']='notice';
+                $data['toname']='all';
+                $db->addNotice($data);
+
+                }
+
+            //系统通知
+            if ($data['type'] == 4){
+                $data['formname']='admin';
+                $data['toname']='admin_all';
+                $db->addNotice($data);
+
+            }
+
+
+//            $res = $db->addNotice($data);
+            OperationLog(session('adminInfo.admin_id'), 'add_notice', $log);
+            return responseToJson(1);
+        }
+    }
+
+
+    function MessageView(Req $req){
+        $id = $req->input('id');
+        $admin_id=session('adminInfo.admin_id');
+        $where=[
+            'id',
+            $id
+        ];
+        $dataWhwew=[
+            'message_id'=>$id,
+            'account_identity'=>$admin_id,
+            'add_time'=>date("Y-m-d H:i",time())
+        ];
+        $db = new \App\Models\Manager();
+        $dbRead = new \App\Models\MessageRead;
+        $data = $db->getlistd($where);
+        $dataRead = $dbRead->Messagelist($id,$admin_id);
+        if ($dataRead < 0){
+            $dat = $dbRead->addMessage($dataWhwew);
+        }
+        return view('admin.ManagerRead/view',['data'=>$data]);
+    }
+}
+
+?>

+ 230 - 0
app/Http/Controllers/Admin/MgGameController.php

@@ -0,0 +1,230 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: qin
+ * Date: 2019/2/27
+ * Time: 15:13
+ */
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Request;
+use Illuminate\Support\Facades\DB;
+use \SoapClient;
+use \SoapVar;
+use \SoapHeader;
+
+class MgGameController extends Controller
+{
+	protected $SessionGUID = 'ae6b4f27-ffdf-4db1-b1d2-3f99031f6d14';
+	protected $game_type;
+    protected $user_prefix;
+    protected $agent_host;
+    protected $agent_username;
+    protected $agent_pincode;
+    protected $agent_gameinfo;
+    protected $api_url1;
+    protected $api_url2;
+    protected $token       = '123321';
+    protected $callbackurl;
+    
+    
+    const cache_path = './';
+    const PWDSTR = '2019';
+
+    public function __construct()
+    {
+    	$set = new \App\Models\Rgame_setting();
+
+        $where = array();
+        $where[] = array('game_type','=','mggame');
+        $set_obj  = $set->getGame($where);
+        $json = json_decode($set_obj->extend, true);
+        $this->agent_username = $set_obj->agent_name;
+        $this->agent_pincode  = $set_obj->agent_pwd;
+        $this->api_url1    = $json['host1'];//api1
+        $this->api_url2    = $json['host2'] ?? '';//api2
+        $this->paly_host1  = $json['host3'] ?? '';//play1
+        $this->paly_host2  = $json['host4'] ?? '';//play2
+        $this->callbackurl = $json['callbackurl'] ?? '';//返回地址
+        $this->game_type   = $set_obj->game_type;
+        $this->user_prefix = $set_obj->user_prefix;
+        $this->agent_host  = $set_obj->agent_url;
+        $this->actype = 1;
+    }
+
+    //获取投注记录
+    public function getbetlist(){
+    	$limit = Request::has ('limit') ? Request::get ('limit') : 10;
+    	$page = Request::has ('page') ? Request::get ('page') : 1;
+        $start_time = Request::has ('start_time') ? Request::get ('start_time') : '';
+        $end_time = Request::has ('end_time') ? Request::get ('end_time') : '';
+        $mggame =  new \App\Models\Mggame_betting_ogrbv();
+        $where[] = array('GameEndTime','>=',strtotime($start_time.' 00:00:00'));
+        $where[] = array('GameEndTime','<',strtotime($end_time.' 23:59:59'));
+
+        $data = $mggame->getlist($where,$limit);
+        foreach($data['data'] as $key => $val)
+        {
+            $data['data'][$key]['GameEndTime'] = date('Y-m-d H:i:s', $val['GameEndTime']);
+        }
+        return \App\Lib\DataTable\DataTable::init ()->toJson ($data['data'], $data['total']);
+
+    }
+
+    //更新流水
+    public function updatebetlist(){
+        $limit = Request::has ('limit') ? Request::get ('limit') : 1000;
+        $page = Request::has ('page') ? Request::get ('page') : 1;
+        $start_time = Request::has ('start_time') ? Request::get ('start_time') : date('Y-m-d');
+        $end_time = Request::has ('end_time') ? Request::get ('end_time') : date('Y-m-d');
+        $res = array();
+        $this->IsAuthenticate();
+        $id=$this->GetBetInfoDetails($start_time,$end_time,$limit);
+        if(!empty($id)){
+            $res = $this->GetReportResult($id,$page);
+            if($res['code'] == 0){
+                $indata =   [];
+                $indatatwo =   [];
+                foreach ($res['data'] as $key => $value) {
+                   //获取本站用户名
+                    $loainfo = \App\Models\Oggame_user::select('lo_name')->where('rp_name',$value['AccountNumber'])->where('game_type','mggame')->first();
+                    if(!$loainfo || empty($loainfo->lo_name))return -50630201302;
+                    //获取本站用户ID
+                    $aid = \App\Models\Account::select('identity')->where('account',$loainfo->lo_name)->first();
+                    if(!$aid || empty($aid->identity))return -50630200302;
+                    $mginfo = \App\Models\Mggame_betting_ogrbv::where(['AccountNumber'=>$value['AccountNumber'],'GameEndTime'=>strtotime($value['Date'])])->first();
+                    if(empty($mginfo)){
+                        $indata[$key] = array(
+                            'RowId' => md5(json_encode($value)),
+                            'AccountNumber' => $value['AccountNumber'],
+                            'Income' => $value['Income'],
+                            'Payout' => $value['Payout'],
+                            'WinAmount' => $value['WinAmount'],
+                            'LoseAmount' => $value['LoseAmount'],
+                            'ModuleId' => $value['ModuleId'],
+                            'ClientId' => $value['ClientId'],
+                            'DisplayGameCategory' => $value['GameType'],
+                            'GameEndTime' => strtotime($value['Date']),
+                            'account_identity'=>$aid->identity,
+                            'account_name'=>$loainfo->lo_name,
+                            'winloseamount'=>floatval($value['WinAmount'])+floatval($value['LoseAmount'])
+                        );
+                    }else{
+                        $indatatwo = array(
+                            'RowId' => md5(json_encode($value)),
+                            'AccountNumber' => $value['AccountNumber'],
+                            'Income' => $value['Income'],
+                            'Payout' => $value['Payout'],
+                            'WinAmount' => $value['WinAmount'],
+                            'LoseAmount' => $value['LoseAmount'],
+                            'ModuleId' => $value['ModuleId'],
+                            'ClientId' => $value['ClientId'],
+                            'DisplayGameCategory' => $value['GameType'],
+                            'GameEndTime' => strtotime($value['Date']),
+                            'account_identity'=>$aid->identity,
+                            'account_name'=>$loainfo->lo_name,
+                            'winloseamount'=>floatval($value['WinAmount'])+floatval($value['LoseAmount'])
+                        );
+                        $restt = \App\Models\Mggame_betting_ogrbv::where('id',$mginfo->id)->update($indatatwo);
+                    }
+                    
+                }
+            }
+            if(!empty($indata)){
+                $res = \App\Models\Mggame_betting_ogrbv::insert($indata);
+                if($res<0)return -50630200402;
+            }
+
+        }
+
+        return 1;
+    }
+
+    /**
+	 * get SessionGUID
+	 *
+	 * Authenticates the agent by login name and password.
+	 * The SessionGUID which retrieved via this method should be used in all other methods in theHeader
+	 *
+	 * @param $agentname
+	 * @param $pincode
+	 */
+	public function IsAuthenticate(){
+		
+		$client = new SoapClient($this->api_url1.'?wsdl', array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));
+
+		$result = $client->IsAuthenticate(
+            array(
+                'loginName' => $this->agent_username,
+                'pinCode' =>$this->agent_pincode
+            )
+        );
+
+		if ($result->IsAuthenticateResult->ErrorCode == 0) {
+			$this->SessionGUID = $result->IsAuthenticateResult->SessionGUID;
+		}
+		return $result;
+	}
+	
+
+    //获取投注详情id
+    public function GetBetInfoDetails($s_time='',$e_time='',$limit){
+        $client = new SoapClient($this->api_url1.'?wsdl', array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));
+        $starttime  =   date("Y-m-d\TH:i:s",strtotime($s_time)) ?? date("Y-m-d\TH:i:s",strtotime("-1 day"));
+        $endtime    =   date("Y-m-d\TH:i:s",strtotime($e_time)) ?? date("Y-m-d\TH:i:s");
+        $data = [
+            'dateFrom' => $starttime,
+            'dateTo' => $endtime,
+            'maxNumRowsPage' => $limit,
+        ];
+        $xml = '
+            <AgentSession xmlns="https://entservices.totalegame.net">
+                <SessionGUID>' . $this->SessionGUID . '</SessionGUID>
+                <IPAddress>' . $_SERVER['REMOTE_ADDR'] . '</IPAddress>
+            </AgentSession>
+        ';
+        $xmlvar = new SoapVar($xml, XSD_ANYXML);
+        $header = new SoapHeader($this->api_url1, 'AgentSession', $xmlvar);
+        $client->__setSoapHeaders($header);
+        $result = $client->GetBetInfoDetails($data);
+        $res=$result->GetBetInfoDetailsResult;
+        return $res;
+    }
+    //获取投注列表
+     public function GetReportResult($id,$page){
+        $client = new SoapClient($this->api_url1.'?wsdl', array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));
+        $data = [
+            'id' => $id,
+            'nPage' => $page
+        ];
+        $xml = '
+            <AgentSession xmlns="https://entservices.totalegame.net">
+                <SessionGUID>' . $this->SessionGUID . '</SessionGUID>
+                <IPAddress>' . $_SERVER['REMOTE_ADDR'] . '</IPAddress>
+            </AgentSession>
+        ';
+        $xmlvar = new SoapVar($xml, XSD_ANYXML);
+        $header = new SoapHeader($this->api_url1, 'AgentSession', $xmlvar);
+        $client->__setSoapHeaders($header);
+        $result = $client->GetReportResult($data);
+        $res=$result->GetReportResultResult;
+        if($res->ErrorCode ==0){
+            $json =  json_decode(json_encode(simplexml_load_string($res->CurrentPageData->any)),TRUE);
+            $da['code'] = 0;
+            if(empty($json)){
+            	$da['data'] = [];
+            }else{
+            	$da['data'] = $json['NewDataSet']['Table'];
+            }
+            $paging = json_decode(json_encode($res->Paging),TRUE);
+            $da['count'] = count($da['data']);
+            $da['extras'] =[];
+            $da['msg'] ='';
+        }
+        return $da;
+    }
+
+
+}

+ 1293 - 0
app/Http/Controllers/Admin/MoneyController.php

@@ -0,0 +1,1293 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\Withdraw_rule;
+use Illuminate\Support\Facades\DB;
+use Request;
+
+/**
+ *
+ */
+class MoneyController extends Controller
+{
+
+    /**
+     * @return 账务管理
+     */
+    function index()
+    {
+        return view('admin.MoneyManage/Index');
+    }
+
+    //用户存取反水列表
+    function moneyList()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 6;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
+        $trade_type = Request::has('trade_type') ? Request::get('trade_type') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
+        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
+        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
+        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $where = array();
+        if (is_numeric($status)) {
+            $where[] = array('money_details.status', '=', $status);
+        }
+        if (!empty($trade_type)) {
+            $where[] = array('trade_type', '=', $trade_type);
+        }
+        if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $where[] = array('money_time', '>=', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $where[] = array('money_time', '<=', $end_time);
+        }
+
+        if (!empty($money_small)) {
+            $where[] = array('money', '>=', $money_small);
+        }
+        if (!empty($money_big)) {
+            $where[] = array('money', '<=', $money_big);
+        }
+
+        if (!empty($account_name)) {
+            if (empty($sureblur) || $sureblur == '模糊') {
+                $where[] = array('account_name', 'like', '%' . $account_name . '%');
+            } else {
+                $where[] = array('money_details.account_name', '=', $account_name);
+            }
+        }
+        if (!empty($order_id)) {
+            $where = array(array('trade_id', '=', $order_id));
+        }
+
+        $moneydetails = new \App\Models\Money_details;
+        $data = $moneydetails->getPartlist($where, 1, $limit, $field, $order);
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+
+        $data['data'] = arrayToNumber($data['data'], ['money']);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    //用户账务日志
+    function fundLog()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 6;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $loss_name = Request::has('loss_name') ? Request::get('loss_name') : '';
+        $agent_name = Request::has('agent_name') ? Request::get('agent_name') : '';
+        $startime = Request::get('startime') ? Request::get('startime') . ' 00:00:00' : '';
+        $endtime = Request::get('endtime') ? Request::get('endtime') . ' 23:59:59' : '';
+
+        if (empty($account_name) && !empty($agent_name)) {
+            $db = new \App\Models\NagentChild;
+            $account_name = $db->getChildStr($agent_name);
+        }
+        /*$whereIn = array();
+        $whereNotin = array();
+        $where = array();
+        if (!empty($account_name)) {
+            $whereIn[] = array('account_name', explode(',', $account_name));
+        }
+        if (!empty($loss_name)) {
+            $whereNotin[] = array('account_name', explode(',', $loss_name));
+        }
+        if (!empty($startime)) {
+            $startime = date('Y-m-d H:i:s', strtotime($startime));
+            $where[] = array('money_time', '>=', $startime);
+        }
+        if (!empty($endtime)) {
+            $endtime = date('Y-m-d H:i:s', strtotime($endtime));
+            $where[] = array('money_time', '<=', $endtime);
+        }*/
+        $where = '';
+        if (!empty($account_name)) {
+            $account_name = explode(',', $account_name);
+            $account_name = implode("','", $account_name);
+            $where .= " where account_name in ('" . $account_name . "') ";
+        }
+        if (!empty($loss_name)) {
+            $loss_name = explode(',', $loss_name);
+            $loss_name = implode("','", $loss_name);
+            $where .= empty($where) ? ' where ' : ' and ';
+            $where .= "account_name not in ('" . $loss_name . "')";
+        }
+        if (!empty($startime)) {
+            $startime = date('Y-m-d H:i:s', strtotime($startime));
+            $where .= empty($where) ? ' where ' : ' and ';
+            $where .= "money_time>='" . $startime . "'";
+        }
+        if (!empty($endtime)) {
+            $endtime = date('Y-m-d H:i:s', strtotime($endtime));
+            $where .= empty($where) ? ' where ' : ' and ';
+            $where .= "money_time<='" . $endtime . "'";
+        }
+
+        $moneydetails = new \App\Models\Money_details();
+        $data = $moneydetails->getFundlog($where, 1, $limit, $field, $order, $page);
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+
+        $data['data'] = arrayToNumber($data['data'], ['sendmoney', 'savemoney', 'getmoney', 'winmoney', 'adminadd', 'adminpull', 'recharge_send', 'back_return']);
+        /*$uwhere = array();
+        $uwhere = $where;
+        $countmoney = $moneydetails->getPatlog($where, 4);
+        foreach ($data['data'] as $k => $v) {
+            $data['data'][$k]['sendmoney'] = 0;
+            $data['data'][$k]['savemoney'] = 0;
+            $data['data'][$k]['getmoney'] = 0;
+            $data['data'][$k]['winmoney'] = 0;
+            $data['data'][$k]['adminadd'] = 0;
+            $data['data'][$k]['adminpull'] = 0;
+            $data['data'][$k]['recharge_send'] = 0;
+            $data['data'][$k]['back_return'] = 0;
+            $data['data'][$k]['countmoney'] = $countmoney;
+            if (is_array($countmoney) && count($countmoney) > 0) {
+                foreach ($countmoney as $sk => $sv) {
+                    if ($v['account_name'] == $sv['account_name']) {
+                        $data['data'][$k]['sendmoney'] = ($sv['trade_type'] == 14) ? ($data['data'][$k]['sendmoney'] + $sv['summoney']) : $data['data'][$k]['sendmoney'];
+                        $data['data'][$k]['savemoney'] = ($sv['trade_type'] == 6 || $sv['trade_type'] == 11 || $sv['trade_type'] == 14) ? ($data['data'][$k]['savemoney'] + $sv['summoney']) : $data['data'][$k]['savemoney'];
+                        $data['data'][$k]['getmoney'] = ($sv['trade_type'] == 5 || $sv['trade_type'] == 9) ? ($data['data'][$k]['getmoney'] + $sv['summoney']) : $data['data'][$k]['getmoney'];
+                        $data['data'][$k]['adminadd'] = ($sv['trade_type'] == 12 && $sv['money_type'] == 1) ? ($data['data'][$k]['adminadd'] + $sv['summoney']) : $data['data'][$k]['adminadd'];
+                        $data['data'][$k]['adminpull'] = ($sv['trade_type'] == 12 && $sv['money_type'] == 2) ? ($data['data'][$k]['adminpull'] + $sv['summoney']) : $data['data'][$k]['adminpull'];
+                        $data['data'][$k]['recharge_send'] = ($sv['trade_type'] == 13) ? ($data['data'][$k]['recharge_send'] + $sv['summoney']) : $data['data'][$k]['recharge_send'];
+                        $data['data'][$k]['back_return'] = ($sv['trade_type'] == 7 || $sv['trade_type'] == 8) ? ($data['data'][$k]['back_return'] + $sv['summoney']) : $data['data'][$k]['back_return'];
+                    }
+                }
+            }
+            $data['data'][$k]['winmoney'] = $data['data'][$k]['sendmoney'] + $data['data'][$k]['savemoney'] - $data['data'][$k]['getmoney'];
+        }
+        $data['data'] = arrayToNumber($data['data'], ['sendmoney', 'savemoney', 'getmoney', 'winmoney', 'adminadd', 'adminpull', 'recharge_send', 'back_return']);*/
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    //用户资金流水列表
+    function moneyWaterList()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 6;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
+        $trade_type = Request::has('trade_type') ? Request::get('trade_type') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
+        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
+        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
+        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $isuser = Request::has('isuser') ? Request::get('isuser') : 2;
+        if ($isuser == 1) {
+            $star_time = '';
+            $end_time = '';
+        }
+        $where = array();
+        if (!empty($account_name)) {
+            if (empty($sureblur) || $sureblur == '模糊') {
+                $where[] = array('money_details.account_name', 'like', '%' . $account_name . '%');
+            } else {
+                $where[] = array('money_details.account_name', '=', $account_name);
+            }
+        }
+        if (!empty($trade_type)) {
+            $where[] = array('trade_type', '=', $trade_type);
+        }
+        if (!empty($status)) {
+            $where[] = array('money_details.status', '=', $status);
+        }
+        if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $where[] = array('money_time', '>=', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $where[] = array('money_time', '<=', $end_time);
+        }
+        if (!empty($money_small)) {
+            $where[] = array('money', '>=', $money_small);
+        }
+        if (!empty($money_big)) {
+            $where[] = array('money', '<=', $money_big);
+        }
+        if (!empty($order_id)) {
+            $where = array(array('trade_id', '=', $order_id));
+        }
+
+        if (count($where) == 0) {
+            return \App\Lib\DataTable\DataTable::init()->toJson(array(), 0, 0, $where);
+        }
+        $moneydetails = new \App\Models\Money_details();
+        $data = $moneydetails->getMoneylist($where, 1, $limit, $field, $order);
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+        $usercash = array();
+        $data['data'] = arrayToNumber($data['data'], ['money']);
+        foreach ($data['data'] as $k => $v) {
+            /*if(isset($usercash[$v['account_name']])){
+                if($v['money_type'] == 1){
+                    $ccash = $usercash[$v['account_name']] + $v['money'];
+                }else{
+                    $ccash = $usercash[$v['account_name']] - $v['money'];
+                }
+                //$usercash[$v['account_name']] = $ccash;
+                if($v['money_cash'] != $ccash){
+                    $data['data'][$k]['money_cash'] = $ccash;
+                }
+            }else{
+                $usercash[$v['account_name']] = $v['money_cash'];
+            }*/
+
+            if ($v['trade_type'] == 9 && strpos($v['trade_desc'], '撤销') !== false) {
+                if (strpos($v['trade_desc'], '重新开奖') !== false) {
+                    $data['data'][$k]['isdel'] = 2;
+                } else {
+                    $data['data'][$k]['isdel'] = 1;
+                }
+            } else {
+                $data['data'][$k]['isdel'] = 2;
+            }
+            $data['data'][$k]['money_time'] = date('Y-m-d H:i:s', strtotime($v['money_time']));
+        }
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    //交易订单详情
+    function moneyDetails()
+    {
+        $tradeid = Request::has('tradeid') ? Request::get('tradeid') : '';
+        if (empty($tradeid)) {
+            return responseToJson(-3021000202); //未提交对应订单号
+        }
+        $moneydetails = new \App\Models\Money_details();
+        $data = $moneydetails->getOrderDetails($tradeid, 3, 'account_bank', 'account_identity', 'account_identity');
+
+        return responseToJson($data);
+    }
+
+    //充值记录
+    function recharge()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 6;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
+        $recharge_type = Request::has('recharge_type') ? Request::get('recharge_type') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $apply_startime = Request::get('apply_startime') ? Request::get('apply_startime') . ' 00:00:00' : '';
+        $apply_endtime = Request::get('apply_endtime') ? Request::get('apply_endtime') . ' 23:59:59' : '';
+        $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
+        $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
+        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
+        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
+        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+        if($status==-1)$status='';
+        $where = array();
+        $whereIn = array();
+        $sql = '';
+        if (!empty($recharge_type) && empty($status)) {
+            $where[] = array('recharge_type', '=', $recharge_type);
+        }
+        if (!empty($recharge_type)) {
+            $where[] = array('recharge_type', '=', $recharge_type);
+        }
+        if ($status || $status === '0') $where[] = array('status', '=', $status);
+        if (!empty($apply_startime)) {
+            $apply_startime = date('Y-m-d H:i:s', strtotime($apply_startime));
+            $where[] = array('apply_time', '>=', $apply_startime);
+        }
+        if (!empty($apply_endtime)) {
+            $apply_endtime = date('Y-m-d H:i:s', strtotime($apply_endtime));
+            $where[] = array('apply_time', '<=', $apply_endtime);
+        }
+        if (!empty($haddle_startime)) {
+            $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
+            $where[] = array('complete_time', '>=', $haddle_startime);
+        }
+        if (!empty($haddle_endtime)) {
+            $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
+            $where[] = array('complete_time', '<=', $haddle_endtime);
+        }
+        if (!empty($money_small)) {
+            $where[] = array('money', '>=', $money_small);
+        }
+        if (!empty($money_big)) {
+            $where[] = array('money', '<=', $money_big);
+        }
+
+        if (!empty($account_name)) {
+            if (empty($sureblur) || $sureblur == '模糊') {
+                $where[] = array('account_name', 'like', '%' . $account_name . '%');
+            } else {
+                $where[] = array('account_name', '=', $account_name);
+            }
+        }
+
+        if (!empty($order_id)) {
+            $where = array(array('order_id', '=', $order_id));
+        }
+        $moneydetails = new \App\Models\Money_recharge();
+
+        if ($status || (int)$status < -1) {
+            $sql = "status={$status}";
+        }
+        $data = $moneydetails->getRechargelist($where, 1, $limit, $field, $order, '', '', '', $whereIn, $sql);
+        if ($data < 0) {
+            return $data;
+        }
+        $data['data'] = arrayToNumber($data['data'], ['money', 'money_cash']);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    //待审核充值记录量获取
+    function getRechargeNum()
+    {
+        $recharge = new \App\Models\Money_recharge();
+        $status = Request::has('status') ? Request::get('status') : 1;
+        $data = $recharge->getCount($status);
+        return responseToJson(1, '', $data);
+    }
+
+    //充值订单详情
+    function rechargeDetails()
+    {
+        $orderid = Request::has('orderid') ? Request::get('orderid') : '';
+        if (empty($orderid)) {
+            return responseToJson(-3020000202); //未提交对应订单号
+        }
+        $rechargedetails = new \App\Models\Money_recharge();
+        $data = $rechargedetails->getOrderDetails($orderid, 3, 'account_bank', 'account_identity', 'account_identity');
+
+        return responseToJson($data);
+    }
+
+    //提现记录
+    function withdraw()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 'id';
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+        $grade = Request::has('grade') ? Request::get('grade') : '-1';
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
+        $bank_user = Request::has('bank_user') ? Request::get('bank_user') : '';
+        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
+        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
+        $apply_startime = Request::get('apply_startime') ? Request::get('apply_startime') . ' 00:00:00' : '';
+        $apply_endtime = Request::get('apply_endtime') ? Request::get('apply_endtime') . ' 23:59:59' : '';
+        $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
+        $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'on';
+        $status = Request::has('status') ? Request::get('status') : '';
+
+        $where = array();
+
+        if ($grade < 0) {
+            // $where .= ' AND grade=';
+            $grade = '';
+        } else {
+            $grade = ($grade == 10) ? '' : $grade;
+            $where[] = array('grade', '=', $grade);
+        }
+        if (!empty($bank_user)) {
+            $where[] = array('bank_user', 'like', '%' . $bank_user . '%');
+        }
+        if (!empty($money_small)) {
+            $where[] = array('money', '>=', $money_small);
+        }
+        if (!empty($money_big)) {
+            $where[] = array('money', '<=', $money_big);
+        }
+        if (!empty($apply_startime)) {
+            $apply_startime = date('Y-m-d H:i:s', strtotime($apply_startime));
+            $where[] = array('apply_time', '>=', $apply_startime);
+        }
+        if (!empty($apply_endtime)) {
+            $apply_endtime = date('Y-m-d H:i:s', strtotime($apply_endtime));
+            $where[] = array('apply_time', '<=', $apply_endtime);
+        }
+        if (!empty($haddle_startime)) {
+            $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
+            $where[] = array('pass_time', '>=', $haddle_startime);
+        }
+        if (!empty($haddle_endtime)) {
+            $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
+            $where[] = array('pass_time', '<=', $haddle_endtime);
+        }
+        if (!empty($status) && $status != 4) {
+            if ($status == 3) {
+                $where[] = array('status', '=', '0');
+            } else {
+                $where[] = array('status', '=', $status);
+            }
+        }
+        if (!empty($account_name)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where = array(array('account_name', 'like', '%' . $account_name . '%'));
+            } else {
+                $where = array(array('account_name', '=', $account_name));
+            }
+        }
+
+        if (!empty($order_id)) {
+            $where = array(array('order_id', '=', $order_id));
+        }
+        $takedetails = new \App\Models\Money_take();
+        $jointable = '';
+        if (is_numeric($grade)) {
+            $jointable = 'account_detailed';
+        }
+        $data = $takedetails->getTakelist($where, 1, $limit, $field, $order, $jointable, $grade);
+
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+        $take_status = trans('status.money_take.status');
+        $has_root = 0;
+        if (\App\Models\Role::hasRoot('/enable/show/bankcard') < 0) {
+            $has_root = 1;
+        }
+
+        foreach ($data['data'] as $k => $v) {
+            $data['data'][$k]['apply_time'] = $v['order_id'] . '<br>' . $v['apply_time'];
+            $data['data'][$k]['status'] = ($v['status'] == 0) ? $take_status[3] : $take_status[$v['status']];
+            // $data['data'][$k]['bank_info_no'] = $v['bank_info'] . '<br>' . bankHide($v['bank_no']);
+            $has_root == 1 ? $data['data'][$k]['bank_no'] = bankHide($v['bank_no']) : null;
+
+            $data['data'][$k]['bank_user_address'] = $v['bank_user'] . '<br>' . $v['bank_address'];
+            // $data['data'][$k]['pass_time'] = '<p style="color:red;">'.$data['data'][$k]['status'] . '<br>' . $v['pass_time'];
+        }
+        $data['data'] = arrayToNumber($data['data'], ['money']);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    //待审核提现记录量获取
+    function getTakeNum()
+    {
+        $take = new \App\Models\Money_take();
+        $status = Request::has('status') ? Request::get('status') : 3;
+        $data = $take->getCountnum($status);
+        return responseToJson(1, '', $data);
+    }
+
+    //提现订单详情
+    function withdrawDetails()
+    {
+        $orderid = Request::has('orderid') ? Request::get('orderid') : '';
+        if (empty($orderid)) {
+            return responseToJson(-3020100202); //未提交对应订单号
+        }
+        $takedetails = new \App\Models\Money_take();
+        $data = $takedetails->getOrderDetails($orderid, 3, '', '', '', 2);
+
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+        $data['trade_type'] = 5;
+
+        return responseToJson($data);
+    }
+
+    //回水记录
+    function returnList()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 6;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $order_id = Request::has('order_id') ? Request::get('order_id') : '';
+        $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
+        $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
+        $money_small = Request::has('money_small') ? Request::get('money_small') : '';
+        $money_big = Request::has('money_big') ? Request::get('money_big') : '';
+        $lossmoney_small = Request::has('lossmoney_small') ? Request::get('lossmoney_small') : '';
+        $lossmoney_big = Request::has('lossmoney_big') ? Request::get('lossmoney_big') : '';
+        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+
+        $where = array();
+        if (!empty($account_name)) {
+            if (empty($sureblur) || $sureblur == '模糊') {
+                $where[] = array('account_name', 'like', '%' . $account_name . '%');
+            } else {
+                $where[] = array('account_name', '=', $account_name);
+            }
+        }
+        if (!empty($haddle_startime)) {
+            $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
+            $where[] = array('processing_time', '>=', $haddle_startime);
+        }
+        if (!empty($haddle_endtime)) {
+            $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
+            $where[] = array('processing_time', '<=', $haddle_endtime);
+        }
+        if (!empty($money_small)) {
+            $where[] = array('money', '>=', $money_small);
+        }
+        if (!empty($money_big)) {
+            $where[] = array('money', '<=', $money_big);
+        }
+        if (!empty($lossmoney_small)) {
+            $where[] = array('total_money', '>=', $lossmoney_small);
+        }
+        if (!empty($lossmoney_big)) {
+            $where[] = array('total_money', '<=', $lossmoney_big);
+        }
+
+        if (!empty($order_id)) {
+            $where = array(array('order_id', '=', $order_id));
+        }
+        $moneydetails = new \App\Models\Money_return();
+        $data = $moneydetails->getReturnlist($where, 1, $limit, $field, $order);
+
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+
+        foreach ($data['data'] as $k => $v) {
+            $data['data'][$k]['orderid_time'] = $v['order_id'] . '<br>' . $v['processing_time'];
+        }
+        $data['data'] = arrayToNumber($data['data'], array('return_money', 'total_money'));
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    //回水订单详情
+    function returnDetails()
+    {
+        $orderid = Request::has('orderid') ? Request::get('orderid') : '';
+        if (empty($orderid)) {
+            return responseToJson(-3020200202); //未提交对应订单号
+        }
+        $returndetails = new \App\Models\Money_return();
+        $data = $returndetails->getOrderDetails($orderid, 3, 'account_bank', 'account_identity', 'account_identity');
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+        $data['trade_type'] = 8;
+
+        return responseToJson($data);
+    }
+
+    //加款扣款
+    function moneyChange()
+    {
+        $changeType = Request::has('changetype') ? Request::get('changetype') : '';
+        $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
+        $money = Request::has('money') ? Request::get('money') : '';
+        $bili = Request::has('bili') ? Request::get('bili') : 0;
+        $reson = Request::has('reson') ? Request::get('reson') : 0;
+        $orderid = Request::has('orderid') ? Request::get('orderid') : '';
+        $status = Request::has('status') ? Request::get('status') : 1; //1:成功 2:失败
+        if (empty($changeType)) {
+            return responseToJson(-3020300302); //未提交加款扣款类型 1:加款,2:扣款
+        }
+        if (empty($money)) {
+            return responseToJson(-3020300402); //操作金额不能为空
+        }
+        if (empty($account_identity)) {
+            return responseToJson(-3020300502); //未提交用户ID
+        }
+        if ($bili > 0) {
+            $money = $money * $bili;
+        }
+        //第三方充值
+        if (empty($orderid)) {
+            $res = $status; //加款扣款
+            if ($res == 1) {
+                return responseToJson($res);
+            }
+            return responseToJson(-3020300602); //加款扣款失败
+        }
+        //活动加款扣款
+        $res = $status; //加款扣款
+        if ($res == 1) {
+            return responseToJson($res);
+        }
+        return responseToJson(-3020300702); //加款扣款失败
+    }
+
+    //加款扣款用户信息获取
+    function getUser()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 'id';
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+        $account = Request::has('account_name') ? Request::get('account_name') : '';
+        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+        if (empty($account)) {
+            $data = array(
+                array(
+                    'account_name' => '',
+                    'account_identity' => '',
+                    'cash' => '',
+                ),
+            );
+            return \App\Lib\DataTable\DataTable::init()->toJson($data, 1);
+        }
+        $account = strtolower($account);
+        $where = array();
+        if (!empty($account)) {
+//			if (empty($sureblur) || $sureblur == '模糊') {
+//				$where[] = array('account', 'like', '%' . $account . '%');
+//			} else {
+            $where[] = array('account', '=', $account);
+//			}
+        }
+
+        $userdetails = new \App\Models\Account();
+        $data = $userdetails->getUserDetails($where, 3, 'account_detailed', 'identity', 'account_identity', $page, $limit, $field, $order);
+
+        if ($data < 0) {
+            return responseToJson($data); //没有用户数据
+        }
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //回水管理
+    function returnInfo()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+//		$field = Request::has('field') ? Request::get('field') : '';
+//		$order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+//		$account_name = 'gust17687';
+        $gametype = Request::has('gametype') ? Request::get('gametype') : '';
+        $lossmoney_small = Request::has('lossmoney_small') ? Request::get('lossmoney_small') : '';
+        $lossmoney_big = Request::has('lossmoney_big') ? Request::get('lossmoney_big') : '';
+        $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
+        $total_money = Request::has('total_money') ? Request::get('total_money') : '';
+
+        $where = array();
+        $user_where = array();
+        $wheregame = array();
+        $orwhere = array();
+        $having = '';
+        if (!empty($total_money)) {
+            $having = 'sum("get_money")<=' . (-$total_money);
+        }
+        if (!empty($account_name)) {
+            if (empty($sureblur) || $sureblur == '模糊') {
+                $where[] = array('account_name', 'like', '%' . $account_name . '%');
+            } else {
+                $where[] = array('account_name', '=', $account_name);
+            }
+            $user_where = array('account' => $account_name, 'status' => 4);
+        }
+        if (!empty($gametype) || $gametype != 0) {
+            $where[] = array('game_name', '=', $gametype);
+        } else {
+//			$wheregame[] = array('game_name', '=', 'xy28');
+//			$orwhere[] = array('game_name', '=', 'jnd28');
+            $wheregame = array('xy28', 'jnd28');
+        }
+        if (!empty($lossmoney_small)) {
+            $where[] = array('total_money', '>=', $lossmoney_small);
+        }
+        if (!empty($lossmoney_big)) {
+            $where[] = array('total_money', '<=', $lossmoney_big);
+        }
+        if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $where[] = array('money_time', '>=', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $where[] = array('money_time', '<=', $end_time);
+        }
+
+//        $user= new \App\Model\Account;
+//        $users=$user->Accounta($user_where);
+        $moneyreturn = new \App\Models\MoneyBuy();
+//		if ($users > 0){
+//            return responseToJson(-3020400202);
+//        }
+        $data = $moneyreturn->getMoneyReturn($where, 1, $limit, $wheregame, $orwhere, $having);
+
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+
+//		$game = trans('money');
+//        var_dump($data['data']);
+
+//		$gamearr = $game['gametype'];
+        foreach ($data['data'] as $k => $v) {
+//			$data['data'][$k]['game_name'] = $gamearr[$v['game_name']];
+            if ($v['total_money'] < 0) {
+                $data['data'][$k]['total_money'] = floatval(abs($v['total_money']));
+            } else {
+                unset($data['data'][$k]);
+            }
+
+            // $data['data'][$k]['total_money'] = floatval($v['total_money']);
+        }
+//        var_dump($data['data'])
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //回水
+    function returnAct()
+    {
+        $status = Request::has('status') ? Request::get('status') : 1; //1:成功 2:失败
+        $systemUser = Request::has('systemuser') ? Request::get('systemuser') : ''; //管理员名
+        $data = Request::has('data') ? Request::get('data') : '';
+        //$data = '{"data":[{"account_name":"147ceshi","account_identity":"3df48c6c-f805-ed8b-1d2f-e4e95f09242f","total_money":200,"status":2,"game_name":"\u5e78\u8fd028","ratio":0.1},{"account_name":"123daili","account_identity":"f243a05d-f0b4-6eee-e8ad-53472612230e","total_money":0,"status":1,"game_name":"\u5e78\u8fd028","ratio":0.1}]}';
+        if (empty($data)) {
+            return Rens(-3020400202); //未提交回水信息
+        }
+        if (empty($systemUser)) {
+            return Rens(-3020400302); //未提交操作管理员信息
+        }
+        $data = json_decode($data);
+        $data = $data->data;
+        $addData = array();
+        foreach ($data as $k => $v) {
+            $addData[] = array(
+                'info_identity' => '',
+                'order_id' => '',
+                'account_name' => $v->account_name,
+                'account_identity' => $v->account_identity,
+                'money' => $v->total_money * $v->ratio,
+                'total_money' => $v->total_money,
+                'sysetem_user' => $systemUser,
+                'processing_time' => date('Y-m-d H:i:s', time()),
+                'ratio' => $v->ratio,
+                'reason' => '',
+            );
+        }
+
+        foreach ($addData as $v) {
+            if (!empty($v)) {
+                $res = $status;
+            }
+        }
+        if ($res == 1) {
+            return Rens($res);
+        }
+        return Rens(-3020400402); //回水操作失败
+
+    }
+
+    //提现账单详情
+    function stateDetails()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 6;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        if (empty($account_name) && empty($account_identity)) {
+            return responseToJson(-3020200102); //未提交对应用户信息
+        }
+        if (empty($status)) {
+            return responseToJson(-3020200202); //未提交对应信息状态
+        }
+        $where = array();
+        if (!empty($account_name)) {
+            $where[] = array('account_name', '=', $account_name);
+        } else {
+            $where[] = array('account_identity', '=', $account_identity);
+        }
+        if ($status == 3) {
+            $where[] = array('money_take.status', '=', '0');
+        } else {
+            $where[] = array('money_take.status', '=', $status);
+        }
+
+        $takedetails = new \App\Models\Money_take();
+        $data = $takedetails->getTotalDetails($where, 1, $limit, $page, $field, $order);
+
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //充值账单详情
+    function rechargesDetails()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 6;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        if (empty($account_name) && empty($account_identity)) {
+            return responseToJson(-3020200102); //未提交对应用户信息
+        }
+        if (empty($status)) {
+            return responseToJson(-3020200202); //未提交对应信息状态
+        }
+        $where = array();
+        if (!empty($account_name)) {
+            $where[] = array('money_recharge.account_name', '=', $account_name);
+        } else {
+            $where[] = array('money_recharge.account_identity', '=', $account_identity);
+        }
+
+        $where[] = array('money_recharge.status', '=', $status);
+
+        $takedetails = new \App\Models\Money_recharge();
+        $data = $takedetails->getTotalDetails($where, 1, $limit, $page, $field, $order);
+
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //用户回水详情列表
+    function userreturnList()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 13;
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $game_name = Request::has('game_name') ? Request::get('game_name') : '';
+        if (empty($account_name) && empty($account_identity)) {
+            return responseToJson(-3020300102); //未提交对应用户信息
+        }
+        $game_name = ($game_name == '幸运28') ? 'xy28' : ($game_name == '加拿大28' ? 'jnd28' : '');
+        if (empty($game_name)) {
+            return responseToJson(-3020300202); //未提交对应游戏信息
+        }
+        $where = array();
+        $where[] = array('account_name', '=', $account_name);
+        $where[] = array('game_name', '=', $game_name);
+
+        $moneybuy = new \App\Models\MoneyBuy();
+        $data = $moneybuy->getUserReturndetail($where, 1, $limit, $field, $order);
+
+        if ($data < 0) {
+            return responseToJson($data);
+        }
+        foreach ($data['data'] as $k => $v) {
+            $data['data'][$k]['money_time'] = $v['order_id'] . '<br>' . $v['money_time'];
+        }
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //统计
+
+    /**
+     * 充值金额统计
+     * 'money description'
+     * @return 'type' 'description'
+     */
+    function rechargeMoneyCount()
+    {
+        $where = Request::has('where') ? Request::get('where') : '';
+        $db = new \App\Models\Money_recharge;
+
+        $data = $db->rechargeMoneyCount($where);
+        return responseToJson($data);
+    }
+
+    /**
+     * 提款金额统计
+     * 'money description'
+     * @return 'type' 'description'
+     */
+    function takeMoneyCount()
+    {
+        $where = Request::has('where') ? Request::get('where') : '';
+        $db = new \App\Models\Money_take;
+
+        $data = $db->takeMoneyCount($where);
+        return responseToJson($data);
+    }
+
+    /**
+     * 汇款金额统计
+     * 'money description'
+     * @return 'type' 'description'
+     */
+    function sendMoneyCount()
+    {
+        $where = Request::has('where') ? Request::get('where') : '';
+        $db = new \App\Models\Money_recharge;
+
+        $data = $db->sendMoneyCount($where);
+        return responseToJson($data);
+    }
+
+    /**
+     * 回水金额统计
+     * 'money description'
+     * @return 'type' 'description'
+     */
+    function returnMoneyCount()
+    {
+        $where = Request::has('where') ? Request::get('where') : '';
+        $db = new \App\Models\Money_return;
+
+        $data = $db->returnMoneyCount($where);
+        return responseToJson($data);
+    }
+
+    //获取交易表名后缀
+    private function getTradetable($num)
+    {
+        $type = array(
+            '1' => 'buy',
+            '2' => 'buy',
+            '3' => 'buy',
+            '4' => 'prize',
+            '5' => 'take',
+            '6' => 'recharge',
+            '7' => 'back',
+            '8' => 'return',
+            '11' => 'recharge',
+            '12' => 'recharge',
+            '13' => 'recharge',
+            '14' => 'recharge',
+        );
+        return $type[$num];
+    }
+
+    //汇款
+    function Rimit($order_id, $rale)
+    {
+        DB::beginTransaction();
+        $db = new \App\Models\Money_recharge;
+        $accountDB = new \App\Models\Account_detailed(); //用户详情
+        $info = $db->getRimitDetails($order_id);
+        if ($info < 0) {
+            return $info;
+        }
+        $limitroot = new \App\Models\System_user();
+        $limitmoney = $limitroot->checkActMoney($info['money']);
+        if ($limitmoney < 0) {
+            return $limitmoney;
+        }
+        //更新统计数据
+        $data = $info;
+        $info['complete_time'] = date('Y-m-d H:i:s');
+        $data['pass_time'] = $info['complete_time'];
+        $res = \App\Models\Money_count::AddCountinfo($data, 'save');
+        if ($res < 0) {
+            DB::rollback();//事务回滚
+            return responseToJson($res);
+        }
+        //更新数据状态
+        $res = $db->updateStatus($order_id, 1);
+        if ($res < 0) {
+            DB::rollBack();
+            return $res;
+        }
+        $acount = new \App\Models\Account_detailed;
+        $acount_info = $acount->getInfoBy($info['account_identity']);
+        $prize_moeny = 0;
+        //添加汇款详情
+        unset($info['apply_time']);
+        unset($info['complete_time']);
+        unset($info['status']);
+        unset($info['recharge_type']);
+        unset($info['recharge_type']);
+        unset($info['id']);
+        unset($info['info_identity']);
+        unset($info['money_cash']);
+        unset($info['order_id']);
+        unset($info['remark']);
+        $rate = $info['rate'] ?? 1;
+        if (isset($info['rate']))
+            unset($info['rate']);
+
+        //获取充值备注信息
+        $remarkinfo = \App\Models\Recharge_Remark::where('order_id', $order_id)->first();
+        if (!$remarkinfo) {
+            return -30010102;
+        }
+        $remarkinfo = $remarkinfo->toArray();
+        //添加汇款详情
+        $info["sysetem_user"] = session('adminInfo.admin_name');
+        $res = $this->addLog($info, 14, $acount_info['cash'], $rate, $order_id);
+        if ($res < 0) {
+            DB::rollBack();
+            return $res;
+        }
+        //更新余额
+        $rimt_res = $accountDB->addMoney($acount_info['account_identity'], $info['money']);
+        if ($rimt_res < 0) {
+            DB::rollBack();
+            return $rimt_res;
+        }
+
+        //含赠送金额时插入赠送新数据
+        if (!empty($rale)) {
+            $order_id2 = OrderID();
+            $prize_moeny = $info['money'] * $rale; //奖励金额
+            $money_cash = $prize_moeny + $acount_info['cash'] + $info['money'];
+            $data = array(
+                'money' => $prize_moeny,
+                "account_name" => $info['account_name'],
+                "account_identity" => $info['account_identity'],
+                "sysetem_user" => session('adminInfo.admin_name'),
+                "reason" => '汇款赠送1',
+                "money_cash" => $money_cash,
+            );
+            $re_data = $data;
+            $data['order_id'] = $order_id2;
+            $data['apply_time'] = date('Y-m-d H:i:s');
+            $data['complete_time'] = date('Y-m-d H:i:s');
+            $data['status'] = 1;
+            $data['recharge_type'] = '汇款赠送';
+
+            //添加充值赠送备注信息
+            $remarkdata = array(
+                'order_id' => $order_id2,
+                'name' => $remarkinfo['name'],
+                'recharge_time' => $remarkinfo['recharge_time'],
+                'money' => $prize_moeny,
+            );
+            $rminfo = \App\Models\Recharge_Remark::insert($remarkdata);
+            if (!$rminfo) {
+                DB::rollBack();
+                return -30010202;
+            }
+
+            $order_id2 = $db->addMoney($data);
+            if ($order_id2 < 0) {
+                DB::rollBack();
+                return $order_id2;
+            }
+            //添加充值详情
+            $res2 = $this->addLog($re_data, 13, ($acount_info['cash'] + $info['money']));
+            if ($res2 < 0) {
+                DB::rollBack();
+                return $res2;
+            }
+            $rimt_res = $accountDB->addMoney($data['account_identity'], $data['money']);
+            if ($rimt_res < 0) {
+                DB::rollBack();
+                return $rimt_res;
+            }
+        }
+
+        $uinfo = $accountDB->getInfoBy($acount_info['account_identity']);
+        $data = array('money_cash' => $uinfo['cash'] - $prize_moeny);
+        $res5 = $db->updateInfo($data, 'order_id', $order_id);
+        if ($res5 < 0) {
+            DB::rollBack();
+            return $res5;
+        }
+        DB::commit();
+        return 1;
+    }
+
+    //详情记录
+    function addLog($data, $type, $cash, int $rate = 1, $order_id = '')
+    {
+        $data['money_cash'] = $data['money'] + $cash;
+        $data['trade_id'] = !empty($order_id) ? $order_id : OrderID();
+        $data['trade_type'] = $type;
+        $data['money_time'] = date('Y-m-d H:i:s');
+        $data['money_type'] = 1;
+        $admin_name = session('adminInfo.admin_name');
+
+        $detailsinfo = \App\Models\Money_details::where('trade_id', $order_id)->where('trade_id', '<>', '')->first();
+        if ($detailsinfo) {
+            return -3020035022;
+        }
+        if ($type == 13) {
+            $data['trade_desc'] = sprintf(trans('trade.admin_prize_money'), $admin_name, $data['account_name'], $data['money'], $data['trade_id'], $rate);
+            $data['reason'] = '汇款赠送';
+        } else if ($type == 14) {
+            $data['trade_desc'] = sprintf(trans('trade.admin_rimit_money'), $admin_name, $data['account_name'], $data['money'], $data['trade_id'], $rate);
+            $data['reason'] = '汇款';
+        }
+        $db_money = new \App\Models\Money_details;
+        $res = $db_money->insertData($data);
+        return $res;
+    }
+
+
+    //获取提现,汇款,充值待处理内容
+    function getNum()
+    {
+        $model = new \App\Models\Money_recharge();
+        $data['rimit'] = $model::where('status', 0)->where('recharge_type', '汇款')->count();
+        $data['take'] = \App\Models\Money_take::where('status', 0)->count();
+        $data['vip'] = \App\Models\Uservip::where('status', 1)->count();
+        // $data['back'] = \App\Model\Oggame_transfer_record::where('type', 3)->count();
+        // $data['lotteryMoney'] = \App\Model\LotteryMoneyLog::where('status', 0)->count();//待审核彩金条数
+        // $msg_db = new \App\Model\MessageRead;
+        // $data['msg'] = $msg_db->countNoReade (session ('adminInfo.admin_id'));
+        // $data['agent'] = \App\Model\Agent_detailed::where ('status', 0)->count ('id');
+        return responseToJson($data);
+    }
+
+
+    /**
+     *检查用户提现规则
+     * @param $idd
+     * @param null $money
+     * @return int
+     */
+    public function checkWithdrawRule()
+    {
+        $idd = Request::has('idd') ? Request::get('idd') : '';
+        if (!$idd)
+            return responseToJson(-1, '非法操作,用户账户不能为空', '');
+        $ret = Withdraw_rule::check($idd);
+        return responseToJson($ret ? 1 : -1, $ret ? 'success' : '无结果', $ret);
+    }
+
+    /**
+     * 更新用户提现规则
+     * @param $idd
+     * @param $data
+     * @return array
+     */
+    public function changeWithDrawRule()
+    {
+
+        $idd = Request::has('idd') ? Request::get('idd') : '';
+        $start_time = Request::has('start_time') ? Request::post('start_time') : '';
+        $end_time = Request::has('end_time') ? Request::post('end_time') : '';
+        $bettingMoney = Request::has('bettingMoney') ? Request::post('bettingMoney') : 0;
+        $rate = Request::has('rate') ? Request::post('rate') : 1;
+        $needBettingMoney = Request::has('needBettingMoney') ? Request::post('needBettingMoney') : 0;
+        if (!$idd)
+            return responseToJson(-1, '非法操作,用户账户不能为空', '');
+        $ret = Withdraw_rule::updateRule($idd, $bettingMoney, $rate);
+        return responseToJson($ret ? 1 : -1, $ret ? '修改规则成功' : '修改规则失败', '');
+    }
+
+    /**
+     *添加用户提现规则
+     * @return array|int
+     */
+    public function addRule()
+    {
+        $idd = Request::has('idd') ? Request::get('idd') : '';
+        $startTime = Request::has('startTime') ? Request::post('startTime') : '';
+        $endTime = Request::has('endTime') ? Request::post('endTime') : '';
+        $bettingMoney = Request::has('bettingMoney') ? Request::post('bettingMoney') : 0;
+        $needBettingMoney = Request::has('needBettingMoney') ? Request::post('needBettingMoney') : 0;
+        if (!$idd)
+            return responseToJson(-1, '非法操作,用户账户不能为空', '');
+        if (!$startTime)
+            $startTime = time();
+        if (!$endTime)
+            $endTime = time();
+        if (!$bettingMoney || !$needBettingMoney) {
+            //return responseToJson (-1, '金额不能为空或0', '');
+        }
+        if ($bettingMoney) $data['bettingMoney'] = $bettingMoney;
+        if ($needBettingMoney) $data['needBettingMoney'] = $needBettingMoney;
+        //$ret = Withdraw_rule::setRule ($idd, $startTime, $endTime, $bettingMoney, $needBettingMoney);
+        $ret = Withdraw_rule::setRule($idd, time(), time(), 1000, 1200);
+        return responseToJson($ret ? 1 : -1, $ret ? '添加规则成功' : '添加规则失败', $ret);
+    }
+
+    /**
+     * 删除用户提现规则
+     * @return mixed
+     */
+    public function rmWithdrawRule()
+    {
+        $idd = Request::has('idd') ? Request::post('idd') : '';
+        if (!$idd)
+            return responseToJson('', '非法操作', '');
+        $ret = Withdraw_rule::rmRule($idd);
+        return responseToJson($ret ? 1 : -1, $ret ? '删除规则成功' : '删除规则失败', '');
+    }
+
+    public function getWithdrawList()
+    {
+        $data = Withdraw_rule::get();
+        //return responseToJson (1,'',$data);
+        return ['code' => 0, 'count' => count($data), 'data' => $data, 'msg' => 'success'];
+    }
+
+    /**
+     * 用户提现规则表页面
+     */
+    public function withdrawRules(Request $req)
+    {
+        $request['title'] = isset($req->title) ? trim($req->title) : '提现规则表';
+        $request['type'] = isset($req->type) ? trim($req->type) : null;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/money/getWithdrawList');
+        $dt->setLang('withdrawRule');
+        $dt->addColsFields('account_identity', ['templet' => '#account_identity']);
+        $dt->addColsFields('bettingMoney');
+        $dt->addColsFields('needBettingMoney');
+        $dt->addColsFields('start_time');
+        $dt->addColsFields('end_time');
+        //$dt->enableCheckBox ();
+        $arr[] = 'editRule';
+        $dt->setToolBar($arr, array('width' => 140));
+        return view('admin.withdraw/rules', $dt->render($request));
+    }
+
+    /**
+     * 修改用户提现规则页面
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     */
+    public function editRule()
+    {
+        $id = Request::has('id') ? Request::get('id') : '';
+        if ($id) {
+            $data = Withdraw_rule::getRule($id);
+
+            return view('admin.withdraw.editRule', ['data' => $data]);
+        }
+
+        die('error');
+    }
+
+}
+
+
+function test()
+{
+    $db = new \App\Models\Money_recharge;
+    $data = $db->text();
+    print_r($data);
+}
+

+ 224 - 0
app/Http/Controllers/Admin/MoneyListController.php

@@ -0,0 +1,224 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class MoneyListController extends Controller {
+	/**
+	 * @return 资金流水管理
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['account_name']=isset($req->account_name)?trim($req->account_name):null;
+		$request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
+		$request['trade_type'] = isset($req->trade_type) ? trim($req->trade_type) : null;
+		$request['money_small'] = isset($req->money_small) ? trim($req->money_small) : null;
+		$request['money_big'] = isset($req->money_big) ? trim($req->money_big) : null;
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) : null;
+		$request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
+        $request['status']=isset($req->status) ? trim($req->status) : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$isuser = !empty(Request::has('isuser')) ? Request::get('isuser') : 2;
+		$dt->setDataSource('/admin/money/moneyWaterList?account_name=' . $request['account_name'] . '&isuser=' . $isuser);
+		$dt->setLang('money');
+		$dt->setPriKey('trade_id');
+		$dt->addColsFields('id', array('width' => 80));
+		$dt->addColsFields('account_name', array('templet' => '#usermoneyRecord', 'width' => 110));
+		$dt->addColsFields('money_time', array('templet' => '#orderid_time','width' => 240));
+		$dt->addColsFields('change_cash', array('templet' => '#money_aftercash','width' => 290));
+		$dt->addColsFields('systemuser_ordertype', array('templet' => '#systemuser_ordertype','sort'=>false,'width' => 160));
+		$dt->addColsFields('trade_desc', array('templet' => '#ordertype','sort'=>false));
+		$dt->addColsFields('game_view', array('templet' => '#game','width' => 100,'sort'=>false,'align' => 'left'));
+
+		return view('admin.moneylist/index', $dt->render($request));
+	}
+
+	/**
+	 * 单用户资金流水列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function usermoneyRecord() {
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/moneyWaterList?account_name=' . $account_name . '&sureblur=精确');
+		$dt->setLang('money');
+		$dt->setPriKey('trade_id');
+		$dt->addColsFields('id', array('width' => 100));
+		$dt->addColsFields('account_name', array('width' => 140));
+		$dt->addColsFields('money_time', array('width' => 200));
+		$dt->addColsFields('systemuser_ordertype', array('sort' => false, 'width' => 160));
+		$dt->addColsFields('money', array('width' => 120));
+		$dt->addColsFields('reason', array('sort' => false));
+		$dt->setToolBar(array('view'), array('width' => 80));
+		return view('admin.view', $dt->render());
+	}
+
+	//查看资金流水
+	function View(Req $req) {
+		$order_id = $req->order_id;
+		if (empty($order_id)) {
+			abort(404);
+		}
+		$money_db = new \App\Models\Money_details;
+		$bank_db = new \App\Models\Account_bank;
+		$data = $money_db->getOrderDetails($order_id, 3);
+		$bank_data = $bank_db->getInfoByUid($data['account_identity']);
+
+		$data['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+		$data['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+		$data['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+		$data['money_cash'] = round($data['money_cash'],2);
+		$data['name'] = isset($bank_data['account_name']) ? $bank_data['account_name'] : '';
+		return view('admin.moneylist/view', ['data' => $data]);
+	}
+	//获取按照类型统计
+	function getCount(Req $req) {
+		$startTime = $req->startTime;
+		$endTime = $req->endTime;
+		$type = $req->type;
+		$res = $this->getSumMoney($startTime, $endTime, $type);
+		return responseToJson($res);
+	}
+    //按照类型统计总金额
+    function getSumMoney($where, $type = '') {
+        $db = new \App\Models\Money_details;
+        $where[]=array('status','=',1);
+        return $db->totalTypeMoney($where);
+    }
+    function getActive($where, $type) {
+        $db = new \App\Models\Money_details;
+        return $db->getActiveMoney($where, $type);
+    }
+    //统计总数
+    //统计总数
+    function allTotal(Req $req) {
+        $where = $req->where;
+        if (count($where) == 0) {
+        return    $where=array();
+        }
+        $data_odc=$this->getSumMoney($where);
+        $data = array();
+        //赋初值
+        $data['totalMoney']=0;
+        $data['onlineRecharge']=0;
+        $data['backstageRecharge']=0;
+        $data['remit']=0;
+        $data['rechargePrize']=0;
+        $data['active_add_money']=0;
+        $data['active_cut_money']=0;
+        $data['active_money']=0;
+        $data['back_water']=0;
+        $data['return_water']=0;
+        $data['take_money']=0;
+        $data['cut_money']=0;
+        $data['commission_addmoney']=0;
+        $data['nagentin']=0; //代理充值
+        $data['nagentout']=0; //代理代充
+
+        foreach ($data_odc as $k=>$v){
+            if($v['trade_type']==6){
+                $data['onlineRecharge']=round($v['money'],2);
+            }
+            if($v['trade_type']==11){
+                $data['backstageRecharge']=round($v['money'],2);//后台充值
+            }
+            if($v['trade_type']==14){
+                $data['remit']=round($v['money'],2);
+            }
+            if($v['trade_type']==13){
+                $data['rechargePrize']=round($v['money'],2);
+            }
+            if($v['trade_type']==12&&$v['money_type']==1){
+                $data['active_add_money']=round($v['money'],2);
+                $data['active_money']+= $data['active_add_money'];
+            }
+            if($v['trade_type']==12&&$v['money_type']==2){
+                $data['active_cut_money']=round($v['money'],2);
+                $data['active_money']+=$data['active_cut_money'];
+            }
+            if($v['trade_type']==7){
+                $data['back_water']=round($v['money'],2);
+            }
+            if($v['trade_type']==8){
+                $data['return_water']=round($v['money'],2);
+            }
+            if($v['trade_type']==5){
+                $data['take_money'] =round($v['money'],2); //5前台提现
+            }
+            if($v['trade_type']==9){
+                $data['cut_money'] = round($v['money'],2); //管理员扣款
+            }
+            if($v['trade_type']==16&&$v['money_type']==1){
+                $data['reward_addmoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==16&&$v['money_type']==2){
+                $data['reward_reducemoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==19&&$v['money_type']==1){
+                $data['conversion_addmoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==19&&$v['money_type']==2){
+                $data['conversion_reducemoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==10&&$v['money_type']==1){
+                $data['commission_addmoney']=round($v['money'],2);
+            }
+            if($v['trade_type']==22&&$v['money_type']==2){
+                $data['nagentout']=round($v['money'],2);
+            }
+            if($v['trade_type']==22&&$v['money_type']==1){
+                $data['nagentin']=round($v['money'],2);
+            }
+
+            $data['totalMoney']+=$v['money'];
+        }
+        if(empty($data['reward_addmoney'])){
+            $data['reward_addmoney'] =0;
+        }
+        if(empty($data['reward_reducemoney'])){
+            $data['reward_reducemoney'] =0;
+        }
+        if(empty($data['conversion_addmoney'])){
+            $data['conversion_addmoney'] =0;
+        }
+        if(empty($data['conversion_reducemoney'])){
+            $data['conversion_reducemoney'] =0;
+        }
+//		$data['totalMoney'] = $this->getSumMoney($where);
+//		$data['onlineRecharge'] = $this->getSumMoney($where, 6); //在线充值
+//		$data['backstageRecharge'] = $this->getSumMoney($where, 11); //后台充值
+//		$data['remit'] = $this->getSumMoney($where, 14); //14汇款
+//		$data['rechargePrize'] = $this->getSumMoney($where, 13); //13充值赠送
+        //活动金额
+//		$data['active_cut_money'] = $this->getActive($where, 2); //活动扣除
+//        $data['active_cut_money']=round($data['active_cut_money'],2);
+//        $data['totalMoney']+=$data['active_cut_money'];
+//		$data['active_add_money'] = $this->getActive($where, 1); //活动加款
+//        $data['active_add_money']=round($data['active_add_money'],2);
+//		$data['active_money'] = $this->getSumMoney($where, 12); //总活动
+
+//		$data['back_water'] = $this->getSumMoney($where, 7); //反水
+//		$data['return_water'] = $this->getSumMoney($where, 8); //回水
+//		$data['take_money'] = $this->getSumMoney($where, 5); //5前台提现
+//		$data['cut_money'] = $this->getSumMoney($where, 9); //管理员扣款
+        $data['intoTotalMoney'] = $data['onlineRecharge'] + $data['backstageRecharge'] + $data['remit'] + $data['nagentin']; //总入款扣除活动充值赠送
+        $data['cut_total_money'] = $data['cut_money'] + $data['take_money'] + $data['nagentout']; //扣款总额扣除活动充值赠送
+        $data['profit'] = $data['intoTotalMoney'] - $data['cut_total_money'];
+        $data['all_save_money'] = $data['intoTotalMoney'] + $data['active_add_money'] + $data['rechargePrize'] + $data['back_water'] + $data['return_water']; //总存款
+        $data['all_take_money'] = $data['take_money'] + $data['cut_money'] + $data['active_cut_money'] + $data['nagentout']; //总扣款
+//        $type= ['totalMoney', 'onlineRecharge', 'backstageRecharge','remit','rechargePrize','active_cut_money','active_add_money','active_money','back_water',
+//        'return_water','take_money','cut_money','intoTotalMoney','cut_total_money','profit','all_save_money','all_take_money'];
+//        $arr = arrayToNum($data,$type);
+        return responseToJson($data);
+    }
+
+}
+
+?>

+ 741 - 0
app/Http/Controllers/Admin/MoveDataController.php

@@ -0,0 +1,741 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: ikeke
+ * Date: 2018/12/4
+ * Time: 15:08
+ */
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+use DB;
+
+class MoveDataController extends Controller
+{
+    public function __construct()
+    {
+        
+    }
+
+    /*//连接数据库
+    public function connecDb($host,$port,$dbname,$user,$password){
+        $host = "host={$host}";
+        $port = "port={$port}";
+        $dbname = "dbname={$dbname}";
+        $credentials = "user={$user} password={$password}";
+        $db = pg_connect("$host $port $dbname $credentials");
+        if(!$db)return -4020000202;
+        return $db;
+    }
+
+    //查询
+    public function select($db,$sql,$type=1){
+        $data = @pg_query($db,$sql);
+        print_r($data);
+        if($type!=1){
+            $res = pg_num_rows($data);
+            return $res;
+        }
+        $resdata = array();
+        $i=0;
+        while ($row = pg_fetch_array($data,null,PGSQL_ASSOC)){
+            $resdata[$i] = $row;
+            $i++;
+        }
+        if($resdata)return $resdata;
+        return array();
+    }*/
+
+    //迁移数据
+    /*public function MovedataView(Req $req){
+        $limit = Request::has ('limit') ? Request::get ('limit') : 10;
+        $page = Request::has ('page') ? Request::get ('page') : 1;
+        $ids=isset($req->id)?trim($req->id):'all';
+        $db = $this->connecDb('192.168.2.200','5432','kaiyou2','postgres','qq123456');
+        $sql = 'select * from account';
+        $data = $this->select($db,$sql);
+        
+        $clslog = '\App\Model\Account_list';
+        $cls = '\App\Model\Account';
+        $bank = '\App\Model\Account_bank';
+        $group = '\App\Model\Account_group';
+        $userpwd = '\App\Model\Account_password';
+        $usertoken = '\App\Model\Account_Token';
+        $uservip = '\App\Model\Uservip';
+        if (!$req->isMethod('post')) {
+            if($ids=='all'){
+                $unum = $this->select($db,$sql,2);
+                $data['unum'] = empty($unum)?0:$unum;
+            }else{
+                $data['unum'] = 1;
+            }
+            
+            return view('admin.MoveData/index', array('data' => $data));
+        } else {
+            echo '<pre>';
+            $password = Request::has('rpassword') ? Request::get('rpassword') : '';
+            $allnum = Request::has('allnum') ? Request::get('allnum') : '0';
+            if (empty($password)) {
+                return responseToJson(-7010123622); //密码不能为空
+            }
+            //验证二级密码
+            //验证密码
+            $checkpwdsql = 'select * from system_user where id='.session('adminInfo.admin_id');
+            $admin_info = $this->select($db,$checkpwdsql);
+            $admin_info = current($admin_info);
+            if (!$admin_info) {
+                return responseToJson(-7010100202);
+            }
+            if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
+                return responseToJson(-7010001622);
+            }
+
+            $log = array(
+                session('adminInfo.admin_name'),
+            );
+            //$res = OperationLog(session('adminInfo.admin_id'), 'GameKjcodes', $log);
+            $identitys = array();
+            $accounts = array();
+            if($ids=='all'){
+                $offset = ($page-1) * $limit;
+                $uinfosql = 'select * from account_list orderBy id asc limit ' . $limit . ' offset ' . $offset;
+            }else{
+                $uinfosql = 'select * from account_list where id=' . $ids;
+                $allnum = 1;
+            }
+            $uinfo = $this->select($db,$uinfosql);
+            print_r($uinfo);exit;
+            $curnum = count($uinfo);
+            if(empty($uinfo) || $curnum<1)return responseToJson(-4020000102);
+            foreach ($uinfo as $k => $v) {
+                $identitys[] = $v['account_identity'];
+                $accounts[] = $v['account'];
+                $accounts[] = 'vip' . $v['account'];
+            }
+            $bankinfo = $bank::whereIn('account_identity',$identitys)->get();
+            $pwdinfo = $userpwd::whereIn('account_identity',$identitys)->get();
+            $tokeninfo = $usertoken::whereIn('account_identity',$identitys)->get();
+            $vipinfo = $uservip::whereIn('account_identity',$identitys)->get();
+            $data = array(
+                'identitys' => $identitys,
+                'accounts' => $accounts,
+                'uinfo' => $uinfo,
+                'bankinfo' => $bankinfo?$bankinfo->toArray() : array(),
+                'pwdinfo' => $pwdinfo?$pwdinfo->toArray() : array(),
+                'tokeninfo' => $tokeninfo?$tokeninfo->toArray() : array(),
+                'vipinfo' => $vipinfo?$vipinfo->toArray() : array(),
+            );
+            echo "<pre>";
+            print_r($data);exit;
+            return responseToJson(1,'',array('allnum'=>$allnum,'curnum'=>$curnum,'data'=>$data));
+        }
+    }*/
+
+    //迁移数据
+    public function MovedataView(Req $req){
+        $limit = Request::has ('limit') ? Request::get ('limit') : 10;
+        $page = Request::has ('page') ? Request::get ('page') : 1;
+        $ids=isset($req->id)?trim($req->id):'all';
+        $oldDB = DB::connection('pgsql');
+
+        $oldcls = $oldDB->table('account');
+        if (!$req->isMethod('post')) {
+            if($ids=='all'){
+                $unum = $oldcls->count('id');
+                $data['unum'] = empty($unum)?0:$unum;
+            }else{
+                $data['unum'] = 1;
+            }
+            
+            return view('admin.MoveData/index', array('data' => $data));
+        } else {
+            $oldclslog = $oldDB->table('account_list');
+            $oldbank = $oldDB->table('account_bank');
+            $oldgroup = $oldDB->table('account_group');
+            $olduserpwd = $oldDB->table('account_password');
+            $oldusertoken = $oldDB->table('account_token');
+            $olduservip = $oldDB->table('user_vip');
+            $oldadmin = $oldDB->table('system_user');
+            $oldpay = $oldDB->table('pay_password');
+            $password = Request::has('rpassword') ? Request::get('rpassword') : '';
+            $allnum = Request::has('allnum') ? Request::get('allnum') : '0';
+            if (empty($password)) {
+                return responseToJson(-7010123622); //密码不能为空
+            }
+            //验证二级密码
+            //验证密码
+            $admin_info = $oldadmin->where('id', session('adminInfo.admin_id'))->first();
+            if (!$admin_info) {
+                return responseToJson(-7010100202);
+            }
+            $admin_info = $this->toArray($admin_info);
+            if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
+                return responseToJson(-7010001622);
+            }
+            
+            $log = array(
+                session('adminInfo.admin_name'),
+            );
+            //$res = OperationLog(session('adminInfo.admin_id'), 'GameKjcodes', $log);
+            $identitys = array();
+            $accounts = array();
+            if($ids=='all'){
+                $offset = ($page-1) * $limit;
+                $uinfo = $oldclslog->limit($limit)->offset($offset)->orderBy('identity','asc')->get();
+            }else{
+                $uinfo = $oldclslog->where('id',$ids)->get();
+                $allnum = 1;
+            }
+            $uinfo = $this->toArray($uinfo);
+            $curnum = count($uinfo);
+            if(!$uinfo || $curnum<1)return responseToJson(-4020000102);
+            foreach ($uinfo as $k => $v) {
+                $identitys[] = $v['account_identity'];
+                $accounts[] = $v['account'];
+                $accounts[] = 'vip' . $v['account'];
+            }
+            $bankinfo = $oldbank->whereIn('account_identity',$identitys)->get();
+            $pwdinfo = $olduserpwd->whereIn('account_identity',$identitys)->get();
+            $tokeninfo = $oldusertoken->whereIn('account_identity',$identitys)->get();
+            $vipinfo = $olduservip->whereIn('account_identity',$identitys)->get();
+            $payinfo = $oldpay->whereIn('account_identity',$identitys)->get();
+            $data = array(
+                'identitys' => $identitys,
+                'accounts' => $accounts,
+                'uinfo' => $uinfo,
+                'bankinfo' => $this->toArray($bankinfo),
+                'pwdinfo' => $this->toArray($pwdinfo),
+                'tokeninfo' => $this->toArray($tokeninfo),
+                'vipinfo' => $this->toArray($vipinfo),
+                'payinfo' => $this->toArray($payinfo),
+            );
+            $this->AddData($data);
+            return responseToJson(1,'',array('allnum'=>$allnum,'curnum'=>$curnum,'data'=>$data));
+        }
+    }
+
+    //迁移数据到新数据库
+    function AddData($data){
+        $newDB = DB::connection('pgsql1');
+
+        $newcls = $newDB->table('account');
+        $newclslog = $newDB->table('change_record');
+        $newdetail = $newDB->table('account_detailed');
+        $newbank = $newDB->table('account_bank');
+        $newgroup = $newDB->table('account_group');
+        $newuserpwd = $newDB->table('account_password');
+        $newusertoken = $newDB->table('account_token');
+        $newuservip = $newDB->table('user_vip');
+        $newpay = $newDB->table('pay_password');
+        //获取已迁移数据信息,用于避免重复迁移
+        $hsinfo = $newclslog->select('old_identity')->whereIn('old_identity',$data['identitys'])->get();
+        $hsids = array();
+        $hsinfo = $this->toArray($hsinfo);
+        if($hsinfo && count($hsinfo)>0){
+            foreach ($hsinfo as $k => $v) {
+                $hsids[] = $v['old_identity'];
+            }
+        }
+
+        //获取分组信息
+        $groupinfo = $this->getGroupinfo($newgroup);
+        //查询重复用户名
+        $reaccount = $newcls->select('account')->whereIn('account',$data['accounts'])->get();
+        $unames = array();
+        $reaccount = $this->toArray($reaccount);
+        if($reaccount && count($reaccount)>0){
+            foreach ($reaccount as $k => $v) {
+                $unames[] = $v['account'];
+            }
+        }
+        //不迁移数据
+        $nouser = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/nouser.txt');
+        $nouser = explode(PHP_EOL, $nouser);
+
+        //组装数据
+        $cashinfo = array();
+        $account_data = array();    //会员信息
+        $accountdetail_data = array();  //会员详情数据
+        $record_data = array(); //迁移记录信息
+        foreach ($data['uinfo'] as $k => $v) {
+            if(in_array($v['account_identity'], $hsids))continue;
+            if(in_array($v['account'], $nouser)){
+                $hsids[] = $v['account_identity'];
+                continue;
+            }
+
+            $tuname = !in_array($v['account'], $unames)?$v['account'] : (!in_array('vip'.$v['account'], $unames)?'vip'.$v['account'] : $v['account'].'vip');
+            $account_data[] = array(
+                'identity' => $v['identity'],
+                'account' => $tuname,
+                'status' => $v['account_status'],
+                'fanshui' => $v['fanshui'],
+                'remark' => $v['remark'],
+            );
+            $record_data[] = array(
+                'old_user' => $v['account'],
+                'old_identity' => $v['account_identity'],
+                'new_user' => $tuname,
+                'new_identity' => $v['account_identity'],
+                'update_time' => date('Y-m-d H:i:s'),
+                'old_id' => $v['id'],
+            );
+            $accountdetail_data[] = array(
+                'identity' => $v['detail_identity'],
+                'account_identity' => $v['account_identity'],
+                'register_time' => $v['register_time'],
+                'register_ip' => $v['register_ip'],
+                'last_time' => $v['last_time'],
+                'last_ip' => $v['last_ip'],
+                'grade' => $v['grade'],
+                'email' => $v['email'],
+                'phone' => $v['phone'],
+                'invitation' => $v['invitation'],
+                'available_cash' => 0,
+                'cash' => 0,
+                'frozen_cash' => $v['frozen_cash'],
+                'open_invitation' => $v['open_invitation'],
+                'spread' => $v['spread'],
+                'placing' => $v['placing'],
+                'token' => $v['token'],
+                'statuss' => $v['statuss'],
+                'ranking' => $v['ranking'],
+                'card' => $v['card'],
+                'name' => $v['name'],
+                'show' => $v['show'],
+                'img_url' => $v['img_url'],
+                'qq' => $v['qq'],
+                'register_url' => $v['register_url'],
+                'last_url' => $v['last_url'],
+                'group_code' => $this->getGroupcode($groupinfo,$v['group_code'],$v['group_name']),
+                'group_name' => $v['group_name'],
+                'parent_id' => $v['parent_id'],
+                'parent_path' => $v['parent_path'],
+                'level' => $v['level'],
+                //'finance_cash' => $v['finance_cash'],
+            );
+            if($v['cash']<=0)continue;
+            $cashinfo[$v['account_identity']] = array(
+                'identity' => $v['account_identity'],
+                'account' => $v['account'],
+                'money' => $v['cash'],
+                'remark' => '用户活动,账号资金迁移',
+            );
+        }
+
+        //会员相关数据组装
+        $bank_data = array();   //会员银行卡信息
+        $pwd_data = array();    //会员密码数据
+        $token_data = array();  //会员token信息
+        $uservip_data = array();  //会员vip信息
+        $pay_data = array();    //支付密码信息
+        if(!empty($data['bankinfo']) && count($data['bankinfo'])>0){
+            foreach ($data['bankinfo'] as $k => $v) {
+                if(in_array($v['account_identity'], $hsids))continue;
+                $v['account_name'] = !in_array($v['account_name'], $unames)?$v['account_name'] : (!in_array('vip'.$v['account_name'], $unames)?'vip'.$v['account_name'] : $v['account_name'].'vip');
+                unset($v['id']);
+                unset($v['bank_code']);
+                $bank_data[] = $v;
+            }
+        }
+        if(!empty($data['pwdinfo']) && count($data['pwdinfo'])>0){
+            foreach ($data['pwdinfo'] as $k => $v) {
+                if(in_array($v['account_identity'], $hsids))continue;
+                unset($v['id']);
+                $pwd_data[] = $v;
+            }
+        }
+        if(!empty($data['tokeninfo']) && count($data['tokeninfo'])>0){
+            foreach ($data['tokeninfo'] as $k => $v) {
+                if(in_array($v['account_identity'], $hsids))continue;
+                unset($v['id']);
+                $token_data[] = $v;
+            }
+        }
+        if(!empty($data['vipinfo']) && count($data['vipinfo'])>0){
+            foreach ($data['vipinfo'] as $k => $v) {
+                if(in_array($v['account_identity'], $hsids))continue;
+                $v['account_name'] = !in_array($v['account_name'], $unames)?$v['account_name'] : (!in_array('vip'.$v['account_name'], $unames)?'vip'.$v['account_name'] : $v['account_name'].'vip');
+                unset($v['id']);
+                $uservip_data[] = $v;
+            }
+        }
+        if(!empty($data['payinfo']) && count($data['payinfo'])>0){
+            foreach ($data['payinfo'] as $k => $v) {
+                if(in_array($v['account_identity'], $hsids))continue;
+                unset($v['id']);
+                $pay_data[] = $v;
+            }
+        }
+
+        DB::beginTransaction ();
+        //添加数据到对应表中
+        $res = $this->addDataIntable($newcls,$account_data);
+        if($res<0){
+            DB::rollback ();
+            return $res;
+        }
+        $res = $this->addDataIntable($newdetail,$accountdetail_data);
+        if($res<0){
+            DB::rollback ();
+            return $res;
+        }
+        $res = $this->addDataIntable($newclslog,$record_data);
+        if($res<0){
+            DB::rollback ();
+            return $res;
+        }
+        $res = $this->addDataIntable($newbank,$bank_data);
+        if($res<0){
+            DB::rollback ();
+            return $res;
+        }
+        $res = $this->addDataIntable($newuserpwd,$pwd_data);
+        if($res<0){
+            DB::rollback ();
+            return $res;
+        }
+        $res = $this->addDataIntable($newusertoken,$token_data);
+        if($res<0){
+            DB::rollback ();
+            return $res;
+        }
+        $res = $this->addDataIntable($newuservip,$uservip_data);
+        if($res<0){
+            DB::rollback ();
+            return $res;
+        }
+        $res = $this->addDataIntable($newpay,$pay_data);
+        if($res<0){
+            DB::rollback ();
+            return $res;
+        }
+//print_r($cashinfo);
+        //会员加款
+        //$url = $_SERVER['HTTP_ORIGIN'] . '/admin/Regulation/Edit';
+        if(count($cashinfo)>0){
+            foreach ($cashinfo as $k => $v) {
+                //$res = $this->addMoney($url,$v);
+                $res = $this->addMoneys($v,$newDB);
+                if($res<0){
+                    DB::rollback ();
+                    return $res;
+                }
+            }
+        }
+        DB::commit ();
+        return 1;
+    }
+
+    //通过用户分组名获取用户分组代码
+    function getGroupcode($groupinfo,$group_code,$group_name){
+        if(empty($groupinfo))return $group_code;
+        $group_name = explode('|', $group_name);
+        if(count($group_name)<1)return $group_code;
+        $group_code = '0,';
+        foreach ($group_name as $k => $v) {
+            $v = trim($v);
+            if(isset($groupinfo[$v])){
+                $group_code .= $groupinfo[$v] . ',';
+            }
+        }
+        return $group_code;
+    }
+
+    //获取本站用户组信息
+    function getGroupinfo($newgroup){
+        $data = $newgroup->select('group_name','group_code')->get();
+        $data = $this->toArray($data);
+        $resdata = array();
+        if(count($data)>0){
+            foreach ($data as $k => $v) {
+                $resdata[$v['group_name']] = $v['group_code'];
+            }
+        }
+        return $resdata;
+    }
+
+    //加款
+    function addMoneys($getdata,$newDB)
+    {
+        $id = $getdata['identity'];
+        $money = $getdata['money'];
+        $remark = $getdata['remark'];
+
+        $newcls = $newDB->table('account');
+        $newrecharge = $newDB->table('money_recharge');
+        $newwith = $newDB->table('withdraw_rule');
+        $newmc = $newDB->table('money_count');
+        $newman = $newDB->table('message');
+        $newdetail = $newDB->table('account_detailed');
+        $newmdetail = $newDB->table('money_details');
+        $newlog = $newDB->table('system_log');
+
+        $admin_name = session ('adminInfo.admin_name') ? session ('adminInfo.admin_name') : '来自接口';
+
+        //检测提交数据
+        $res_data = $this->CheckaddMoney ($id, $money,$newrecharge);
+        if ($res_data < 0)return $res_data;
+        
+        $data = array(
+            'account_name' => $getdata['account'],
+            'account_identity' => $id,
+            'money' => $money,
+            'reason' => $remark,
+            'sysetem_user' => $admin_name,
+        );
+
+        //充值处理
+        //资金统计记录
+        $cdata = $data;
+        $cdata['pass_time'] = date ('Y-m-d', time ());
+        $res = $this->AddCountinfo ($cdata, $newmc);
+        if ($res < 0)return $res;
+        
+        //加钱
+        $data['money_cash'] = $money;
+        $data['rate'] = 1;
+        $trade_type = 12;
+        /***********活动加款**************/
+        $reason = str_replace ('用于活动', '!@#$', $data['reason']);
+        $order_id = $this->addMoney ($data, 1, $trade_type,$newdetail,$newman,$newrecharge,$newmdetail);//加钱
+        if ($order_id < 0)return $order_id;
+
+        $prize_money = 0;
+        $log = array(
+            session ('adminInfo.admin_name'),
+            $data['account_name'],
+            $money,
+            $prize_money,
+            $data['reason'],
+            $order_id,
+            1,
+        );
+        $this->OperationLog (session ('adminInfo.admin_id'), 'add_money', $log,$newlog);
+        return 1;
+    }
+
+    function OperationLog($id, $opt, $_data,$newlog)
+    {
+        $data = array(
+            'identity' => UUID(),
+            'status' => 1,
+            'ip' => GETIP(),
+            'operation_time' => date('Y-m-d H:i:s', time()),
+            'system_identity' => $id,
+            'operation' => vsprintf(trans('operation.' . $opt), $_data),
+        );
+        return $newlog->insert($data);
+    }
+
+    //添加最新金额到统计表
+    private function AddCountinfo($data,$newmc){
+        $mtype = 'save';
+        $ts = GetpartTime($data['pass_time']);  //获取统计周期信息
+        $type = $this->GetcountType();  //获取周期类型
+        $indata = array(
+            'account' => $data['account_name'],
+            'account_identity' => $data['account_identity'],
+            'ut_time' => $data['pass_time'],
+            $mtype => $data['money'],
+        );
+        for($i=1;$i<6;$i++){
+            $indata['count_time'] = $ts[$type[$i]];
+            switch ($i) {
+                case '1':
+                    $indata['count_alltime'] = $indata['count_time'];
+                    break;
+                case '3':
+                    $indata['count_alltime'] = $ts['year'] . '-' . $ts['month'] . '-' . $indata['count_time'];
+                    break;
+                case '4':
+                    $indata['count_alltime'] = $ts['wyear'] . '-' . $indata['count_time'];
+                    break;
+                
+                default:
+                    $indata['count_alltime'] = $ts['year'] . '-' . $indata['count_time'];
+                    break;
+            }
+            $indata['type'] = $i;
+            $indata['identity'] =$data['account_identity'] . '_' . $i . '_' . $indata['count_alltime'];
+            $res=$newmc->where('identity',$indata['identity'])->first();
+            if(!$res){
+                $res = $newmc->insert($indata);
+            }else{
+                $res = $newmc->where('identity',$indata['identity'])->increment($mtype,$data['money']);
+            }
+            if($res<1)return -300326;
+        }
+        return 1;
+    }
+
+    //周期类型
+    private function GetcountType(){
+        return $type = array(
+            '1' => 'year',
+            '2' => 'month',
+            '3' => 'day',
+            '4' => 'week',
+            '5' => 'season',
+        );
+    }
+
+    /**
+     * 加钱函数
+     * @param array $data
+     * @param int $type
+     * @param int $trade_type
+     * @param obj $newudetail
+     * @param obj $newman
+     * @param obj $newrecharge
+     * @param obj $newmdetail
+     * @return int|string
+     */
+    private function addMoney(array $data, $type, $trade_type,$newudetail,$newman,$newrecharge,$newmdetail)
+    {
+        $order_id = $this->rechargeLog ($data,$newrecharge);//充值记录
+        if ($order_id < 0)return $order_id;
+        
+        $detail=$data;
+        $detail['rate']=1;
+        $res = $this->dataLog ($detail, $order_id, $type, $trade_type,$newmdetail);
+        if ($res < 0)return $res;
+
+        //添加用户余额
+        $res1=$newudetail->where('account_identity',$data['account_identity'])->increment('available_cash',$data['money']);
+        if(!$res1)return -5040022022;//增加约失败
+        
+        $res2=$newudetail->where('account_identity',$data['account_identity'])->increment('cash',$data['money']);
+        if(!$res2)return -5040022022;//增加约失败
+
+        $this->updateMessage ('admin', $data['account_name'], '加款提示', '加款成功,加款金额:' . $data['money'], $newman);
+        return $order_id;
+    }
+
+    //添加公告数据
+    function updateMessage($sender, $reciver, $title, $content, $newman)
+    {
+        $data['add_time']=date('Y-m-d H:i:s');
+        $data['formname']=$sender;
+        $data['toname']=$reciver;
+        $data['title'] = $title;
+        $data['type'] =2;
+        $data['content'] = $content;
+        //普通消息
+        $res = $newman->insertGetId ($data);
+        if(!$res)return -6030001222;
+        return 1;
+    }
+
+    /**
+     * 添加充值/扣款详情记录函数
+     * @param array $data 详情数据数组
+     * @param mixed $order_id 充值/扣款订单号
+     * @param int $type 订单类别[1=>'充值',2=>'扣款'];
+     * @param int $trade_type 交易类型
+     * @return int|string 成功返回当前详单号,失败返回错误号
+     */
+    private function dataLog(array $data, $order_id, $type, $trade_type,$money_db)
+    {
+        $rate = 1;
+        unset($data['rate']);
+        $deal_data = $data;
+        $deal_data['money_type'] = $type;
+        $deal_data['money_time'] = date ('Y-m-d H:i:s', time ());
+        $deal_data['trade_id'] = $order_id;
+        $deal_data['trade_type'] = $trade_type;
+        $admin_name = session ('adminInfo.admin_name');
+        $admin_name = isset($admin_name) ? $admin_name : '来自接口' . GETIP ();
+        $deal_data['sysetem_user'] = $admin_name;
+        $deal_data['trade_desc'] = sprintf (trans ('trade.admin_active_money'), $admin_name, $data['account_name'], $data['money'], $order_id, $rate);
+
+        $deal_data['status'] = 1;
+        $deal_data['info_identity'] = UUID();
+        $res = $money_db->insert($deal_data);
+        if (!$res) {
+            return -2020072022; //插入资金详情失败
+        }
+        return $order_id;
+    }
+
+
+    /**
+     * 充值记录
+     * @param array $data 充值记录数据
+     * @return int|string 充值成功返回充值订单号
+     */
+    private function rechargeLog(array $data,$recharge)
+    {
+        $data['recharge_type'] = '活动充值';
+        $data['status'] = 1;
+        $data['apply_time'] = date ('Y-m-d H:i:s', time ());
+        $data['complete_time'] = date ('Y-m-d H:i:s', time ());
+        $data['rate'] = 1;
+        $data['order_id'] = OrderID (); 
+        $data['info_identity'] = UUID ();
+        $data['remark'] = '后台充值';
+        $res = $recharge->insert($data);
+        if (!$res)return -3020011322; //加款失败
+        
+        return $data['order_id'];exit;
+    }
+
+    //调用加款接口
+    /*function addMoney($url,$data){
+        $data = json_encode($data);
+        $ch = curl_init();
+        //设置选项,包括URL
+        curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页
+        curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);  //设置http验证方法
+        curl_setopt($ch, CURLOPT_TIMEOUT,30);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
+        curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
+        curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+            'X-USER-TOKEN: {{ csrf_token() }}'
+        ));
+
+        //执行并获取HTML文档内容
+        $output = curl_exec($ch);
+        $cinfo = curl_getinfo($ch);
+        //释放curl句柄
+        curl_close($ch);
+        //返回数据
+        print_r($cinfo);
+        print_r($output);
+        return $output;
+    }*/
+
+    //添加数据到对应表中
+    function addDataIntable($obj,$data){
+        if(!empty($data) && count($data)>0){
+            $res = $obj->insert($data);
+            if($res>0)return 1;
+            return -1;
+        }
+        return 1;
+    }
+
+    //验证金额
+    function CheckaddMoney($account_id, $money,$newrecharge)
+    {
+        $time = date ('Y-m-d H:i:s', time () - 10);
+        $res = $newrecharge->where ('account_identity', $account_id)->where ('money', $money)->where ('apply_time', '>', $time)->first ();
+        if (!$res) {
+            return 1;
+        }
+        return -5023809122;
+    }
+
+    //对象转数组
+    function toArray($data){
+        $data = json_encode($data);
+        $data = json_decode($data,1);
+        return $data;
+    }
+}
+

+ 236 - 0
app/Http/Controllers/Admin/NoticeController.php

@@ -0,0 +1,236 @@
+<?php
+/**
+ * 系统设置
+ */
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\ArticleType;
+use Illuminate\Http\Request as Req;
+
+/**
+ *
+ */
+class NoticeController extends Controller{
+
+    /**
+     * 活动公告
+     */
+    function Index(Req $req){
+        $request['title'] = isset($req->title) ? trim($req->title) : null;
+        $request['type'] = isset($req->type) ? trim($req->type) : null;
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/System/getArticle');
+        $dt->setLang('notice');
+         $dt->addColsFields('id',array('width' => 50));
+        $dt->addColsFields('title', array('templet' => '#title', 'sort' => false, 'width' => 120));
+        // $dt->addColsFields('content');
+        $dt->addColsFields('time');
+        $dt->addColsFields('type');
+        $dt->addColsFields('typebind');
+        $dt->addColsFields('sort',array('width' => 120));
+        $dt->addColsFields('status', array('templet' => '#closeTool', 'sort' => false, 'width' => 120));
+        $dt->enableCheckBox();
+        $arr[] = 'view';
+        if (checkRriv('/admin/Notice/Edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 140));
+        return view('admin.systemSet/arictle', $dt->render($request));
+    }
+
+    function view(Req $req){
+        return $this->Edit($req);
+    }
+
+    function Edit(Req $req){
+        $id = $req->id;
+//        $id=Request::has('id')?Request::get('id'):'';
+		if (intval($id) < 1) {
+			abort(404);
+		}
+        $acticle_type   =   new  ArticleType();
+		$db = new \App\Models\Article;
+		if (!$req->isMethod('post')) {
+			$data = $db->getDmsg($id, 1);
+			if (!$data) {
+				return responseToJson($data);
+			}
+			$datas = new \App\Models\LotteryMoney();
+        	$arr = $datas->getlist();
+//        	$admin = \App\Model\TypeName::getAllType();
+        $selectdata = $acticle_type->type();
+            $_selectdata =   $this->getTree($selectdata);
+            $select =    $data["type"];
+            $child_id   =   $data["child_id"];
+            //查出优惠活动的子类
+            $show_hui   =   $this->getTree($selectdata,3);
+            $show_hui   =   array_column($show_hui,"id");
+			return view('admin.systemSet/editNotice', ['select'=>intval($select),'data' => $data,'show_hui'=>json_encode($show_hui),/*'admin'=>$admin,*/'list'=>1,'arr'=>$arr['data'],"child_id"=>$child_id,"selectdata"=>$_selectdata]);
+		} else {
+            $data['child_id'] =$req->child_id;
+			$data['title'] = $req->input('title');
+			$data['author'] = $req->input('author');
+			$data['sort'] = $req->input('sort');
+			$data['type'] = $req->input('type');
+			$data['img'] = $req->input('img');
+			$data['typebind'] = $req->input('typebind');
+            $data['mobilecontent'] = $req->mobilecontent;
+            $data['mobileimg'] = $req->input('mobileimg');
+			$data['content'] = $req->desc;
+			$res = $db->updateMsg($data, $id);
+			$log = array(
+				session('adminInfo.admin_name'),
+				$data['title']
+			);
+			OperationLog(session('adminInfo.admin_id'), 'edit_game', $log);
+			return responseToJson($res);
+		}
+	}
+
+	/**
+	 * 批量删除
+	 * [delete description]
+	 * @return [type] [description]
+	 */
+	function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\Article::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1); //id����
+	}
+
+	function addNotice(Req $req){
+        $acticle_type = new ArticleType();
+        if (!$req->isMethod('post')) {
+        	$datas = new \App\Models\LotteryMoney();
+        	$arr = $datas->getlist();
+
+        //	$admin = \App\Model\TypeName::getAllType();
+            $selectdata = $acticle_type->type();
+
+            //查出优惠活动的子类
+            $show_hui   =   $this->getTree($selectdata,3);
+            $show_hui   =   array_column($show_hui,"id");
+
+            return view('admin.systemSet/editNotice',['select'=>0,/*'admin'=>$admin,*/'show_hui'=>json_encode($show_hui),'arr'=>$arr['data'],"child_id"=>0,"selectdata" => $this->getTree($selectdata)]);
+        }else{
+            $data['title'] = $req->input('title');
+            $data['img'] = $req->input('img');
+            $data['sort'] = $req->input('sort');
+            $data['typebind'] = $req->input('typebind');
+            $data['mobilecontent'] = $req->mobilecontent;
+            $data['mobileimg'] = $req->input('mobileimg');
+            $data['type'] =$req->type;
+            $data['child_id'] =$req->child_id;
+            $data['content'] = $req->desc;
+            $log = array(
+                session('adminInfo.admin_name'),
+                $data['title']
+            );
+
+
+            $data['time'] = date('Y-m-d H:i:s');
+            $data['author'] = session('adminInfo.admin_name');
+            $data['identity'] = UUID();
+            $db = new \App\Models\Article;
+            $res = $db->addNotice($data);
+            OperationLog(session('adminInfo.admin_id'), 'add_notice', $log);
+            return responseToJson(1);
+        }
+    }
+
+    function upImg(Req $req){
+        if (!$req->hasFile('file')) {
+            return responseToJson(-5050010022);
+        }
+        $img = $req->file('file');
+        $newFileName = md5(time() . rand(0, 10000)) . '.' . $img->getClientOriginalExtension();
+        if (!$img->isValid()) {
+            return responseToJson(-5050010122);
+        }
+        if (file_exists(public_path('/home/img') . $img->getClientOriginalName())) {
+            return responseToJson(-5050012122);
+        }
+        $newPath = public_path('/home/img');
+        $res = $img->move($newPath, $img->getClientOriginalName());
+        if ($res) {
+            $retarr = array(
+                'code' => 0,
+                'msg' => 'success',
+                'data' => array(
+                    'src' => $res->getPathname(),
+                    'title' => $img->getClientOriginalName(),
+                )
+            );
+            echo json_encode($retarr);
+        } else {
+            return responseToJson(-5050010122);
+        }
+    }
+
+    private function getTree($array, $pid = 0, $cen = 0)
+    {
+        $arr = array();
+        $cen = ++$cen;
+        $str = "";
+        foreach ($array as $k => $v) {
+            if ($v['parent_id'] == $pid) {
+                $str = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", $cen - 1);
+                $arr[] = ["id" => $v["id"], "name" => ($cen - 1 ? $str . "└" . $v["cate_name"] : $v["cate_name"])];
+                unset($array[$k]);
+                $arr = array_merge($arr, $this->getTree($array, $v['id'], $cen));
+            }
+        }
+        return $arr;
+    }
+
+    /**
+     * 关闭游戏接口
+     */
+    function activeClose(Req $req) {
+        $status = $req->has('status') ? $req->get('status') : '';
+        $active_id = $req->has('id') ? $req->get('id') : '';
+
+
+        if (empty($active_id)) {
+            return responseToJson(-5030002031);
+        }
+        if ($status < 0) {
+            return responseToJson(-5030002032);
+        }
+
+        $lottery = new \App\Models\Article();
+        $data = array(
+            'status' => $status,
+        );
+        if ($status) {
+            $data['status'] = 1;
+        } else {
+            $data['status'] = '0';
+        }
+        $res = $lottery->closeGame(["id"=>intval($active_id)],$data );
+        return responseToJson($res);
+    }
+
+}
+
+?>

+ 198 - 0
app/Http/Controllers/Admin/PaymentController.php

@@ -0,0 +1,198 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class PaymentController extends Controller {
+
+	function index(Req $req) {
+		$request['show_name'] = isset($req->show_name) ? trim($req->show_name) : null;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Payment/info');
+		$dt->setLang('payment');
+		$dt->addColsFields('infoname', array('templet' => '#infoname', 'sort' => false, 'width' => 160));
+		$dt->addColsFields('bank_num', array('sort' => false));
+		$dt->addColsFields('bank');
+        $dt->addColsFields('groups_names');
+		$dt->addColsFields('remark');
+		$dt->addColsFields('sort');
+		$dt->addColsFields('time');
+        $dt->addColsFields('type', array('templet' => '#type', 'sort' => false, 'width' => 150,'align' => 'center'));
+		$dt->addColsFields('status', array('templet' => '#status', 'sort' => false, 'width' => 150,'align' => 'left'));
+		$dt->enableCheckBox();
+		if (checkRriv('/admin/Payment/edit')) {
+			$dt->setToolBar(array('edit'));
+		}
+		return view('admin.Payment/index', $dt->render($request));
+	}
+
+	function info() {
+		$db = new \App\Models\Payment();
+		$data = $db->getInfos();
+		return \App\Lib\DataTable\DataTable::init()->toJson($data);
+	}
+
+
+    //启用/禁用会员信息
+    function UserStart(Req $req) {
+        $id = $req->id;
+        $status = is_numeric($req->status) ? intval($req->status) : '';
+        if (empty($id) || !is_numeric($status)) {
+            return responseToJson(-2020100102);
+        }
+        $u_db = new \App\Models\Payment;
+        $data = array(
+            'status' => $status,
+        );
+        $res = $u_db->updateInfos($data, $id);
+        $dd = $u_db->upInfos($id);
+        if ($status == 1) {
+            $log = array(
+                session('adminInfo.admin_name'), 
+                $dd['bank'],
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'upUserStart', $log);
+        }else {
+            $log = array(
+                session('adminInfo.admin_name'), 
+                $dd['bank'],
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'deUserStart', $log);
+        }
+        return responseToJson($res);
+    }
+
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        /***获取会员等级信息***/
+        $labelInfo=\App\Models\Account_group::getAllInfo();
+        /**********/
+        if (!$req->isMethod('post')) {
+            $data = \App\Models\Payment::where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+            $data = $data->toArray();
+            return view('admin.Payment/edit', array('data' => $data,'group'=>$labelInfo));
+        } else {
+            $groups=$req->groups?$req->groups:'';
+            //选择的组
+            $group_codes=array_keys($groups);
+            //获取组名的
+            $groups_names='| ';
+            foreach ($labelInfo as $k=>$v){
+                if(in_array($v['group_code'],$group_codes))
+                    $groups_names.=$v['group_name'].'| ';
+            }
+
+            $model = \App\Models\Payment::where('id', $id)->first();
+            $model->infoname = trim($req->input('infoname'));
+            $model->bank_num = trim($req->input('bank_num'));
+            $model->bank = trim($req->input('bank'));
+            $model->remark = trim($req->input('remark'));
+            $model->groups='0,'.implode(',',$group_codes).',';
+            $model->groups_names=$groups_names;
+            $model->sort = trim($req->input('sort'));
+            $model->time = date('Y-m-d H:i:s');
+            $model->status = trim($req->input('status'));
+            $type = trim($req->input('type'));
+            if(!empty($type)){
+                $model->type = $type;
+            }
+
+            $model->save();
+            $log = array(
+                session('adminInfo.admin_name'),
+                $model->infoname,
+                $model->bank_num,
+            );
+            OperationLog(session('adminInfo.admin_id'), 'UserStart', $log);
+            return responseToJson(1);
+        }
+
+    }
+
+    function add(Req $req) {
+        /***获取会员等级信息***/
+        $labelInfo=\App\Models\Account_group::getAllInfo();
+        /***获取会员等级信息**/
+        if (!$req->isMethod('post')) {
+            $data['status'] = 1;
+            $data['type'] = 0;
+            return view('admin.Payment/edit', ['data' => $data,'group'=>$labelInfo]);
+        } else {
+            $groups=$req->groups?$req->groups:'';
+            //选择的组
+            $group_codes=array_keys($groups);
+            //获取组名的
+            $groups_names='| ';
+            foreach ($labelInfo as $k=>$v){
+                if(in_array($v['group_code'],$group_codes))
+                    $groups_names.=$v['group_name'].'| ';
+            }
+            $model = new \App\Models\Payment();
+            $model->infoname = trim($req->input('infoname'));
+            $model->bank_num = trim($req->input('bank_num'));
+            $model->bank = trim($req->input('bank'));
+            $model->groups='0,'.implode(',',$group_codes).',';
+            $model->groups_names=$groups_names;
+            $model->remark = trim($req->input('remark'));
+            $model->sort = trim($req->input('sort'));
+            $model->time = date('Y-m-d H:i:s');
+            $model->status = 1;
+            $type = trim($req->input('type'));
+            if(!empty($type)){
+                $model->type = $type;
+            }
+            $model->save();
+            $log = array(
+                session('adminInfo.admin_name'),
+                $model->infoname,
+                $model->bank_num,
+            );
+            OperationLog(session('adminInfo.admin_id'), 'addStart', $log);
+            return responseToJson(1);
+        }
+    }
+
+    /**
+     * 批量删除
+     * [delete description]
+     * @return [type] [description]
+     */
+    function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\Payment::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        $log = array(
+           session('adminInfo.admin_name'), 
+        );
+        $res = OperationLog(session('adminInfo.admin_id'), 'deleteUserStart', $log);
+        return responseToJson(1); //id����
+    }
+}

+ 110 - 0
app/Http/Controllers/Admin/PrivController.php

@@ -0,0 +1,110 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+class PrivController extends Controller {
+
+	function addTo(Request $req) {
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setLang('priv_code');
+		$dt->setdataSource('/admin/priv/dataSource?role_id=' . $req->role_id . '&priv_code=' . $req->priv_code);
+		$dt->addColsFields('priv_name');
+		$dt->addColsFields('priv_code');
+		$dt->addColsFields('remark');
+		$dt->addColsFields('create_at');
+		$dt->addColsFields('update_at');
+		$dt->enableCheckBox();
+		return view('admin.Priv/addTo', $dt->render());
+
+	}
+
+	public function insert(Request $req) {
+
+		$id = $req->id;
+		if (empty($id)) {
+			return responseToJson(-2001); //id不能为空
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id错误
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+        //获取权限详情
+        $code_data=\App\Models\Priv_codeModel::whereIn('id',$ids)->get();
+        $code_data=$code_data->toArray();
+        //获取角色信息
+        $role_info=\App\Models\System_root::where('id',$req->role_id)->first();
+        $role_info=$role_info->toArray();
+        //组装权限角色关联数组
+        $data=array();
+        foreach ($code_data as $k=>$v){
+            $data[$k]['role_id']=$req->role_id;
+            $data[$k]['priv_id']=$v['id'];
+            $data[$k]['role_name']=$role_info['name'];
+//            $data[$k]['priv_code']=$v['priv_code'];
+            $data[$k]['create_at']=date('Y-m-d H:i:s');
+        }
+        $rows = \App\Models\Priv_roleModel::insert($data);
+		return responseToJson(1, trans('priv_role.insert_success')); //id错误
+	}
+
+	public function dataSource(Request $req) {
+		$limit = intval($req->limit) > 0 ? $req->limit : 10;
+		$page = intval($req->page) > 0 ? $req->page : 1;
+		$field = !empty($req->field) ? $req->field : '';
+		$order = !empty($req->order) ? $req->order : 'asc';
+		$model = \App\Models\Priv_codeModel::offset(($page - 1) * $limit)
+			->limit($limit);
+		if (!empty($field) && !empty($order)) {
+			$model = $model->orderBy($field, $order);
+		}
+
+		$priv_name = $req->role_name ? $req->role_name : '';
+		if (!empty($priv_name)) {
+			$model = $model->where('priv_name', 'like','%' . $priv_name . '%');
+		}
+
+		$priv_code = $req->priv_code ? $req->priv_code : '';
+		if (!empty($priv_code)) {
+			$model = $model->where('priv_code','like', '%' . $priv_code . '%');
+		}
+
+		$remark = $req->priv_id ? $req->priv_id : '';
+		if (!empty($remark)) {
+			$model = $model->where('remark','like', '%' . $remark . '%');
+		}
+		
+		$ids = \App\Models\Priv_roleModel::where('role_id', $req->role_id)->select('priv_id')->get();
+		if ($ids) {
+			$ids = $ids->toArray();
+			if (is_array($ids) && count($ids)) {
+				$ids2 = array();
+				foreach ($ids as $v) {
+					$ids2[] = $v['priv_id'];
+				}
+				$model = $model->whereNotIn('id', $ids2);
+			}
+
+		}
+
+		$data = $model->get();
+
+		if (!$data) {
+			return;
+		}
+		$data = $data->toArray();
+		$count = $model->count();
+
+		return \App\Lib\DataTable\DataTable::init()->toJson($data, $count);
+	}
+}

+ 155 - 0
app/Http/Controllers/Admin/Priv_codeController.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+class Priv_codeController extends Controller {
+
+	function add(Request $req) {
+		if (!$req->isMethod('post')) {
+			return view('admin.Priv_code/add');
+		} else {
+			$model = new \App\Models\Priv_codeModel();
+
+			$model->priv_name = trim($req->input('priv_name'));
+
+			$model->priv_code = trim($req->input('priv_code'));
+
+			$model->remark = trim($req->input('remark'));
+
+			$model->create_at = date('Y-m-d H:i:s');
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+	function getEditColsModel() {
+		return 'Priv_codeModel';
+	}
+	function view(Request $req) {
+		return $this->edit($req);
+	}
+	function edit(Request $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\Priv_codeModel::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+			return view('admin.Priv_code/view', array('priv_code' => $data));
+		} else {
+			$model = \App\Models\Priv_codeModel::where('id', $id)->first();
+
+			$model->priv_name = trim($req->input('priv_name'));
+
+			$model->priv_code = trim($req->input('priv_code'));
+
+			$model->remark = trim($req->input('remark'));
+
+			$model->update_at = date('Y-m-d H:i:s');
+
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+	public function delete(Request $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			return responseToJson(-2001); //id不能为空
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id错误
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\Priv_codeModel::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id错误
+		}
+		return responseToJson(1, trans('priv_code.delete_success')); //id错误
+
+	}
+
+	public function dataSource(Request $req) {
+		$limit = intval($req->limit) > 0 ? $req->limit : 10;
+		$page = intval($req->page) > 0 ? $req->page : 1;
+		$field = !empty($req->field) ? $req->field : '';
+		$order = !empty($req->order) ? $req->order : 'asc';
+
+		$model = \App\Models\Priv_codeModel::offset(($page - 1) * $limit)
+			->limit($limit);
+		if (!empty($field) && !empty($order)) {
+			$model = $model->orderBy($field, $order);
+		}
+
+		$priv_name = $req->priv_name ? $req->priv_name : '';
+		if (!empty($priv_name)) {
+			$model = $model->where('priv_name','like', '%' . $priv_name . '%');
+		}
+
+		$priv_code = $req->priv_code ? $req->priv_code : '';
+		if (!empty($priv_code)) {
+			$model = $model->where('priv_code', 'like','%' . $priv_code . '%');
+		}
+
+		$remark = $req->remark ? $req->remark : '';
+		if (!empty($remark)) {
+			$model = $model->where('remark', 'like','%' . $remark . '%');
+		}
+
+		/**
+		$name=$req->name?$req->name:'';
+		if(!empty($name)){
+		$model=$model->where('name','like','%'.$name.'%');
+		}
+		 **/
+
+		$data = $model->get();
+		if (!$data) {
+			return;
+		}
+		$data = $data->toArray();
+		$count = \App\Models\Priv_codeModel::count();
+		return \App\Lib\DataTable\DataTable::init()->toJson($data, $count);
+	}
+
+	public function index(Request $req) {
+		$request=array();
+		$request['priv_name']=isset($req->priv_name)?trim($req->priv_name):null;
+		$request['priv_code'] = isset($req->priv_code) ? trim($req->priv_code) : null;
+		$request['remark'] = isset($req->remark) ? trim($req->remark) : null;
+
+
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setLang('priv_code');
+		$dt->addColsFields('id', array('width' => 80));
+		$dt->addColsFields('priv_name', array('sort'=>false));
+		$dt->addColsFields('priv_code', array('sort'=>false));
+		$dt->addColsFields('remark', array('sort'=>false));
+		$dt->addColsFields('create_at');
+		$dt->addColsFields('update_at');
+		$dt->enableCheckBox();
+		$arr=array();
+		$arr[]='view';
+		if (checkRriv('/admin/Priv_code/edit')) {
+			$arr[]= 'edit';
+		}
+		$dt->setToolBar($arr, array('width' => 140));
+		return view('admin.Priv_code/index', $dt->render($request));
+	}
+}

+ 161 - 0
app/Http/Controllers/Admin/Priv_roleController.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use DB;
+
+class Priv_roleController extends Controller {
+
+	function add(Request $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$model = new \App\Models\Priv_roleModel();
+		$data = $model->getRole($id);
+		if (!$req->isMethod('post')) {
+			return view('admin.Priv_role/add', ['priv_role' => $data]);
+		} else {
+			$model->role_id = trim($req->input('role_id'));
+
+			$model->priv_code = trim($req->input('priv_code'));
+
+			$model->priv_id = trim($req->input('priv_id'));
+
+			$model->role_name = trim($req->input('role_name'));
+
+			$model->create_at = date('Y-m-d H:i:s');
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+
+	function addTo(Request $req) {
+
+		return view('admin.Priv_role/addTo');
+	}
+
+	function view(Request $req) {
+		return $this->edit($req);
+	}
+	function edit(Request $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\Priv_roleModel::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+			return view('admin.Priv_role/view', array('priv_role' => $data));
+		} else {
+			$model = \App\Models\Priv_roleModel::where('id', $id)->first();
+
+			$model->role_id = trim($req->input('role_id'));
+
+			$model->priv_code = trim($req->input('priv_code'));
+
+			$model->priv_id = trim($req->input('priv_id'));
+
+			$model->role_name = trim($req->input('role_name'));
+
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+	public function delete(Request $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			return responseToJson(-2001); //id不能为空
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id错误
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\Priv_roleModel::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id错误
+		}
+		return responseToJson(1, trans('priv_role.delete_success')); //id错误
+
+	}
+
+	public function dataSource(Request $req) {
+		$limit = intval($req->limit) > 0 ? $req->limit : 10;
+		$page = intval($req->page) > 0 ? $req->page : 1;
+		$field = !empty($req->field) ? $req->field : '';
+		$order = !empty($req->order) ? $req->order : 'asc';
+		$id = intval($req->id) > 0 ? $req->id : '';
+		DB::connection()->enableQueryLog();
+
+		$model = \App\Models\Priv_roleModel::select('dc_priv_role.id','role_id','role_name','priv.priv_code','priv_id','priv.priv_name','dc_priv_role.create_at')->join('dc_priv_code as priv','priv.id','dc_priv_role.priv_id')->where('role_id', $id);
+//		->offset(($page - 1) * $limit)
+//			->limit($limit);
+		if (!empty($field) && !empty($order)) {
+			$model = $model->orderBy($field, $order);
+		}
+
+		$role_name = $req->role_name ? $req->role_name : '';
+		if (!empty($role_name)) {
+			$model = $model->where('role_name','like', '%' . $role_name . '%');
+		}
+
+		$priv_code = $req->priv_code ? $req->priv_code : '';
+		if (!empty($priv_code)) {
+			$model = $model->where('priv.priv_code','like', "%" . $priv_code . "%");
+		}
+
+		$priv_name = $req->priv_name ? $req->priv_name : '';
+		if (!empty($priv_name)) {
+			$model = $model->where('priv_name','like', "%" . $priv_name . "%");
+		}
+
+		/**
+		$name=$req->name?$req->name:'';
+		if(!empty($name)){
+		$model=$model->where('name','like','%'.$name.'%');
+		}
+		 **/
+
+		$data = $model->paginate($limit);
+
+		if (!$data) {
+			return;
+		}
+		$data = $data->toArray();
+//		$count = $model->count();
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	public function index(Request $req) {
+		$id = $req->id;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setLang('priv_role');
+		$dt->setdataSource('/admin/priv_role/dataSource?id=' . $id);
+		$dt->addColsFields('id', array('width' => 120));
+		$dt->addColsFields('priv_name', array('sort' => false));
+		// $dt->addColsFields('priv_code');
+		$dt->addColsFields('priv_code', array('sort' => false));
+		$dt->addColsFields('role_name', array('sort' => false));
+		$dt->addColsFields('create_at', array('width' => 240));
+		$dt->enableCheckBox();
+
+		$dt->setToolBar();
+		return view('admin.Priv_role/index', $dt->render());
+	}
+
+}

+ 93 - 0
app/Http/Controllers/Admin/RechargeController.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class RechargeController extends Controller {
+	/**
+	 * @return 充值管理
+	 */
+	function index() {
+        $reqest=array();
+        $reqest['account_name'] = Request::has('account_name') ? Request::get('account_name') : '';
+        $reqest['order_id'] = Request::has('order_id') ? Request::get('order_id') : '';
+        $reqest['recharge_type'] = Request::has('recharge_type') ? Request::get('recharge_type') : '';
+        $reqest['status'] = Request::has('status') ? Request::get('status') : '';
+        $reqest['apply_startime'] = Request::get('apply_startime') ? Request::get('apply_startime') : '';
+        $reqest['apply_endtime'] = Request::get('apply_endtime') ? Request::get('apply_endtime') : '';
+        $reqest['haddle_startime'] = Request::get('haddle_startime') ? Request::get('haddle_startime') : '';
+        $reqest['haddle_endtime'] = Request::get('haddle_endtime') ? Request::get('haddle_endtime') : '';
+        $reqest['money_small'] = Request::has('money_small') ? Request::get('money_small') : '';
+        $reqest['money_big'] = Request::has('money_big') ? Request::get('money_big') : '';
+        $reqest['sureblur'] = Request::has('sureblur') ? Request::get('sureblur') : '';
+        
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$account = Request::has('account_name') ? Request::get('account_name') : '';
+		$isuser = !empty(Request::has('isuser')) ? Request::get('isuser') : 2;
+		$dt->setDataSource('/admin/money/recharge?account_name=' . $account . '&isuser=' . $isuser);
+		$dt->setLang('money');
+		$dt->setPriKey('order_id');
+		$dt->addColsFields('id', array('width' => 100));
+		$dt->addColsFields('account_name', array('templet' => '#userrecharge', 'width' => 150));
+		$dt->addColsFields('apply_time', array('templet' => '#orderid_time', 'width' => 260));
+		$dt->addColsFields('complete_time', array('templet' => '#taked', 'width' => 220));
+		// $dt->addColsFields('money', array('width' => 140));
+		// $dt->addColsFields('status', array('width' => 105));
+		$dt->addColsFields('money', array('templet' => '#money_aftercash', 'width' => 300));
+		$dt->addColsFields('systemuser_rechargetype', array('templet' => '#act_type', 'sort' => false));
+		$dt->setToolBar(array('view'), array('width' => 100,'align' => 'left'));	
+
+		return view('admin.Recharge/index', $dt->render($reqest));
+	}
+
+	/**
+	 * 单用户充值列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function userrecharge() {
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/recharge?account_name=' . $account_name . '&sureblur=精确');
+		$dt->setLang('money');
+		$dt->addColsFields('id', array('width' => 90));
+		$dt->setPriKey('order_id');
+		$dt->addColsFields('account_name', array('sort' => false, 'width' => 110));
+		$dt->addColsFields('apply_time', array('templet' => '#use', 'width' => 240));
+		$dt->addColsFields('complete_time', array('width' => 165));
+		$dt->addColsFields('money');
+		$dt->addColsFields('money_cash');
+		$dt->addColsFields('systemuser_rechargetype', array('sort' => false));
+		$dt->setToolBar(array('view'), array('width' => 100));
+		return view('admin.view', $dt->render());
+	}
+
+	//查看充值
+	function View(Req $req) {
+		$order_id = $req->order_id;
+		if (empty($order_id)) {
+			abort(404);
+		}
+		$moneydetails = new \App\Models\Money_recharge();
+		$data = $moneydetails->getOrderDetails($order_id, 3);
+		$bank = new \App\Models\Account_bank();
+		$bank_data = $bank->getInfoByUid($data['account_identity']);
+		$data['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+		$data['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+		$data['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+		$data['name'] = isset($bank_data['account_name']) ? $bank_data['account_name'] : '';
+		$remark = new \App\Models\Recharge_Remark();
+		$remark = $remark->getinfoByoid($order_id);
+		$data['remark'] = isset($remark['remark']) ? $remark['remark'] : '';
+		return view('admin.Recharge/view', ['data' => $data]);
+	}
+
+}
+
+?>

+ 160 - 0
app/Http/Controllers/Admin/RechargeDetailController.php

@@ -0,0 +1,160 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+class RechargeDetailController extends Controller {
+
+	function index() {
+		# code...
+	}
+
+	function recharge(Req $req) {
+
+        $request=array();
+        $request['betnum_small']=isset($req->betnum_small)?trim($req->betnum_small):null;
+        $request['betnum_big']=isset($req->betnum_big)?trim($req->betnum_big):null;
+        $request['betmoney_small']=isset($req->betmoney_small)?trim($req->betmoney_small):null;
+        $request['betmoney_big']=isset($req->betmoney_big)?trim($req->betmoney_big):null;
+        $request['name']=isset($req->name)?trim($req->name):null;
+        $request['status']=isset($req->status)?trim($req->status):null;
+        $request['account_name']=isset($req->account_name)?trim($req->account_name):null;
+        $request['star_time']=isset($req->star_time)?trim($req->star_time):null;
+        $request['end_time']=isset($req->end_time)?trim($req->end_time):null;
+
+
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/RechargeDetail/recharges');
+		$dt->setLang('state');
+		$dt->addColsFields('account_name', array('sort' => false, 'toolbar' => '#userrecharge', 'width' => 120));
+		$dt->addColsFields('name', array('sort' => false));
+		$dt->addColsFields('betnum', array('width' => 110));
+		$dt->addColsFields('betmoney');
+		$dt->addColsFields('recharge_type', array('sort' => false));
+		$dt->addColsFields('star_time');
+		$dt->addColsFields('end_time');
+		$dt->addColsFields('status', array('sort' => false, 'toolbar' => '#rechargeStatus'));
+		$dt->setToolBar(array('view'), array('toolbar' => '#query_status','align' => 'left'));
+		$dt->setPriKey('account_identity');
+		// $dt->setPriKey('statuss');
+		return view('admin.rechargedetail/recharge', $dt->render($request));
+	}
+
+	//报表查看
+	function View(Req $req) {
+		$id = $req->identity;
+		$status = $req->status;
+		if (empty($id)) {
+			abort(404);
+		}
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$url = '/admin/RechargeDetail/withDetail?id=' . $id . '&status=' . $status;
+		// $url = '/admin/RechargeDetail/withDetail?id=' . $id;
+		$dt->setDataSource($url);
+		$dt->setLang('rechargeDetail');
+		$dt->addColsFields('account_name', array('sort' => false,'width' => '140'));
+		$dt->addColsFields('id', array('width' => 110));
+		$dt->addColsFields('order_id', array('width' => 360));
+        $dt->addColsFields('old_money', array('width' => 150));//充值前
+		$dt->addColsFields('money', array('width' => 150));
+        $dt->addColsFields('money_cash', array('width' => 150)); //充值后
+		$dt->addColsFields('recharge_type', array('sort' => false, 'width' => 140));
+		$dt->addColsFields('apply_time', array('width' => 180));
+		$dt->addColsFields('complete_time', array('width' => 180));
+		$dt->setPriKey('identity');
+		return view('admin.rechargedetail/view', $dt->render());
+	}
+
+	/**
+	 * 充值明细
+	 * 'with description'
+	 * @return 'type' 'description'
+	 */
+	function withDetail(Req $req) {
+		$id = $req->id;
+		$tem = 'status';
+		$status = $req->$tem;
+		if (empty($id)) {
+			abort(404);
+		}
+		$db = new \App\Models\Money_recharge();
+		$data = $db::where('account_identity', $id)->where('status', $status)->orderBy('apply_time','desc')->get();
+		if (!$data) {
+			abort(404);
+		}
+		$data = $data->toArray();
+		foreach ($data as $k => $v) {
+			$data[$k]['old_money'] = sprintf("%.2f", $v['money_cash'] - $v['money']);
+            $data[$k]['money_cash'] = sprintf("%.2f", $v['money_cash']);
+		}
+		return \App\Lib\DataTable\DataTable::init()->toJson($data, count($data));
+	}
+
+	/**
+	 *充值账单
+	 * [state description]
+	 * @return [type] [description]
+	 */
+	function recharges() {
+		$page = Request::has('page') ? Request::get('page') : 1;
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$field = Request::has('field') ? Request::get('field') : 'star_time';
+		$order = Request::has('order') ? Request::get('order') : 'desc';
+
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$name = Request::has('name') ? Request::get('name') : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$betnum_small = Request::has('betnum_small') ? Request::get('betnum_small') : '';
+		$betnum_big = Request::has('betnum_big') ? Request::get('betnum_big') : '';
+		$betmoney_small = Request::has('betmoney_small') ? Request::get('betmoney_small') : '';
+		$betmoney_big = Request::has('betmoney_big') ? Request::get('betmoney_big') : '';
+		$sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+		$end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$where = array();
+		$having = array();
+
+		if (!empty($account_name)) {
+			if (empty($sureblur) || $sureblur == '模糊') {
+				$where[] = array('account_name', 'like', '%' . $account_name . '%');
+			} else {
+				$where[] = array('account_name', '=', $account_name);
+			}
+		}
+		if (!empty($name)) {
+			$where[] = array('name', 'like', '%' . $name . '%');
+		}
+		/*if (!empty($status)) {
+			if ($status == 4) {
+				$where[] = array('status', '=', '0');
+			} else {
+				$where[] = array('status', '=', $status);
+			}
+		}*/
+		if (!empty($star_time)) {
+			$where[] = array('apply_time', '>=', $star_time);
+		}
+		if (!empty($end_time)) {
+			$where[] = array('apply_time', '<=', $end_time);
+		}
+		if (!empty($betnum_small)) {
+			$having[] = 'count("order_id")>=' . $betnum_small;
+		}
+		if (!empty($betnum_big)) {
+			$having[] = 'count("order_id")<=' . $betnum_big;
+		}
+		if (!empty($betmoney_small)) {
+			$having[] = 'sum("money")>=' . $betmoney_small;
+		}
+		if (!empty($betmoney_big)) {
+			$having[] = 'sum("money")<=' . $betmoney_big;
+		}
+
+		$db = new \App\Models\Money_recharge;
+		$data = $db->getTotal($where, 1, $list, 6, 'desc', 1, $having,$status);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+}

+ 218 - 0
app/Http/Controllers/Admin/RedReturnController.php

@@ -0,0 +1,218 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\App;
+use Request;
+use DB;
+
+
+class RedReturnController extends Controller {
+
+	public function index(Req $req)	{
+		$request['type']=isset($req->type)?trim($req->type):'-1';
+        $request['lm_order_id']=$req->lm_order_id ? $req->lm_order_id : '';
+        $request['account']=$req->account ? $req->account : '';
+        $request['start_time'] = isset($req->start_time) ? trim($req->start_time) : null;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/RedReturn/getList');
+        $dt->setLang('lucky_money');
+        $dt->addColsFields('lm_order_id', array('templet' => '#lm_order_id','sort' => false,'width'=>300));
+        $dt->addColsFields('account', array('sort' => false));
+        $dt->addColsFields('room_name', array('sort' => false));
+        $dt->addColsFields('money', array('sort' => false));
+        $dt->addColsFields('num', array('sort' => false,'width'=>120));
+        $dt->addColsFields('take_num', array('sort' => false,'width'=>120));
+        $dt->addColsFields('take_money', array('sort' => false));
+        $dt->addColsFields('created_at', array('sort' => false,'width'=>160));
+        $dt->addColsFields('lm_return_money', array('sort' => false));
+        // $dt->addColsFields('type_name', array('sort' => false));
+        // $dt->addColsFields('action_d', array('templet' => '#waterTool', 'sort' => false));
+		$dt->enableCheckBox();
+
+		return view('admin.refund/redreturn', $dt->render($request));
+
+	}
+
+
+	function getList(Req $req) {
+		$list=isset($req->limit)?trim($req->limit):50;
+        $request['type']=isset($req->type)?trim($req->type):'-1';	
+        $start_time = Request::has ('start_time') ? Request::get ('start_time') : '';
+        $end_time = Request::has ('end_time') ? Request::get ('end_time') : '';
+        $account = $req->account ? $req->account : '';
+        $lm_order_id = $req->lm_order_id ? $req->lm_order_id : '';
+        $where=array();
+        if($request['type'] > '-1'){
+            $where['type'] = $request['type'];
+        }
+        if(!empty($lm_order_id)){
+            $where[]=array('lm_order_id',$lm_order_id);
+        }
+        if(!empty($account)){
+            $where[]=array('account',$account);
+        }
+        // if(!empty($user_name)){
+        //     $where[] = array('user_name', 'like', '%' . $user_name . '%');
+        // }
+
+        if (!empty($start_time)) {
+            $where[] = array('created_at', '>=', $start_time);
+        }
+        if (!empty($end_time)) {
+            $where[] = array('created_at', '<=', $end_time);
+        }
+        $langinfo = trans('lucky_money');
+        $db=new \App\Models\LuckyMoney;
+        $data=$db->getReturn($list,$where);
+        foreach ($data['data'] as $k=>$v){
+            $room_info=DB::table('chat_rooms')->where('id',$v['room_id'])->first();
+            if($room_info){
+                $data['data'][$k]['room_name']=$room_info->room_name;
+            }
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'],$data['total']);
+	}
+
+	function delete(Req $req) {
+		$get_data = $req->data;
+        $star_time=$req->star_time?$req->star_time.' 00:00:00':'';
+        $end_time=$req->end_time?$req->end_time.' 23:59:59':'';
+
+        // $room_id=$req->room_id?trim($req->room_id):'';
+        /**时间条件***/
+        $timearea=array();
+        if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $timearea[] = array('created_at', '>=', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $timearea[] = array('created_at', '<=', $end_time);
+        }
+        /**数据检验***/
+		if (!is_array($get_data)) {
+			return responseToJson(-2001);
+		}
+		$account_id_array=array();
+		foreach ($get_data as $v) {
+			if ($v['take_money'] < 0) {
+				return responseToJson(-5030021122);
+			}
+            //获取用户id数组
+            $account_id_array[]=$v['account_identity'];
+		}
+
+		$lm_order_id=array();
+		foreach ($get_data as $v) {
+			if ($v['take_money'] < 0) {
+				return responseToJson(-5030021122);
+			}
+            //获取用户id数组
+            $lm_order_id[]=$v['lm_order_id'];
+		}
+		//插入回水记录
+		$data_min_array = array(); //详情数据数组
+		$refund_money_array = array(); //详情数据数组
+		//获取用户信息
+		$account_detailed = new \App\Models\Account_detailed;
+
+        //获取用户当前余额
+        $account_cash_array=$account_detailed->getCashArray($account_id_array);
+
+        $lucky_money = new \App\Models\LuckyMoney; 
+        $refund_money = $lucky_money->getRefundArr($lm_order_id);
+        $refu_money = $lucky_money->getRefundA($lm_order_id);
+
+		//组装数据
+		foreach ($get_data as $k => $v) {
+			$order_id = OrderID();
+			$money = $v['money'] - $v['take_money'];
+			$data_min_array[$k]['account_name'] = $v['user_name'];
+			$data_min_array[$k]['account_identity'] = $v['account_identity'];
+			$data_min_array[$k]['trade_id'] = $order_id;
+			$data_min_array[$k]['money'] = $money;
+			$data_min_array[$k]['sysetem_user'] = session('adminInfo.admin_name');
+			$data_min_array[$k]['info_identity'] = UUID();
+			$data_min_array[$k]['money_time'] = date('Y-m-d H:i:s');
+			$data_min_array[$k]['money_type'] = 1;
+			$data_min_array[$k]['money_cash'] = $account_cash_array[$v['account_identity']]+$money;
+			$data_min_array[$k]['trade_type'] = 16;
+			$data_min_array[$k]['trade_desc'] = sprintf(trans('trade.admin_refund_money'), session('adminInfo.admin_name'), $v['user_name'], $money, $order_id);
+
+			$refund_money_array[$k]['lm_return_order_id'] = OrderID();
+			$refund_money_array[$k]['lm_return_money'] = $money;
+		}
+		//插入详情记录
+		$db_money_de = new \App\Models\Money_details;
+		$res_detail = $db_money_de->returnData($data_min_array);
+		if ($res_detail < 0) {
+			DB::rollback();
+			return responseToJson($res_detail);
+		}
+		//退还红包
+		foreach ($get_data as $k => $v) {
+			$money = $v['money'] - $v['take_money'];
+			$order_id = OrderID();
+			$re_money = $lucky_money->refundData($v['lm_order_id'],$money);
+			if ($re_money < 0) {
+				break;
+			}
+		}
+
+		//更新用户余额
+		foreach ($get_data as $k => $v) {
+			$money = $v['money'] - $v['take_money'];
+			$res_money = $account_detailed->addMoney($v['account_identity'], $money);
+			if ($res_money < 0) {
+				break;
+			}
+		}
+		if ($res_money < 0) {
+			DB::rollback();
+			return responseToJson($res_money);
+		}
+		//组装
+        $account_str=array();
+        $length=count($get_data);
+        $limit=0;
+        if($length>20){
+            $limit=ceil($length/20);
+        }
+        $i=0;
+		foreach ($get_data as $k=>$v){
+		    if($k<20*($i+1)){
+		        if(!isset($account_str[$i])){
+                    $account_str[$i]='';
+                }
+                $account_str[$i].=$v['user_name'].',';
+            }else{
+                $i++;
+            }
+        }
+        $log=array();
+         foreach ($account_str as $k=>$v){
+             $log[]=array(
+                 session('adminInfo.admin_name'),
+                 $v
+             );
+         }
+         foreach ($log as $v){
+            $res=OperationLog(session('adminInfo.admin_id'),'refund_money',$v);
+            if($res<0) {
+                break;
+            }
+         }
+        if($res<0){
+            DB::rollback();
+            return responseToJson($res);
+        }
+        DB::commit();
+		return responseToJson(1);
+	}
+
+
+}

+ 401 - 0
app/Http/Controllers/Admin/RedbagController.php

@@ -0,0 +1,401 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: blade
+ * Date: 2018/1/12
+ * Time: 18:42
+ */
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\App;
+use Request;
+
+class RedbagController extends Controller{
+    //页面
+    function Index(Req $req){
+        $request['red_type']=isset($req->red_type)?trim($req->red_type):null;
+        $request['system_user']=isset($req->system_user)?trim($req->system_user):null;
+        $request['input_order']=isset($req->account_name)?trim($req->account_name):null;
+        $request['startime']=isset($req->startime)?trim($req->startime):null;
+        $request['endtime']=isset($req->endtime)?trim($req->endtime):null;
+
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Redbag/getList');
+        $dt->setLang('redBag');
+        $dt->addColsFields('red_type', array('templet' => '#red_type', 'sort' => false,'width'=>120));
+        $dt->addColsFields('system_user', array('sort' => false,'width'=>140));
+        $dt->addColsFields('create_time', array('sort' => false,'width'=>190));
+        $dt->addColsFields('input_order', array('sort' => false,'width'=>240));
+        $dt->addColsFields('input_reason', array('sort' => false));
+//        $dt->addColsFields('input_rule', array('sort' => false,'templet' => '#input_rule'));//暂时无用,注释
+        $dt->addColsFields('sum_money', array('sort' => false,'width'=>100));
+        $dt->addColsFields('success_money', array('sort' => false,'width'=>100));
+        $dt->addColsFields('sum_user', array('sort' => false));
+        $dt->addColsFields('suescc_user', array('sort' => false));//成功人数
+        $dt->addColsFields('fail_user', array('sort' => false));//失败人数
+        return view('admin.redBag/index', $dt->render($request));
+
+    }
+    //数据源
+    function getList(Req $req){
+        $red_type=isset($req->red_type)?trim($req->red_type):null;
+        $system_user=isset($req->system_user)?trim($req->system_user):null;
+        $input_order=isset($req->account_name)?trim($req->account_name):null;
+        $startime=isset($req->startime)?trim($req->startime):null;
+        $endtime=isset($req->endtime)?trim($req->endtime):null;
+        $list=isset($req->limit)?trim($req->limit):50;
+        $where=array();
+        if(!empty($red_type)){
+            $where[]=array('red_type',$red_type);
+        }
+        $db=new \App\Models\MoneyRed;
+        $data=$db->getList($list,$where);
+        $regType=trans('redBag.redType');
+        foreach ($data['data'] as $k=>$v){
+            $data['data'][$k]['red_type']=$regType[$v['red_type']];
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'],$data['total']);
+    }
+
+    function  addRedBag(Req $req){
+
+        if(!$req->isMethod('post')){
+            $redType_db=new \App\Models\RedBag;
+            $type=$redType_db->getRedBagType();
+            return view('admin.redBag/addRedBag',['type'=>$type]);
+        }else{
+            //理由
+            $password=$req->password;
+            $reason=$req->reason_info?trim($req->reason_info):'';
+            $redBag_type=$req->type?intval($req->type):'';
+            $input_rule=$req->input_rule?trim($req->input_rule):'';
+            $path=$req->path?trim($req->path):'';
+            if(empty($reason)){
+                return responseToJson(-5023500012);//理由不能为空
+            }
+            if(empty($redBag_type)){
+                return responseToJson(-5023500112);//类型不能为空
+            }
+            if(empty($password)){
+                return responseToJson(-5040022122);//密码不能为空
+            }
+            if(empty($path)){
+                return responseToJson(-5040022222);//文件路径不能为空
+            }
+            //验证密码
+            $admin_info = \App\Models\System_user::where('id', session('adminInfo.admin_id'))->first();
+            if (!$admin_info) {
+                return responseToJson(-7010100202);
+            }
+            $admin_info = $admin_info->toArray();
+            if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
+                return responseToJson(-7010001622);
+            }
+            //初始化错误记录数组
+            $error_account_array=array();
+            $total_count=0;//总条数
+            //计算失败金额
+            $fail_money=0;
+            //读取文件内容
+            $data=$this->readFile($path);
+            if($data<0) {
+                return responseToJson($data);
+            }
+            //检查重复数据
+            $data=$this->checkDate($data);
+            $total_count=count($data);
+            foreach ($data as $k=>$v){
+                if(empty($v['money'])){
+                    $error_account_array[]=$v['account_name'].','.$v['money'].','.$v['reason'];
+                    $fail_money+=$v['money'];
+                    unset($data[$k]);
+                }
+            }
+            //重排序列
+            $data=array_values($data);
+
+            //获取含用户id的数据
+            $data_account=$this->getAccountDate($data);
+            //获取初始用户名数组
+//            $org_name_array=array_column($data,'account_name');
+            //获取有效用户名数组
+            $real_name_array=array_column($data_account,'account_name');
+            //记录无限用户及金额
+            foreach ($data as $v){
+                if(!in_array(trim($v['account_name']),$real_name_array)){
+                    $error_account_array[]=$v['account_name'].','.$v['money'].','.$v['reason'];
+                    $fail_money+=$v['money'];
+                }
+            }
+            if(empty($data_account)){
+                $report_data=array(
+                    'total'=>$total_count,//总条数
+                    'fail'=>count($error_account_array),//失败条数
+                    'error'=>$error_account_array,
+                    'success'=>0,
+                );
+                return responseToJson($report_data);//文件上用户均不存在
+            }
+            $out_order_id=OrderID();
+            //更新用户余额
+            $res=$this->updateCash($data_account);
+            if($res<0){
+                return responseToJson($res);
+            }
+            //添加资金记录
+            $inset_return=$this->MoneyLog($data_account,$out_order_id,$reason,$redBag_type);
+            if(is_array($inset_return['error'])&&count($inset_return['error'])>0){
+                foreach ($inset_return['error'] as $v){
+                    $error_account_array[]=$v;
+                }
+            }
+            $fail_money+=$inset_return['fail_money'];
+            $log = array(
+                session('adminInfo.admin_name'),
+                $reason,
+                $redBag_type,
+                $input_rule,
+            );
+            OperationLog(session('adminInfo.admin_id'), 'Redbag', $log);
+            $res_data=array(
+                'total'=>$total_count,//总条数
+                'fail'=>count($error_account_array),//失败条数
+                'error'=>$error_account_array,
+            );
+            $res_data['success']=$res_data['total']-$res_data['fail'];
+            //计算总金额
+            $sum_money=0;
+            foreach ($data as $k=>$v){
+                $sum_money+=$v['money'];
+            }
+            //红包记录数据
+            $data_log=array(
+                'red_type'=>$redBag_type,
+                'suescc_user'=>$res_data['success'],
+                'fail_user'=>$res_data['fail'],
+                'input_reason'=>$reason,
+                'input_rule'=>$input_rule,
+                'sum_user'=>$total_count,
+                'sum_money'=>$sum_money,
+                'success_money'=>round($sum_money-$fail_money,2),
+            );
+            $data_log['input_order']=$out_order_id;
+
+            $out_order=$this->baoLog($data_log);
+            if($out_order<0){
+                return responseToJson($out_order);
+            }
+            return responseToJson($res_data);
+        }
+    }
+    //文件上传
+    function upload(Req $req){
+//        print_r($_FILES);
+        //判断请求中是否包含name=file的上传文件
+        if(!$req->hasFile('file')){
+            return responseToJson(-5050010022);
+//                exit('上传文件为空!');
+        }
+        $file = $req->file('file');
+        //判断文件上传过程中是否出错
+        if(!$file->isValid()){
+            return responseToJson(-5050010122);
+//                exit('文件上传出错!');
+        }
+//        $path = $file->path();//文件路径
+        $store_result = $file->store('cvs');
+        $path=storage_path('app/'.$store_result);
+//        $path=str_replace('\\','/',$path);
+        $data=array(
+            'path'=>$path,
+            'name'=>$file->getClientOriginalName()
+        );
+        return responseToJson($data);
+    }
+    //读取cvs文件
+    function readFile($path){
+        $data=array();
+        $file = fopen($path,"r");
+        while(! feof($file))
+        {
+            $str=fgetcsv($file);
+//            print_r($str);
+            $str[2]=!empty($str[2])?iconv('GBK', 'UTF-8',$str[2]):' ';
+//            $data[]=fgetcsv($file);
+            $data[]=$str;
+        }
+        fclose($file);
+//        print_r($data);
+        array_shift ($data);//弹出第一姓名,金额,理由数据
+        $data=array_filter($data);
+//        print_r($data);die;
+        if(count($data)==0){
+            return -5050010222;
+        }
+        $return_array=array();
+        foreach ($data as $k=>$v){
+            if(isset($v[0])){
+                $return_array[$k]['account_name']=trim($v[0]);
+                $return_array[$k]['money']=trim($v[1]);
+                $return_array[$k]['reason']=$v[2];
+            }
+
+//            if(isset($v[2])){
+//                $return_array[$k]['reason']=mb_convert_encoding($v[2],'utf-8',mb_detect_encoding($v[2]));
+//            }else{
+//                $return_array[$k]['reason']='';
+//            }
+
+        }
+        unset($data);
+        return $return_array;
+
+    }
+    //数据检测排除重复用户和金额的钱
+    private function checkDate($data){
+        $len=count($data);
+        for($i = 0; $i < $len; $i ++) {
+            for($j = $i + 1; $j < $len; $j ++) {
+                if ($data[$i]['account_name'] == $data[$j]['account_name']&&$data[$i]['money'] == $data[$j]['money']) {
+//                    $repeat_arr [] = $data [$i];
+                    unset($data[$i]);
+                    break;
+                }
+            }
+        }
+        return $data;
+    }
+    //添加红包记录
+    private function baoLog($data){
+        $red_db=new \App\Models\MoneyRed;
+        return $red_db->insertData($data);
+    }
+
+    //更新用户余额
+    private function updateCash($data){
+        if(!is_array($data)){
+            return -5050010322;
+        }
+        $account_db=new \App\Models\Account_detailed;
+        foreach ($data as $k=>$v){
+            if($v['money']>0){
+                $res=$account_db->addMoney($v['account_identity'],$v['money']);
+                if($res<0){
+                    break;
+                }
+            }else if($v['money']<0){
+                $res=$account_db->costMoney($v['account_identity'],$v['money']);
+                if($res<0){
+                    break;
+                }
+            }
+        }
+        return $res;
+    }
+    //用户数据组装成含有用户余额及用户id的数组
+    private function getAccountDate($data){
+        $account_db=new \App\Models\Account_list;
+        //获取用户名的以为数组
+        $account_name_array=array_column($data,'account_name');
+
+        //获取用户余额,及id
+        $account_data=$account_db->getAccountCash($account_name_array);
+
+
+        foreach ($account_data as $k=>$v){
+            foreach ($data as $ka=>$va){
+                if($v['account_name']==$va['account_name']){
+                    $account_data[$k]['money']=$va['money'];
+//                    if(isset($va['reason'])){
+                    $account_data[$k]['reason']=$va['reason'];
+//                    }
+                }
+            }
+        }
+        return $account_data;
+    }
+    //添加用户资金记录
+    private function MoneyLog($data,$out_order_id,$reson,$red_type){
+        $money_db=new \App\Models\Money_details;
+        $insert_data=array();
+        $money_time=date('Y-m-d H:i:s');
+        $order_f=date('Ym');
+        $system=session('adminInfo.admin_name');
+        $order_f_red=trans('redBag.redoder');
+        $error_account_array=array();
+        $fail_money=0;
+        foreach ($data as $k=>$v){
+            $end_order=$v['money']*100;
+            $money_cash=$v['cash']+$v['money'];
+            $insert_data['trade_id']=$order_f.'_'.$v['account_name'].'_'.$end_order.$order_f_red[$red_type];
+            $insert_data['info_identity']=UUID();
+            $insert_data['money_time']=$money_time;
+            $insert_data['account_name']=$v['account_name'];
+            $insert_data['account_identity']=$v['account_identity'];
+            $insert_data['money']=abs($v['money']);
+            if($v['money']>0){
+                $insert_data['money_type']=1;
+            }else{
+                $insert_data['money_type']=2;
+            }
+            $insert_data['money_cash']=$money_cash;
+            $insert_data['trade_type']=12;
+            $insert_data['reason']=trans('redBag.redType')[$red_type].':'.$reson.$v['reason'];
+            $insert_data['trade_desc']=$system.'发放红包给:'.$v["account_name"].'金额'.$v['money'];
+            $insert_data['sysetem_user']=session('adminInfo.admin_name');
+            $insert_data['out_order_id']=$out_order_id;
+            //插入数据
+            $res=$money_db->insertData($insert_data);
+            if($res<0){
+                $error_account_array[]=$v["account_name"].','.$v['money'].','.$v['reason'];
+                $fail_money+=$v['money'];
+            }
+        }
+//        return $money_db->insertAllData($insert_data);
+        return array('error'=>$error_account_array,'fail_money'=>$fail_money);
+    }
+
+    //添加红包记录
+    function addLog(Req $req){
+        $reason=$req->reason?trim($req->reason):'';
+        $redBag_type=$req->red_type?intval($req->red_type):'';
+        $input_order=$req->input_order?trim($req->input_order):'';
+        $input_rule=$req->input_rule?trim($req->input_rule):'';
+        if(empty($reason)){
+            return responseToJson(-5023500012);//理由不能为空
+        }
+        if(empty($redBag_type)){
+            return responseToJson(-5023500112);//类型不能为空
+        }
+        $data=array(
+            'red_type'=>$redBag_type,
+            'input_order'=>$input_order,
+            'input_reason'=>$reason,
+            'input_rule'=>$input_rule,
+        );
+
+
+    }
+
+    //导出红包文件返利
+    function giveDemo(){
+        $head = '用户名, 金额, 理由';
+        $str = iconv('utf-8', 'gbk',  $head) . chr(10) . chr(9);
+        $data=array(
+            'test1',
+            100,
+            '红包'
+        );
+        $str .= iconv('utf-8', 'gbk', trim(implode(',', $data))) . chr(10) . chr(9);
+        header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment;filename="demo.csv"');
+        header('Cache-Control: max-age=0');
+
+        echo $str;
+    }
+
+}

+ 120 - 0
app/Http/Controllers/Admin/RedpackController.php

@@ -0,0 +1,120 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: lfq
+ * Date: 2018/12/1
+ * Time: 10:55
+ */
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\App;
+use Request;
+use DB;
+
+class RedpackController extends Controller{
+    //页面
+    function Index(Req $req){
+        $request['type']=isset($req->type)?trim($req->type):'-1';
+        $request['lm_order_id']=$req->lm_order_id ? $req->lm_order_id : '';
+        $request['user_name']=$req->user_name ? $req->user_name : '';
+        $request['start_time'] = isset($req->start_time) ? trim($req->start_time) : null;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
+       
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Redpack/getList?user_name='.$request['user_name']);
+        $dt->setLang('lucky_money');
+        $dt->addColsFields('lm_order_id', array('templet' => '#lm_order_id','sort' => false));
+        $dt->addColsFields('account', array('sort' => false));
+        $dt->addColsFields('room_name', array('sort' => false));
+        $dt->addColsFields('money', array('sort' => false));
+        $dt->addColsFields('num', array('sort' => false));
+        $dt->addColsFields('take_num', array('sort' => false));
+        $dt->addColsFields('take_money', array('sort' => false));
+        $dt->addColsFields('created_at', array('sort' => false,'width'=>160));
+        // $dt->addColsFields('lm_return_money', array('sort' => false));
+        $dt->addColsFields('type_name', array('sort' => false));
+        $dt->addColsFields('action_d', array('templet' => '#waterTool', 'sort' => false));
+        return view('admin.redpack/index', $dt->render($request));
+    }
+    //数据源
+    function getList(Req $req){
+        $list=isset($req->limit)?trim($req->limit):50;
+        $request['type']=isset($req->type)?trim($req->type):'-1';
+        $lm_order_id = $req->lm_order_id ? $req->lm_order_id : '';
+        // $start_time = Request::get('start_time') ? Request::get('start_time') . ' 00:00:00' : '';
+        // $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
+        $start_time = Request::has ('start_time') ? Request::get ('start_time') : '';
+        $end_time = Request::has ('end_time') ? Request::get ('end_time') : '';
+        $user_name = $req->user_name ? $req->user_name : '';
+        $where=array();
+        if($request['type'] > '-1'){
+            $where['type'] = $request['type'];
+        }
+        if(!empty($lm_order_id)){
+            $where[]=array('lm_order_id',$lm_order_id);
+        }
+        if (!empty($user_name)) {
+            $where[] = array('account', '=', $user_name);
+        }
+        if (!empty($start_time)) {
+            $where[] = array('created_at', '>=', $start_time);
+        }
+        if (!empty($end_time)) {
+            $where[] = array('created_at', '<=', $end_time);
+        }
+        $langinfo = trans('lucky_money');
+        $db=new \App\Models\LuckyMoney;
+        $data=$db->getList($list,$where);
+
+        foreach ($data['data'] as $k=>$v){
+            // $user_info=\App\Model\Account::where('identity',$v['account_identity'])->first()->toArray();
+            // $data['data'][$k]['user_name']=$user_info['account'];
+            $data['data'][$k]['type_name']=$langinfo['type'][$v['type']];
+            // $data['data'][$k]['room_name']='';
+            $room_info=DB::table('chat_rooms')->where('id',$v['room_id'])->first();
+            if($room_info){
+                $data['data'][$k]['room_name']=$room_info->room_name;
+            }
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'],$data['total']);
+    }
+    function redinfo(Req $req){
+        $request = array();
+        $request['lm_id'] = isset($req->lm_id) ? trim($req->lm_id) : null;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Redpack/getRecordList?lm_id=' . $request['lm_id']);
+        $dt->setLang('lucky_money_record');
+        $dt->addColsFields('account', array('sort' => false));
+        $dt->addColsFields('time', array('sort' => false));
+        $dt->addColsFields('money', array('sort' => false));
+        $dt->addColsFields('room_name', array('sort' => false));
+        return view('admin.redpack/redinfo', $dt->render($request));
+    }
+    function getRecordList(Req $req){
+        $list=isset($req->limit)?trim($req->limit):50;
+        $lm_id = Request::has('lm_id') ? Request::get('lm_id') : '';
+        $where=array();
+         if (!empty($lm_id)) {
+            $where[] = array('lm_id', '=', $lm_id);
+        }
+        $db=new \App\Models\LuckyMoneyTake;
+        $data=$db->getList($list,$where);
+        foreach ($data['data'] as $k=>$v){
+            $user_info=\App\Models\Account::where('identity',$v['account_identity'])->first()->toArray();
+            $data['data'][$k]['account']=$user_info['account'];
+            $data['data'][$k]['time']=date('Y-m-d H:i:s',$v['time']);
+            $data['data'][$k]['room_name']='';
+            $room_info=DB::table('chat_rooms')->where('id',$v['room_id'])->first();
+            if($room_info){
+                $data['data'][$k]['room_name']=$room_info->room_name;
+            }
+            
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'],$data['total']);
+    }
+    
+
+}

+ 302 - 0
app/Http/Controllers/Admin/RefundController.php

@@ -0,0 +1,302 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\Account_detailed;
+use App\Models\LuckyMoney;
+use App\Lib\Biz\Money\AddOrCutMoney;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\App;
+use Ramsey\Uuid\Uuid;
+use Request;
+use DB;
+
+class RefundController extends Controller {
+
+    public function index(Req $req) {
+        $request['type'] = isset($req->type) ? trim($req->type) : '-1';
+        $request['lm_order_id'] = $req->lm_order_id ? $req->lm_order_id : '';
+        $request['account'] = $req->account ? $req->account : '';
+        $request['start_time'] = isset($req->start_time) ? trim($req->start_time) : null;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : null;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Refund/getList');
+        $dt->setLang('lucky_money');
+        $dt->addColsFields('lm_order_id', array('templet' => '#lm_order_id', 'sort' => false, 'width' => 300));
+        $dt->addColsFields('account', array('sort' => false));
+        $dt->addColsFields('room_name', array('sort' => false));
+        $dt->addColsFields('money', array('sort' => false));
+        $dt->addColsFields('num', array('sort' => false, 'width' => 120));
+        $dt->addColsFields('take_num', array('sort' => false, 'width' => 120));
+        $dt->addColsFields('take_money', array('sort' => false));
+        $dt->addColsFields('created_at', array('templet' => '#created_at', 'sort' => false, 'width' => 160));
+        // $dt->addColsFields('lm_return_money', array('sort' => false));
+        // $dt->addColsFields('type_name', array('sort' => false));
+        // $dt->addColsFields('action_d', array('templet' => '#waterTool', 'sort' => false));
+        $dt->enableCheckBox();
+
+        return view('admin.refund/index', $dt->render($request));
+
+    }
+
+
+    function getList(Req $req) {
+        $list = isset($req->limit) ? trim($req->limit) : 50;
+        $request['type'] = isset($req->type) ? trim($req->type) : '-1';
+        $start_time = Request::has('start_time') ? Request::get('start_time') : '';
+        $end_time = Request::has('end_time') ? Request::get('end_time') : '';
+        $lm_order_id = $req->lm_order_id ? $req->lm_order_id : '';
+        $account = $req->account ? $req->account : '';
+        $where = array();
+        if ($request['type'] > '-1') {
+            $where['type'] = $request['type'];
+        }
+        if (!empty($lm_order_id)) {
+            $where[] = array('lm_order_id', $lm_order_id);
+        }
+        if (!empty($account)) {
+            $where[] = array('account', 'like', '%' . $account . '%');
+        }
+        if (!empty($start_time)) {
+            $where[] = array('created_at', '>=', $start_time);
+        }
+        if (!empty($end_time)) {
+            $where[] = array('created_at', '<=', $end_time);
+        }
+        $langinfo = trans('lucky_money');
+        $db = new \App\Models\LuckyMoney;
+        $data = $db->getRefund($list, $where);
+
+        foreach ($data['data'] as $k => $v) {
+            $room_info = DB::table('chat_rooms')->where('id', $v['room_id'])->first();
+            if ($room_info) {
+                $data['data'][$k]['room_name'] = $room_info->room_name;
+            }
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    function delete(Req $req) {
+        set_time_limit(0);
+        $get_data = $req->data;
+//        $star_time = $req->star_time ? $req->star_time . ' 00:00:00' : '';
+//        $end_time = $req->end_time ? $req->end_time . ' 23:59:59' : '';
+        if (!is_array($get_data)) {
+            return responseToJson(-2001);
+        }
+        $err_times = 0;
+        $s_times = 0;
+        $skip=0;
+        foreach ($get_data as $k => $v) {
+            $money = $v['money'] - $v['take_money'];
+            if ($money == 0){
+                $skip++;
+                continue;
+            }
+                $i = $this->handleRefund($v['account_identity'], $v['account'], $v['lm_order_id'], $money, session('adminInfo.admin_id'));
+            if (!$i) $err_times++;
+            else
+                $s_times++;
+        }
+        return responseToJson( ['ok' => $s_times, 'nok' => $err_times,'skip'=>$skip]);
+    }
+
+    function delete2(Req $req) {
+        $get_data = $req->data;
+        $star_time = $req->star_time ? $req->star_time . ' 00:00:00' : '';
+        $end_time = $req->end_time ? $req->end_time . ' 23:59:59' : '';
+
+        // $room_id=$req->room_id?trim($req->room_id):'';
+        /**时间条件***/
+        $timearea = array();
+        if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $timearea[] = array('created_at', '>=', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $timearea[] = array('created_at', '<=', $end_time);
+        }
+        /**数据检验***/
+        if (!is_array($get_data)) {
+            return responseToJson(-2001);
+        }
+        $account_id_array = array();
+        foreach ($get_data as $v) {
+            if ($v['take_money'] < 0) {
+                return responseToJson(-5030021122);
+            }
+            //获取用户id数组
+            $account_id_array[] = $v['account_identity'];
+        }
+
+        $lm_order_id = array();
+        foreach ($get_data as $v) {
+            if ($v['take_money'] < 0) {
+                return responseToJson(-5030021122);
+            }
+            //获取用户id数组
+            $lm_order_id[] = $v['lm_order_id'];
+        }
+        //插入回水记录
+        $data_min_array = array(); //详情数据数组
+        $refund_money_array = array(); //详情数据数组
+        //获取用户信息
+        $account_detailed = new \App\Models\Account_detailed;
+
+        //获取用户当前余额
+        $account_cash_array = $account_detailed->getCashArray($account_id_array);
+
+        $lucky_money = new \App\Models\LuckyMoney;
+        $refund_money = $lucky_money->getRefundArr($lm_order_id);
+        $refu_money = $lucky_money->getRefundA($lm_order_id);
+
+        //组装数据
+        foreach ($get_data as $k => $v) {
+            $order_id = OrderID();
+            $money = $v['money'] - $v['take_money'];
+            $data_min_array[$k]['account_name'] = $v['account'];
+            $data_min_array[$k]['account_identity'] = $v['account_identity'];
+            $data_min_array[$k]['trade_id'] = $order_id;
+            $data_min_array[$k]['money'] = $money;
+            $data_min_array[$k]['sysetem_user'] = session('adminInfo.admin_name');
+            $data_min_array[$k]['info_identity'] = UUID();
+            $data_min_array[$k]['money_time'] = date('Y-m-d H:i:s');
+            $data_min_array[$k]['money_type'] = 1;
+            $data_min_array[$k]['money_cash'] = $account_cash_array[$v['account_identity']] + $money;
+            $data_min_array[$k]['trade_type'] = 16;
+            $data_min_array[$k]['trade_desc'] = sprintf(trans('trade.admin_refund_money'), session('adminInfo.admin_name'), $v['account'], $money, $order_id);
+
+            $refund_money_array[$k]['lm_return_order_id'] = OrderID();
+            $refund_money_array[$k]['lm_return_money'] = $money;
+        }
+        //插入详情记录
+        $db_money_de = new \App\Models\Money_details;
+        $res_detail = $db_money_de->returnData($data_min_array);
+        if ($res_detail < 0) {
+            DB::rollback();
+            return responseToJson($res_detail);
+        }
+        //退还红包
+        foreach ($get_data as $k => $v) {
+            $money = $v['money'] - $v['take_money'];
+            $order_id = OrderID();
+            $re_money = $lucky_money->refundData($v['lm_order_id'], $money);
+            if ($re_money < 0) {
+                break;
+            }
+        }
+
+        //更新用户余额
+        foreach ($get_data as $k => $v) {
+            $money = $v['money'] - $v['take_money'];
+            $res_money = $account_detailed->addMoney($v['account_identity'], $money);
+            if ($res_money < 0) {
+                break;
+            }
+        }
+        if ($res_money < 0) {
+            DB::rollback();
+            return responseToJson($res_money);
+        }
+        //组装
+        $account_str = array();
+        $length = count($get_data);
+        $limit = 0;
+        if ($length > 20) {
+            $limit = ceil($length / 20);
+        }
+        $i = 0;
+        foreach ($get_data as $k => $v) {
+            if ($k < 20 * ($i + 1)) {
+                if (!isset($account_str[$i])) {
+                    $account_str[$i] = '';
+                }
+                $account_str[$i] .= $v['account'] . ',';
+            } else {
+                $i++;
+            }
+        }
+        $log = array();
+        foreach ($account_str as $k => $v) {
+            $log[] = array(
+                session('adminInfo.admin_name'),
+                $v
+            );
+        }
+        foreach ($log as $v) {
+            $res = OperationLog(session('adminInfo.admin_id'), 'refund_money', $v);
+            if ($res < 0) {
+                break;
+            }
+        }
+        if ($res < 0) {
+            DB::rollback();
+            return responseToJson($res);
+        }
+        DB::commit();
+        return responseToJson(1);
+    }
+
+    /**
+     * 退红包函数
+     * @param $account_id
+     * @param $account_name
+     * @param $lm_id
+     * @param $money
+     * @param $admin
+     * @return bool
+     */
+
+    protected function handleRefund($account_id, $account_name, $lm_id, $money, $admin): bool {
+        $ad = new Account_detailed();
+        $adObj = $ad->where('account_identity', $account_id)->first();
+        DB::beginTransaction();
+        $rlm_id = UUID();
+        $aoc = new AddOrCutMoney();
+        $trade_id = OrderID();
+        $date = date('Y-m-d H:i:s');
+        $trad_desc = sprintf("管理员%s于{$date}退还了%s发起的红包余额%s元(红包ID:%s),退还单号为%s", $admin, $account_name, $money, $lm_id, $rlm_id);
+        $reason = '红包退还';
+        $ret = $aoc->addMoneyDetailRec($adObj, $account_name, $trade_id, $money, 1, 16, $admin, $trad_desc, $reason);
+        if (is_int($ret)) {
+            DB::rollBack();
+            return false;
+        }
+        $ret = DB::table('lucky_money')->where('lm_order_id', $lm_id)->update([
+            'lm_return_order_id' => $rlm_id,
+            'lm_return_money' => $money,
+            'updated_at' => date('Y-m-d H:i:s'),
+        ]);//更新红包退还数据
+
+        if ($ret !== 1) {
+            DB::rollBack();
+            return false;
+        }
+        $detail = $trad_desc;
+        $ret = $aoc->addMoneyRechargeRec($adObj, $account_name, $trade_id, $money, '红包退还', $admin, $reason, $detail, 0, 1);//添加充值详情
+        if (is_int($ret)) {
+            DB::rollBack();
+            return false;
+        }
+        $ret = $aoc->incAccountDetailMoney($adObj, $money);//更新用户余额
+        if ($ret !== 1) {
+            DB::rollBack();
+            return false;
+        }
+        $res = OperationLog($admin = session('adminInfo.admin_id'), 'refund_money', [$admin, $account_name, $money]);
+        if ($res < 0) {
+            DB::rollBack();
+            return false;
+        }
+        $ret=DB::table('chat_redbag')->where('redid',$lm_id)->delete();
+        if(!is_int($ret)){
+            DB::rollBack();
+            return false;
+        }
+        DB::commit();
+        return true;
+    }
+
+}

+ 523 - 0
app/Http/Controllers/Admin/RegulationController.php

@@ -0,0 +1,523 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\Withdraw_rule;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class RegulationController extends Controller
+{
+//    private $token='so5j3C150405826059a61b94de9df';
+    /**
+     * @return 加款扣款
+     */
+    function index()
+    {
+        $request = array();
+        $request['account_name'] = Request::has ('account_name') ? Request::get ('account_name') : '';
+        $dt = \App\Lib\DataTable\DataTable::init ();
+        $dt->setDataSource ('/admin/money/getUser');
+        $dt->setLang ('money');
+        $dt->addColsFields ('id', array('width' => 100));
+        $dt->addColsFields ('account_name', array('templet' => '#userRegulation', 'width' => 140));
+        $dt->addColsFields ('cash', array('width' => 120));
+//		$dt->addColsFields('add_money');
+        $dt->addColsFields ('add_money', array('sort' => false, 'templet' => '#add_money'));
+        $dt->addColsFields ('cut_money', array('sort' => false, 'templet' => '#cut_money'));
+//		$dt->addColsFields('takeoff_money');
+//		$dt->setToolBar(array('add','cut'));
+        return view ('admin.Regulation/index', $dt->render ($request));
+    }
+
+    function add()
+    {
+        echo 123;
+    }
+
+    //查看充值
+    function Edit(Req $req)
+    {
+        $id = $req->id;
+        $identity = isset($req->identity)?$req->identity:'';
+        $type = $req->type;
+        if ((empty($id) || $id < 1) && empty($identity)) {
+            echo '请选择加扣款用户';
+            abort (404);
+        }
+        $keyv = empty($id)?2:1;
+        $id = empty($id)?$identity:$id;
+        $account_db = new \App\Models\Account(); //用户
+        $rate = $req->rate ?? 1;
+        if (!$req->isMethod ('post')) {
+            $data = $account_db->getUserDetails ($id, $keyv, 'account_detailed', 'identity', 'account_identity');
+            $data = $data['data'][0];
+
+            return view ('admin.Regulation/edit', ['data' => $data, 'type' => $type]);
+        } else {
+            $money = $req->money;
+            $remark = $req->remark;
+            $bate = $req->peize_bate;
+            $order_id = $req->order_id;
+
+            if (!is_numeric ($money) || $money < 0) {
+                return responseToJson (-3010025022);//提交金额必须为大于0的数字
+            }
+            if (!is_numeric ($bate) || $money < 0) {
+                return responseToJson (-3010025122);//奖励百分比金额必须为大于0的数字
+            }
+            //验证可操作金额限额
+            $limitroot = new \App\Models\System_user();
+            $limitmoney = $limitroot->checkActMoney ($money);
+            if ($limitmoney < 0) {
+                return responseToJson ($limitmoney);
+            }
+
+            DB::beginTransaction ();
+            $prize_money = $money * $bate / 100;//奖励金额
+            $admin_name = session ('adminInfo.admin_name') ? session ('adminInfo.admin_name') : '来自接口';
+            //获取用户信息
+            $account_data = $account_db->getUserDetails ($id, $keyv, 'account_detailed', 'identity', 'account_identity');
+            $account_data = current ($account_data['data']);
+
+            //检测提交数据
+            $res_data = $this->CheckaddMoney ($account_data['identity'], $money);
+            if ($res_data < 0) {
+                DB::rollback ();
+                return responseToJson ($res_data);
+            }
+            $data = array(
+                'account_name' => $account_data['account_name'],
+                'account_identity' => $account_data['identity'],
+                'money' => $money,
+                'reason' => $remark,
+                'sysetem_user' => $admin_name,
+            );
+            if ($type == 1) {
+                //充值处理
+                //资金统计记录
+                $cdata = $data;
+                $cdata['pass_time'] = date ('Y-m-d', time ());
+                $res = \App\Models\Money_count::AddCountinfo ($cdata, 'save');
+
+                if ($res < 0) {
+                    DB::rollback ();
+                    return responseToJson ($res);
+                }
+                //加钱
+                $money_cash = $account_data['cash'] + $money;
+                $data['money_cash'] = $money_cash;
+                $data['rate'] = $rate;
+                $trade_type = 11;
+                /***********活动加款**************/
+                $reason = str_replace ('用于活动', '!@#$', $data['reason']);
+                if (strstr ($reason, '!@#$')) {
+                    $trade_type = 12;
+                    $prize_money = '';
+                    //添加流水倍率数据
+                    $res_data = Withdraw_rule::updateRule ($account_data['identity'], $money, $rate);
+                    if ($res_data < 0) {
+                        DB::rollback ();
+                        return responseToJson ($res_data);
+                    }
+                }
+                $order_id = $this->addMoney ($data, $type, $trade_type, $order_id, '', '', $rate);//加钱
+                if ($order_id < 0) {
+                    DB::rollback ();
+                    return responseToJson ($order_id);
+                }
+                //赠送金额
+                if (!empty($prize_money)) {
+                    $data['money'] = $prize_money;//重置金额
+                    $trade_type = 13;
+                    /***********活动加款**************/
+                    $reason = str_replace ('用于活动', '!@#$', $data['reason']);
+                    if (strstr ($reason, '!@#$')) {
+                        $trade_type = 12;
+                    }
+                    $data['money_cash'] = $data['money_cash'] + $prize_money;
+                    $res = $this->addMoney ($data, $type, $trade_type, '', $prize_money, $order_id, $rate);//充值赠送
+                    if ($res < 0) {
+                        DB::rollback ();
+                        return responseToJson ($res);
+                    }
+                }
+                $prize_money = empty($prize_money) ? 0 : $prize_money;
+                $log = array(
+                    session ('adminInfo.admin_name'),
+                    $data['account_name'],
+                    $money,
+                    $prize_money,
+                    $data['reason'],
+                    $order_id,
+                    $rate,
+                );
+                OperationLog (session ('adminInfo.admin_id'), 'add_money', $log);
+            } else {
+                $order_id = OrderID();
+                $money_cash = $account_data['cash'] - $money;
+                $data['money_cash'] = $money_cash;
+                
+                $res = $this->cutMoney ($data, $type, $order_id);
+                if ($res < 0) {
+                    DB::rollback ();
+                    return responseToJson ($res);
+                }
+               /*if(!empty($prize_money)){
+                   $data['money']=$prize_money;//重置金额
+                   $res=$this->cutMoney($data,$type,$order_id);
+                   if($res<0){
+                       return responseToJson($res);
+                   }
+               }*/
+                $log = array(
+                    session ('adminInfo.admin_name'),
+                    $data['account_name'],
+                    $data['money'],
+                    $data['reason'],
+                    $res,
+                );
+                OperationLog (session ('adminInfo.admin_id'), 'cut_money', $log);
+            }
+            $session_data = array(
+                'time' => date ('Y-m-d H::s'),
+                'money' => $data['money'],
+                'user_id' => $data['account_identity'],
+                'user_name' => $data['account_name'],
+            );
+            event (new \App\Events\MoneyRecharge($session_data));
+            DB::commit ();
+            return responseToJson (1);
+        }
+    }
+
+    /**
+     * 加钱函数
+     * @param array $data
+     * @param int $type
+     * @param int $trade_type
+     * @param string $order_id
+     * @param string $prize_money
+     * @param string $parent_order_id
+     * @param int $rate
+     * @return int|string
+     */
+    private function addMoney(array $data, $type, $trade_type, $order_id = '', $prize_money = '', $parent_order_id = '', $rate)
+    {
+        $accountDB = new \App\Models\Account_detailed(); //用户详情
+        $order_id = $this->rechargeLog ($data, $order_id, $prize_money, $parent_order_id, $rate);//充值记录
+        if ($order_id < 0) {
+            return $order_id;
+        }
+        $detail=$data;
+        $detail['rate']=$rate;
+        $res = $this->dataLog ($detail, $order_id, $type, $trade_type);
+        if ($res < 0) {
+            return $res;
+        }
+        $res2 = $accountDB->addMoney ($data['account_identity'], $data['money']);
+        if ($res2 < 0) {
+            return $res2;
+        }
+        $db = new \App\Models\Manager;
+        $dbs = new \App\Models\Account();
+        $names = $dbs->getinfo ($data['account_identity'], 2);
+        $db->updateMessage ('admin', $names['account'], '加款提示', '加款成功,加款金额:' . $data['money'], 2);
+        return $order_id;
+    }
+
+    /**
+     * 扣钱函数
+     * @param array $data 扣款详情数组
+     * @param int $type 操作类型,此处为2
+     * @param string $order_id 扣款订单号
+     * @return int|string  处理结果,成功返回扣款订单号,失败返回错误号
+     */
+    private function cutMoney(array $data, int $type, string $order_id)
+    {
+        $accountDB = new \App\Models\Account_detailed(); //用户详情
+        $trade_type = 9;
+        $reason = str_replace ('用于活动', '!@#$', $data['reason']);
+        if (strstr ($reason, '!@#$')) {
+            $trade_type = 12; //活动扣款
+        }
+        $res = $this->dataLog ($data, $order_id, $type, $trade_type);//扣款
+
+        if ($res < 0) {
+            return $res;
+        }
+        $res2 = $accountDB->costMoney ($data['account_identity'], $data['money']);
+        if ($res2 < 0) {
+            return $res2;
+        }
+        return $order_id;
+    }
+
+    /**
+     * 充值记录
+     * @param array $data 充值记录数据
+     * @param string $order_id 充值订单ID
+     * @param float $prize_money 充值金额
+     * @param string $parent_order_id 父订单ID
+     * @param int $rate 流水倍数要求
+     * @return int|string 充值成功返回充值订单号
+     */
+    private function rechargeLog(array $data, $order_id = '', $prize_money = 0.00, $parent_order_id = '', $rate)
+    {
+        $recharge = new \App\Models\Money_recharge(); //充值
+        $re_data = $data;
+
+        if (strstr ($data['reason'], '用于活动')) {
+            $re_data['recharge_type'] = '活动充值';
+            if (!empty($parent_order_id)) {
+                $re_data['reason'] = $parent_order_id;
+            }
+        } else {
+            $re_data['recharge_type'] = '后台充值';
+        }
+        if (!empty($prize_money)) {
+            $re_data['recharge_type'] .= '赠送';
+        }
+        $re_data['status'] = 1;
+        $re_data['apply_time'] = date ('Y-m-d H:i:s', time ());
+        $re_data['complete_time'] = date ('Y-m-d H:i:s', time ());
+        $re_data['rate'] = $rate;
+        if (empty($order_id)) {
+            $re_data['order_id'] = OrderID ();
+        } else {
+            $re_data['order_id'] = $order_id;
+        }
+        $order_id = $recharge->addMoney ($re_data);
+        return $order_id;
+    }
+
+
+    /**
+     * 添加充值/扣款详情记录函数
+     * @param array $data 详情数据数组
+     * @param mixed $order_id 充值/扣款订单号
+     * @param int $type 订单类别[1=>'充值',2=>'扣款'];
+     * @param int $trade_type 交易类型
+     * @return int|string 成功返回当前详单号,失败返回错误号
+     */
+    private function dataLog(array $data, $order_id, $type, $trade_type)
+    {
+        if (empty($order_id)) {
+            $order_id = OrderID ();
+        }
+        $rate = 1;
+        $money_db = new \App\Models\Money_details;//资金详情表
+        if (isset($data['rate'])) {
+            $rate = $data['rate'];
+            unset($data['rate']);
+        }
+        $deal_data = $data;
+        $deal_data['money_type'] = $type;
+        $deal_data['money_time'] = date ('Y-m-d H:i:s', time ());
+        $deal_data['trade_id'] = $order_id;
+        $deal_data['trade_type'] = $trade_type;
+        $admin_name = session ('adminInfo.admin_name');
+        $admin_name = isset($admin_name) ? $admin_name : '来自接口' . GETIP ();
+        $deal_data['sysetem_user'] = $admin_name;
+
+
+        if ($trade_type == 11) {
+            $deal_data['trade_desc'] = sprintf (trans ('trade.admin_add_momey'), $admin_name, $data['account_name'], $data['money'], $order_id, $rate);
+        } else if ($trade_type == '13') {
+            $deal_data['trade_desc'] = sprintf (trans ('trade.admin_prize_money'), $admin_name, $data['account_name'], $data['money'], $order_id, $rate);
+        } else if ($trade_type == '9') {
+            $deal_data['trade_desc'] = sprintf (trans ('trade.admin_cut_momey'), $admin_name, $data['account_name'], $data['money'], $order_id, $rate);
+        } else if ($trade_type == '14') {
+            $deal_data['trade_desc'] = sprintf (trans ('trade.admin_rimit_money'), $admin_name, $data['account_name'], $data['money'], $order_id, $rate);
+        } else if ($trade_type == '12') {
+            $deal_data['trade_desc'] = sprintf (trans ('trade.admin_active_money'), $admin_name, $data['account_name'], $data['money'], $order_id, $rate);
+        }
+
+        $deal_data['status'] = 1;
+        $res = $money_db->insertData ($deal_data);
+        if ($res < 0) {
+            return $res;
+        }
+        return $order_id;
+    }
+
+    /**
+     * 对外充值或者扣款接口
+     * @param Req $req
+     * @return mixed
+     */
+    public function AddOrCutMoney(Req $req)
+    {
+        $user_name = $req->name;
+        $type = intval ($req->type) ? $req->type : '';
+        $money = $req->money;
+        $remark = $req->remark;
+        $bate = floatval ($req->peize_bate) ? $req->peize_bate : 0;
+        $order_id = $req->order_id;
+        $time = $req->time;
+        $sign = $req->sign;
+        $rate = $req->rate ?? 1;
+
+        $parent_order_id = $req->parent_order_id ?? '';
+        if (empty($user_name) || empty($money) || empty($type)) {
+            return responseToJson (-3010229022);//必要项不能为空
+        }
+        if (!is_numeric ($money) || $money < 0) {
+            return responseToJson (-3010025022);//提交金额必须为大于0的数字
+        }
+        if (!is_numeric ($bate) || $bate < 0) {
+            return responseToJson (-3010025122);//奖励百分比金额必须为大于0的数字
+        }
+        //时间检验
+        if ($time < (time () - 10)) {
+            return responseToJson (-3020035023);//请求超时
+        }
+        //token校验
+        $setInfo_db = new \App\Models\Setinfo;
+        $token = $setInfo_db->getInfo (19);
+        $token = $token['infocontent'];
+        //校验数据
+        $ver_data = array(
+            'name' => $user_name,
+            'type' => $type,
+            'money' => $money,
+            'peize_bate' => $bate,
+            'order_id' => $order_id,
+            'time' => $time,
+        );
+        krsort ($ver_data);
+        $right_sign = md5 (http_build_query ($ver_data) . '&token=' . $token);
+        if ($right_sign != $sign) {
+            return responseToJson (-3020035024);//
+        }
+        //赠送金额
+        $prize_money = ($money * $bate) / 100;
+        $prize_money = round ($prize_money, 2);
+        //获取用户信息
+        $account_db = new \App\Models\Account(); //用户表
+        $account_data = $account_db->getUserDetails ($user_name, 3, 'account_detailed', 'identity', 'account_identity');
+        if ($account_data < 0) {
+            return responseToJson ($account_data);
+        }
+        $account_data = current ($account_data['data']);
+        if (!$account_data) {
+            return responseToJson (-30203000202);
+        }
+
+        $data = array(
+            'account_name' => $account_data['account_name'],
+            'account_identity' => $account_data['identity'],
+            'money' => $money,
+            'reason' => $remark,
+            'sysetem_user' => '接口',
+        );
+        if ($type == 1) {
+            //加钱
+            $money_cash = $account_data['cash'] + $money;
+            $data['money_cash'] = $money_cash;
+            $trade_type = 11;
+            if (strstr ($data['reason'], '用于活动')) {
+                $trade_type = 12;
+                $prize_money = '';
+            }
+            $order_id = $this->addMoney ($data, $type, $trade_type, $order_id, 0, '', $rate);//加钱
+            if ($order_id < 0) {
+                return responseToJson ($order_id);
+            }
+            if (!empty($prize_money) && $prize_money > 1) {
+                $data['money'] = $prize_money;//重置金额
+                $trade_type = 13;
+                if (strstr ($data['reason'], '用于活动')) {
+                    $trade_type = 12;
+                }
+                $res = $this->addMoney ($data, $type, $trade_type, '', $prize_money, $parent_order_id, $rate);//赠送
+                if ($res < 0) {
+                    return responseToJson ($res);
+                }
+            }
+            $prize_money = empty($prize_money) ? 0 : $prize_money;
+            $log = array(
+                '来自接口IP' . GETIP (),
+                $data['account_name'],
+                $money,
+                $prize_money,
+                $data['reason'],
+                $order_id,
+            );
+            OperationLog (0, 'add_money', $log);
+        } else {
+            $money_cash = $account_data['cash'] - $money;
+            $data['money_cash'] = $money_cash;
+            $res = $this->cutMoney ($data, $type, $order_id);
+            $log = array(
+                '来自接口' . GETIP (),
+                $data['account_name'],
+                $data['money'],
+                $data['reason'],
+                $res,
+            );
+            OperationLog (0, 'cut_money', $log);
+        }
+        $session_data = array(
+            'time' => date ('Y-m-d H::s'),
+            'money' => $data['money'],
+            'user_id' => $data['account_identity'],
+            'user_name' => $data['account_name'],
+        );
+        event (new \App\Events\MoneyRecharge($session_data));
+        return responseToJson (1);
+
+    }
+
+    function rechergeMoney($data, $type, $trade_type, $order_id = '', $prize_money = '', $rate = 1)
+    {
+        //加钱
+        $accountDB = new \App\Models\Account_detailed(); //用户详情
+        //充值记录
+        $order_id = $this->rechargeLog ($data, $order_id, $prize_money, '', $rate);
+        if ($order_id < 0) {
+            return $order_id;
+        }
+        if (!empty($prize_money)) {
+            $prize_data = $data;
+            $prize_data['money'] = $prize_money;//重置金额
+            $order_id2 = $this->rechargeLog ($prize_data, $order_id, $prize_money, '', $rate);
+            if ($order_id2 < 0) {
+                return $order_id2;
+            }
+        }
+
+        //详情记录
+        $res = $this->dataLog ($data, $order_id, $type, $trade_type);
+        if ($res < 0) {
+            return $res;
+        }
+        if (!empty($prize_money)) {
+            $res2 = $this->dataLog ($prize_data, $order_id, $type, $trade_type);
+            if ($res2 < 0) {
+                return $res2;
+            }
+        }
+        //加钱
+        $res3 = $accountDB->addMoney ($data['account_identity'], $data['money']);
+        if ($res3 < 0) {
+            return $res3;
+        }
+        return $order_id;
+    }
+
+    function CheckaddMoney($account_id, $money)
+    {
+        $money_db = new \App\Models\Money_recharge;
+        $time = date ('Y-m-d H:i:s', time () - 10);
+        return $money_db->checkAdd ($account_id, $money, $time);
+    }
+
+
+}
+

+ 358 - 0
app/Http/Controllers/Admin/RemittanceController.php

@@ -0,0 +1,358 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class RemittanceController extends Controller {
+	/**
+	 * @return 汇款管理
+	 */
+	function index() {
+        $request=array();
+        $request['account_name'] = Request::has('account_name') ? Request::get('account_name') : '';
+        $request['order_id'] = Request::has('order_id') ? Request::get('order_id') : '';
+        $request['recharge_type'] = Request::has('recharge_type') ? Request::get('recharge_type') : '';
+        $request['status'] = Request::has('status') ? Request::get('status') : '3';
+        $request['apply_startime'] = Request::get('apply_startime') ? Request::get('apply_startime') : '';
+        $request['apply_endtime'] = Request::get('apply_endtime') ? Request::get('apply_endtime') : '';
+        $request['haddle_startime'] = Request::get('haddle_startime') ? Request::get('haddle_startime') : '';
+        $request['haddle_endtime'] = Request::get('haddle_endtime') ? Request::get('haddle_endtime') : '';
+        $request['money_small'] = Request::has('money_small') ? Request::get('money_small') : '';
+        $request['money_big'] = Request::has('money_big') ? Request::get('money_big') : '';
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$dt->setDataSource('/admin/Remittance/getData');
+		$dt->setLang('money');
+		$dt->setPriKey('order_id');
+		$dt->addColsFields('id', array('width' => 80));
+		$dt->addColsFields('account_name', array('templet' => '#userrecharge', 'width' => 150, 'sort' => false));
+		$dt->addColsFields('apply_time');
+		$dt->addColsFields('group_name', array('width' => 220));
+		$dt->addColsFields('recharge_time', array('templet' => '#money_user','width' => 180));
+		$dt->addColsFields('complete_time', array('templet' => '#taked', 'width' => 180));
+		$dt->addColsFields('money', array('templet' => '#money_aftercash', 'width' => 290));
+		$dt->addColsFields('systemuser_rechargetype', array('sort' => false, 'width' => 150));
+		$dt->addColsFields('action', array('sort' => false, 'templet' => '#sendmoney', 'width' => 110));
+		return view('admin.remittance/index', $dt->render($request));
+	}
+
+	//获取数据
+	function getData() {
+		$page = Request::has('page') ? Request::get('page') : 1;
+		$limit = Request::has('limit') ? Request::get('limit') : 10;
+		$field = Request::has('field') ? Request::get('field') : 'apply_time';
+		$order = Request::has('order') ? Request::get('order') : 'desc';
+
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$order_id = Request::has('order_id') ? Request::get('order_id') : '';
+		$recharge_type = Request::has('recharge_type') ? Request::get('recharge_type') : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$apply_startime = Request::get('apply_startime') ? Request::get('apply_startime').' 00:00:00' : '';
+		$apply_endtime = Request::get('apply_endtime') ? Request::get('apply_endtime').' 23:59:59' : '';
+		$haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime').' 00:00:00' : '';
+		$haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime').' 23:59:59' : '';
+		$money_small = Request::has('money_small') ? Request::get('money_small') : '';
+		$money_big = Request::has('money_big') ? Request::get('money_big') : '';
+		$sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+
+        $whereIn = array();
+		$where = array();
+        $reType=trans('status.money_recharge.send_type');
+		if (!empty($recharge_type)) {
+			$where[] = array('recharge_type', '=', $reType[$recharge_type]);
+		}
+//		if (!empty($status)) {
+//			$status = ($status==3)?'0':$status;
+//			$where[] = array('status', '=', $status);
+//		}
+        if (is_numeric($status)) {
+            if ($status != 4) {
+                $where[] = array('status', '=', $status);
+            }
+
+        }
+		if (!empty($apply_startime)) {
+			$apply_startime = date('Y-m-d H:i:s', strtotime($apply_startime));
+			$where[] = array('apply_time', '>=', $apply_startime);
+		}
+		if (!empty($apply_endtime)) {
+			$apply_endtime = date('Y-m-d H:i:s', strtotime($apply_endtime));
+			$where[] = array('apply_time', '<=', $apply_endtime);
+		}
+		if (!empty($haddle_startime)) {
+			$haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
+			$where[] = array('complete_time', '>=', $haddle_startime);
+		}
+		if (!empty($haddle_endtime)) {
+			$haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
+			$where[] = array('complete_time', '<=', $haddle_endtime);
+		}
+		if (!empty($money_small)) {
+			$where[] = array('money', '>=', $money_small);
+		}
+		if (!empty($money_big)) {
+			$where[] = array('money', '<=', $money_big);
+		}
+
+		$infield = 'recharge_type';
+        $invalue = ['汇款', '汇款赠送'];
+
+		if (!empty($account_name)) {
+			if (empty($sureblur) || $sureblur == '模糊') {
+				$where[] = array('account_name', 'like', '%' . $account_name . '%');
+			} else {
+				$where[] = array('account_name', '=', $account_name);
+			}
+		}
+
+		if (!empty($order_id)) {
+			$where = array(array('money_recharge.order_id', '=', $order_id));
+		}
+		$moneydetails = new \App\Models\Money_recharge();
+		$jointable = 'money_recharge_remark';
+
+		if($field=='recharge_time'){
+			$field = 'money_recharge_remark.'.$field;
+		}else if($field=='group_name'){
+            $field = 'account_detailed.'.$field;
+        } else{
+			$field = 'money_recharge.'.$field;
+		}
+        $remark = 'money_recharge.remark';
+
+		$data = $moneydetails->getRechargelist($where, 8, $limit, $field, $order, $infield, $invalue, $jointable,$whereIn);
+		if ($data < 0) {
+			return $data;
+		}
+		$status = trans('status');
+		$status = $status['money_recharge']['sendstatus'];
+		foreach ($data['data'] as $k => $v) {
+			$data['data'][$k]['apply_time'] = $v['order_id'] . '<br>' . $v['apply_time'];
+			$data['data'][$k]['statuss'] = $status[$v['status']];
+			// $data['data'][$k]['complete_time'] = $data['data'][$k]['statuss'] . '<br>' . $v['complete_time'];
+			$data['data'][$k]['systemuser_rechargetype'] = $v['sysetem_user'] . '<br>' . $v['recharge_type'];
+			(empty($v['remark']))?null:($data['data'][$k]['systemuser_rechargetype'].='---'.$v['remark']);
+			//$data['data'][$k]['recharge_time'] = $v['name'] . '<br>' . $v['recharge_time'];
+		}
+		$data['data'] = arrayToNumber($data['data'], ['money', 'money_cash']);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+	}
+	//汇款统计
+	function getTotal() {
+
+	}
+	//获取
+	private function getSumRemit($startTime, $endTime, $type = '') {
+		if (empty($startTime)) {
+			$startTime = date('Y-m-d 00:00:00');
+		}
+		if (empty($endTime)) {
+			$endTime = date('Y-m-d 23:59:59');
+		}
+		$db = new \App\Models\Money_recharge;
+		$where = array();
+		$where[] = array('money_time', '>=', $startTime);
+		$where[] = array('money_time', '<=', $endTime);
+		if ($type) {
+			$where[] = array('trade_type', '=', $type);
+		} else {
+			//获取总存取反水金额
+			return $db->getRimitTotal($where);
+		}
+		//规定的类型总数
+		return $db->sumRimitMoney($where);
+	}
+
+	//汇款详情
+
+	function Sendview(Req $req) {
+		return $this->senddetail($req);
+	}
+
+	//查看汇款详情
+	function senddetail(Req $req) {
+		$orderid = $req->orderid;
+		if (empty($orderid)) {
+			abort(404);
+		}
+		$send = new \App\Models\Money_recharge();
+		if (!$req->isMethod('post')) {
+			$where = array();
+			if (!empty($orderid)) {
+				$where[] = array('order_id', '=', $orderid);
+			}
+			$data = $send::where($where)->first();
+			if (!$data) {
+				abort(404);
+			}
+			$data = $data->toArray();
+			return view('admin.MoneyManage/Senddetail', ['data' => $data]);
+			//return view('admin.menu/userAdd', ['data' => $data_details]);
+		}
+		abort(404);
+	}
+
+	//汇款通过
+	function save_recharge(Req $req) {
+		return $this->EditSend($req);
+	}
+
+	//汇款通过
+	function EditSend(Req $req) {
+		$order_id = $req->order_id;
+		if (empty($order_id)) {
+			abort(404);
+		}
+		$send = new \App\Models\Money_recharge();
+		$where = array();
+		$where[] = array('order_id', '=', $order_id);
+		$data = $send::where($where)->first();
+		if (!$data) {
+			abort(404);
+		}
+		$data = $data->toArray();
+		//print_r($data);exit;
+		if (!$req->isMethod('post')) {
+			$account = new \App\Models\Account_detailed();
+			$uinfo = $account->getInfoBy($data['account_identity']);
+			if($uinfo<0){
+				return responseToJson($uinfo);
+			}
+			$data['cur_cash'] = $uinfo['cash'];
+			return view('admin.remittance/save_recharge', ['data' => $data]);
+		} else {
+			$limitroot = new \App\Models\System_user();
+			$limitmoney = $limitroot->checkActMoney($data['money']);
+			if($limitmoney<0){
+				return responseToJson($limitmoney);
+			}
+			$point = empty($req->point)?0:$req->point;
+			$checkedL = empty($req->checkedL)?2:$req->checkedL;
+			$point = ($checkedL == 1) ? $point / 100 : 0;
+			$rimit = new \App\Http\Controllers\Admin\MoneyController;
+			$res = $rimit->Rimit($order_id, $point);
+
+			$log = array(
+				session('adminInfo.admin_name'),
+                $data['account_name'],
+                $data['money'],
+                $order_id,
+			);
+
+            $db = new \App\Models\Manager;
+
+            $dbs = new \App\Models\Account();
+            $names=$dbs->getinfo($data['account_identity'],2);
+            $db->updateMessage('admin',$names['account'],'充值提示','充值成功,充值金额:'.$data['money'],2);
+			OperationLog(session('adminInfo.admin_id'), 'EditSend', $log);
+			return responseToJson($res);
+		}
+	}
+
+	//汇款驳回
+	function return_recharge(Req $req) {
+		return $this->EditReturn($req);
+	}
+
+	//汇款驳回
+	function EditReturn(Req $req) {
+		$order_id = $req->order_id;
+		if (empty($order_id)) {
+			abort(404);
+		}
+		$send = new \App\Models\Money_recharge();
+		$where = array();
+		$where[] = array('order_id', '=', $order_id);
+		$data = $send::where($where)->first();
+		if (!$data) {
+			abort(404);
+		}
+		$data = $data->toArray();
+		$temp_data=$data;
+		if (!$req->isMethod('post')) {
+			return view('admin.remittance/return_recharge');
+		} else {
+			//验证可操作金额权限
+			$db = new \App\Models\Money_recharge;
+			$info = $db->getRimitDetails($order_id);
+			if ($info < 0) {
+				return responseToJson($info);
+			}
+			$limitroot = new \App\Models\System_user();
+			$limitmoney = $limitroot->checkActMoney($info['money']);
+			if($limitmoney<0){
+				return responseToJson($limitmoney);
+			}
+            $db = new \App\Models\Manager;
+            $dbs = new \App\Models\Account();
+            $names=$dbs->getinfo($data['account_identity'],2);
+            $db->updateMessage('admin',$names['account'],'充值提示','充值失败,充值金额:'.$info['money'],2);
+
+
+			$reason = $req->reason;
+			$account = new \App\Models\Account_detailed();
+			$uinfo = $account->getInfoBy($data['account_identity']);
+			if($uinfo<0){
+				return responseToJson($uinfo);
+			}
+			$data = array();
+			$data['status'] = 2;
+			if (!empty($reason)) {
+				$data['sysetem_user'] = session('adminInfo.admin_name');
+				$data['money_cash'] = $uinfo['cash'];
+				$data['complete_time'] = date('Y-m-d H:i:s',time());
+				$data['reason'] = $reason;
+			}
+
+			$db = new \App\Models\Money_recharge;
+			$res = $db->updateInfo($data, 'order_id', $order_id);
+			if($res<0){
+                return responseToJson($res);
+            }
+            $res=$this->addRemitFailLog($temp_data,$uinfo['cash'],$reason);
+            $log = array(
+				session('adminInfo.admin_name'),
+                $temp_data['account_name'],
+                $info['money'],
+                $reason,
+                $order_id,
+			);
+			OperationLog(session('adminInfo.admin_id'), 'EditReturn', $log);
+			return responseToJson($res);
+		}
+	}
+    //添加汇款失败详情
+    function addRemitFailLog($data,$money_cash,$reason){
+        $lang=array(
+          session('adminInfo.admin_name'),
+            $data['account_name'],
+            $data['money'],
+            $data['order_id']
+        );
+	    $log=array(
+	        'trade_id'=>$data['order_id'],
+            'account_name'=>$data['account_name'],
+            'account_identity'=>$data['account_identity'],
+            'money'=>$data['money'],
+            'money_time'=>date('Y-m-d H:i:s'),
+            'money_type'=>2,
+            'trade_type'=>14,
+            'trade_desc'=>vsprintf( trans('trade.remit_money_fail') , $lang),
+            'reason'=>$reason,
+            'sysetem_user'=>session('adminInfo.admin_name'),
+            'money_cash'=>$money_cash,
+            'status'=>2,
+        );
+	    $db=new \App\Models\Money_details;
+	    return $db->insertData($log);
+    }
+
+}

+ 255 - 0
app/Http/Controllers/Admin/ReportController.php

@@ -0,0 +1,255 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\DB;
+use Request;
+
+/**
+ *
+ */
+class ReportController extends Controller {
+	function Index(Req $req) {
+
+        $request=array();
+        $request['account_name']=isset($req->account_name)?trim($req->account_name):null;
+        $request['betnum_small']=isset($req->betnum_small)?trim($req->betnum_small):null;
+        $request['betnum_big']=isset($req->betnum_big)?trim($req->betnum_big):null;
+        $request['betmoney_small']=isset($req->betmoney_small)?trim($req->betmoney_small):null;
+        $request['betmoney_big']=isset($req->betmoney_big)?trim($req->betmoney_big):null;
+        $request['settle_status']=isset($req->settle_status)?trim($req->settle_status):null;
+        $request['name']=isset($req->name)?trim($req->name):null;
+        $request['betres_small']=isset($req->betres_small)?trim($req->betres_small):null;
+        $request['betres_big']=isset($req->betres_big)?trim($req->betres_big):null;
+        $request['win_small']=isset($req->win_small)?trim($req->win_small):null;
+        $request['win_big']=isset($req->win_big)?trim($req->win_big):null;
+        $request['star_time']=isset($req->star_time)?trim($req->star_time):null;
+        $request['end_time']=isset($req->end_time)?trim($req->end_time):null;
+
+
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Report/single');
+		$dt->setLang('report');
+		$dt->setPriKey('game_name');
+		$dt->addColsFields('name', array('templet' => '#betdetail'));
+		$dt->addColsFields('munBet');
+		$dt->addColsFields('betmoney');
+//		$dt->addColsFields('effectivemoney');
+		$dt->addColsFields('prizemoney');
+		$dt->addColsFields('winmoney', array('templet' => '#betde'));
+		$dt->addColsFields('star_time');
+		$dt->addColsFields('end_time');
+		// $dt->setToolBar(array('view'), array('toolbar' => '#query'));
+		return view('admin.report/index', $dt->render($request));
+	}
+	//报表查看
+	function View(Req $req) {
+		$game = $req->game_name;
+		$star_time = !empty($req->star_time) ? $req->star_time : '';
+		$end_time = !empty($req->end_time) ? $req->end_time : '';
+		if (empty($game)) {
+			abort(404);
+		}
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Report/getDatil?game=' . $game . '&star_time=' . $star_time . '&end_time=' . $end_time);
+		$dt->setLang('report');
+		$dt->addColsFields('name');
+		$dt->addColsFields('account_name');
+		$dt->addColsFields('munBet');
+		$dt->addColsFields('betmoney');
+		$dt->addColsFields('winmoney');
+		$dt->addColsFields('star_time');
+		$dt->addColsFields('end_time');
+		return view('admin.report/datial', $dt->render());
+	}
+	//获取游戏按照个人统计数据
+	function getDatil() {
+		$game = Request::has('game') ? Request::get('game') : '';
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : '';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+		$end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$where = array();
+		if (!empty($star_time)) {
+			$where[] = array('money_time', '>=', $star_time);
+		}
+		if (!empty($end_time)) {
+			$where[] = array('money_time', '<=', $end_time);
+		}
+		$buy_db = new \App\Models\MoneyBuy;
+		$data = $buy_db->getTotalByUser($game, $page, $list, $where);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	/**
+	 *注单明细报表
+	 * 'FunctionName description'
+	 */
+	function single() {
+		$page = Request::has('page') ? Request::get('page') : 1;
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+
+		$name = Request::has('name') ? Request::get('name') : '';
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$settle_status = Request::has('settle_status') ? Request::get('settle_status') : '';
+		$betnum_small = Request::has('betnum_small') ? Request::get('betnum_small') : '';
+		$betnum_big = Request::has('betnum_big') ? Request::get('betnum_big') : '';
+		$betmoney_small = Request::has('betmoney_small') ? Request::get('betmoney_small') : '';
+		$betmoney_big = Request::has('betmoney_big') ? Request::get('betmoney_big') : '';
+		$betres_small = Request::has('betres_small') ? Request::get('betres_small') : '';
+		$betres_big = Request::has('betres_big') ? Request::get('betres_big') : '';
+		$win_small = Request::has('win_small') ? Request::get('win_small') : '';
+		$win_big = Request::has('win_big') ? Request::get('win_big') : '';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+		$end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$where = array();
+		$having = array();
+		$where[] = array('money_buy.status', '<>', 4);
+		if (!empty($account_name)) {
+			$where[] = array('account_name', '=', $account_name);
+		}
+		/*if (!empty($settle_status) && $settle_status!=3) {
+			$where[] = array('game_status', '<>', '0');
+			$where[] = array('settle_status', '=', $settle_status);
+		}*/
+		if ($settle_status == 1) {
+			$where[] = array('game_status', '=', '0');
+		}
+		if ($settle_status == 2) {
+			$where[] = array('game_status', '<>', '0');
+		}
+		if (!empty($name)) {
+			$where[] = array('game_name', '=', $name);
+		}
+		if (!empty($star_time)) {
+			$where[] = array('money_time', '>=', $star_time);
+		}
+		if (!empty($end_time)) {
+			$where[] = array('money_time', '<=', $end_time);
+		}
+		if (!empty($betnum_small)) {
+			$having[] = 'count("order_id")>=' . $betnum_small;
+		}
+		if (!empty($betnum_big)) {
+			$having[] = 'count("order_id")<=' . $betnum_big;
+		}
+		if (!empty($betmoney_small)) {
+			$having[] = 'sum("money")>=' . $betmoney_small;
+		}
+		if (!empty($betmoney_big)) {
+			$having[] = 'sum("money")<=' . $betmoney_big;
+		}
+		if (!empty($betres_small)) {
+			$having[] = 'sum("get_money")>=' . $betres_small;
+		}
+		if (!empty($betres_big)) {
+			$having[] = 'sum("get_money")<=' . $betres_big;
+		}
+		if (!empty($win_small)) {
+			$having[] = 'sum("prize_money")>=' . $win_small;
+		}
+		if (!empty($win_big)) {
+			$having[] = 'sum("prize_money")<=' . $win_big;
+		}
+
+		$db = new \App\Models\MoneyBuy;
+		$data = $db->getTotal($list, $page, $where, $having);
+		$allcount = array(
+			'allnum' => 0,
+			'allbetmoney' => 0,
+			'allbetres' => 0,
+			'allwinmoney' => 0,
+			'alleffectivemoney' => 0,
+		);
+		
+		$gamedata = array();
+		$tempgd = array();
+		$sl = ($page-1)*$list;
+		$i = 0;
+		if (!($data < 0)) {
+		    /*************有效金额************************/
+		    //获取游戏列表
+           /* $nodatas=array();
+            $effectivemoney=array();
+            if (empty($name)) {
+                $gameList=\App\Model\GameType::getGameType();
+                foreach ($gameList as $kg=>$vg){
+                    $nodata=DB::Select("select info_no from game_".$vg["gameCode"]." where open_time >='".$star_time."' and open_time <='".$end_time."'");
+                    $nodatas=array_merge($nodatas,array_column($nodata,'info_no'));
+                    $effectivemoney[$vg['gameCode']]=0;
+                }
+            }else{
+                $nodata=DB::Select("select info_no from game_".$name." where open_time >='".$star_time."' and open_time <='".$end_time."'");
+                $nodatas=array_merge($nodatas,array_column($nodata,'info_no'));
+                $effectivemoney[$name]=0;
+            }
+
+            //按游戏统计有效金额
+            $effective=array();
+            if($nodatas){
+                $effective=$db->getEffectiveMoney($list, $page, $nodatas,$name);
+            }
+            foreach ($effective as $k=>$v){
+                $effectivemoney[$v['game_name']]=$v['money'];
+            }*/
+		    /*************有效金额************************/
+			foreach ($data as $k => $v) {
+
+				if(isset($tempgd[$v['game_name']])){
+                    $tempgd[$v['game_name']]['effectivemoney'] = 0;
+					$tempgd[$v['game_name']]['winmoney'] += $v['winmoney'];
+					$tempgd[$v['game_name']]['prizemoney'] += $v['prizemoney'];
+					$tempgd[$v['game_name']]['betmoney'] += $v['betmoney'];
+					$tempgd[$v['game_name']]['munBet'] += $v['munBet'];
+					$tempgd[$v['game_name']]['end_time'] = ($v['end_time']>$tempgd[$v['game_name']]['end_time'])?$v['end_time']:$tempgd[$v['game_name']]['end_time'];
+					$tempgd[$v['game_name']]['star_time'] = ($v['star_time']<$tempgd[$v['game_name']]['star_time'])?$v['star_time']:$tempgd[$v['game_name']]['star_time'];
+
+//					$tempgd[$v['game_name']]['effectivemoney'] += ($v['game_status']!=0)?$v['betmoney']:0;
+
+				}else{
+					$tempgd[$v['game_name']]['winmoney'] = $data[$k]['winmoney'];
+					$tempgd[$v['game_name']]['prizemoney'] = $v['prizemoney'];
+					$tempgd[$v['game_name']]['betmoney'] = $v['betmoney'];
+					$tempgd[$v['game_name']]['munBet'] = $v['munBet'];
+					$tempgd[$v['game_name']]['end_time'] = $v['end_time'];
+					$tempgd[$v['game_name']]['star_time'] = $v['star_time'];
+					$tempgd[$v['game_name']]['game_name'] = $v['game_name'];
+					$tempgd[$v['game_name']]['name'] = $v['name'];
+                    $tempgd[$v['game_name']]['effectivemoney'] = 0;
+//					$tempgd[$v['game_name']]['effectivemoney'] = ($v['game_status']!=0)?$v['betmoney']:0;
+				}
+			}
+			foreach ($tempgd as $v) {
+				if($i<$sl){
+					$i++;
+					continue;
+				}
+				if(($i-$sl)>=$list)break;
+				$gamedata[$i] = $v;
+				$gamedata[$i]['winmoney'] = ($v['winmoney'] > 0) ? -$v['winmoney'] : abs($v['winmoney']);
+				$allcount['allnum'] += $v['munBet'];
+				$allcount['allbetmoney'] += $v['betmoney'];
+				$allcount['allbetres'] += $v['prizemoney'];
+				$allcount['allwinmoney'] += $v['winmoney'];
+				$allcount['alleffectivemoney'] += $v['effectivemoney'];
+				$i++;
+			}
+
+			foreach ($gamedata as $k => $v) {
+				$gamedata[$k]['allnum'] = $allcount['allnum'];
+				$gamedata[$k]['allbetmoney'] = $allcount['allbetmoney'];
+				$gamedata[$k]['allbetres'] = $allcount['allbetres'];
+				$gamedata[$k]['allwinmoney'] = $allcount['allwinmoney'];
+				$gamedata[$k]['alleffectivemoney'] = $allcount['alleffectivemoney'];
+			}
+		}
+		$data = arrayToNumber($gamedata, array('betmoney', 'prizemoney', 'winmoney','effectivemoney', 'allbetmoney', 'allbetres', 'allwinmoney','alleffectivemoney'));
+
+		return \App\Lib\DataTable\DataTable::init()->toJson($gamedata, count($tempgd));
+	}
+
+}
+?>

+ 97 - 0
app/Http/Controllers/Admin/ReturnController.php

@@ -0,0 +1,97 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class ReturnController extends Controller {
+	/**
+	 * @return 回水记录
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['account_name']=isset($req->account_name)?trim($req->account_name):null;
+		$request['order_id'] = isset($req->order_id) ? trim($req->order_id) : null;
+		$request['haddle_startime'] = isset($req->haddle_startime) ? trim($req->haddle_startime) : trans('status.default_time.seven_day');
+		$request['haddle_endtime'] = isset($req->haddle_endtime) ? trim($req->haddle_endtime) : trans('status.default_time.etime');
+		$request['money_small'] = isset($req->money_small) ? trim($req->money_small) : null;
+		$request['money_big'] = isset($req->money_big) ? trim($req->money_big) : null;
+		$request['lossmoney_small'] = isset($req->lossmoney_small) ? trim($req->lossmoney_small) : null;
+		$request['lossmoney_big'] = isset($req->lossmoney_big) ? trim($req->lossmoney_big) : null;
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/returnList');
+		$dt->setLang('money');
+		$dt->setPriKey('order_id');
+		$dt->addColsFields('id', array('width' => 110));
+		$dt->addColsFields('account_name', array('sort' => false, 'templet' => '#userReturn', 'width' => 200));
+		$dt->addColsFields('order_id', array('sort' => false, 'width' => 260));
+		$dt->addColsFields('return_money', array('width' => 200));
+		$dt->addColsFields('total_money', array('templet' => '#moneyReturn', 'width' => 200));
+		$dt->addColsFields('processing_time');
+		$dt->setToolBar(array('view'), array('width' => 100,'align' => 'left'));
+		//$dt->addColsFields('action',array('width'=>250));
+
+		return view('admin.Return/index', $dt->render($request));
+	}
+
+	/**
+	 * 单用户回水列表
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function userReturn() {
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/returnList?account_name=' . $account_name . '&sureblur=精确');
+		$dt->setLang('money');
+		$dt->setPriKey('order_id');
+		$dt->addColsFields('id', array('fixed' => 'left'));
+		$dt->addColsFields('account_name', array('templet' => '#userReturn'));
+		$dt->addColsFields('order_id');
+		$dt->addColsFields('money');
+		$dt->addColsFields('total_money');
+		$dt->addColsFields('processing_time');
+		$dt->setToolBar(array('view'), array('width' => '103'));
+		return view('admin.view', $dt->render());
+	}
+
+	//查看回水
+	function View(Req $req) {
+		$order_id = $req->order_id;
+		if (empty($order_id)) {
+			abort(404);
+		}
+//        $back_db=new \App\Model\Money_return;
+		$money_db = new \App\Models\Money_details;
+		$account_db = new \App\Models\Account;
+		$bank_db = new \App\Models\Account_bank;
+//        $data=$back_db->getOrderDetails($order_id,3);
+		$data = $money_db->getOrderDetails($order_id, 3);
+		$account = $account_db->getinfo($data['account_identity'], 2);
+		$data['account_name'] = $account['account'];
+		$bank_data = $bank_db->getInfoByUid($data['account_identity']);
+
+		$data['bank_name'] = '';
+		$data['bank_address'] = '';
+		$data['bank_number'] = '';
+		$data['name'] = '';
+		if (!empty($bank_data)) {
+			$data['bank_name'] = $bank_data['bank_name'];
+			$data['bank_address'] = $bank_data['bank_address'];
+			$data['bank_number'] = $bank_data['bank_number'];
+			$data['name'] = $bank_data['account_name'];
+		}
+//        $data['trade_type ']='回水';
+		//        dd($data);
+		return view('admin.Return/view', ['data' => $data]);
+	}
+
+}
+
+?>

+ 214 - 0
app/Http/Controllers/Admin/ReturnmanageController.php

@@ -0,0 +1,214 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use Request;
+
+/**
+ *
+ */
+class ReturnmanageController extends Controller {
+	/**
+	 * @return 回水管理
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['account_name']=isset($req->account_name)?trim($req->account_name):null;
+		$request['gametype'] = isset($req->gametype) ? trim($req->gametype) : null;
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) : trans('status.default_time.seven_day');
+		$request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+		$request['return_point'] = isset($req->return_point) ? trim($req->return_point) : 0.1;
+		$request['total_money'] = isset($req->total_money) ? trim($req->total_money) : null;
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/returnInfo');
+		$dt->enableCheckBox();
+		$dt->setPriKey('account_name');
+		$dt->setLang('money');
+		$dt->addColsFields('account_name', array('templet' => '#userdetail', 'width' => 270));
+		$dt->addColsFields('game_name', array('sort' => false, 'width' => 270,'templet'=>'#gameType'));
+		$dt->addColsFields('total_money', array('width' => 270,'templet' => '#money'));
+		//$dt->addColsFields('return_water', array('sort' => false, 'width' => 270));
+		return view('admin.returnmanage/index', $dt->render($request));
+	}
+
+	/**
+	 * 单用户回水明细
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function userReturndetail() {
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$game_name = Request::has('game_name') ? Request::get('game_name') : '';
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/money/userreturnList?account_name=' . $account_name . '&game_name=' . $game_name);
+		$dt->setLang('money');
+		$dt->setPriKey('order_id');
+		$dt->addColsFields('id');
+		$dt->addColsFields('account_name');
+		$dt->addColsFields('game_name', array('sort' => false));
+		$dt->addColsFields('money_time');
+		$dt->addColsFields('money');
+		$dt->addColsFields('prize_money');
+		$dt->addColsFields('get_money');
+		$dt->addColsFields('returnstatus', array('sort' => false));
+		return view('admin.view', $dt->render());
+	}
+	//一件回水
+	function delete(Req $req) {
+		$get_data = $req->data;
+        $star_time=$req->star_time?$req->star_time.' 00:00:00':'';
+        $end_time=$req->end_time?$req->end_time.' 23:59:59':'';
+        $game_name=$req->game?trim($req->game):'';
+//		if(empty($s_time)||empty($e_time)){
+//            return responseToJson(-5051572522);
+//        }
+        /**时间条件***/
+        $timearea=array();
+        if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $timearea[] = array('money_time', '>=', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $timearea[] = array('money_time', '<=', $end_time);
+        }
+        /**数据检验***/
+		if (!is_array($get_data)) {
+			return responseToJson(-2001);
+		}
+		$account_id_array=array();
+		foreach ($get_data as $v) {
+			if ($v['total_money']<= 0) {
+				return responseToJson(-5030021122);
+			}
+            //获取用户id数组
+            $account_id_array[]=$v['account_identity'];
+		}
+
+		DB::beginTransaction();//开启事务
+		$money_buy = new \App\Models\MoneyBuy;
+
+		//更改结算状态
+		foreach ($get_data as $v) {
+			$res = $money_buy->updateWater($v['account_name'],$timearea,$game_name);
+			if ($res < 0) {
+				break;
+			}
+		}
+		if ($res < 0) {
+            DB::rollback();
+            return responseToJson($res);
+		}
+		//插入回水记录
+		$data_back_array = array(); //回水数据数组
+		$data_min_array = array(); //详情数据数组
+		//获取用户信息
+		$account_detailed = new \App\Models\Account_detailed;
+
+        //获取用户当前余额
+        $account_cash_array=$account_detailed->getCashArray($account_id_array);
+
+		$rate = (!empty($req->return_point))?$req->return_point:0.1;
+		$rate = ($rate>=1)?$rate/100:$rate;
+		//组装数据
+		foreach ($get_data as $k => $v) {
+			$order_id = OrderID();
+			$money = abs($rate * $v['total_money']);
+			$data_back_array[$k]['account_name'] = $v['account_name'];
+			$data_back_array[$k]['account_identity'] = $v['account_identity'];
+			$data_back_array[$k]['order_id'] = $order_id;
+			$data_back_array[$k]['money'] = $money;
+			$data_back_array[$k]['total_money'] = $v['total_money'];
+			$data_back_array[$k]['sysetem_user'] = session('adminInfo.admin_name');
+			$data_back_array[$k]['processing_time'] = date('Y-m-d H:i:s');
+			$data_back_array[$k]['ratio'] = $rate;
+			$data_back_array[$k]['info_identity'] = UUID();
+
+			$data_min_array[$k]['account_name'] = $v['account_name'];
+			$data_min_array[$k]['account_identity'] = $v['account_identity'];
+			$data_min_array[$k]['trade_id'] = $order_id;
+			$data_min_array[$k]['money'] = $money;
+			$data_min_array[$k]['sysetem_user'] = session('adminInfo.admin_name');
+			$data_min_array[$k]['info_identity'] = UUID();
+			$data_min_array[$k]['money_time'] = date('Y-m-d H:i:s');
+			$data_min_array[$k]['money_type'] = 1;
+			$data_min_array[$k]['money_cash'] = $account_cash_array[$v['account_identity']]+$money;
+			$data_min_array[$k]['trade_type'] = 8;
+			$data_min_array[$k]['trade_desc'] = sprintf(trans('trade.admin_hui_money'), session('adminInfo.admin_name'), $v['account_name'], $money, $order_id);
+		}
+
+		//插入回水记录
+		$return_db = new \App\Models\Money_return;
+		$res_return = $return_db->returnMoney($data_back_array);
+		if ($res_return < 0) {
+			DB::rollback();
+			return responseToJson($res_return);
+		}
+
+		//插入详情记录
+		$db_money_de = new \App\Models\Money_details;
+		$res_detail = $db_money_de->returnData($data_min_array);
+		if ($res_detail < 0) {
+			DB::rollback();
+			return responseToJson($res_detail);
+		}
+
+		//更新用户余额
+		foreach ($get_data as $k => $v) {
+			$money = abs($rate * $v['total_money']);
+			$res_money = $account_detailed->addMoney($v['account_identity'], $money);
+			if ($res_money < 0) {
+				break;
+			}
+		}
+     
+		if ($res_money < 0) {
+			DB::rollback();
+			return responseToJson($res_money);
+		}
+		//组装
+        $account_str=array();
+        $length=count($get_data);
+        $limit=0;
+        if($length>20){
+            $limit=ceil($length/20);
+        }
+        $i=0;
+		foreach ($get_data as $k=>$v){
+		    if($k<20*($i+1)){
+		        if(!isset($account_str[$i])){
+                    $account_str[$i]='';
+                }
+                $account_str[$i].=$v['account_name'].',';
+            }else{
+                $i++;
+            }
+        }
+        $log=array();
+         foreach ($account_str as $k=>$v){
+             $log[]=array(
+                 session('adminInfo.admin_name'),
+                 $v
+             );
+         }
+         foreach ($log as $v){
+            $res=OperationLog(session('adminInfo.admin_id'),'return_money',$v);
+            if($res<0) {
+                break;
+            }
+         }
+        if($res<0){
+            DB::rollback();
+            return responseToJson($res);
+        }
+        DB::commit();
+		return responseToJson(1);
+	}
+
+}
+
+?>

+ 103 - 0
app/Http/Controllers/Admin/RoutesCategoryController.php

@@ -0,0 +1,103 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+/**
+ *
+ */
+class RoutesCategoryController extends Controller {
+	/**
+	 * @return 管理员日志管理
+	 */
+	function index(Request $req) {
+		$request=array();
+		$request['name'] = isset($req->name) ? trim($req->name) : null;
+		$request['rdesc'] = isset($req->rdesc) ? trim($req->rdesc) : null;
+		$request['remark'] = isset($req->remark) ? trim($req->remark) : null;
+        $request['sort'] = isset($req->sort) ? trim($req->sort) :null;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/RoutesCategory/data');
+		$dt->setLang('routes');
+		$dt->addColsFields('id');
+		$dt->addColsFields('name');
+		$dt->addColsFields('rdesc');
+		$dt->addColsFields('remark');
+		$dt->addColsFields('sort');
+		$dt->setToolBar(array('edit'),array('sort' => false));
+		$dt->enableCheckBox();
+		return view('admin.RoutesCategory/index', $dt->render($request));
+	}
+
+	function data() {
+		$db = new \App\Models\RoutesCategory();
+		$data =  $db->getCode();
+		return \App\Lib\DataTable\DataTable::init()->toJson($data);
+	}
+	function add(Request $req) {
+		$model = new \App\Models\RoutesCategory();
+		if (!$req->isMethod('post')) {
+			return view('admin.RoutesCategory/add', array('data' => $model));
+		} else {
+			$model = new \App\Models\RoutesCategory();
+			$model->name = trim($req->input('name'));
+			$model->rdesc = trim($req->input('rdesc'));
+			$model->remark = trim($req->input('remark'));
+			$model->sort = trim($req->input('sort'));
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+
+	public function delete(Request $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			return responseToJson(-2001); //id不能为空
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id错误
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\RoutesCategory::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id错误
+		}
+		return responseToJson(1); //id错误
+	}
+
+	function edit(Request $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+			$data = \App\Models\RoutesCategory::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+			return view('admin.RoutesCategory/add', array('data' => $data));
+		} else {
+			$model = \App\Models\RoutesCategory::where('id', $id)->first();
+			$model->name = trim($req->input('name'));
+			$model->rdesc = trim($req->input('rdesc'));
+			$model->remark = trim($req->input('remark'));
+			$model->sort = trim($req->input('sort'));
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+	
+
+}

+ 119 - 0
app/Http/Controllers/Admin/RoutesController.php

@@ -0,0 +1,119 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+/**
+ *
+ */
+class RoutesController extends Controller {
+	/**
+	 * @return 管理员日志管理
+	 */
+	function index(Request $req) {
+		$request=array();
+		$request['name'] = isset($req->name) ? trim($req->name) : null;
+		$request['rdesc'] = isset($req->rdesc) ? trim($req->rdesc) : null;
+		$request['remark'] = isset($req->remark) ? trim($req->remark) : null;
+        $request['sort'] = isset($req->sort) ? trim($req->sort) :null;
+        $request['ip'] = isset($req->ip) ? trim($req->ip) : null;
+        $request['url'] = isset($req->url) ? trim($req->url) :null;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Routes/data');
+		$dt->setLang('routes');
+		$dt->addColsFields('id');
+		$dt->addColsFields('name');
+		$dt->addColsFields('cate_name');
+		$dt->addColsFields('rdesc');
+		$dt->addColsFields('remark');
+		$dt->addColsFields('ip');
+		$dt->addColsFields('url');
+		$dt->addColsFields('sort');
+		$dt->setToolBar(array('edit'),array('sort' => false));
+		$dt->enableCheckBox();
+		return view('admin.Routes/index', $dt->render($request));
+	}
+
+	function data(Request $req) {
+		$list = $req->limit;
+		$db = new \App\Models\Routes();
+		$data =  $db->getCode($list);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data']);
+	}
+	function add(Request $req) {
+		$model = new \App\Models\Routes();
+		$models = new \App\Models\RoutesCategory();
+		$arr = $models->getCode();
+		if (!$req->isMethod('post')) {
+			return view('admin.Routes/add', array('data' => $model,'datas' => $arr));
+		} else {
+			$model = new \App\Models\Routes();
+			$model->name = trim($req->input('name'));
+			$model->cate_id = trim($req->input('cate_id'));
+			$model->rdesc = trim($req->input('rdesc'));
+			$model->remark = trim($req->input('remark'));
+			$model->ip = trim($req->input('ip'));
+			$model->url = trim($req->input('url'));
+			$model->sort = trim($req->input('sort'));
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+
+	public function delete(Request $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			return responseToJson(-2001); //id不能为空
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id错误
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\Routes::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id错误
+		}
+		return responseToJson(1); //id错误
+	}
+
+	function edit(Request $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		$models = new \App\Models\RoutesCategory();
+		$arr = $models->getCode();
+		if (!$req->isMethod('post')) {
+			$data = \App\Models\Routes::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+			return view('admin.Routes/add', array('data' => $data,'datas' => $arr));
+		} else {
+			$model = \App\Models\Routes::where('id', $id)->first();
+			$model->name = trim($req->input('name'));
+			$model->cate_id = trim($req->input('cate_id'));
+			$model->rdesc = trim($req->input('rdesc'));
+			$model->remark = trim($req->input('remark'));
+			$model->ip = trim($req->input('ip'));
+			$model->url = trim($req->input('url'));
+			$model->sort = trim($req->input('sort'));
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+	
+
+}

+ 224 - 0
app/Http/Controllers/Admin/SoccerLeagueController.php

@@ -0,0 +1,224 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SoccerLeagueController extends Controller {
+
+    public function index(Req $req) {
+        //$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
+        $request['area_id'] = isset($req->area_id) ? trim($req->area_id) : '';
+        $request['country_id'] = isset($req->country_id) ? trim($req->country_id) : '';
+        $request['id'] = isset($req->id) ? trim($req->id) : '';
+        $request['status'] = isset($req->status) ? trim($req->status) : '0';
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $data = \App\Models\SoccerLeague::select('id','lg_id','name_chinese')->get();
+        $area = \App\Models\StAreaCountry::where('pid',0)->get();
+        $country = \App\Models\StAreaCountry::where('pid','!=',0)->get();
+        $request['league'] = $data;
+        $request['area'] = $area;
+        $request['country'] = $country;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SoccerLeague/info');
+        $dt->setLang('sportsbase');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('area', array('sort' => false, 'width' => 180));
+        $dt->addColsFields('country', array('sort' => true, 'width' => 180));
+        $dt->addColsFields('league_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('utime', array('templet' => '#userdetail', 'sort' => false, 'width' => 160));
+        if (checkRriv('/admin/SoccerLeague/edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 140));
+        $dt->enableCheckBox();
+        return view('sports/soccer_league', $dt->render($request));
+    }
+
+    function info(Req $req) {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+        $area_id = Request::has('area_id') ? Request::get('area_id') : '';
+        $country_id = Request::has('country_id') ? Request::get('country_id') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        if (!empty($name_chinese)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_zq_league.name_chinese', 'like', '%' . $name_chinese . '%');
+            }else{
+                $where[] = array('st_zq_league.name_chinese', '=', $name_chinese);
+            }
+        }
+//        if ($name_chinese != -1) {
+//            $where[] = array('st_zq_league.name_chinese', '=', $name_chinese);
+//        }
+        if(!empty($area_id)){
+            $where[] = array('st_zq_league.area_id', '=', $area_id);
+        }
+        if(!empty($country_id)){
+            $where[] = array('st_zq_league.country_id', '=', $country_id);
+        }
+        if($status != 0){
+            $where[] = array('st_zq_league.status', '=', $status);
+        }
+
+        $newapp = new \App\Models\SoccerLeague();
+        $data = $newapp->getinfo($list, $page, $where);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    /**
+     *获取地区
+     */
+    function getarea() {
+        $area = \App\Models\StAreaCountry::where('pid',0)->get();
+        return $area;
+    }
+
+    /**
+     *获取该地区的所有国家
+     */
+    function getcountry() {
+        $pid = $_GET["id"];
+        $country = \App\Models\StAreaCountry::where('pid',$pid)->get();
+        return json_encode($country);
+    }
+
+    /**
+     *添加联赛
+     */
+    function add(Req $req) {
+        if (!$req->isMethod('post')) {
+            $areas = $this->getarea();
+            if (!$areas) {
+                return -2;
+            }
+            $data['area'] = $areas;
+            return view('sports.soccer_league_form', $data);
+        } else {
+            $model = new \App\Models\SoccerLeague();
+            $model->name_chinese = $req->input('name_chinese');
+            $model->country_id = $req->input('country_id');
+            $model->area_id = $req->input('area_id');
+            $model->status = $req->input('status');
+            $model->lg_id = time();
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->source = 'user-defined';
+
+            $db = new \App\Models\Stzqlocalleague();
+            $db->source = 'user-defined';
+            $db->lg_id = $model->lg_id;
+
+            $model->save();
+            $db->save();
+            return responseToJson(1);
+        }
+    }
+
+    function view(Req $req) {
+        return $this->edit($req);
+    }
+
+    /**
+     *修改联赛信息(地区,国家)
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+            $areas = $this->getarea();
+            if (!$areas) {
+                return -2;
+            }
+            $data = \App\Models\SoccerLeague::where('id',$id)->first();
+            $areaname = \App\Models\StAreaCountry::where('id',$data->area_id)->first();
+            $countryname = \App\Models\StAreaCountry::where('id',$data->country_id)->first();
+            if(!empty($areaname)){
+                $data->area = $areaname->name;
+            }
+            if(!empty($countryname)){
+                $data->country = $countryname->name;
+            }
+
+            $data = $data->toArray();
+            $data['area'] = $areas;
+
+            return view('sports.soccer_league_form', $data);
+        } else {
+            $model = new \App\Models\SoccerLeague();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            if(!empty($req->input('country_id'))){
+                $model->country_id = $req->input('country_id');
+            }else{
+                $model->country_id = 0;
+            }
+            if(!empty($req->input('area_id'))){
+                $model->area_id = $req->input('area_id');
+            }else{
+                $model->area_id = 0;
+            }
+            $model->status = $req->input('status');
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *删除联赛
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id???????
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id????
+        }
+        $id = array();
+        $localleague = \App\Models\Stzqlocalleague::get();
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+                $league = \App\Models\SoccerLeague::where('id',$v)->first();
+                for($i=0;$i<count($localleague);$i++){
+                    if($localleague[$i]->lg_id == $league->lg_id){
+                        $id[] = $localleague[$i]->id;
+                    }
+                }
+            }
+        }
+
+        $rows = \App\Models\SoccerLeague::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id????
+        }
+        if(count($id)>0) {
+            $row = \App\Models\Stzqlocalleague::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id????
+
+    }
+
+
+}

+ 282 - 0
app/Http/Controllers/Admin/SoccerNoteListController.php

@@ -0,0 +1,282 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jonlin
+ * Date: 2019/4/9
+ * Time: 9:11
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementOrder;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SoccerNoteListController extends Controller
+{
+
+    public function notelist(Req $req)
+    {
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['account'] = isset($req->account) ? trim($req->account) :null ;
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+        $request['order_id'] = isset($req->order_id) ? trim($req->order_id) :null ;
+        $request['match_id'] = isset($req->match_id) ? trim($req->match_id) :null ;
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
+        $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SoccerNoteList/info');
+        $dt->setLang('sportsnotelist');
+        //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('match_id_order', array('sort' => true, 'width' => 200));
+        $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 250));
+        $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
+        $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 110));
+        $dt->addColsFields('game_status', array('sort' => false, 'width' =>90));
+        //$arr[] = 'view';
+//        if (checkRriv('/admin/SoccerNoteList/edit')) {
+//            $arr[] = 'edit';
+//        }
+//        $dt->setToolBar($arr, array('width' => 70));
+        $dt->enableCheckBox();
+        return view('sports/sports_notelist', $dt->render($request));
+    }
+
+    function info()
+    {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $account = Request::get('account') ? Request::get('account') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+        $order_id = Request::get('order_id') ? Request::get('order_id') : '';
+        $match_id = Request::get('match_id') ? Request::get('match_id') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $order_status = Request::has('order_status') ? Request::get('order_status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $type = Request::has('type') ? Request::get('type') : 'zq';
+        $where = array();
+        if (!empty($account)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
+            } else {
+                $where[] = array('money_buy_simplex.account_name', '=', $account);
+            }
+        }
+        if (!empty($star_time)) {
+            if (!empty($end_time)){
+                $where[] = array('money_buy_simplex.money_time', '>', $star_time);
+                $where[] = array('money_buy_simplex.money_time', '<', $end_time);
+            }else{
+                $where[] = array('money_buy_simplex.money_time', '>', $star_time);
+            }
+        }else if(empty($star_time)){
+            if (!empty($end_time)){
+
+                $where[] = array('money_buy_simplex.money_time', '<', $end_time);
+            }
+        }
+        if (!empty($order_id)){
+            $where[] = array('money_buy_simplex.order_id', $order_id);
+        }
+        if (!empty($match_id)){
+            $where[] = array('money_buy_simplex.match_id', $match_id);
+        }
+        if ($status != -1) {
+            $where[] = array('money_buy_simplex.settle_status', '=', $status);
+        }
+        if ($order_status != -1) {
+            $where[] = array('money_buy_simplex.status', '=', $order_status);
+        }
+        $where[] = array('money_buy_simplex.game_code', $type);
+        $newapp = new \App\Models\SportsNoteList();
+        $data = $newapp->getinfo($list, $page, $where,$type);
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    /**
+     *单式注单作废
+     */
+    public function invalid(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $order = \App\Models\SportsNoteList::where('id',$id)->first();
+        //用戶账户金额
+        $account_money = \App\Models\Account_detailed::where('account_identity',$order->account_identity)->first();
+        //反水
+        $water_return_money = \App\Models\Money_details::where('trade_id',$order->order_id)->where('trade_type','7')->first();
+        if(!empty($water_return_money)){
+            $water_return = $water_return_money->money;
+        }else{
+            $water_return = 0;
+        }
+        //撤单后用户账户金额
+        $available_cash = $account_money->available_cash;
+        $new_available_cash = $available_cash+$order->money-$order->gain_money-$water_return;
+
+        $model =new \App\Models\Money_details();
+        $model->info_identity = UUID();
+        $model->trade_id = $order->order_id;
+        $model->account_name = $order->account_name;
+        $model->account_identity = $order->account_identity;
+        $model->money = abs($order->money-$order->gain_money-$water_return);
+        $model->money_time = date("Y-m-d H:i:s",time());
+        if($new_available_cash>$available_cash){
+            $model->money_type = '1';
+        }else{
+            $model->money_type = '2';
+        }
+        $model->money_cash = $new_available_cash;
+        $model->trade_type = '3';
+        $model->trade_desc = '管理员作废单式注单';
+        $model->status = '1';
+        try {
+            DB::beginTransaction();//开启事务
+            \App\Models\SportsNoteList::where('id',$id)->update(['status'=>'2'],['gain_money'=>'0']);
+            \App\Models\Account_detailed::where('account_identity',$order->account_identity)->update(['available_cash'=>$new_available_cash,'cash'=>$new_available_cash]);
+            $model->save();
+
+            DB::commit();//提交
+            return 1;
+        } catch (Exception $e) {
+            DB::rollback();//回滚
+            return -1;
+        }
+    }
+
+    /**
+     *单式注单首次结算
+     */
+    public function settlement(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $order = \App\Models\SportsNoteList::where('id', $id)->first();
+        $order_id = $order->order_id;
+        $order_ids = array($order->order_id);
+        $match_id = $order->match_id;
+        $game_code = $order->game_code;
+        $bet_type = 1;//单式注单
+        //return $match_id;
+        //判断输赢
+        $settlementWinFail = new SettlementWinFail();
+        $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
+        //结算
+        $SettlementOrder = new SettlementOrder();
+        $settype = 1; //首次结算
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
+        return $data;
+    }
+
+
+    /**
+     *单式注单重新结算
+     */
+    public function resettlement(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $order = \App\Models\SportsNoteList::where('id',$id)->first();
+        $match_id = $order->match_id;
+        $game_code = $order->game_code;
+        $order_id = $order->order_id;
+        $order_ids = array($order->order_id);
+        //return $match_id;
+        $bet_type = 1;//单式注单
+        //重新判断输赢
+        $settlementWinFail = new SettlementWinFail();
+        $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
+        //结算
+        $SettlementOrder = new SettlementOrder();
+        $settype = 2; //重新结算
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
+        return $data;
+    }
+
+    /**
+     *单式注单批量结算
+     */
+    public function batchsettlement(){
+        $orders = \App\Models\SportsNoteList::where('settle_status','1')->get();
+        $order_ids = array();
+        for($i=0;$i<count($orders);$i++){
+            $result = \App\Models\MoneyBuyMatch::where('batch_id',$orders[$i]->batch_id)->where('match_id',$orders[$i]->match_id)->get();
+            $res = array();
+            for($j=0;$j<count($result);$j++){
+                $res[] = $result[$j]->result;
+            }
+            if(!in_array(0,$res)){
+                $order_ids[] = $orders[$i]->order_id;
+            }
+        }
+        $SettlementOrder = new SettlementOrder();
+        $bet_type = 1;//单式注单
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
+        return $data;
+    }
+
+    /**
+     *删除订单
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+
+    /**
+     * 投注金额统计
+     */
+    function moneycount()
+    {
+        $where = Request::has('where') ? Request::get('where') : '';
+        $type = Request::has('type') ? Request::get('type') : 'zq';
+        $db = new \App\Models\SportsNoteList;
+
+        $data = $db->MoneyCount($where,$type);
+        return responseToJson($data);
+    }
+
+}

+ 311 - 0
app/Http/Controllers/Admin/SoccerStringNoteListController.php

@@ -0,0 +1,311 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jonlin
+ * Date: 2019/4/9
+ * Time: 9:11
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementOrder;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SoccerStringNoteListController extends Controller
+{
+
+    public function notelist(Req $req)
+    {
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['account'] = isset($req->account) ? trim($req->account) :null ;
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+        $request['order_id'] = isset($req->order_id) ? trim($req->order_id) :null ;
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['order_status'] = isset($req->order_status) ? trim($req->order_status) : '-1';
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SoccerStringNoteList/info');
+        $dt->setLang('sportsnotelist');
+        //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('order_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
+        $dt->addColsFields('str_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('detail_content', array('sort' => false, 'width' => 150));
+        $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('money_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 140));
+        $dt->addColsFields('order_status', array('sort' => false, 'width' => 80));
+        $dt->addColsFields('account_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 230));
+        $dt->addColsFields('settle_status', array('sort' => false, 'width' => 90));
+//        if (checkRriv('/admin/SoccerStringNoteList/edit')) {
+//            $arr[] ='edit';
+//        }
+//        $dt->setToolBar($arr, array('width' => 100));
+        $dt->enableCheckBox();
+        return view('sports/sports_stringnotelist', $dt->render($request));
+    }
+
+    function info()
+    {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $account = Request::get('account') ? Request::get('account') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+        $order_id = Request::get('order_id') ? Request::get('order_id') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $order_status = Request::has('order_status') ? Request::get('order_status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        if (!empty($account)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('money_buy_str.account_name', 'like', '%' . $account . '%');
+            } else {
+                $where[] = array('money_buy_str.account_name', '=', $account);
+            }
+        }
+        if (!empty($star_time)) {
+            if (!empty($end_time)){
+                $where[] = array('money_buy_str.money_time', '>', $star_time);
+                $where[] = array('money_buy_str.money_time', '<', $end_time);
+            }else{
+                $where[] = array('money_buy_str.money_time', '>', $star_time);
+            }
+        }else if(empty($star_time)){
+            if (!empty($end_time)){
+
+                $where[] = array('money_buy_str.money_time', '<', $end_time);
+            }
+        }
+        if (!empty($order_id)){
+            $where[] = array('money_buy_str.order_id', $order_id);
+        }
+        if ($status != -1) {
+            $where[] = array('money_buy_str.settle_status', '=', $status);
+        }
+        if ($order_status != -1) {
+            $where[] = array('money_buy_str.status', '=', $order_status);
+        }
+        $newapp = new \App\Models\MoneyBuyStr();
+        $data = $newapp->getinfo($list, $page, $where);
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    /**
+     *串关注单详情
+     */
+    function detail(Req $req) {
+        $id = $req->id;
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['account'] = isset($req->account) ? trim($req->account) :null ;
+        $request['match_id'] = isset($req->match_id) ? trim($req->match_id) :null ;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SoccerStringNoteList/detailinfo?id='.$id.'');
+        $dt->setLang('sportsnotelist');
+        $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 150));
+        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 220));
+        $dt->addColsFields('game_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('time', array('templet' => '#userdetail', 'sort' => false, 'width' => 180));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->enableCheckBox();
+        return view('sports/sports_notelistdetail', $dt->render($request));
+    }
+    function detailinfo(Req $req) {
+        $id = $req->id;
+
+        $newapp = new \App\Models\MoneyBuyStr();
+        $data = $newapp->getdetailinfo($id);
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data);
+    }
+
+    /**
+     *串关注单作废
+     */
+    public function invalid(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        //return 1;
+        $order = \App\Models\MoneyBuyStr::where('id',$id)->first();
+        //用戶账户金额
+        $account_money = \App\Models\Account_detailed::where('account_identity',$order->account_identity)->first();
+        //反水
+        $water_return_money = \App\Models\Money_details::where('trade_id',$order->order_id)->where('trade_type','7')->first();
+        if(!empty($water_return_money)){
+            $water_return = $water_return_money->money;
+        }else{
+            $water_return = 0;
+        }
+        //撤单后用户账户金额
+        $available_cash = $account_money->available_cash;
+        $new_available_cash = $available_cash+$order->money-$order->gain_money-$water_return;
+
+        $model =new \App\Models\Money_details();
+        $model->info_identity = UUID();
+        $model->trade_id = $order->order_id;
+        $model->account_name = $order->account_name;
+        $model->account_identity = $order->account_identity;
+        $model->money = abs($order->money-$order->gain_money-$water_return);
+        $model->money_time = date("Y-m-d H:i:s",time());
+        if($new_available_cash>$available_cash){
+            $model->money_type = '1';
+        }else{
+            $model->money_type = '2';
+        }
+        $model->money_cash = $new_available_cash;
+        $model->trade_type = '3';
+        $model->trade_desc = '管理员作废串关注单';
+        $model->status = '1';
+        try {
+            DB::beginTransaction();//开启事务
+            \App\Models\MoneyBuyStr::where('id',$id)->update(['status'=>'2'],['gain_money'=>'0']);
+            \App\Models\Account_detailed::where('account_identity',$order->account_identity)->update(['available_cash'=>$new_available_cash,'cash'=>$new_available_cash]);
+            $model->save();
+            DB::commit();//提交
+            return 1;
+        } catch (Exception $e) {
+            DB::rollback();//回滚
+            return -1;
+        }
+
+
+    }
+
+    /**
+     *串关注单首次结算
+     */
+    public function settlement(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $order = \App\Models\MoneyBuyStr::where('id', $id)->first();
+        $match = \App\Models\MoneyBuyMatch::where('batch_id',$order->batch_id)->where('bet_type','2')->get();
+        $bet_type = 2; //串关注单
+        $order_id = $order->order_id;
+        for($i=0;$i<count($match);$i++){
+            $match_id = $match[$i]->match_id;
+            $game_code = $match[$i]->game_code;
+            //判断输赢
+            //$match_ids[] = $match[$i]->match_id;
+            $settlementWinFail = new SettlementWinFail();
+            $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
+        }
+        $order_ids = array($order->order_id);
+        //return $match_ids;
+        //结算
+        $SettlementOrder = new SettlementOrder();
+        $settype = 1; //首次结算
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
+        return $data;
+    }
+
+    /**
+     *串关注单重新结算
+     */
+    public function resettlement(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $order = \App\Models\MoneyBuyStr::where('id',$id)->first();
+        $match = \App\Models\MoneyBuyMatch::where('batch_id',$order->batch_id)->where('bet_type','2')->get();
+        $bet_type = 2; //串关注单
+        $order_id = $order->order_id;
+        for($i=0;$i<count($match);$i++){
+            $match_id = $match[$i]->match_id;
+            $game_code = $match[$i]->game_code;
+            //判断输赢
+            $settlementWinFail = new SettlementWinFail();
+            $res = $settlementWinFail->ProcWinInfoByOneOrder($match_id, $order_id, $bet_type);
+        }
+        $order_ids = array($order->order_id);
+        //return $order_ids;
+        //重新结算
+        $SettlementOrder = new SettlementOrder();
+        $settype = 2; //重新结算
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type,$settype,$game_code,$match_id,$match_status=0);
+        return  $data;
+    }
+
+    /**
+     *串关注单批量结算
+     */
+    public function batchsettlement(){
+        $bet_type = 2; //串关注单
+        $orders = \App\Models\MoneyBuyStr::where('settle_status','1')->get();
+        $order_ids = array();
+        for($i=0;$i<count($orders);$i++){
+            $result = \App\Models\MoneyBuyMatch::where('batch_id',$orders[$i]->batch_id)->get();
+            $res = array();
+            for($j=0;$j<count($result);$j++){
+                $res[] = $result[$j]->result;
+            }
+            if(!in_array(0,$res)){
+                $order_ids[] = $orders[$i]->order_id;
+            }
+        }
+        //return $order_id;
+        $SettlementOrder = new SettlementOrder();
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
+        return $data;
+    }
+
+    /**
+     *删除串关注单
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\MoneyBuyStr::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+
+    /**
+     * 投注金额统计
+     */
+    function moneycount()
+    {
+        $where = Request::has('where') ? Request::get('where') : '';
+        $db = new \App\Models\MoneyBuyStr();
+
+        $data = $db->MoneyCount($where);
+        return responseToJson($data);
+    }
+
+}

+ 132 - 0
app/Http/Controllers/Admin/SpecialReportController.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class SpecialReportController extends Controller {
+	/**
+	 * @return 六合彩特码报表
+	 */
+	function index(Req $req) {
+		$request=array();
+		$request['game']=isset($req->game)?trim($req->game):'sixlottery';
+		$request['game_no']=isset($req->game_no)?trim($req->game_no):null;
+		$gamelist = \App\Models\GameType::select('table_name','name')->whereIn('table_name',array('sixlottery','sfsixlottery'))->get();
+        if($gamelist){
+			$request['gameList'] = $gamelist->toArray();
+		}else{
+			$request['gameList'] = array('table_name'=>'sixlottery','name'=>'香港六合彩');
+		}
+		
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/SpecialReport/ReportList');
+		$dt->setLang('sixlottery');
+		$dt->setPriKey('identity');
+		$dt->addColsFields('name', array('sort' => false));
+		$dt->addColsFields('specialcode', array('sort' => false,'width'=>'80'));
+		$dt->addColsFields('codea_summoney', array('sort' => false,'templet' => '#userrecharge','width'=>'150'));
+		$dt->addColsFields('codeb_summoney', array('sort' => false,'templet' => '#orderid_time','width'=>'150'));
+		$dt->addColsFields('code_summoney', array('sort' => false,'width'=>'150'));
+		$dt->addColsFields('code1_summoney', array('sort' => false,'width'=>'150'));
+		$dt->addColsFields('code2_summoney', array('sort' => false,'width'=>'150'));
+		$dt->addColsFields('code3_summoney', array('sort' => false,'width'=>'150'));
+		$dt->addColsFields('code4_summoney', array('sort' => false,'width'=>'150'));
+		$dt->addColsFields('code5_summoney', array('sort' => false,'width'=>'150'));
+		$dt->addColsFields('code6_summoney', array('sort' => false,'width'=>'150'));
+		$dt->addColsFields('codee_summoney', array('sort' => false));
+		$gameno = $this->getAllno($request['game']);
+		$request['noinfo'] = $gameno;
+		//print_r($gameno);exit;
+		return view('admin.SpecialReport/index', $dt->render($request));
+	}
+	
+	//获取特码报表
+	function ReportList() {
+		$where = array();
+		$info_no = Request::has('game_no') ? Request::get('game_no') : '';
+		$game = Request::has('game') ? Request::get('game') : 'sixlottery';
+		$where[] = array('delstatus','=',1);
+		$cls = '\App\Models\Game' . ucfirst($game);
+		$clsbuy = '\\App\\Model\\' . ucfirst($game) . 'Buy';
+		if(empty($info_no)){
+			$gameno =new $cls;
+			$gamenofirst = $gameno->getGameno();
+			if($gamenofirst<0){
+				return responseToJson($gamenofirst);
+			}
+			$info_no = $gamenofirst['info_no'];
+		}
+		$where[] = array('no','=',$info_no);
+		
+		$moneybuy =new $clsbuy;
+		$data = $moneybuy->getBetInfo($where);
+		//$data[0]['codes'] = '{"special_code_a":{"1":{"0":"1","settings":{"multiple":"42.5","back":"0"}},"2":{"0":"1","settings":{"multiple":"42.5","back":"0"}}}}';
+		if($data<0){
+			return responseToJson($data);
+		}
+		$newdata = array();
+		for($i=1;$i<50;$i++){
+			$newdata[] = array(
+				'name' => trans($game . '.' . $game),
+				'specialcode' => $i,
+				'codea_summoney' => 0,
+				'codeb_summoney' => 0,
+				'code_summoney' => 0,
+				'code1_summoney' => 0,
+				'code2_summoney' => 0,
+				'code3_summoney' => 0,
+				'code4_summoney' => 0,
+				'code5_summoney' => 0,
+				'code6_summoney' => 0,
+				'codee_summoney' => 0,
+			);
+		}
+
+		foreach($data as $k=>$v){
+			$codes = json_decode($v['codes'],1);
+			//print_r($codes);
+            if(!empty($codes)){
+                foreach($codes as $sk=>$sv){
+                    if($sk=='special_code_a'||$sk=='special_code_b'){
+                        foreach($sv as $ck=>$cv){
+                            $j = $ck-1;
+                            $codename = ($sk=='special_code_a')?'codea_summoney':'codeb_summoney';
+                            $newdata[$j]['code_summoney'] += $cv[0];
+                            $newdata[$j][$codename] += $cv[0];
+                        }
+                    }else if ($sk == 'general_special'){
+                    	foreach($sv as $ck=>$cv){
+                    		$gk = explode('_', $ck);
+                            $j = $gk[1]-1;
+                            $codename = 'code' . $gk[0] . '_summoney';
+                            $newdata[$j]['codee_summoney'] += $cv[0];
+                            $newdata[$j][$codename] += $cv[0];
+                        }
+                    }
+                }
+            }
+
+		}
+		
+		return \App\Lib\DataTable\DataTable::init()->toJson($newdata, 49);
+	}
+	
+	function getAllno($game){
+		$cls = '\App\Models\Game' . ucfirst($game);
+		$gameno =new $cls;
+		$gamenoAll = $gameno->getGameAllno();
+		if($gamenoAll<0){
+			return 1;
+		}else{
+			return $gamenoAll;
+		}
+	}
+
+}
+?>

+ 698 - 0
app/Http/Controllers/Admin/SportsBaseController.php

@@ -0,0 +1,698 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SportsBaseController extends Controller {
+
+    public function score(Req $req) {
+        //$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
+        $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+        $request['match_date'] = isset($req->match_date) ? trim($req->match_date) : null;
+        $request['recommend'] = isset($req->recommend) ? trim($req->recommend) : '';
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+
+        $request['is_rollball'] = isset($req->is_rollball) ? trim($req->is_rollball) : '0';
+        $request['is_today'] = isset($req->is_today) ? trim($req->is_today) : '0';
+        $request['is_morningplate'] = isset($req->is_morningplate) ? trim($req->is_morningplate) : '0';
+        $request['is_stringscene'] = isset($req->is_stringscene) ? trim($req->is_stringscene) : '0';
+
+        $source = \App\Models\Setinfo::where('id','1000')->first();
+        if($source->infocontent != '混合数据'){
+            $data = \App\Models\BaseLeague::join('st_bq_local_league','st_bq_league.id','=','st_bq_local_league.lg_id')->select('st_bq_league.id','st_bq_league.name_chinese')->where('st_bq_local_league.source',$source->infocontent)->get();
+        }else{
+            $data = \App\Models\BaseLeague::select('id','name_chinese')->get();
+        }
+
+//        $data = \App\Models\BaseLeague::select('id','lg_id','name_chinese')->get();
+        $request['league'] = $data;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SportsBase/info');
+        $dt->setLang('sportsbase');
+        $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
+        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        //$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
+        if (checkRriv('/admin/SportsBase/edit')) {
+            $arr[] = 'edit';
+        }
+        if (checkRriv('/admin/SportsBase/odds')) {
+            $arr[] = 'odds';
+        }
+        $dt->setToolBar($arr, array('width' => 200));
+        $dt->enableCheckBox();
+        return view('sports/base_match', $dt->render($request));
+    }
+
+    function info(Req $req) {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+        $home_team = Request::has('home_team') ? Request::get('home_team') : '';
+        $match_date = Request::has('match_date') ? Request::get('match_date') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time') : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time') : '';
+        //$match_date = $req->input('match_date');
+//        if(!empty($match_date)){
+//            return 2;
+//        }
+        $status = Request::has('status') ? Request::get('status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        $orwhere = array();
+//        if (!empty($name_chinese) && $name_chinese!=-1) {
+//            $where[] = array('st_bq_league.name_chinese', '=', $name_chinese);
+//        }
+        if (!empty($name_chinese)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_bq_league.name_chinese', 'like', '%' . $name_chinese . '%');
+            } else {
+                $where[] = array('st_bq_league.name_chinese', '=', $name_chinese);
+            }
+        }
+
+        if (!empty($home_team)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_bq_competition.home_team', 'like', '%' . $home_team . '%');
+                $orwhere[] = array('st_bq_competition.guest_team', 'like', '%' . $home_team . '%');
+            } else {
+                $where[] = array('st_bq_competition.home_team', '=', $home_team);
+                $orwhere[] = array('st_bq_competition.guest_team', '=', $home_team);
+            }
+        }
+
+        if (!empty($star_time)) {
+            if (!empty($end_time)){
+                $where[] = array('st_bq_competition.match_date', '>=', $star_time);
+                $where[] = array('st_bq_competition.match_date', '<=', $end_time);
+            }else{
+                $where[] = array('st_bq_competition.match_date', '>=', $star_time);
+            }
+        }else if(empty($star_time)){
+            if (!empty($end_time)){
+
+                $where[] = array('st_bq_competition.match_date', '<=', $end_time);
+            }
+        }
+//        if (!empty($match_date)) {
+//            $where[] = array('st_bq_competition.match_date', '=', $match_date);
+//        }
+        if ($status != -1) {
+            $where[] = array('st_bq_competition.status', '=', $status);
+        }
+        $newapp = new \App\Models\SportsBase();
+        $data = $newapp->getinfo($list, $page, $where,$orwhere);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+    /**
+     *设置是否为推荐赛事
+     */
+    function recommendmatch(Req $req) {
+        $id = $req->id;
+        $recommend = is_numeric($req->recommend) ? intval($req->recommend) : '';
+        if (empty($id) || !is_numeric($recommend)) {
+            return responseToJson(-2020100102);
+        }
+        $u_db = new \App\Models\SportsBase;
+        $data = array(
+            'recommend' => $recommend,
+        );
+        $res = $u_db->updateInfos($data, $id);
+        return responseToJson($res);
+    }
+    /**
+     *获取所有足球联赛信息
+     */
+    function getParent() {
+
+        $source = \App\Models\Setinfo::where('id','1000')->first();
+        if($source->infocontent != '混合数据'){
+            $data = \App\Models\BaseLeague::join('st_bq_local_league','st_bq_league.id','=','st_bq_local_league.lg_id')->select('st_bq_league.id','st_bq_league.name_chinese')->where('st_bq_local_league.source',$source->infocontent)->get();
+        }else{
+            $data = \App\Models\BaseLeague::select('id','name_chinese')->get();
+        }
+
+//        $data = \App\Models\BaseLeague::select('id','lg_id','name_chinese')->get();
+        if (!$data) {
+            return;
+        }
+        return $data->toArray();
+    }
+    /**
+     *获取所有国家信息
+     */
+    function getCountry() {
+        $data = \App\Models\Country::select('country_id','name_chinese')->get();
+        if (!$data) {
+            return;
+        }
+        for($i=0;$i<count($data);$i++){
+            $data[$i]->home_country_name = $data[$i]->name_chinese;
+            $data[$i]->home_country_id = $data[$i]->country_id;
+            $data[$i]->guest_country_name = $data[$i]->name_chinese;
+            $data[$i]->guest_country_id = $data[$i]->country_id;
+        }
+        return $data->toArray();
+    }
+    /**
+     *获取国家的球队信息
+     */
+    function getteam() {
+        $countryid = $_GET["countryid"];
+        $gametype = \App\Models\StGameType::where('game_code','bq')->first();
+        $res = \App\Models\Team::where('country_id',$countryid)->where('game_type_id',$gametype->id)->get();
+        return json_encode($res);
+    }
+    /**
+     *添加赛事
+     */
+    function add(Req $req) {
+        if (!$req->isMethod('post')) {
+            $parents = $this->getParent();
+            $country = $this->getCountry();
+            $countrys = $this->getCountry();
+            $lange = trans('menu');
+            foreach ($parents as $k => $v) {
+                $arr = trim($parents[$k]['name_chinese']);
+                if (isset($lange[$arr])) {
+                    $parents[$k]['name']=$lange[$arr];
+                }
+            }
+            $data['parents'] = $parents;
+            $data['country'] = $country;
+            $data['countrys'] = $countrys;
+            return view('sports.base_form', $data);
+        } else {
+            $model = new \App\Models\SportsBase();
+            $model->home_team = $req->input('home_team');
+            $model->guest_team = $req->input('guest_team');
+            $model->lg_id = $req->input('parent_id');
+            $model->match_date = $req->input('match_date');
+            $model->match_time = $req->input('match_time');
+            $model->status = $req->input('status');
+            if($req->input('is_rollball') == true){
+                $model->is_rollball = 1;
+            }else{
+                $model->is_rollball = 0;
+            }
+            if($req->input('is_today') == true){
+                $model->is_today = 1;
+            }else{
+                $model->is_today = 0;
+            }
+            if($req->input('is_morningplate') == true){
+                $model->is_morningplate = 1;
+            }else{
+                $model->is_morningplate = 0;
+            }
+            if($req->input('is_stringscene') == true){
+                $model->is_stringscene = 1;
+            }else{
+                $model->is_stringscene = 0;
+            }
+            $model->match_id = time() ;
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->tag = mt_rand(0,100) ;
+            $model->source = 'user-defined';
+
+            $db = new \App\Models\Stbqlocalmatch();
+            $db->source = 'user-defined';
+            $db->match_id = $model->match_id;
+
+            $model->save();
+            $db->save();
+            return responseToJson(1);
+
+        }
+    }
+
+    function view(Req $req) {
+        return $this->edit($req);
+    }
+
+    /**
+     *修改赛事
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+            $country = $this->getCountry();
+            $countrys = $this->getCountry();
+            $data = \App\Models\SportsBase::where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+            //查看赛事是否有下注细信息
+            $res = \App\Models\MoneyBuyMatch::where('match_id', $data->match_id)->get()->toArray();
+            if(!empty($res)){
+                if($data->status == 0){
+                    $match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废']);
+                }
+                if($data->status == 1){
+                    $match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+                }
+            }else{
+                if($data->status == 0){
+                    $match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+                }
+                if($data->status == 1){
+                    $match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+                }
+            }
+            if($data->status == 2){
+                $match_status =array(['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+            }
+            if($data->status == 3){
+                $match_status =array(['status'=>3,'name'=>'已结算'],['status'=>5,'name'=>'待结算']);
+            }
+            if($data->status == 4){
+                $match_status =array(['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+            }
+            if($data->status == 5){
+                $match_status =array(['status'=>5,'name'=>'待结算'],['status'=>4,'name'=>'作废']);
+            }
+            if($data->status == 6){
+                $match_status =array(['status'=>6,'name'=>'取消']);
+            }
+
+            $name_chinese = \App\Models\BaseLeague::where('id', $data->lg_id)->first();
+            $data->name_chinese = $name_chinese->name_chinese;
+            $data = $data->toArray();
+            $data['parents'] = $this->getParent();
+            $data['country'] = $country;
+            $data['countrys'] = $countrys;
+
+            $data['match_status'] = $match_status;
+
+
+            //$lange = trans('menu');
+            foreach ($data['parents'] as $k => $v) {
+                $arr = trim($data['parents'][$k]['name_chinese']);
+                if (isset($lange[$arr])) {
+                    $data['parents'][$k]['name_chinese']=$lange[$arr];
+                }
+            }
+
+            return view('sports.base_form', $data);
+        } else {
+            $model = new \App\Models\SportsBase();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            $model->home_team = $req->input('home_team');
+            $model->guest_team = $req->input('guest_team');
+//            if(gettype($req->input('parent_id'))=='integer'){
+//                $model->lg_id = $req->input('parent_id');
+//            }else{
+//                $model->name_chinese = $req->input('parent_id');
+//                $res = \App\Model\SportsLeague::where('name_chinese',$model->name_chinese)->first();
+//                $model->lg_id = $res->lg_id;
+//            }
+            $model->lg_id = $req->input('parent_id');
+            $model->match_date = $req->input('match_date');
+            $model->match_time = $req->input('match_time');
+            $model->status = $req->input('status');
+            if($req->input('is_rollball') == true){
+                $model->is_rollball = 1;
+            }else{
+                $model->is_rollball = 0;
+            }
+            if($req->input('is_today') == true){
+                $model->is_today = 1;
+            }else{
+                $model->is_today = 0;
+            }
+            if($req->input('is_morningplate') == true){
+                $model->is_morningplate = 1;
+            }else{
+                $model->is_morningplate = 0;
+            }
+            if($req->input('is_stringscene') == true){
+                $model->is_stringscene = 1;
+            }else{
+                $model->is_stringscene = 0;
+            }
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *删除赛事
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        $id = array();
+        $localmatch = \App\Models\Stbqlocalmatch::get();
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+                $match = \App\Models\SportsBase::where('id',$v)->first();
+                for($i=0;$i<count($localmatch);$i++){
+                    if($localmatch[$i]->match_id == $match->match_id){
+                        $id[] = $localmatch[$i]->id;
+                    }
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsBase::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        if(count($id)>0){
+            $row = \App\Models\Stbqlocalmatch::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+
+    /**
+     *赛事结果处理
+     */
+    public function dealwith(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        //return $id;
+        $SettlementWinFail = new SettlementWinFail();
+        $data = $SettlementWinFail->doRun($id);
+        return $data;
+    }
+
+    function odds(Req $req)
+    {
+        $cp_id = $req->id;
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['p_code'] = isset($req->p_code) ? trim($req->p_code) : '-1';
+        $request['id'] = isset($req->id) ? trim($req->id) : null;
+        $newapp = \App\Models\SportsBase::where('id',$request['id'])->first();
+        // $match_id = $newapp->match_id;
+        if(empty($newapp)){
+            $match_id = $req->input('id');
+        }else{
+            $match_id = $newapp->id;
+        }
+        $request['match_id'] = isset($match_id) ? trim($match_id) : null;
+
+        //$data = \App\Model\Matchcode::where('p_id','0')->get();
+
+        $data = \App\Models\Matchcode::where('p_id','0')->where('game_code','bq')->get();
+        $request['pcode'] = $data;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SportsBase/oddsinfo?match_id='.$match_id.'');
+        $dt->setLang('sportssoccer');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('odds_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('condition', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('odds', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+//        $dt->addColsFields('p_id', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('p_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('max', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('min', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('expire_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('source', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        if (checkRriv('/admin/SportsBase/oddsedit?id='.$cp_id.'')) {
+            $arr[] = 'oddsedit';
+        }
+        $dt->setToolBar($arr, array('width' => 150));
+        $dt->enableCheckBox();
+
+        return view('sports/base_odds', $dt->render($request));
+    }
+
+    function oddsinfo(Req $req){
+        $lange = trans('sportsoddscode');
+        $match_id = $req->match_id;
+        $p_code = Request::has('p_code') ? Request::get('p_code') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $where = array();
+        if (!empty($p_code) && $p_code!=-1) {
+            $where[] = array('st_bq_odds.p_code', '=', $p_code);
+        }
+        if (!empty($status) && $status != -1) {
+            $where[] = array('st_bq_odds.status', '=', $status);
+        }
+
+        if (intval($match_id) < 1) {
+            return -1;
+        }
+        $new = new \App\Models\BaseOdds();
+        $data = $new->getodds($match_id,$where);
+
+        foreach ($data as $k => $v) {
+            $odds_code = trim($data[$k]['odds_code']);
+            $p_code = trim($data[$k]['p_code']);
+            if (isset($lange[$odds_code])) {
+                $data[$k]['odds_code']=$lange[$odds_code];
+            }
+            if (isset($lange[$p_code])) {
+                $data[$k]['p_code']=$lange[$p_code];
+            }
+        };
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data);
+    }
+    /**
+     *根据选择的父级赔率代码获取对应的子级赔率代码
+     */
+    function getoddscode() {
+        $p_code = $_GET["pcode"];
+        $res = \App\Models\Matchcode::where('odds_code',$p_code)->first();
+        $codedata = \App\Models\Matchcode::where('p_id',$res->id)->get();
+        return json_encode($codedata);
+    }
+    /**
+     *添加赔率
+     */
+    function addodds(Req $req) {
+
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
+
+        $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','bq')->get();
+        for($i=0;$i<count($pcodedata);$i++){
+            $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
+        }
+
+        if (!$req->isMethod('post')) {
+            $cp_id = $_SERVER['QUERY_STRING'];  //获取url中的参数--赛事id
+            $data = ["match_id"=>$cp_id];
+            $data['pcode'] = $pcodedata;
+            return view('sports.base_odds_form',$data);
+        } else {
+            $model = new \App\Models\BaseOdds();
+            $date = new \App\Models\BaseOddsRecord();
+            $model->match_id = $req->input('match_id');
+            $model->odds_code = $req->input('code');
+            $model->status = $req->input('status');
+            $model->p_code = $req->input('pcode');
+            $res = \App\Models\Matchcode::where('odds_code',$model->p_code)->first();
+            $model->p_id = $res->id;
+            $result = \App\Models\BaseOdds::where('odds_code',$model->odds_code)->where('p_id',$model->p_id)->orderby('utime','desc')->first();
+            if(!empty($result)){
+                $sort = $result->sort;
+                $model->sort = $sort+1;
+            }else{
+                $model->sort = 0;
+            }
+            $model->odds = $req->input('odds');
+            $model->condition = $req->input('condition');
+            $model->max = $req->input('max');
+            $model->min = $req->input('min');
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->sole = md5($model->match_id.$model->odds_code.$model->sort.$model->p_id.$model->ctime);
+            $model->source = 'user-defined';
+            $lg_id = \App\Models\SportsBase::where('match_id',$model->match_id)->first();
+            if(!empty($lg_id)){
+                $model->lg_id = $lg_id->lg_id;
+            }
+            $model->expire_time = $req->input('expire_time');
+            $model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+
+            $date->match_id = $model->match_id;
+            $date->odds_code = $model->odds_code;
+            $date->status = $model->status;
+            $date->p_code = $model->p_code;
+            $date->p_id = $model->p_id;
+            $record = \App\Models\BaseOddsRecord::where('odds_code',$date->odds_code)->where('p_id',$date->p_id)->orderby('utime','desc')->first();
+            if(!empty($record)){
+                $sort = $record->sort;
+                $date->sort = $sort+1;
+            }else{
+                $date->sort = 0;
+            }
+            $date->odds = $model->odds;
+            $date->condition = $model->condition;
+            $date->max = $model->max;
+            $date->min = $model->min;
+            $date->ctime = $model->ctime;
+            $date->utime = $model->utime;
+            $date->source = $model->source;
+            $date->lg_id = $model->lg_id;
+            $date->odds_only = $model->odds_only;
+
+            $model->save();
+            $date->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *修改赔率
+     */
+    function oddsedit(Req $req) {
+
+        $pcodedata = \App\Models\Matchcode::where('p_id','0')->get();
+
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->where('game_code','bq')->get();
+        for($i=0;$i<count($pcodedata);$i++){
+            $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
+        }
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+
+            $data = \App\Models\BaseOdds::where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+
+            $res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
+
+            //$res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->where('game_type','bq')->first();
+            if(!empty($res)){
+                $data->odds_name = $res->odds_name;
+            }
+
+            $expire_time = $data->expire_time; //2019-04-15 21:10:00
+            $str1 = str_replace(" ","T",$expire_time);
+            $data->expire_time = $str1;
+
+            $odds_code = trim($data->odds_code);
+            $p_code = trim($data->p_code);
+            if (isset($lange[$odds_code])) {
+                $data->odds_code_cn=$lange[$odds_code];
+            }
+            if (isset($lange[$p_code])) {
+                $data->p_code_cn=$lange[$p_code];
+            }
+            $data = $data->toArray();
+
+            $data['pcode'] = $pcodedata;
+            //$data['code'] = $codedata;
+
+            return view('sports.base_odds_form', $data);
+        } else {
+            $model = new \App\Models\BaseOdds();
+            $data = new \App\Models\BaseOddsRecord();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            $model->odds_code = $req->input('code');
+            $model->status = $req->input('status');
+            $model->p_code = $req->input('pcode');
+            $model->odds = $req->input('odds');
+            $model->condition = $req->input('condition');
+            $model->max = $req->input('max');
+            $model->min = $req->input('min');
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->expire_time = $req->input('expire_time');
+            $model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+
+            $result = \App\Models\BaseOdds::where('id',$model->id)->first();
+            $data->match_id = $result->match_id;
+            $data->odds_code = $model->odds_code;
+            $data->status = $model->status;
+            $data->p_code = $model->p_code;
+            $data->p_id = $model->p_id;
+            $record = \App\Models\BaseOddsRecord::where('match_id',$data->match_id)->where('odds_code',$data->odds_code)->where('p_id',$data->p_id)->orderby('utime','desc')->first();
+            if(!empty($record)){
+                $sort = $record->sort;
+                $data->sort = $sort+1;
+            }else{
+                $data->sort = 0;
+            }
+            $data->odds = $model->odds;
+            $data->condition = $model->condition;
+            $data->max = $model->max;
+            $data->min = $model->min;
+            $data->ctime = $model->ctime;
+            $data->utime = $model->utime;
+            $data->source = $result->source;
+            $data->lg_id = $result->lg_id;
+            $data->odds_only = $result->odds_only;
+
+            $model->save();
+            $data->save();
+            return responseToJson(1);
+        }
+
+    }
+    /**
+     *删除赔率
+     */
+    public function oddsdelete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\BaseOdds::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+}

+ 692 - 0
app/Http/Controllers/Admin/SportsBasketController.php

@@ -0,0 +1,692 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SportsBasketController extends Controller {
+
+	public function score(Req $req) {
+		//$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
+		$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$request['match_date'] = isset($req->match_date) ? trim($req->match_date) : null;
+		$request['recommend'] = isset($req->recommend) ? trim($req->recommend) : '';
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+		$request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+
+		$request['is_rollball'] = isset($req->is_rollball) ? trim($req->is_rollball) : '0';
+		$request['is_today'] = isset($req->is_today) ? trim($req->is_today) : '0';
+		$request['is_morningplate'] = isset($req->is_morningplate) ? trim($req->is_morningplate) : '0';
+		$request['is_stringscene'] = isset($req->is_stringscene) ? trim($req->is_stringscene) : '0';
+
+        $source = \App\Models\Setinfo::where('id','1000')->first();
+        if($source->infocontent != '混合数据'){
+            $data = \App\Models\BasketLeague::join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')->select('st_lq_league.id','st_lq_league.name_chinese')->where('st_lq_local_league.source',$source->infocontent)->get();
+        }else{
+            $data = \App\Models\BasketLeague::select('id','name_chinese')->get();
+        }
+
+//		$data = \App\Models\BasketLeague::select('id','lg_id','name_chinese')->get();
+		$request['league'] = $data;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/SportsBasket/info');
+		$dt->setLang('sportsbase');
+		$dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+		$dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+		$dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+		$dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
+		$dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+		$dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+		$dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
+		$dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+		//$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
+		//$arr[] = 'view';
+		if (checkRriv('/admin/SportsBasket/edit')) {
+			$arr[] = 'edit';
+		}
+		if (checkRriv('/admin/SportsBasket/odds')) {
+			$arr[] = 'odds';
+		}
+		$dt->setToolBar($arr, array('width' => 200));
+		$dt->enableCheckBox();
+		return view('sports/basket_match', $dt->render($request));
+	}
+
+	function info(Req $req) {
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$match_date = Request::has('match_date') ? Request::get('match_date') : '';
+		$star_time = Request::get('star_time') ? Request::get('star_time') : '';
+		$end_time = Request::get('end_time') ? Request::get('end_time') : '';
+		//$match_date = $req->input('match_date');
+//        if(!empty($match_date)){
+//            return 2;
+//        }
+		$status = Request::has('status') ? Request::get('status') : '';
+		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$where = array();
+		$orwhere = array();
+//		if (!empty($name_chinese) && $name_chinese!=-1) {
+//			$where[] = array('st_lq_league.name_chinese', '=', $name_chinese);
+//		}
+		if (!empty($name_chinese)) {
+			if (empty($sureblur) || $sureblur == 'off') {
+				$where[] = array('st_lq_league.name_chinese', 'like', '%' . $name_chinese . '%');
+			} else {
+				$where[] = array('st_lq_league.name_chinese', '=', $name_chinese);
+			}
+		}
+
+		if (!empty($home_team)) {
+			if (empty($sureblur) || $sureblur == 'off') {
+				$where[] = array('st_lq_competition.home_team', 'like', '%' . $home_team . '%');
+				$orwhere[] = array('st_lq_competition.guest_team', 'like', '%' . $home_team . '%');
+			} else {
+				$where[] = array('st_lq_competition.home_team', '=', $home_team);
+				$orwhere[] = array('st_lq_competition.guest_team', '=', $home_team);
+			}
+		}
+
+		if (!empty($star_time)) {
+			if (!empty($end_time)){
+				$where[] = array('st_lq_competition.match_date', '>=', $star_time);
+				$where[] = array('st_lq_competition.match_date', '<=', $end_time);
+			}else{
+				$where[] = array('st_lq_competition.match_date', '>=', $star_time);
+			}
+		}else if(empty($star_time)){
+			if (!empty($end_time)){
+
+				$where[] = array('st_lq_competition.match_date', '<=', $end_time);
+			}
+		}
+//		if (!empty($match_date)) {
+//			$where[] = array('st_lq_competition.match_date', '=', $match_date);
+//		}
+		if ($status != -1) {
+			$where[] = array('st_lq_competition.status', '=', $status);
+		}
+
+		$newapp = new \App\Models\SportsBasket();
+		$data = $newapp->getinfo($list, $page, $where,$orwhere);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+	/**
+	 *设置是否为推荐赛事
+	 */
+	function recommendmatch(Req $req) {
+		$id = $req->id;
+		$recommend = is_numeric($req->recommend) ? intval($req->recommend) : '';
+		if (empty($id) || !is_numeric($recommend)) {
+			return responseToJson(-2020100102);
+		}
+		$u_db = new \App\Models\SportsBasket;
+		$data = array(
+			'recommend' => $recommend,
+		);
+		$res = $u_db->updateInfos($data, $id);
+		return responseToJson($res);
+	}
+	/**
+	 *获取所有篮球联赛信息
+	 */
+	function getParent() {
+
+        $source = \App\Models\Setinfo::where('id','1000')->first();
+        if($source->infocontent != '混合数据'){
+            $data = \App\Models\BasketLeague::join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')->select('st_lq_league.id','st_lq_league.name_chinese')->where('st_lq_local_league.source',$source->infocontent)->get();
+        }else{
+            $data = \App\Models\BasketLeague::select('id','name_chinese')->get();
+        }
+
+//		$data = \App\Models\BasketLeague::select('id','lg_id','name_chinese')->get();
+		if (!$data) {
+			return;
+		}
+		return $data->toArray();
+	}
+	/**
+	 *获取所有国家信息
+	 */
+	function getCountry() {
+		$data = \App\Models\Country::select('country_id','name_chinese')->get();
+		if (!$data) {
+			return;
+		}
+		for($i=0;$i<count($data);$i++){
+			$data[$i]->home_country_name = $data[$i]->name_chinese;
+			$data[$i]->home_country_id = $data[$i]->country_id;
+			$data[$i]->guest_country_name = $data[$i]->name_chinese;
+			$data[$i]->guest_country_id = $data[$i]->country_id;
+		}
+		return $data->toArray();
+	}
+	/**
+	 *获取国家的球队信息
+	 */
+	function getteam() {
+		$countryid = $_GET["countryid"];
+		$gametype = \App\Models\StGameType::where('game_code','zq')->first();
+		$res = \App\Models\Team::where('country_id',$countryid)->where('game_type_id',$gametype->id)->get();
+		return json_encode($res);
+	}
+	/**
+	 *添加赛事
+	 */
+	function add(Req $req) {
+		if (!$req->isMethod('post')) {
+			$parents = $this->getParent();
+			$country = $this->getCountry();
+			$countrys = $this->getCountry();
+			$lange = trans('menu');
+			foreach ($parents as $k => $v) {
+				$arr = trim($parents[$k]['name_chinese']);
+				if (isset($lange[$arr])) {
+					$parents[$k]['name']=$lange[$arr];
+				}
+			}
+			$data['parents'] = $parents;
+			$data['country'] = $country;
+			$data['countrys'] = $countrys;
+			return view('sports.basket_form', $data);
+		} else {
+			$model = new \App\Models\SportsBasket();
+			$model->home_team = $req->input('home_team');
+			$model->guest_team = $req->input('guest_team');
+			$model->lg_id = $req->input('parent_id');
+			$model->match_date = $req->input('match_date');
+			$model->match_time = $req->input('match_time');
+			$model->status = $req->input('status');
+			if($req->input('is_rollball') == true){
+				$model->is_rollball = 1;
+			}else{
+				$model->is_rollball = 0;
+			}
+			if($req->input('is_today') == true){
+				$model->is_today = 1;
+			}else{
+				$model->is_today = 0;
+			}
+			if($req->input('is_morningplate') == true){
+				$model->is_morningplate = 1;
+			}else{
+				$model->is_morningplate = 0;
+			}
+			if($req->input('is_stringscene') == true){
+				$model->is_stringscene = 1;
+			}else{
+				$model->is_stringscene = 0;
+			}
+			$model->match_id = time() ;
+			$model->ctime = date('Y-m-d H:i:s',time());
+			$model->utime = date('Y-m-d H:i:s',time());
+			$model->tag = mt_rand(0,100) ;
+			$model->source = 'user-defined';
+
+			$db = new \App\Models\Stlqlocalmatch();
+			$db->source = 'user-defined';
+			$db->match_id = $model->match_id;
+
+			$model->save();
+			$db->save();
+			return responseToJson(1);
+
+		}
+	}
+
+	function view(Req $req) {
+		return $this->edit($req);
+	}
+
+	/**
+	 *修改赛事
+	 */
+	function edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+			$country = $this->getCountry();
+			$countrys = $this->getCountry();
+			$data = \App\Models\SportsBasket::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			//查看赛事是否有下注细信息
+			$res = \App\Models\MoneyBuyMatch::where('match_id', $data->match_id)->get()->toArray();
+			if(!empty($res)){
+				if($data->status == 0){
+					$match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废']);
+				}
+				if($data->status == 1){
+					$match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+				}
+			}else{
+				if($data->status == 0){
+					$match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+				}
+				if($data->status == 1){
+					$match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+				}
+			}
+			if($data->status == 2){
+				$match_status =array(['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+			}
+			if($data->status == 3){
+				$match_status =array(['status'=>3,'name'=>'已结算'],['status'=>5,'name'=>'待结算']);
+			}
+			if($data->status == 4){
+				$match_status =array(['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+			}
+			if($data->status == 5){
+				$match_status =array(['status'=>5,'name'=>'待结算'],['status'=>4,'name'=>'作废']);
+			}
+			if($data->status == 6){
+				$match_status =array(['status'=>6,'name'=>'取消']);
+			}
+
+			$name_chinese = \App\Models\BasketLeague::where('id', $data->lg_id)->first();
+			$data->name_chinese = $name_chinese->name_chinese;
+			$data = $data->toArray();
+			$data['parents'] = $this->getParent();
+			$data['country'] = $country;
+			$data['countrys'] = $countrys;
+
+			$data['match_status'] = $match_status;
+
+
+			//$lange = trans('menu');
+			foreach ($data['parents'] as $k => $v) {
+				$arr = trim($data['parents'][$k]['name_chinese']);
+				if (isset($lange[$arr])) {
+					$data['parents'][$k]['name_chinese']=$lange[$arr];
+				}
+			}
+
+			return view('sports.basket_form', $data);
+		} else {
+			$model = new \App\Models\SportsBasket();
+			$model->id = $req->input('id');
+			$model = $model::find($model->id);
+			$model->home_team = $req->input('home_team');
+			$model->guest_team = $req->input('guest_team');
+//            if(gettype($req->input('parent_id'))=='integer'){
+//                $model->lg_id = $req->input('parent_id');
+//            }else{
+//                $model->name_chinese = $req->input('parent_id');
+//                $res = \App\Model\SportsLeague::where('name_chinese',$model->name_chinese)->first();
+//                $model->lg_id = $res->lg_id;
+//            }
+			$model->lg_id = $req->input('parent_id');
+			$model->match_date = $req->input('match_date');
+			$model->match_time = $req->input('match_time');
+			$model->status = $req->input('status');
+			if($req->input('is_rollball') == true){
+				$model->is_rollball = 1;
+			}else{
+				$model->is_rollball = 0;
+			}
+			if($req->input('is_today') == true){
+				$model->is_today = 1;
+			}else{
+				$model->is_today = 0;
+			}
+			if($req->input('is_morningplate') == true){
+				$model->is_morningplate = 1;
+			}else{
+				$model->is_morningplate = 0;
+			}
+			if($req->input('is_stringscene') == true){
+				$model->is_stringscene = 1;
+			}else{
+				$model->is_stringscene = 0;
+			}
+			$model->ctime = date('Y-m-d H:i:s',time());
+			$model->utime = date('Y-m-d H:i:s',time());
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+	/**
+	 *删除赛事
+	 */
+	public function delete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		$id = array();
+		$localmatch = \App\Models\Stlqlocalmatch::get();
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+				$match = \App\Models\SportsBasket::where('id',$v)->first();
+				for($i=0;$i<count($localmatch);$i++){
+					if($localmatch[$i]->match_id == $match->match_id){
+						$id[] = $localmatch[$i]->id;
+					}
+				}
+			}
+		}
+
+		$rows = \App\Models\SportsBasket::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		if(count($id)>0) {
+			$row = \App\Models\Stlqlocalmatch::whereIn('id', $id)->delete();
+			if (!$row) {
+				return responseToJson(-2003); //id????
+			}
+		}
+		return responseToJson(1, trans('menu.delete_success')); //id����
+
+	}
+
+	/**
+	 *赛事结果处理
+	 */
+	public function dealwith(Req $req)
+	{
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		//return $id;
+		$SettlementWinFail = new SettlementWinFail();
+		$data = $SettlementWinFail->doRun($id);
+		return $data;
+	}
+
+	function odds(Req $req)
+	{
+		$cp_id = $req->id;
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['p_code'] = isset($req->p_code) ? trim($req->p_code) : '-1';
+		$request['id'] = isset($req->id) ? trim($req->id) : null;
+		$newapp = \App\Models\SportsBasket::where('id',$request['id'])->first();
+		// $match_id = $newapp->match_id;
+		if(empty($newapp)){
+			$match_id = $req->input('id');
+		}else{
+			$match_id = $newapp->id;
+		}
+		$request['match_id'] = isset($match_id) ? trim($match_id) : null;
+		//$data = \App\Model\Matchcode::where('p_id','0')->get();
+		$data = \App\Models\Matchcode::where('p_id','0')->where('game_code','lq')->get();
+		$request['pcode'] = $data;
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/SportsBasket/oddsinfo?match_id='.$match_id.'');
+		$dt->setLang('sportssoccer');
+		$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+		$dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+		$dt->addColsFields('odds_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+		$dt->addColsFields('condition', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+		$dt->addColsFields('odds', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+//        $dt->addColsFields('p_id', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+		$dt->addColsFields('p_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+		$dt->addColsFields('max', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+		$dt->addColsFields('min', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+		$dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+		$dt->addColsFields('expire_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+		$dt->addColsFields('source', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+		if (checkRriv('/admin/SportsBasket/oddsedit?id='.$cp_id.'')) {
+			$arr[] = 'oddsedit';
+		}
+		$dt->setToolBar($arr, array('width' => 150));
+		$dt->enableCheckBox();
+
+		return view('sports/basket_odds', $dt->render($request));
+	}
+
+	function oddsinfo(Req $req){
+		$lange = trans('sportsoddscode');
+		$match_id = $req->match_id;
+		$p_code = Request::has('p_code') ? Request::get('p_code') : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$where = array();
+		if (!empty($p_code) && $p_code!=-1) {
+			$where[] = array('st_lq_odds.p_code', '=', $p_code);
+		}
+		if (!empty($status) && $status != -1) {
+			$where[] = array('st_lq_odds.status', '=', $status);
+		}
+
+		if (intval($match_id) < 1) {
+			return -1;
+		}
+		$new = new \App\Models\BasketOdds();
+		$data = $new->getodds($match_id,$where);
+
+//		foreach ($data as $k => $v) {
+//			$odds_code = trim($data[$k]['odds_code']);
+//			$p_code = trim($data[$k]['p_code']);
+//			if (isset($lange[$odds_code])) {
+//				$data[$k]['odds_code']=$lange[$odds_code];
+//			}
+//			if (isset($lange[$p_code])) {
+//				$data[$k]['p_code']=$lange[$p_code];
+//			}
+//		};
+
+		return \App\Lib\DataTable\DataTable::init()->toJson($data);
+	}
+	/**
+	 *根据选择的父级赔率代码获取对应的子级赔率代码
+	 */
+	function getoddscode() {
+		$p_code = $_GET["pcode"];
+		$res = \App\Models\Matchcode::where('odds_code',$p_code)->first();
+		$codedata = \App\Models\Matchcode::where('p_id',$res->id)->get();
+		return json_encode($codedata);
+	}
+	/**
+	 *添加赔率
+	 */
+	function addodds(Req $req) {
+		//$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
+		$pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','lq')->get();
+		for($i=0;$i<count($pcodedata);$i++){
+			$pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
+		}
+
+		if (!$req->isMethod('post')) {
+			$cp_id = $_SERVER['QUERY_STRING'];  //获取url中的参数--赛事id
+			$data = ["match_id"=>$cp_id];
+			$data['pcode'] = $pcodedata;
+			return view('sports.basket_odds_form',$data);
+		} else {
+			$model = new \App\Models\BasketOdds();
+			$date = new \App\Models\BasketOddsRecord();
+			$model->match_id = $req->input('match_id');
+			$model->odds_code = $req->input('code');
+			$model->status = $req->input('status');
+			$model->p_code = $req->input('pcode');
+			$res = \App\Models\Matchcode::where('odds_code',$model->p_code)->first();
+			$model->p_id = $res->id;
+			$result = \App\Models\BasketOdds::where('odds_code',$model->odds_code)->where('p_id',$model->p_id)->orderby('utime','desc')->first();
+			if(!empty($result)){
+				$sort = $result->sort;
+				$model->sort = $sort+1;
+			}else{
+				$model->sort = 0;
+			}
+			$model->odds = $req->input('odds');
+			$model->condition = $req->input('condition');
+			$model->max = $req->input('max');
+			$model->min = $req->input('min');
+			$model->ctime = date('Y-m-d H:i:s',time());
+			$model->utime = date('Y-m-d H:i:s',time());
+			$model->sole = md5($model->match_id.$model->odds_code.$model->sort.$model->p_id.$model->ctime);
+			$model->source = 'user-defined';
+			$lg_id = \App\Models\SportsBasket::where('match_id',$model->match_id)->first();
+			if(!empty($lg_id)){
+				$model->lg_id = $lg_id->lg_id;
+			}
+			$model->expire_time = $req->input('expire_time');
+			$model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+
+			$date->match_id = $model->match_id;
+			$date->odds_code = $model->odds_code;
+			$date->status = $model->status;
+			$date->p_code = $model->p_code;
+			$date->p_id = $model->p_id;
+			$record = \App\Models\BasketOddsRecord::where('odds_code',$date->odds_code)->where('p_id',$date->p_id)->orderby('utime','desc')->first();
+			if(!empty($record)){
+				$sort = $record->sort;
+				$date->sort = $sort+1;
+			}else{
+				$date->sort = 0;
+			}
+			$date->odds = $model->odds;
+			$date->condition = $model->condition;
+			$date->max = $model->max;
+			$date->min = $model->min;
+			$date->ctime = $model->ctime;
+			$date->utime = $model->utime;
+			$date->source = $model->source;
+			$date->lg_id = $model->lg_id;
+			$date->odds_only = $model->odds_only;
+
+			$model->save();
+			$date->save();
+			return responseToJson(1);
+		}
+	}
+	/**
+	 *修改赔率
+	 */
+	function oddsedit(Req $req) {
+		//$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
+		$pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','lq')->get();
+		for($i=0;$i<count($pcodedata);$i++){
+			$pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
+		}
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\BasketOdds::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			//$res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->where('game_type','lq')->first();
+			$res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
+			if(!empty($res)){
+				$data->odds_name = $res->odds_name;
+			}
+
+			$expire_time = $data->expire_time; //2019-04-15 21:10:00
+			$str1 = str_replace(" ","T",$expire_time);
+			$data->expire_time = $str1;
+
+			$odds_code = trim($data->odds_code);
+			$p_code = trim($data->p_code);
+			if (isset($lange[$odds_code])) {
+				$data->odds_code_cn=$lange[$odds_code];
+			}
+			if (isset($lange[$p_code])) {
+				$data->p_code_cn=$lange[$p_code];
+			}
+			$data = $data->toArray();
+
+			$data['pcode'] = $pcodedata;
+			//$data['code'] = $codedata;
+
+			return view('sports.basket_odds_form', $data);
+		} else {
+			$model = new \App\Models\BasketOdds();
+			$data = new \App\Models\BasketOddsRecord();
+			$model->id = $req->input('id');
+			$model = $model::find($model->id);
+			$model->odds_code = $req->input('code');
+			$model->status = $req->input('status');
+			$model->p_code = $req->input('pcode');
+			$model->odds = $req->input('odds');
+			$model->condition = $req->input('condition');
+			$model->max = $req->input('max');
+			$model->min = $req->input('min');
+			$model->ctime = date('Y-m-d H:i:s',time());
+			$model->utime = date('Y-m-d H:i:s',time());
+			$model->expire_time = $req->input('expire_time');
+			$model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+
+			$result = \App\Models\BasketOdds::where('id',$model->id)->first();
+			$data->match_id = $result->match_id;
+			$data->odds_code = $model->odds_code;
+			$data->status = $model->status;
+			$data->p_code = $model->p_code;
+			$data->p_id = $model->p_id;
+			$record = \App\Models\BasketOddsRecord::where('match_id',$data->match_id)->where('odds_code',$data->odds_code)->where('p_id',$data->p_id)->orderby('utime','desc')->first();
+			if(!empty($record)){
+				$sort = $record->sort;
+				$data->sort = $sort+1;
+			}else{
+				$data->sort = 0;
+			}
+			$data->odds = $model->odds;
+			$data->condition = $model->condition;
+			$data->max = $model->max;
+			$data->min = $model->min;
+			$data->ctime = $model->ctime;
+			$data->utime = $model->utime;
+			$data->source = $result->source;
+			$data->lg_id = $result->lg_id;
+			$data->odds_only = $result->odds_only;
+
+			$model->save();
+			$data->save();
+			return responseToJson(1);
+		}
+
+	}
+	/**
+	 *删除赔率
+	 */
+	public function oddsdelete(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //id������
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id����
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+
+		$rows = \App\Models\BasketOdds::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id����
+		}
+		return responseToJson(1, trans('menu.delete_success')); //id����
+
+	}
+}

+ 705 - 0
app/Http/Controllers/Admin/SportsSoccerController.php

@@ -0,0 +1,705 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SportsSoccerController extends Controller {
+
+    public function score(Req $req) {
+        //$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
+        $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+        $request['match_date'] = isset($req->match_date) ? trim($req->match_date) : null;
+        $request['recommend'] = isset($req->recommend) ? trim($req->recommend) : '';
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+
+        $request['is_rollball'] = isset($req->is_rollball) ? trim($req->is_rollball) : '0';
+        $request['is_today'] = isset($req->is_today) ? trim($req->is_today) : '0';
+        $request['is_morningplate'] = isset($req->is_morningplate) ? trim($req->is_morningplate) : '0';
+        $request['is_stringscene'] = isset($req->is_stringscene) ? trim($req->is_stringscene) : '0';
+
+        $source = \App\Models\Setinfo::where('id','1000')->first();
+        if($source->infocontent != '混合数据'){
+            $data = \App\Models\SoccerLeague::join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')->select('st_zq_league.id','st_zq_league.name_chinese')->where('st_zq_local_league.source',$source->infocontent)->get();
+        }else{
+            $data = \App\Models\SoccerLeague::select('id','name_chinese')->get();
+        }
+
+//        $data = \App\Models\SoccerLeague::select('id','lg_id','name_chinese')->get();
+
+        $request['league'] = $data;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SportsSoccer/info');
+        $dt->setLang('sportsbase');
+        $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
+        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        //$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
+        if (checkRriv('/admin/SportsSoccer/edit')) {
+            $arr[] = 'edit';
+        }
+        if (checkRriv('/admin/SportsSoccer/odds')) {
+            $arr[] = 'odds';
+        }
+        $dt->setToolBar($arr, array('width' => 200));
+        $dt->enableCheckBox();
+        return view('sports/soccer_match', $dt->render($request));
+    }
+
+    function info(Req $req) {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+        $home_team = Request::has('home_team') ? Request::get('home_team') : '';
+        $match_date = Request::has('match_date') ? Request::get('match_date') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time') : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        $orwhere = array();
+//        if (!empty($name_chinese) && $name_chinese!=-1) {
+//            $where[] = array('st_zq_league.name_chinese', '=', $name_chinese);
+//        }
+        if (!empty($name_chinese)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_zq_league.name_chinese', 'like', '%' . $name_chinese . '%');
+            } else {
+                $where[] = array('st_zq_league.name_chinese', '=', $name_chinese);
+            }
+        }
+        if (!empty($home_team)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_zq_competition.home_team', 'like', '%' . $home_team . '%');
+                $orwhere[] = array('st_zq_competition.guest_team', 'like', '%' . $home_team . '%');
+            } else {
+                $where[] = array('st_zq_competition.home_team', '=', $home_team);
+                $orwhere[] = array('st_zq_competition.guest_team', '=', $home_team);
+            }
+        }
+
+        if (!empty($star_time)) {
+            if (!empty($end_time)){
+                $where[] = array('st_zq_competition.match_date', '>=', $star_time);
+                $where[] = array('st_zq_competition.match_date', '<=', $end_time);
+            }else{
+                $where[] = array('st_zq_competition.match_date', '>=', $star_time);
+            }
+        }else if(empty($star_time)){
+            if (!empty($end_time)){
+
+                $where[] = array('st_zq_competition.match_date', '<=', $end_time);
+            }
+        }
+
+//        if(!empty($match_date)){
+//            $where[] = array('st_zq_competition.match_date', '=', $match_date);
+//        }
+        if($status != -1){
+            $where[] = array('st_zq_competition.status', '=', $status);
+        }
+
+        $newapp = new \App\Models\SportsSoccer();
+        $data = $newapp->getinfo($list, $page, $where,$orwhere);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+    /**
+     *设置是否为推荐赛事
+     */
+    function recommendmatch(Req $req) {
+        $id = $req->id;
+        $recommend = is_numeric($req->recommend) ? intval($req->recommend) : '';
+        if (empty($id) || !is_numeric($recommend)) {
+            return responseToJson(-2020100102);
+        }
+        $u_db = new \App\Models\SportsSoccer;
+        $data = array(
+            'recommend' => $recommend,
+        );
+        $res = $u_db->updateInfos($data, $id);
+        return responseToJson($res);
+    }
+    /**
+     *获取所有足球联赛信息
+     */
+    function getParent() {
+        $source = \App\Models\Setinfo::where('id','1000')->first();
+        if($source->infocontent != '混合数据'){
+            $data = \App\Models\SoccerLeague::join('st_zq_local_league','st_zq_league.id','=','st_zq_local_league.lg_id')->select('st_zq_league.id','st_zq_league.name_chinese')->where('st_zq_local_league.source',$source->infocontent)->get();
+        }else{
+            $data = \App\Models\SoccerLeague::select('id','name_chinese')->get();
+        }
+
+//        $data = \App\Models\SoccerLeague::select('id','lg_id','name_chinese')->get();
+
+        if (!$data) {
+            return;
+        }
+        return $data->toArray();
+    }
+    /**
+     *获取所有国家信息
+     */
+    function getCountry() {
+        $data = \App\Models\Country::select('country_id','name_chinese')->get();
+        if (!$data) {
+            return;
+        }
+        for($i=0;$i<count($data);$i++){
+            $data[$i]->home_country_name = $data[$i]->name_chinese;
+            $data[$i]->home_country_id = $data[$i]->country_id;
+            $data[$i]->guest_country_name = $data[$i]->name_chinese;
+            $data[$i]->guest_country_id = $data[$i]->country_id;
+        }
+        return $data->toArray();
+    }
+    /**
+     *获取国家的球队信息
+     */
+    function getteam() {
+        $countryid = $_GET["countryid"];
+        $gametype = \App\Models\StGameType::where('game_code','zq')->first();
+        $res = \App\Models\Team::where('country_id',$countryid)->where('game_type_id',$gametype->id)->get();
+        return json_encode($res);
+    }
+    /**
+     *添加赛事
+     */
+    function add(Req $req) {
+        if (!$req->isMethod('post')) {
+            $parents = $this->getParent();
+            $country = $this->getCountry();
+            $countrys = $this->getCountry();
+            $lange = trans('menu');
+            foreach ($parents as $k => $v) {
+                $arr = trim($parents[$k]['name_chinese']);
+                if (isset($lange[$arr])) {
+                    $parents[$k]['name']=$lange[$arr];
+                }
+            }
+            $data['parents'] = $parents;
+            $data['country'] = $country;
+            $data['countrys'] = $countrys;
+            return view('sports.soccer_form', $data);
+        } else {
+            $model = new \App\Models\SportsSoccer();
+            $model->home_team = $req->input('home_team');
+            $model->guest_team = $req->input('guest_team');
+            $model->lg_id = $req->input('parent_id');
+            $model->match_date = $req->input('match_date');
+            $model->match_time = $req->input('match_time');
+            $model->status = $req->input('status');
+            if($req->input('is_rollball') == true){
+                $model->is_rollball = 1;
+            }else{
+                $model->is_rollball = 0;
+            }
+            if($req->input('is_today') == true){
+                $model->is_today = 1;
+            }else{
+                $model->is_today = 0;
+            }
+            if($req->input('is_morningplate') == true){
+                $model->is_morningplate = 1;
+            }else{
+                $model->is_morningplate = 0;
+            }
+            if($req->input('is_stringscene') == true){
+                $model->is_stringscene = 1;
+            }else{
+                $model->is_stringscene = 0;
+            }
+            $model->match_id = time() ;
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->tag = mt_rand(0,100) ;
+            $model->source = 'user-defined';
+
+            $db = new \App\Models\Stzqlocalmatch();
+            $db->source = 'user-defined';
+            $db->match_id = $model->match_id;
+
+            $model->save();
+            $db->save();
+            return responseToJson(1);
+
+        }
+    }
+
+    function view(Req $req) {
+        return $this->edit($req);
+    }
+
+    /**
+     *修改赛事
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+            $country = $this->getCountry();
+            $countrys = $this->getCountry();
+            $data = \App\Models\SportsSoccer::where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+
+            //查看赛事是否有下注细信息
+            $res = \App\Models\MoneyBuyMatch::where('match_id', $data->match_id)->get()->toArray();
+            if(!empty($res)){
+                if($data->status == 0){
+                    $match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废']);
+                }
+                if($data->status == 1){
+                    $match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+                }
+            }else{
+                if($data->status == 0){
+                    $match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+                }
+                if($data->status == 1){
+                    $match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+                }
+            }
+            if($data->status == 2){
+                $match_status =array(['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+            }
+            if($data->status == 3){
+                $match_status =array(['status'=>3,'name'=>'已结算'],['status'=>5,'name'=>'待结算']);
+            }
+            if($data->status == 4){
+                $match_status =array(['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+            }
+            if($data->status == 5){
+                $match_status =array(['status'=>5,'name'=>'待结算'],['status'=>4,'name'=>'作废']);
+            }
+            if($data->status == 6){
+                $match_status =array(['status'=>6,'name'=>'取消']);
+            }
+
+            $name_chinese = \App\Models\SoccerLeague::where('id', $data->lg_id)->first();
+            $data->name_chinese = $name_chinese->name_chinese;
+            $data = $data->toArray();
+            $data['parents'] = $this->getParent();
+            $data['country'] = $country;
+            $data['countrys'] = $countrys;
+
+            $data['match_status'] = $match_status;
+
+
+            //$lange = trans('menu');
+            foreach ($data['parents'] as $k => $v) {
+                $arr = trim($data['parents'][$k]['name_chinese']);
+                if (isset($lange[$arr])) {
+                    $data['parents'][$k]['name_chinese']=$lange[$arr];
+                }
+            }
+// var_dump($data);die;
+            return view('sports.soccer_form', $data);
+        } else {
+            $model = new \App\Models\SportsSoccer();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            $model->home_team = $req->input('home_team');
+            $model->guest_team = $req->input('guest_team');
+//            if(gettype($req->input('parent_id'))=='integer'){
+//                $model->lg_id = $req->input('parent_id');
+//            }else{
+//                $model->name_chinese = $req->input('parent_id');
+//                $res = \App\Model\SportsLeague::where('name_chinese',$model->name_chinese)->first();
+//                $model->lg_id = $res->lg_id;
+//            }
+            $model->lg_id = $req->input('parent_id');
+            $model->match_date = $req->input('match_date');
+            $model->match_time = $req->input('match_time');
+            $model->status = $req->input('status');
+            if($req->input('is_rollball') == true){
+                $model->is_rollball = 1;
+            }else{
+                $model->is_rollball = 0;
+            }
+            if($req->input('is_today') == true){
+                $model->is_today = 1;
+            }else{
+                $model->is_today = 0;
+            }
+            if($req->input('is_morningplate') == true){
+                $model->is_morningplate = 1;
+            }else{
+                $model->is_morningplate = 0;
+            }
+            if($req->input('is_stringscene') == true){
+                $model->is_stringscene = 1;
+            }else{
+                $model->is_stringscene = 0;
+            }
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *删除赛事
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        $id = array();
+        $localmatch = \App\Models\Stzqlocalmatch::get();
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+                $match = \App\Models\SportsSoccer::where('id',$v)->first();
+                for($i=0;$i<count($localmatch);$i++){
+                    if($localmatch[$i]->match_id == $match->match_id){
+                        $id[] = $localmatch[$i]->id;
+                    }
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsSoccer::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        if(count($id)>0) {
+            $row = \App\Models\Stzqlocalmatch::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+
+    /**
+     *赛事结果处理
+     */
+    public function dealwith(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        //return $id;
+        $SettlementWinFail = new SettlementWinFail();
+        $data = $SettlementWinFail->doRun($id);
+        return $data;
+    }
+
+    function odds(Req $req)
+    {
+        $cp_id = $req->id;
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['p_code'] = isset($req->p_code) ? trim($req->p_code) : '-1';
+        $request['id'] = isset($req->id) ? trim($req->id) : null;
+        $newapp = \App\Models\SportsSoccer::where('id',$request['id'])->first();
+       // $match_id = $newapp->match_id;
+        if(empty($newapp)){
+            $match_id = $req->input('id');
+        }else{
+            $match_id = $newapp->id;
+        }
+        $request['match_id'] = isset($match_id) ? trim($match_id) : null;
+        $data = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
+        //$data = \App\Model\Matchcode::where('p_id','0')->get();
+        $request['pcode'] = $data;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SportsSoccer/oddsinfo?match_id='.$match_id.'');
+        $dt->setLang('sportssoccer');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('odds_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('condition', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('odds', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+//        $dt->addColsFields('p_id', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('p_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('max', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('min', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('expire_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('source', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        if (checkRriv('/admin/SportsSoccer/oddsedit?id='.$cp_id.'')) {
+            $arr[] = 'oddsedit';
+        }
+        $dt->setToolBar($arr, array('width' => 150));
+        $dt->enableCheckBox();
+
+        return view('sports/soccer_odds', $dt->render($request));
+    }
+
+    function oddsinfo(Req $req){
+        $lange = trans('sportsoddscode');
+        $match_id = $req->match_id;
+        $p_code = Request::has('p_code') ? Request::get('p_code') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $where = array();
+        if (!empty($p_code) && $p_code!=-1) {
+            $where[] = array('st_zq_odds.p_code', '=', $p_code);
+        }
+        if (!empty($status) && $status != -1) {
+            $where[] = array('st_zq_odds.status', '=', $status);
+        }
+
+        if (intval($match_id) < 1) {
+            return -1;
+        }
+        $new = new \App\Models\SoccerOdds();
+        $data = $new->getodds($match_id,$where);
+
+        foreach ($data as $k => $v) {
+            $odds_code = trim($data[$k]['odds_code']);
+            $p_code = trim($data[$k]['p_code']);
+            if (isset($lange[$odds_code])) {
+                $data[$k]['odds_code']=$lange[$odds_code];
+            }
+            if (isset($lange[$p_code])) {
+                $data[$k]['p_code']=$lange[$p_code];
+            }
+        };
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data);
+    }
+    /**
+     *根据选择的父级赔率代码获取对应的子级赔率代码
+     */
+    function getoddscode() {
+        $p_code = $_GET["pcode"];
+        $res = \App\Models\Matchcode::where('odds_code',$p_code)->first();
+        $codedata = \App\Models\Matchcode::where('p_id',$res->id)->get();
+        return json_encode($codedata);
+    }
+    /**
+     *添加赔率
+     */
+    function addodds(Req $req) {
+        $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
+        for($i=0;$i<count($pcodedata);$i++){
+            $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
+        }
+
+        if (!$req->isMethod('post')) {
+            $cp_id = $_SERVER['QUERY_STRING'];  //获取url中的参数--赛事id
+            $data = ["match_id"=>$cp_id];
+            $data['pcode'] = $pcodedata;
+            return view('sports.soccer_odds_form',$data);
+        } else {
+            $model = new \App\Models\SoccerOdds();
+            $date = new \App\Models\SoccerOddsRecord();
+            $model->match_id = $req->input('match_id');
+            $model->odds_code = $req->input('code');
+            $model->status = $req->input('status');
+            $model->p_code = $req->input('pcode');
+            $res = \App\Models\Matchcode::where('odds_code',$model->p_code)->first();
+            $model->p_id = $res->id;
+            $result = \App\Models\SoccerOdds::where('odds_code',$model->odds_code)->where('p_id',$model->p_id)->orderby('utime','desc')->first();
+            if(!empty($result)){
+                $sort = $result->sort;
+                $model->sort = $sort+1;
+            }else{
+                $model->sort = 0;
+            }
+            $model->odds = $req->input('odds');
+            $model->condition = $req->input('condition');
+            $model->max = $req->input('max');
+            $model->min = $req->input('min');
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->sole = md5($model->match_id.$model->odds_code.$model->sort.$model->p_id.$model->ctime);
+            $model->source = 'user-defined';
+            $lg_id = \App\Models\SportsSoccer::where('match_id',$model->match_id)->first();
+            if(!empty($lg_id)){
+                $model->lg_id = $lg_id->lg_id;
+            }
+            $model->expire_time = $req->input('expire_time');
+            $model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+
+            $date->match_id = $model->match_id;
+            $date->odds_code = $model->odds_code;
+            $date->status = $model->status;
+            $date->p_code = $model->p_code;
+            $date->p_id = $model->p_id;
+            $record = \App\Models\SoccerOddsRecord::where('odds_code',$date->odds_code)->where('p_id',$date->p_id)->orderby('utime','desc')->first();
+            if(!empty($record)){
+                $sort = $record->sort;
+                $date->sort = $sort+1;
+            }else{
+                $date->sort = 0;
+            }
+            $date->odds = $model->odds;
+            $date->condition = $model->condition;
+            $date->max = $model->max;
+            $date->min = $model->min;
+            $date->ctime = $model->ctime;
+            $date->utime = $model->utime;
+            $date->source = $model->source;
+            $date->lg_id = $model->lg_id;
+            $date->odds_only = $model->odds_only;
+
+            $model->save();
+            $date->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *修改赔率
+     */
+    function oddsedit(Req $req) {
+        $lange = trans('sportsoddscode');
+        $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','zq')->get();
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
+        for($i=0;$i<count($pcodedata);$i++){
+            $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
+        }
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+
+            $data = \App\Models\SoccerOdds::where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+            //$res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->where('game_type','zq')->first();
+            $res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
+            if(!empty($res)){
+                $data->odds_name = $res->odds_name;
+            }
+//            $res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->first();
+//            if(!empty($res)){
+//                $data->odds_code = $res->odds_name;
+//            }
+//            $res1 = \App\Model\Matchcode::where('odds_code', $data->p_code)->first();
+//            if(!empty($res)){
+//                $data->p_code = $res1->odds_name;
+//            }
+
+
+            $expire_time = $data->expire_time; //2019-04-15 21:10:00
+            $str1 = str_replace(" ","T",$expire_time);
+            $data->expire_time = $str1;
+
+//            $odds_code = trim($data->odds_code);
+//            $p_code = trim($data->p_code);
+//            if (isset($lange[$odds_code])) {
+//                $data->odds_code_cn=$lange[$odds_code];
+//            }
+//            if (isset($lange[$p_code])) {
+//                $data->p_code_cn=$lange[$p_code];
+//            }
+//            if (isset($lange[$odds_code])) {
+//                $data->odds_code=$lange[$odds_code];
+//            }
+//            if (isset($lange[$p_code])) {
+//                $data->p_code=$lange[$p_code];
+//            }
+            $data = $data->toArray();
+
+            $data['pcode'] = $pcodedata;
+            //$data['code'] = $codedata;
+
+            return view('sports.soccer_odds_form', $data);
+        } else {
+            $model = new \App\Models\SoccerOdds();
+            $data = new \App\Models\SoccerOddsRecord();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            //$model->odds_code = $req->input('code');
+            $model->status = $req->input('status');
+            //$model->p_code = $req->input('pcode');
+            $model->odds = $req->input('odds');
+            $model->condition = $req->input('condition');
+            $model->max = $req->input('max');
+            $model->min = $req->input('min');
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->expire_time = $req->input('expire_time');
+            $model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+
+            $result = \App\Models\SoccerOdds::where('id',$model->id)->first();
+            $data->match_id = $result->match_id;
+            //$data->odds_code = $model->odds_code;
+            $data->status = $model->status;
+            //$data->p_code = $model->p_code;
+            $data->p_id = $result->p_id;
+            $record = \App\Models\SoccerOddsRecord::where('match_id',$data->match_id)->where('odds_code',$result->odds_code)->where('p_id',$result->p_id)->orderby('utime','desc')->first();
+            if(!empty($record)){
+                $sort = $record->sort;
+                $data->sort = $sort+1;
+            }else{
+                $data->sort = 0;
+            }
+            $data->odds = $model->odds;
+            $data->condition = $model->condition;
+            $data->max = $model->max;
+            $data->min = $model->min;
+            $data->ctime = $model->ctime;
+            $data->utime = $model->utime;
+            $data->source = $result->source;
+            $data->lg_id = $result->lg_id;
+            $data->odds_only = $result->odds_only;
+
+            $model->save();
+            $data->save();
+            return responseToJson(1);
+        }
+
+    }
+    /**
+     *删除赔率
+     */
+    public function oddsdelete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\SoccerOdds::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+}

+ 697 - 0
app/Http/Controllers/Admin/SportsTennisController.php

@@ -0,0 +1,697 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SportsTennisController extends Controller {
+
+    public function score(Req $req) {
+        //$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
+        $request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+        $request['match_date'] = isset($req->match_date) ? trim($req->match_date) : null;
+        $request['recommend'] = isset($req->recommend) ? trim($req->recommend) : '';
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+
+        $request['is_rollball'] = isset($req->is_rollball) ? trim($req->is_rollball) : '0';
+        $request['is_today'] = isset($req->is_today) ? trim($req->is_today) : '0';
+        $request['is_morningplate'] = isset($req->is_morningplate) ? trim($req->is_morningplate) : '0';
+        $request['is_stringscene'] = isset($req->is_stringscene) ? trim($req->is_stringscene) : '0';
+
+        $source = \App\Models\Setinfo::where('id','1000')->first();
+        if($source->infocontent != '混合数据'){
+            $data = \App\Models\TennisLeague::join('st_wq_local_league','st_wq_league.id','=','st_wq_local_league.lg_id')->select('st_wq_league.id','st_wq_league.name_chinese')->where('st_wq_local_league.source',$source->infocontent)->get();
+        }else{
+            $data = \App\Models\TennisLeague::select('id','name_chinese')->get();
+        }
+
+//        $data = \App\Models\TennisLeague::select('id','lg_id','name_chinese')->get();
+        $request['league'] = $data;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SportsTennis/info');
+        $dt->setLang('sportstennis');
+        $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('lg_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 260));
+        $dt->addColsFields('match_date', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('match_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('recommend', array('templet' => '#recommend', 'sort' => false, 'width' => 120,'align' => 'center'));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        //$dt->addColsFields('result', array( 'sort' => false, 'width' => 100));
+        //$arr[] = 'view';
+        if (checkRriv('/admin/SportsTennis/edit')) {
+            $arr[] = 'edit';
+        }
+        if (checkRriv('/admin/SportsTennis/odds')) {
+            $arr[] = 'odds';
+        }
+        $dt->setToolBar($arr, array('width' => 200));
+        $dt->enableCheckBox();
+        return view('sports/tennis_match', $dt->render($request));
+    }
+
+    function info(Req $req) {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+        $home_team = Request::has('home_team') ? Request::get('home_team') : '';
+        $match_date = Request::has('match_date') ? Request::get('match_date') : '';
+        $star_time = Request::get('star_time') ? Request::get('star_time') : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time') : '';
+        //$match_date = $req->input('match_date');
+//        if(!empty($match_date)){
+//            return 2;
+//        }
+        $status = Request::has('status') ? Request::get('status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        $orwhere = array();
+//        if (!empty($name_chinese) && $name_chinese!=-1) {
+//            $where[] = array('st_wq_league.name_chinese', '=', $name_chinese);
+//        }
+        if (!empty($name_chinese)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_wq_league.name_chinese', 'like', '%' . $name_chinese . '%');
+            } else {
+                $where[] = array('st_wq_league.name_chinese', '=', $name_chinese);
+            }
+        }
+
+        if (!empty($home_team)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_wq_competition.home_team', 'like', '%' . $home_team . '%');
+                $orwhere[] = array('st_wq_competition.guest_team', 'like', '%' . $home_team . '%');
+            } else {
+                $where[] = array('st_wq_competition.home_team', '=', $home_team);
+                $orwhere[] = array('st_wq_competition.guest_team', '=', $home_team);
+            }
+        }
+
+        if (!empty($star_time)) {
+            if (!empty($end_time)){
+                $where[] = array('st_wq_competition.match_date', '>=', $star_time);
+                $where[] = array('st_wq_competition.match_date', '<=', $end_time);
+            }else{
+                $where[] = array('st_wq_competition.match_date', '>=', $star_time);
+            }
+        }else if(empty($star_time)){
+            if (!empty($end_time)){
+
+                $where[] = array('st_wq_competition.match_date', '<=', $end_time);
+            }
+        }
+//        if (!empty($match_date)) {
+//            $where[] = array('st_wq_competition.match_date', '=', $match_date);
+//        }
+        if ($status != -1) {
+            $where[] = array('st_wq_competition.status', '=', $status);
+        }
+        $newapp = new \App\Models\SportsTennis();
+        $data = $newapp->getinfo($list, $page, $where,$orwhere);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+    /**
+     *设置是否为推荐赛事
+     */
+    function recommendmatch(Req $req) {
+        $id = $req->id;
+        $recommend = is_numeric($req->recommend) ? intval($req->recommend) : '';
+        if (empty($id) || !is_numeric($recommend)) {
+            return responseToJson(-2020100102);
+        }
+        $u_db = new \App\Models\SportsTennis;
+        $data = array(
+            'recommend' => $recommend,
+        );
+        $res = $u_db->updateInfos($data, $id);
+        return responseToJson($res);
+    }
+    /**
+     *获取所有足球联赛信息
+     */
+    function getParent() {
+
+        $source = \App\Models\Setinfo::where('id','1000')->first();
+        if($source->infocontent != '混合数据'){
+            $data = \App\Models\TennisLeague::join('st_wq_local_league','st_wq_league.id','=','st_wq_local_league.lg_id')->select('st_wq_league.id','st_wq_league.name_chinese')->where('st_wq_local_league.source',$source->infocontent)->get();
+        }else{
+            $data = \App\Models\TennisLeague::select('id','name_chinese')->get();
+        }
+
+//        $data = \App\Models\TennisLeague::select('id','lg_id','name_chinese')->get();
+        if (!$data) {
+            return;
+        }
+        return $data->toArray();
+    }
+    /**
+     *获取所有国家信息
+     */
+    function getCountry() {
+        $data = \App\Models\Country::select('country_id','name_chinese')->get();
+        if (!$data) {
+            return;
+        }
+        for($i=0;$i<count($data);$i++){
+            $data[$i]->home_country_name = $data[$i]->name_chinese;
+            $data[$i]->home_country_id = $data[$i]->country_id;
+            $data[$i]->guest_country_name = $data[$i]->name_chinese;
+            $data[$i]->guest_country_id = $data[$i]->country_id;
+        }
+        return $data->toArray();
+    }
+    /**
+     *获取国家的球队信息
+     */
+    function getteam() {
+        $countryid = $_GET["countryid"];
+        $gametype = \App\Models\StGameType::where('game_code','wq')->first();
+        $res = \App\Models\Team::where('country_id',$countryid)->where('game_type_id',$gametype->id)->get();
+        return json_encode($res);
+    }
+    /**
+     *添加赛事
+     */
+    function add(Req $req) {
+        if (!$req->isMethod('post')) {
+            $parents = $this->getParent();
+            $country = $this->getCountry();
+            $countrys = $this->getCountry();
+            $lange = trans('menu');
+            foreach ($parents as $k => $v) {
+                $arr = trim($parents[$k]['name_chinese']);
+                if (isset($lange[$arr])) {
+                    $parents[$k]['name']=$lange[$arr];
+                }
+            }
+            $data['parents'] = $parents;
+            $data['country'] = $country;
+            $data['countrys'] = $countrys;
+            return view('sports.tennis_form', $data);
+        } else {
+            $model = new \App\Models\SportsTennis();
+            $model->home_team = $req->input('home_team');
+            $model->guest_team = $req->input('guest_team');
+            $model->lg_id = $req->input('parent_id');
+            $model->match_date = $req->input('match_date');
+            $model->match_time = $req->input('match_time');
+            $model->status = $req->input('status');
+            if($req->input('is_rollball') == true){
+                $model->is_rollball = 1;
+            }else{
+                $model->is_rollball = 0;
+            }
+            if($req->input('is_today') == true){
+                $model->is_today = 1;
+            }else{
+                $model->is_today = 0;
+            }
+            if($req->input('is_morningplate') == true){
+                $model->is_morningplate = 1;
+            }else{
+                $model->is_morningplate = 0;
+            }
+            if($req->input('is_stringscene') == true){
+                $model->is_stringscene = 1;
+            }else{
+                $model->is_stringscene = 0;
+            }
+            $model->match_id = time() ;
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->tag = mt_rand(0,100) ;
+            $model->source = 'user-defined';
+
+            $db = new \App\Models\Stwqlocalmatch();
+            $db->source = 'user-defined';
+            $db->match_id = $model->match_id;
+
+            $model->save();
+            $db->save();
+            return responseToJson(1);
+
+        }
+    }
+
+    function view(Req $req) {
+        return $this->edit($req);
+    }
+
+    /**
+     *修改赛事
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+            $country = $this->getCountry();
+            $countrys = $this->getCountry();
+            $data = \App\Models\SportsTennis::where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+
+            //查看赛事是否有下注细信息
+            $res = \App\Models\MoneyBuyMatch::where('match_id', $data->match_id)->get()->toArray();
+            if(!empty($res)){
+                if($data->status == 0){
+                    $match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废']);
+                }
+                if($data->status == 1){
+                    $match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+                }
+            }else{
+                if($data->status == 0){
+                    $match_status =array(['status'=>0,'name'=>'未开始'],['status'=>1,'name'=>'正在进行'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+                }
+                if($data->status == 1){
+                    $match_status =array(['status'=>1,'name'=>'正在进行'],['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+                }
+            }
+            if($data->status == 2){
+                $match_status =array(['status'=>2,'name'=>'已结束'],['status'=>4,'name'=>'作废']);
+            }
+            if($data->status == 3){
+                $match_status =array(['status'=>3,'name'=>'已结算'],['status'=>5,'name'=>'待结算']);
+            }
+            if($data->status == 4){
+                $match_status =array(['status'=>4,'name'=>'作废'],['status'=>6,'name'=>'取消']);
+            }
+            if($data->status == 5){
+                $match_status =array(['status'=>5,'name'=>'待结算'],['status'=>4,'name'=>'作废']);
+            }
+            if($data->status == 6){
+                $match_status =array(['status'=>6,'name'=>'取消']);
+            }
+
+            $name_chinese = \App\Models\TennisLeague::where('id', $data->lg_id)->first();
+            $data->name_chinese = $name_chinese->name_chinese;
+            $data = $data->toArray();
+            $data['parents'] = $this->getParent();
+            $data['country'] = $country;
+            $data['countrys'] = $countrys;
+
+            $data['match_status'] = $match_status;
+
+
+            //$lange = trans('menu');
+            foreach ($data['parents'] as $k => $v) {
+                $arr = trim($data['parents'][$k]['name_chinese']);
+                if (isset($lange[$arr])) {
+                    $data['parents'][$k]['name_chinese']=$lange[$arr];
+                }
+            }
+
+            return view('sports.tennis_form', $data);
+        } else {
+            $model = new \App\Models\SportsTennis();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            $model->home_team = $req->input('home_team');
+            $model->guest_team = $req->input('guest_team');
+//            if(gettype($req->input('parent_id'))=='integer'){
+//                $model->lg_id = $req->input('parent_id');
+//            }else{
+//                $model->name_chinese = $req->input('parent_id');
+//                $res = \App\Model\SportsLeague::where('name_chinese',$model->name_chinese)->first();
+//                $model->lg_id = $res->lg_id;
+//            }
+            $model->lg_id = $req->input('parent_id');
+            $model->match_date = $req->input('match_date');
+            $model->match_time = $req->input('match_time');
+            $model->status = $req->input('status');
+            if($req->input('is_rollball') == true){
+                $model->is_rollball = 1;
+            }else{
+                $model->is_rollball = 0;
+            }
+            if($req->input('is_today') == true){
+                $model->is_today = 1;
+            }else{
+                $model->is_today = 0;
+            }
+            if($req->input('is_morningplate') == true){
+                $model->is_morningplate = 1;
+            }else{
+                $model->is_morningplate = 0;
+            }
+            if($req->input('is_stringscene') == true){
+                $model->is_stringscene = 1;
+            }else{
+                $model->is_stringscene = 0;
+            }
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *删除赛事
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        $id = array();
+        $localmatch = \App\Models\Stwqlocalmatch::get();
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+                $match = \App\Models\SportsTennis::where('id',$v)->first();
+                for($i=0;$i<count($localmatch);$i++){
+                    if($localmatch[$i]->match_id == $match->match_id){
+                        $id[] = $localmatch[$i]->id;
+                    }
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsTennis::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        if(count($id)>0) {
+            $row = \App\Models\Stwqlocalmatch::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+
+    /**
+     *赛事结果处理
+     */
+    public function dealwith(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        //return $id;
+        $SettlementWinFail = new SettlementWinFail();
+        $data = $SettlementWinFail->doRun($id);
+        return $data;
+    }
+
+    function odds(Req $req)
+    {
+        $cp_id = $req->id;
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
+        $request['p_code'] = isset($req->p_code) ? trim($req->p_code) : '-1';
+        $request['id'] = isset($req->id) ? trim($req->id) : null;
+        $newapp = \App\Models\SportsTennis::where('id',$request['id'])->first();
+        // $match_id = $newapp->match_id;
+        if(empty($newapp)){
+            $match_id = $req->input('id');
+        }else{
+            $match_id = $newapp->id;
+        }
+        $request['match_id'] = isset($match_id) ? trim($match_id) : null;
+        //$data = \App\Model\Matchcode::where('p_id','0')->get();
+        $data = \App\Models\Matchcode::where('p_id','0')->where('game_code','wq')->get();
+        $request['pcode'] = $data;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SportsTennis/oddsinfo?match_id='.$match_id.'');
+        $dt->setLang('sportssoccer');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('match_id', array('templet' => '#userdetail', 'sort' => true, 'width' => 100));
+        $dt->addColsFields('odds_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('condition', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('odds', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+//        $dt->addColsFields('p_id', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('p_code_cn', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('max', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('min', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('expire_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('source', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+        if (checkRriv('/admin/SportsTennis/oddsedit?id='.$cp_id.'')) {
+            $arr[] = 'oddsedit';
+        }
+        $dt->setToolBar($arr, array('width' => 150));
+        $dt->enableCheckBox();
+
+        return view('sports/tennis_odds', $dt->render($request));
+    }
+
+    function oddsinfo(Req $req){
+        $lange = trans('sportsoddscode');
+        $match_id = $req->match_id;
+        $p_code = Request::has('p_code') ? Request::get('p_code') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $where = array();
+        if (!empty($p_code) && $p_code!=-1) {
+            $where[] = array('st_wq_odds.p_code', '=', $p_code);
+        }
+        if (!empty($status) && $status != -1) {
+            $where[] = array('st_wq_odds.status', '=', $status);
+        }
+
+        if (intval($match_id) < 1) {
+            return -1;
+        }
+        $new = new \App\Models\TennisOdds();
+        $data = $new->getodds($match_id,$where);
+
+        foreach ($data as $k => $v) {
+            $odds_code = trim($data[$k]['odds_code']);
+            $p_code = trim($data[$k]['p_code']);
+            if (isset($lange[$odds_code])) {
+                $data[$k]['odds_code']=$lange[$odds_code];
+            }
+            if (isset($lange[$p_code])) {
+                $data[$k]['p_code']=$lange[$p_code];
+            }
+        };
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data);
+    }
+    /**
+     *根据选择的父级赔率代码获取对应的子级赔率代码
+     */
+    function getoddscode() {
+        $p_code = $_GET["pcode"];
+        $res = \App\Models\Matchcode::where('odds_code',$p_code)->first();
+        $codedata = \App\Models\Matchcode::where('p_id',$res->id)->get();
+        return json_encode($codedata);
+    }
+    /**
+     *添加赔率
+     */
+    function addodds(Req $req) {
+
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
+
+        $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','wq')->get();
+        for($i=0;$i<count($pcodedata);$i++){
+            $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
+        }
+
+        if (!$req->isMethod('post')) {
+            $cp_id = $_SERVER['QUERY_STRING'];  //获取url中的参数--赛事id
+            $data = ["match_id"=>$cp_id];
+            $data['pcode'] = $pcodedata;
+            return view('sports.tennis_odds_form',$data);
+        } else {
+            $model = new \App\Models\TennisOdds();
+            $date = new \App\Models\TennisOddsRecord();
+            $model->match_id = $req->input('match_id');
+            $model->odds_code = $req->input('code');
+            $model->status = $req->input('status');
+            $model->p_code = $req->input('pcode');
+            $res = \App\Models\Matchcode::where('odds_code',$model->p_code)->first();
+            $model->p_id = $res->id;
+            $result = \App\Models\TennisOdds::where('odds_code',$model->odds_code)->where('p_id',$model->p_id)->orderby('utime','desc')->first();
+            if(!empty($result)){
+                $sort = $result->sort;
+                $model->sort = $sort+1;
+            }else{
+                $model->sort = 0;
+            }
+            $model->odds = $req->input('odds');
+            $model->condition = $req->input('condition');
+            $model->max = $req->input('max');
+            $model->min = $req->input('min');
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->sole = md5($model->match_id.$model->odds_code.$model->sort.$model->p_id.$model->ctime);
+            $model->source = 'user-defined';
+            $lg_id = \App\Models\SportsTennis::where('match_id',$model->match_id)->first();
+            if(!empty($lg_id)){
+                $model->lg_id = $lg_id->lg_id;
+            }
+            $model->expire_time = $req->input('expire_time');
+            $model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+
+            $date->match_id = $model->match_id;
+            $date->odds_code = $model->odds_code;
+            $date->status = $model->status;
+            $date->p_code = $model->p_code;
+            $date->p_id = $model->p_id;
+            $record = \App\Models\TennisOddsRecord::where('odds_code',$date->odds_code)->where('p_id',$date->p_id)->orderby('utime','desc')->first();
+            if(!empty($record)){
+                $sort = $record->sort;
+                $date->sort = $sort+1;
+            }else{
+                $date->sort = 0;
+            }
+            $date->odds = $model->odds;
+            $date->condition = $model->condition;
+            $date->max = $model->max;
+            $date->min = $model->min;
+            $date->ctime = $model->ctime;
+            $date->utime = $model->utime;
+            $date->source = $model->source;
+            $date->lg_id = $model->lg_id;
+            $date->odds_only = $model->odds_only;
+
+            $model->save();
+            $date->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *修改赔率
+     */
+    function oddsedit(Req $req) {
+
+        //$pcodedata = \App\Model\Matchcode::where('p_id','0')->get();
+
+        $pcodedata = \App\Models\Matchcode::where('p_id','0')->where('game_code','wq')->get();
+        for($i=0;$i<count($pcodedata);$i++){
+            $pcodedata[$i]->p_code = $pcodedata[$i]->odds_code;
+        }
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+
+            $data = \App\Models\TennisOdds::where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+            $res = \App\Models\Matchcode::where('odds_code', $data->odds_code)->first();
+
+            //$res = \App\Model\Matchcode::where('odds_code', $data->odds_code)->where('game_type','wq')->first();
+            if(!empty($res)){
+                $data->odds_name = $res->odds_name;
+            }
+
+            $expire_time = $data->expire_time; //2019-04-15 21:10:00
+            $str1 = str_replace(" ","T",$expire_time);
+            $data->expire_time = $str1;
+
+            $odds_code = trim($data->odds_code);
+            $p_code = trim($data->p_code);
+            if (isset($lange[$odds_code])) {
+                $data->odds_code_cn=$lange[$odds_code];
+            }
+            if (isset($lange[$p_code])) {
+                $data->p_code_cn=$lange[$p_code];
+            }
+            $data = $data->toArray();
+
+            $data['pcode'] = $pcodedata;
+            //$data['code'] = $codedata;
+
+            return view('sports.tennis_odds_form', $data);
+        } else {
+            $model = new \App\Models\TennisOdds();
+            $data = new \App\Models\TennisOddsRecord();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            $model->odds_code = $req->input('code');
+            $model->status = $req->input('status');
+            $model->p_code = $req->input('pcode');
+            $model->odds = $req->input('odds');
+            $model->condition = $req->input('condition');
+            $model->max = $req->input('max');
+            $model->min = $req->input('min');
+            $model->ctime = date('Y-m-d H:i:s',time());
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->expire_time = $req->input('expire_time');
+            $model->odds_only = md5($model->match_id.$model->odds_code.$model->ctime);
+
+            $result = \App\Models\TennisOdds::where('id',$model->id)->first();
+            $data->match_id = $result->match_id;
+            $data->odds_code = $model->odds_code;
+            $data->status = $model->status;
+            $data->p_code = $model->p_code;
+            $data->p_id = $model->p_id;
+            $record = \App\Models\TennisOddsRecord::where('match_id',$data->match_id)->where('odds_code',$data->odds_code)->where('p_id',$data->p_id)->orderby('utime','desc')->first();
+            if(!empty($record)){
+                $sort = $record->sort;
+                $data->sort = $sort+1;
+            }else{
+                $data->sort = 0;
+            }
+            $data->odds = $model->odds;
+            $data->condition = $model->condition;
+            $data->max = $model->max;
+            $data->min = $model->min;
+            $data->ctime = $model->ctime;
+            $data->utime = $model->utime;
+            $data->source = $result->source;
+            $data->lg_id = $result->lg_id;
+            $data->odds_only = $result->odds_only;
+
+            $model->save();
+            $data->save();
+            return responseToJson(1);
+        }
+
+    }
+    /**
+     *删除赔率
+     */
+    public function oddsdelete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\TennisOdds::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+}

+ 340 - 0
app/Http/Controllers/Admin/SportsbkController.php

@@ -0,0 +1,340 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementOrder;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SportsbkController extends Controller {
+	public $code = "lq";
+	//篮球结果列表
+	public function outcome(Req $req) {
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['source'] = isset($req->source) ? $req->source : null;
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/Sportsbk/info');
+		$dt->setLang('sportsbk');
+		$dt->addColsFields('lg_id', array('templet' => '#liansai', 'sort' => true, 'width' => 160));
+		// $dt->addColsFields('update_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 160));
+		$dt->addColsFields('home_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+		$dt->addColsFields('guest_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 100));
+		$dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 70));
+		$dt->addColsFields('csnum', array('templet' => '#csnum', 'sort' => false, 'width' => 70));
+		$dt->addColsFields('sectionone_two', array('templet' => '#sectionone_two', 'sort' => false, 'width' => 180));
+		$dt->addColsFields('sectionthere_four', array('templet' => '#sectionthere_four', 'sort' => false, 'width' => 180));
+		$dt->addColsFields('status', array('templet' => '#matchstatus', 'sort' => false, 'width' => 80));
+		$dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300));
+
+		// if (checkRriv('/admin/Sportsbk/edit')) {
+		// 	$arr[] = 'edit';
+		// }
+		// $dt->setToolBar($arr, array('width' => 200));
+		// $dt->enableCheckBox();
+		return view('admin/sportsbk/outcome', $dt->render($request));
+	}
+
+	//篮球赛事作废
+	function revoke(Req $req){
+		$match_id = $req->match_id;//赛事id
+		\App\Models\Stlqresult::where('match_id', $match_id)->update(['status'=>4]);
+		\App\Models\SportsBasket::where('match_id', $match_id)->update(['status'=>4]);
+
+		$upapp = new \App\Models\SportsNoteList();
+        $data = $upapp->updatesimplex($match_id,$this->code);//修改单式状态
+
+        //单式撤单返现
+        $newapp = new \App\Models\MoneyBuyMatch();
+		$all = $newapp->allsimplexorder($match_id,$this->code);
+        for ($i=0; $i < count($all); $i++) { 
+	        $appgx = new SettlementOrder();
+	        $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'zq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
+        }
+
+        //串式撤单只改状态
+        $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
+        $csapp = new \App\Models\MoneyBuyStr();
+        $csapp->updatestatus($str_ids);
+        //修改money_buy_match 投注结果result=2为平
+        $newapp->updatast($match_id);
+        
+		return responseToJson(1);
+	}
+
+	//结果添加
+	function addend(Req $req){
+		$match_id = $req->input('match_id');
+		$model = \App\Models\Stlqresult::where('match_id', $match_id)->first();
+
+		// $penaltycard = array(
+  //       	'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
+  //       	'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
+  //       	'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
+  //       	'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
+  //       );
+  //       $cornerball = array(
+  //       	'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
+  //       	'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
+  //       	'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
+  //       	'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
+  //       );
+
+		$model->first_score = $req->firstscore;
+		$model->last_score = $req->lastscore;
+		$model->match_winer = $req->matchwiner;
+		$model->u_home_score = $req->uhomescore;
+		$model->u_guest_score = $req->uguestscore;
+		// $model->penalty_card = json_encode($penaltycard);
+		// $model->corner_ball = json_encode($cornerball);
+
+        $model->save();
+        return responseToJson(1);
+	}
+
+	//查询赛事结果
+	function Matchresult(Req $req){
+		$match_id = $req->match_id;
+		$newapp = \App\Models\Stlqresult::where('match_id', $match_id)->first();
+
+		$array =array(
+			'corner_ball' => json_decode($newapp['corner_ball'],true),
+			'penalty_card' => json_decode($newapp['penalty_card'],true),
+			'newapp' => $newapp,
+		);
+		return $array;
+	}
+
+	//结算
+	function Settlementlq(Req $req){
+		//查询赛事下所有订单
+		$ssid = $req->match_id;//赛事id
+		$type = $req->type;//是否再结算1,首次结算2,再次结算
+		$newapp = new \App\Models\MoneyBuyMatch();
+		$simplex_ids = array_column($newapp->allsimplexorder($ssid,'lq'),'order_id');
+		$str_ids = array_column($newapp->allstrorder($ssid),'order_id');
+
+		$addnew = new \App\Models\Comendnotice();
+		$update = $addnew->addcomendnotice($ssid);
+		if($update['status']==1){
+			$SettlementOrder = new SettlementOrder();
+	        $SettlementOrder->reSettlement($str_ids, 2,$type,$this->code,$ssid);//串式
+	        $data = $SettlementOrder->reSettlement($simplex_ids, 1,$type,$this->code,$ssid);//单式注单
+	        return responseToJson($data);
+	    }else{
+	    	return responseToJson($update);
+	    }
+	}
+
+	function info() {
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 1;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblurs = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$source = Request::has('source') ? Request::get('source') : '';
+		$where = array();
+		$orwhere = array();
+		if (!empty($home_team)) {
+			if (empty($sureblurs) || $sureblurs == 'off') {
+				$where[] = array('st_lq_result.home_team', 'like', '%' . $home_team . '%');
+				$orwhere[] = array('st_lq_result.guest_team', 'like', '%' . $home_team . '%');
+			} else {
+				$where[] = array('st_lq_result.home_team', '=', $home_team);
+				$orwhere[] = array('st_lq_result.guest_team', '=', $home_team);
+			}
+		}
+		if ($status != -1) {
+			$where[] = array('st_lq_result.status', '=', $status);
+		}
+		if (!empty($source)) {
+			$where[] = array('st_lq_result.source', '=', $source);
+		}//var_dump($where);die;
+		if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $where[] = array('st_lq_result.start_time', '>', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $where[] = array('st_lq_result.start_time', '<', $end_time);
+        }
+		$newapp = new \App\Models\Stlqresult();
+		$data = $newapp->resultbklist($list, $page, $where, $orwhere);
+		
+		for ($i=0; $i < count($data['data']); $i++) { 
+			$match_id = $data['data'][$i]['match_id'];
+			$score = $newapp->allscore($match_id,5);
+
+			if(!empty($score[0])){
+				$data['data'][$i]['okteamscore'] = $score[0]['guest_score']?$score[0]['guest_score']:0;//第一节客队比分
+				$data['data'][$i]['ozteamscore'] = $score[0]['home_score']?$score[0]['home_score']:0;//第一节主队比分
+			}else{
+				$data['data'][$i]['okteamscore'] = 0;//第一节客队比分
+				$data['data'][$i]['ozteamscore'] = 0;//第一节主队比分
+			}
+			if(!empty($score[1])){
+				$data['data'][$i]['tkteamscore'] = $score[1]['guest_score']?$score[1]['guest_score']:0;//第二节客队比分
+				$data['data'][$i]['tzteamscore'] = $score[1]['home_score']?$score[1]['home_score']:0;//第二节主队比分
+			}else{
+				$data['data'][$i]['tkteamscore'] = 0;//第二节客队比分
+				$data['data'][$i]['tzteamscore'] = 0;//第二节主队比分
+			}
+			if(!empty($score[2])){
+				$data['data'][$i]['skteamscore'] = $score[2]['guest_score']?$score[2]['guest_score']:0;//第三节客队比分
+				$data['data'][$i]['szteamscore'] = $score[2]['home_score']?$score[2]['home_score']:0;//第三节主队比分
+			}else{
+				$data['data'][$i]['skteamscore'] = 0;//第三节客队比分
+				$data['data'][$i]['szteamscore'] = 0;//第三节主队比分
+			}
+			if(!empty($score[3])){
+				$data['data'][$i]['akteamscore'] = $score[3]['guest_score']?$score[3]['guest_score']:0;//第四节客队比分
+				$data['data'][$i]['azteamscore'] = $score[3]['home_score']?$score[3]['home_score']:0;//第四节主队比分
+			}else{
+				$data['data'][$i]['akteamscore'] = 0;//第四节客队比分
+				$data['data'][$i]['azteamscore'] = 0;//第四节主队比分
+			}
+		    unset($data['data'][$i]['match_process'],$data['data'][$i]['id'],$data['data'][$i]['home_score'],$data['data'][$i]['guest_score'],$data['data'][$i]['update_time']); //去重
+		}
+
+		$data['data'] = array_unique($data['data'], SORT_REGULAR); //去重
+		// var_dump($data);die;
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	//修改添加赛事比分
+	function updatascore(Req $req){
+		$only = $req->only;//节数唯一标识
+		$match_id = $req->match_id;//节数唯一标识
+		$okteamscore = $req->okteamscore;//第一节客队比分
+		$ozteamscore = $req->ozteamscore;//第一节主队比分
+		$tkteamscore = $req->tkteamscore;//第二节客队比分
+		$tzteamscore = $req->tzteamscore;//第二节主队比分
+		$skteamscore = $req->skteamscore;//第三节客队比分
+		$szteamscore = $req->szteamscore;//第三节主队比分
+		$akteamscore = $req->akteamscore;//第四节客队比分
+		$azteamscore = $req->azteamscore;//第四节主队比分
+
+		$newapp = new \App\Models\Stlqresult();
+		$alldata = $newapp->onlyselect($match_id);
+		
+		if($only==1 || $only==2){
+			$ret = \App\Models\Stlqresult::updateOrCreate(['match_id'=>$match_id,'match_process'=>1],array_merge($alldata,['home_score'=>intval($ozteamscore),'guest_score'=>intval($okteamscore),'update_time'=>date('Y-m-d H:i:s'),'match_process'=>1]));
+		}
+		if($only==3 || $only==4){
+			$ret = \App\Models\Stlqresult::updateOrCreate(['match_id'=>$match_id,'match_process'=>2],array_merge($alldata,['home_score'=>intval($tzteamscore),'guest_score'=>intval($tkteamscore),'update_time'=>date('Y-m-d H:i:s'),'match_process'=>2]));
+		}
+		if($only==5 || $only==6){
+			$ret = \App\Models\Stlqresult::updateOrCreate(['match_id'=>$match_id,'match_process'=>3],array_merge($alldata,['home_score'=>intval($szteamscore),'guest_score'=>intval($skteamscore),'update_time'=>date('Y-m-d H:i:s'),'match_process'=>3]));
+		}
+		if($only==7 || $only==8){
+			$ret = \App\Models\Stlqresult::updateOrCreate(['match_id'=>$match_id,'match_process'=>4],array_merge($alldata,['home_score'=>intval($azteamscore),'guest_score'=>intval($akteamscore),'update_time'=>date('Y-m-d H:i:s'),'match_process'=>4]));
+		}
+		return responseToJson(1); 
+	}
+
+	function saislist(){
+		$lgid = $_POST['lgid'];//赛事id
+		$newstzqcompetition = new \App\Models\SportsBasket();
+		$league_data = $newstzqcompetition->allcompetition($lgid);//赛事id
+
+		return $league_data;
+	}
+
+	function addoutcome(Req $req) {
+		if (!$req->isMethod('post')) {
+            $lange = trans('menu');
+			$newapp = new \App\Models\BasketLeague();
+			$league_data = $newapp->allleague();//联赛id
+			return view('admin.sportsbk/addoutcome',['data'=>$league_data]);
+		}else{
+			$model = new \App\Models\Stlqresult();
+			$model->lg_id = trim($req->input('lg_id'));//联赛id
+			$model->home_team = trim($req->input('home_team'));
+			$model->guest_team = trim($req->input('guest_team'));
+			$model->home_rate = trim($req->input('home_rate'));
+			$model->guest_rate = trim($req->input('guest_rate'));
+			$model->home_score = trim($req->input('home_score'));
+			$model->guest_score = trim($req->input('guest_score'));
+			$model->all_goal = trim($req->input('all_goal'));
+			$model->match_score = trim($req->input('match_score'));
+			$model->u_home_score = trim($req->input('u_home_score'));
+			$model->u_guest_score = trim($req->input('u_guest_score'));
+			$model->update_time = date('Y-m-d h:i:s', time());//更新时间
+			$model->match_time = "11:22";//trim($req->input('match_time'));
+			$model->tag = trim($req->input('tag'));
+			$model->status = trim($req->input('status'));
+			$model->match_process = trim($req->input('match_process'));
+			$model->match_id = trim($req->input('match_id'));//赛事id
+
+			$model->save();
+			return responseToJson(1);
+
+		}
+	}
+
+	//赛事结果修改
+	function edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\Stlqresult::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+
+			return view('admin.sportsbk/edit', $data);
+		} else {
+			$model = \App\Models\Stlqresult::where('id', $id)->first();
+			$model->home_team = $req->input('home_team');
+			$model->guest_team = $req->input('guest_team');
+			$model->home_rate = $req->input('home_rate');
+			$model->guest_rate = $req->input('guest_rate');
+			$model->status = $req->input('status');
+			//$model->update_time = time();
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+
+	//删除赛事结果
+	function deleteoutcome(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		// echo '敬请期待';die;
+		$rows = \App\Models\Stlqresult::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); 
+		}
+		return responseToJson(1); 
+	}
+
+
+}

+ 177 - 0
app/Http/Controllers/Admin/SportsbqController.php

@@ -0,0 +1,177 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SportsbqController extends Controller {
+
+	//棒球结果列表
+	function outcome(Req $req) {
+		$request=array();
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['source'] = isset($req->source) ? $req->source : null;
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+		$dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Sportsbq/info');
+        $dt->setLang('Sportsbq');
+        $dt->addColsFields('newtime', array('templet' => '#home_team', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('home_team', array('templet' => '#home_team', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('guest_team', array('templet' => '#guest_team', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('dsnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('csnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('match_score', array('templet' => '#match_score', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300));
+		return view('admin.Sportsbq/outcome', $dt->render($request));
+	}
+
+	function info(){
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$source = Request::has('source') ? Request::get('source') : 'hg3535';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+
+        $where = array();
+        if ($status != -1) {
+			$where[] = array('st_bq_result.status', '=', $status);
+		}
+		if (!empty($source)) {
+			$where[] = array('st_bq_result.source', '=', $source);
+		}
+		if (!empty($star_time)) {
+	            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+	            $where[] = array('st_bq_result.start_time', '>', $star_time);
+	        }
+	    if (!empty($end_time)) {
+	        $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+	        $where[] = array('st_bq_result.start_time', '<', $end_time);
+	    }//var_dump($where);die;
+		$newapp = new \App\Models\Stbqresult();
+        $data = $newapp->getinfo($list, $page, $where);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	//作废
+	function revoke(Req $req){
+		$match_id = $req->match_id;//赛事id
+		$model = \App\Models\Stbqresult::where('match_id', $match_id)->first();
+		$model->status = 4;
+		$model->save();
+
+		$smodel = \App\Models\SportsSoccer::where('match_id', $match_id)->first();
+		if($smodel){
+			$smodel->status = 4;
+			$smodel->save();
+		}
+
+		$upapp = new \App\Models\SportsNoteList();
+        $data = $upapp->updatesimplex($match_id,'bq');//修改单式状态
+
+        //单式撤单返现
+        $newapp = new \App\Models\MoneyBuyMatch();
+		$all = $newapp->allsimplexorder($match_id,'bq');
+        for ($i=0; $i < count($all); $i++) { 
+	        $appgx = new \App\Lib\Settlement\SettlementOrder();
+	        $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'bq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
+        }
+
+        //串式撤单只改状态
+        $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
+        $csapp = new \App\Models\MoneyBuyStr();
+        $csapp->updatestatus($str_ids);//var_dump($ss);die;
+        //修改money_buy_match 投注结果result=2为平
+        $newapp->updatast($match_id);
+        
+		return responseToJson(1);
+	}
+
+	//结算
+	function Settlement(Req $req){
+		//查询赛事下所有订单
+		$ssid = $req->match_id;//赛事id
+		$type = $req->type;//是否再结算1,首次结算2,再次结算
+		$newapp = new \App\Models\MoneyBuyMatch();
+		$simplex_ids = array_column($newapp->allsimplexorder($ssid,'bq'),'order_id');
+		$str_ids = array_column($newapp->allstrorder($ssid),'order_id');
+
+		$update = $this->addcomendnotice($ssid);
+		if($update['status']==1){
+			$SettlementOrder = new SettlementOrder();
+	        $SettlementOrder->reSettlement($str_ids, 2,$type,'bq',$ssid);//串式
+	        $data = $SettlementOrder->reSettlement($simplex_ids, 1,$type,'bq',$ssid);//单式注单
+	        return responseToJson($data);
+	    }else{
+	    	return responseToJson($update);
+	    }
+	}
+
+	//查询赛事结果
+	function Matchresult(Req $req){
+		$match_id = $req->match_id;
+		$newapp = \App\Models\Stbqresult::where('match_id', $match_id)->first();
+
+		$array =array(
+			'corner_ball' => json_decode($newapp['corner_ball'],true),
+			'penalty_card' => json_decode($newapp['penalty_card'],true),
+			'newapp' => $newapp,
+		);
+		return $array;
+	}
+
+	function onlyresult(Req $req){
+		$match_id = $req->matchid;
+		$newapp = \App\Models\Stbqresult::where('match_id', $match_id)->first();
+		return $newapp;
+	}
+
+	//结果添加
+	function addend(Req $req){
+		$match_id = $req->matchid;
+		$model = \App\Models\Stbqresult::where('match_id', $match_id)->first();
+
+		$penaltycard = array(
+        	'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
+        	'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
+        	'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
+        	'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
+        );
+        $cornerball = array(
+        	'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
+        	'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
+        	'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
+        	'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
+        );
+
+		$model->first_score = $req->firstscore;
+		$model->last_score = $req->lastscore;
+		$model->match_winer = $req->matchwiner;
+		$model->penalty_card = json_encode($penaltycard);
+		$model->corner_ball = json_encode($cornerball);
+
+        $model->save();
+        return responseToJson(1);
+	}
+
+
+
+
+
+
+
+}

+ 361 - 0
app/Http/Controllers/Admin/SportsfootController.php

@@ -0,0 +1,361 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementOrder;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SportsfootController extends Controller {
+
+	//足球结果列表
+	function outcome(Req $req) {
+		$request=array();
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['source'] = isset($req->source) ? $req->source : null;
+		$request['name_chinese'] = isset($req->name_chinese) ? $req->name_chinese : null;
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+        $newapp = new \App\Models\SoccerLeague();
+		$data = $newapp->allleague();
+        $request['league'] = $data;//联赛id
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/sportsfoot/outcomeinfo');
+        $dt->setLang('sportsfoot');
+        $dt->addColsFields('newtime', array('templet' => '#newtime', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('totime', array('templet' => '#totime', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('home_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+		$dt->addColsFields('guest_team', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+		$dt->addColsFields('dsnum', array('templet' => '#dsnum', 'sort' => false, 'width' => 70));
+		$dt->addColsFields('csnum', array('templet' => '#csnum', 'sort' => false, 'width' => 110));
+		$dt->addColsFields('sxalfcourt', array('templet' => '#sxalfcourt', 'sort' => false, 'width' => 300));
+        $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 150,'align' => 'left'));
+		$dt->addColsFields('operation', array('templet' => '#status', 'sort' => false, 'width' => 300));
+        // $arr[] = 'view';
+		// if (checkRriv('/admin/sportsfoot/edit')) {
+		// 	$arr[] = 'edit';
+		// }
+		// $dt->setToolBar($arr, array('width' => 200));
+        $dt->enableCheckBox();
+
+		
+		return view('admin.sportsfoot/outcome', $dt->render($request));
+	}
+
+	//结果添加
+	function addend(Req $req){
+		$match_id = $req->matchid;
+		$model = \App\Models\Stzqresult::where('match_id', $match_id)->first();
+
+		$penaltycard = array(
+        	'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
+        	'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
+        	'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
+        	'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
+        );
+        $cornerball = array(
+        	'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
+        	'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
+        	'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
+        	'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
+        );
+
+		$model->first_score = $req->firstscore;
+		$model->last_score = $req->lastscore;
+		$model->match_winer = $req->matchwiner;
+		$model->penalty_card = json_encode($penaltycard);
+		$model->corner_ball = json_encode($cornerball);
+
+        $model->save();
+        return responseToJson(1);
+	}
+
+	//查询赛事结果
+	function Matchresult(Req $req){
+		$match_id = $req->match_id;
+		$newapp = \App\Models\Stzqresult::where('match_id', $match_id)->first();
+
+		$array =array(
+			'corner_ball' => json_decode($newapp['corner_ball'],true),
+			'penalty_card' => json_decode($newapp['penalty_card'],true),
+			'newapp' => $newapp,
+		);
+		return $array;
+	}
+
+	//
+	function onlyresult(Req $req){
+		$match_id = $req->matchid;
+		$newapp = \App\Models\Stzqresult::where('match_id', $match_id)->first();
+		return $newapp;
+	}
+
+	//结算
+	function Settlement(Req $req){
+		//查询赛事下所有订单
+		$ssid = $req->match_id;//赛事id
+		$type = $req->type;//是否再结算1,首次结算2,再次结算
+		$newapp = new \App\Models\MoneyBuyMatch();
+		$simplex_ids = array_column($newapp->allsimplexorder($ssid,'zq'),'order_id');
+		$str_ids = array_column($newapp->allstrorder($ssid),'order_id');
+
+		$data = \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->first();
+		if($data){
+			$newapp = new \App\Lib\Settlement\SettlementWinFail();
+            \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->update(['status'=>0]);
+			$ret = $newapp->doRun($data->toArray()['id']);
+			$ret2 =$data->toArray()['id'];
+            if ($ret2['status']==1){
+                \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->update(['status'=>4]);
+            }
+        }
+		
+		if($ret['status']==1){
+			$SettlementOrder = new SettlementOrder();
+	        $SettlementOrder->reSettlement($str_ids, 2,$type,'zq',$ssid);//串式
+	        $data = $SettlementOrder->reSettlement($simplex_ids, 1,$type,'zq',$ssid);//单式注单
+	        return responseToJson($data);
+	    }else{
+	    	return responseToJson($ret);
+	    }
+	}
+
+	//作废
+	function revoke(Req $req){
+		$match_id = $req->match_id;//赛事id
+		$model = \App\Models\Stzqresult::where('match_id', $match_id)->first();
+		$model->status = 4;
+		$model->save();
+
+		$smodel = \App\Models\SportsSoccer::where('match_id', $match_id)->first();
+		if($smodel){
+			$smodel->status = 4;
+			$smodel->save();
+		}
+
+		$upapp = new \App\Models\SportsNoteList();
+        $data = $upapp->updatesimplex($match_id,'zq');//修改单式状态
+
+        //单式撤单返现
+        $newapp = new \App\Models\MoneyBuyMatch();
+		$all = $newapp->allsimplexorder($match_id,'zq');
+        for ($i=0; $i < count($all); $i++) { 
+	        $appgx = new \App\Lib\Settlement\SettlementOrder();
+	        $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'zq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
+        }
+
+        //串式撤单只改状态
+        $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
+        $csapp = new \App\Models\MoneyBuyStr();
+        $csapp->updatestatus($str_ids);//var_dump($ss);die;
+        //修改money_buy_match 投注结果result=2为平
+        $newapp->updatast($match_id);
+        
+		return responseToJson(1);
+	}
+
+	//赛事结果修改
+	function edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\Stzqresult::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+
+			return view('admin.sportsfoot/edit', $data);
+		} else {
+			$model = \App\Models\Stzqresult::where('id', $id)->first();
+			$model->home_team = $req->input('home_team');
+			$model->guest_team = $req->input('guest_team');
+			$model->home_rate = $req->input('home_rate');
+			$model->guest_rate = $req->input('guest_rate');
+			$model->status = $req->input('status');
+			//$model->update_time = time();
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+
+	function outcomeinfo() {
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$source = Request::has('source') ? Request::get('source') : 'hg3535';
+        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+
+		$where = array();
+		$orwhere = array();
+		if (!empty($home_team)) {
+			if (empty($sureblur) || $sureblur == 'off') {
+				$where[] = array('st_zq_result.home_team', 'like', '%' . $home_team . '%');
+				$orwhere[] = array('st_zq_result.guest_team', 'like', '%' . $home_team . '%');
+			} else {
+				if(is_numeric($home_team)){
+					$where[] = array('st_zq_result.match_id', '=', $home_team);
+				}else{
+					$where[] = array('st_zq_result.home_team', '=', $home_team);
+					$orwhere[] = array('st_zq_result.guest_team', '=', $home_team);
+				}
+			}
+		}
+		if ($status != -1) {
+			$where[] = array('st_zq_result.status', '=', $status);
+		}
+		if (!empty($source)) {
+			$where[] = array('st_zq_result.source', '=', $source);
+		}
+		if (!empty($name_chinese)) {
+			$where[] = array('st_zq_league.name_chinese', '=', $name_chinese);
+		}
+		if(!is_numeric($home_team)){
+			if (!empty($star_time)) {
+	            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+	            $where[] = array('st_zq_result.start_time', '>', $star_time);
+	        }
+	        if (!empty($end_time)) {
+	            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+	            $where[] = array('st_zq_result.start_time', '<', $end_time);
+	        }
+	    }
+        //var_dump($where);var_dump($orwhere);var_dump($srwhere);die;
+        $newapp = new \App\Models\Stzqresult();
+        $data = $newapp->resultlist($list, $page, $where, $orwhere);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    //
+    function saislist(Req $req){
+    	$lgid = $req->lgid;//赛事id
+		$newstzqcompetition = new \App\Models\Stzqcompetition();
+		$league_data = $newstzqcompetition->allcompetition($lgid);//赛事id
+
+		return $league_data;
+    }
+    
+	//赛事结果添加  guest_score 客队进球  all_goal总进球数
+    function addoutcome(Req $req) {
+		if (!$req->isMethod('post')) {
+            $lange = trans('menu');
+			$newapp = new \App\Models\SoccerLeague();
+			$league_data = $newapp->allleague();//联赛id
+
+            return view('admin.sportsfoot/addoutcome',['data'=>$league_data]);
+        } else {
+        	$match_id = trim($req->input('match_id'));//赛事id
+        	//添加足球比赛结果表
+        	$alldata = $req->input();
+        	unset($alldata['_token']);
+        	$all_goal = intval($alldata['home_score'])+intval($alldata['guest_score']);//总进球数
+        	$penaltycard = array(
+        		'home'=>intval($alldata['homeallcard'])?intval($alldata['homeallcard']):0,
+        		'guest'=>intval($alldata['guestallcard'])?intval($alldata['guestallcard']):0,
+        		'home_half'=>intval($alldata['homehalfcard'])?intval($alldata['homehalfcard']):0,
+        		'guest_half'=>intval($alldata['guesthalfcard'])?intval($alldata['guesthalfcard']):0,
+        	);
+        	$cornerball = array(
+        		'home'=>intval($alldata['homeallcorner'])?intval($alldata['homeallcorner']):0,
+        		'guest'=>intval($alldata['guestallcorner'])?intval($alldata['guestallcorner']):0,
+        		'home_half'=>intval($alldata['homehalfcorner'])?intval($alldata['homehalfcorner']):0,
+        		'guest_half'=>intval($alldata['guesthalfcorner'])?intval($alldata['guesthalfcorner']):0,
+        	);
+        	
+        	$ret = \App\Models\Stzqresult::updateOrCreate(['match_id'=>$match_id],array_merge($alldata,['match_time'=>'00:01','update_time'=>date('Y-m-d H:i:s'),'all_goal'=>$all_goal,'penalty_card'=>json_encode($penaltycard),'corner_ball'=>json_encode($cornerball)]));
+        	//添加足球比赛结果记录表
+        	\App\Models\Stzqresultrecord::updateOrCreate(['match_id'=>$match_id,'update_time'=>date('Y-m-d H:i:s')],array_merge($alldata,['match_time'=>'00:01','update_time'=>date('Y-m-d H:i:s')]));
+        }
+        return responseToJson(1); 
+    }
+
+    //删除赛事结果
+	function deleteoutcome(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		// echo '敬请期待';die;
+		$rows = \App\Models\Stzqresult::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); 
+		}
+		return responseToJson(1); 
+	}
+
+	//更新赛事比分
+	function updatenum(Req $req){
+		$type = $req->type;
+		$id = $req->id;
+		$num = $req->num;
+		$match_id = $req->match_id;
+
+		$newapp = new \App\Models\Stzqresult();
+		
+		if($type==1){
+			$data['u_home_score'] = $num;
+			$res = $newapp->updateInfo($data,$id);//联赛id
+		}else if($type==2){
+			$data['u_guest_score'] = $num;
+			$res = $newapp->updateInfo($data,$id);//联赛id
+		}else if($type==3){
+			$data['home_score'] = $num;
+			$res = $newapp->updateInfo($data,$id);//联赛id
+		}else{
+			$data['guest_score'] = $num;
+			$res = $newapp->updateInfo($data,$id);//联赛id
+		}
+		$newapp->totalgoal($match_id);
+		$update = $this->addcomendnotice($match_id);
+
+		$twoapp = new \App\Models\SportsSoccer();
+		$twoapp->updatestatus('match_id',$match_id,['status'=>2]);//修改赛事状态
+		$newapp->updatestatus('match_id',$match_id,['status'=>2]);//修改结果状态
+
+		return responseToJson(1);
+	}
+ 		
+	//添加赛事结束纪录
+	function addcomendnotice($match_id){
+		$data = \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->first();
+		if(!$data){
+			$model = new \App\Models\Comendnotice();
+			$model->status = 0;//联赛id
+			$model->game_code = 'zq';
+			$model->match_id = $match_id;//赛事id
+			$model->ctime = date('Y-m-d H:i:s');
+			$model->save();
+		}
+		return responseToJson(1);
+	}
+	
+	
+}

+ 194 - 0
app/Http/Controllers/Admin/SportswqController.php

@@ -0,0 +1,194 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementOrder;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class SportswqController extends Controller {
+	public $code = "wq";
+
+	//网球结果列表
+	public function outcome(Req $req) {
+		$request=array();
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['source'] = isset($req->source) ? $req->source : null;
+		$request['name_chinese'] = isset($req->name_chinese) ? $req->name_chinese : null;
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+        $newapp = new \App\Models\SoccerLeague();
+		$data = $newapp->allleague();
+        $request['league'] = $data;//联赛id
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/Sportswq/outcomeinfo');
+        $dt->setLang('sportswq');
+        $dt->addColsFields('newtime', array('templet' => '#home_team', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('home_team', array('templet' => '#home_team', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('guest_team', array('templet' => '#guest_team', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('dsnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('csnum', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('match_score', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('statusmatch', array('templet' => '#statusmatch', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('operation', array('templet' => '#operation', 'sort' => false, 'width' => 300));
+        return view('admin.Sportswq/outcome', $dt->render($request));
+	}
+
+	function outcomeinfo(){
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$source = Request::has('source') ? Request::get('source') : 'hg3535';
+        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+
+		$where = array();
+		$orwhere = array();
+		if (!empty($home_team)) {
+			if (empty($sureblur) || $sureblur == 'off') {
+				$where[] = array('st_wq_result.home_team', 'like', '%' . $home_team . '%');
+				$orwhere[] = array('st_wq_result.guest_team', 'like', '%' . $home_team . '%');
+			} else {
+				$where[] = array('st_wq_result.home_team', '=', $home_team);
+				$orwhere[] = array('st_wq_result.guest_team', '=', $home_team);
+			}
+		}
+		if ($status != -1) {
+			$where[] = array('st_wq_result.status', '=', $status);
+		}
+		if (!empty($source)) {
+			$where[] = array('st_wq_result.source', '=', $source);
+		}
+		if (!empty($name_chinese)) {
+			$where[] = array('st_wq_result.name_chinese', '=', $name_chinese);
+		}
+		if (!empty($star_time)) {
+            $star_time = date('Y-m-d H:i:s', strtotime($star_time));
+            $where[] = array('st_wq_result.start_time', '>', $star_time);
+        }
+        if (!empty($end_time)) {
+            $end_time = date('Y-m-d H:i:s', strtotime($end_time));
+            $where[] = array('st_wq_result.start_time', '<', $end_time);
+        }
+        $newapp = new \App\Models\Stwqresult();
+        $data = $newapp->resultlist($list, $page, $where, $orwhere);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	//作废
+	function revoke(Req $req){
+		$match_id = $req->match_id;//赛事id
+		$model = \App\Models\Stwqresult::where('match_id', $match_id)->first();
+		$model->status = 4;
+		$model->save();
+
+		$smodel = \App\Models\SportsSoccer::where('match_id', $match_id)->first();
+		if($smodel){
+			$smodel->status = 4;
+			$smodel->save();
+		}
+
+		$upapp = new \App\Models\SportsNoteList();
+        $data = $upapp->updatesimplex($match_id,'wq');//修改单式状态
+
+        //单式撤单返现
+        $newapp = new \App\Models\MoneyBuyMatch();
+		$all = $newapp->allsimplexorder($match_id,'wq');
+        for ($i=0; $i < count($all); $i++) { 
+	        $appgx = new \App\Lib\Settlement\SettlementOrder();
+	        $appgx->insertData($all[$i]['order_id'], $all[$i]['money'], $all[$i]['account_identity'], '1', 'wq', $all[$i]['info_identity'], $all[$i]['money'],$all[$i]['match_id']);
+        }
+
+        //串式撤单只改状态
+        $str_ids = array_column($newapp->allstrorder($match_id),'order_id');
+        $csapp = new \App\Models\MoneyBuyStr();
+        $csapp->updatestatus($str_ids);//var_dump($ss);die;
+        //修改money_buy_match 投注结果result=2为平
+        $newapp->updatast($match_id);
+        
+		return responseToJson(1);
+	}
+
+	//结算
+	function Settlement(Req $req){
+		//查询赛事下所有订单
+		$ssid = $req->match_id;//赛事id
+		$type = $req->type;//是否再结算1,首次结算2,再次结算
+		$newapp = new \App\Models\MoneyBuyMatch();
+		$simplex_ids = array_column($newapp->allsimplexorder($ssid,'wq'),'order_id');
+		$str_ids = array_column($newapp->allstrorder($ssid),'order_id');
+
+		$update = $this->addcomendnotice($ssid);
+		if($update['status']==1){
+			$SettlementOrder = new SettlementOrder();
+	        $SettlementOrder->reSettlement($str_ids, 2,$type,'wq',$ssid);//串式
+	        $data = $SettlementOrder->reSettlement($simplex_ids, 1,$type,'wq',$ssid);//单式注单
+	        return responseToJson($data);
+	    }else{
+	    	return responseToJson($update);
+	    }
+	}
+
+	//查询赛事结果
+	function Matchresult(Req $req){
+		$match_id = $req->match_id;
+		$newapp = \App\Models\Stwqresult::where('match_id', $match_id)->first();
+
+		$array =array(
+			'corner_ball' => json_decode($newapp['corner_ball'],true),
+			'penalty_card' => json_decode($newapp['penalty_card'],true),
+			'newapp' => $newapp,
+		);
+		return $array;
+	}
+
+	function onlyresult(Req $req){
+		$match_id = $req->matchid;
+		$newapp = \App\Models\Stwqresult::where('match_id', $match_id)->first();
+		return $newapp;
+	}
+
+	//结果添加
+	function addend(Req $req){
+		$match_id = $req->matchid;
+		$model = \App\Models\Stwqresult::where('match_id', $match_id)->first();
+
+		$penaltycard = array(
+        	'home'=>intval($req->homeallcard)?intval($req->homeallcard):0,
+        	'guest'=>intval($req->guestallcard)?intval($req->guestallcard):0,
+        	'home_half'=>intval($req->homehalfcard)?intval($req->homehalfcard):0,
+        	'guest_half'=>intval($req->guesthalfcard)?intval($req->guesthalfcard):0,
+        );
+        $cornerball = array(
+        	'home'=>intval($req->homeallcorner)?intval($req->homeallcorner):0,
+        	'guest'=>intval($req->guestallcorner)?intval($req->guestallcorner):0,
+        	'home_half'=>intval($req->homehalfcorner)?intval($req->homehalfcorner):0,
+        	'guest_half'=>intval($req->guesthalfcorner)?intval($req->guesthalfcorner):0,
+        );
+
+		$model->first_score = $req->firstscore;
+		$model->last_score = $req->lastscore;
+		$model->match_winer = $req->matchwiner;
+		$model->penalty_card = json_encode($penaltycard);
+		$model->corner_ball = json_encode($cornerball);
+
+        $model->save();
+        return responseToJson(1);
+	}
+
+
+
+}

+ 215 - 0
app/Http/Controllers/Admin/SystemAppupdateController.php

@@ -0,0 +1,215 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: blues
+ * Date: 2018/10/30
+ * Time: 15:09
+ */
+
+    namespace App\Http\Controllers\Admin;
+    use App\Http\Controllers\Controller;
+    use App\Models\SystemAppupdate;
+    use Illuminate\Http\Request as Req;
+    use Request;
+
+    class SystemAppupdateController   extends Controller
+    {
+
+        public function index(Req $req)
+        {
+            $request['title'] = isset($req->title) ? trim($req->title) : null;
+            $request['type'] = isset($req->type) ? trim($req->type) : null;
+            $update = new SystemAppupdate();
+            $dt = \App\Lib\DataTable\DataTable::init();
+            $dt->setDataSource('/admin/SystemAppupdate/getlist');
+            $dt->setLang('update_record');
+            // $dt->addColsFields('id');
+            $dt->addColsFields('id');
+            // $dt->addColsFields('content');
+            $dt->addColsFields('version_no');
+            $dt->addColsFields('settype');//层级
+//            $dt->addColsFields('version_details');
+//            $dt->addColsFields('version_remark');
+//            $dt->addColsFields('download_url');
+            $dt->addColsFields('update_num');
+            $dt->addColsFields('status');
+            $dt->addColsFields('create_date');
+            $dt->enableCheckBox();
+            if (checkRriv('/admin/SystemAppupdate/edit')) {
+                $arr[] = 'edit';
+            }
+            $dt->setToolBar($arr, array('width' => 140));
+
+            $request["classtype"]    = [
+                ["id" => 0, "name" => 'WEB'],
+                ["id" => 1, "name" => '苹果'],
+                ["id" => 2, "name" => '安卓'],
+            ];
+
+            return view('admin.systemSet/sysAppUpdateRecord', $dt->render($request));
+        }
+
+        function records(){
+               return $this->index();
+        }
+        function add(Req $req){
+
+
+                if (!$req->isMethod('post')) {
+                    $datas['version_no'] = 'v'.'-'.time();
+                    return view('admin.systemSet/ayaAppUpdateAdd', ['select' => null, 'datas'=>$datas, 'data'=>[],"selectdata" => []]);
+                } else {
+
+
+                    $update =   new SystemAppupdate();
+                    $version_no = $req->input("version_no") ? $req->input("version_no") : '';
+                   
+                    $version_details = $req->input("version_details");
+                    $version_remark = $req->input("version_remark");
+                    $settype = $req->input("settype");
+                    $status = $req->input("status");
+                    $download_url = $req->input("download_url");
+					$app_version = $req->input("app_version");
+                    $type_data = [
+                        "version_details" => $version_details,
+                        "version_remark" => $version_remark,
+                        "settype" => $settype,
+                        "status" => $status,
+                        "download_url" => $download_url,
+                        "create_date" => date("Y-m-d H:i:s"),
+                        "other" =>$app_version,
+                    ];
+
+                    if (empty($version_no)) {
+                        $type_data["version_no"] = 'v'.'-'.time();
+                    }else{
+                        $type_data["version_no"] = $version_no;
+                    }
+                    $add = $update->addRecord($type_data);
+                    $type_log = [
+                        session('adminInfo.admin_name'),
+                        $req['version_no']];
+                    OperationLog(session('adminInfo.admin_id'), 'system_appupdate_add', $type_log);
+
+                    return responseToJson(1);
+                }
+            }
+
+
+        function edit(Req $req){
+            $id = $req->id;
+
+            if (empty($id)) {
+                abort(404);
+            }
+            $db = new SystemAppupdate();
+            if (!$req->isMethod('post')) {
+                $data = $db->getIdData($id, 1);
+                return view('admin.systemSet/ayaAppUpdateAdd', ['data' => $data,]);
+            } else {
+
+                $version_no = $req->input("version_no");
+                $version_details = $req->input("version_details");
+                $version_remark = $req->input("version_remark");
+                $settype = $req->input("settype");
+                $status = $req->input("status");
+                $download_url = $req->input("download_url");
+                $app_version = $req->input("app_version");
+
+                $type_data = [
+                    "version_no" => $version_no,
+                    "version_details" => $version_details,
+                    "version_remark" => $version_remark,
+                    "settype" => $settype,
+                    "status" => $status,
+                    "download_url" => $download_url,
+                    "create_date" => date("Y-m-d H:i:s"),
+                    "other" =>$app_version,
+                ];
+
+                $update = $db->updateIdData(intval($id), $type_data);
+                $type_log = [
+                    session('adminInfo.admin_name'),
+                    $req['version_no,'] ];
+                OperationLog(session('adminInfo.admin_id'), 'system_appupdate_update', $type_log);
+
+                return responseToJson(1);
+            }
+        }
+
+        public function delete(Req $req) {
+        $id = $req->id;
+        if (empty($id)) {
+            return responseToJson(-2001); //id不能为空
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id错误
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\SystemAppupdate::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id错误
+        }
+        return responseToJson(1, trans('priv_code.delete_success')); //id错误
+
+    }
+
+
+
+        //获取列表信息
+        function getlist() {
+
+            //设备0=wap,1=ios,2=androi
+            $settype    =   [
+                0=>'WEB',
+                1=>'苹果',
+                2=>'安卓'
+            ];
+
+            $limit = Request::has('limit') ? Request::get('limit') : 50;
+
+            $title = Request::has('title') ? Request::get('title') : '';
+            $type = Request::has('type') ? Request::get('type') : '';
+
+            $add_startime = Request::has('add_startime') ? Request::get('add_startime') : '';
+            $add_endtime = Request::has('add_endtime') ? Request::get('add_endtime') : '';
+
+            $where = array();
+            if (isset($title)) {
+                $where[] = array('version_no', 'like', '%' . $title . '%');
+            }
+            if (isset($type)) {
+                $where[] = array('settype', $type);
+            }
+
+            if (!empty($add_startime)) {
+                $add_startime = date('Y-m-d H:i:s', strtotime($add_startime));
+                $where[] = array('create_time', '>=', $add_startime);
+            }
+            if (!empty($add_endtime)) {
+                $add_endtime = date('Y-m-d H:i:s', strtotime($add_endtime));
+                $where[] = array('create_time', '<=', $add_endtime);
+            }
+
+            $db = new SystemAppupdate();
+            $data = $db->getlist($where,$limit );
+
+            $c  =   count($data);
+            if ($c>0) {
+                foreach ($data as $k=>$v){
+                    $data[$k]["settype"]=$settype[$v['settype']];
+                    $data[$k]["status"]=empty($v['status'])?'禁用':'启用';
+//                    $data[$k]["status"]=empty($v['status'])?'禁用':'<b style="color: green">启用</b>';
+                }
+                return \App\Lib\DataTable\DataTable::init()->toJson($data, $c);
+            }
+            return \App\Lib\DataTable\DataTable::init()->toJson($data['data']=[], $data['total']=null);
+        }
+    }

+ 456 - 0
app/Http/Controllers/Admin/SystemController.php

@@ -0,0 +1,456 @@
+<?php
+/**
+ * 系统设置
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\ArticleType;
+use App\Models\LotteryMoney;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class SystemController extends Controller {
+	/**
+	 *
+	 */
+	function index() {
+		return view('admin.systemSet/index');
+	}
+
+	/**
+	 * 活动公告
+	 */
+	function Article() {
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/System/getArticle');
+		$dt->setLang('notice');
+		$dt->addColsFields('id');
+		$dt->addColsFields('title');
+//        $dt->addColsFields('content');
+		$dt->addColsFields('time');
+		$dt->addColsFields('type');
+		$dt->setToolBar(array('edit'));
+		return view('admin.systemSet/arictle', $dt->render());
+	}
+
+	/**
+	 * 公告添加
+	 * [addNotice description]
+	 */
+	function addNotice() {
+		return view('admin.menu/addNotice');
+	}
+
+//	//基础设置
+	//	function BaseSet() {
+	//		$dt = \App\Lib\DataTable\DataTable::init();
+	//		$dt->setDataSource('/admin/System/getBaseSet');
+	//		$dt->setLang('notice');
+	//		$dt->addColsFields('id', array('fixed' => 'left'));
+	//		$dt->addColsFields('infoname');
+	//		$dt->addColsFields('infocontent', array('edit' => 'password'));
+	//		$dt->addColsFields('status');
+	//		$dt->setToolBar(array('save'));
+	//		return view('admin.systemSet/arictle', $dt->render());
+	//
+	//	}
+	//获取基础设置
+	function getBaseSet() {
+		$infoname = Request::has('infoname') ? Request::get('infoname') : '';
+		$infocontent = Request::has('infocontent') ? Request::get('infocontent') : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+
+		$where = array();
+		if (!empty($infoname)) {
+			$where[] = array('infoname', 'like', '%' . $infoname . '%');
+		}
+		if (!empty($infocontent)) {
+			$where[] = array('infocontent', 'like', '%' . $infocontent . '%');
+		}
+		if (!empty($status)) {
+			if ($status == 2) {
+				$where[] = array('status', '=', '0');
+			} else {
+				$where[] = array('status', '=', $status);
+			}
+		}
+
+		$db = new \App\Models\Setinfo();
+		$data = $db->getAllSet($where);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data, count($data));
+	}
+	/**
+	 * 菜单管理
+	 */
+	function Menu() {
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/System/getMenu');
+		$dt->setLang('menu');
+		$dt->addColsFields('id', array('fixed' => 'left'));
+		$dt->addColsFields('name');
+		$dt->addColsFields('icon');
+		$dt->addColsFields('href');
+		$dt->addColsFields('type');
+		$dt->addColsFields('sort');
+		$dt->addColsFields('parent_id');
+		$dt->addColsFields('target');
+		$dt->setToolBar(array('edit'));
+//        return  view('vip.menu',$dt->render());
+		return view('admin.systemSet/menu', $dt->render());
+	}
+	//获取菜单列表
+	function getMenu() {
+		$limit = Request::has('limit') ? Request::get('limit') : '';
+		$page = Request::has('page') ? Request::get('page') : '';
+		$field = Request::has('field') ? Request::get('field') : '';
+		$order = Request::has('order') ? Request::get('order') : '';
+		$model = \App\Models\NavsModel::offset(($page - 1) * $limit)
+			->limit($limit);
+
+		$name = Request::has('name') ? Request::get('name') : '';
+		$href = Request::has('href') ? Request::get('href') : '';
+		$parent_id = Request::has('parent_id') ? Request::get('parent_id') : '';
+		$type = Request::has('type') ? Request::get('type') : '';
+		$where = array();
+		if (!empty($name)) {
+			$where[] = array('name', 'like', '%' . $name . '%');
+		}
+		if (!empty($href)) {
+			$where[] = array('href', 'like', '%' . $href . '%');
+		}
+		if (!empty($parent_id)) {
+			$where[] = array('parent_id', '=', $parent_id);
+		}
+		if (!empty($type)) {
+			if ($type == -1) {
+				$where[] = array('type', '=', '0');
+			} else {
+				$where[] = array('type', '=', $type);
+			}
+		}
+		if (!empty($where) && is_array($where)) {
+			$model = $model->where($where);
+		}
+		if (!empty($field) && !empty($order)) {
+			$model = $model->orderBy($field, $order);
+		}
+		$data = $model->get();
+		$data = $data->toArray();
+		if (!empty($data) && is_array($data)) {
+			$langinfo = trans('status.dc_navs.type');
+			foreach ($data as $k => $v) {
+				$data[$k]['type'] = ($v['type'] == 0) ? $langinfo['-1'] : $langinfo[$v['type']];
+			}
+		}
+		$count = \App\Models\NavsModel::count();
+		return \App\Lib\DataTable\DataTable::init()->toJson($data, $count);
+	}
+
+	//获取活动信息
+	function getArticle() {
+		$limit = Request::has('limit') ? Request::get('limit') : 10;
+
+		$title = Request::has('title') ? Request::get('title') : '';
+		$type = Request::has('type') ? Request::get('type') : '';
+		$add_startime = Request::has('add_startime') ? Request::get('add_startime') : '';
+		$add_endtime = Request::has('add_endtime') ? Request::get('add_endtime') : '';
+
+		$where = array();
+		if (!empty($title)) {
+			$where[] = array('title', 'like', '%' . $title . '%');
+		}
+		if (!empty($type)) {
+			$where[] = array('type', '=', $type);
+		}
+		if (!empty($add_startime)) {
+			$add_startime = date('Y-m-d H:i:s', strtotime($add_startime));
+			$where[] = array('time', '>=', $add_startime);
+		}
+		if (!empty($add_endtime)) {
+			$add_endtime = date('Y-m-d H:i:s', strtotime($add_endtime));
+			$where[] = array('time', '<=', $add_endtime);
+		}
+       
+		$db = new \App\Models\Article();
+		$data = $db->getlist($limit, $where);
+
+		$Lottery=   new LotteryMoney();
+		$activity_list  =   $Lottery->getLotteryList();
+       $activity_list   =   is_array($activity_list)&&count($activity_list) >0?array_column($Lottery->getLotteryList(),"name","id"):[];
+
+		if (count($data)>0) {
+			//$langinfo = trans('status.article.type');
+            //2018-09-26 修改无限级分类
+
+			$_type   =   (new  ArticleType())->type();
+            $type   =   array_column($_type,"parent_path","id");
+            $type_name  =   array_column($_type,"cate_name","id");
+			foreach ($data['data'] as $k => $v) {
+			//	$data['data'][$k]['type'] = isset($langinfo[$v['type']])?$langinfo[$v['type']]:null;
+                $act    =   isset($activity_list[$v["child_id"]])&&!empty($activity_list[$v["child_id"]])?"<b>【活动:".$activity_list[$v["child_id"]]."】</b>":"";
+                $_name= isset($type_name[$v['type']])?">".$type_name[$v['type']]:"";
+				$data['data'][$k]['type'] = isset($type[$v['type']])?$type[$v['type']].$_name.$act:$_name;
+
+			}
+		}
+
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+    //获取活动信息
+    function getArticleType() {
+
+	    $cen    =   [
+	        "1"=>"一级分类",
+	        "2"=>"二级分类",
+	        "3"=>"三级分类",
+	        "4"=>"四级分类",
+	        "5"=>"五级分类",
+	        "6"=>"六级分类",
+	        "7"=>"七级分类",
+	        "8"=>"八级分类",
+	        "9"=>"九级分类",
+        ];
+
+        $limit = Request::has('limit') ? Request::get('limit') : 10;
+
+        $title = Request::has('title') ? Request::get('title') : '';
+        $type = Request::has('type') ? Request::get('type') : '';
+        $add_startime = Request::has('add_startime') ? Request::get('add_startime') : '';
+        $add_endtime = Request::has('add_endtime') ? Request::get('add_endtime') : '';
+
+        $where = array();
+        if (!empty($title)) {
+            $where[] = array('cate_name', 'like', '%' . $title . '%');
+        }
+
+        if (!empty($add_startime)) {
+            $add_startime = date('Y-m-d H:i:s', strtotime($add_startime));
+            $where[] = array('create_time', '>=', $add_startime);
+        }
+        if (!empty($add_endtime)) {
+            $add_endtime = date('Y-m-d H:i:s', strtotime($add_endtime));
+            $where[] = array('create_time', '<=', $add_endtime);
+        }
+
+        $db = new ArticleType();
+        $data = $db->getlist($where,$limit );
+        $c  =   count($data);
+        if ($c>0) {
+            foreach ($data as $k=>$v){
+                $data[$k]["parent_path"]=empty($v["parent_path"])?$cen[1]:$v["parent_path"];
+            }
+            return \App\Lib\DataTable\DataTable::init()->toJson($data, $c);
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data']=[], $data['total']=null);
+    }
+
+
+	//添加菜单
+	function AddMenu() {
+		$id = Request::has('id') ? Request::get('id') : '';
+		$data = array();
+		$db = new \App\Models\NewMenu();
+		if (!empty($id)) {
+			$data = $db->getMenuById($id);
+		}
+		$parent = $db->getMenuParent();
+		return view('admin.menu/add', ['data' => $data, 'parents' => $parent]);
+	}
+	function Edit(Req $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		$db = new \App\Models\NewMenu();
+		if (!$req->isMethod('post')) {
+			$data = $db::where('id', $id)->first();
+			if (!$data) {
+				abort(404);
+			}
+			$data = $data->toArray();
+			$parent = $db->getMenuParent();
+			return view('admin.menu/add', ['data' => $data, 'parents' => $parent]);
+		} else {
+			$model = $db::where('id', $id)->first();
+			$model->name = $req->input('menu_name');
+			$model->href = $req->input('menu_url');
+			$model->icon = $req->input('menu_icon');
+			$model->sort = $req->input('menu_sort');
+			$model->type = $req->input('type');
+			$model->save();
+			return responseToJson(1);
+		}
+	}
+	//添加
+	function add() {
+		$name = Request::get('name');
+		echo '<pre>';
+		print_r($_GET);
+		print_r($_POST);
+	}
+	//玩法简介
+	function Playdesc() {
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/System/active');
+		$dt->setLang('notice');
+		$dt->addColsFields('id', array('fixed' => 'left'));
+		$dt->addColsFields('name');
+//        $dt->addColsFields('play_desc');
+		$dt->addColsFields('table_name');
+		$dt->setToolBar(array('view', 'edit'));
+		return view('admin.systemSet/arictle', $dt->render());
+	}
+	/**
+	 * 公告显示
+	 */
+	function Notice() {
+		$db = new \App\Models\Setinfo();
+		$data = $db->getNotice();
+		return responseToJson($data);
+	}
+
+	/**
+	 * 公告设置
+	 */
+	function NoticeSet() {
+
+	}
+
+	/**
+	 * 弹框
+	 */
+	function OutBox() {
+		$db = new \App\Models\Setinfo();
+		$data = $db->getBoxOut();
+		return responseToJson($data);
+	}
+
+	/**
+	 * 手机弹框内容设置
+	 */
+	function OutBoxSet() {
+
+	}
+
+	/**
+	 * 客服QQ设置
+	 */
+	function ServerQQ() {
+//        $data=DB::table('setinfo')->where('infotype',14)->get();
+		//        dump($data->toArray());
+		$db = new \App\Models\Setinfo();
+		$data = $db->getQQnumber();
+		return responseToJson($data);
+	}
+	/**
+	 * 客服QQ设置修改
+	 */
+	function ServerQQSet() {
+
+	}
+	/**
+	 * 代理设置
+	 */
+	function Agent() {
+		$db = new \App\Models\Setinfo();
+		$data = $db->getAgentSet();
+		return responseToJson($data);
+	}
+
+	/**
+	 * 代理模式设置
+	 */
+	function AgentSet() {
+
+	}
+
+	/**
+	 * 平台维护
+	 */
+	function PlatFrom() {
+		$db = new \App\Models\Setinfo();
+		$data = $db->getPlatSet();
+		return responseToJson($data);
+	}
+
+	/**
+	 * 平台维护设置
+	 */
+	function PlatFromSet() {
+
+	}
+	//虚拟游戏设置显示
+	function Flaseprize() {
+		$db = new \App\Models\Setinfo();
+		$data = $db->getPrizeSet();
+		return responseToJson($data);
+	}
+	//转账银行卡信息
+	function BankInfo() {
+		$db = new \App\Models\Setinfo();
+		$data = $db->getBankInfo();
+		return responseToJson($data);
+	}
+	//跑马灯公告
+	function RunNotice() {
+		$db = new \App\Models\Setinfo();
+		$data = $db->getRunNotice();
+		return responseToJson($data);
+	}
+	//注册设置信息
+	function RegisterSet() {
+		$db = new \App\Models\Settings();
+		$data = $db->getSet();
+		return responseToJson($data);
+	}
+	/**
+	 * 游戏玩法说明消息
+	 */
+	function Active() {
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$db = new \App\Models\GameType();
+		$data = $db->getDescList($list);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+//        return responseToJson($data);
+	}
+
+	/**
+	 * 修改游戏玩法内容
+	 */
+	function ActiveSet() {
+//        $data=DB::table('article')->limit(3)->get();
+		//        dump($data->toArray());
+
+	}
+
+	/**
+	 * 系统菜单列表
+	 */
+	function SystemMenu() {
+		$db = new \App\Models\Menu();
+		$data = $db->getMenuAll();
+		return responseToJson($data);
+	}
+
+	/**
+	 * 菜单
+	 */
+	function MenuList() {
+		$data = config('menu');
+		return responseToJson($data);
+	}
+
+	function cceshi(){
+        dump('start');
+        $db=\App\Models\Role::hasRoot('11');
+	    dump($db);
+    }
+
+}
+
+?>

+ 171 - 0
app/Http/Controllers/Admin/SystemRedController.php

@@ -0,0 +1,171 @@
+<?php
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+
+class SystemRedController extends Controller {
+
+    public function Index(Req $req)
+    {
+        $request=array();
+        $request['name']=isset($req->name)?trim($req->name):null;
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/SystemRed/redList');
+        $dt->setLang('systemred');
+        $dt->enableCheckBox();
+        $dt->addColsFields('id');
+        $dt->addColsFields('red_num');
+        $dt->addColsFields('red_money');
+        $dt->addColsFields('room_name');
+        $dt->addColsFields('username');
+        $dt->addColsFields('status');
+        $dt->addColsFields('tool', array('templet' => '#option','sort'=>false));
+        return view('admin.SystemRed/index',$dt->render($request));
+    }
+
+    public function redList(Req $req)
+    {
+        $list = $req->limit;
+        $db = new \App\Models\SystemRed();
+        $data = $db->getAll($list);
+        $status = trans ('systemred.stat');
+        foreach ($data['data'] as $key => $val)
+        {
+            $data['data'][$key]->status =  $status[$val->status];
+        }
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+
+
+    public function add(Req $req)
+    {
+        if(!$req->isMethod('post')){
+            $chatRoom = new \App\Models\ChatRooms();
+            $chatRoom = $chatRoom->getAll();
+            return view('admin.SystemRed/add',['chatRoom' => $chatRoom]);
+        }else{
+            $chatRoom = $req->chatRoom?trim($req->chatRoom):'';
+            $red_num = trim($req->red_num);
+            $red_money = trim($req->red_money);
+            $red_mark = trim($req->red_mark);
+            $status = trim($req->status);
+            $username = trim($req->username);
+            $account = new \App\Models\Account();
+            $res = $account->checkUserByName($username);
+            if($res<0){
+                return responseToJson(-1,'账户不存在');
+            }
+            iF($red_money > $res['cash'])
+            {
+                return responseToJson(-1,'账户余额不足');
+            }
+            if(empty($chatRoom)){
+                return responseToJson(-10086);
+            }
+            if(empty($red_num)){
+                return responseToJson(-10086);
+            }
+            if(empty($red_money)){
+                return responseToJson(-10088);
+            }
+            $red = new \App\Models\SystemRed();
+            $room = $red->checkRoom($chatRoom);
+            if($room){
+                return responseToJson(-1,'房间红包已存在');
+            }
+            $update_data=array(
+                'red_num'=>$red_num,
+                'red_money' =>$red_money,
+                'red_mark' => $red_mark,
+                'room_id' =>$chatRoom,
+                'status' => $status,
+                'username'=>$username
+            );
+            $res=$red->addSystemRed($update_data);
+            $log = array(
+                session('adminInfo.admin_name'),
+                $chatRoom
+            );
+            OperationLog(session('adminInfo.admin_id'), 'edit_info', $log);
+            return responseToJson($res);
+        }
+    }
+
+    public function edit(Req $req)
+    {
+        $id=$req->id;
+        $chatRoom = new \App\Models\ChatRooms();
+        $red = new \App\Models\SystemRed();
+        if(!$req->isMethod('post')){
+            $data=$red->getSystemRedOne(['id'=>$id]);
+            $room = $chatRoom->getAll();
+            return view('admin.SystemRed/edit',['chatRoom'=>$room,'data'=>$data]);
+        }else{
+            $red_num = trim($req->red_num);
+            $red_money = trim($req->red_money);
+            $red_mark = trim($req->red_mark);
+            $status = trim($req->status);
+            $username = trim($req->username);
+            $account = new \App\Models\Account();
+            $res = $account->checkUserByName($username);
+            if($res<0){
+                return responseToJson(-1,'账户不存在');
+            }
+            iF($red_money > $res['cash'])
+            {
+                return responseToJson(-1,'账户余额不足');
+            }
+            if(empty($chatRoom)){
+                return responseToJson(-10086);
+            }
+            if(empty($red_num)){
+                return responseToJson(-10086);
+            }
+            if(empty($red_money)){
+                return responseToJson(-10088);
+            }
+            $update_data=array(
+                'red_num'=>$red_num,
+                'red_money' =>$red_money,
+                'red_mark' => $red_mark,
+                'status' => $status,
+                'username'=>$username
+            );
+            $res=$red->updateSystemRed(['id'=>$id],$update_data);
+            $log = array(
+                session('adminInfo.admin_name'),
+                $chatRoom
+            );
+            OperationLog(session('adminInfo.admin_id'), 'edit_info', $log);
+            return responseToJson($res);
+        }
+    }
+
+    public function delete(Req $req)
+    {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001);
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002);
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\SystemRed::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003);
+        }
+        return responseToJson(1);
+    }
+
+}

+ 230 - 0
app/Http/Controllers/Admin/TakeController.php

@@ -0,0 +1,230 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\Withdraw_rule;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use Request;
+
+/**
+ *
+ */
+class TakeController extends Controller
+{
+    /**
+     * @return 提现管理
+     */
+    function index(Req $req)
+    {
+        $request = array();
+        $request['grade'] = isset($req->grade) ? trim ($req->grade) : null;
+        $request['account_name'] = isset($req->account_name) ? trim ($req->account_name) : null;
+        $request['order_id'] = isset($req->order_id) ? trim ($req->order_id) : null;
+        $request['bank_user'] = isset($req->bank_user) ? trim ($req->bank_user) : null;
+        $request['grade'] = isset($req->grade) ? trim ($req->grade) : null;
+        $request['status'] = isset($req->status) ? trim ($req->status) : 3;
+        $request['money_small'] = isset($req->money_small) ? trim ($req->money_small) : null;
+        $request['money_big'] = isset($req->money_big) ? trim ($req->money_big) : null;
+        $request['apply_startime'] = isset($req->apply_startime) ? trim ($req->apply_startime) : trans ('status.default_time.atime');
+        $request['apply_endtime'] = isset($req->apply_endtime) ? trim ($req->apply_endtime) : trans ('status.default_time.etime');
+        $request['haddle_startime'] = isset($req->haddle_startime) ? trim ($req->haddle_startime) : null;
+        $request['haddle_endtime'] = isset($req->haddle_endtime) ? trim ($req->haddle_endtime) : null;
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+
+
+        $dt = \App\Lib\DataTable\DataTable::init ();
+        $dt->setDataSource ('/admin/money/withdraw');
+        $dt->setLang ('money');
+        $dt->setPriKey ('order_id');
+        $dt->addColsFields ('id', array('width' => 90));
+        $dt->addColsFields ('account_name', array('templet' => '#usertake', 'width' => 130));
+        $dt->addColsFields ('apply_time', array('width' => 230));
+        $dt->addColsFields ('money', array('templet' => '#money_aftercash', 'width' => 280));
+        $dt->addColsFields ('bank_info_no', array('sort' => false, 'templet' => '#infoNo', 'width' => 200));
+        $dt->addColsFields ('bank_user_address', array('sort' => false, 'width' => 180));
+        $dt->addColsFields ('reason', array('sort' => false));
+        $dt->addColsFields ('pass_time', array('templet' => '#takes', 'width' => 180));
+        $dt->addColsFields ('pass', array('sort' => false, 'templet' => '#pass', 'width' => 120));
+        return view ('admin.Take/index', $dt->render ($request));
+    }
+
+    /**
+     * 单用户提现列表
+     * [detail description]
+     * @return [type] [description]
+     */
+    function usertake()
+    {
+        $account_name = Request::has ('account_name') ? Request::get ('account_name') : '';
+        $dt = \App\Lib\DataTable\DataTable::init ();
+        $dt->setDataSource (htmlspecialchars ('/admin/money/withdraw?account_name=' . $account_name . "&sureblur=精确"));
+        $dt->setLang ('money');
+        $dt->setPriKey ('order_id');
+        $dt->addColsFields ('id', array('width' => 100));
+        $dt->addColsFields ('account_name', array('templet' => '#usertake', 'width' => 110));
+        $dt->addColsFields ('apply_time', array('width' => 200));
+        $dt->addColsFields ('money', array('width' => 100));
+        $dt->addColsFields ('bank_info_no', array('sort' => false, 'width' => 180));
+        $dt->addColsFields ('bank_user_address', array('sort' => false, 'width' => 180));
+        $dt->addColsFields ('pass_time', array('width' => 180));
+        $dt->addColsFields ('pass', array('sort' => false, 'templet' => '#pass', 'width' => 100));
+        return view ('admin.Take/usertake', $dt->render ());
+    }
+
+    //查看提现
+    function Edit(Req $req)
+    {
+        $order_id = $req->order_id;
+        if (empty($order_id)) {
+            abort (404);
+        }
+        $moneydetails = new \App\Models\Money_take();
+        $userObj = new \App\Models\Account();
+        $accountDB = new \App\Models\Account_detailed();
+        $reccharge = new \App\Models\Money_recharge(); //充值
+        $money_buy_db = new \App\Models\MoneyBuy(); //购买
+        $data = $moneydetails->getOrderDetails ($order_id, 3);
+        if ($data < 0) {
+            return responseToJson ($data);
+        }
+        if (!$req->isMethod ('post')) {
+            $userRemark = $userObj->getinfo ($data['account_identity'], 2);
+            $data['user_remark'] = $userRemark['remark'];
+            $account = $accountDB->getInfoBy ($data['account_identity']);
+            $data['last_money'] = $account['available_cash']; //交易余额
+            $data['pre_money'] = $data['money'] + $account['available_cash']; //交易余额
+            $count_take = $moneydetails->getCount ($data['account_identity']);
+            $data['take_count'] = $count_take;
+            $data['today_take'] = $moneydetails->gettoDayCount ($data['account_identity']);
+            $last_rech_info = $reccharge->getLast ($data['account_identity']);
+            $time = isset($last_rech_info['apply_time']) ? $last_rech_info['apply_time'] : '';
+            $data['last_recharge_time'] = $time; //最后一笔存款时间
+            $data['last_recharge_money'] = isset($last_rech_info['money']) ? $last_rech_info['money'] : '0'; //最后一笔存款金额
+            $data['total_bet_money'] = 0;
+            $re = Withdraw_rule::check ($data['account_identity']);
+            $data['needBettingMoney'] = $re ? $re->needBettingMoney : '未设定';
+            $data['bettingMoney'] = $re ? $re->bettingMoney : '未设定';
+            $data['total_bet_money'] = $data['bettingMoney'];
+            $tradetype = \App\Models\Money_details::select('trade_type')->where('trade_id',$data['order_id'])->first();
+            $data['active'] = ($tradetype && isset($tradetype->trade_type))?$tradetype->trade_type:5;
+            return view ('admin.Take/edit', ['data' => $data]);
+        } else {
+            //验证可操作金额限额
+            $limitroot = new \App\Models\System_user();
+            $limitmoney = $limitroot->checkActMoney ($data['money']);
+            if ($limitmoney < 0) {
+                return responseToJson ($limitmoney);
+            }
+            if (empty($req->status)) {
+                return responseToJson (-3025210022); //已处理的订单不能再处理
+            }
+            $tradetype = $req->active?trim($req->active):5;
+            //开启事务
+            DB::beginTransaction ();
+            $datas = array(
+                'status' => $req->status,
+                'reason' => $req->reason,
+            );
+            $datas['pass_time'] = date ('Y-m-d H:i:s');
+            $data['pass_time'] = $datas['pass_time'];
+            $res = \App\Models\Money_count::AddCountinfo ($data, 'take');
+            if ($res < 0) {
+                DB::rollback ();//事务回滚
+                return responseToJson ($res);
+            }
+            $res = $moneydetails->checkInfo ($order_id);
+            if ($res < 0) {
+                DB::rollback ();//事务回滚
+                return responseToJson ($res);
+            }
+            if ($req->status == 2) {
+                //如果驳回
+                $res1 = $accountDB->addMoney ($data['account_identity'], $data['money']);
+                if ($res1 < 0) {
+                    DB::rollback ();//事务回滚
+                    return responseToJson ($res1);
+                }
+            }
+            $res = $moneydetails->updateInfo ($datas, $order_id);
+            if ($res < 0) {
+                DB::rollback ();//事务回滚
+                return responseToJson ($res);
+            }
+            $log = array(
+                session ('adminInfo.admin_name'),
+                $data['account_name'],
+                $data['money'],
+                $order_id,
+            );
+            if ($req->status == 1) {
+                OperationLog (session ('adminInfo.admin_id'), 'pass_take', $log);
+            } else {
+                OperationLog (session ('adminInfo.admin_id'), 'nopass_take', $log);
+            }
+            $data['reason'] = $datas['reason'];
+            $res = $this->addLog ($data, $req->status,$tradetype);
+            if ($res < 0) {
+                DB::rollback ();//事务回滚
+                return responseToJson ($res);
+            }
+            $db = new \App\Models\Manager;
+            if ($req->status == 1) {
+                $db->updateMessage ('admin', $data['account_name'], '提款提示', '提款成功,提款金额:' . $data['money'], 2);
+            } else {
+                $db->updateMessage ('admin', $data['account_name'], '提款提示', '提款失败,提款金额:' . $data['money'], 2);
+            }
+            $clear = Withdraw_rule::withDraw ($data['account_identity']);//更新目标流水增量记录
+            if (!$clear)
+                DB::rollback ();
+            DB::commit ();//事务回滚
+            return responseToJson ($res);
+        }
+    }
+
+    //详情记录
+    function addLog($data, $type,$trade_type=5)
+    {
+        $ac_log = array(
+            $data['account_name'],
+            $data['money'],
+            $data['order_id'],
+        );
+        $str = 'take_money_';
+        if ($type == 2) {
+            $str .= 'fail';
+            $money_type = 1;
+        } else {
+            $str .= 'success';
+            $money_type = 2;
+        }
+        $accountDB = new \App\Models\Account_detailed();
+        $account = $accountDB->getInfoBy ($data['account_identity']);
+        $log = array(
+            'trade_id' => $data['order_id'],
+            'account_name' => $data['account_name'],
+            'account_identity' => $data['account_identity'],
+            'money' => $data['money'],
+            'money_time' => date ('Y-m-d H:i:s', time ()),
+            'trade_type' => $trade_type,
+            'trade_desc' => vsprintf (trans ('trade.' . $str), $ac_log),
+            'status' => $type,
+            'money_type' => $money_type,
+            'money_cash' => $account['cash'],
+            'reason' => $data['reason'],
+            'sysetem_user' => session ('adminInfo.admin_name'),
+        );
+        $moeny_db = new \App\Models\Money_details;//详情表
+        return $moeny_db->insertData ($log);
+    }
+
+    public function checkMoney(Req $req)
+    {
+        $idd = $req->account_identity ?? '';
+        if (!$idd) return responseToJson (-3020300502);
+        return $ret = Withdraw_rule::check ($idd)??0;
+    }
+}
+
+?>

+ 227 - 0
app/Http/Controllers/Admin/TennisLeagueController.php

@@ -0,0 +1,227 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementWinFail;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class TennisLeagueController extends Controller {
+
+    public function index(Req $req) {
+        //$request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '-1';
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : '';
+        $request['area_id'] = isset($req->area_id) ? trim($req->area_id) : '';
+        $request['country_id'] = isset($req->country_id) ? trim($req->country_id) : '';
+        $request['id'] = isset($req->id) ? trim($req->id) : '';
+        $request['status'] = isset($req->status) ? trim($req->status) : '0';
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $data = \App\Models\SoccerLeague::select('id','lg_id','name_chinese')->get();
+        $area = \App\Models\StAreaCountry::where('pid',0)->get();
+        $country = \App\Models\StAreaCountry::where('pid','!=',0)->get();
+        $request['league'] = $data;
+        $request['area'] = $area;
+        $request['country'] = $country;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/TennisLeague/info');
+        $dt->setLang('sportsbase');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 120));
+        $dt->addColsFields('name_chinese', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('area', array('sort' => false, 'width' => 180));
+        $dt->addColsFields('country', array('sort' => true, 'width' => 180));
+        $dt->addColsFields('league_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 90));
+        $dt->addColsFields('utime', array('templet' => '#userdetail', 'sort' => false, 'width' => 160));
+        if (checkRriv('/admin/TennisLeague/edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 140));
+        $dt->enableCheckBox();
+        return view('sports/tennis_league', $dt->render($request));
+    }
+
+    function info(Req $req) {
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $id = Request::has('id') ? Request::get('id') : '';
+        $name_chinese = Request::has('name_chinese') ? Request::get('name_chinese') : '';
+        $area_id = Request::has('area_id') ? Request::get('area_id') : '';
+        $country_id = Request::has('country_id') ? Request::get('country_id') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        if (!empty($name_chinese)) {
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where[] = array('st_wq_league.name_chinese', 'like', '%' . $name_chinese . '%');
+            }else{
+                $where[] = array('st_wq_league.name_chinese', '=', $name_chinese);
+            }
+        }
+//        if ($name_chinese != -1) {
+//            $where[] = array('st_wq_league.name_chinese', '=', $name_chinese);
+//        }
+        if(!empty($area_id)){
+            $where[] = array('st_wq_league.area_id', '=', $area_id);
+        }
+        if(!empty($country_id)){
+            $where[] = array('st_wq_league.country_id', '=', $country_id);
+        }
+        if($status != 0){
+            $where[] = array('st_wq_league.status', '=', $status);
+        }
+
+        $newapp = new \App\Models\TennisLeague();
+        $data = $newapp->getinfo($list, $page, $where);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    /**
+     *获取地区
+     */
+    function getarea() {
+        $area = \App\Models\StAreaCountry::where('pid',0)->get();
+        return $area;
+    }
+
+    /**
+     *获取该地区的所有国家
+     */
+    function getcountry() {
+        $pid = $_GET["id"];
+        $country = \App\Models\StAreaCountry::where('pid',$pid)->get();
+        return json_encode($country);
+    }
+
+    /**
+     *添加联赛
+     */
+    function add(Req $req) {
+        if (!$req->isMethod('post')) {
+            $areas = $this->getarea();
+            if (!$areas) {
+                return -2;
+            }
+            $data['area'] = $areas;
+            return view('sports.tennis_league_form', $data);
+        } else {
+            $model = new \App\Models\TennisLeague();
+            $model->name_chinese = $req->input('name_chinese');
+            $model->country_id = $req->input('country_id');
+            $model->area_id = $req->input('area_id');
+            $model->status = $req->input('status');
+            $model->lg_id = time();
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->source = 'user-defined';
+
+            $db = new \App\Models\Stwqlocalleague();
+            $db->source = 'user-defined';
+            $db->lg_id = $model->lg_id;
+
+            $model->save();
+            $db->save();
+            return responseToJson(1);
+
+        }
+    }
+
+    function view(Req $req) {
+        return $this->edit($req);
+    }
+
+    /**
+     *修改联赛
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        if (!$req->isMethod('post')) {
+            $areas = $this->getarea();
+            if (!$areas) {
+                return -2;
+            }
+            $data = \App\Models\TennisLeague::where('id',$id)->first();
+            $areaname = \App\Models\StAreaCountry::where('id',$data->area_id)->first();
+            $countryname = \App\Models\StAreaCountry::where('id',$data->country_id)->first();
+            if(!empty($areaname)){
+                $data->area = $areaname->name;
+            }
+            if(!empty($countryname)){
+                $data->country = $countryname->name;
+            }
+
+            $data = $data->toArray();
+            $data['area'] = $areas;
+
+            return view('sports.tennis_league_form', $data);
+        } else {
+            $model = new \App\Models\TennisLeague();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            if(!empty($req->input('country_id'))){
+                $model->country_id = $req->input('country_id');
+            }else{
+                $model->country_id = 0;
+            }
+            if(!empty($req->input('area_id'))){
+                $model->area_id = $req->input('area_id');
+            }else{
+                $model->area_id = 0;
+            }
+            $model->status = $req->input('status');
+            $model->utime = date('Y-m-d H:i:s',time());
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+    /**
+     *删除联赛
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id???????
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id????
+        }
+        $id = array();
+        $localleague = \App\Models\Stwqlocalleague::get();
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+                $league = \App\Models\TennisLeague::where('id',$v)->first();
+                for($i=0;$i<count($localleague);$i++){
+                    if($localleague[$i]->lg_id == $league->lg_id){
+                        $id[] = $localleague[$i]->id;
+                    }
+                }
+            }
+        }
+
+
+        $rows = \App\Models\TennisLeague::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id????
+        }
+        if(count($id)>0) {
+            $row = \App\Models\Stwqlocalleague::whereIn('id', $id)->delete();
+            if (!$row) {
+                return responseToJson(-2003); //id????
+            }
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id????
+
+    }
+
+
+}

+ 184 - 0
app/Http/Controllers/Admin/TennisNoteListController.php

@@ -0,0 +1,184 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jonlin
+ * Date: 2019/4/9
+ * Time: 9:11
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Models;
+use Request;
+
+/**
+ *
+ */
+class TennisNoteListController extends Controller
+{
+
+    public function notelist(Req $req)
+    {
+        $request['name_chinese'] = isset($req->name_chinese) ? trim($req->name_chinese) : null;
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/TennisNoteList/info');
+        $dt->setLang('sportsnotelist');
+        $dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
+        $dt->addColsFields('order_time', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
+        $dt->addColsFields('game', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('game_no', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('prize_note', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('water_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        //$dt->addColsFields('prize', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('settle_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('game_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('account_name', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('member_type', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
+        //$arr[] = 'view';
+        if (checkRriv('/admin/TennisNoteList/edit')) {
+            $arr[] = 'edit';
+        }
+        $dt->setToolBar($arr, array('width' => 70));
+        $dt->enableCheckBox();
+        return view('sports/sports_notelist', $dt->render($request));
+    }
+
+    function info()
+    {
+        $type = 'wq';
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+//        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $where = array();
+        if (!empty($star_time)) {
+            if (!empty($end_time)){
+                $where[] = array('money_buy.money_time', '>', $star_time);
+                $where[] = array('money_buy.money_time', '<', $end_time);
+            }else{
+                $where[] = array('money_buy.money_time', '>', $star_time);
+            }
+        }else if(empty($star_time)){
+            if (!empty($end_time)){
+
+                $where[] = array('money_buy.money_time', '<', $end_time);
+            }
+        }
+        $newapp = new \App\Models\SportsNoteList();
+        $data = $newapp->getinfo($list, $page, $where,$type);
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    /**
+     *修改订单
+     */
+    function edit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $lange = trans('sportssoccer');
+        $data = \App\Models\SportsNoteList::where('id',$id)->first();
+        $data->order_time = $data->order_id.'     '.$data->money_time;
+        //for($i=0;$i<count($data);$i++){
+        $codes = json_decode($data->codes, true);
+        $data->content = '';
+        for($j=0;$j<count($codes);$j++){
+            $odds_only = $data->odds_only;
+            $res = DB::table('st_wq_odds_record')->where('odds_only',$odds_only)->first();
+            $result = DB::table('st_odds_code')->where('odds_code',$res['odds_code'])->first();
+            //$result = \App\Model\Matchcode::where('odds_code',$res->odds_code)->first();
+            $game = DB::table('st_game_type')->where('game_code',$data->game_name)->first();
+            $data->content = $data->content.$result['odds_name'].  '¥'.$codes[$j]['bet_amount'];
+            $data->game = $game->game_name;
+        }
+        //}
+
+        if (!$req->isMethod('post')) {
+
+
+            $data = $data->toArray();
+
+            return view('sports/sports_notelist_form', $data);
+        } else {
+            $model = new \App\Models\SportsNoteList();
+            $model->id = $req->input('id');
+            $model = $model::find($model->id);
+            $model->water_status = $req->input('water_status');
+            $model->settle_status = $req->input('settle_status');
+            $model->game_status = $req->input('game_status');
+            //$model->utime = date('Y-m-d H:i:s',time());
+
+            $model->save();
+            return responseToJson(1);
+        }
+
+    }
+
+    /**
+     *订单审核
+     */
+    public function orderstatus(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+
+
+    /**
+     *删除订单
+     */
+    public function delete(Req $req) {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+
+        $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+
+    }
+}

+ 22 - 0
app/Http/Controllers/Admin/TestController.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+class TestController extends Controller {
+	function test() {
+        $gameTypeModel = new \App\Models\StGameType();
+        $getGameTypeSelect = ['id', 'game_name', 'game_code']; 
+        $getGameTypeWhere['status'] = 1;
+        $result['sportType'] = $gameTypeModel -> getGameType($getGameTypeSelect, $getGameTypeWhere);
+        $cascadeModel = new \App\Models\Cascade();
+        $getRankSelect = ['id', 'title', 'source'];
+        $result['rank']['area'] = $cascadeModel -> allArea($getRankSelect);
+        $getCountrySelect = ['country_id', 'name_chinese', 'name_english', 'country_ico', 'country_area', 'id', 'source'];
+        $result['rank']['country'] = $cascadeModel -> getCountry($getCountrySelect, '');
+        $dt = \App\Lib\DataTable\DataTable::init();
+        return view('admin.test/test', $dt->render($result));
+	}
+}

+ 55 - 0
app/Http/Controllers/Admin/TokenController.php

@@ -0,0 +1,55 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: blade
+ * Date: 2018/2/1
+ * Time: 16:52
+ */
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+
+class TokenController extends Controller
+{
+
+    /**
+     * @param $ver_data 含时间的数据数组
+     * @param $ver_sign 传入验证字符串
+     * @param $token 后台token
+     * @return int
+     */
+      function check($ver_data,$ver_sign,$token){
+        $res=$this->checkTime($ver_data['time']);
+        if($res<0){
+            return $res;
+        }
+        return $this->checkToken($ver_data,$ver_sign,$token);
+    }
+
+
+    /**
+     * @param $ver_data 数据
+     * @param $sign 传入的校验串
+     * @param $token 正确的token
+     * @return int
+     */
+    private function checkToken($ver_data,$sign,$token){
+        krsort($ver_data);
+        $right_sign=md5(http_build_query($ver_data).'&token='.$token);
+        if($right_sign!=$sign){
+            return -3020035024;//校验失败
+        }
+        return 1;
+    }
+    //时间检验
+    private function checkTime($time){
+        //时间检验
+        if($time<(time()-10)){
+            return -3020035023;//请求超时
+        }
+        return 1;
+    }
+}

+ 256 - 0
app/Http/Controllers/Admin/TransferVerifyController.php

@@ -0,0 +1,256 @@
+<?php
+/**
+ * 真人转账审核
+ * User: qin
+ * Date: 2019/2/18
+ * Time: 14:30
+ */
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Request;
+use Illuminate\Support\Facades\DB;
+
+class TransferVerifyController extends Controller
+{
+	/**
+     * 审核用户转账申请接口
+     */
+    public function transferCredit()
+    {
+        $username = isset($_POST['username']) ? $_POST['username'] : '';
+        $game_type = isset($_POST['game_type']) ? $_POST['game_type'] : '';
+    	$localuser = isset($_POST['localuser']) ? $_POST['localuser'] : '';
+        $credit = isset($_POST['credit']) ? $_POST['credit'] : '';
+        $type = isset($_POST['type']) ? $_POST['type'] : '';
+        $billno = isset($_POST['billno']) ? $_POST['billno'] : '';
+        $stype = isset($_POST['stype']) ? $_POST['stype'] : '';
+        $remarks = isset($_POST['remarks']) ? $_POST['remarks'] : '';
+        $zngame = isset($_POST['zngame']) ? $_POST['zngame'] : '';
+
+        if(empty($game_type))
+        {
+            echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入游戏英文名称'));
+        }
+        else if(empty($localuser))
+        {
+            echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入用户名'));
+        }
+        else if(empty($credit))
+        {
+            echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入转账金额'));
+        }
+        else if(empty($type))
+        {
+            echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入转账类型'));
+        }
+        else if(empty($billno))
+        {
+            echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入订单号'));
+        }
+        else if(empty($stype))
+        {
+            echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入审核类型'));
+        }
+        else if(empty($remarks))
+        {
+            echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入审核理由'));
+        }else if(empty($zngame))
+        {
+            echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入游戏中文名称'));
+        }
+        else
+        {
+        	$ostr = '\\App\\Lib\\Biz\\Game\\Egame\\'.ucfirst($game_type);
+            $obj = new $ostr();
+            $user = new \App\Models\Account();
+            $userobj = new \App\Models\Account_detailed();
+            $moneydetails = new \App\Models\Money_details();
+            $moneyrecharge = new \App\Models\Money_recharge();
+            $re = new \App\Models\Oggame_transfer_record();
+            //查询用户信息
+            $un = $user->getinfo($localuser,3);
+            //查询用户可操作余额
+            $userinfo = $userobj->getInfoBy($un['identity']);
+            $set = new \App\Models\Rgame_setting();
+
+            $where = array();
+            $where[] = array('game_type','=',$game_type);
+            $set_obj  = $set->getGame($where);
+            
+            if($stype ==1){
+
+                $logtwo = array(session ('adminInfo.admin_name'),$type.'-'.$stype,$localuser,$game_type,$zngame);
+                OperationLog (session ('adminInfo.admin_id'), 'transferCredit', $logtwo);
+                //查询用户当前最新余额
+                $nc = $userobj->getInfoBy($un['identity']);
+                if($type == 1)
+                {
+                    $res_to=$obj->transferCreditNew($localuser,$username,$credit,1);
+
+                    if($res_to['status'] !=1){
+                        $logtwo = array(session ('adminInfo.admin_name'),$type.'-'.$stype,$localuser,$game_type,$zngame);
+                        OperationLog (session ('adminInfo.admin_id'), 'transferCredit', $logtwo);
+                        echo json_encode(array('status' => 0, 'data' => '', 'msg' => $res_to['msg']));
+                    }else{
+                        $msg = '[审核通过]从余额转入到'.$zngame.',金额为:'.$credit.' 元。订单号为:'.$billno.'';
+                        $ud['trade_desc'] = $msg;
+                        $moneydetails->updateInfo($ud,$billno,3);
+
+                        //更改用户转账申请状态
+                        $w[] = array('order_no','=',$billno);
+                        $w[] = array('game_type','=',$game_type);
+                        $w[] = array('local_user','=',$localuser);
+                        $d['type'] = 1;
+                        $d['exec_time'] = time();
+                        $d['exec_result'] = '[转账成功]从余额转入到游戏(手机版)';
+                        $d['remarks'] = $remarks;
+                        $re->setTransferCredit($w,$d);
+
+                        echo json_encode(array('status' => 1, 'data' => '', 'msg' => '转账成功', 'exec_result' => $d['exec_result']));
+                    }
+                    
+                }
+                else if($type == 2)
+                {
+                    $add = $userobj->addMoney($userinfo['account_identity'],$credit);
+                    //写入资金操作记录
+                    $msg = '[审核成功]从'.$zngame.'转入到余额,金额为:'.$credit.' 元。订单号为:'.$billno.'';
+                    $log=array(
+                        'info_identity'=>UUID (),
+                        'trade_id'=>date('YmdHis', time()).rand(111111,999999),
+                        'account_name'=>$localuser,
+                        'account_identity'=>$userinfo['account_identity'],
+                        'money'=>$credit,
+                        'money_time'=>date('Y-m-d H:i:s'),
+                        'money_type'=>1,
+                        'reason'=>$remarks,
+                        'trade_type'=>19,
+                        'trade_desc'=>$msg,
+                        'sysetem_user'=>session ('adminInfo.admin_name'),
+                        'money_cash'=>floatval($userinfo['cash'])+floatval($credit),
+                        'status'=>1,
+                    );
+                    $moneydetails->insert($log);
+                    // $ud['trade_desc'] = $msg;
+                    // $ud['money_cash'] = floatval($userinfo['cash'])+floatval($credit);
+                    // $moneydetails->updateInfo($ud,$billno,3);
+
+
+                    //更新充值记录状态
+                    $da['info_identity'] = UUID ();
+                    $da['order_id'] = date('YmdHis', time()).rand(111111,999999);
+                    $da['apply_time'] = date('Y-m-d H:i:s');
+                    $da['complete_time'] = date('Y-m-d H:i:s');
+                    $da['money'] = $credit;
+                    $da['account_name'] = $localuser;
+                    $da['account_identity'] = $userinfo['account_identity'];
+                    $da['status'] = 1;
+                    $da['recharge_type'] = '额度转换';
+                    $da['sysetem_user'] = session ('adminInfo.admin_name');
+                    $da['reason'] = '审核通过';
+                    $da['money_cash'] = floatval($userinfo['cash'])+floatval($credit);
+                    $da['remark'] = '审核通过加款';
+                    $moneyrecharge->insert($da);
+
+                    //更改用户转账申请状态
+                    $w[] = array('order_no','=',$billno);
+                    $w[] = array('game_type','=',$game_type);
+                    $w[] = array('local_user','=',$localuser);
+                    $d['type'] = 1;
+                    $d['exec_time'] = time();
+                    $d['exec_result'] = '[转账成功]从游戏转入到余额(手机版)';
+                    $d['remarks'] = $remarks;
+
+                    $re->setTransferCredit($w,$d);
+
+                    echo json_encode(array('status' => 1, 'data' => '', 'msg' => '转账成功', 'exec_result' => $d['exec_result']));
+                }
+
+            }else{
+
+                if($type == 1)
+                {
+                    //返回到用户余额
+                    $userobj->addMoney($userinfo['account_identity'],$credit);
+
+                    $msg = '[审核未通过]从余额转入到'.$zngame.',金额为:'.$credit.' 元。订单号为:'.$billno.'';
+                    $log=array(
+                        'info_identity'=>UUID (),
+                        'trade_id'=>date('YmdHis', time()).rand(111111,999999),
+                        'account_name'=>$localuser,
+                        'account_identity'=>$userinfo['account_identity'],
+                        'money'=>$credit,
+                        'money_time'=>date('Y-m-d H:i:s'),
+                        'money_type'=>1,
+                        'trade_type'=>19,
+                        'trade_desc'=>$msg,
+                        'sysetem_user'=>session ('adminInfo.admin_name'),
+                        'money_cash'=>floatval($userinfo['cash'])+floatval($credit),
+                        'status'=>1,
+                    );
+                    $moneydetails->insert($log);
+                    // $ud['trade_desc'] = $msg;
+                    // $ud['money_cash'] = floatval($userinfo['cash'])+floatval($credit);
+                    // $moneydetails->updateInfo($ud,$billno,3);
+
+                    $da['info_identity'] = UUID ();
+                    $da['order_id'] = date('YmdHis', time()).rand(111111,999999);
+                    $da['apply_time'] = date('Y-m-d H:i:s');
+                    $da['complete_time'] = date('Y-m-d H:i:s');
+                    $da['money'] = $credit;
+                    $da['account_name'] = $localuser;
+                    $da['account_identity'] = $userinfo['account_identity'];
+                    $da['status'] = 1;
+                    $da['recharge_type'] = '额度转换';
+                    $da['sysetem_user'] = session ('adminInfo.admin_name');
+                    $da['reason'] = '审核未通过';
+                    $da['money_cash'] = floatval($userinfo['cash'])+floatval($credit);
+                    $da['remark'] = '审核未通过退款';
+                    //var_dump($da);exit;
+                    $moneyrecharge->insert($da);
+
+                    //更改用户转账申请状态
+                    $w[] = array('order_no','=',$billno);
+                    $w[] = array('game_type','=',$game_type);
+                    $w[] = array('local_user','=',$localuser);
+
+                    $d['type'] = 4;
+                    $d['exec_time'] = time();
+                    $d['exec_result'] =  '[审核未通过]从余额转入到游戏(手机版)';
+                    $d['remarks'] = $remarks;
+
+                    $re->setTransferCredit($w,$d);
+
+                    echo json_encode(array('status' => 1, 'data' => '', 'msg' => '申请未通过', 'exec_result' => $d['exec_result']));
+                    exit;
+                }
+                else if($type == 2)
+                {
+                    //更改用户转账申请状态
+                    $w[] = array('order_no','=',$billno);
+                    $w[] = array('game_type','=',$game_type);
+                    $w[] = array('local_user','=',$localuser);
+
+                    $d['type'] = 4;
+                    $d['exec_time'] = time();
+                    $d['exec_result'] = '[审核未通过]从游戏转入到余额(手机版)';
+                    $d['remarks'] = $remarks;
+
+                    $re->setTransferCredit($w,$d);
+
+                    //返还到用户游戏余额
+                    $res_to=$obj->transferCreditNew($localuser,$username,$credit,1);
+                    if($res_to['status'] !=1){
+                        $logtwo = array(session ('adminInfo.admin_name'),$type.'-'.$stype,$localuser,$game_type,$zngame);
+                        OperationLog (session ('adminInfo.admin_id'), 'transferCredit', $logtwo);
+                    }
+                    echo json_encode(array('status' => 1, 'data' => '', 'msg' => '申请未通过', 'exec_result' => $d['exec_result']));
+                    exit;
+                }
+            }
+        }
+    }
+}
+
+?>

+ 123 - 0
app/Http/Controllers/Admin/TypeNameController.php

@@ -0,0 +1,123 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use Illuminate\Http\Request as Req;
+use App\Http\Controllers\Controller;
+use Request;
+class TypeNameController extends Controller
+{
+    //首页
+    public function index(){
+        $dt=\App\Lib\DataTable\DataTable::init();
+        $dt->setLang('type_name');
+        $dt->enableCheckBox();
+        $dt->addColsFields('id');
+        $dt->addColsFields('name');
+        $dt->addColsFields('sort');
+        $dt->addColsFields('remark');
+        $dt->addColsFields('type_id');
+        $dt->addColsFields('create_at');
+        $dt->setToolBar(array('edit'),array('sort' => false));
+        return  view('admin.TypeName/index',$dt->render());
+    }
+
+    //数据源
+    public function dataSource(Request $req){
+        $name = isset($req->name) ? trim($req->name) : null;
+        $limit = isset($req->limit) ? trim($req->limit) : 20;
+        $page = isset($req->page) ? trim($req->page) : null;
+        $where=array();
+        if (!empty($name)) {
+            $where[] = array('name', 'like', '%' . $name . '%');
+        }
+        $data = \App\Models\TypeName::getList($where,$limit);
+        $tn = trans('type_name');
+        foreach ($data['data'] as $k => $v) {
+            // $data['data'][$k]['type_id']=$tn['typed'][$v['type_id']];
+        }
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+
+    }
+   //添加
+   function add(Req $req){
+        if(!$req->isMethod('post')){
+            return view('admin.TypeName/add');
+        }else{
+            $name=$req->name?trim($req->name):'';
+            $sort=$req->sort?intval($req->sort):1;
+            $remark=$req->remark?trim($req->remark):'';
+            $type=$req->type?$req->type:'';
+        
+            if(empty($name)){
+                return responseToJson(-240006);
+            }
+            $data=array(
+                'name'=>$name,
+                'sort'=>$sort,
+                'remark'=>$remark,
+                'type_id'=>implode($type,','),
+                'create_at'=>date('Y-m-d H:i:s'),
+            );
+            $model=\App\Models\TypeName::addGroup($data);
+            return responseToJson($model);
+        }        
+    }
+	//查看
+    function view(Request $req){
+       return $this->edit($req);
+    }
+
+   function delete(Req $req) {
+        $loginname = '';
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\TypeName::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1); //id����
+    }
+    //修改
+    function edit(Req $req){
+        $id=$req->id;
+        if(intval($id)<1){
+            return -1;
+        }
+        if(!$req->isMethod('post')){
+
+            $data=\App\Models\TypeName::where('id',$id)->first();
+            if(!$data){
+                return -2;
+            }
+            $data=$data->toArray();
+            return view('admin.TypeName/add',array('admin'=>$data));
+        }else{
+            $model=\App\Models\TypeName::where('id',$id)->first();
+            $model->name=trim($req->input('name'));
+            $model->sort=trim($req->input('sort'));
+            $model->remark=trim($req->input('remark'));
+            $model->type_id=trim($req->input('type_id'));
+            $model->create_at=date('Y-m-d H:i:s');
+            $model->save();
+            return responseToJson(1);
+        }
+    }
+
+}
+
+

+ 333 - 0
app/Http/Controllers/Admin/UnsetController.php

@@ -0,0 +1,333 @@
+<?php
+/**
+ * 游戏未结算注单
+ */
+
+namespace App\Http\Controllers\Admin;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use Request;
+
+class UnsetController extends Controller {
+	public $point = [
+        '1001'=>'pc投注',
+        '1002'=>'wap投注',
+        '1003'=>'长龙投注'
+    ];
+	/**
+	 * 游戏开关
+	 */
+	function Index() {
+//		$game = Request::has('game') ? Request::get('game') : '';
+//		$data = Request::has('data') ? Request::get('data') : '';
+//		$no = Request::has('no') ? Request::get('no') : '';
+//		$name = Request::has('name') ? Request::get('name') : '';
+
+        $request=array();
+        $request['game'] = Request::has('game') ? Request::get('game') : 'xy28';
+        $request['account_name'] = Request::has('account_name') ? Request::get('account_name') : '';
+        $request['order_id'] = Request::has('order_id') ? Request::get('order_id') : '';
+//        $request['game'] = Request::get('name') ? Request::get('name') : $name;
+        $request['game_no'] = Request::has('game_no') ? Request::get('game_no') : '';
+        $request['bet_small'] = Request::has('bet_small') ? Request::get('bet_small') : '';
+        $request['bet_big'] = Request::has('bet_big') ? Request::get('bet_big') : '';
+        $request['winfail_small'] = Request::has('winfail_small') ? Request::get('winfail_small') : '';
+        $request['winfail_big'] = Request::has('winfail_big') ? Request::get('winfail_big') : '';
+        $request['money_big'] = Request::has('money_big') ? Request::get('money_big') : '';
+        $request['money_small'] = Request::has('money_small') ? Request::get('money_small') : '';
+        $request['star_time'] = Request::has('star_time') ?Request::get('star_time'): trans('status.default_time.seven_day');
+        $request['end_time'] = Request::has('end_time') ? Request::get('end_time') : trans('status.default_time.etime');
+        $request['status'] = Request::has('status') ? Request::get('status') : '';
+        $request['game_point'] = Request::has('game_point') ? Request::get('game_point') : '';
+        $request['gameList']=\App\Models\GameType::getGameType();
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->enableCheckBox();
+		$dt->setDataSource('/admin/Unset/dataSource?game=' .  $request['game'] . '&account_name=' .  $request['account_name'] . '&game_no=' . $request['game_no'] . '&game_status=0');
+		$dt->setLang('bet_order');
+		$dt->addColsFields('name', array('sort' => false, 'width' => 130));
+		$dt->addColsFields('game_no', array('width' => 120, 'templet' => '#game_no'));
+		$dt->addColsFields('money_time', array('sort' => true, 'width' => 235));
+//		$dt->addColsFields('prizes_code', array('width' => 220));
+		$dt->addColsFields('money', array('width' => 120,'templet' => '#moneynew'));
+		$dt->addColsFields('get_money', array('width' => 120, 'templet' => '#money'));
+		$dt->addColsFields('winmoney', array('sort' => false,'width' => 120));
+//		$dt->addColsFields('money_time', array('width' => 160));
+		$dt->addColsFields('account_getw', array('sort' => false, 'templet' => '#account', 'width' => 145));
+		$dt->addColsFields('game_status', array('templet' => '#acc', 'sort' => false, 'width' => 100));
+		$dt->addColsFields('bet_', array('sort' => false));
+		//加在表头
+		//		$table = new \App\Lib\Biz\Game\Table\GameTable;
+		//		$table->gameTable($dt, $game);
+		//$dt->setToolBar(array('view'), array('width' => 100,'align' => 'left')); 
+		$dt->addColsFields('tool',array('width'=>110,'templet'=>'#tool','sort' => false));
+		if (!empty($data)) {
+			return responseToJson($dt->render());
+		}
+		return view('admin.unset/index', $dt->render($request));
+	}
+
+	function dataSource(Req $req) {
+		$game = Request::has('game') ? Request::get('game') : '';
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : '';
+		$field = !empty(Request::get('field')) ? Request::get('field') : 'money_time';
+		$order = !empty(Request::get('order')) ? Request::get('order') : 'desc';
+
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$order_id = Request::has('order_id') ? Request::get('order_id') : '';
+//		$game = Request::has('name') ? Request::get('name') : '';
+		$game_no = Request::has('game_no') ? Request::get('game_no') : '';
+		$bet_small = Request::has('bet_small') ? Request::get('bet_small') : '';
+		$bet_big = Request::has('bet_big') ? Request::get('bet_big') : '';
+		$winfail_small = Request::has('winfail_small') ? Request::get('winfail_small') : '';
+		$winfail_big = Request::has('winfail_big') ? Request::get('winfail_big') : '';
+		$money_big = Request::has('money_big') ? Request::get('money_big') : '';
+		$money_small = Request::has('money_small') ? Request::get('money_small') : '';
+		$game_status = !empty(Request::get('game_status')) ? Request::get('game_status') : 0;
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+		$end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$status = !empty(Request::get('status')) ? Request::get('status') : '';
+		$game_point = Request::get('game_point') ? Request::get('game_point') : '';
+		$where = array();
+		$where[] = array('status', '<>', 4);
+        //排除六合彩
+        $where[]=array('game_name','<>','sixlottery');
+//		if (!empty($name)) {
+//			$game = $name;
+//			$where[] = array('game_name', '=', $name);
+//		}
+        //权限检测
+        if(!checkRriv('/bet/game/'.$game)){
+            return \App\Lib\DataTable\DataTable::init()->toJson(array(), 1, 0, $where);
+        }
+		if (!empty($game)) {
+			$where[] = array('game_name', '=', $game);
+		}
+		if (!empty($bet_small)) {
+			$where[] = array('money', '>=', $bet_small);
+		}
+		if (!empty($bet_big)) {
+			$where[] = array('money', '<=', $bet_big);
+		}
+		if (!empty($winfail_small)) {
+			$where[] = array('get_money', '>=', $winfail_small);
+		}
+		if (!empty($winfail_big)) {
+			$where[] = array('get_money', '<=', $winfail_big);
+		}
+		if (!empty($money_small)) {
+			$where[] = array('prize_money', '>=', $money_small);
+		}
+		if (!empty($money_big)) {
+			$where[] = array('prize_money', '<=', $money_big);
+		}
+		if (is_numeric($game_status)) {
+			$where[] = array('game_status', '=', $game_status);
+		}
+		if (!empty($star_time)) {
+			$star_time = date('Y-m-d H:i:s', strtotime($star_time));
+			$where[] = array('money_time', '>=', $star_time);
+		}
+		if (!empty($end_time)) {
+			$end_time = date('Y-m-d H:i:s', strtotime($end_time));
+			$where[] = array('money_time', '<=', $end_time);
+		}
+		if (!empty($status)) {
+			$where[] = array('status', '=', $status);
+		}
+
+		if (!empty($order_id)) {
+			$where = array(array('order_id', '=', $order_id));
+		}
+
+		if (!empty($game_no)) {
+			$where = array(array('game_no', '=', $game_no));
+		}
+
+		if (!empty($account_name)) {
+			$where[] = array('account_name', 'like', '%' . $account_name . '%');
+		}
+		if(!empty($game_point)){
+            $where[] = array('remark', 'like', '%|'.$game_point.'|%');
+        }
+
+//        $where[] = array('status', '!=', 4);
+		$db = new \App\Models\MoneyBuy();
+		$data = $db->getBuy($where, $list, $page, $field, $order);
+		$gameParse = new \App\Lib\Biz\Game\Parse\GameParse;
+//        $total = array('total_bet_money' => 0, 'win_money' => 0);
+		foreach ($data['data'] as $k => $v) {
+			$data['data'][$k] = $gameParse->packbet($v, $v['game_name']); //开奖号码解析
+			$data['data'][$k]['winmoney'] = $gameParse->winMomey($v['codes']); //可盈金额
+			$data['data'][$k]['money_time'] = $v['order_id'] . '<br>' . $v['money_time'];
+			$data['data'][$k]['game_no_prize'] = $v['game_no'] . '<br/>';
+            if(isset($data['data'][$k]['prizes_code'])){
+                $data['data'][$k]['game_no_prize'].=$data['data'][$k]['prizes_code'];
+            }
+//            $total['total_bet_money'] += $v['money'];
+			//            $total['win_money'] += $v['get_money'];
+		}
+		$data['data'] = arrayToNumber($data['data'], ['money', 'get_money', 'winmoney']);
+		$long = $this->getLongtype();
+		foreach ($data['data'] as $k => $v) {
+			if(!empty($v['remark'])){
+				$remark = explode('|', $v['remark']);
+				if(isset($remark[3]) && isset($long[$remark[3]])){
+                    $data['data'][$k]['remark'] = $long[$remark[3]];
+                }else if(isset($remark[1]) && !empty($remark[1])){
+                    $data['data'][$k]['remark'] = $this->point[$remark[1]];
+                }else{
+                    $data['data'][$k]['remark'] = '';
+                }
+			}else{
+				$data['data'][$k]['remark'] = '';
+			}
+		}
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+//        return responseToJson($data);
+	}
+
+    //获取投注来源
+    private function getLongtype(){
+        return $long = array(
+            '3' => '长龙助手',
+            '4' => '路珠长龙',
+        );
+    }
+
+	function Code(Req $req) {
+		$game = isset($req->game) ? $req->game : '';
+		$no = $req->no;
+		if (empty($game)) {
+			abort(404);
+		}
+		$path = '\App\Models\Game' . ucfirst($game);
+		$db = new $path;
+		$prize_data = $db->getPrizeCodes($no);
+		if ($prize_data < 0) {
+			echo '没有该期开奖数据';
+		}
+		$parse = new \App\Lib\Biz\Game\Parse\GameParse;
+		$data = $parse->prizeParse($prize_data, $game);
+		return view('admin.unset/prizeCode', ['data' => $data]);
+	}
+	//整期作废
+	function Cancel(Req $req) {
+		$type = $req->type;
+		if (!$req->isMethod('post')) {
+			return view('admin.unset/unset_del', ['type' => $type]);
+		} else {
+			$game = $req->game;
+			$info_no = $req->no;
+			$password = $req->password;
+			if (!is_numeric($info_no)) {
+				return responseToJson(-5030013022);
+			}
+			if (empty($password)) {
+				return responseToJson(-7010000622);
+			}
+			if (empty($game)) {
+				return responseToJson(-5040000201);
+			}
+			//验证密码
+			$admin_info = \App\Models\System_user::where('id', session('adminInfo.admin_id'))->first();
+			if (!$admin_info) {
+				return responseToJson(-7010100202);
+			}
+			$admin_info = $admin_info->toArray();
+			if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
+				return responseToJson(-7010001622);
+			}
+			if (($check = $this->checkNo($game, $info_no)) < 0) {
+				return responseToJson($check);
+			}
+			DB::beginTransaction();
+			$path = '\App\Models\Game' . ucfirst($game) . '_Buy';
+			$game_buy_table = new $path;
+			$where[] = array('no', '=', $info_no);
+			$res = $game_buy_table->Cancel($where);
+			if ($res < 0) {
+				DB::rollBack();
+				return responseToJson($res);
+			}
+			$buy_table = new \App\Models\MoneyBuy;
+			$whe[] = array('game_name', '=', $game);
+			$whe[] = array('game_no', '=', $info_no);
+			$res2 = $buy_table->Cancel($whe);
+			if ($res2 < 0) {
+				DB::rollBack();
+				return responseToJson($res2);
+			}
+			DB::commit();
+			return responseToJson(1);
+		}
+	}
+	//检测改期是否开奖
+	private function checkNo($game, $info_no) {
+		$path = '\App\Models\Game' . ucfirst($game);
+		$game_table = new $path;
+		$res = $game_table->where('info_no', $info_no)->where('status', 0)->frist();
+		if (!$res) {
+			return 1;
+		}
+		return -5051263522;
+	}
+	//批量作废
+	function delete(Req $req) {
+		$id = $req->id;
+		if (!$req->isMethod('post')) {
+			return view('admin.game/unset_del', ['id' => $id]);
+		} else {
+			$password = $req->password;
+			if (empty($password)) {
+				return responseToJson(-7010000622);
+			}
+			$ids = explode(',', $id);
+			//验证密码
+			$admin_info = \App\Models\System_user::where('id', session('adminInfo.admin_id'))->first();
+			if (!$admin_info) {
+				return responseToJson(-7010100202);
+			}
+			$admin_info = $admin_info->toArray();
+			if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
+				return responseToJson(-7010001622);
+			}
+			//撤销的订单
+			DB::beginTransaction();
+			$buy_table = new \App\Models\MoneyBuy;
+			$res2 = $buy_table->CancelByids($ids);
+			if ($res2 < 0) {
+				DB::rollBack();
+				return responseToJson($res2);
+			}
+			DB::commit();
+			return responseToJson(1);
+		}
+	}
+	//查看投注详情
+	function view(Req $req) {
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$id = $req->id;
+		$game_no = $req->game_no;
+        $game_name = $req->game_name;
+		if (empty($id)) {
+			abort(404);
+		}
+		$db = new \App\Models\MoneyBuy();
+		$data = $db->getInfoByID($id);
+		$dt->setDataSource('/admin/game/CodeDetails?id=' . $id."&game_no=".$game_no."&game_name=".$game_name);
+		$dt->setlang($data['game_name']);
+		$dt->addColsFields('gameType', array('sort' => false, 'width' => 100));
+		$dt->addColsFields('codes', array('sort' => false));
+		$dt->addColsFields('money', array('sort' => false, 'width' => 100));
+		$dt->addColsFields('odds', array('sort' => false, 'width' => 100));
+		$dt->addColsFields('back', array('sort' => false, 'width' => 100));
+		$dt->addColsFields('maybe', array('sort' => false, 'width' => 100));
+		$dt->addColsFields('get_money', array('sort' => false, 'templet' => '#getMoney', 'width' => 100));
+		$dt->addColsFields('prize_status', array('sort' => false, 'templet' => '#status', 'width' => 110));
+		$dt->addColsFields('remark',array('sort'=>false,'width'=> '200','title'=>'备注'));
+		return view('admin.unset/betdatial', $dt->render());
+
+	}
+}

+ 1312 - 0
app/Http/Controllers/Admin/UserController.php

@@ -0,0 +1,1312 @@
+<?php
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use Request;
+
+/**
+ *
+ */
+class UserController extends Controller
+{
+    /**
+     *
+     * [Colse description]
+     */
+    public function index(Req $req)
+    {
+
+        $request = array();
+        $request['account'] = isset($req->account) ? trim($req->account) : null;
+        $request['agent_name'] = isset($req->agent_name) ? trim($req->agent_name) : null;
+        $request['select_type'] = isset($req->select_type) ? trim($req->select_type) : null;
+        $request['select_value'] = isset($req->select_value) ? trim($req->select_value) : null;
+        $request['grade'] = isset($req->grade) ? trim($req->grade) : null;
+        $request['statuss'] = isset($req->statuss) ? trim($req->statuss) : null;
+        $request['rechargenum_small'] = isset($req->rechargenum_small) ? trim($req->rechargenum_small) : null;
+        $request['rechargenum_big'] = isset($req->rechargenum_big) ? trim($req->rechargenum_big) : null;
+        $request['takenum_small'] = isset($req->takenum_small) ? trim($req->takenum_small) : null;
+        $request['takenum_big'] = isset($req->takenum_big) ? trim($req->takenum_big) : null;
+        $request['takenum_small'] = isset($req->takenum_small) ? trim($req->takenum_small) : null;
+        $request['last_startime'] = isset($req->last_startime) ? trim($req->last_startime) : null;
+        $request['last_endtime'] = isset($req->last_endtime) ? trim($req->last_endtime) : null;
+        $request['regist_startime'] = isset($req->regist_startime) ? trim($req->regist_startime) : null;
+        $request['fanshui'] = isset($req->fanshui) ? trim($req->fanshui) : '';
+        $request['regist_endtime'] = isset($req->regist_endtime) ? trim($req->regist_endtime) : null;
+        $request['status'] = isset($req->status) ? trim($req->status) : null;
+        $request['group'] = isset($req->group) ? intval($req->group) : null;
+        $request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+        //用户组数组
+        $request['select_group']=\App\Models\Account_group::getAllInfo();
+        $Account = new \App\Models\Account();
+        $request['gradelist']=$Account->getUserGrade();
+        $page = Request::has('page') ? Request::get('page') : '';
+        $list = Request::has('limit') ? Request::get('limit') : '';
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/user/user?page=' . $page . '&limit=' . $list);
+        $dt->setLang('user');
+        // $dt->addColsFields('id', array('sort' => false));
+        $dt->addColsFields('account_grade', array('templet' => '#userdetail', 'width'=>120,'sort' => false));
+        $dt->addColsFields('cash', array('templet' => '#moneyrecord','width'=>90));
+        $dt->addColsFields('name', array('templet' => '#selectname', 'width'=>90,'sort' => false));
+        $dt->addColsFields('register_last_time',array('width'=>160,'templet'=>'#register_last', 'sort' => false)); //'templet' => '#selectname',
+        $dt->addColsFields('register_log_ip', array('templet' => '#selectip','width'=>130, 'sort' => false));
+        $dt->addColsFields('register_log_url', array('width'=>150,'sort' => false, 'templet' => '#selecturl','display'=>'inline-block','overflow'=>'hidden'));
+        $dt->addColsFields('phone', array( 'sort' => false, 'width'=>120));
+        // $dt->addColsFields('qq', array('width'=>120, 'sort' => false));
+        // $dt->addColsFields('wechat', array('width'=>120, 'sort' => false));
+        //邀请码显示
+        $dt->addColsFields('open_invitation', array('templet' => '#invitation','width'=>120, 'sort' => false));
+        // $dt->addColsFields('last_time',array('width'=>90)); //'templet' => '#selectphone',
+        //$dt->addColsFields('money_num', array('templet' => '#moneynum', 'sort' => false, 'width' => 110));
+        $dt->addColsFields('statuss', array('templet' => '#openstatus', 'sort' => false,'width'=>100));
+        $dt->addColsFields('isfs', array('sort' => false, 'templet' => '#agent','width'=>100,));
+        $dt->addColsFields('action_user', array('templet' => '#waterTool', 'sort' => false,'width'=>160));
+        $dt->setPriKey('id');
+        return view('admin.user/index', $dt->render($request));
+    }
+
+    //改变反水状态
+    function ajaxfsup(){
+        $data = array();
+        $data['fanshui'] = $_POST['type'];
+        return \App\Models\Account::where('id',$_POST['id'])->update($data);
+    }
+
+    /**
+     * 会员存取反水列表
+     * [detail description]
+     * @return [type] [description]
+     */
+    public function moneyrecord()
+    {
+        $account_name = Request::has('account_name') ? Request::get('account_name') : '';
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/money/moneyList?account_name=' . $account_name . '&sureblur=精确');
+        $dt->setLang('money');
+        $dt->setPriKey('trade_id');
+        $dt->addColsFields('id');
+        $dt->addColsFields('account_name');
+        $dt->addColsFields('trade_id');
+        $dt->addColsFields('trade_type');
+        $dt->addColsFields('money_time');
+        $dt->addColsFields('money');
+        $dt->addColsFields('system_user');
+        $dt->addColsFields('reason');
+        $dt->disableCheckBox();
+        return view('admin.user/viewip', $dt->render());
+    }
+
+    /**
+     * 同一实名用户列表
+     * [detail description]
+     * @return [type] [description]
+     */
+    public function userlist()
+    {
+        $name = Request::has('name') ? Request::get('name') : '';
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/user/user?name=' . $name . '&nameblur=精确');
+        $dt->setLang('state');
+        $dt->setLang('user');
+        $dt->addColsFields('account_grade', array('sort' => false, 'width' => 140));
+        $dt->addColsFields('cash', array('width' => 120));
+        $dt->addColsFields('name_registtime', array('sort' => false, 'width' => 160));
+        $dt->addColsFields('register_log_ip', array('sort' => false, 'width' => 140));
+        $dt->addColsFields('register_log_url', array('sort' => false, 'width' => 133));
+        $dt->addColsFields('phone', array('sort' => false, 'width' => 140));
+        $dt->addColsFields('statuss', array('sort' => false, 'width' => 80));
+        $dt->setPriKey('id');
+        $dt->setToolBar(array('view'));
+        return view('admin.view', $dt->render());
+    }
+
+    /**
+     * 会员列表
+     * 'user description'
+     * @return 'type' 'description'
+     */
+    public function user()
+    {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $list = Request::has('limit') ? Request::get('limit') : 10;
+        $field = Request::has('field') ? Request::get('field') : 'id';
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $agent_name = Request::has('agent_name') ? Request::get('agent_name') : '';
+        $fanshui = Request::has('fanshui') ? Request::get('fanshui') : '';
+
+        $account = Request::has('account') ? Request::get('account') : '';
+        $select_type = Request::has('select_type') ? trim(Request::get('select_type')) : '';
+        $select_value = Request::has('select_value') ? trim(Request::get('select_value')) : '';
+        /*$name = Request::has('name') ? Request::get('name') : '';
+        $register_ip = Request::has('register_ip') ? Request::get('register_ip') : '';
+        $last_ip = Request::has('last_ip') ? Request::get('last_ip') : '';
+        $register_url = Request::has('register_url') ? Request::get('register_url') : '';
+        $last_url = Request::has('last_url') ? Request::get('last_url') : '';
+        $phone = Request::has('phone') ? Request::get('phone') : '';*/
+        $grade = Request::has('grade') ? Request::get('grade') : '';
+        $group = Request::has('group') ? Request::get('group') : '';
+        $regist_startime = Request::get('regist_startime') ? Request::get('regist_startime') . ' 00:00:00' : '';
+        $regist_endtime = Request::get('regist_endtime') ? Request::get('regist_endtime') . ' 23:59:59' : '';
+        $last_startime = Request::get('last_startime') ? Request::get('last_startime') . ' 00:00:00' : '';
+        $last_endtime = Request::get('last_endtime') ? Request::get('last_endtime') . ' 23:59:59' : '';
+        $statuss = Request::has('statuss') ? Request::get('statuss') : '';
+        $cash_small = Request::has('cash_small') ? Request::get('cash_small') : '';
+        $cash_big = Request::has('cash_big') ? Request::get('cash_big') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+        $nameblur = Request::has('nameblur') ? Request::get('nameblur') : '';
+        $rechargenum_small = Request::has('rechargenum_small') ? Request::get('rechargenum_small') : '';
+        $rechargenum_big = Request::has('rechargenum_big') ? Request::get('rechargenum_big') : '';
+        $takenum_small = Request::has('takenum_small') ? Request::get('takenum_small') : '';
+        $takenum_big = Request::has('takenum_big') ? Request::get('takenum_big') : '';
+
+        $where = ' ';
+        $curtime = time() - 300;
+        $rflag = -1;
+        $tflag = -1;
+        if (!empty($account)) {
+            $account = strtolower($account);
+            $where .= ' AND account';
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where .= " LIKE '%" . $account . "%'";
+            } else {
+                $where .= "='" . $account . "'";
+            }
+        }
+
+        if (!empty($select_value)) {
+            if ($select_type == 'name') {
+                $where .= ' AND name';
+                if (empty($nameblur) || $nameblur == '模糊') {
+                    $where .= " LIKE '%" . $select_value . "%'";
+                } else {
+                    $where .= "='" . $select_value . "'";
+                }
+            } elseif (in_array($select_type, array('register_ip','last_ip','open_invitation','invitation'))) {
+                $where .= " AND " . $select_type . "='" . $select_value . "'";
+            } elseif ($select_type == 'register_url') {
+                $where .= " AND register_url LIKE '%" . $select_value . "%'";
+            } elseif ($select_type == 'last_url') {
+                $where .= " AND last_url LIKE '%" . $select_value . "%'";
+            } elseif ($select_type == 'phone') {
+                $where .= " AND b.phone LIKE '%{$select_value}%'";
+            } elseif ($select_type == 'email') {
+                $where .= " AND email LIKE '%" . $select_value . "%'";
+            }elseif (in_array($select_type,['qq','wechat'])) {
+                $where .= " AND b.{$select_type} LIKE '%". trim($select_value) . "%'";
+            }elseif($select_type == 'agent'){
+                $where .= " AND c.invite ='" . $select_value . "'";
+            }
+
+        }
+
+        if (!empty($grade)) {
+            $where .= ' AND b.grade=';
+            $where .= ($grade == 10) ? '0' : $grade;
+        }
+
+        if (!empty($invite)) {
+            $where .= " AND open_invitation='" . $invite . "'";
+        }
+        if(!empty($group)){
+            $where .= " AND group_code like '%,".$group. ",%'";
+        }
+        if (!empty($regist_startime)) {
+            $regist_startime = date('Y-m-d H:i:s', strtotime($regist_startime));
+            $where .= " AND b.register_time>='" . $regist_startime . "'";
+        }
+        if (!empty($regist_endtime)) {
+            $regist_endtime = date('Y-m-d H:i:s', strtotime($regist_endtime));
+            $where .= " AND b.register_time<='" . $regist_endtime . "'";
+        }
+        if (!empty($last_startime)) {
+            $last_startime = date('Y-m-d H:i:s', strtotime($last_startime));
+            //$last_startime = strtotime($last_startime)-300;
+            $where .= " AND last_time>='" . $last_startime . "'";
+            //$where .= " AND ta.effective_time>=" . $last_startime;
+        }
+        if (!empty($last_endtime)) {
+            $last_endtime = date('Y-m-d H:i:s', strtotime($last_endtime));
+            //$last_endtime = strtotime($last_endtime)-300;
+            $where .= " AND last_time<='" . $last_endtime . "'";
+            //$where .= " AND ta.effective_time<=" . $last_endtime;
+        }
+        if (!empty($statuss)) {
+            $statuss = ($statuss == 2) ? '0' : $statuss;
+            $where .= " AND statuss=" . $statuss;
+        }
+
+        if (!empty($status)) {
+            $status = ($status == 5) ? '-1' : $status;
+            $where .= " AND status=" . $status;
+            $where .= " or status=" . '2';
+        }
+
+        if(!empty($fanshui)){
+            $where .= " AND fanshui=" . $fanshui;
+        }
+        if (!empty($cash_small)) {
+            $where .= " AND cash>=" . $cash_small;
+        }
+        if (!empty($cash_big)) {
+            $where .= " AND cash<=" . $cash_big;
+        }
+        if (!empty($rechargenum_small)) {
+            $rflag = 1;
+            $where .= ' AND (mc.recharge_num >=' . $rechargenum_small;
+        }
+        if (!empty($rechargenum_big)) {
+            $rflag = 1;
+            $where .= empty($rechargenum_small) ? 'AND (' : 'AND ';
+            $where .= ' mc.recharge_num <=' . $rechargenum_big;
+        }
+        if ((empty($rechargenum_small) || $rechargenum_small <= 0) && (empty($rechargenum_big) || $rechargenum_big >= 0)) {
+            if (!(empty($rechargenum_small) && empty($rechargenum_big))) {
+                $where .= " OR mc.recharge_num ISNULL)";
+            }
+        } else {
+            $where .= ')';
+        }
+
+        if (!empty($takenum_small)) {
+            $tflag = 1;
+            $where .= ' AND (tc.take_num >=' . $takenum_small;
+        }
+        if (!empty($takenum_big)) {
+            $tflag = 1;
+            $where .= empty($takenum_small) ? 'AND (' : 'AND ';
+            $where .= ' tc.take_num <=' . $takenum_big;
+        }
+        if ((empty($takenum_small) || $takenum_small <= 0) && (empty($takenum_big) || $takenum_big >= 0)) {
+            if (!(empty($takenum_small) && empty($takenum_big))) {
+                $where .= " OR tc.take_num ISNULL)";
+            }
+        } else {
+            $where .= ')';
+        }
+// var_dump($where);die;
+        $db = new \App\Models\Account;
+        $data = $db->account($list, $page, $where, $field, $order, $rflag, $tflag);
+        $gradelist = $db->getUserGrade();
+        $data['data'] = arrayToNumber($data['data'], ['cash']);
+        $has_root = 0;
+        $has_roots = 0;
+        $show_name=0;
+        if (\App\Models\Role::hasRoot('/enable/show/mobile') < 0) {
+            $has_root = 1;
+            // $data['data'][$k]['phone'] = phoneHide($v['phone']);
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/email') < 0) {
+            $has_roots = 1;
+            // $data['data'][$k]['email'] = emailHide($v['email']);
+        }
+        if (\App\Models\Role::hasRoot('/enable/show/name') < 0) {
+            $show_name = 1;
+            // $data['data'][$k]['email'] = emailHide($v['email']);
+        };
+        $letime = time()-60*30;
+        // foreach ($data['data'] as $k => $v) {
+        //     $findId[] = $v['agent_identity'];
+        //     $data['data'][$k]['online'] = ($v['statuss'] == 0) ? '离线' : '在线';
+        //     if($v['statuss']){
+        //         $linetime = \App\Model\Account_Token::where('effective_time','>=',$letime)->where('account_identity',$v['identity'])->first();
+        //         if($linetime){}else{
+        //             \App\Model\Account_detailed::where('account_identity',$v['identity'])->update(['statuss'=>'0']);
+        //             if(!empty($statuss) && $statuss==1){
+        //                 unset($data['data'][$k]);
+        //                 continue;
+        //             }
+        //             $data['data'][$k]['online'] = '离线';
+        //             $data['data'][$k]['statuss'] = '0';
+        //         }
+        //     }
+        //     $data['data'][$k]['invite'] = ($v['invite']=='null' || empty($v['invite']))?'':$v['invite'];
+        //     $data['data'][$k]['agent_id'] = '无上级';
+        //     $data['data'][$k]['register_ip'] = str_replace(',','/',$v['register_ip']);
+        //     $data['data'][$k]['last_ip'] = str_replace(',','/',$v['last_ip']);
+        //     $has_root == 1 ? $data['data'][$k]['phone'] = phoneHide($v['phone']) : null;
+        //     $has_roots == 1 ? $data['data'][$k]['email'] = emailHide($v['email']) : null;
+
+        //     $show_name == 1 ? $data['data'][$k]['account'] = userHide($v['account']) : null;
+        //     $data['data'][$k]['grade_name'] = $gradelist[$v['grade']]??'';
+        //     // if($v['grade'] >=0){
+        //     //     $data['data'][$k]['grade_name'] = $gradelist[$v['grade']]??'';
+        //     // }elseif($v['grade'] ==-1){
+        //     //     $data['data'][$k]['grade_name'] = '申请vip审核中';
+        //     // }elseif($v['grade'] ==-2){
+        //     //     $data['data'][$k]['grade_name'] = 'vip0';
+        //     // }
+
+        // }
+
+        // if (!empty($findId)){
+        //     $db = new \App\Model\Agent_detailed;
+        //     $asd = $db->findId($findId);
+
+        //     foreach ($data['data'] as $k => $v) {
+        //         foreach ($asd as $val) {
+        //             if ($v['agent_identity'] == $val['agent_identity']) {
+        //                 $data['data'][$k]['agent_id'] = $val['id'];
+        //             }
+        //         }
+        //     }
+        // }
+
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
+    }
+
+    //修改用户密码
+    public function SetPwdview(Req $req)
+    {
+        return $this->EditPwd($req);
+    }
+
+    //修改会员密码
+    public function EditPwd(Req $req)
+    {
+        $id = $req->id;
+        $parentid = isset($req->parentid)?$req->parentid:'';
+        if (empty($id)) {
+            abort(404);
+        }
+        $pwdtype = empty($req->pwdtype) ? '' : $req->pwdtype;
+        $u_db = new \App\Models\Account();
+        $where = array();
+        $where[] = array('id', '=', $id);
+        $data = $u_db::where($where)->first();
+        if (!$data) {
+            abort(404);
+        }
+        $data = $data->toArray();
+        if(!(empty($parentid) || is_null($parentid) || $parentid == 'null')){
+            $udetail = \App\Models\Nagent_detailed::select('agent_identity','invite')->where('agent_identity',$parentid)->first();
+            if(!empty($udetail) && count($udetail->toArray())>0 && !empty($udetail->invite)){
+                $data['invite']=$udetail->invite;
+            }
+        }
+
+        $uname = $data['account'];
+        unset($data['password']);
+        if (!$req->isMethod('post')) {
+            $aid = session('adminInfo.admin_id');
+            $arootid = \App\Models\System_user::select('root_id')->where('id',$aid)->first();
+            $data['arootid'] = $arootid->root_id;
+            return view('admin.user/editpwd', ['data' => $data]);
+        } else {
+            //修改代理父级
+            if(!empty($pwdtype) && $pwdtype==2){
+                DB::beginTransaction();
+                $invite = $req->invite;
+                //$agent_id = $req->agent_id;
+                //修改代理父级
+                $res = $this->updateAgentParent($data,$invite);
+                if($res<0){
+                    DB::rollBack();
+                }else{
+                    DB::commit();
+                }
+                return responseToJson($res);
+            }
+
+            $pwd = $req->password;
+            $repwd = $req->repassword;
+            $updatetype = '';
+            if (!empty($pwd)) {
+                if ($pwd != $repwd) {
+                    return responseToJson(-4010000502); //两次密码不一致
+                }
+                $updatevalue = $pwd;
+                $pwddata = GenPassword($pwd);
+                $remark = empty($req->remark) ? '' : $req->remark;
+                $status = empty($req->status) ? '' : $req->status;
+                $editdata = array();
+                $editdata['account_password'] = $pwddata['password'];
+                $editdata['encryption'] = $pwddata['encryption'];
+            }
+            if (!empty($pwdtype) && $pwdtype == 1) {
+                $updatetype = '支付密码';
+                $paydata = array(
+                    'pay_password' => $editdata['account_password'],
+                    'encryption' => $editdata['encryption'],
+                );
+                $db = new \App\Models\Pay_password;
+                $res = $db->updateInfo($paydata, $data['identity']);
+            } else {
+                $updatetype = '密码';
+                $db = new \App\Models\Account_password;
+                if (isset($editdata)) {
+                    $res = $db->updateInfo($editdata, $data['identity']);
+                }
+            }
+            $identity=$data['identity'];
+            $status_type = $req->status_type;
+            $data = array(
+                'remark' => $req->remark,
+                'status' => $req->status,
+            );
+            if (!empty($status_type) && $status_type == 1) {
+                $updatetype = '备注信息、状态';
+                $sch = ($data['status']==1)?'启用':'禁用';
+                $updatevalue = $data['remark'].'、'.$sch;
+                $db = new \App\Models\Account;
+                $res = $db->updateInfo($data, $id);
+            }
+            if($res>0){
+                \App\Models\Account_detailed::where('account_identity',$identity)->update(['token'=>createToken()]);
+            }
+            $log = array(
+                session('adminInfo.admin_name'),
+                $uname,
+                $updatetype,
+                $updatevalue,
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'update_userinfo', $log);
+            return responseToJson($res);
+        }
+    }
+
+    //修改代理父级
+    private function updateAgentParent($data,$invite){
+        if(empty($invite))return -4010010102;
+        //验证代理是否存在
+        $check_agent = \App\Models\Nagent_detailed::select('agent_identity as identity','agent_user','parent_path')->where('invite',$invite)->first();
+        if(!$check_agent || count($check_agent->toArray())<1 || empty($check_agent->identity))return -4010010202;
+        $agent_name = $check_agent->agent_user;
+        if($agent_name == $data['account'])return -4010010802;
+
+        //验证会员下级关系中是否存在该父级
+        $conchild = \App\Models\Nagent_detailed::select('id')->where('parent_path','like',$data['identity'])->where('agent_identity',$check_agent->identity)->first();
+        if($conchild && count($conchild->toArray())>0)return -4010010302;
+
+        //验证相同代理关系是否已存在
+        $check_conhas = \App\Models\NagentChild::select('id')->where('agent_name',$agent_name)->where('account_identity',$data['identity'])->first();
+        if($check_conhas && count($check_conhas->toArray())>0 && !empty($check_conhas->id))return -4010010302;
+
+        $pdata = array(
+            'parent_id' => $check_agent->identity,
+            'parent_path' => $check_agent->parent_path.','.$check_agent->identity,
+        );
+        $res = \App\Models\Account_detailed::where('account_identity',$data['identity'])->update($pdata);
+        if($res<1)return -4010010602;
+        $res = \App\Models\Nagent_detailed::where('agent_identity',$data['identity'])->update($pdata);
+        if($res<1)return -4010010902;
+        $updatesub = $this->updateChildinfo($pdata['parent_path'],$data['identity']);
+        if($updatesub<0)return $updatesub;
+        //关联信息处理
+        $coninfo = array(
+            'agent_identity' => $check_agent->identity,
+            'account_identity' => $data['identity'],
+            'agent_name' => $agent_name,
+            'account_name' => $data['account'],
+        );
+
+        //获取用户原父级信息
+        $ypinfo = \App\Models\NagentChild::select('agent_name','agent_identity')->where('account_identity',$data['identity'])->first();
+        if($ypinfo && count($ypinfo->toArray())>0 && !empty($ypinfo->agent_name)){
+            $res = \App\Models\NagentChild::where('account_identity',$data['identity'])->update($coninfo);
+            if($res<0)return -4010011002;
+            $ypinvite = \App\Models\Nagent_detailed::select('invite')->where('agent_identity',$ypinfo->agent_identity)->first();
+            if(!$ypinvite || !isset($ypinvite->invite))return -4010011102;
+            $log = array(
+                session('adminInfo.admin_name'),
+                $data['account'],
+                $ypinfo->agent_name,
+                $ypinvite->invite,
+                $agent_name,
+                $invite,
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'update_parentagent', $log);
+        }else{
+            $res = \App\Models\NagentChild::where('account_identity',$data['identity'])->insert($coninfo);
+            if($res<0)return -4010010702;
+            $log = array(
+                session('adminInfo.admin_name'),
+                $data['account'],
+                $agent_name,
+                $invite,
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'add_parentagent', $log);
+        }
+
+        return 1;
+    }
+
+    //更新代理下级信息
+    private function updateChildinfo($ppath,$pid){
+        $childinfo = \App\Models\Nagent_detailed::select('agent_identity','parent_path')->where('parent_path','like','%' . $pid . '%')->get();
+        if(!$childinfo || count($childinfo->toArray())<1)return 1;
+        $childinfo = $childinfo->toArray();
+        foreach ($childinfo as $k => $v) {
+            $subpath = strstr($v['parent_path'],$pid);
+            $pdata = array('parent_path'=>$ppath.','.$subpath);
+            $res = \App\Models\Account_detailed::where('account_identity',$v['agent_identity'])->update($pdata);
+            if($res<1)return -4010010602;
+            $res = \App\Models\Nagent_detailed::where('agent_identity',$v['agent_identity'])->update($pdata);
+            if($res<1)return -4010010602;
+        }
+    }
+
+    //修改代理父级invite
+    /*private function updateAgentParent($data,$agent_id){
+        if(empty($agent_id))return -4010010102;
+        //验证代理是否存在
+        $check_agent = \App\Model\Agent_detailed::select('agent_identity as identity','agent_user')->where('id',$agent_id)->first();
+        if(!$check_agent || count($check_agent->toArray())<1 || empty($check_agent->identity))return -4010010202;
+        $agent_name = $check_agent->agent_user;
+        if($agent_name == $data['account'])return -4010010802;
+        //验证相同代理关系是否已存在
+        $check_conhas = \App\Model\AgentChild::select('id')->where('agent_name',$agent_name)->where('account_identity',$data['identity'])->first();
+        if($check_conhas && count($check_conhas->toArray())>0 && !empty($check_conhas->id))return -4010010302;
+
+        //关联信息处理
+        $coninfo = array(
+            'agent_identity' => $check_agent->identity,
+            'account_identity' => $data['identity'],
+            'agent_name' => $agent_name,
+            'account_name' => $data['account'],
+        );
+
+        //获取用户原父级信息
+        $ypinfo = \App\Model\AgentChild::select('agent_name','agent_identity')->where('account_identity',$data['identity'])->first();
+        if($ypinfo && count($ypinfo->toArray())>0 && !empty($ypinfo->agent_name)){
+            $res = \App\Model\AgentChild::where('account_identity',$data['identity'])->update($coninfo);
+            if($res<0)return -4010010602;
+            $log = array(
+                session('adminInfo.admin_name'),
+                $data['account'],
+                $ypinfo->agent_name,
+                $ypinfo->agent_identity,
+                $agent_name,
+                $check_agent->identity,
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'update_parentagent', $log);
+        }else{
+            $res = \App\Model\AgentChild::where('account_identity',$data['identity'])->insert($coninfo);
+            if($res<0)return -4010010702;
+            $log = array(
+                session('adminInfo.admin_name'),
+                $data['account'],
+                $agent_name,
+                $check_agent->identity,
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'add_parentagent', $log);
+        }
+
+        return 1;
+    }*/
+
+    public function View(Req $req)
+    {
+        return $this->Edit($req);
+    }
+
+    //修改会员信息
+    public function Edit(Req $req)
+    {
+        $id = $req->id;
+        $identity = !empty($req->identity) ? $req->identity : '';
+        //echo 'id:'.$id.';account:'.$account;exit;
+        if (empty($id) && empty($identity)) {
+            abort(404);
+        }
+        $u_db = new \App\Models\Account();
+        $u_details = new \App\Models\Account_detailed();
+        $bank = new \App\Models\Account_bank();
+        $groupinfo = \App\Models\Account_group::getList();
+        $groupdata = $groupinfo['data'];
+        $gradelist = $u_db->getUserGrade();
+        if (!$req->isMethod('post')) {
+            $where = array();
+            if (!empty($id)) {
+                $where[] = array('id', '=', $id);
+            } elseif (!empty($identity)) {
+                $where[] = array('identity', '=', $identity);
+            }
+            $data = $u_db::where($where)->first();
+            if (!$data) {
+                abort(404);
+            }
+            $data = $data->toArray();
+            $data_details = array();
+            $data_details = $u_details->getInfoBy($data['identity']);
+            if ($data_details < 0) {
+                abort(404);
+            }
+            $data_details['id'] = $data['id'];
+            $data_details['user_type'] = $data['user_type'];
+            $data_details['account'] = $data['account'];
+            $data_details['remark'] = $data['remark'];
+            $data_details['group'] = $groupdata;
+            $data_details['gradelist'] = $gradelist;
+            $bank_data = $bank->getInfoByUid($data['identity']);
+            $data_details['bank_name'] = isset($bank_data['bank_name']) ? $bank_data['bank_name'] : '';
+            $data_details['bank_address'] = isset($bank_data['bank_address']) ? $bank_data['bank_address'] : '';
+            $data_details['bank_number'] = isset($bank_data['bank_number']) ? $bank_data['bank_number'] : '';
+            if (\App\Models\Role::hasRoot('/enable/show/bankcard') < 0) {
+                $data_details['bank_number'] = bankHide($data_details['bank_number']);
+            }
+            if (\App\Models\Role::hasRoot('/enable/show/mobile') < 0) {
+                $data_details['phone'] = phoneHide($data_details['phone']);
+            }
+            if (\App\Models\Role::hasRoot('/enable/show/name') < 0) {
+                $data_details['account'] = userHide($data_details['account']);
+            }
+            if(\App\Models\Role::hasRoot('/enable/show/qq') < 0){
+                $data_details['qq'] = phoneHide($data_details['qq']);
+            }
+            $data_details['register_time'] = isset($data_details['register_time']) ? $data_details['register_time'] : '';
+            $data_details['register_ip'] = isset($data_details['register_ip']) ? $data_details['register_ip'] : '';
+            $data_details['last_ip'] = isset($data_details['last_ip']) ? $data_details['last_ip'] : '';
+            $data_details['cash'] = isset($data_details['cash']) ? $data_details['cash'] : '';
+            $data_details['og_type'] = isset($data_details['og_type']) ? $data_details['og_type'] : '';
+            if (\App\Models\Role::hasRoot('/enable/show/email') < 0) {
+                $data_details['email'] = emailHide($data_details['email']);
+            }
+
+            $data_details['name'] = isset($data_details['name']) ? $data_details['name'] : '';
+            unset($data_details['password']);
+            //获取用户存取款笔数
+            $moneydetail = new \App\Models\Money_details();
+            $Withdraw_rule = new \App\Models\Withdraw_rule();
+            $mdata = $moneydetail->getUserMoneynum($data['identity']);
+            $data_details['recharge_num'] = $mdata['recharge_num'];
+            $data_details['take_num'] = $mdata['take_num'];
+            $withdrawRule = $Withdraw_rule::check($data_details['account_identity']);
+            if(!empty($withdrawRule)){
+                $withdrawRule = $withdrawRule->toArray();
+                $data_details['bettingMoney'] = $withdrawRule['bettingMoney'];
+                $data_details['needBettingMoney'] = $withdrawRule['needBettingMoney'];
+            }else{
+                $data_details['bettingMoney'] = $data_details['cash'];
+                $data_details['needBettingMoney'] = $data_details['cash'];
+            }
+            return view('admin.user/view', ['data' => $data_details]);
+            //return view('admin.menu/userAdd', ['data' => $data_details]);
+        } else {
+            if (empty($id)) {
+                return responseToJson(-4010100102);
+            }
+            $data = $u_db::where('id', $id)->first();
+            if (!$data) {
+                return responseToJson(-4010100202);
+            }
+            $data = $data->toArray();
+            $uname = $data['account'];
+            $groups=$req->groups?$req->groups:'';
+            //选择的组
+            $group_codes=array_keys($groups);
+            //获取组名的
+            $groups_names='| ';
+            foreach ($groupdata as $k=>$v){
+                if(in_array($v['group_code'],$group_codes))
+                    $groups_names.=$v['group_name'].'| ';
+            }
+            $updatedata = array(
+                'name' => $req->input('name'),
+                'grade' => $req->input('grade'),
+                'email'=>$req->input('email'),
+                'phone'=>$req->input('phone'),
+                'qq'=>$req->input('qq'),
+                'wechat'=>$req->input('wechat'),
+                'og_type'=>$req->input('og_type'),
+                'group_code' => '0,'.implode(',',$group_codes).',',
+                'group_name' => $groups_names,
+            );
+
+            if (strpos($updatedata['phone'], '*')!==false) {
+                unset($updatedata['phone']);
+            }
+            if (strpos($updatedata['email'], '*')!==false) {
+                unset($updatedata['email']);
+            }
+            if (strpos($updatedata['qq'], '*')!==false) {
+                unset($updatedata['qq']);
+            }
+            $UserInfo  = array(
+                'user_type' => is_numeric($req->user_type)?trim($req->user_type):1,
+                'remark' => $req->remark,
+             );
+            $log = array(
+                session('adminInfo.admin_name'),
+                $uname,
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'update_userinfos', $log);
+            $res = $u_details->updateInfo($updatedata, $data['identity']);
+            if ($res < 0) {
+                return responseToJson($res);
+            }
+            $res=$u_db->upUserInfo($UserInfo,$data['identity']);
+            if ($res < 0) {
+                return responseToJson($res);
+            }
+            $bankObj = new \App\Models\Account_bank();
+            $checkbank = $bankObj->checkHasBank($data['identity']);
+            if ($checkbank < 0) {
+                return responseToJson($res);
+            }
+            $res = $bankObj->updateOne(array('account_name' => $updatedata['name']), $data['identity']);
+
+            return responseToJson($res);
+        }
+    }
+
+    /**
+     * 批量删除
+     * [delete description]
+     * @return [type] [description]
+     */
+    public function delete(Req $req)
+    {
+        $id = $req->input('id');
+        if (empty($id)) {
+            return responseToJson(-2001); //id������
+        }
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return responseToJson(-2002); //id����
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $rows = \App\Models\Account::whereIn('id', $ids)->delete();
+        if (!$rows) {
+            return responseToJson(-2003); //id����
+        }
+        return responseToJson(1, trans('menu.delete_success')); //id����
+    }
+
+    //启用/禁用会员信息
+    public function changeStatus(Req $req)
+    {
+        $id = Request::has('id') ? Request::get('id') : '';
+        $account = Request::has('account') ? Request::get('account') : '';
+        if (empty($id)) {
+            return responseToJson(-4010100102); //未提交用户ID
+        }
+        $u_db = new \App\Models\Account();
+        $where = array();
+        $where[] = array('id', '=', $id);
+        $data = $u_db::where($where)->first();
+        if (!$data) {
+            return responseToJson(-4010100202); //用户不存在
+        }
+        $data = $data->toArray();
+        unset($data['password']);
+        if (!$req->isMethod('post')) {
+            return view('admin.user/changeStatus', ['data' => $data]);
+        } else {
+            $status = $req->status;
+            $password = $req->password;
+
+            if (!empty($password)) {
+                $admin_id = session('adminInfo.admin_id');
+                $adminObj = new \App\Models\System_user();
+                $admininfo = $adminObj->getAdminInfo($admin_id);
+                if ($admininfo < 0 || empty($admininfo['password_2'])) {
+                    return responseToJson(-7010200102); //未获取到二次密码
+                }
+                $checkpwd = VerPassword($password, $admininfo['encryption_2'], $admininfo['password_2']);
+                if (!$checkpwd) {
+                    return responseToJson(-7010200202); //二次密码错误
+                }
+            } else {
+                return responseToJson(-7010200302); //二次密码不能为空
+            }
+
+            $status = is_numeric($req->status) ? intval($req->status) : '';
+            if (empty($id) || !is_numeric($status)) {
+                return responseToJson(-2020100102);
+            }
+            $u_db = new \App\Models\Account();
+
+            $data = array(
+                'status' => $status,
+            );
+            $res = $u_db->updateInfo($data, $id);
+            $log = array(
+                session('adminInfo.admin_name'),
+                $account,
+            );
+            OperationLog(session('adminInfo.admin_id'), 'changeStatus', $log);
+            return responseToJson($res);
+        }
+    }
+
+    //用户踢线
+    public function changeStatuss(Req $req)
+    {
+        $id = $req->id;
+        if (empty($id)) {
+            return responseToJson(-4010100102); //未提交用户ID
+        }
+        $u_db = new \App\Models\Account();
+        $u_details = new \App\Models\Account_detailed();
+        $where = array();
+        $where[] = array('id', '=', $id);
+        $data = $u_db::where($where)->first();
+        if (!$data) {
+            return responseToJson(-4010100202); //用户不存在
+        }
+        $data_details = $u_details::where($where)->first();
+        $data = $data->toArray();
+        $data_details = $u_details->getInfoBy($data['identity']);
+        $data_details['account'] = $data['account'];
+        $uname = $data['account'];
+        unset($data['password']);
+        if (!$req->isMethod('post')) {
+            return view('admin.user/changeStatuss', ['data' => $data_details]);
+        } else {
+            $password = $req->password;
+            $ids = $req->ids;
+
+            if (!empty($password)) {
+                $admin_id = session('adminInfo.admin_id');
+                $adminObj = new \App\Models\System_user();
+                $admininfo = $adminObj->getAdminInfo($admin_id);
+                if ($admininfo < 0 || empty($admininfo['password_2'])) {
+                    return responseToJson(-7010200102); //未获取到二次密码
+                }
+                $checkpwd = VerPassword($password, $admininfo['encryption_2'], $admininfo['password_2']);
+                if (!$checkpwd) {
+                    return responseToJson(-7010200202); //二次密码错误
+                }
+            } else {
+                return responseToJson(-7010200302); //二次密码不能为空
+            }
+
+            $status = is_numeric($req->statuss) ? intval($req->statuss) : '';
+            if (empty($ids) || !is_numeric($status)) {
+                return responseToJson(-2020100102);
+            }
+            $u_db = new \App\Models\Account_detailed();
+            $u_dbs = new \App\Models\Account_Token();
+            $datas = $u_dbs->getTime($data['identity']);
+            if ($datas != 1) {
+                return responseToJson(-27349826); //未获取到二次密码
+            }
+            $data = array(
+                'statuss' => $status,
+                'token' => '',
+            );
+            $res = $u_db->updateInfos($data, $ids);
+            $log = array(
+                session('adminInfo.admin_name'),
+                $uname,
+            );
+            $res = OperationLog(session('adminInfo.admin_id'), 'letuser_outline', $log);
+            return responseToJson($res);
+        }
+
+    }
+    /**
+     * 用户添加
+     * [add description]
+     */
+    public function userAdd()
+    {
+        return view('admin.menu/userAdd');
+    }
+
+    /**
+     * 会员列表
+     * [getCloseTable description]
+     * @return [type] [description]
+     */
+    public function getUserTable()
+    {
+        $table = new \App\Lib\Biz\Game\Table\UserTable();
+        $data = $table->getUserTh();
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+    }
+
+    /**
+     * 资金流水
+     * 'money description'
+     * @return 'type' 'description'
+     */
+    public function money()
+    {
+        $db = new \App\Models\Money_details;
+        $page = Request::has('statpageus') ? Request::get('page') : '20';
+        $identity = Request::has('account_identity') ? Request::get('account_identity') : '45b7d4e9-2bb9-16b3-9a50-6fd6f62235f8';
+        if (empty($identity)) {
+            return -2020162003; //用户不存在
+        }
+        $status = Request::has('status') ? Request::get('status') : '1';
+        if ($status == 1) {
+            $data = $db->money($page, $identity, $status);
+            return responseToJson($data);
+        } else {
+            return -2020162103; //账户异常
+        }
+    }
+
+    /**
+     * 会员余额统计
+     * 'money description'
+     * @return 'type' 'description'
+     */
+    public function userCashCount()
+    {
+        $where = Request::has('where') ? Request::get('where') : '';
+        $db = new \App\Models\Account;
+
+        $data = $db->userCount($where);
+        return responseToJson($data);
+    }
+
+    public function test()
+    {
+        $detail = new \App\Models\Account_detailed;
+        $userdata = $detail->getUinfo();
+        if ($userdata < 0) {
+            return responseToJson($userdata);
+        }
+        //print_r($userdata);
+        $account_identity = '';
+        foreach ($userdata as $k => $v) {
+            $account_identity .= ($k == 0) ? "('" . $v['account_identity'] . "'" : ",'" . $v['account_identity'] . "'";
+        }
+        $account_identity .= empty($account_identity) ? '' : ')';
+        //echo $account_identity.'<hr>';
+        if (!empty($account_identity)) {
+            $url = new \App\Models\Logfile;
+            $urldata = $url->getUrl($account_identity);
+            if (empty($urldata) || $urldata < 0) {
+                foreach ($userdata as $k => $v) {
+                    $res = $detail->updateInfo(array('last_url' => 'xin83888.com', 'register_url' => 'xin83888.com'), $v['account_identity']);
+                    echo 1;
+                }
+            }
+
+            if (!($urldata < 0)) {
+                foreach ($urldata as $sk => $sv) {
+                    $res = $detail->updateInfo(array('last_url' => $sv['last_url'], 'register_url' => $sv['register_url'], 'last_time' => $sv['maxtime'], 'last_ip' => $sv['ip']), $sv['account_identity']);
+                    echo $sv['account'] . '<br>';
+                }
+            }
+            if ($res > 0) {
+                return responseToJson(1);
+            }
+        } else {
+            return responseToJson(2);
+        }
+    }
+
+   //  public function checkPwd(Req $req){
+   //  	//密码验证
+
+   //      // return responseToJson('/admin/User/export');
+   // //  	if (!$req->isMethod('post')) {
+   // //  		return view('admin.user/export');
+   // //  	}else {
+   // //  		$password = $req->password;
+   // //  		$admin_info = \App\Model\System_user::where('id', session('adminInfo.admin_id'))->first();
+			// // if (!$admin_info) {
+			// // 	return responseToJson(-7010100202);
+			// // }
+			// // $admin_info = $admin_info->toArray();
+			// // if (!VerPassword($password, $admin_info['encryption_2'], $admin_info['password_2'])) {
+			// // 	return responseToJson(-7010001622);
+			// // }
+   //  		return redirect('/admin/User/export');
+   // //  	}
+
+   //  }
+    function checkPwd(){
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $list = Request::has('limit') ? Request::get('limit') : '1000';
+        $field = Request::has('field') ? Request::get('field') : 'id';
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $agent_name = Request::has('agent_name') ? Request::get('agent_name') : '';
+
+        $account = Request::has('account') ? Request::get('account') : '';
+        $select_type = Request::has('select_type') ? Request::get('select_type') : '';
+        $select_value = Request::has('select_value') ? Request::get('select_value') : '';
+        $grade = Request::has('grade') ? Request::get('grade') : '';
+        $group = Request::has('group') ? Request::get('group') : '';
+        $regist_startime = Request::get('regist_startime') ? Request::get('regist_startime') . ' 00:00:00' : '';
+        $regist_endtime = Request::get('regist_endtime') ? Request::get('regist_endtime') . ' 23:59:59' : '';
+        $last_startime = Request::get('last_startime') ? Request::get('last_startime') . ' 00:00:00' : '';
+        $last_endtime = Request::get('last_endtime') ? Request::get('last_endtime') . ' 23:59:59' : '';
+        $statuss = Request::has('statuss') ? Request::get('statuss') : '';
+        $cash_small = Request::has('cash_small') ? Request::get('cash_small') : '';
+        $cash_big = Request::has('cash_big') ? Request::get('cash_big') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'on';
+        $nameblur = Request::has('nameblur') ? Request::get('nameblur') : '';
+        $rechargenum_small = Request::has('rechargenum_small') ? Request::get('rechargenum_small') : '';
+        $rechargenum_big = Request::has('rechargenum_big') ? Request::get('rechargenum_big') : '';
+        $takenum_small = Request::has('takenum_small') ? Request::get('takenum_small') : '';
+        $takenum_big = Request::has('takenum_big') ? Request::get('takenum_big') : '';
+
+        $where = '/admin/User/export?';
+        if (!empty($account)) {
+            $account = strtolower($account);
+            $where .= '&account='.$account;
+        }
+        if (!empty($select_type)) {
+             $where .= '&select_type='.$select_type;
+        }
+        if (!empty($select_value)) {
+             $where .= '&select_value='.$select_value;
+        }
+        if (!empty($group)) {
+             $where .= '&group='.$group;
+        }
+        if (!empty($grade)) {
+            $where .= '&grade='.$grade;
+        }
+        if (!empty($statuss)) {
+            $where .= "&statuss=" . $statuss;
+        }
+        if (!empty($regist_startime)) {
+            $where .= '&regist_startime='. $regist_startime;
+        }
+        if (!empty($regist_endtime)) {
+            $where .= '&regist_endtime=' . $regist_endtime;
+        }
+        if (!empty($last_startime)) {
+            $where .= '&last_startime=' . $last_startime;
+        }
+        if (!empty($last_endtime)) {
+            $where .= '&last_endtime=' . $last_endtime;
+        }
+        if (!empty($takenum_small)) {
+            $where .= "&takenum_small=" . $takenum_small;
+        }
+        if (!empty($takenum_big)) {
+            $where .= "&takenum_big=" . $takenum_big;
+        }
+        if (!empty($rechargenum_small)) {
+            $where .= '&rechargenum_small=' . $rechargenum_small;
+        }
+        if (!empty($rechargenum_big)) {
+            $where .= '&rechargenum_big=' . $rechargenum_big;
+        }
+        if (!empty($sureblur)) {
+            $where .= '&sureblurs=' . $sureblur;
+        }
+        return responseToJson($where);
+
+    }
+
+    //Excel文件导出功能 By Laravel学院
+    public function export() {
+        $page = Request::has('page') ? Request::get('page') : 1;
+        $list = Request::has('limit') ? Request::get('') : '';
+        $field = Request::has('field') ? Request::get('field') : 'id';
+        $order = Request::has('order') ? Request::get('order') : 'desc';
+        $status = Request::has('status') ? Request::get('status') : '';
+        $agent_name = Request::has('agent_name') ? Request::get('agent_name') : '';
+
+        $account = Request::has('account') ? Request::get('account') : '';
+        $select_type = Request::has('select_type') ? Request::get('select_type') : '';
+        $select_value = Request::has('select_value') ? Request::get('select_value') : '';
+        $grade = Request::has('grade') ? Request::get('grade') : '';
+        $group = Request::has('group') ? Request::get('group') : '';
+        $regist_startime = Request::get('regist_startime') ? Request::get('regist_startime') : '';
+        $regist_endtime = Request::get('regist_endtime') ? Request::get('regist_endtime')  : '';
+        $last_startime = Request::get('last_startime') ? Request::get('last_startime')  : '';
+        $last_endtime = Request::get('last_endtime') ? Request::get('last_endtime')  : '';
+        $statuss = Request::has('statuss') ? Request::get('statuss') : '';
+        $cash_small = Request::has('cash_small') ? Request::get('cash_small') : '';
+        $cash_big = Request::has('cash_big') ? Request::get('cash_big') : '';
+        $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'on';
+        $nameblur = Request::has('nameblur') ? Request::get('nameblur') : '';
+        $rechargenum_small = Request::has('rechargenum_small') ? Request::get('rechargenum_small') : '';
+        $rechargenum_big = Request::has('rechargenum_big') ? Request::get('rechargenum_big') : '';
+        $takenum_small = Request::has('takenum_small') ? Request::get('takenum_small') : '';
+        $takenum_big = Request::has('takenum_big') ? Request::get('takenum_big') : '';
+
+        $where = ' ';
+        $curtime = time() - 300;
+        $rflag = -1;
+        $tflag = -1;
+        if (!empty($account)) {
+            $account = strtolower($account);
+            $where .= ' AND account';
+            if (empty($sureblur) || $sureblur == 'off') {
+                $where .= " LIKE '%" . $account . "%'";
+            } else {
+                $where .= "='" . $account . "'";
+            }
+        }
+        if (!empty($select_value)) {
+            if ($select_type == 'name') {
+                $where .= ' AND name';
+                if (empty($nameblur) || $nameblur == '模糊') {
+                    $where .= " LIKE '%" . $select_value . "%'";
+                } else {
+                    $where .= "='" . $select_value . "'";
+                }
+            } elseif ($select_type == 'register_ip') {
+                $where .= " AND register_ip='" . $select_value . "'";
+            } elseif ($select_type == 'last_ip') {
+                $where .= " AND last_ip='" . $select_value . "'";
+            } elseif ($select_type == 'register_url') {
+                $where .= " AND register_url LIKE '%" . $select_value . "%'";
+            } elseif ($select_type == 'last_url') {
+                $where .= " AND last_url LIKE '%" . $select_value . "%'";
+            } elseif ($select_type == 'phone') {
+                $where .= " AND phone LIKE '%" . $select_value . "%'";
+            } elseif ($select_type == 'email') {
+                $where .= " AND email LIKE '%" . $select_value . "%'";
+            }
+        }
+
+        if (!empty($grade)) {
+            $where .= ' AND grade=';
+            $where .= ($grade == 10) ? '0' : $grade;
+        }
+        if(!empty($group)){
+            $where .= " AND group_code like '%,".$group. ",%'";
+        }
+        if (!empty($regist_startime)) {
+            $regist_startime = date('Y-m-d H:i:s', strtotime($regist_startime));
+            $where .= " AND register_time>='" . $regist_startime . "'";
+        }
+        if (!empty($regist_endtime)) {
+            $regist_endtime = date('Y-m-d H:i:s', strtotime($regist_endtime));
+            $where .= " AND register_time<='" . $regist_endtime . "'";
+        }
+        if (!empty($last_startime)) {
+            $last_startime = date('Y-m-d H:i:s', strtotime($last_startime));
+            //$last_startime = strtotime($last_startime)-300;
+            $where .= " AND last_time>='" . $last_startime . "'";
+            //$where .= " AND ta.effective_time>=" . $last_startime;
+        }
+        if (!empty($last_endtime)) {
+            $last_endtime = date('Y-m-d H:i:s', strtotime($last_endtime));
+            //$last_endtime = strtotime($last_endtime)-300;
+            $where .= " AND last_time<='" . $last_endtime . "'";
+            //$where .= " AND ta.effective_time<=" . $last_endtime;
+        }
+        if (!empty($statuss)) {
+            $statuss = ($statuss == 2) ? '0' : $statuss;
+            $where .= " AND statuss=" . $statuss;
+        }
+
+        if (!empty($status)) {
+            $status = ($status == 5) ? '-1' : $status;
+            $where .= " AND status=" . $status;
+            $where .= " or status=" . '2';
+        }
+        if (!empty($cash_small)) {
+            $where .= " AND cash>=" . $cash_small;
+        }
+        if (!empty($cash_big)) {
+            $where .= " AND cash<=" . $cash_big;
+        }
+        if (!empty($rechargenum_small)) {
+            $rflag = 1;
+            $where .= ' AND (mc.recharge_num >=' . $rechargenum_small;
+        }
+        if (!empty($rechargenum_big)) {
+            $rflag = 1;
+            $where .= empty($rechargenum_small) ? 'AND (' : 'AND ';
+            $where .= ' mc.recharge_num <=' . $rechargenum_big;
+        }
+        if ((empty($rechargenum_small) || $rechargenum_small <= 0) && (empty($rechargenum_big) || $rechargenum_big >= 0)) {
+            if (!(empty($rechargenum_small) && empty($rechargenum_big))) {
+                $where .= " OR mc.recharge_num ISNULL)";
+            }
+        } else {
+            $where .= ')';
+        }
+
+        if (!empty($takenum_small)) {
+            $tflag = 1;
+            $where .= ' AND (tc.take_num >=' . $takenum_small;
+        }
+        if (!empty($takenum_big)) {
+            $tflag = 1;
+            $where .= empty($takenum_small) ? 'AND (' : 'AND ';
+            $where .= ' tc.take_num <=' . $takenum_big;
+        }
+        if ((empty($takenum_small) || $takenum_small <= 0) && (empty($takenum_big) || $takenum_big >= 0)) {
+            if (!(empty($takenum_small) && empty($takenum_big))) {
+                $where .= " OR tc.take_num ISNULL)";
+            }
+        } else {
+            $where .= ')';
+        }
+
+
+        $db = new \App\Models\Account;
+        $data = $db->account($list, $page, $where, $field, $order, $rflag, $tflag);
+
+        if ($data < 0) {
+            return -1;
+        }
+        $data = $data['data'];
+        // // 打开PHP文件句柄,php://output 表示直接输出到浏览器
+        // dump($data);
+        // // 输出Excel列名信息
+        $head = '编号, 用户名/等级, 余额, 姓名, 注册时间, 注册IP/登录IP, 注册网址/登录网址, 手机号码, 邮箱, 最后登录时间, 状态, 代理';
+
+
+        $log = array(
+            session('adminInfo.admin_name'),
+        );
+        OperationLog(session('adminInfo.admin_id'), 'export_userlist', $log);
+        $str = iconv('utf-8', 'gbk',  $head) . chr(10) . chr(9);
+        foreach ($data as $value) {
+            $row = array();
+            $row[] = $value['id'];
+            $row[] = $value['account'];
+            $row[] = $value['cash'];
+            $row[] = $value['name'];
+            $row[] = $value['register_time'];
+            $row[] = str_replace(',','-',$value['register_ip']) . '/' . str_replace(',','-',$value['last_ip']);
+            $row[] = $value['register_url'] . '/' . $value['last_url'];
+            $row[] = $value['phone'];
+            $row[] = $value['email'];
+            $row[] = $value['last_time'];
+            $row[] = ($value['status']== 1) ? '启用' : '禁用';
+            $row[] = $value['agent_name'];
+            $str .= iconv('UTF-8', 'GBK//TRANSLIT', implode(',', $row)) . chr(10) . chr(9);
+        }
+        header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment;filename="user.csv"');
+        header('Cache-Control: max-age=0');
+        echo $str;
+
+    }
+
+
+    function getUser(Req $req){
+        $account_name=$req->account_name?trim($req->account_name):'';
+        if(empty($account_name)){
+            return responseToJson(-4010100201);
+        }
+        $acccount_db=new \App\Models\Account_list;
+        $data=$acccount_db->getMsg($account_name);
+        if($data<0){
+            return responseToJson($data);
+        }
+        //获取次数
+        $recharge_db=new \App\Models\Money_details;
+        $rech_data=$recharge_db->countUserNum($account_name);
+        $data['take_num']=0;
+        $data['recharge_num']=0;
+        foreach ($rech_data as $v){
+            if($v['trade_type']==5){
+                $data['take_num']=$v['num'];
+            }else{
+                $data['recharge_num']+=$v['num'];
+            }
+        }
+        //获取金额
+        $data['recharge']=$recharge_db->sumRecharge($account_name);
+        return responseToJson($data);
+
+    }
+}

+ 217 - 0
app/Http/Controllers/Admin/UserWaterController.php

@@ -0,0 +1,217 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class UserWaterController extends Controller {
+	/**
+	 *
+	 * [Colse description]
+	 */
+	function index(Req $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			abort(404);
+		}
+		return $this->show($id);
+	}
+	//流水
+	function water(Req $req) {
+		$id = $req->identity;
+		if (empty($id)) {
+			abort(404);
+		}
+		$user_db = new \App\Models\Account; //用户
+		$account = $user_db->getinfo($id, 2);
+		return $this->show($account['id']);
+	}
+	function show($id) {
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/userWater/getWater?id=' . $id);
+		$dt->setLang('user');
+		$dt->addColsFields('money_time', array('width' => 105)); //日期
+		$dt->addColsFields('trade_id', array('width' => 205)); //定单号
+		$dt->addColsFields('trade_type', array('width' => 100)); //交易类型
+		$dt->addColsFields('old_money', array('width' => 100)); //交易前
+		$dt->addColsFields('money', array('width' => 100)); //交易金额
+		$dt->addColsFields('money_cash', array('width' => 100)); //交易后金额
+		$dt->addColsFields('trade_desc'); //交易描述
+		$dt->addColsFields('details', array('templet' => '#detailsTool', 'width' => 90));
+		$dt->setPriKey('order_id');
+//        $dt->setToolBar(array('view'));//详情
+		return view('admin.user/userwater', $dt->render());
+	}
+
+	/**
+	 * 会员列表
+	 * 'user description'
+	 * @return 'type' 'description'
+	 */
+	function View(Req $req) {
+		return $this->Edit($req);
+	}
+
+	function getWater() {
+		$id = Request::has('id') ? Request::get('id') : '';
+		$page = Request::has('page') ? Request::get('page') : 1;
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$startime = Request::get('startime') ? Request::get('startime').' 00:00:00' : '';
+		$endtime = Request::get('endtime') ? Request::get('endtime').' 23:59:59' : '';
+		$trade_type = Request::has('trade_type') ? Request::get('trade_type') : '';
+
+		$where = array();
+		if (!empty($startime)) {
+			$startime = date('Y-m-d H:i:s', strtotime($startime));
+			$where[] = array('money_time', '>=', $startime);
+		}
+		if (!empty($endtime)) {
+			$endtime = date('Y-m-d H:i:s', strtotime($endtime));
+			$where[] = array('money_time', '<=', $endtime);
+		}
+
+		if (!empty($trade_type)) {
+			$where[] = array('trade_type', '=', $trade_type);
+		}
+		$user_db = new \App\Models\Account; //用户
+		$account = $user_db->getinfo($id, 1);
+		$money_db = new \App\Models\Money_details; //资金
+		$data = $money_db->getUserWater($account['identity'], $list,$where);
+
+		if (is_array($data['data']) && count($data['data']) > 0) {
+			$money_type = trans('status.money_details.trade_type');
+			foreach ($data['data'] as $k => $v) {
+				$data['data'][$k]['trade_type'] = $money_type[$v['trade_type']];
+			}
+		}
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+
+	}
+	/**
+	 * 用户添加
+	 * [add description]
+	 */
+	function userAdd() {
+		return view('admin.menu/userAdd');
+	}
+
+	/**
+	 * 会员列表
+	 * [getCloseTable description]
+	 * @return [type] [description]
+	 */
+	function getUserTable() {
+		$table = new \App\Lib\Biz\Game\Table\UserTable();
+		$data = $table->getUserTh();
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	/**
+	 * 资金流水
+	 * 'money description'
+	 * @return 'type' 'description'
+	 */
+	function money() {
+		$db = new \App\Models\Money_details;
+		$page = Request::has('statpageus') ? Request::get('page') : '20';
+		$identity = Request::has('account_identity') ? Request::get('account_identity') : '45b7d4e9-2bb9-16b3-9a50-6fd6f62235f8';
+		if (empty($identity)) {
+			return -2020162003; //用户不存在
+		}
+		$status = Request::has('status') ? Request::get('status') : '1';
+		if ($status == 1) {
+			$data = $db->money($page, $identity, $status);
+			return responseToJson($data);
+		} else {
+			return -2020162103; //账户异常
+		}
+	}
+
+	/**
+	 * 会员详情
+	 */
+	function Memdetails() {
+//        DB::connection()->enableQueryLog();
+		$id = Request::has('account.identity') ? Request::get('account.identity') : '19a67df4-b40e-3e40-ca25-deffbf0c846d';
+		if (empty($id)) {
+			return Rens(-2020023003); //此用户不存在
+		}
+//		$data = DB::table('account_detailed')
+		//			->join('account', 'account_detailed.account_identity', '=', 'account.identity')
+		//			->join('account_bank', 'account_detailed.account_identity', '=', 'account_bank.account_identity')
+		//			->select('account', 'cash', 'phone', 'email', 'name', 'email', 'email', 'email', 'bank_name', 'bank_address', 'bank_number', 'register_time', 'register_ip', 'last_time', 'last_ip')
+		//			->where('account.status', 1)
+		//			->where('account.identity', $id)
+		//			->first();
+		////        $log= DB::getQueryLog();
+		//		//        dd($log);die;
+		//		echo "<pre>";
+		//		print_r($data);
+
+		$data = array(
+			'account' => '13434926679',
+			'cash' => '0.00',
+			'phone' => '13434926679',
+			'email' => '',
+			'name' => '方玉佳',
+			'bank_name' => '中国工商银行',
+			'bank_address' => '洪阳工商银行',
+			'bank_number' => '6222082019001327324',
+			'register_time' => '2016-10-03 11:10:00',
+			'register_ip' => '121.11.142.210',
+			'last_time' => '2016-10-07 10:11:45',
+			'last_ip' => '121.11.142.210',
+		);
+		return Rens($data);
+
+	}
+
+	/**
+	 * 查看财务
+	 * 'finance description'
+	 * @return 'type' 'description'
+	 */
+	function finance() {
+		// $id = Request::has('account_identity') ? Request::get('account_identity') : '45b7d4e9-2bb9-16b3-9a50-6fd6f62235f8';
+		// $data = DB::table('money_details')->select('account_name', 'id', 'trade_type', 'trade_id', 'money_time', 'money', 'sysetem_user')->where('account_identity', $id)->limit(2)->get();
+		// echo "<pre>";
+		// print_r($data);
+
+		$data = array(
+			'0' => array
+			(
+				'account_name' => '123qqq',
+				'id' => '1094327',
+				'trade_type' => 1,
+				'trade_id' => '20170913162223362227472',
+				'money_time' => '2017-09-13 16:22:23',
+				'money' => 20,
+				'sysetem_user' => '系统',
+			),
+
+			'1' => array
+			(
+				'account_name' => '123qqq',
+				'id' => '1094352',
+				'trade_type' => 1,
+				'trade_id' => '20170913162250796540257',
+				'money_time' => '2017-09-13 16:22:50',
+				'money' => 180,
+				'sysetem_user' => '系统',
+			),
+		);
+
+		if (!$data) {
+			return Rens(-2020026003);
+		}
+		return Rens($data);
+	}
+
+}
+
+?>

+ 209 - 0
app/Http/Controllers/Admin/User_buyController.php

@@ -0,0 +1,209 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+
+class User_buyController extends Controller {
+
+	function add(Request $req) {
+		if (!$req->isMethod('post')) {
+			return view('admin.user_buy_form');
+		} else {
+			$model = new \App\Models\User_buyModel();
+			return responseToJson(1);
+		}
+	}
+
+	function view(Request $req) {
+		return $this->edit($req);
+	}
+	function edit(Request $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\User_buyModel::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+			return view('admin.user_buy_form', array('user_buy' => $data));
+		} else {
+			$model = \App\Models\User_buyModel::where('id', $id)->first();
+
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+	public function delete(Request $req) {
+		$id = $req->id;
+		if (empty($id)) {
+			return responseToJson(-2001); //id不能为空
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //id错误
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		$rows = \App\Models\User_buyModel::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); //id错误
+		}
+		return responseToJson(1, trans('user_buy.delete_success')); //id错误
+
+	}
+
+	public function dataSource(Request $req) {
+		$limit = intval($req->limit) > 0 ? $req->limit : 10;
+		$page = intval($req->page) > 0 ? $req->page : 1;
+		$field = !empty($req->field) ? $req->field : '';
+		$order = !empty($req->order) ? $req->order : 'desc';
+
+		$model = new \App\Models\User_buyModel;
+
+		$type = $req->type ? $req->type : '';
+		$type == '-1' ? $type = '' : null;
+		$where = array();
+        $model = $model->whereIn('status', array(1, 2));
+        $where['in'] = array(1, 2);
+		if (!empty($type)) {
+			switch ($type) {
+			case 'unclear':
+//				$model = $model->whereIn('status', array(1, 2));
+				$model = $model->where('game_status', 0);
+//				$where['in'] = array(1, 2);
+				$where[] = array('game_status', '=', 0);
+				break;
+			case 'cleared':
+//                $model = $model->whereIn('status', array(1, 2));
+				$model = $model->where('game_status', '<>', '0');
+//				$where['in'] = array(1, 2);
+				$where[] = array('game_status', '<>', '0');
+				break;
+			// case 'rubish':
+			// 	$model = $model->where('status', 4);
+			// 	$where[] = array('status', '=', 4);
+			// 	break;
+			default:
+				break;
+			}
+		}
+
+		$time_start = $req->time_start ? $req->time_start.' 00:00:00' : '';
+		if (!empty($time_start)) {
+			$model = $model->where('money_time', '>', $time_start);
+			$where[] = array('money_time', '>', $time_start);
+		}
+		$time_end = $req->time_end ? $req->time_end.' 23:59:59': '';
+		if (!empty($time_end)) {
+			$model = $model->where('money_time', '<', $time_end);
+			$where[] = array('money_time', '<', $time_end);
+		}
+		$account = $req->account ? $req->account : '';
+		if (!empty($account)) {
+			$model = $model->where('account_name', $account);
+			$where[] = array('account_name', '=', $account);
+		}
+		$game_no = $req->game_no ? $req->game_no : '';
+		if (!empty($game_no)) {
+			$model = $model->where('game_no', $game_no);
+			$where[] = array('game_no', '=', $game_no);
+		}
+		$game = $req->game ? $req->game : '';
+		if (!empty($game)) {
+			$model = $model->where('game_name', $game);
+			$where[] = array('game_name', '=', $game);
+		}
+		$model = $model->select(DB::raw('count(id) as num,account_name,sum(money) as money,sum(prize_money) as prize_money,sum(get_money) as get_money'));
+		$model->groupBy('account_name');
+		if (!empty($field) && !empty($order)) {
+			$model = $model->orderBy($field, $order);
+		}
+		$model->offset(($page - 1) * $limit);
+		$model->limit($limit);
+		$data = $model->get();
+		$data = $data->toArray();
+		foreach ($data as $k => $v) {
+			if (empty($game)) {
+				$data[$k]['game_name'] = '全部游戏';
+			} else {
+				$data[$k]['game_name'] = trans('common.' . $game);
+			}
+			if (empty($type)) {
+				$data[$k]['type'] = '全部注单';
+			} else {
+				$data[$k]['type'] = trans('user_buy.' . $type);
+			}
+			// $data[$k]['prize_money'] = floatval($v['prize_money']);
+		}
+		$count = new \App\Models\User_buyModel;
+		$num = $count->getAllBetAccount($where);
+		$data = arrayToNumber($data, array('money', 'prize_money', 'get_money'));
+		return \App\Lib\DataTable\DataTable::init()->toJson($data, count($num), 0, $where);
+	}
+
+	public function index(Request $req) {
+        $request=array();
+        $request['time_start'] = isset($req->time_start) ? $req->time_start : trans('status.default_time.seven_day');
+        $request['time_end'] = isset($req->time_end) ? $req->time_end : trans('status.default_time.etime');
+        $request['account'] = $req->account ? $req->account : '';
+        $request['game_no'] = $req->game_no ? $req->game_no : '';
+        $request['game'] = $req->game ? $req->game : '';
+        $request['type'] = $req->type ? $req->type : '';
+        $request['gameList']=\App\Models\GameType::getGameType();
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setLang('user_buy');
+		$dt->addColsFields('type', array('sort' => false, 'width' => 140));
+		$dt->addColsFields('account_name', array('sort' => false, 'width' => 140, 'templet' => '#userdetail'));
+		$dt->addColsFields('game_name', array('sort' => false, 'width' => 140));
+		$dt->addColsFields('num', array('width' => 190));
+		$dt->addColsFields('money', array('width' => 165));
+		$dt->addColsFields('prize_money', array('width' => 165));
+		$dt->addColsFields('get_money', array('templet' => '#usergetmoney', 'width' => 180));
+
+		$data = array(
+			'options' => array('type' => \App\Models\User_buyModel::getType()),
+		);
+        $request['options']=array('type' => \App\Models\User_buyModel::getType());
+		return view('admin.user_buy_list', $dt->render($request));
+	}
+	//统计用户总投注
+	function Total(Request $req) {
+		$where = $req->where;
+		$model = new \App\Models\MoneyBuy;
+		$model = $model->select(DB::raw('count(id) as num,sum(money) as money,sum(prize_money) as prize_money,sum(get_money) as get_money'));
+
+		if (isset($where['in'])) {
+			$model = $model->whereIn('status', $where['in']);
+			unset($where['in']);
+		}
+		if (!empty($where)) {
+			$model = $model->where($where);
+		}
+
+		$data = $model->get();
+		//处理数据
+		$array = array();
+		foreach ($data as $v) {
+			$array['num'] = round($v['num'], 2);
+			$array['money'] = round($v['money'], 2);
+			$array['prize_money'] = round($v['prize_money'], 2);
+			$array['get_money'] = -round($v['get_money'], 2);
+		}
+		return responseToJson($array);
+	}
+
+}

+ 132 - 0
app/Http/Controllers/Admin/UservipController.php

@@ -0,0 +1,132 @@
+<?php
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+/**
+ *
+ */
+class UservipController extends Controller
+{
+	/**
+     *
+     * [Colse description]
+     */
+    public function index(Req $req)
+    {
+    	$request = array();
+    	$request['account'] = isset($req->account) ? trim($req->account) : null;
+    	$request['sysetem_user'] = isset($req->sysetem_user) ? trim($req->sysetem_user) : null;
+    	$request['addtime_start'] = isset($req->addtime_start) ? trim($req->addtime_start) : null;
+    	$request['addtime_end'] = isset($req->addtime_end) ? trim($req->addtime_end) : null;
+    	$request['status'] = isset($req->status) ? trim($req->status) : null;
+    	$request['remark'] = isset($req->remark) ? trim($req->remark) : null;
+    	$limit = Request::has('limit') ? Request::get('limit') : '';
+        $dt = \App\Lib\DataTable\DataTable::init();
+    	$dt->setDataSource('/admin/uservip/info?limit='.$limit);
+		$dt->setLang('uservip');
+		$dt->addColsFields('account_name');
+		$dt->addColsFields('sysetem_user');
+		$dt->addColsFields('addtime');
+        $dt->addColsFields('audittime');
+		//$dt->addColsFields('remark');
+		$dt->addColsFields('status');
+		$dt->addColsFields ('tools', array('templet' => '#caozuo'));
+		$dt->enableCheckBox();
+		$dt->setToolBar ();
+    	return view('admin.user/uservip', $dt->render($request));
+    }
+
+    function info() {
+    	$list = Request::has ('limit') ? Request::get ('limit') : '';
+		$db = new \App\Models\Uservip();
+		$account = Request::has('account') ? Request::get('account') : '';
+		$sysetem_user = Request::has('sysetem_user') ? Request::get('sysetem_user') : '';
+		$addtime_start = Request::has('addtime_start') ? Request::get('addtime_start') : '';
+		$addtime_end = Request::has('addtime_end') ? Request::get('addtime_end') : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$remark = Request::has('remark') ? Request::get('remark') : '';
+		$where = array();
+		if(!empty($account)){
+			$where[] =  array('account_name','=',$account);
+		}
+		if(!empty($sysetem_user)){
+			$where[] = array('sysetem_user','=',$sysetem_user);
+		}
+		if(!empty($addtime_start)){
+			$where[] = array('addtime','>=',$addtime_start.' 00:00:00');
+		}
+		if(!empty($addtime_end)){
+			$where[] = array('addtime','<=',$addtime_end.' 23:59:59');
+		}
+		if(!empty($status)){
+			$where[] = array('status','=',$status);
+		}
+		if(!empty($remark)){
+			$where[] = array('remark','like','%'.$remark.'%');
+		}
+		$data = $db->getlist($list,$where);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	function upvip(Req $req){
+		$id = isset($req->id) ? trim($req->id) : 0;
+		$status = isset($req->status) ? trim($req->status) : 1;
+		$remark = isset($req->remark) ? trim($req->remark) : '';
+        if (empty($id)) {
+            return -1;
+        }
+        $db = new \App\Models\Uservip();
+        if (!$req->isMethod('post')) {
+        	$data = $db->where('id', $id)->first();
+            if (!$data) {
+                return -2;
+            }
+            $data = $data->toArray();
+        	return view('admin.user/editvip', array('data' => $data));
+        }else{
+
+	        $Account_detailed = new \App\Models\Account_detailed();
+	        $info = $db->where('id',$id)->first();
+	        if(!empty($info)){
+	        	$info = $info->toArray();
+	        	$data['sysetem_user_id'] = session('adminInfo.admin_id');
+	        	$data['sysetem_user'] = session('adminInfo.admin_name');
+	        	$data['status'] = $status;
+	        	$data['remark'] = $remark;
+	        	$data['audittime'] = date('Y-m-d H:i:s');
+	        	$res = $db->where('id',$id)->update($data);
+		        if($res){ 
+		        	$tong ="";
+		        	if($status == 2){
+		        		$tong ="通过";
+		        		$re=$Account_detailed->where('account_identity',$info['account_identity'])->update(['grade'=>-2]);
+		        	}elseif($status == 3){
+		        		$tong ="未通过";
+		        		$re=$Account_detailed->where('account_identity',$info['account_identity'])->update(['grade'=>0]);
+		        	}
+		        	$log = array(
+			            session('adminInfo.admin_name'),
+			            $tong,
+			            $info['account_name'],
+			            session('adminInfo.admin_name'),
+			        );
+
+			        OperationLog(session('adminInfo.admin_id'), 'Uservip', $log);
+			        
+			        return responseToJson ($re);
+		        }else{
+		        	return responseToJson(-1);
+		        }
+	        }else{
+	        	return responseToJson(-1);
+	        }
+        }
+		
+	}
+
+}
+
+?>

+ 230 - 0
app/Http/Controllers/Admin/WagentController.php

@@ -0,0 +1,230 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Models;
+use Request;
+
+/**
+ *代理管理
+ */
+class WagentController extends Controller {
+
+	//代理列表
+	function index(Req $req) {
+		$request=array();
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/wagent/info');
+        $dt->setLang('wagent');
+        $dt->addColsFields('agent_name', array('templet' => '#newtime', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('agent_key_secret', array('templet' => '#agent_key_secret', 'sort' => false, 'width' => 160));
+        $dt->addColsFields('create_time', array('templet' => '#totime', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('frozen_money', array('templet' => '#frozen_money', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('money', array('templet' => '#totime', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('zjrecord_xxrecord', array('templet' => '#zjrecord_xxrecord', 'sort' => false, 'width' => 180));
+        if (checkRriv('/admin/wagent/edit')) {
+			$arr[] = 'edit';
+		}
+		$dt->setToolBar($arr, array('width' => 100));
+        $dt->enableCheckBox();
+		return view('admin.wagent/index', $dt->render($request));
+	}
+
+	//代理用户资金纪录
+	function zjrecord(Req $req){
+		$request=array();
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/wagent/zjrecordinfo');
+        $dt->setLang('wagent');
+        $dt->addColsFields('agent_name', array('templet' => '#newtime', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('ordernumber', array('templet' => '#newtime', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('credit', array('templet' => '#newtime', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('agent_money_before', array('templet' => '#newtime', 'sort' => false, 'width' => 100));
+        $dt->addColsFields('agent_money_after', array('templet' => '#newtime', 'sort' => false, 'width' => 100));
+        $dt->enableCheckBox();
+		return view('admin.wagent/zjrecord', $dt->render($request));
+	}
+
+	function zjrecordinfo(){
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$where = array();
+		if (!empty($home_team)) {
+			if (empty($sureblur) || $sureblur == 'off') {
+				$where[] = array('wagent_log.agent_name', 'like', '%' . $home_team . '%');
+			} else {
+				$where[] = array('wagent_log.agent_name', '=', $home_team);
+			}
+		}
+
+		$newapp = new \App\Models\Wagentlog();
+        $data = $newapp->wagentloglist($list, $page, $where);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	//代理用户客户资金纪录
+	function xxrecord(Req $req){
+		$request=array();
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['star_time'] = isset($req->star_time) ? trim($req->star_time) :trans('status.default_time.seven_day') ;
+        $request['end_time'] = isset($req->end_time) ? trim($req->end_time) : trans('status.default_time.etime');
+        
+        $dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/wagent/xxrecordinfo');
+        $dt->setLang('wagent');
+        $dt->addColsFields('ordernumber', array('templet' => '#newtime', 'sort' => false, 'width' => 300));
+        $dt->addColsFields('tradeamount', array('templet' => '#newtime', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('blance', array('templet' => '#newtime', 'sort' => false, 'width' => 80));
+        $dt->addColsFields('addtime', array('templet' => '#newtime', 'sort' => false, 'width' => 160));
+        $dt->addColsFields('agent_name', array('templet' => '#newtime', 'sort' => false, 'width' => 80));
+        $dt->enableCheckBox();
+		return view('admin.wagent/xxrecord', $dt->render($request));
+	}
+
+	function xxrecordinfo(){
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$where = array();
+		if (!empty($home_team)) {
+			if (empty($sureblur) || $sureblur == 'off') {
+				$where[] = array('money_transfer.agent_name', 'like', '%' . $home_team . '%');
+			} else {
+				$where[] = array('money_transfer.agent_name', '=', $home_team);
+			}
+		}
+
+		$newapp = new \App\Models\Moneytransfer();
+        $data = $newapp->moneytransferlist($list, $page, $where);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	function info(){
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$where = array();
+		if (!empty($home_team)) {
+			if (empty($sureblur) || $sureblur == 'off') {
+				$where[] = array('wagent.agent_name', 'like', '%' . $home_team . '%');
+			} else {
+				$where[] = array('wagent.agent_name', '=', $home_team);
+			}
+		}
+
+		$newapp = new \App\Models\Wagent();
+        $data = $newapp->wagentlist($list, $page, $where);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	function edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\Wagent::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+
+			return view('admin.wagent/edit', $data);
+		} else {
+			$newapp = new \App\Models\Wagentlog();
+			$model = \App\Models\Wagent::where('id', $id)->first();
+			$newapp->agent_money_before = $model['money'];//交易前金额
+			$upmoney = $req->input('upmoney');
+			$type = $req->input('type');
+
+			if($type==1){
+				$model->money = $model['money']+$upmoney;
+			}
+			if($type==2){
+				if($model['money']>=$upmoney){
+					$model->money = $model['money']-$upmoney;
+				}
+			}
+			$model->status = $req->input('status');
+			$model->save();
+
+			//资金纪录日志
+			$newapp->agent_name = $model['agent_name'];//代理名称
+			$newapp->account_identity = 0;//默认值
+			$newapp->ordernumber = 'ST'.date("Ymdhis").mt_rand(100000, 999999);//订单号
+			$newapp->credit = $upmoney;//改变金额
+			$newapp->agent_money_after = $model->money;//交易后金额
+			$newapp->uid = session('adminInfo.admin_id');//操作员id
+			$newapp->save();
+			return responseToJson(1);
+		}
+	}	
+
+	function add(Req $req) {
+		if (!$req->isMethod('post')) {
+            $lange = trans('menu');
+
+            return view('admin.wagent/add');
+        } else {
+        	$agent_name = trim($req->input('agent_name'));//唯一代理名称
+        	$agent_pre = trim($req->input('agent_pre'));//唯一代理用户前缀
+
+            $model = new \App\Models\Wagent();
+            $only = $model->onlywagent($agent_name,$agent_pre);
+            if($only==1){
+				$model->agent_name = $agent_name;//唯一代理名称
+				$model->money = trim($req->input('money'));
+				$model->frozen_money = trim($req->input('frozen_money'));
+				$model->agent_key = md5($this->randomnum(6));
+				$model->auth_expire = time();
+				$model->agent_secret = md5($this->randomnum(6));
+				$model->create_time = date("Y-m-d");
+				$model->agent_pre = $agent_pre.'_';//唯一代理用户前缀
+				$model->status = trim($req->input('status'));
+			}
+
+			$model->save();
+			return responseToJson(1);
+        }
+	}
+
+	//随机数
+	function randomnum($num){
+		$str='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
+		$randStr = str_shuffle($str);//打乱字符串
+		$rands= substr($randStr,0,$num);
+		return $rands;
+	}
+
+}

+ 182 - 0
app/Http/Controllers/Admin/WithController.php

@@ -0,0 +1,182 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Request;
+
+class WithController extends Controller {
+
+	function index() {
+		# code...
+	}
+
+	/**
+	 * 提现明细
+	 * [detail description]
+	 * @return [type] [description]
+	 */
+	function detail(Req $req) {
+
+        $request=array();
+        $request['betnum_small']=isset($req->betnum_small)?trim($req->betnum_small):null;
+        $request['betnum_big']=isset($req->betnum_big)?trim($req->betnum_big):null;
+        $request['betmoney_small']=isset($req->betmoney_small)?trim($req->betmoney_small):null;
+        $request['betmoney_big']=isset($req->betmoney_big)?trim($req->betmoney_big):null;
+        $request['name']=isset($req->name)?trim($req->name):null;
+        $request['status']=isset($req->status)?trim($req->status):null;
+        $request['account_name']=isset($req->account_name)?trim($req->account_name):null;
+        $request['star_time']=isset($req->star_time)?trim($req->star_time):null;
+        $request['end_time']=isset($req->end_time)?trim($req->end_time):null;
+
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$dt->setDataSource('/admin/With/state');
+		$dt->setLang('state');
+		$dt->addColsFields('account_name', array('sort' => false, 'toolbar' => '#usertake'));
+		$dt->addColsFields('name', array('sort' => false));
+		$dt->addColsFields('betnum');
+		$dt->addColsFields('betmoney');
+		$dt->addColsFields('star_time');
+		$dt->addColsFields('end_time');
+		$dt->addColsFields('status', array('sort' => false, 'toolbar' => '#userStatus'));
+		$dt->setPriKey('account_identity');
+		$dt->setToolBar(array('view'), array('toolbar' => '#query_status','align' => 'left'));
+		// $dt->setPriKey('statuss');
+		return view('admin.with/detail', $dt->render($request));
+	}
+
+	//报表查看
+	function View(Req $req) {
+		$id = $req->identity;
+		$status = $req->status;
+		$star_time = !empty($req->star_time) ? $req->star_time : '';
+		$end_time = !empty($req->end_time) ? $req->end_time : '';
+		if (empty($id)) {
+			abort(404);
+		}
+		$dt = \App\Lib\DataTable\DataTable::init();
+		$url = '/admin/With/withDetail?id=' . $id . '&statuss=' . $status . '&star_time=' . $star_time . '&end_time=' . $end_time;
+		$dt->setDataSource($url);
+		$dt->setLang('with');
+		$dt->addColsFields('account_name', array('sort' => false, 'width' => 150));
+		$dt->addColsFields('id', array('width' => 120));
+		// $dt->addColsFields('order_id', array('width' => 210));
+		$dt->addColsFields('old_money', array('width' => 135)); //提现前
+		$dt->addColsFields('money', array('width' => 135));
+		$dt->addColsFields('money_cash', array('width' => 135)); //提现后
+		// $dt->addColsFields('bank_no', array('width' => 170));
+		// $dt->addColsFields('bank_user', array('width' => 80));
+		$dt->addColsFields('bank_no_bank_info', array('sort' => false, 'width' => 200));
+		$dt->addColsFields('bank_user_bank_address', array('sort' => false));
+		$dt->addColsFields('order_id_apply_time');
+		$dt->addColsFields('pass_time', array('width' => 190));
+		$dt->setPriKey('identity');
+		return view('admin.with/view', $dt->render());
+	}
+
+	/**
+	 * 提现明细
+	 * 'with description'
+	 * @return 'type' 'description'
+	 */
+	function withDetail(Req $req) {
+		$id = $req->id;
+		$tem = 'statuss';
+		$status = $req->$tem;
+		if (empty($id)) {
+			abort(404);
+		}
+		$star_time = !empty($req->star_time) ? $req->star_time : '';
+		$end_time = !empty($req->end_time) ? $req->end_time : '';
+		$where = array();
+		$where[] = array('account_identity', '=', $id);
+		$where[] = array('status', '=', $status);
+		if (!empty($star_time)) {
+			$where[] = array('apply_time', '>=', $star_time);
+		}
+		if (!empty($end_time)) {
+			$where[] = array('apply_time', '<=', $end_time);
+		}
+		$db = new \App\Models\Money_take();
+		$data = $db::where($where)->orderBy('apply_time', 'desc')->get();
+		if (!$data) {
+			abort(404);
+		}
+		$data = $data->toArray();
+		foreach ($data as $k => $v) {
+			$data[$k]['old_money'] = sprintf("%.1f", $v['money_cash'] + $v['money']);
+			$data[$k]['bank_no_bank_info'] = $v['bank_info'] . '<br>' . $v['bank_no'];
+			$data[$k]['bank_user_bank_address'] = $v['bank_user'] . '<br>' . $v['bank_address'];
+			$data[$k]['order_id_apply_time'] = $v['order_id'] . '<br>' . $v['apply_time'];
+		}
+		// $where = array();
+		// $data = $db->getTotalDetails($where);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data, count($data));
+	}
+
+	/**
+	 *提现账单
+	 * [state description]
+	 * @return [type] [description]
+	 */
+	function state() {
+		$page = Request::has('page') ? Request::get('page') : 1;
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$field = Request::has('field') ? Request::get('field') : 6;
+		$order = Request::has('order') ? Request::get('order') : 'desc';
+
+		$account_name = Request::has('account_name') ? Request::get('account_name') : '';
+		$name = Request::has('name') ? Request::get('name') : '';
+		$status = Request::has('status') ? Request::get('status') : '';
+		$betnum_small = Request::has('betnum_small') ? Request::get('betnum_small') : '';
+		$betnum_big = Request::has('betnum_big') ? Request::get('betnum_big') : '';
+		$betmoney_small = Request::has('betmoney_small') ? Request::get('betmoney_small') : '';
+		$betmoney_big = Request::has('betmoney_big') ? Request::get('betmoney_big') : '';
+		$sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
+		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
+		$end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
+		$where = array();
+		$having = array();
+
+		if (!empty($account_name)) {
+			if (empty($sureblur) || $sureblur == '模糊') {
+				$where[] = array('account_name', 'like', '%' . $account_name . '%');
+			} else {
+				$where[] = array('account_name', '=', $account_name);
+			}
+		}
+		if (!empty($name)) {
+			$where[] = array('name', 'like', '%' . $name . '%');
+		}
+		if (!empty($status)) {
+			if ($status == 3) {
+				$where[] = array('status', '=', '0');
+			} else {
+				$where[] = array('status', '=', $status);
+			}
+		}
+		if (!empty($star_time)) {
+			$where[] = array('apply_time', '>=', $star_time);
+		}
+		if (!empty($end_time)) {
+			$where[] = array('apply_time', '<=', $end_time);
+		}
+		if (!empty($betnum_small)) {
+			$having[] = 'count("order_id")>=' . $betnum_small;
+		}
+		if (!empty($betnum_big)) {
+			$having[] = 'count("order_id")<=' . $betnum_big;
+		}
+		if (!empty($betmoney_small)) {
+			$having[] = 'sum("money")>=' . $betmoney_small;
+		}
+		if (!empty($betmoney_big)) {
+			$having[] = 'sum("money")<=' . $betmoney_big;
+		}
+		$field = ($field==6||$field=='star_time')?'star_time':(($field=='end_time')?'end_time':$field);
+
+		$db = new \App\Models\Money_take;
+		$data = $db->getTotal($where, 1, $list, $field, $order, 1, $having);
+		return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+}

+ 131 - 0
app/Http/Controllers/Api/SettlementController.php

@@ -0,0 +1,131 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Http\Model\StSettlementMiddleDetail;
+use App\Lib\Settlement\Adapter\RulePlus;
+use App\Lib\Settlement\SettlementOrder;
+use App\Lib\Settlement\Adapter\ZqRule;
+
+
+use App\Lib\Settlement\SettlementWinFail;
+use  Illuminate\Routing\Controller as Controller;
+use function MongoDB\BSON\toJSON;
+use Illuminate\Support\Facades\DB;
+
+
+class SettlementController extends Controller
+{
+    use RulePlus;
+    public function index()
+    {
+        $dd = new ZqRule();
+        dd($dd->bodan(1,2,1));
+    }
+
+    public function dd()
+    {
+        $obj = new SettlementOrder();
+        $ret = $obj->stringComputing(1);
+        var_dump($ret);
+    }
+
+    public function debug()
+    {
+
+        $rule = new ZqRule();
+        $model = DB::table('money_buy_match')->where(['id' => 320])->first();
+        $reco = DB::table('st_zq_result')->where(['id' => 1317823])->get();
+
+        print_r([$model,$reco]);
+        $ret = $rule->tema_ball($model, $reco, []);
+        //corner_concede_home($model, $reco, []);
+        print_r($ret);
+
+
+        exit;
+
+
+
+
+
+
+
+
+
+        $cond = '+2.5/3';
+        $cond = '+3/3.5';
+
+        $ret = $this->zq_letball(3,$cond,'xxx');
+        print_r($ret);
+        exit ;
+
+
+
+
+        /*
+        $rule = new ZqRule();
+        $model = DB::table('money_buy_match')->where(['id' => 320])->first();
+        $reco = DB::table('st_zq_result')->where(['id' => 1317823])->get();
+        print_r([$model,$reco]);
+        $ret = $rule->first_ball_guest($model, $reco, []);
+        print_r($ret);
+
+        exit ;
+        */
+
+
+
+        $noticeid = 3592444;
+        $matchid = 3217130;
+        $order_ids = $this->getIds(1, $matchid,'zq');
+
+
+        $winorfalse = new  SettlementWinFail();
+        $ret1 = $winorfalse->doRun($noticeid);
+        print_r(['ret1' => $ret1]);
+
+        if ($ret1['status'] == 1) {
+            $setOrder = new SettlementOrder();
+            $ret2 = $setOrder->reSettlement($order_ids, 1, 2, 'zq', $matchid);
+            print_r(['ret2' => $ret2]);
+        }
+        exit;
+
+
+
+
+        $model = DB::table('st_zq_result')->where(['id' => 1317823])->first();
+        echo json_decode($model->corner_ball);
+
+
+        exit;
+
+
+
+    }
+
+
+    private function getIds($type, $match_id, $game_code='')
+    {
+        $return  = [] ;
+        if ($type == 1) {
+            $ret = DB::table('money_buy_simplex')->where(['match_id' => $match_id])->get();
+            if ($ret){
+                foreach ($ret as $val){
+                    $return[] = $val->order_id;
+                }
+            }
+            return $return;
+        }else{
+            $ret = DB::table('money_buy_str')->leftJoin('money_buy_match','money_buy_match.batch_id','=','money_buy_str.batch_id')->where(['money_buy_match.match_id'=>$match_id,'money_buy_match.game_code'=>$game_code])->get();
+            if ($ret){
+                foreach ($ret as $val){
+                    $return[] = $val->order_id;
+                }
+            }
+            return $return ;
+        }
+    }
+
+}

+ 825 - 0
app/Http/Controllers/Api/WriteSportsController.php

@@ -0,0 +1,825 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jun.peng
+ * Date: 2019/5/13
+ * Time: 10:19
+ */
+namespace App\Http\Controllers\Api;
+use Illuminate\Routing\Controller as BaseController;
+use App\Http\Response\Response;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Lib\Biz\Sport\Common as commonFunction;
+use App\Http\Model\StBqResult as BqResultModel;
+use App\Http\Model\StBroadcast as broadcastModel;
+use App\Http\Model\StGameType as gameModel;
+use App\Http\Model\StLqResult as LqResultModel;
+use App\Http\Model\StWqResult as WqResultModel;
+use App\Http\Model\StZqLocalLeague as LeagueModel;
+use App\Http\Model\StZqLocalMatch as MatchModel;
+use App\Http\Model\StZqOdds as OddsModel;
+use App\Http\Model\StZqOddsRecord as OddsRecordModel;
+use App\Http\Model\StZqResult as ZqResultModel;
+
+
+/**
+ * 体育数据入库接口
+ */
+class WriteSportsController extends BaseController{
+    public function setSports(Req $data){
+        try {
+            //开启事务
+            DB::beginTransaction();
+            if($data->game_code){
+                //用于后台 将所有进行中的赛事写入结果
+                $this->match_result($data->game_code);
+            }//写赛事数据
+            $obt = $data->data;
+            if($obt){
+                $getData = $this->getAddData($obt);
+                $league = [];
+                $competition = [];
+                $odds = [];
+                $league_result = [];
+                $match_result = [];
+                $match_result_record = [];
+                $odds_record = [];
+                $broadcast = [];
+                //指定排序 联赛->赛事->赔率->联赛结果->赛事结果->赛事结果记录->赔率记录->直播数据
+                foreach ($getData as $k=>$v){
+                    $game_code = $v['game_code'];
+                    if($v['title'] == 'league') $league[] = $v;
+                    if($v['title'] == 'competition') $competition[] = $v;
+                    if($v['title'] == 'odds') $odds[] = $v;
+                    if($v['title'] == 'league_result') $league_result[] = $v;
+                    if($v['title'] == 'match_result') $match_result[] = $v;
+                    if($v['title'] == 'match_result_record') $match_result_record[] = $v;
+                    if($v['title'] == 'odds_record') $odds_record[] = $v;
+                    if($v['title'] == 'broadcast') $broadcast[] = $v;
+                }
+                $matchData = [$league,$competition,$odds,$league_result,$match_result,$match_result_record,$odds_record,$broadcast];
+
+                //排空处理
+                foreach ($matchData as $k=>$v){
+                    if($v == []) unset($matchData[$k]);
+                }
+                sort($matchData);
+
+                //根据顺序写入数据
+                //降维数据
+                $mentData = [];
+                foreach ($matchData as $k=>$v){
+                    foreach ($v as $kk=>$vv){
+                        $mentData[] = $vv;
+                    }
+                }
+                //获取各球类model
+                $models = commonFunction::getModels($game_code,1);
+                //获取球类名称
+                $gameName = gameModel::getGameName($game_code);
+                //===获取验证数据===
+                //获取一段时间内所有联赛本地记录
+                $lg_data = LeagueModel::getLeagueID($models);
+                //获取一段时间内所有赛事本地记录
+                $match_data = MatchModel::getMatchID($models);
+                //获取一段时间内所有赔率
+                $odds_data = OddsModel::getOddsID($models);
+                //获取一段时间内所有赔率记录
+                $odds_record_data = OddsRecordModel::getOddsRecordID($models);
+                //===获取验证数据===
+                $others_lg_id = '';//继承 源联赛id
+                $others_match_id = '';//继承 源赛事id
+                $s_lg_id = '';//源 联赛ID
+                $l_lg_id = '';//本地 联赛 ID
+                $s_match_id = '';//源 赛事ID
+                $l_match_id = '';//本地 赛事 ID
+                foreach ($mentData as $kk =>$vv){
+                    switch ($vv['title']){
+                        case 'area'://地区
+                            throw new \Exception(Response::generate('地区数据-area:',Response::AUTH_ERROR)) ;
+                            break;
+                        case 'country'://国家
+                            throw new \Exception(Response::generate('国家数据-country:',Response::AUTH_ERROR));
+                            break;
+                        case 'league'://联赛
+                            $others_lg_id = $vv['data']['lg_id'];
+                            $s_lg_id = $vv['data']['lg_id'];
+
+                            $source = $vv['data']['source'];
+                            //验证联赛记录是否已存在
+                            $ret_lg = commonFunction::ver_league($s_lg_id,$source,$lg_data);
+                            if($ret_lg != false) {
+                                $l_lg_id = $ret_lg;
+                                break;
+                            }
+                            //执行 联赛数据
+                            $lg_data = $this->league($vv,$gameName);
+                            $l_lg_id = $lg_data['lg_id'];
+                            break;
+                        case 'competition'://赛事
+                            $others_match_id = $vv['data']['match_id'];
+                            $s_lg_id = $vv['data']['lg_id'];
+                            $s_match_id = $vv['data']['match_id'];
+                            $source = $vv['data']['source'];
+                            //本次请求是否包含 联赛数据
+                            if(empty($others_lg_id)){
+                                //验证本地是否存在
+                                $ret_lg = commonFunction::ver_league($s_lg_id,$source,$lg_data);
+                                if($ret_lg == false) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
+                                $l_lg_id = $ret_lg;
+                            }else{
+                                //本次有 联赛数据 验证属于同联赛
+                                if($s_lg_id != $others_lg_id) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
+                            }
+                             //验证赛事记录是否已存在
+                            $ret_match = commonFunction::ver_match($s_match_id,$source,$match_data);
+                            if($ret_match != false){
+                                $l_match_id = $ret_match;
+                                    break;
+                            }
+                            //执行 赛事数据
+                            $match_data = $this->competition($vv,$gameName,$l_lg_id);
+                            $l_match_id = $match_data['match_id'];
+                            break;
+                        case 'odds'://赔率
+                            $s_lg_id = $vv['data']['lg_id'];
+                            $s_match_id = $vv['data']['match_id'];
+                            $source = $vv['data']['source'];
+                            $odds_only = $vv['data']['odds_only'];
+                            $sole = $vv['data']['sole'];
+                            $odds_type = $vv['data']['type'];//0普通 1冠军盘口
+
+                            //本次请求是否包含 联赛数据
+                            if(empty($others_lg_id)){
+                                //无联赛数据 验证本地是否存在
+                                $ret_lg = commonFunction::ver_league($s_lg_id,$source,$lg_data);
+                                //联赛 不存在
+                                if($ret_lg == false) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
+                                $l_lg_id = $ret_lg;
+                            }else{
+                                //有联赛数据 验证属于同请求联赛
+                                if($s_lg_id != $others_lg_id) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
+                            }
+                            //如果是普通 赔率,则验证所属赛事
+                            if($odds_type == 0){
+                                //验证赛事记录是否已存在
+                                if(empty($others_match_id)){
+                                    //无赛事数据 验证本地是否存在
+                                    $ret_match = commonFunction::ver_match($s_match_id,$source,$match_data);
+                                    //赛事 不存在
+                                    if($ret_match == false) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::MATCH_ERROR));
+                                    $l_match_id = $ret_match;
+                                }else{
+                                    //有赛事数据 验证属于同请求赛事
+                                    if($s_match_id != $others_match_id) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::MATCH_ERROR));
+                                }
+                            }
+
+                            //验证赔率 是否存在
+                            $ret_odds = '';
+                            $ret_odds = commonFunction::ver_odds($sole,$source,$odds_data);
+                            //验证赔率记录 是否存在
+                            $ret_odds_record = '';
+                            $ret_odds_record = commonFunction::ver_odds_record($odds_only,$source,$odds_record_data);
+
+                            $this->odds($vv,$gameName,$l_lg_id,$l_match_id,$ret_odds,$ret_odds_record);
+                            break;
+                        case 'league_result'://联赛结果
+                            $this->league_result($vv);
+                            break;
+                        case 'match_result'://赛事结果
+                            throw new \Exception(Response::generate('赛事结果数据-match_result:',Response::AUTH_ERROR));
+                            $this->match_result($vv);
+                            break;
+                        case 'match_result_record'://赛事结果记录
+                            $s_lg_id = $vv['data']['lg_id'];
+                            $s_match_id = $vv['data']['match_id'];
+                            $source = $vv['data']['source'];
+                            //如果本次请求没有 联赛数据
+                            if(empty($others_lg_id)){
+                                //验证本地是否存在
+                                $ret_lg = commonFunction::ver_league($s_lg_id,$source,$lg_data);
+                                //联赛 不存在
+                                if($ret_lg == false) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
+                                $l_lg_id = $ret_lg;
+                            }else{
+                                //有联赛数据 验证属于同请求联赛
+                                if($s_lg_id != $others_lg_id) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$s_lg_id.';',Response::LEAGUE_ERROR));
+                            }
+                            //验证赛事记录是否已存在
+                            if(empty($others_match_id)){
+                                //无赛事数据 验证本地是否存在
+                                $ret_match = commonFunction::ver_match($s_match_id,$source,$match_data);
+                                //联赛 不存在
+                                if($ret_match == false) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::MATCH_ERROR));
+                                $l_match_id = $ret_match;
+                            }else{
+                                //有赛事数据 验证属于同请求赛事
+                                if($s_match_id != $others_match_id) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::MATCH_ERROR));
+                            }
+                            //处理 赛事结果 记录
+                            $this->com_result_record($vv,$gameName,$l_lg_id,$l_match_id);
+                            break;
+                        case 'odds_record'://赔率记录
+                            throw new \Exception(Response::generate('赔率记录数据-odds_record:',Response::AUTH_ERROR));
+                            $this->odds_record($vv);
+                            break;
+                        case 'broadcast'://直播数据
+                            $this->broadcast($vv,$game_code);
+                            break;
+                        default:
+                            throw new \Exception(Response::generate('',Response::ABNORMAL)) ;
+                    }
+                }
+            }
+            //提交事务
+            DB::commit();
+            return Response::success();
+        } catch (\Exception $e) {
+            //回滚事务
+            DB::rollBack();
+            return $e->getMessage();
+        }
+    }
+
+    /**
+     * @param Req $data
+     * @return string
+     * @throws \App\Lib\Biz\Sport\Exception
+     * 更新赛事状态
+     */
+    public function upMatch(Req $data){
+        try {
+            //开启事务
+            DB::beginTransaction();
+            //获取待更新赛事
+            $obt = $data->data;
+            if($obt){
+                //json转数组
+                $data = $this->getAddData($obt);
+                //获取所有数据源赛事 match_id
+                $others_match_ids = [];
+                foreach ($data as $k=>$v){
+                    $game_code = $v['game_code'];
+                    $source = $v['source'];
+                    $others_match_ids[] = $v['match_id'];
+                }
+                //根据球类代码 获取model
+                $model =commonFunction::getModels($game_code,1);
+                //获取所有赛事 match_id
+                $local_match = $model['model_local_match']::SELECT('others_match_id','match_id')
+                    ->where(['source'=>$source])
+                    ->whereIn('others_match_id',$others_match_ids)
+                    ->get()->toArray();
+                if(empty($local_match)) throw new \Exception(Response::generate('',Response::MATCHID_NULL));
+                //更新状态字段
+                $set_status = ['status'=>2];
+                foreach ($local_match as $k=>$v){
+                    $ret = $model['model_match']::where(['id'=>$v['match_id']])
+                        -> update($set_status);
+                    if($ret<1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$v['others_match_id'],Response::UPSTATUS_ERROR));
+                }
+            }
+            //提交事务
+            DB::commit();
+            return Response::success();
+        } catch (\Exception $e) {
+            //回滚事务
+            DB::rollBack();
+            return $e->getMessage();
+        }
+    }
+
+    //写入直播 数据
+    public function broadcast($opt = [],$game_code=''){
+        $data = $opt['data'];
+        $set_broadcast = [
+            "doing" => $data['doing'],
+		    "game_type" => $data['game_type'],
+            "game_code" => $game_code,
+            "guest_team" => $data['guest_team'],
+		    "host_team" => $data['host_team'],
+		    "league_name" => $data['league_name'],
+		    "shower" => $data['shower'],
+		    "showid" => (int)$data['showid'],
+            "start_time" => $data['start_time'],
+            "ctime" =>date('Y-m-d H:i:s'),
+            "utime" =>date('Y-m-d H:i:s'),
+        ];
+        $ret = broadcastModel::insert($set_broadcast);
+        if($ret == false) throw new \Exception(Response::generate('',Response::BROADCAST_ERROR));
+    }
+
+    //将进行中赛事写入 赛事结果
+    public function match_result($game_code = ''){
+        $model =commonFunction::getModels($game_code,1);
+        if($game_code == 'zq')  ZqResultModel::ZQresult($model);
+        if($game_code == 'lq')  LqResultModel::LQresult($model);
+        if($game_code == 'wq')  WqResultModel::WQresult($model);
+        if($game_code == 'bq')  BqResultModel::BQresult($model);
+    }
+    //写入地区数据 弃用
+    public function area($opt = []){
+        $ret = lm('st_area','Sports')->insert($opt);
+        return $ret;
+    }
+
+    //写入国家数据 弃用
+    public function country($opt = []){
+        $ret = lm('st_country','Sports')->insert($opt);
+        return $ret;
+    }
+
+    //写入联赛数据
+    public function league($opt = [],$gameName=''){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model =commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+//        if(empty($data['belong'])) throw new \Exception(Response::generate(Response::COUNTRY_ERROR)) ;//Render([], '10013', lang('Tips','Sports')->get('country_error'));
+//        //获取联赛所属 国家/地区id
+//        $belong = St_area_countryModel::getID($data['belong']);
+        $set_lg['area_id'] = 0;//$belong['area_id'];
+        $set_lg['country_id'] = 0;// $belong['country_id'];
+
+        //查询联赛是否已存在
+        $id = $model['model_league']::where('name_chinese','=',$data['name_chinese'])
+            ->value('id');
+        //默认获取本年最后一天
+        $last_time = date('Y-12-31 23:59:59');
+        //决赛时间
+        if($data['last_time']){
+            $last_time = $data['last_time'];
+        }
+        $set_lg['name_chinese'] = $data['name_chinese'];
+        $set_lg['kind'] = $data['kind'];
+        $set_lg['match_mode'] = $data['match_mode'];
+        $set_lg['if_stop'] = $data['if_stop'];
+        $set_lg['identity'] = $data['uuid'];
+        $set_lg['last_time'] = $last_time;
+        $set_lg['utime'] = date('Y-m-d H:i:s');
+        if(empty($id)){
+            //写入联赛
+            $id = $model['model_league']::insertGetId($set_lg);
+            $m_lg_id = $id;
+            if($m_lg_id < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::INSERT_ERROR));
+        }else{
+            //更新联赛
+            $ret = $model['model_league']::where(['id'=>$id])
+                -> update($set_lg);
+            if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::UPDATE_ERROR));
+        }
+
+        $set_local = [
+            'lg_id'=>$id,
+            'others_lg_id'=>$data['lg_id'],
+            'source'=>$data['source'],
+            'ctime'=>date('Y-m-d H:i:s')
+        ];
+        $ret = $model['model_local_league']::insertGetId($set_local);
+        if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LOCAL_LEAGUE_ERROR)) ;//Render([], '10017', lang('Tips','Sports')->get('local_league_error'));
+
+        //执行成功返回源数据 联赛ID
+        $data = ['others_lg_id'=>$data['lg_id'],'lg_id'=>$id];
+        return $data;
+    }
+
+    //写入赛事数据
+    public function competition($opt = [],$gameName='',$lg_id=''){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+        if(empty($data['lg_id'])) throw new \Exception(Response::generate('',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+
+        //查询赛事是否存在
+        $id = $model['model_match']::where(['home_team'=>$data['home_team'],'guest_team'=>$data['guest_team'],'match_date'=>$data['match_date'],'match_time'=>$data['match_time']])
+            ->value('id');
+
+        $half_match_id = 0;
+        //如果有上半场赛事id 获取上半场赛事是否存在
+        if(!empty($data['half_match_id'])){
+            $half_match_id = $match_id = $model['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$data['source']])
+                ->value('match_id');
+            if(empty($half_match_id)) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
+        }
+        //如果赛事没有开始日期,则为冠军盘口赛事
+        if(empty($data['match_date'])){
+            //冠军盘口赛事获取所属联赛结束时间
+            $last_time = $model['model_league']::where(['id'=>$lg_id])
+                ->value('last_time');
+
+            if(empty($last_time)) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LG_LASTTIME_ERROR)) ;//Render([], '10023', lang('Tips','Sports')->get('lg_lastTime_error'));
+            //给冠军盘口赛事 赋值时间
+            $time = strtotime($last_time);
+            $data['match_date'] = date('Y-m-d',$time);
+            $data['match_time'] = date('H:i:s',$time);
+        }
+        $set_match = [
+            'ctime'=>date('Y-m-d H:i:s'),
+            'utime'=>date('Y-m-d H:i:s'),
+            'expire_time'=>date('Y-m-d H:i:s',time()+60),
+            'home_team'=>$data['home_team']?:'',
+            'guest_team'=>$data['guest_team']?:'no_team',
+            'lg_id'=>$lg_id,
+            'status'=>$data['status'],
+            'match_date'=>$data['match_date']?:date('Y-m-d'),
+            'match_time'=>$data['match_time']?:date('H:i:s'),
+            'tag'=>$data['tag']?:0,
+            'is_rollball'=>$data['is_rollball']?:0,
+            'is_today'=>$data['is_today']?:0,
+            'is_morningplate'=>$data['is_morningplate']?:0,
+            'is_stringscene'=>$data['is_stringscene']?:0,
+            'us_time'=>$data['us_time']?:commonFunction::qgmdate('Y-m-d H:i:s', '', -4),
+            'half_match_id'=>$half_match_id?:0,
+            'identity' => $data['uuid'],
+        ];
+        //写入赛事
+        if(empty($id)){
+            //写入赛事 返回id
+            $id = $model['model_match']::insertGetId($set_match);
+            if($id < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::INSERT_ERROR)) ;
+        }else{
+            //更新赛事
+            $ret = $model['model_match']::where(['id'=>$id])->update($set_match);
+            if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::UPDATE_ERROR)) ;
+        }
+
+        //写关联记录
+        $set_local = [
+            'match_id'=>$id,
+            'others_match_id'=>$data['match_id'],
+            'source'=>$data['source'],
+            'ctime'=>date('Y-m-d H:i:s')
+        ];
+        $ret = $model['model_local_match']::insertGetId($set_local);
+        if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::LOCAL_MATCH_ERROR)) ;//Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
+
+        //返回 源数据 赛事ID
+        $data = ['others_match_id'=>$data['match_id'],'match_id'=>$id];
+        return $data;
+    }
+
+    //写入赔率数据
+    public function odds($opt=[],$gameName='',$lg_id=0,$match_id=0,$oddsID='',$oddsRecordID=''){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+
+        //获取赛事 本地/源ID
+        $others_match_id = $data['match_id'];
+
+        //获取联赛 本地/源ID
+        $others_lg_id = $data['lg_id'];
+        //===写赔率记录===
+        $set_odds_r = [
+            'match_id'=> $match_id?:0,
+            'others_match_id'=> $others_match_id?:0,
+            'odds_code'=> $data['odds_code']?:'',
+            'status'=> $data['status']?:0,
+            'sort'=> $data['sort']?:0,
+            'p_code'=> $data['p_code']?:'',
+            'odds'=> $data['odds']?:0,
+            'condition'=> $data['condition'],
+            'odds_only'=> $data['odds_only']?:'',
+            'source'=> $data['source']?:'',
+            'type'=> $data['type']?:0,
+            'team'=> $data['team']?:'',
+            'lg_id'=> $lg_id,
+            'others_lg_id'=> $others_lg_id,
+            'ctime'=> date('Y-m-d H:i:s'),
+        ];
+        //更新或写入赔率记录
+        if($oddsRecordID != false){
+            $ret = $model['model_odds_record']::where(['id'=>$oddsRecordID])
+                -> update($set_odds_r);
+            if($ret < 1) throw new \Exception(Response::generate($gameName.'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR)) ;//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
+        }else{
+            $ret = $model['model_odds_record']::insert($set_odds_r);
+            if($ret != true) throw new \Exception(Response::generate($gameName.'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR));//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
+        }
+
+        //===写赔率===
+        $set_odds = [
+            'match_id'=> $match_id?:0,
+            'others_match_id'=> $others_match_id?:0,
+            'odds_code'=> $data['odds_code']?:'',
+            'status'=> $data['status']?:0,
+            'sort'=> $data['sort']?:0,
+            'p_code'=> $data['p_code']?:'',
+            'odds'=> $data['odds']?:0,
+            'condition'=> $data['condition'],
+            'odds_only'=> $data['odds_only']?:'',
+            'sole'=> $data['sole']?:'',
+            'source'=> $data['source']?:'',
+            'type'=> $data['type']?:0,
+            'team'=> $data['team']?:'',
+            'lg_id'=> $lg_id,
+            'others_lg_id'=> $others_lg_id,
+            'ctime'=> date('Y-m-d H:i:s'),
+            'utime'=> date('Y-m-d H:i:s'),
+            'expire_time'=>date('Y-m-d H:i:s',time()+60),
+        ];
+        //更新或写入赔率数据
+        if($oddsID != false){
+            $ret = $model['model_odds']::where(['id'=>$oddsID])
+                -> update($set_odds);
+            if($ret < 1) throw new \Exception(Response::generate($gameName.'赔率-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_ERROR));//Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
+        }else{
+            $ret = $model['model_odds']::insert($set_odds);
+            if($ret != true) throw new \Exception(Response::generate($gameName.'赔率-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_ERROR));//Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
+        }
+        //===end===
+    }
+
+    //写入联赛结果
+    public function league_result($opt){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+
+        //验证结果所属联赛
+        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->value('lg_id');
+        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR));//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+
+        $lg_result_id = $model['model_league_result']::where(['lg_id'=>$lg_id,'game_name'=>$data['game_name']])
+            ->value('id');
+        $set_lg_result = [
+            'lg_id'=>$lg_id,
+            'game_name'=>$data['game_name'],
+            'result'=>json_encode($data['result'],JSON_UNESCAPED_UNICODE),
+            'status'=>$data['status'],
+            'ctime'=> date('Y-m-d H:i:s'),
+            'utime'=> date('Y-m-d H:i:s'),
+        ];
+        //联赛结果数据处理
+        if(!empty($lg_result_id)){
+            $ret = $model['model_league_result']::where(['id'=>$lg_result_id])
+                -> update($set_lg_result);
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR)) ;//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
+        }else{
+            $ret = $model['model_league_result']::insert($set_lg_result);
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR));//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
+        }
+//        return Response::success();
+    }
+
+    //写入赛事结果
+    public function com_result($opt=[],$gameName='',$lg_id='',$match_id=''){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+//        //验证结果所属联赛
+//        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+//            ->value('lg_id');
+//        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+//        //验证结果所属赛事
+//        $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
+//            ->value('match_id');
+//        if($match_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
+        //查询结果是否存在
+        $match_r_id = $model['model_result']::where(['match_id'=>$match_id])
+            ->value('id');
+
+        $set_match_r = [
+            "home_team"=>$data['home_team'],
+            "guest_team"=>$data['guest_team'],
+            "lg_id"=>$lg_id,
+            "home_rate"=> $data['home_rate'],
+            "guest_rate"=> $data['guest_rate'],
+            "home_score"=> $data['home_score'],
+            "guest_score"=> $data['guest_score'],
+            "all_goal"=> $data['all_goal'],
+            "status"=>$data['status'],
+            "first_score"=>$data['first_score'],
+            "last_score"=> $data['last_score'],
+            "match_score"=> $data['match_score'],
+            "match_winer"=> $data['match_winer'],
+            "match_time"=> $data['match_time'],
+            "match_process"=> $data['match_process'],
+            "tag"=> $data['tag'],
+            "match_id"=> $match_id,
+            "u_home_score"=> $data['u_home_score'],
+            "u_guest_score"=> $data['u_guest_score'],
+            "p_code"=> $data['p_code'],
+            "update_time"=>date('Y-m-d H:i:s')
+        ];
+        //赛事结果数据处理
+        if(!empty($match_r_id)){
+            $ret = $model['model_result']::where(['id'=>$match_r_id])
+                -> update($set_match_r);
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
+        }else{
+            $ret = $model['model_result']::insert($set_match_r);
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
+        }
+//        return Response::success();
+    }
+
+    //写入赛事结果记录
+    public function com_result_record($opt=[],$gameName='',$lg_id='',$match_id=''){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+
+        //验证结果所属联赛
+//        $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+//            ->value('lg_id');
+//        if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+//        //验证结果所属赛事
+//        $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
+//            ->value('match_id');
+//        if($match_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
+
+        $match_r_id = $model['model_result_record']::where(['match_id'=>$match_id,'match_time'=>$data['match_time']])
+            ->value('id');
+        //根据球类 获取 赛事结果记录字段
+        $set_match_r = $this->get_match_r($game_code,$lg_id,$match_id,$data);
+
+        //赛事结果记录处理
+        if($match_r_id > 0){
+            $ret = $model['model_result_record']::where(['id'=>$match_r_id])
+                ->update($set_match_r);
+            if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
+        }else{
+            $ret = $model['model_result_record']::insert($set_match_r);
+            if($ret != true) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_R_ERROR));//Render([], '10022', lang('Tips','Sports')->get('add_match_r_r_error'));
+        }
+    }
+
+    //写入赔率记录
+    public function odds_record($opt){
+        $game_code = $opt['game_code'];
+        //根据球类代码获取相关model
+        $model = commonFunction::getModels($game_code,1);
+        $data = $opt['data'];
+
+        $match = $model['model_local_match']::select('match_id','others_match_id')
+            ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
+            ->first();
+        if(count($match) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR)) ;//Render([], '10016', lang('Tips','Sports')->get('match_error'));
+
+        //获取赛事 本地/源ID
+        $others_match_id = $match->others_match_id;
+        $match_id = $match->match_id;
+
+        $lg = $model['model_local_league']::select('lg_id','others_lg_id')
+            ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
+            ->first();
+        if(count($lg) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
+
+        //获取联赛 本地/源ID
+        $others_lg_id = $lg->others_lg_id;
+        $lg_id = $lg->lg_id;
+        //查询 赔率数据是否存在
+        $oddsID = $model['model_odds_record']::where(['odds_only'=>$data['odds_only']])
+            ->value('id');
+
+        $set_odds = [
+            'match_id'=> $match_id,
+            'others_match_id'=> $others_match_id,
+            'odds_code'=> $data['odds_code'],
+            'status'=> $data['status'],
+            'sort'=> $data['sort'],
+            'p_code'=> $data['p_code'],
+            'odds'=> $data['odds'],
+            'condition'=> $data['condition'],
+            'odds_only'=> $data['odds_only'],
+            'source'=> $data['source'],
+            'type'=> $data['type'],
+            'team'=> $data['team'],
+            'lg_id'=> $lg_id,
+            'others_lg_id'=> $others_lg_id,
+            'ctime'=> date('Y-m-d H:i:s'),
+            'utime'=> date('Y-m-d H:i:s'),
+        ];
+        //更新或写入赔率记录
+        if(!empty($oddsID)){
+            $ret = $model['model_odds_record']::where(['id'=>$oddsID])
+                -> update($set_odds);
+            if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR)) ;//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
+        }else{
+            $ret = $model['model_odds_record']::insert($set_odds);
+            if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR));//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
+        }
+//        return Response::success();
+    }
+
+    /**
+     * @param $data
+     * @return mixed
+     * json转数组
+     */
+    public function getAddData($data){
+
+        $data = json_decode($data,true);
+
+        return $data;
+    }
+
+    //根据球类获取 赛事结果记录字段
+    public function get_match_r($game_code,$lg_id,$match_id,$data){
+        $set_match_r = [];
+        if($game_code == 'zq'){
+            $set_match_r = [
+                "home_team"=>$data['home_team']?:'',
+                "guest_team"=>$data['guest_team']?:'',
+                "lg_id"=>$lg_id,
+                "all_goal"=>$data['all_goal']?:0,
+                "home_rate"=> $data['home_rate']?:0,
+                "guest_rate"=> $data['guest_rate']?:0,
+                "home_score"=> $data['home_score']?:0,
+                "guest_score"=> $data['guest_score']?:0,
+                "status"=>$data['status']?:0,
+                "first_score"=>$data['first_score']?:0,
+                "last_score"=> $data['last_score']?:0,
+                "match_score"=> $data['match_score']?:0,
+                "match_winer"=> $data['match_winer']?:'',
+                "match_time"=> $data['match_time']?:0,
+                "match_process"=> $data['match_process']?:'',
+                "tag"=> $data['tag']?:0,
+                "match_id"=> $match_id,
+                "update_time"=>date('Y-m-d H:i:s')
+            ];
+        };
+        if($game_code == 'lq'){
+            $set_match_r = [
+                "home_team"=>$data['home_team']?:'',
+                "guest_team"=>$data['guest_team']?:'',
+                "lg_id"=>$lg_id,
+                "home_rate"=> $data['home_rate']?:0,
+                "guest_rate"=> $data['guest_rate']?:0,
+                "home_score"=> $data['home_score']?:0,
+                "guest_score"=> $data['guest_score']?:0,
+                "status"=>$data['status']?:0,
+                "first_score"=>$data['first_score']?:0,
+                "last_score"=> $data['last_score']?:0,
+                "match_score"=> $data['match_score']?:0,
+                "match_winer"=> $data['match_winer']?:'',
+                "match_time"=> $data['match_time']?:0,
+                "match_process"=> $data['match_process']?:'',
+                "tag"=> $data['tag']?:0,
+                "match_id"=> $match_id,
+                "update_time"=>date('Y-m-d H:i:s')
+            ];
+        }
+        if($game_code == 'wq'){
+            $set_match_r = [
+                "home_player_name"=>$data['home_player_name']?:'',
+                "guest_player_name"=>$data['guest_player_name']?:'',
+                "lg_id"=>$lg_id,
+                "home_player_let_plate"=>$data['home_player_let_plate']?:0,
+                "guest_player_let_plate"=>$data['guest_player_let_plate']?:0,
+                "home_player_let_inning"=>$data['home_player_let_inning']?:0,
+                "guest_player_let_inning"=>$data['guest_player_let_inning']?:0,
+                "all_inning"=>$data['all_inning']?:0,
+                "home_player_score"=>$data['home_player_score']?:0,
+                "guest_player_score"=>$data['guest_player_score']?:0,
+                "status"=>$data['status']?:0,
+                "first_score_player"=>$data['first_score_player']?:'',
+                "last_score_player"=>$data['last_score_player']?:'',
+                "first_inning_score"=>$data['first_inning_score']?:0,
+                "second_inning_score"=>$data['second_inning_score']?:0,
+                "third_inning_score"=>$data['third_inning_score']?:0,
+                "match_winer_player"=>$data['match_winer_player']?:'',
+                "update_time"=>date('Y-m-d H:i:s'),
+                "match_time"=>$data['match_time']?:0,
+                "match_process"=>$data['match_process']?:'',
+                "tag"=>$data['tag']?:0,
+                "match_id"=>$match_id,
+                "result_mark" =>$data['result_mark']?:'',
+            ];
+        }
+        if($game_code == 'bq'){
+            $set_match_r = [
+                "home_team"=>$data['home_team']?:'',
+                "guest_team"=>$data['guest_team']?:'',
+                "lg_id"=>$lg_id,
+                "home_rate"=> $data['home_rate']?:0,
+                "guest_rate"=> $data['guest_rate']?:0,
+                "home_score"=> $data['home_score']?:0,
+                "guest_score"=> $data['guest_score']?:0,
+                "status"=>$data['status']?:0,
+                "first_score"=>$data['first_score']?:0,
+                "last_score"=> $data['last_score']?:0,
+                "match_score"=> $data['match_score']?:0,
+                "match_winer"=> $data['match_winer']?:'',
+                "match_time"=> $data['match_time']?:0,
+                "match_process"=> $data['match_process']?:'',
+                "tag"=> $data['tag']?:0,
+                "match_id"=> $match_id,
+                "all_inning"=>$data['all_inning']?:9,
+                "update_time"=>date('Y-m-d H:i:s'),
+                "result_mark" =>$data['result_mark']?:'',
+            ];
+        }
+
+        return $set_match_r;
+    }
+}

+ 32 - 0
app/Http/Controllers/Auth/ForgotPasswordController.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
+
+class ForgotPasswordController extends Controller
+{
+    /*
+    |--------------------------------------------------------------------------
+    | Password Reset Controller
+    |--------------------------------------------------------------------------
+    |
+    | This controller is responsible for handling password reset emails and
+    | includes a trait which assists in sending these notifications from
+    | your application to your users. Feel free to explore this trait.
+    |
+    */
+
+    use SendsPasswordResetEmails;
+
+    /**
+     * Create a new controller instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        $this->middleware('guest');
+    }
+}

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác