Skip to content

Commit

Permalink
Snapshot 2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Tai7sy-Mac committed Jul 9, 2019
0 parents commit f498cb1
Show file tree
Hide file tree
Showing 347 changed files with 15,241 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

DB_CONNECTION=mysql
DB_HOST=数据库地址
DB_PORT=数据库端口
DB_DATABASE=数据库名称
DB_USERNAME=用户名
DB_PASSWORD=密码


# 下面配置无需修改
APP_ENV=local
APP_KEY=
APP_DEBUG=false
APP_LOG_LEVEL=error
APP_LOG=daily

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.env
/database/seeds/MyPayTableSeeder.php
.phpstorm.meta.php
_ide_helper*
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"2.8","md5":"734c79b5b39f298efbc7fba546e6c0fa","url":"https:\/\/github.com\/Tai7sy\/card-system\/releases\/download\/2.8\/card_release.tar.gz"}
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

### 关于

> 当前版本: 2.8
> [安装教程 V2.X](https://github.com/Tai7sy/card-system/wiki/BT%E9%9D%A2%E6%9D%BF%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B---V2.X)
> [更新教程 V2.X](https://github.com/Tai7sy/card-system/wiki/V2.X-%E6%9B%B4%E6%96%B0%E6%95%99%E7%A8%8B)
> 广告: 商业版 [http://demo.fakaxitong.com/](http://demo.fakaxitong.com/)
### 常见问题
- 修改 `.env` 文件无效 / 修改网站设置无效
```
cd /www/wwwroot/example.com #进入网站目录
php artisan config:clear
php artisan cache:clear
```
- 忘记密码后重置
```
cd /www/wwwroot/example.com #进入网站目录
php artisan reset:password [email protected] 123456
```
- 500错误
```
storage/logs 里面有错误详细内容, 可以自行参考解决, 或者附录log文件提交issue/mail
```
2 changes: 2 additions & 0 deletions app/Card.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\DB; class Card extends Model { protected $guarded = array(); use SoftDeletes; protected $dates = array('deleted_at'); const STATUS_NORMAL = 0; const STATUS_SOLD = 1; const STATUS_USED = 2; const TYPE_ONETIME = 0; const TYPE_REPEAT = 1; function orders() { return $this->hasMany(Order::class); } function product() { return $this->belongsTo(Product::class); } public static function add_cards($spfaef2f, $spad8100, $spdc3fe5, $spc3ee59, $sp28982f, $sp425ca9) { DB::statement('call add_cards(?,?,?,?,?,?)', array($spfaef2f, $spad8100, $spdc3fe5, $spc3ee59, $sp28982f, (int) $sp425ca9)); } public static function _trash($spe440a8) { DB::transaction(function () use($spe440a8) { $sp822fce = clone $spe440a8; $sp822fce->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($speab77e) { foreach ($speab77e as $sp9bfdd7) { $spaeec37 = \App\Product::where('id', $sp9bfdd7->product_id)->lockForUpdate()->first(); if ($spaeec37) { $spaeec37->count_all -= $sp9bfdd7->count_left; $spaeec37->saveOrFail(); } } }); $spe440a8->delete(); return true; }); } public static function _restore($spe440a8) { DB::transaction(function () use($spe440a8) { $sp822fce = clone $spe440a8; $sp822fce->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($speab77e) { foreach ($speab77e as $sp9bfdd7) { $spaeec37 = \App\Product::where('id', $sp9bfdd7->product_id)->lockForUpdate()->first(); if ($spaeec37) { $spaeec37->count_all += $sp9bfdd7->count_left; $spaeec37->saveOrFail(); } } }); $spe440a8->restore(); return true; }); } }
2 changes: 2 additions & 0 deletions app/CardOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
namespace App; use Illuminate\Database\Eloquent\Model; class CardOrder extends Model { protected $table = 'card_order'; public $timestamps = false; function order() { return $this->belongsTo(Order::class); } function card() { return $this->belongsTo(Card::class)->withTrashed(); } }
2 changes: 2 additions & 0 deletions app/Category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
namespace App; use App\Library\Helper; use Illuminate\Database\Eloquent\Model; class Category extends Model { protected $guarded = array(); function getUrlAttribute() { return config('app.url') . '/c/' . Helper::id_encode($this->id, Helper::ID_TYPE_CATEGORY); } function products() { return $this->hasMany(Product::class); } function user() { return $this->belongsTo(User::class); } function getTmpPassword() { return md5('$wGgMd45Jgi@dBDR' . $this->password . '1#DS2%!VLqJolmMD'); } function getProductsForShop() { $sp1cba4d = Product::where('category_id', $this->id)->where('enabled', 1)->orderBy('sort')->get(); foreach ($sp1cba4d as $spaeec37) { $spaeec37->setForShop($this->user); } $this->addVisible(array('products')); $this->setAttribute('products', $sp1cba4d); return $sp1cba4d; } }
4 changes: 4 additions & 0 deletions app/Console/Commands/ResetPassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
namespace App\Console\Commands; use Illuminate\Console\Command; class ResetPassword extends Command { protected $signature = 'reset:password {email} {password}'; protected $description = 'Reset the password of user
Usage: php artisan reset:password [email protected]'; public function __construct() { parent::__construct(); } public function handle() { $spd6b98d = $this->argument('email'); if (!$spd6b98d) { $this->warn('please input the user\'s email
'); return false; } $sp694bd2 = \App\User::where('email', $spd6b98d)->first(); if (!$sp694bd2) { $this->warn("can't find the user: {$spd6b98d} \nplease input the user's email\n"); return false; } $spb07b5d = $this->argument('password'); $sp694bd2->password = bcrypt($spb07b5d); $sp694bd2->save(); $this->info("the password of '{$spd6b98d}' has been set to {$spb07b5d}\n"); return true; } }
12 changes: 12 additions & 0 deletions app/Console/Commands/Update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace App\Console\Commands; use App\Library\CurlRequest; use function DeepCopy\deep_copy; use Illuminate\Console\Command; use Illuminate\Support\Str; class Update extends Command { protected $signature = 'update'; protected $description = 'check update'; public function __construct() { parent::__construct(); } private function download_progress($sp3ae187, $sp89a419) { $sp82a428 = fopen($sp89a419, 'w+'); if (!$sp82a428) { return false; } $sp4e752c = curl_init(); curl_setopt($sp4e752c, CURLOPT_URL, $sp3ae187); curl_setopt($sp4e752c, CURLOPT_FOLLOWLOCATION, true); curl_setopt($sp4e752c, CURLOPT_RETURNTRANSFER, true); curl_setopt($sp4e752c, CURLOPT_FILE, $sp82a428); curl_setopt($sp4e752c, CURLOPT_PROGRESSFUNCTION, function ($sp0571b4, $sp63dbe3, $sp67476b, $sp0958df, $sp0dc2bb) { if ($sp63dbe3 > 0) { echo ' download: ' . sprintf('%.2f', $sp67476b / $sp63dbe3 * 100) . '%'; } }); curl_setopt($sp4e752c, CURLOPT_NOPROGRESS, false); curl_setopt($sp4e752c, CURLOPT_HEADER, 0); curl_setopt($sp4e752c, CURLOPT_USERAGENT, 'card update'); curl_exec($sp4e752c); curl_close($sp4e752c); echo '
'; return true; } public function handle() { set_time_limit(0); \Artisan::call('cache:clear'); \Artisan::call('config:clear'); echo '
'; $this->comment('检查更新中...'); $this->info('当前版本: ' . config('app.version')); $sp48d343 = @json_decode(CurlRequest::get('https://github.com/Tai7sy/card-system/blob/master/.version'), true); if (!@$sp48d343['data']['version']) { $this->warn('检查更新失败!'); $this->warn('Error: ' . ((@$sp48d343['message'] ?? $sp48d343) ?? 'Network error')); goto LABEL_EXIT; } $sp48d343 = $sp48d343['data']; if (config('app.version') >= $sp48d343['version']) { $this->comment('您的版本已是最新!'); goto LABEL_EXIT; } $this->info('最新版本: ' . $sp48d343['version']); $this->info('版本说明: ' . (@$sp48d343['description'] ?? '')); $sp7e8ab7 = strtolower($this->ask('是否现在更新 (yes/no)', 'no')); if ($sp7e8ab7 !== 'yes') { goto LABEL_EXIT; } $spcdad27 = realpath(sys_get_temp_dir()); if (strlen($spcdad27) < 3) { $this->warn('获取临时目录失败!'); goto LABEL_EXIT; } $spcdad27 .= DIRECTORY_SEPARATOR . Str::random(16); if (!mkdir($spcdad27) || !is_writable($spcdad27) || !is_readable($spcdad27)) { $this->warn('临时目录不可读写!'); goto LABEL_EXIT; } if (!function_exists('exec')) { $this->warn('函数 exec 已被禁用, 无法继续更新!'); goto LABEL_EXIT; } if (PHP_OS === 'WINNT') { $sp4eb5ef = 'C:\\Program Files\\7-Zip\\7z.exe'; if (!is_file($sp4eb5ef)) { $sp4eb5ef = strtolower($this->ask('未找到7-Zip, 请手动输入7zG.exe路径', $sp4eb5ef)); } if (!is_file($sp4eb5ef)) { $this->warn('7-Zip不可用, 请安装7-Zip后重试'); goto LABEL_EXIT; } $sp4eb5ef = '"' . $sp4eb5ef . '"'; } else { exec('tar --version', $sp245564, $spdf727a); if ($spdf727a) { $this->warn('Error: tar --version
' . join('
', $sp245564)); goto LABEL_EXIT; } } $this->comment('正在下载新版本...'); $sp89a419 = $spcdad27 . DIRECTORY_SEPARATOR . 'ka_update_' . Str::random(16) . '.tmp'; if (!$this->download_progress($sp48d343['url'], $sp89a419)) { $this->warn('写入临时文件失败!'); goto LABEL_EXIT; } $sp318f05 = md5_file($sp89a419); if ($sp318f05 !== $sp48d343['md5']) { $this->warn('更新文件md5校验失败!, file:' . $sp318f05 . ', require:' . $sp48d343['md5']); goto LABEL_EXIT; } $this->comment('正在解压...'); unset($sp245564); if (PHP_OS === 'WINNT') { exec("{$sp4eb5ef} x -so {$sp89a419} | {$sp4eb5ef} x -aoa -si -ttar -o{$spcdad27}", $sp245564, $spdf727a); } else { exec("tar -zxf {$sp89a419} -C {$spcdad27}", $sp245564, $spdf727a); } if ($spdf727a) { $this->warn('Error: 解压失败
' . join('
', $sp245564)); goto LABEL_EXIT; } $this->comment('正在关闭主站...'); \Artisan::call('down'); sleep(5); $this->comment(' --> 正在清理旧文件...'); $sp447462 = base_path(); foreach (array('app', 'bootstrap', 'config', 'public/dist', 'database', 'routes', 'vendor') as $spd55287) { \File::deleteDirectory($sp447462 . DIRECTORY_SEPARATOR . $spd55287); } $this->comment(' --> 正在复制新文件...'); \File::copyDirectory($spcdad27 . DIRECTORY_SEPARATOR . 'card_dist', $sp447462); $this->comment(' --> 正在创建缓存...'); \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); $this->comment(' --> 正在更新数据库...'); \Artisan::call('migrate'); if (PHP_OS === 'WINNT') { echo '
'; $this->alert('请注意手动设置目录权限'); $this->comment(' storage 可读可写 '); $this->comment(' bootstrap/cache/ 可读可写 '); echo '
'; } else { $this->comment(' --> 正在设置目录权限...'); exec('rm -rf storage/framework/cache/data/*'); exec('chmod -R 777 storage/'); exec('chmod -R 777 bootstrap/cache/'); } $this->comment('正在启用主站...'); \Artisan::call('up'); \Artisan::call('queue:restart'); $sp7d0ad5 = true; LABEL_EXIT: if (isset($spcdad27) && strlen($spcdad27) > 19) { $this->comment('清理临时目录...'); \File::deleteDirectory($spcdad27); } if (isset($sp7d0ad5) && $sp7d0ad5) { $this->info('更新成功!'); } if (PHP_OS === 'WINNT') { } else { exec('rm -rf storage/framework/cache/data/*'); exec('chmod -R 777 storage/'); exec('chmod -R 777 bootstrap/cache/'); } echo '
'; die; } }
Expand Down
4 changes: 4 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
namespace App\Console; use App\System; use Carbon\Carbon; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Schema; class Kernel extends ConsoleKernel { protected $commands = array(); protected function schedule(Schedule $spba8a1c) { if (!app()->runningInConsole()) { return; } if (System::_getInt('order_clean_unpay_open') === 1) { $sp135b94 = System::_getInt('order_clean_unpay_day', 7); $spba8a1c->call(function () use($sp135b94) { echo '[' . date('Y-m-d H:i:s') . "] cleaning unpaid orders({$sp135b94} days ago)...\n"; \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new Carbon())->addDays(-$sp135b94))->delete(); $sp06fc7d = '[' . date('Y-m-d H:i:s') . '] unpaid-orders cleaned
'; echo $sp06fc7d; })->dailyAt('01:00'); } $spba8a1c->call(function () { $sp135b94 = 7; echo '[' . date('Y-m-d H:i:s') . "] cleaning deleted cards({$sp135b94} days ago)...\n"; \App\Card::onlyTrashed()->where('deleted_at', '<', (new Carbon())->addDays(-$sp135b94))->forceDelete(); $sp06fc7d = '[' . date('Y-m-d H:i:s') . '] deleted-cards cleaned
'; echo $sp06fc7d; })->dailyAt('02:00'); } protected function commands() { $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } }
2 changes: 2 additions & 0 deletions app/Coupon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
namespace App; use Illuminate\Database\Eloquent\Model; class Coupon extends Model { protected $guarded = array(); const STATUS_NORMAL = 0; const STATUS_USED = 2; const TYPE_ONETIME = 0; const TYPE_REPEAT = 1; const DISCOUNT_TYPE_AMOUNT = 0; const DISCOUNT_TYPE_PERCENT = 1; function product() { return $this->belongsTo(Product::class); } function category() { return $this->belongsTo(Category::class); } }
2 changes: 2 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
namespace App\Exceptions; use App\Library\Response; use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Support\Facades\Log; class Handler extends ExceptionHandler { protected $dontReport = array(); protected $dontFlash = array('password', 'password_confirmation'); public function report(Exception $sp8f27c2) { parent::report($sp8f27c2); } private function msg($spd5cc4d, $sp06fc7d, $spc3ee59) { return $spd5cc4d->isXmlHttpRequest() ? response()->json(array('message' => $sp06fc7d), $spc3ee59) : response()->view('errors._', array('code' => $spc3ee59, 'message' => $sp06fc7d), $spc3ee59); } public function render($spd5cc4d, Exception $spece20f) { if ($spece20f instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { return $this->msg($spd5cc4d, '记录未找到', 404); } elseif ($spece20f instanceof \Illuminate\Auth\AuthenticationException) { return $this->msg($spd5cc4d, '您需要登录您的账户再进行此操作', 401); } elseif ($spece20f instanceof \Illuminate\Auth\Access\AuthorizationException) { return $this->msg($spd5cc4d, '未授权的操作', 403); } elseif ($spece20f instanceof \Illuminate\Validation\ValidationException) { return parent::render($spd5cc4d, $spece20f); } elseif ($spece20f instanceof \Illuminate\Session\TokenMismatchException) { return $this->msg($spd5cc4d, '请刷新页面后重试', 403); } elseif ($spece20f instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return $this->msg($spd5cc4d, '页面未找到', 404); } elseif ($spece20f instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) { return $this->msg($spd5cc4d, '请求方法不允许', 405); } elseif ($spece20f instanceof \Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException) { Log::error('Caught a ServiceUnavailableHttpException', array('Exception' => $spece20f)); return $this->msg($spd5cc4d, '当前服务不可用,请稍后重试', 503); } elseif ($spece20f instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { $sp6f36ad = $spd5cc4d->isXmlHttpRequest(); switch ($sp6f36ad) { case 429: return $this->msg($spd5cc4d, '您的请求过于频繁,请稍后重试', $sp6f36ad); break; default: Log::error('Caught a UnknownHttpException', array('Exception' => $spece20f)); return $this->msg($spd5cc4d, '当前服务不可用,请稍后重试', $sp6f36ad); } } Log::error('Uncaught Exception', array('Exception' => $spece20f)); if (config('app.debug')) { return parent::render($spd5cc4d, $spece20f); } else { return $this->msg($spd5cc4d, '未知错误,请查看错误日志(storage/logs)', 500); } } }
2 changes: 2 additions & 0 deletions app/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
namespace App; use Illuminate\Database\Eloquent\Model; class File extends Model { protected $guarded = array(); public $timestamps = false; function deleteFile() { try { Storage::disk($this->driver)->delete($this->path); } catch (\Exception $spece20f) { \Log::error('File.deleteFile Error: ' . $spece20f->getMessage(), array('exception' => $spece20f)); } } public static function getProductFolder() { return 'images/product'; } }
2 changes: 2 additions & 0 deletions app/FundRecord.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
namespace App; use Illuminate\Database\Eloquent\Model; class FundRecord extends Model { protected $guarded = array(); const TYPE_IN = 1; const TYPE_OUT = 2; function order() { return $this->belongsTo(Order::class); } }
2 changes: 2 additions & 0 deletions app/Http/Controllers/Admin/Dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
namespace App\Http\Controllers\Admin; use App\Library\CurlRequest; use App\Library\Response; use App\Order; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class Dashboard extends Controller { function index(Request $spd5cc4d) { $sp5bd36e = array('today' => array('count' => 0, 'paid' => 0, 'profit' => 0), 'yesterday' => array('count' => 0, 'paid' => 0, 'profit' => 0)); $spf69415 = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::now()->toDateString())->where(function ($spe440a8) { $spe440a8->where('status', Order::STATUS_PAID)->orWhere('status', Order::STATUS_SUCCESS); })->selectRaw('COUNT(*) as `count`,SUM(`paid`) as `paid`,SUM(`paid`-`sms_price`-`cost`-`fee`) as `profit`')->get()->toArray(); $spb33a22 = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::yesterday()->toDateString())->where(function ($spe440a8) { $spe440a8->where('status', Order::STATUS_PAID)->orWhere('status', Order::STATUS_SUCCESS); })->selectRaw('COUNT(*) as `count`,SUM(`paid`) as `paid`,SUM(`paid`-`sms_price`-`cost`-`fee`) as `profit`')->get()->toArray(); if (isset($spf69415[0]) && isset($spf69415[0]['count'])) { $sp5bd36e['today'] = array('count' => (int) $spf69415[0]['count'], 'paid' => (int) $spf69415[0]['paid'], 'profit' => (int) $spf69415[0]['profit']); } if (isset($spb33a22[0]) && isset($spb33a22[0]['count'])) { $sp5bd36e['yesterday'] = array('count' => (int) $spb33a22[0]['count'], 'paid' => (int) $spb33a22[0]['paid'], 'profit' => (int) $spb33a22[0]['profit']); } $sp5bd36e['need_ship_count'] = Order::whereUserId(\Auth::Id())->where('status', Order::STATUS_PAID)->count(); $sp5bd36e['login'] = \App\Log::where('action', \App\Log::ACTION_LOGIN)->latest()->firstOrFail(); return Response::success($sp5bd36e); } function clearCache() { if (function_exists('opcache_reset')) { opcache_reset(); } try { \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); } catch (\Throwable $spece20f) { return Response::fail($spece20f->getMessage()); } return Response::success(); } function version() { return Response::success(array('version' => config('app.version'))); } function checkUpdate() { return Response::success(@json_decode(CurlRequest::get('https://github.com/Tai7sy/card-system/blob/master/.version'), true)); } }
Loading

0 comments on commit f498cb1

Please sign in to comment.