diff --git a/.version b/.version index 0f523f614..428126bda 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -{"version":"2.95d","md5":"cf8a824cd66355708365e42b644a22ac","url":"https:\/\/github.com\/Tai7sy\/card-system\/releases\/download\/2.95\/card_release.tar.gz"} \ No newline at end of file +{"version":"2.95d","md5":"2451129b92d3e083db53a53494e61521","url":"https:\/\/github.com\/Tai7sy\/card-system\/releases\/download\/2.95d\/card_release.tar.gz"} \ No newline at end of file diff --git a/README.md b/README.md index 4ec8e64a6..9f751567b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### 关于 -> 当前版本: 2.95d +> 当前版本: 2.95d > 支付网关: [card-gateway](https://github.com/Tai7sy/card-gateway) diff --git a/app/Card.php b/app/Card.php index 8ade74ef9..3655218a8 100644 --- a/app/Card.php +++ b/app/Card.php @@ -1,2 +1,2 @@ hasMany(Order::class); } function product() { return $this->belongsTo(Product::class); } function getCountAttribute() { return $this->count_all - $this->count_sold; } public static function add_cards($sp258cf6, $sp112a12, $sp460df4, $spf66c3d, $sp7c8ced, $sp46a9f0) { DB::statement('call add_cards(?,?,?,?,?,?)', array($sp258cf6, $sp112a12, $sp460df4, $spf66c3d, $sp7c8ced, (int) $sp46a9f0)); } public static function _trash($sp7e6fa3) { DB::transaction(function () use($sp7e6fa3) { $spf10bec = clone $sp7e6fa3; $spf10bec->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp5b0739) { foreach ($sp5b0739 as $sp1d0a77) { $sp1a3ec5 = \App\Product::where('id', $sp1d0a77->product_id)->lockForUpdate()->first(); if ($sp1a3ec5) { $sp1a3ec5->count_all -= $sp1d0a77->count_left; $sp1a3ec5->saveOrFail(); } } }); $sp7e6fa3->delete(); return true; }); } public static function _restore($sp7e6fa3) { DB::transaction(function () use($sp7e6fa3) { $spf10bec = clone $sp7e6fa3; $spf10bec->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp5b0739) { foreach ($sp5b0739 as $sp1d0a77) { $sp1a3ec5 = \App\Product::where('id', $sp1d0a77->product_id)->lockForUpdate()->first(); if ($sp1a3ec5) { $sp1a3ec5->count_all += $sp1d0a77->count_left; $sp1a3ec5->saveOrFail(); } } }); $sp7e6fa3->restore(); return true; }); } } \ No newline at end of file +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); } function getCountAttribute() { return $this->count_all - $this->count_sold; } public static function add_cards($spf5ae13, $sp1b83a8, $spe7b1c7, $sp732cf7, $spb73662, $spd3d838) { DB::statement('call add_cards(?,?,?,?,?,?)', array($spf5ae13, $sp1b83a8, $spe7b1c7, $sp732cf7, $spb73662, (int) $spd3d838)); } public static function _trash($spca8acc) { DB::transaction(function () use($spca8acc) { $spd2ab5e = clone $spca8acc; $spd2ab5e->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp43445b) { foreach ($sp43445b as $sp78bb46) { $sp9dfc99 = \App\Product::where('id', $sp78bb46->product_id)->lockForUpdate()->first(); if ($sp9dfc99) { $sp9dfc99->count_all -= $sp78bb46->count_left; $sp9dfc99->saveOrFail(); } } }); $spca8acc->delete(); return true; }); } public static function _restore($spca8acc) { DB::transaction(function () use($spca8acc) { $spd2ab5e = clone $spca8acc; $spd2ab5e->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp43445b) { foreach ($sp43445b as $sp78bb46) { $sp9dfc99 = \App\Product::where('id', $sp78bb46->product_id)->lockForUpdate()->first(); if ($sp9dfc99) { $sp9dfc99->count_all += $sp78bb46->count_left; $sp9dfc99->saveOrFail(); } } }); $spca8acc->restore(); return true; }); } } \ No newline at end of file diff --git a/app/Category.php b/app/Category.php index e6f12935a..2adfa91c1 100644 --- a/app/Category.php +++ b/app/Category.php @@ -1,2 +1,2 @@ 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() { $sp8fefde = Product::where('category_id', $this->id)->where('enabled', 1)->orderBy('sort')->get(); foreach ($sp8fefde as $sp1a3ec5) { $sp1a3ec5->setForShop($this->user); } $this->addVisible(array('products')); $this->setAttribute('products', $sp8fefde); return $sp8fefde; } } \ No newline at end of file +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() { $spde3992 = Product::where('category_id', $this->id)->where('enabled', 1)->orderBy('sort')->get(); foreach ($spde3992 as $sp9dfc99) { $sp9dfc99->setForShop($this->user); } $this->addVisible(array('products')); $this->setAttribute('products', $spde3992); return $spde3992; } } \ No newline at end of file diff --git a/app/Console/Commands/ResetPassword.php b/app/Console/Commands/ResetPassword.php index e2076dbac..03529ba71 100644 --- a/app/Console/Commands/ResetPassword.php +++ b/app/Console/Commands/ResetPassword.php @@ -1,4 +1,4 @@ argument('email'); if (!$spd347b9) { $this->warn('please input the user\'s email -'); return false; } $sp845283 = \App\User::where('email', $spd347b9)->first(); if (!$sp845283) { $this->warn("can't find the user: {$spd347b9} \nplease input the user's email\n"); return false; } $sp943c4c = $this->argument('password'); $sp845283->password = bcrypt($sp943c4c); $sp845283->save(); $this->info("the password of '{$spd347b9}' has been set to {$sp943c4c}\n"); return true; } } \ No newline at end of file +Usage: php artisan reset:password user@email.com'; public function __construct() { parent::__construct(); } public function handle() { $sp667296 = $this->argument('email'); if (!$sp667296) { $this->warn('please input the user\'s email +'); return false; } $spac34b1 = \App\User::where('email', $sp667296)->first(); if (!$spac34b1) { $this->warn("can't find the user: {$sp667296} \nplease input the user's email\n"); return false; } $spdc3802 = $this->argument('password'); $spac34b1->password = bcrypt($spdc3802); $spac34b1->save(); $this->info("the password of '{$sp667296}' has been set to {$spdc3802}\n"); return true; } } \ No newline at end of file diff --git a/app/Console/Commands/Update.php b/app/Console/Commands/Update.php index 054958168..40b62e693 100644 --- a/app/Console/Commands/Update.php +++ b/app/Console/Commands/Update.php @@ -1,12 +1,12 @@ 0) { echo ' download: ' . sprintf('%.2f', $sp61d690 / $spfb8a6d * 100) . '%'; } }); curl_setopt($spa9fd67, CURLOPT_NOPROGRESS, false); curl_setopt($spa9fd67, CURLOPT_HEADER, 0); curl_setopt($spa9fd67, CURLOPT_USERAGENT, 'card update'); if (defined('MY_PROXY')) { $sp554d3f = MY_PROXY; $sp0e1f77 = CURLPROXY_HTTP; if (strpos($sp554d3f, 'http://') || strpos($sp554d3f, 'https://')) { $sp554d3f = str_replace('http://', $sp554d3f, $sp554d3f); $sp554d3f = str_replace('https://', $sp554d3f, $sp554d3f); $sp0e1f77 = CURLPROXY_HTTP; } elseif (strpos($sp554d3f, 'socks4://')) { $sp554d3f = str_replace('socks4://', $sp554d3f, $sp554d3f); $sp0e1f77 = CURLPROXY_SOCKS4; } elseif (strpos($sp554d3f, 'socks4a://')) { $sp554d3f = str_replace('socks4a://', $sp554d3f, $sp554d3f); $sp0e1f77 = CURLPROXY_SOCKS4A; } elseif (strpos($sp554d3f, 'socks5://')) { $sp554d3f = str_replace('socks5://', $sp554d3f, $sp554d3f); $sp0e1f77 = CURLPROXY_SOCKS5_HOSTNAME; } curl_setopt($spa9fd67, CURLOPT_PROXY, $sp554d3f); curl_setopt($spa9fd67, CURLOPT_PROXYTYPE, $sp0e1f77); if (defined('MY_PROXY_PASS')) { curl_setopt($spa9fd67, CURLOPT_PROXYUSERPWD, MY_PROXY_PASS); } } curl_exec($spa9fd67); curl_close($spa9fd67); echo ' -'; return true; } public function handle() { set_time_limit(0); $sp554d3f = $this->option('proxy'); if (!empty($sp554d3f)) { define('MY_PROXY', $sp554d3f); } $sp447d56 = $this->option('proxy-auth'); if (!empty($sp447d56)) { define('MY_PROXY_PASS', $sp447d56); } \Artisan::call('cache:clear'); \Artisan::call('config:clear'); echo ' -'; $this->comment('检查更新中...'); $this->info('当前版本: ' . config('app.version')); $sp00cd63 = @json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true); if (!@$sp00cd63['version']) { $this->warn('检查更新失败!'); $this->warn('Error: ' . ($sp00cd63 ? json_encode($sp00cd63) : 'Network error')); goto LABEL_EXIT; } if (config('app.version') >= $sp00cd63['version']) { $this->comment('您的版本已是最新!'); goto LABEL_EXIT; } $this->info('最新版本: ' . $sp00cd63['version']); $this->info('版本说明: ' . (@$sp00cd63['description'] ?? '无')); $sp91a927 = strtolower($this->ask('是否现在更新 (yes/no)', 'no')); if ($sp91a927 !== 'yes') { goto LABEL_EXIT; } $spf4ec72 = realpath(sys_get_temp_dir()); if (strlen($spf4ec72) < 3) { $this->warn('获取临时目录失败!'); goto LABEL_EXIT; } $spf4ec72 .= DIRECTORY_SEPARATOR . Str::random(16); if (!mkdir($spf4ec72) || !is_writable($spf4ec72) || !is_readable($spf4ec72)) { $this->warn('临时目录不可读写!'); goto LABEL_EXIT; } if (!function_exists('exec')) { $this->warn('函数 exec 已被禁用, 无法继续更新!'); goto LABEL_EXIT; } if (PHP_OS === 'WINNT') { $spfc8911 = 'C:\\Program Files\\7-Zip\\7z.exe'; if (!is_file($spfc8911)) { $spfc8911 = strtolower($this->ask('未找到7-Zip, 请手动输入7zG.exe路径', $spfc8911)); } if (!is_file($spfc8911)) { $this->warn('7-Zip不可用, 请安装7-Zip后重试'); goto LABEL_EXIT; } $spfc8911 = '"' . $spfc8911 . '"'; } else { exec('tar --version', $sp93ceb5, $spf691d6); if ($spf691d6) { $this->warn('Error: tar --version +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 {--proxy=} {--proxy-auth=}'; protected $description = 'check update'; public function __construct() { parent::__construct(); } private function download_progress($sp0784c1, $spfe2766) { $spd14037 = fopen($spfe2766, 'w+'); if (!$spd14037) { return false; } $spf86e31 = curl_init(); curl_setopt($spf86e31, CURLOPT_URL, $sp0784c1); curl_setopt($spf86e31, CURLOPT_FOLLOWLOCATION, true); curl_setopt($spf86e31, CURLOPT_RETURNTRANSFER, true); curl_setopt($spf86e31, CURLOPT_FILE, $spd14037); curl_setopt($spf86e31, CURLOPT_PROGRESSFUNCTION, function ($sp1eb5e5, $spad20fe, $sp1d9593, $sp52e253, $spb26e6f) { if ($spad20fe > 0) { echo ' download: ' . sprintf('%.2f', $sp1d9593 / $spad20fe * 100) . '%'; } }); curl_setopt($spf86e31, CURLOPT_NOPROGRESS, false); curl_setopt($spf86e31, CURLOPT_HEADER, 0); curl_setopt($spf86e31, CURLOPT_USERAGENT, 'card update'); if (defined('MY_PROXY')) { $spee5a33 = MY_PROXY; $sp1437c3 = CURLPROXY_HTTP; if (strpos($spee5a33, 'http://') || strpos($spee5a33, 'https://')) { $spee5a33 = str_replace('http://', $spee5a33, $spee5a33); $spee5a33 = str_replace('https://', $spee5a33, $spee5a33); $sp1437c3 = CURLPROXY_HTTP; } elseif (strpos($spee5a33, 'socks4://')) { $spee5a33 = str_replace('socks4://', $spee5a33, $spee5a33); $sp1437c3 = CURLPROXY_SOCKS4; } elseif (strpos($spee5a33, 'socks4a://')) { $spee5a33 = str_replace('socks4a://', $spee5a33, $spee5a33); $sp1437c3 = CURLPROXY_SOCKS4A; } elseif (strpos($spee5a33, 'socks5://')) { $spee5a33 = str_replace('socks5://', $spee5a33, $spee5a33); $sp1437c3 = CURLPROXY_SOCKS5_HOSTNAME; } curl_setopt($spf86e31, CURLOPT_PROXY, $spee5a33); curl_setopt($spf86e31, CURLOPT_PROXYTYPE, $sp1437c3); if (defined('MY_PROXY_PASS')) { curl_setopt($spf86e31, CURLOPT_PROXYUSERPWD, MY_PROXY_PASS); } } curl_exec($spf86e31); curl_close($spf86e31); echo ' +'; return true; } public function handle() { set_time_limit(0); $spee5a33 = $this->option('proxy'); if (!empty($spee5a33)) { define('MY_PROXY', $spee5a33); } $sp3e4ff9 = $this->option('proxy-auth'); if (!empty($sp3e4ff9)) { define('MY_PROXY_PASS', $sp3e4ff9); } \Artisan::call('cache:clear'); \Artisan::call('config:clear'); echo ' +'; $this->comment('检查更新中...'); $this->info('当前版本: ' . config('app.version')); $sp50de9a = @json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true); if (!@$sp50de9a['version']) { $this->warn('检查更新失败!'); $this->warn('Error: ' . ($sp50de9a ? json_encode($sp50de9a) : 'Network error')); goto LABEL_EXIT; } if (config('app.version') >= $sp50de9a['version']) { $this->comment('您的版本已是最新!'); goto LABEL_EXIT; } $this->info('最新版本: ' . $sp50de9a['version']); $this->info('版本说明: ' . (@$sp50de9a['description'] ?? '无')); $spa76c5d = strtolower($this->ask('是否现在更新 (yes/no)', 'no')); if ($spa76c5d !== 'yes') { goto LABEL_EXIT; } $sp7c1eea = realpath(sys_get_temp_dir()); if (strlen($sp7c1eea) < 3) { $this->warn('获取临时目录失败!'); goto LABEL_EXIT; } $sp7c1eea .= DIRECTORY_SEPARATOR . Str::random(16); if (!mkdir($sp7c1eea) || !is_writable($sp7c1eea) || !is_readable($sp7c1eea)) { $this->warn('临时目录不可读写!'); goto LABEL_EXIT; } if (!function_exists('exec')) { $this->warn('函数 exec 已被禁用, 无法继续更新!'); goto LABEL_EXIT; } if (PHP_OS === 'WINNT') { $spf704a8 = 'C:\\Program Files\\7-Zip\\7z.exe'; if (!is_file($spf704a8)) { $spf704a8 = strtolower($this->ask('未找到7-Zip, 请手动输入7zG.exe路径', $spf704a8)); } if (!is_file($spf704a8)) { $this->warn('7-Zip不可用, 请安装7-Zip后重试'); goto LABEL_EXIT; } $spf704a8 = '"' . $spf704a8 . '"'; } else { exec('tar --version', $sp1f82a5, $sp2e14e1); if ($sp2e14e1) { $this->warn('Error: tar --version ' . join(' -', $sp93ceb5)); goto LABEL_EXIT; } } $this->comment('正在下载新版本...'); $spd861bc = $spf4ec72 . DIRECTORY_SEPARATOR . 'ka_update_' . Str::random(16) . '.tmp'; if (!$this->download_progress($sp00cd63['url'], $spd861bc)) { $this->warn('写入临时文件失败!'); goto LABEL_EXIT; } $sp75f1bb = md5_file($spd861bc); if ($sp75f1bb !== $sp00cd63['md5']) { $this->warn('更新文件md5校验失败!, file:' . $sp75f1bb . ', require:' . $sp00cd63['md5']); goto LABEL_EXIT; } $this->comment('正在解压...'); unset($sp93ceb5); if (PHP_OS === 'WINNT') { exec("{$spfc8911} x -so {$spd861bc} | {$spfc8911} x -aoa -si -ttar -o{$spf4ec72}", $sp93ceb5, $spf691d6); } else { exec("tar -zxf {$spd861bc} -C {$spf4ec72}", $sp93ceb5, $spf691d6); } if ($spf691d6) { $this->warn('Error: 解压失败 +', $sp1f82a5)); goto LABEL_EXIT; } } $this->comment('正在下载新版本...'); $spfe2766 = $sp7c1eea . DIRECTORY_SEPARATOR . 'ka_update_' . Str::random(16) . '.tmp'; if (!$this->download_progress($sp50de9a['url'], $spfe2766)) { $this->warn('写入临时文件失败!'); goto LABEL_EXIT; } $sp83e66d = md5_file($spfe2766); if ($sp83e66d !== $sp50de9a['md5']) { $this->warn('更新文件md5校验失败!, file:' . $sp83e66d . ', require:' . $sp50de9a['md5']); goto LABEL_EXIT; } $this->comment('正在解压...'); unset($sp1f82a5); if (PHP_OS === 'WINNT') { exec("{$spf704a8} x -so {$spfe2766} | {$spf704a8} x -aoa -si -ttar -o{$sp7c1eea}", $sp1f82a5, $sp2e14e1); } else { exec("tar -zxf {$spfe2766} -C {$sp7c1eea}", $sp1f82a5, $sp2e14e1); } if ($sp2e14e1) { $this->warn('Error: 解压失败 ' . join(' -', $sp93ceb5)); goto LABEL_EXIT; } $this->comment('正在关闭主站...'); \Artisan::call('down'); sleep(5); $this->comment(' --> 正在清理旧文件...'); $sp39d523 = base_path(); foreach (array('app', 'bootstrap', 'config', 'public/dist', 'database', 'routes', 'vendor') as $spde3d9c) { \File::deleteDirectory($sp39d523 . DIRECTORY_SEPARATOR . $spde3d9c); } $this->comment(' --> 正在复制新文件...'); \File::copyDirectory($spf4ec72 . DIRECTORY_SEPARATOR . 'card_system_free_dist', $sp39d523); $this->comment(' --> 正在创建缓存...'); \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); $this->comment(' --> 正在更新数据库...'); \Artisan::call('migrate'); if (PHP_OS === 'WINNT') { echo ' +', $sp1f82a5)); goto LABEL_EXIT; } $this->comment('正在关闭主站...'); \Artisan::call('down'); sleep(5); $this->comment(' --> 正在清理旧文件...'); $spade944 = base_path(); foreach (array('app', 'bootstrap', 'config', 'public/dist', 'database', 'routes', 'vendor') as $spffbc51) { \File::deleteDirectory($spade944 . DIRECTORY_SEPARATOR . $spffbc51); } $this->comment(' --> 正在复制新文件...'); \File::copyDirectory($sp7c1eea . DIRECTORY_SEPARATOR . 'card_system_free_dist', $spade944); $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'); $sp935d85 = true; LABEL_EXIT: if (isset($spf4ec72) && strlen($spf4ec72) > 19) { $this->comment('清理临时目录...'); \File::deleteDirectory($spf4ec72); } if (isset($sp935d85) && $sp935d85) { $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 ' +'; } 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'); $sp904e20 = true; LABEL_EXIT: if (isset($sp7c1eea) && strlen($sp7c1eea) > 19) { $this->comment('清理临时目录...'); \File::deleteDirectory($sp7c1eea); } if (isset($sp904e20) && $sp904e20) { $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; } } \ No newline at end of file diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ac1e952f9..b2581961a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -1,4 +1,4 @@ runningInConsole()) { return; } try { System::_init(); } catch (\Throwable $sp45f5f1) { return; } if (System::_getInt('order_clean_unpay_open') === 1) { $spcb4d2f = System::_getInt('order_clean_unpay_day', 7); $spcdcc55->call(function () use($spcb4d2f) { echo '[' . date('Y-m-d H:i:s') . "] cleaning unpaid orders({$spcb4d2f} days ago)...\n"; \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new Carbon())->addDays(-$spcb4d2f))->delete(); $sp478b36 = '[' . date('Y-m-d H:i:s') . '] unpaid-orders cleaned -'; echo $sp478b36; })->dailyAt('01:00'); } $spcdcc55->call(function () { $spcb4d2f = 7; echo '[' . date('Y-m-d H:i:s') . "] cleaning deleted cards({$spcb4d2f} days ago)...\n"; \App\Card::onlyTrashed()->where('deleted_at', '<', (new Carbon())->addDays(-$spcb4d2f))->forceDelete(); $sp478b36 = '[' . date('Y-m-d H:i:s') . '] deleted-cards cleaned -'; echo $sp478b36; })->dailyAt('02:00'); } protected function commands() { $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } } \ No newline at end of file +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 $sp793fb1) { if (!app()->runningInConsole()) { return; } try { System::_init(); } catch (\Throwable $sp6a7295) { return; } if (System::_getInt('order_clean_unpay_open') === 1) { $sp8d35f0 = System::_getInt('order_clean_unpay_day', 7); $sp793fb1->call(function () use($sp8d35f0) { echo '[' . date('Y-m-d H:i:s') . "] cleaning unpaid orders({$sp8d35f0} days ago)...\n"; \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new Carbon())->addDays(-$sp8d35f0))->delete(); $sp4cabc4 = '[' . date('Y-m-d H:i:s') . '] unpaid-orders cleaned +'; echo $sp4cabc4; })->dailyAt('01:00'); } $sp793fb1->call(function () { $sp8d35f0 = 7; echo '[' . date('Y-m-d H:i:s') . "] cleaning deleted cards({$sp8d35f0} days ago)...\n"; \App\Card::onlyTrashed()->where('deleted_at', '<', (new Carbon())->addDays(-$sp8d35f0))->forceDelete(); $sp4cabc4 = '[' . date('Y-m-d H:i:s') . '] deleted-cards cleaned +'; echo $sp4cabc4; })->dailyAt('02:00'); } protected function commands() { $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } } \ No newline at end of file diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8f101ffaa..77923067f 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -1,2 +1,2 @@ isXmlHttpRequest() ? response()->json(array('message' => $sp478b36), $spf66c3d) : response()->view('errors._', array('code' => $spf66c3d, 'message' => $sp478b36), $spf66c3d); } public function render($spa27895, Exception $sp45f5f1) { if ($sp45f5f1 instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { return $this->msg($spa27895, '记录未找到', 404); } elseif ($sp45f5f1 instanceof \Illuminate\Auth\AuthenticationException) { return $this->msg($spa27895, '您需要登录您的账户再进行此操作', 401); } elseif ($sp45f5f1 instanceof \Illuminate\Auth\Access\AuthorizationException) { return $this->msg($spa27895, '未授权的操作', 403); } elseif ($sp45f5f1 instanceof \Illuminate\Validation\ValidationException) { return parent::render($spa27895, $sp45f5f1); } elseif ($sp45f5f1 instanceof \Illuminate\Session\TokenMismatchException) { return $this->msg($spa27895, '请刷新页面后重试', 403); } elseif ($sp45f5f1 instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return $this->msg($spa27895, '页面未找到', 404); } elseif ($sp45f5f1 instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) { return $this->msg($spa27895, '请求方法不允许', 405); } elseif ($sp45f5f1 instanceof \Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException) { Log::error('Caught a ServiceUnavailableHttpException', array('Exception' => $sp45f5f1)); return $this->msg($spa27895, '当前服务不可用,请稍后重试', 503); } elseif ($sp45f5f1 instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { $sp1b2df3 = $sp45f5f1->getStatusCode(); switch ($sp1b2df3) { case 429: return $this->msg($spa27895, '您的请求过于频繁,请稍后重试', 429); break; default: Log::error('Caught a UnknownHttpException', array('Exception' => $sp45f5f1)); return $this->msg($spa27895, '当前服务不可用,请稍后重试', 500); } } Log::error('Uncaught error', array('exception' => $sp45f5f1, 'method' => $spa27895->method(), 'url' => $spa27895->fullUrl(), 'data' => file_get_contents('php://input'), 'ip' => Helper::getIP(), 'client_ip' => $spa27895->getClientIp(), 'headers' => $spa27895->header())); if (config('app.debug')) { return parent::render($spa27895, $sp45f5f1); } else { return $this->msg($spa27895, '未知错误,请联系客服', 500); } } } \ No newline at end of file +namespace App\Exceptions; use App\Library\Helper; 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 $sp6724ce) { parent::report($sp6724ce); } private function msg($spba756f, $sp4cabc4, $sp732cf7) { return $spba756f->isXmlHttpRequest() ? response()->json(array('message' => $sp4cabc4), $sp732cf7) : response()->view('errors._', array('code' => $sp732cf7, 'message' => $sp4cabc4), $sp732cf7); } public function render($spba756f, Exception $sp6a7295) { if ($sp6a7295 instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { return $this->msg($spba756f, '记录未找到', 404); } elseif ($sp6a7295 instanceof \Illuminate\Auth\AuthenticationException) { return $this->msg($spba756f, '您需要登录您的账户再进行此操作', 401); } elseif ($sp6a7295 instanceof \Illuminate\Auth\Access\AuthorizationException) { return $this->msg($spba756f, '未授权的操作', 403); } elseif ($sp6a7295 instanceof \Illuminate\Validation\ValidationException) { return parent::render($spba756f, $sp6a7295); } elseif ($sp6a7295 instanceof \Illuminate\Session\TokenMismatchException) { return $this->msg($spba756f, '请刷新页面后重试', 403); } elseif ($sp6a7295 instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return $this->msg($spba756f, '页面未找到', 404); } elseif ($sp6a7295 instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) { return $this->msg($spba756f, '请求方法不允许', 405); } elseif ($sp6a7295 instanceof \Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException) { Log::error('Caught a ServiceUnavailableHttpException', array('Exception' => $sp6a7295)); return $this->msg($spba756f, '当前服务不可用,请稍后重试', 503); } elseif ($sp6a7295 instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { $sp287cdb = $sp6a7295->getStatusCode(); switch ($sp287cdb) { case 429: return $this->msg($spba756f, '您的请求过于频繁,请稍后重试', 429); break; default: Log::error('Caught a UnknownHttpException', array('Exception' => $sp6a7295)); return $this->msg($spba756f, '当前服务不可用,请稍后重试', 500); } } Log::error('Uncaught error', array('exception' => $sp6a7295, 'method' => $spba756f->method(), 'url' => $spba756f->fullUrl(), 'data' => file_get_contents('php://input'), 'ip' => Helper::getIP(), 'client_ip' => $spba756f->getClientIp(), 'headers' => $spba756f->header())); if (config('app.debug')) { return parent::render($spba756f, $sp6a7295); } else { return $this->msg($spba756f, '未知错误,请联系客服', 500); } } } \ No newline at end of file diff --git a/app/File.php b/app/File.php index b68b7c832..d8e853bc4 100644 --- a/app/File.php +++ b/app/File.php @@ -1,2 +1,2 @@ driver)->delete($this->path); } catch (\Exception $sp45f5f1) { \Log::error('File.deleteFile Error: ' . $sp45f5f1->getMessage(), array('exception' => $sp45f5f1)); } } public static function getProductFolder() { return 'images/product'; } } \ No newline at end of file +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 $sp6a7295) { \Log::error('File.deleteFile Error: ' . $sp6a7295->getMessage(), array('exception' => $sp6a7295)); } } public static function getProductFolder() { return 'images/product'; } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/Dashboard.php b/app/Http/Controllers/Admin/Dashboard.php index 7405c6955..28fb97b59 100644 --- a/app/Http/Controllers/Admin/Dashboard.php +++ b/app/Http/Controllers/Admin/Dashboard.php @@ -1,2 +1,2 @@ array('count' => 0, 'paid' => 0, 'profit' => 0), 'yesterday' => array('count' => 0, 'paid' => 0, 'profit' => 0)); $spb9368b = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::now()->toDateString())->where(function ($sp7e6fa3) { $sp7e6fa3->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(); $sp55ff57 = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::yesterday()->toDateString())->where(function ($sp7e6fa3) { $sp7e6fa3->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($spb9368b[0]) && isset($spb9368b[0]['count'])) { $spfafe43['today'] = array('count' => (int) $spb9368b[0]['count'], 'paid' => (int) $spb9368b[0]['paid'], 'profit' => (int) $spb9368b[0]['profit']); } if (isset($sp55ff57[0]) && isset($sp55ff57[0]['count'])) { $spfafe43['yesterday'] = array('count' => (int) $sp55ff57[0]['count'], 'paid' => (int) $sp55ff57[0]['paid'], 'profit' => (int) $sp55ff57[0]['profit']); } $spfafe43['need_ship_count'] = Order::whereUserId(\Auth::Id())->where('status', Order::STATUS_PAID)->count(); $spfafe43['login'] = \App\Log::where('action', \App\Log::ACTION_LOGIN)->latest()->firstOrFail(); return Response::success($spfafe43); } function clearCache() { if (function_exists('opcache_reset')) { opcache_reset(); } try { \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); } catch (\Throwable $sp45f5f1) { return Response::fail($sp45f5f1->getMessage()); } return Response::success(); } function version() { return Response::success(array('version' => config('app.version'))); } function checkUpdate() { return Response::success(@json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true)); } } \ No newline at end of file +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 $spba756f) { $sp56a4a0 = array('today' => array('count' => 0, 'paid' => 0, 'profit' => 0), 'yesterday' => array('count' => 0, 'paid' => 0, 'profit' => 0)); $sp4fe31f = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::now()->toDateString())->where(function ($spca8acc) { $spca8acc->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(); $spfcca6e = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::yesterday()->toDateString())->where(function ($spca8acc) { $spca8acc->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($sp4fe31f[0]) && isset($sp4fe31f[0]['count'])) { $sp56a4a0['today'] = array('count' => (int) $sp4fe31f[0]['count'], 'paid' => (int) $sp4fe31f[0]['paid'], 'profit' => (int) $sp4fe31f[0]['profit']); } if (isset($spfcca6e[0]) && isset($spfcca6e[0]['count'])) { $sp56a4a0['yesterday'] = array('count' => (int) $spfcca6e[0]['count'], 'paid' => (int) $spfcca6e[0]['paid'], 'profit' => (int) $spfcca6e[0]['profit']); } $sp56a4a0['need_ship_count'] = Order::whereUserId(\Auth::Id())->where('status', Order::STATUS_PAID)->count(); $sp56a4a0['login'] = \App\Log::where('action', \App\Log::ACTION_LOGIN)->latest()->firstOrFail(); return Response::success($sp56a4a0); } function clearCache() { if (function_exists('opcache_reset')) { opcache_reset(); } try { \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); } catch (\Throwable $sp6a7295) { return Response::fail($sp6a7295->getMessage()); } return Response::success(); } function version() { return Response::success(array('version' => config('app.version'))); } function checkUpdate() { return Response::success(@json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true)); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/Login.php b/app/Http/Controllers/Admin/Login.php index bde977b46..ac6326968 100644 --- a/app/Http/Controllers/Admin/Login.php +++ b/app/Http/Controllers/Admin/Login.php @@ -1,2 +1,2 @@ 'geetest', 'geetest' => Geetest\API::get()); return Response::success($sp6bda17); } public function login(Request $spa27895) { if ((int) \App\System::_get('vcode_login') === 1) { $sp786169 = Geetest\API::verify($spa27895->post('gt_c'), $spa27895->post('gt_v'), $spa27895->post('gt_s')); if (!$sp786169) { return Response::fail('滑动验证超时,请返回页面重试。'); } } $sp5138db = $spa27895->input('remember') == 'true'; if (!Auth::attempt(array('email' => $spa27895->input('email'), 'password' => $spa27895->input('password')), $sp5138db)) { return Response::fail('邮箱或密码错误, 请检查'); } else { $sp7bbf8b = new \App\Log(); $sp7bbf8b->user_id = Auth::Id(); $sp7bbf8b->ip = Helper::getIP(); $sp7bbf8b->action = \App\Log::ACTION_LOGIN; $sp7bbf8b->save(); $sp845283 = Auth::getUser(); $sp845283->addHidden(array('created_at', 'updated_at')); return Response::success(array('token' => 'login', 'user' => $sp845283->toArray())); } } function info() { $sp845283 = Auth::getUser(); $sp845283->addHidden(array('created_at', 'updated_at')); $sp845283->setAttribute('shop_name', \App\System::_get('app_name')); return Response::success(array('token' => 'login', 'user' => $sp845283->toArray())); } function logout(Request $spa27895) { @Auth::logout(); return Response::success(); } function changePassword(Request $spa27895) { $sp845283 = Auth::getUser(); $sp5fd1b4 = $spa27895->post('old', null); $sp943c4c = $spa27895->post('password', null); if (strlen($sp943c4c) < 6 || strlen($sp943c4c) > 32) { return Response::fail('请输入6-32位密码'); } if (!Hash::check($sp5fd1b4, $sp845283->password)) { return Response::fail('旧密码错误,请检查'); } $sp845283->password = Hash::make($sp943c4c); $sp845283->setRememberToken(str_random(60)); $sp845283->saveOrFail(); event(new PasswordReset($sp845283)); Auth::guard()->login($sp845283); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\Helper; use App\Library\Geetest; use Illuminate\Auth\Events\PasswordReset; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Library\Response; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; class Login extends Controller { function getVerify() { $spe9df6d = array('driver' => 'geetest', 'geetest' => Geetest\API::get()); return Response::success($spe9df6d); } public function login(Request $spba756f) { if ((int) \App\System::_get('vcode_login') === 1) { $sp5359c9 = Geetest\API::verify($spba756f->post('gt_c'), $spba756f->post('gt_v'), $spba756f->post('gt_s')); if (!$sp5359c9) { return Response::fail('滑动验证超时,请返回页面重试。'); } } $sp0074ec = $spba756f->input('remember') == 'true'; if (!Auth::attempt(array('email' => $spba756f->input('email'), 'password' => $spba756f->input('password')), $sp0074ec)) { return Response::fail('邮箱或密码错误, 请检查'); } else { $spaf344d = new \App\Log(); $spaf344d->user_id = Auth::Id(); $spaf344d->ip = Helper::getIP(); $spaf344d->action = \App\Log::ACTION_LOGIN; $spaf344d->save(); $spac34b1 = Auth::getUser(); $spac34b1->addHidden(array('created_at', 'updated_at')); return Response::success(array('token' => 'login', 'user' => $spac34b1->toArray())); } } function info() { $spac34b1 = Auth::getUser(); $spac34b1->addHidden(array('created_at', 'updated_at')); $spac34b1->setAttribute('shop_name', \App\System::_get('app_name')); return Response::success(array('token' => 'login', 'user' => $spac34b1->toArray())); } function logout(Request $spba756f) { @Auth::logout(); return Response::success(); } function changePassword(Request $spba756f) { $spac34b1 = Auth::getUser(); $sp31e536 = $spba756f->post('old', null); $spdc3802 = $spba756f->post('password', null); if (strlen($spdc3802) < 6 || strlen($spdc3802) > 32) { return Response::fail('请输入6-32位密码'); } if (!Hash::check($sp31e536, $spac34b1->password)) { return Response::fail('旧密码错误,请检查'); } $spac34b1->password = Hash::make($spdc3802); $spac34b1->setRememberToken(str_random(60)); $spac34b1->saveOrFail(); event(new PasswordReset($spac34b1)); Auth::guard()->login($spac34b1); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/Order.php b/app/Http/Controllers/Admin/Order.php index 6cdfae93a..2090c055b 100644 --- a/app/Http/Controllers/Admin/Order.php +++ b/app/Http/Controllers/Admin/Order.php @@ -1,2 +1,2 @@ validate($spa27895, array('ids' => 'required|string', 'income' => 'required|integer', 'balance' => 'required|integer')); $sp8e4c06 = $spa27895->post('ids'); $spc7b77d = (int) $spa27895->post('income'); $sp0aa8dc = (int) $spa27895->post('balance'); \App\Order::whereIn('id', explode(',', $sp8e4c06))->chunk(100, function ($spcc3b3e) use($spc7b77d, $sp0aa8dc) { foreach ($spcc3b3e as $sp7b2cfc) { $sp7b2cfc->cards()->detach(); try { if ($spc7b77d) { $sp7b2cfc->fundRecord()->delete(); } if ($sp0aa8dc) { $sp845283 = \App\User::lockForUpdate()->firstOrFail(); $sp845283->m_all -= $sp7b2cfc->income; $sp845283->saveOrFail(); } $sp7b2cfc->delete(); } catch (\Exception $sp45f5f1) { } } }); return Response::success(); } function freeze(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string')); $sp8e4c06 = explode(',', $spa27895->post('ids')); $sp01391f = $spa27895->post('reason'); $spdf4a99 = 0; $sp052277 = 0; foreach ($sp8e4c06 as $sp748f3f) { $spdf4a99++; if (FundHelper::orderFreeze($sp748f3f, $sp01391f)) { $sp052277++; } } return Response::success(array($spdf4a99, $sp052277)); } function unfreeze(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string')); $sp8e4c06 = explode(',', $spa27895->post('ids')); $spdf4a99 = 0; $sp052277 = 0; $sp2fc4dd = \App\Order::STATUS_FROZEN; foreach ($sp8e4c06 as $sp748f3f) { $spdf4a99++; if (FundHelper::orderUnfreeze($sp748f3f, '后台操作', null, $sp2fc4dd)) { $sp052277++; } } return Response::success(array($spdf4a99, $sp052277, $sp2fc4dd)); } function set_paid(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer')); $sp746ee1 = $spa27895->post('id', ''); $sp002509 = $spa27895->post('trade_no', ''); if (strlen($sp002509) < 1) { return Response::forbidden('请输入支付系统内单号'); } $sp7b2cfc = \App\Order::findOrFail($sp746ee1); if ($sp7b2cfc->status !== \App\Order::STATUS_UNPAY) { return Response::forbidden('只能操作未支付订单'); } $sp860109 = 'Admin.SetPaid'; $sp0dbaa3 = $sp7b2cfc->order_no; $spa468fd = $sp7b2cfc->paid; try { Log::debug($sp860109 . " shipOrder start, order_no: {$sp0dbaa3}, amount: {$spa468fd}, trade_no: {$sp002509}"); (new \App\Http\Controllers\Shop\Pay())->shipOrder($spa27895, $sp0dbaa3, $spa468fd, $sp002509); Log::debug($sp860109 . ' shipOrder end, order_no: ' . $sp0dbaa3); $sp052277 = true; $spa9bccc = '发货成功'; } catch (\Exception $sp45f5f1) { $sp052277 = false; $spa9bccc = $sp45f5f1->getMessage(); Log::error($sp860109 . ' shipOrder Exception: ' . $sp45f5f1->getMessage()); } $sp7b2cfc = \App\Order::with(array('pay' => function (Relation $sp7e6fa3) { $sp7e6fa3->select(array('id', 'name')); }, 'card_orders.card' => function (Relation $sp7e6fa3) { $sp7e6fa3->select(array('id', 'card')); }))->findOrFail($sp746ee1); if ($sp7b2cfc->status === \App\Order::STATUS_PAID) { if ($sp7b2cfc->product->delivery === \App\Product::DELIVERY_MANUAL) { $sp052277 = true; $spa9bccc = '已标记为付款成功
当前商品为手动发货商品, 请手动进行发货。'; } else { $sp052277 = false; $spa9bccc = '已标记为付款成功,
但是买家库存不足, 发货失败, 请稍后尝试手动发货。'; } } return Response::success(array('code' => $sp052277 ? 0 : -1, 'msg' => $spa9bccc, 'order' => $sp7b2cfc)); } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\FundHelper; use App\Library\Helper; use Carbon\Carbon; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Library\Response; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class Order extends Controller { public function delete(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string', 'income' => 'required|integer', 'balance' => 'required|integer')); $sp12026a = $spba756f->post('ids'); $sp98659b = (int) $spba756f->post('income'); $spec2bef = (int) $spba756f->post('balance'); \App\Order::whereIn('id', explode(',', $sp12026a))->chunk(100, function ($sp29dcf4) use($sp98659b, $spec2bef) { foreach ($sp29dcf4 as $spedec71) { $spedec71->cards()->detach(); try { if ($sp98659b) { $spedec71->fundRecord()->delete(); } if ($spec2bef) { $spac34b1 = \App\User::lockForUpdate()->firstOrFail(); $spac34b1->m_all -= $spedec71->income; $spac34b1->saveOrFail(); } $spedec71->delete(); } catch (\Exception $sp6a7295) { } } }); return Response::success(); } function freeze(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string')); $sp12026a = explode(',', $spba756f->post('ids')); $sp35d759 = $spba756f->post('reason'); $sp99aae1 = 0; $sp722b63 = 0; foreach ($sp12026a as $spe5a302) { $sp99aae1++; if (FundHelper::orderFreeze($spe5a302, $sp35d759)) { $sp722b63++; } } return Response::success(array($sp99aae1, $sp722b63)); } function unfreeze(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string')); $sp12026a = explode(',', $spba756f->post('ids')); $sp99aae1 = 0; $sp722b63 = 0; $sp172c79 = \App\Order::STATUS_FROZEN; foreach ($sp12026a as $spe5a302) { $sp99aae1++; if (FundHelper::orderUnfreeze($spe5a302, '后台操作', null, $sp172c79)) { $sp722b63++; } } return Response::success(array($sp99aae1, $sp722b63, $sp172c79)); } function set_paid(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer')); $sp8e8060 = $spba756f->post('id', ''); $sp9db197 = $spba756f->post('trade_no', ''); if (strlen($sp9db197) < 1) { return Response::forbidden('请输入支付系统内单号'); } $spedec71 = \App\Order::findOrFail($sp8e8060); if ($spedec71->status !== \App\Order::STATUS_UNPAY) { return Response::forbidden('只能操作未支付订单'); } $sp591089 = 'Admin.SetPaid'; $spf34e1a = $spedec71->order_no; $sp246f65 = $spedec71->paid; try { Log::debug($sp591089 . " shipOrder start, order_no: {$spf34e1a}, amount: {$sp246f65}, trade_no: {$sp9db197}"); (new \App\Http\Controllers\Shop\Pay())->shipOrder($spba756f, $spf34e1a, $sp246f65, $sp9db197); Log::debug($sp591089 . ' shipOrder end, order_no: ' . $spf34e1a); $sp722b63 = true; $spa24442 = '发货成功'; } catch (\Exception $sp6a7295) { $sp722b63 = false; $spa24442 = $sp6a7295->getMessage(); Log::error($sp591089 . ' shipOrder Exception: ' . $sp6a7295->getMessage()); } $spedec71 = \App\Order::with(array('pay' => function (Relation $spca8acc) { $spca8acc->select(array('id', 'name')); }, 'card_orders.card' => function (Relation $spca8acc) { $spca8acc->select(array('id', 'card')); }))->findOrFail($sp8e8060); if ($spedec71->status === \App\Order::STATUS_PAID) { if ($spedec71->product->delivery === \App\Product::DELIVERY_MANUAL) { $sp722b63 = true; $spa24442 = '已标记为付款成功
当前商品为手动发货商品, 请手动进行发货。'; } else { $sp722b63 = false; $spa24442 = '已标记为付款成功,
但是买家库存不足, 发货失败, 请稍后尝试手动发货。'; } } return Response::success(array('code' => $sp722b63 ? 0 : -1, 'msg' => $spa24442, 'order' => $spedec71)); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/Pay.php b/app/Http/Controllers/Admin/Pay.php index afd6534fd..b04539792 100644 --- a/app/Http/Controllers/Admin/Pay.php +++ b/app/Http/Controllers/Admin/Pay.php @@ -1,2 +1,2 @@ post('enabled'); if (strlen($sp2a8f09)) { $sp7e6fa3->whereIn('enabled', explode(',', $sp2a8f09)); } $spfe451d = $spa27895->post('search', false); $sp0edb8f = $spa27895->post('val', false); if ($spfe451d && $sp0edb8f) { if ($spfe451d == 'simple') { return Response::success($sp7e6fa3->get(array('id', 'name'))); } elseif ($spfe451d == 'id') { $sp7e6fa3->where('id', $sp0edb8f); } else { $sp7e6fa3->where($spfe451d, 'like', '%' . $sp0edb8f . '%'); } } $sp966ae1 = $sp7e6fa3->get(); return Response::success(array('list' => $sp966ae1, 'urls' => array('url' => config('app.url'), 'url_api' => config('app.url_api')))); } function stat(Request $spa27895) { $this->validate($spa27895, array('day' => 'required|integer|between:1,30')); $spcb4d2f = (int) $spa27895->input('day'); if ($spcb4d2f === 30) { $sp118ccb = Carbon::now()->addMonths(-1); } else { $sp118ccb = Carbon::now()->addDays(-$spcb4d2f); } $sp966ae1 = $this->authQuery($spa27895, \App\Order::class)->where(function ($sp7e6fa3) { $sp7e6fa3->where('status', \App\Order::STATUS_PAID)->orWhere('status', \App\Order::STATUS_SUCCESS); })->where('paid_at', '>=', $sp118ccb)->with(array('pay' => function ($sp7e6fa3) { $sp7e6fa3->select(array('id', 'name')); }))->groupBy('pay_id')->selectRaw('`pay_id`,COUNT(*) as "count",SUM(`paid`) as "sum"')->get()->toArray(); $sp786169 = array(); foreach ($sp966ae1 as $spc6f905) { if (isset($spc6f905['pay']) && isset($spc6f905['pay']['name'])) { $spf5edea = $spc6f905['pay']['name']; } else { $spf5edea = '未知方式#' . $spc6f905['pay_id']; } $sp786169[$spf5edea] = array((int) $spc6f905['count'], (int) $spc6f905['sum']); } return Response::success($sp786169); } function edit(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer', 'name' => 'required|string', 'img' => 'required|string', 'driver' => 'required|string', 'way' => 'required|string', 'config' => 'required|string')); $sp746ee1 = (int) $spa27895->post('id'); $sp104c39 = $spa27895->post('name'); $sp6df6df = $spa27895->post('img'); $sp5d4c60 = $spa27895->post('comment'); $sp1f9a35 = $spa27895->post('driver'); $spd04a61 = $spa27895->post('way'); $spfd6e52 = $spa27895->post('config'); $sp2a8f09 = (int) $spa27895->post('enabled'); $sp1d1f3d = \App\Pay::find($sp746ee1); if (!$sp1d1f3d) { $sp1d1f3d = new \App\Pay(); } $sp1d1f3d->name = $sp104c39; $sp1d1f3d->img = $sp6df6df; $sp1d1f3d->comment = $sp5d4c60; $sp1d1f3d->driver = $sp1f9a35; $sp1d1f3d->way = $spd04a61; $sp1d1f3d->config = $spfd6e52; $sp1d1f3d->enabled = $sp2a8f09; $sp1d1f3d->fee_system = $spa27895->post('fee_system'); $sp1d1f3d->saveOrFail(); return Response::success(); } function comment(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer')); $sp746ee1 = (int) $spa27895->post('id'); $sp1d1f3d = \App\Pay::findOrFail($sp746ee1); $sp1d1f3d->comment = $spa27895->post('comment'); $sp1d1f3d->save(); return Response::success(); } function sort(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer')); $sp746ee1 = (int) $spa27895->post('id'); $sp1d1f3d = \App\Pay::findOrFail($sp746ee1); $sp1d1f3d->sort = (int) $spa27895->post('sort', 1000); $sp1d1f3d->save(); return Response::success(); } function fee_system(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer')); $sp746ee1 = (int) $spa27895->post('id'); $sp1d1f3d = \App\Pay::findOrFail($sp746ee1); $sp1d1f3d->fee_system = $spa27895->post('fee_system'); $sp1d1f3d->saveOrFail(); return Response::success(); } function enable(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $sp8e4c06 = $spa27895->post('ids'); $sp2a8f09 = (int) $spa27895->post('enabled'); \App\Pay::whereIn('id', explode(',', $sp8e4c06))->update(array('enabled' => $sp2a8f09)); return Response::success(); } function delete(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer')); $sp746ee1 = (int) $spa27895->post('id'); \App\Pay::whereId($sp746ee1)->delete(); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\Helper; use Carbon\Carbon; use function foo\func; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Library\Response; class Pay extends Controller { function get(Request $spba756f) { $spca8acc = \App\Pay::orderBy('sort'); $spc7c4ac = $spba756f->post('enabled'); if (strlen($spc7c4ac)) { $spca8acc->whereIn('enabled', explode(',', $spc7c4ac)); } $speeddd9 = $spba756f->post('search', false); $spe1fc85 = $spba756f->post('val', false); if ($speeddd9 && $spe1fc85) { if ($speeddd9 == 'simple') { return Response::success($spca8acc->get(array('id', 'name'))); } elseif ($speeddd9 == 'id') { $spca8acc->where('id', $spe1fc85); } else { $spca8acc->where($speeddd9, 'like', '%' . $spe1fc85 . '%'); } } $spfea7ce = $spca8acc->get(); return Response::success(array('list' => $spfea7ce, 'urls' => array('url' => config('app.url'), 'url_api' => config('app.url_api')))); } function stat(Request $spba756f) { $this->validate($spba756f, array('day' => 'required|integer|between:1,30')); $sp8d35f0 = (int) $spba756f->input('day'); if ($sp8d35f0 === 30) { $sp20fe30 = Carbon::now()->addMonths(-1); } else { $sp20fe30 = Carbon::now()->addDays(-$sp8d35f0); } $spfea7ce = $this->authQuery($spba756f, \App\Order::class)->where(function ($spca8acc) { $spca8acc->where('status', \App\Order::STATUS_PAID)->orWhere('status', \App\Order::STATUS_SUCCESS); })->where('paid_at', '>=', $sp20fe30)->with(array('pay' => function ($spca8acc) { $spca8acc->select(array('id', 'name')); }))->groupBy('pay_id')->selectRaw('`pay_id`,COUNT(*) as "count",SUM(`paid`) as "sum"')->get()->toArray(); $sp5359c9 = array(); foreach ($spfea7ce as $spbdd4b3) { if (isset($spbdd4b3['pay']) && isset($spbdd4b3['pay']['name'])) { $spc977ba = $spbdd4b3['pay']['name']; } else { $spc977ba = '未知方式#' . $spbdd4b3['pay_id']; } $sp5359c9[$spc977ba] = array((int) $spbdd4b3['count'], (int) $spbdd4b3['sum']); } return Response::success($sp5359c9); } function edit(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer', 'name' => 'required|string', 'img' => 'required|string', 'driver' => 'required|string', 'way' => 'required|string', 'config' => 'required|string')); $sp8e8060 = (int) $spba756f->post('id'); $sp387f04 = $spba756f->post('name'); $spc2cc55 = $spba756f->post('img'); $sp7edcb1 = $spba756f->post('comment'); $spa28d5a = $spba756f->post('driver'); $sp4f3f11 = $spba756f->post('way'); $spf3616d = $spba756f->post('config'); $spc7c4ac = (int) $spba756f->post('enabled'); $sp91f0ec = \App\Pay::find($sp8e8060); if (!$sp91f0ec) { $sp91f0ec = new \App\Pay(); } $sp91f0ec->name = $sp387f04; $sp91f0ec->img = $spc2cc55; $sp91f0ec->comment = $sp7edcb1; $sp91f0ec->driver = $spa28d5a; $sp91f0ec->way = $sp4f3f11; $sp91f0ec->config = $spf3616d; $sp91f0ec->enabled = $spc7c4ac; $sp91f0ec->fee_system = $spba756f->post('fee_system'); $sp91f0ec->saveOrFail(); return Response::success(); } function comment(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer')); $sp8e8060 = (int) $spba756f->post('id'); $sp91f0ec = \App\Pay::findOrFail($sp8e8060); $sp91f0ec->comment = $spba756f->post('comment'); $sp91f0ec->save(); return Response::success(); } function sort(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer')); $sp8e8060 = (int) $spba756f->post('id'); $sp91f0ec = \App\Pay::findOrFail($sp8e8060); $sp91f0ec->sort = (int) $spba756f->post('sort', 1000); $sp91f0ec->save(); return Response::success(); } function fee_system(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer')); $sp8e8060 = (int) $spba756f->post('id'); $sp91f0ec = \App\Pay::findOrFail($sp8e8060); $sp91f0ec->fee_system = $spba756f->post('fee_system'); $sp91f0ec->saveOrFail(); return Response::success(); } function enable(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $sp12026a = $spba756f->post('ids'); $spc7c4ac = (int) $spba756f->post('enabled'); \App\Pay::whereIn('id', explode(',', $sp12026a))->update(array('enabled' => $spc7c4ac)); return Response::success(); } function delete(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer')); $sp8e8060 = (int) $spba756f->post('id'); \App\Pay::whereId($sp8e8060)->delete(); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/System.php b/app/Http/Controllers/Admin/System.php index 32e922fbf..81fcb7f81 100644 --- a/app/Http/Controllers/Admin/System.php +++ b/app/Http/Controllers/Admin/System.php @@ -1,2 +1,2 @@ has($sp104c39)) { \App\System::_set($sp104c39, $spa27895->post($sp104c39)); } } } private function setMoney(Request $spa27895, $spb3332a) { foreach ($spb3332a as $sp104c39) { if ($spa27895->has($sp104c39)) { \App\System::_set($sp104c39, (int) round($spa27895->post($sp104c39) * 100)); } } } private function setInt(Request $spa27895, $spb3332a) { foreach ($spb3332a as $sp104c39) { if ($spa27895->has($sp104c39)) { \App\System::_set($sp104c39, (int) $spa27895->post($sp104c39)); } } } function setItem(Request $spa27895) { $sp104c39 = $spa27895->post('name'); $sp1b5dd9 = $spa27895->post('value'); if (!$sp104c39 || !$sp1b5dd9) { return Response::forbidden(); } \App\System::_set($sp104c39, $sp1b5dd9); return Response::success(); } function info(Request $spa27895) { $sp551f42 = array('app_name', 'app_title', 'app_url', 'app_url_api', 'keywords', 'description', 'shop_ann', 'shop_ann_pop', 'shop_qq', 'company', 'js_tj', 'js_kf'); $spd26096 = array('shop_inventory'); if ($spa27895->isMethod('GET')) { $spfd6e52 = array(); foreach ($sp551f42 as $sp104c39) { $spfd6e52[$sp104c39] = \App\System::_get($sp104c39); } foreach ($spd26096 as $sp104c39) { $spfd6e52[$sp104c39] = (int) \App\System::_get($sp104c39); } return Response::success($spfd6e52); } $spddf3f5 = array('app_url' => Helper::format_url($_POST['app_url']), 'app_url_api' => Helper::format_url($_POST['app_url_api'])); $spa27895->merge($spddf3f5); $this->set($spa27895, $sp551f42); $this->setInt($spa27895, $spd26096); return Response::success(); } function theme(Request $spa27895) { if ($spa27895->isMethod('GET')) { \App\ShopTheme::freshList(); return Response::success(array('themes' => \App\ShopTheme::get(), 'default' => \App\ShopTheme::defaultTheme()->name)); } $sp421ad6 = \App\ShopTheme::whereName($spa27895->post('shop_theme'))->firstOrFail(); \App\System::_set('shop_theme_default', $sp421ad6->name); $sp421ad6->config = @json_decode($spa27895->post('theme_config')) ?? array(); $sp421ad6->saveOrFail(); return Response::success(); } function order(Request $spa27895) { $spb3332a = array('order_clean_unpay_open', 'order_clean_unpay_day'); if ($spa27895->isMethod('GET')) { $spfd6e52 = array(); foreach ($spb3332a as $sp104c39) { $spfd6e52[$sp104c39] = (int) \App\System::_get($sp104c39); } return Response::success($spfd6e52); } $this->setInt($spa27895, $spb3332a); return Response::success(); } function vcode(Request $spa27895) { $sp551f42 = array('vcode_driver', 'vcode_geetest_id', 'vcode_geetest_key'); $spd26096 = array('vcode_login', 'vcode_shop_buy', 'vcode_shop_search'); if ($spa27895->isMethod('GET')) { $spfd6e52 = array(); foreach ($sp551f42 as $sp104c39) { $spfd6e52[$sp104c39] = \App\System::_get($sp104c39); } foreach ($spd26096 as $sp104c39) { $spfd6e52[$sp104c39] = (int) \App\System::_get($sp104c39); } return Response::success($spfd6e52); } $this->set($spa27895, $sp551f42); $this->setInt($spa27895, $spd26096); return Response::success(); } function email(Request $spa27895) { $sp551f42 = array('mail_driver', 'mail_smtp_host', 'mail_smtp_port', 'mail_smtp_username', 'mail_smtp_password', 'mail_smtp_from_address', 'mail_smtp_from_name', 'mail_smtp_encryption', 'sendcloud_user', 'sendcloud_key'); $spd26096 = array('mail_send_order', 'mail_send_order_use_contact'); if ($spa27895->isMethod('GET')) { $spfd6e52 = array(); foreach ($sp551f42 as $sp104c39) { $spfd6e52[$sp104c39] = \App\System::_get($sp104c39); } foreach ($spd26096 as $sp104c39) { $spfd6e52[$sp104c39] = (int) \App\System::_get($sp104c39); } return Response::success($spfd6e52); } $this->set($spa27895, $sp551f42); $this->setInt($spa27895, $spd26096); return Response::success(); } function sms(Request $spa27895) { $sp551f42 = array('sms_api_id', 'sms_api_key'); $spd26096 = array('sms_send_order', 'sms_price'); if ($spa27895->isMethod('GET')) { $spfd6e52 = array(); foreach ($sp551f42 as $sp104c39) { $spfd6e52[$sp104c39] = \App\System::_get($sp104c39); } foreach ($spd26096 as $sp104c39) { $spfd6e52[$sp104c39] = (int) \App\System::_get($sp104c39); } return Response::success($spfd6e52); } $this->set($spa27895, $sp551f42); $this->setInt($spa27895, $spd26096); return Response::success(); } function storage(Request $spa27895) { $sp551f42 = array('storage_driver', 'storage_s3_access_key', 'storage_s3_secret_key', 'storage_s3_region', 'storage_s3_bucket', 'storage_oss_access_key', 'storage_oss_secret_key', 'storage_oss_bucket', 'storage_oss_endpoint', 'storage_oss_cdn_domain', 'storage_qiniu_domains_default', 'storage_qiniu_domains_https', 'storage_qiniu_access_key', 'storage_qiniu_secret_key', 'storage_qiniu_bucket', 'storage_qiniu_notify_url'); $spd26096 = array('storage_oss_is_ssl', 'storage_oss_is_cname'); if ($spa27895->isMethod('GET')) { $spfd6e52 = array(); foreach ($sp551f42 as $sp104c39) { $spfd6e52[$sp104c39] = \App\System::_get($sp104c39); } foreach ($spd26096 as $sp104c39) { $spfd6e52[$sp104c39] = (int) \App\System::_get($sp104c39); } return Response::success($spfd6e52); } $this->set($spa27895, $sp551f42); $this->set($spa27895, $spd26096); return Response::success(); } function emailTest(Request $spa27895) { $this->validate($spa27895, array('to' => 'required')); $sp990270 = $spa27895->post('to'); try { $sp786169 = Mail::to($sp990270)->send(new \App\Mail\Test()); return Response::success($sp786169); } catch (\Throwable $sp45f5f1) { \App\Library\LogHelper::setLogFile('mail'); \Log::error('Mail Test Exception:' . $sp45f5f1->getMessage()); return Response::fail($sp45f5f1->getMessage(), $sp45f5f1); } } function orderClean(Request $spa27895) { $this->validate($spa27895, array('day' => 'required|integer|min:1')); $spcb4d2f = (int) $spa27895->post('day'); \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new \Carbon\Carbon())->addDays(-$spcb4d2f))->delete(); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\Helper; use App\Library\Response; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Mail; class System extends Controller { private function set(Request $spba756f, $spa4106d) { foreach ($spa4106d as $sp387f04) { if ($spba756f->has($sp387f04)) { \App\System::_set($sp387f04, $spba756f->post($sp387f04)); } } } private function setMoney(Request $spba756f, $spa4106d) { foreach ($spa4106d as $sp387f04) { if ($spba756f->has($sp387f04)) { \App\System::_set($sp387f04, (int) round($spba756f->post($sp387f04) * 100)); } } } private function setInt(Request $spba756f, $spa4106d) { foreach ($spa4106d as $sp387f04) { if ($spba756f->has($sp387f04)) { \App\System::_set($sp387f04, (int) $spba756f->post($sp387f04)); } } } function setItem(Request $spba756f) { $sp387f04 = $spba756f->post('name'); $sp4a2047 = $spba756f->post('value'); if (!$sp387f04 || !$sp4a2047) { return Response::forbidden(); } \App\System::_set($sp387f04, $sp4a2047); return Response::success(); } function info(Request $spba756f) { $sp6fedaf = array('app_name', 'app_title', 'app_url', 'app_url_api', 'keywords', 'description', 'shop_ann', 'shop_ann_pop', 'shop_qq', 'company', 'js_tj', 'js_kf'); $sp0ec45a = array('shop_inventory'); if ($spba756f->isMethod('GET')) { $spf3616d = array(); foreach ($sp6fedaf as $sp387f04) { $spf3616d[$sp387f04] = \App\System::_get($sp387f04); } foreach ($sp0ec45a as $sp387f04) { $spf3616d[$sp387f04] = (int) \App\System::_get($sp387f04); } return Response::success($spf3616d); } $sp0784c1 = array('app_url' => Helper::format_url($_POST['app_url']), 'app_url_api' => Helper::format_url($_POST['app_url_api'])); $spba756f->merge($sp0784c1); $this->set($spba756f, $sp6fedaf); $this->setInt($spba756f, $sp0ec45a); return Response::success(); } function theme(Request $spba756f) { if ($spba756f->isMethod('GET')) { \App\ShopTheme::freshList(); return Response::success(array('themes' => \App\ShopTheme::get(), 'default' => \App\ShopTheme::defaultTheme()->name)); } $spf289bd = \App\ShopTheme::whereName($spba756f->post('shop_theme'))->firstOrFail(); \App\System::_set('shop_theme_default', $spf289bd->name); $spf289bd->config = @json_decode($spba756f->post('theme_config')) ?? array(); $spf289bd->saveOrFail(); return Response::success(); } function order(Request $spba756f) { $spa4106d = array('order_clean_unpay_open', 'order_clean_unpay_day'); if ($spba756f->isMethod('GET')) { $spf3616d = array(); foreach ($spa4106d as $sp387f04) { $spf3616d[$sp387f04] = (int) \App\System::_get($sp387f04); } return Response::success($spf3616d); } $this->setInt($spba756f, $spa4106d); return Response::success(); } function vcode(Request $spba756f) { $sp6fedaf = array('vcode_driver', 'vcode_geetest_id', 'vcode_geetest_key'); $sp0ec45a = array('vcode_login', 'vcode_shop_buy', 'vcode_shop_search'); if ($spba756f->isMethod('GET')) { $spf3616d = array(); foreach ($sp6fedaf as $sp387f04) { $spf3616d[$sp387f04] = \App\System::_get($sp387f04); } foreach ($sp0ec45a as $sp387f04) { $spf3616d[$sp387f04] = (int) \App\System::_get($sp387f04); } return Response::success($spf3616d); } $this->set($spba756f, $sp6fedaf); $this->setInt($spba756f, $sp0ec45a); return Response::success(); } function email(Request $spba756f) { $sp6fedaf = array('mail_driver', 'mail_smtp_host', 'mail_smtp_port', 'mail_smtp_username', 'mail_smtp_password', 'mail_smtp_from_address', 'mail_smtp_from_name', 'mail_smtp_encryption', 'sendcloud_user', 'sendcloud_key'); $sp0ec45a = array('mail_send_order', 'mail_send_order_use_contact'); if ($spba756f->isMethod('GET')) { $spf3616d = array(); foreach ($sp6fedaf as $sp387f04) { $spf3616d[$sp387f04] = \App\System::_get($sp387f04); } foreach ($sp0ec45a as $sp387f04) { $spf3616d[$sp387f04] = (int) \App\System::_get($sp387f04); } return Response::success($spf3616d); } $this->set($spba756f, $sp6fedaf); $this->setInt($spba756f, $sp0ec45a); return Response::success(); } function sms(Request $spba756f) { $sp6fedaf = array('sms_api_id', 'sms_api_key'); $sp0ec45a = array('sms_send_order', 'sms_price'); if ($spba756f->isMethod('GET')) { $spf3616d = array(); foreach ($sp6fedaf as $sp387f04) { $spf3616d[$sp387f04] = \App\System::_get($sp387f04); } foreach ($sp0ec45a as $sp387f04) { $spf3616d[$sp387f04] = (int) \App\System::_get($sp387f04); } return Response::success($spf3616d); } $this->set($spba756f, $sp6fedaf); $this->setInt($spba756f, $sp0ec45a); return Response::success(); } function storage(Request $spba756f) { $sp6fedaf = array('storage_driver', 'storage_s3_access_key', 'storage_s3_secret_key', 'storage_s3_region', 'storage_s3_bucket', 'storage_oss_access_key', 'storage_oss_secret_key', 'storage_oss_bucket', 'storage_oss_endpoint', 'storage_oss_cdn_domain', 'storage_qiniu_domains_default', 'storage_qiniu_domains_https', 'storage_qiniu_access_key', 'storage_qiniu_secret_key', 'storage_qiniu_bucket', 'storage_qiniu_notify_url'); $sp0ec45a = array('storage_oss_is_ssl', 'storage_oss_is_cname'); if ($spba756f->isMethod('GET')) { $spf3616d = array(); foreach ($sp6fedaf as $sp387f04) { $spf3616d[$sp387f04] = \App\System::_get($sp387f04); } foreach ($sp0ec45a as $sp387f04) { $spf3616d[$sp387f04] = (int) \App\System::_get($sp387f04); } return Response::success($spf3616d); } $this->set($spba756f, $sp6fedaf); $this->set($spba756f, $sp0ec45a); return Response::success(); } function emailTest(Request $spba756f) { $this->validate($spba756f, array('to' => 'required')); $spa17e0b = $spba756f->post('to'); try { $sp5359c9 = Mail::to($spa17e0b)->send(new \App\Mail\Test()); return Response::success($sp5359c9); } catch (\Throwable $sp6a7295) { \App\Library\LogHelper::setLogFile('mail'); \Log::error('Mail Test Exception:' . $sp6a7295->getMessage()); return Response::fail($sp6a7295->getMessage(), $sp6a7295); } } function orderClean(Request $spba756f) { $this->validate($spba756f, array('day' => 'required|integer|min:1')); $sp8d35f0 = (int) $spba756f->post('day'); \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new \Carbon\Carbon())->addDays(-$sp8d35f0))->delete(); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index c76755bfe..2d6840644 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,2 +1,2 @@ '维护中', 'message' => $sp65b1ce)); die; } } protected function msg($sp478b36, $sp189a2d = null, $sp0ee84b = null) { return view('message', array('message' => $sp478b36, 'title' => $sp189a2d, 'exception' => $sp0ee84b)); } } \ No newline at end of file +namespace App\Http\Controllers; use App\System; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Http\Request; class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; function authQuery(Request $spba756f, $spec1fe7, $sp91f1f0 = 'user_id', $sp162d03 = 'user_id') { return $spec1fe7::where($sp91f1f0, \Auth::id()); } protected function getUserId(Request $spba756f, $sp162d03 = 'user_id') { return \Auth::id(); } protected function getUserIdOrFail(Request $spba756f, $sp162d03 = 'user_id') { $spf5ae13 = self::getUserId($spba756f, $sp162d03); if ($spf5ae13) { return $spf5ae13; } else { throw new \Exception('参数缺少 ' . $sp162d03); } } protected function getUser(Request $spba756f) { return \Auth::getUser(); } protected function checkIsInMaintain() { if ((int) System::_get('maintain') === 1) { $spd13281 = System::_get('maintain_info'); echo view('message', array('title' => '维护中', 'message' => $spd13281)); die; } } protected function msg($sp4cabc4, $spa3831c = null, $sp6724ce = null) { return view('message', array('message' => $sp4cabc4, 'title' => $spa3831c, 'exception' => $sp6724ce)); } } \ No newline at end of file diff --git a/app/Http/Controllers/DevController.php b/app/Http/Controllers/DevController.php index d14e7139e..bc245f63e 100644 --- a/app/Http/Controllers/DevController.php +++ b/app/Http/Controllers/DevController.php @@ -1,2 +1,2 @@ R
'; return true; } else { echo $sp5181dc . ' ...... R
'; return false; } } else { if (file_exists($sp5181dc)) { return is_readable($sp5181dc); } } echo $sp5181dc . ' ...... 文件不存在
'; return false; } private function check_writable_r($sp5181dc) { if (is_dir($sp5181dc)) { if (is_writable($sp5181dc)) { $sp7abc41 = scandir($sp5181dc); foreach ($sp7abc41 as $sp71e4c8) { if ($sp71e4c8 != '.' && $sp71e4c8 != '..') { if (!self::check_writable_r($sp5181dc . '/' . $sp71e4c8)) { return false; } else { continue; } } } echo $sp5181dc . ' ...... W
'; return true; } else { echo $sp5181dc . ' ...... W
'; return false; } } else { if (file_exists($sp5181dc)) { return is_writable($sp5181dc); } } echo $sp5181dc . ' ...... 文件不存在
'; return false; } private function checkPathPermission($spde3d9c) { self::check_readable_r($spde3d9c); self::check_writable_r($spde3d9c); } public function install() { $spa6bbd3 = array(); @ob_start(); self::checkPathPermission(base_path('storage')); self::checkPathPermission(base_path('bootstrap/cache')); $spa6bbd3['permission'] = @ob_get_clean(); return view('install', array('var' => $spa6bbd3)); } public function test(Request $spa27895) { } } \ No newline at end of file +namespace App\Http\Controllers; use App\System; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; class DevController extends Controller { private function check_readable_r($spbc0e03) { if (is_dir($spbc0e03)) { if (is_readable($spbc0e03)) { $sp8a1688 = scandir($spbc0e03); foreach ($sp8a1688 as $spdbc829) { if ($spdbc829 != '.' && $spdbc829 != '..') { if (!self::check_readable_r($spbc0e03 . '/' . $spdbc829)) { return false; } else { continue; } } } echo $spbc0e03 . ' ...... R
'; return true; } else { echo $spbc0e03 . ' ...... R
'; return false; } } else { if (file_exists($spbc0e03)) { return is_readable($spbc0e03); } } echo $spbc0e03 . ' ...... 文件不存在
'; return false; } private function check_writable_r($spbc0e03) { if (is_dir($spbc0e03)) { if (is_writable($spbc0e03)) { $sp8a1688 = scandir($spbc0e03); foreach ($sp8a1688 as $spdbc829) { if ($spdbc829 != '.' && $spdbc829 != '..') { if (!self::check_writable_r($spbc0e03 . '/' . $spdbc829)) { return false; } else { continue; } } } echo $spbc0e03 . ' ...... W
'; return true; } else { echo $spbc0e03 . ' ...... W
'; return false; } } else { if (file_exists($spbc0e03)) { return is_writable($spbc0e03); } } echo $spbc0e03 . ' ...... 文件不存在
'; return false; } private function checkPathPermission($spffbc51) { self::check_readable_r($spffbc51); self::check_writable_r($spffbc51); } public function install() { $sp11e67e = array(); @ob_start(); self::checkPathPermission(base_path('storage')); self::checkPathPermission(base_path('bootstrap/cache')); $sp11e67e['permission'] = @ob_get_clean(); return view('install', array('var' => $sp11e67e)); } public function test(Request $spba756f) { } } \ No newline at end of file diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 2a3e0c4d6..e7ec33b17 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -1,8 +1,8 @@ config('app.url'), 'company' => config('app.company'), 'name' => config('app.name'), 'logo' => config('app.logo'), 'functions' => array()); if (System::_getInt('product_manual')) { $spfd6e52['functions'][] = 'product_manual'; } if (System::_getInt('mail_send_order')) { $spfd6e52['functions'][] = 'mail_send_order'; if (System::_getInt('mail_send_order_use_contact')) { $spfd6e52['functions'][] = 'mail_send_order_use_contact'; } } if (System::_getInt('sms_send_order')) { $spfd6e52['functions'][] = 'sms_send_order'; $spfd6e52['sms_send_order'] = array('sms_price' => System::_getInt('sms_price')); } $spfd6e52['shop'] = array('name' => config('app.name'), 'qq' => System::_get('shop_qq'), 'ann' => System::_get('shop_ann'), 'ann_pop' => System::_get('shop_ann_pop'), 'inventory' => System::_getInt('shop_inventory')); if ($sp1a3ec5) { $spd14ca3->setVisible(array('id', 'name', 'password_open')); if ($spd14ca3->password_open) { $spd14ca3->setAttribute('password', $spd14ca3->getTmpPassword()); $spd14ca3->addVisible(array('password')); } $sp1a3ec5->setForShop($sp845283); $spfd6e52['categories'] = array($spd14ca3); $spfd6e52['product'] = $sp1a3ec5; $sp104c39 = $sp1a3ec5->name . ' - ' . $spfd6e52['name']; $sp64c022 = $sp1a3ec5->description; if (@$sp64c022[0] === '{') { $spb53f50 = array(); preg_match_all('/"insert":"(.+?)"/', $sp64c022, $spb53f50); $sp64c022 = str_replace('\\n', ' ', @join(' ', $spb53f50[1])); } } elseif ($spd14ca3) { $spd14ca3->setVisible(array('id', 'name', 'password_open')); $spfd6e52['categories'] = array($spd14ca3); $spfd6e52['product'] = null; $sp104c39 = $spd14ca3->name . ' - ' . $spfd6e52['name']; $sp64c022 = $spd14ca3->name; } else { $spc225f9 = Category::where('user_id', $sp845283->id)->orderBy('sort')->where('enabled', 1)->get(); foreach ($spc225f9 as $spd14ca3) { $spd14ca3->setVisible(array('id', 'name', 'password_open')); } $spfd6e52['categories'] = $spc225f9; $sp104c39 = $spfd6e52['name']; $sp64c022 = $spfd6e52['shop']['ann']; if (@$sp64c022[0] === '{') { $spb53f50 = array(); preg_match_all('/"insert":"(.+?)"/', $sp64c022, $spb53f50); $sp64c022 = str_replace('\\n', ' ', @join(' ', $spb53f50[1])); } } $spfd6e52['vcode'] = array('driver' => System::_get('vcode_driver'), 'buy' => (int) System::_get('vcode_shop_buy'), 'search' => (int) System::_get('vcode_shop_search')); if ($spfd6e52['vcode']['driver'] === 'geetest' && ($spfd6e52['vcode'] || $spfd6e52['search'])) { $spfd6e52['vcode']['geetest'] = Geetest\API::get(); } $spfd6e52['pays'] = Pay::whereRaw('enabled&' . (Helper::is_mobile() ? Pay::ENABLED_MOBILE : Pay::ENABLED_PC) . '!=0')->orderBy('sort')->get(array('id', 'name', 'img')); $spe44380 = Cookie::get('customer'); $sp620f5b = Cookie::make('customer', strlen($spe44380) !== 32 ? md5(str_random(16)) : $spe44380, 43200, null, null, false, false); $sp421ad6 = null; if (isset($_GET['theme'])) { $sp421ad6 = \App\ShopTheme::whereName($_GET['theme'])->first(); } if (!$sp421ad6) { $sp421ad6 = \App\ShopTheme::defaultTheme(); } $spfd6e52['theme'] = $sp845283->theme_config && isset($sp845283->theme_config[$sp421ad6->name]) ? $sp845283->theme_config[$sp421ad6->name] : $sp421ad6->config; if (isset($spfd6e52['theme']['background']) && $spfd6e52['theme']['background'] === '内置1') { $spfd6e52['theme']['background'] = Helper::b1_rand_background(); } if ($sp1a3ec5 === null) { if (@$spfd6e52['theme']['list_type'] === 'list') { foreach ($spfd6e52['categories'] as $spf10bec) { if (!$spf10bec->password_open) { $spf10bec->getProductsForShop(); } } } else { if (count($spfd6e52['categories']) === 1) { $spf10bec = $spfd6e52['categories'][0]; if (!$spf10bec->password_open) { $spf10bec->getProductsForShop(); } } } } return response()->view('shop_theme.' . $sp421ad6->name . '.index', array('name' => $sp104c39, 'title' => config('app.title'), 'keywords' => preg_replace('/[、,;。!?]/', ', ', $sp104c39), 'description' => $sp64c022, 'js_tj' => System::_get('js_tj'), 'js_kf' => System::_get('js_kf'), 'config' => $spfd6e52))->cookie($sp620f5b); } private function _shop_404() { $this->checkIsInMaintain(); return view('message', array('title' => '404 NotFound', 'message' => '该链接不存在
-查询订单')); } public function shop_default(Request $spa27895) { $sp818393 = $spa27895->get('tab', ''); return response()->redirectTo('/?theme=Material#/record?tab=' . $sp818393); } public function shop_category($sp3afab5) { $this->checkIsInMaintain(); $spd14ca3 = Category::whereId(Helper::id_decode($sp3afab5, Helper::ID_TYPE_CATEGORY))->with('user')->first(); if (!$spd14ca3 && is_numeric($spd14ca3)) { $spd14ca3 = Category::whereId($sp3afab5)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with('user')->first(); } if (!$spd14ca3) { return $this->_shop_404(); } return $this->_shop_render($spd14ca3->user, $spd14ca3); } public function shop_product(Request $spa27895, $sp2b52e9) { $this->checkIsInMaintain(); $sp1a3ec5 = Product::whereId(Helper::id_decode($sp2b52e9, Helper::ID_TYPE_PRODUCT))->with(array('user', 'category'))->first(); if (!$sp1a3ec5 && is_numeric($sp2b52e9)) { $sp1a3ec5 = Product::whereId($sp2b52e9)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with(array('user', 'category'))->first(); } if (!$sp1a3ec5 || !$sp1a3ec5->category) { return $this->_shop_404(); } if ($sp1a3ec5->password_open && $sp1a3ec5->password !== $spa27895->input('p')) { return view('message', array('title' => '当前商品需要密码', 'message' => ($spa27895->has('p') ? '密码错误,请重新输入' : '请输入密码') . '
+namespace App\Http\Controllers; use App\Category; use App\Library\Helper; use App\Pay; use App\Product; use App\System; use App\User; use App\UserDomain; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use App\Library\Geetest; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cookie; class HomeController extends Controller { private function _shop_render($spac34b1, $sp1cd1e4 = null, $sp9dfc99 = null) { $spf3616d = array('url' => config('app.url'), 'company' => config('app.company'), 'name' => config('app.name'), 'logo' => config('app.logo'), 'functions' => array()); if (System::_getInt('product_manual')) { $spf3616d['functions'][] = 'product_manual'; } if (System::_getInt('mail_send_order')) { $spf3616d['functions'][] = 'mail_send_order'; if (System::_getInt('mail_send_order_use_contact')) { $spf3616d['functions'][] = 'mail_send_order_use_contact'; } } if (System::_getInt('sms_send_order')) { $spf3616d['functions'][] = 'sms_send_order'; $spf3616d['sms_send_order'] = array('sms_price' => System::_getInt('sms_price')); } $spf3616d['shop'] = array('name' => config('app.name'), 'qq' => System::_get('shop_qq'), 'ann' => System::_get('shop_ann'), 'ann_pop' => System::_get('shop_ann_pop'), 'inventory' => System::_getInt('shop_inventory')); if ($sp9dfc99) { $sp1cd1e4->setVisible(array('id', 'name', 'password_open')); if ($sp1cd1e4->password_open) { $sp1cd1e4->setAttribute('password', $sp1cd1e4->getTmpPassword()); $sp1cd1e4->addVisible(array('password')); } $sp9dfc99->setForShop($spac34b1); $spf3616d['categories'] = array($sp1cd1e4); $spf3616d['product'] = $sp9dfc99; $sp387f04 = $sp9dfc99->name . ' - ' . $spf3616d['name']; $spfed9d4 = $sp9dfc99->description; if (@$spfed9d4[0] === '{') { $sp8e1538 = array(); preg_match_all('/"insert":"(.+?)"/', $spfed9d4, $sp8e1538); $spfed9d4 = str_replace('\\n', ' ', @join(' ', $sp8e1538[1])); } } elseif ($sp1cd1e4) { $sp1cd1e4->setVisible(array('id', 'name', 'password_open')); $spf3616d['categories'] = array($sp1cd1e4); $spf3616d['product'] = null; $sp387f04 = $sp1cd1e4->name . ' - ' . $spf3616d['name']; $spfed9d4 = $sp1cd1e4->name; } else { $sp3cda33 = Category::where('user_id', $spac34b1->id)->orderBy('sort')->where('enabled', 1)->get(); foreach ($sp3cda33 as $sp1cd1e4) { $sp1cd1e4->setVisible(array('id', 'name', 'password_open')); } $spf3616d['categories'] = $sp3cda33; $sp387f04 = $spf3616d['name']; $spfed9d4 = $spf3616d['shop']['ann']; if (@$spfed9d4[0] === '{') { $sp8e1538 = array(); preg_match_all('/"insert":"(.+?)"/', $spfed9d4, $sp8e1538); $spfed9d4 = str_replace('\\n', ' ', @join(' ', $sp8e1538[1])); } } $spf3616d['vcode'] = array('driver' => System::_get('vcode_driver'), 'buy' => (int) System::_get('vcode_shop_buy'), 'search' => (int) System::_get('vcode_shop_search')); if ($spf3616d['vcode']['driver'] === 'geetest' && ($spf3616d['vcode'] || $spf3616d['search'])) { $spf3616d['vcode']['geetest'] = Geetest\API::get(); } $spf3616d['pays'] = Pay::whereRaw('enabled&' . (Helper::is_mobile() ? Pay::ENABLED_MOBILE : Pay::ENABLED_PC) . '!=0')->orderBy('sort')->get(array('id', 'name', 'img')); $sp5ac530 = Cookie::get('customer'); $speed4bf = Cookie::make('customer', strlen($sp5ac530) !== 32 ? md5(str_random(16)) : $sp5ac530, 43200, null, null, false, false); $spf289bd = null; if (isset($_GET['theme'])) { $spf289bd = \App\ShopTheme::whereName($_GET['theme'])->first(); } if (!$spf289bd) { $spf289bd = \App\ShopTheme::defaultTheme(); } $spf3616d['theme'] = $spac34b1->theme_config && isset($spac34b1->theme_config[$spf289bd->name]) ? $spac34b1->theme_config[$spf289bd->name] : $spf289bd->config; if (isset($spf3616d['theme']['background']) && $spf3616d['theme']['background'] === '内置1') { $spf3616d['theme']['background'] = Helper::b1_rand_background(); } if ($sp9dfc99 === null) { if (@$spf3616d['theme']['list_type'] === 'list') { foreach ($spf3616d['categories'] as $spd2ab5e) { if (!$spd2ab5e->password_open) { $spd2ab5e->getProductsForShop(); } } } else { if (count($spf3616d['categories']) === 1) { $spd2ab5e = $spf3616d['categories'][0]; if (!$spd2ab5e->password_open) { $spd2ab5e->getProductsForShop(); } } } } return response()->view('shop_theme.' . $spf289bd->name . '.index', array('name' => $sp387f04, 'title' => config('app.title'), 'keywords' => preg_replace('/[、,;。!?]/', ', ', $sp387f04), 'description' => $spfed9d4, 'js_tj' => System::_get('js_tj'), 'js_kf' => System::_get('js_kf'), 'config' => $spf3616d))->cookie($speed4bf); } private function _shop_404() { $this->checkIsInMaintain(); return view('message', array('title' => '404 NotFound', 'message' => '该链接不存在
+查询订单')); } public function shop_default(Request $spba756f) { $sp8625c0 = $spba756f->get('tab', ''); return response()->redirectTo('/?theme=Material#/record?tab=' . $sp8625c0); } public function shop_category($sp2a05ea) { $this->checkIsInMaintain(); $sp1cd1e4 = Category::whereId(Helper::id_decode($sp2a05ea, Helper::ID_TYPE_CATEGORY))->with('user')->first(); if (!$sp1cd1e4 && is_numeric($sp1cd1e4)) { $sp1cd1e4 = Category::whereId($sp2a05ea)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with('user')->first(); } if (!$sp1cd1e4) { return $this->_shop_404(); } return $this->_shop_render($sp1cd1e4->user, $sp1cd1e4); } public function shop_product(Request $spba756f, $sp057c0e) { $this->checkIsInMaintain(); $sp9dfc99 = Product::whereId(Helper::id_decode($sp057c0e, Helper::ID_TYPE_PRODUCT))->with(array('user', 'category'))->first(); if (!$sp9dfc99 && is_numeric($sp057c0e)) { $sp9dfc99 = Product::whereId($sp057c0e)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with(array('user', 'category'))->first(); } if (!$sp9dfc99 || !$sp9dfc99->category) { return $this->_shop_404(); } if ($sp9dfc99->password_open && $sp9dfc99->password !== $spba756f->input('p')) { return view('message', array('title' => '当前商品需要密码', 'message' => ($spba756f->has('p') ? '密码错误,请重新输入' : '请输入密码') . '
-')); } return $this->_shop_render($sp1a3ec5->user, $sp1a3ec5->category, $sp1a3ec5); } public function shop() { $this->checkIsInMaintain(); $sp845283 = User::firstOrFail(); return $this->_shop_render($sp845283); } public function admin() { $spfd6e52 = array(); $spfd6e52['url'] = config('app.url'); if (System::_getInt('product_manual')) { $spfd6e52['functions'] = array('product_manual'); } $spfd6e52['vcode'] = array('driver' => System::_get('vcode_driver'), 'login' => (int) System::_get('vcode_login')); if ($spfd6e52['vcode']['driver'] === 'geetest') { $spfd6e52['vcode']['geetest'] = Geetest\API::get(); } return view('admin', array('config' => $spfd6e52)); } } \ No newline at end of file +')); } return $this->_shop_render($sp9dfc99->user, $sp9dfc99->category, $sp9dfc99); } public function shop() { $this->checkIsInMaintain(); $spac34b1 = User::firstOrFail(); return $this->_shop_render($spac34b1); } public function admin() { $spf3616d = array(); $spf3616d['url'] = config('app.url'); if (System::_getInt('product_manual')) { $spf3616d['functions'] = array('product_manual'); } $spf3616d['vcode'] = array('driver' => System::_get('vcode_driver'), 'login' => (int) System::_get('vcode_login')); if ($spf3616d['vcode']['driver'] === 'geetest') { $spf3616d['vcode']['geetest'] = Geetest\API::get(); } return view('admin', array('config' => $spf3616d)); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Card.php b/app/Http/Controllers/Merchant/Card.php index eb074b32c..4823fbb41 100644 --- a/app/Http/Controllers/Merchant/Card.php +++ b/app/Http/Controllers/Merchant/Card.php @@ -1,4 +1,4 @@ authQuery($spa27895, \App\Card::class)->with(array('product' => function ($sp7e6fa3) { $sp7e6fa3->select(array('id', 'name')); })); $spfe451d = $spa27895->input('search', false); $sp0edb8f = $spa27895->input('val', false); if ($spfe451d && $sp0edb8f) { if ($spfe451d == 'id') { $sp7e6fa3->where('id', $sp0edb8f); } else { $sp7e6fa3->where($spfe451d, 'like', '%' . $sp0edb8f . '%'); } } $sp980f44 = (int) $spa27895->input('category_id'); $sp112a12 = $spa27895->input('product_id', -1); if ($sp980f44 > 0) { if ($sp112a12 > 0) { $sp7e6fa3->where('product_id', $sp112a12); } else { $sp7e6fa3->whereHas('product', function ($sp7e6fa3) use($sp980f44) { $sp7e6fa3->where('category_id', $sp980f44); }); } } $spf66c3d = $spa27895->input('status'); if (strlen($spf66c3d)) { $sp7e6fa3->whereIn('status', explode(',', $spf66c3d)); } $sp117066 = (int) $spa27895->input('onlyCanSell'); if ($sp117066) { $sp7e6fa3->whereRaw('`count_all`>`count_sold`'); } $sp460df4 = $spa27895->input('type'); if (strlen($sp460df4)) { $sp7e6fa3->whereIn('type', explode(',', $sp460df4)); } $spe3e595 = $spa27895->input('trashed') === 'true'; if ($spe3e595) { $sp7e6fa3->onlyTrashed(); } if ($sp6b5a40 === true) { if ($spe3e595) { $sp7e6fa3->forceDelete(); } else { \App\Card::_trash($sp7e6fa3); } return Response::success(); } else { if ($spe3e595 && $spd22a73 === true) { \App\Card::_restore($sp7e6fa3); return Response::success(); } else { $sp7e6fa3->orderByRaw('`product_id`,`type`,`status`,`id`'); if ($sp4de76b === true) { $sp83cda3 = ''; $sp7e6fa3->chunk(100, function ($sp16ec83) use(&$sp83cda3) { foreach ($sp16ec83 as $sp089eb8) { $sp83cda3 .= $sp089eb8->card . ' -'; } }); $sp69a6c1 = 'export_cards_' . $this->getUserIdOrFail($spa27895) . '_' . date('YmdHis') . '.txt'; $sp697dbb = array('Content-type' => 'text/plain', 'Content-Disposition' => sprintf('attachment; filename="%s"', $sp69a6c1), 'Content-Length' => strlen($sp83cda3)); return response()->make($sp83cda3, 200, $sp697dbb); } $spf69625 = $spa27895->input('current_page', 1); $spe8f5a8 = $spa27895->input('per_page', 20); $sp966ae1 = $sp7e6fa3->paginate($spe8f5a8, array('*'), 'page', $spf69625); return Response::success($sp966ae1); } } } function export(Request $spa27895) { return self::get($spa27895, true); } function trash(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string')); $sp8e4c06 = $spa27895->post('ids'); $sp7e6fa3 = $this->authQuery($spa27895, \App\Card::class)->whereIn('id', explode(',', $sp8e4c06)); \App\Card::_trash($sp7e6fa3); return Response::success(); } function restoreTrashed(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string')); $sp8e4c06 = $spa27895->post('ids'); $sp7e6fa3 = $this->authQuery($spa27895, \App\Card::class)->whereIn('id', explode(',', $sp8e4c06)); \App\Card::_restore($sp7e6fa3); return Response::success(); } function deleteTrashed(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string')); $sp8e4c06 = $spa27895->post('ids'); $this->authQuery($spa27895, \App\Card::class)->whereIn('id', explode(',', $sp8e4c06))->forceDelete(); return Response::success(); } function deleteAll(Request $spa27895) { return $this->get($spa27895, false, true); } function restoreAll(Request $spa27895) { return $this->get($spa27895, false, false, true); } function add(Request $spa27895) { $sp112a12 = (int) $spa27895->post('product_id'); $sp16ec83 = $spa27895->post('card'); $sp460df4 = (int) $spa27895->post('type', \App\Card::TYPE_ONETIME); $sp46a9f0 = $spa27895->post('is_check') === 'true'; if (str_contains($sp16ec83, '<') || str_contains($sp16ec83, '>')) { return Response::fail('卡密不能包含 < 或 > 符号'); } $sp258cf6 = $this->getUserIdOrFail($spa27895); $sp40a694 = $this->authQuery($spa27895, \App\Product::class)->where('id', $sp112a12); $sp40a694->firstOrFail(array('id')); if ($sp460df4 === \App\Card::TYPE_REPEAT) { if ($sp46a9f0) { if (\App\Card::where('product_id', $sp112a12)->where('card', $sp16ec83)->exists()) { return Response::fail('该卡密已经存在,添加失败'); } } $sp089eb8 = new \App\Card(array('user_id' => $sp258cf6, 'product_id' => $sp112a12, 'card' => $sp16ec83, 'type' => \App\Card::TYPE_REPEAT, 'count_sold' => 0, 'count_all' => (int) $spa27895->post('count_all', 1))); if ($sp089eb8->count_all < 1 || $sp089eb8->count_all > 10000000) { return Response::forbidden('可售总次数不能超过10000000'); } return DB::transaction(function () use($sp40a694, $sp089eb8) { $sp089eb8->saveOrFail(); $sp1a3ec5 = $sp40a694->lockForUpdate()->firstOrFail(); $sp1a3ec5->count_all += $sp089eb8->count_all; $sp1a3ec5->saveOrFail(); return Response::success(); }); } else { $sp7c8ced = explode(' -', $sp16ec83); $sp8a0be2 = count($sp7c8ced); $sp548e1c = 50000; if ($sp8a0be2 > $sp548e1c) { return Response::fail('每次添加不能超过 ' . $sp548e1c . ' 张'); } $sp3e85cb = array(); if ($sp46a9f0) { $sp5584cd = \App\Card::where('user_id', $sp258cf6)->where('product_id', $sp112a12)->get(array('card'))->all(); foreach ($sp5584cd as $sp06e543) { $sp3e85cb[] = $sp06e543['card']; } } $sp0000d8 = array(); $sp900843 = 0; for ($spe20094 = 0; $spe20094 < $sp8a0be2; $spe20094++) { $spa7f003 = trim($sp7c8ced[$spe20094]); if (strlen($spa7f003) < 1) { continue; } if (strlen($spa7f003) > 255) { return Response::fail('第 ' . $spe20094 . ' 张卡密 ' . $spa7f003 . ' 长度错误
卡密最大长度为255'); } if ($sp46a9f0) { if (in_array($spa7f003, $sp3e85cb)) { continue; } $sp3e85cb[] = $spa7f003; } $sp0000d8[] = array('user_id' => $sp258cf6, 'product_id' => $sp112a12, 'card' => $spa7f003, 'type' => \App\Card::TYPE_ONETIME); $sp900843++; } if ($sp900843 === 0) { return Response::success(); } return DB::transaction(function () use($sp40a694, $sp0000d8, $sp900843) { \App\Card::insert($sp0000d8); $sp1a3ec5 = $sp40a694->lockForUpdate()->firstOrFail(); $sp1a3ec5->count_all += $sp900843; $sp1a3ec5->saveOrFail(); return Response::success(); }); } } function edit(Request $spa27895) { $sp746ee1 = (int) $spa27895->post('id'); $sp089eb8 = $this->authQuery($spa27895, \App\Card::class)->findOrFail($sp746ee1); if ($sp089eb8) { $sp851f68 = $spa27895->post('card'); $sp460df4 = (int) $spa27895->post('type', \App\Card::TYPE_ONETIME); $sp31a840 = (int) $spa27895->post('count_all', 1); return DB::transaction(function () use($sp089eb8, $sp851f68, $sp460df4, $sp31a840) { $sp089eb8 = \App\Card::where('id', $sp089eb8->id)->lockForUpdate()->firstOrFail(); $sp089eb8->card = $sp851f68; $sp089eb8->type = $sp460df4; if ($sp089eb8->type === \App\Card::TYPE_REPEAT) { if ($sp31a840 < $sp089eb8->count_sold) { return Response::forbidden('可售总次数不能低于当前已售次数'); } if ($sp31a840 < 1 || $sp31a840 > 10000000) { return Response::forbidden('可售总次数不能超过10000000'); } $sp089eb8->count_all = $sp31a840; } else { $sp089eb8->count_all = 1; } $sp089eb8->saveOrFail(); $sp1a3ec5 = $sp089eb8->product()->lockForUpdate()->firstOrFail(); $sp1a3ec5->count_all -= $sp089eb8->count_all; $sp1a3ec5->count_all += $sp31a840; $sp1a3ec5->saveOrFail(); return Response::success(); }); } return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Merchant; use App\Library\Response; use App\System; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; class Card extends Controller { function get(Request $spba756f, $spe71412 = false, $sp90f231 = false, $sp3ff80d = false) { $spca8acc = $this->authQuery($spba756f, \App\Card::class)->with(array('product' => function ($spca8acc) { $spca8acc->select(array('id', 'name')); })); $speeddd9 = $spba756f->input('search', false); $spe1fc85 = $spba756f->input('val', false); if ($speeddd9 && $spe1fc85) { if ($speeddd9 == 'id') { $spca8acc->where('id', $spe1fc85); } else { $spca8acc->where($speeddd9, 'like', '%' . $spe1fc85 . '%'); } } $sp55f32c = (int) $spba756f->input('category_id'); $sp1b83a8 = $spba756f->input('product_id', -1); if ($sp55f32c > 0) { if ($sp1b83a8 > 0) { $spca8acc->where('product_id', $sp1b83a8); } else { $spca8acc->whereHas('product', function ($spca8acc) use($sp55f32c) { $spca8acc->where('category_id', $sp55f32c); }); } } $sp732cf7 = $spba756f->input('status'); if (strlen($sp732cf7)) { $spca8acc->whereIn('status', explode(',', $sp732cf7)); } $sp194b3c = (int) $spba756f->input('onlyCanSell'); if ($sp194b3c) { $spca8acc->whereRaw('`count_all`>`count_sold`'); } $spe7b1c7 = $spba756f->input('type'); if (strlen($spe7b1c7)) { $spca8acc->whereIn('type', explode(',', $spe7b1c7)); } $sp09ee91 = $spba756f->input('trashed') === 'true'; if ($sp09ee91) { $spca8acc->onlyTrashed(); } if ($sp90f231 === true) { if ($sp09ee91) { $spca8acc->forceDelete(); } else { \App\Card::_trash($spca8acc); } return Response::success(); } else { if ($sp09ee91 && $sp3ff80d === true) { \App\Card::_restore($spca8acc); return Response::success(); } else { $spca8acc->orderByRaw('`product_id`,`type`,`status`,`id`'); if ($spe71412 === true) { $sp93a446 = ''; $spca8acc->chunk(100, function ($sp137cd7) use(&$sp93a446) { foreach ($sp137cd7 as $spa9cef2) { $sp93a446 .= $spa9cef2->card . ' +'; } }); $spe6c5dc = 'export_cards_' . $this->getUserIdOrFail($spba756f) . '_' . date('YmdHis') . '.txt'; $sp3e89cf = array('Content-type' => 'text/plain', 'Content-Disposition' => sprintf('attachment; filename="%s"', $spe6c5dc), 'Content-Length' => strlen($sp93a446)); return response()->make($sp93a446, 200, $sp3e89cf); } $sp881a75 = $spba756f->input('current_page', 1); $sp2a01a9 = $spba756f->input('per_page', 20); $spfea7ce = $spca8acc->paginate($sp2a01a9, array('*'), 'page', $sp881a75); return Response::success($spfea7ce); } } } function export(Request $spba756f) { return self::get($spba756f, true); } function trash(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string')); $sp12026a = $spba756f->post('ids'); $spca8acc = $this->authQuery($spba756f, \App\Card::class)->whereIn('id', explode(',', $sp12026a)); \App\Card::_trash($spca8acc); return Response::success(); } function restoreTrashed(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string')); $sp12026a = $spba756f->post('ids'); $spca8acc = $this->authQuery($spba756f, \App\Card::class)->whereIn('id', explode(',', $sp12026a)); \App\Card::_restore($spca8acc); return Response::success(); } function deleteTrashed(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string')); $sp12026a = $spba756f->post('ids'); $this->authQuery($spba756f, \App\Card::class)->whereIn('id', explode(',', $sp12026a))->forceDelete(); return Response::success(); } function deleteAll(Request $spba756f) { return $this->get($spba756f, false, true); } function restoreAll(Request $spba756f) { return $this->get($spba756f, false, false, true); } function add(Request $spba756f) { $sp1b83a8 = (int) $spba756f->post('product_id'); $sp137cd7 = $spba756f->post('card'); $spe7b1c7 = (int) $spba756f->post('type', \App\Card::TYPE_ONETIME); $spd3d838 = $spba756f->post('is_check') === 'true'; if (str_contains($sp137cd7, '<') || str_contains($sp137cd7, '>')) { return Response::fail('卡密不能包含 < 或 > 符号'); } $spf5ae13 = $this->getUserIdOrFail($spba756f); $sp94e351 = $this->authQuery($spba756f, \App\Product::class)->where('id', $sp1b83a8); $sp94e351->firstOrFail(array('id')); if ($spe7b1c7 === \App\Card::TYPE_REPEAT) { if ($spd3d838) { if (\App\Card::where('product_id', $sp1b83a8)->where('card', $sp137cd7)->exists()) { return Response::fail('该卡密已经存在,添加失败'); } } $spa9cef2 = new \App\Card(array('user_id' => $spf5ae13, 'product_id' => $sp1b83a8, 'card' => $sp137cd7, 'type' => \App\Card::TYPE_REPEAT, 'count_sold' => 0, 'count_all' => (int) $spba756f->post('count_all', 1))); if ($spa9cef2->count_all < 1 || $spa9cef2->count_all > 10000000) { return Response::forbidden('可售总次数不能超过10000000'); } return DB::transaction(function () use($sp94e351, $spa9cef2) { $spa9cef2->saveOrFail(); $sp9dfc99 = $sp94e351->lockForUpdate()->firstOrFail(); $sp9dfc99->count_all += $spa9cef2->count_all; $sp9dfc99->saveOrFail(); return Response::success(); }); } else { $spb73662 = explode(' +', $sp137cd7); $sp1def7a = count($spb73662); $sp9461d0 = 50000; if ($sp1def7a > $sp9461d0) { return Response::fail('每次添加不能超过 ' . $sp9461d0 . ' 张'); } $spcb374f = array(); if ($spd3d838) { $sp3d7961 = \App\Card::where('user_id', $spf5ae13)->where('product_id', $sp1b83a8)->get(array('card'))->all(); foreach ($sp3d7961 as $spb2b013) { $spcb374f[] = $spb2b013['card']; } } $spb26570 = array(); $spb668e0 = 0; for ($spc8f255 = 0; $spc8f255 < $sp1def7a; $spc8f255++) { $spec0853 = trim($spb73662[$spc8f255]); if (strlen($spec0853) < 1) { continue; } if (strlen($spec0853) > 255) { return Response::fail('第 ' . $spc8f255 . ' 张卡密 ' . $spec0853 . ' 长度错误
卡密最大长度为255'); } if ($spd3d838) { if (in_array($spec0853, $spcb374f)) { continue; } $spcb374f[] = $spec0853; } $spb26570[] = array('user_id' => $spf5ae13, 'product_id' => $sp1b83a8, 'card' => $spec0853, 'type' => \App\Card::TYPE_ONETIME); $spb668e0++; } if ($spb668e0 === 0) { return Response::success(); } return DB::transaction(function () use($sp94e351, $spb26570, $spb668e0) { \App\Card::insert($spb26570); $sp9dfc99 = $sp94e351->lockForUpdate()->firstOrFail(); $sp9dfc99->count_all += $spb668e0; $sp9dfc99->saveOrFail(); return Response::success(); }); } } function edit(Request $spba756f) { $sp8e8060 = (int) $spba756f->post('id'); $spa9cef2 = $this->authQuery($spba756f, \App\Card::class)->findOrFail($sp8e8060); if ($spa9cef2) { $spb66176 = $spba756f->post('card'); $spe7b1c7 = (int) $spba756f->post('type', \App\Card::TYPE_ONETIME); $sp5f45b6 = (int) $spba756f->post('count_all', 1); return DB::transaction(function () use($spa9cef2, $spb66176, $spe7b1c7, $sp5f45b6) { $spa9cef2 = \App\Card::where('id', $spa9cef2->id)->lockForUpdate()->firstOrFail(); $spa9cef2->card = $spb66176; $spa9cef2->type = $spe7b1c7; if ($spa9cef2->type === \App\Card::TYPE_REPEAT) { if ($sp5f45b6 < $spa9cef2->count_sold) { return Response::forbidden('可售总次数不能低于当前已售次数'); } if ($sp5f45b6 < 1 || $sp5f45b6 > 10000000) { return Response::forbidden('可售总次数不能超过10000000'); } $spa9cef2->count_all = $sp5f45b6; } else { $spa9cef2->count_all = 1; } $spa9cef2->saveOrFail(); $sp9dfc99 = $spa9cef2->product()->lockForUpdate()->firstOrFail(); $sp9dfc99->count_all -= $spa9cef2->count_all; $sp9dfc99->count_all += $sp5f45b6; $sp9dfc99->saveOrFail(); return Response::success(); }); } return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Category.php b/app/Http/Controllers/Merchant/Category.php index ec058d05a..8711d1264 100644 --- a/app/Http/Controllers/Merchant/Category.php +++ b/app/Http/Controllers/Merchant/Category.php @@ -1,2 +1,2 @@ post('current_page', 1); $spe8f5a8 = $spa27895->post('per_page', 20); $sp7e6fa3 = $this->authQuery($spa27895, \App\Category::class); $spfe451d = $spa27895->post('search', false); $sp0edb8f = $spa27895->post('val', false); if ($spfe451d && $sp0edb8f) { if ($spfe451d == 'simple') { return Response::success($sp7e6fa3->get(array('id', 'name'))); } elseif ($spfe451d == 'id') { $sp7e6fa3->where('id', $sp0edb8f); } else { $sp7e6fa3->where($spfe451d, 'like', '%' . $sp0edb8f . '%'); } } $sp2a8f09 = $spa27895->post('enabled'); if (strlen($sp2a8f09)) { $sp7e6fa3->whereIn('enabled', explode(',', $sp2a8f09)); } $sp966ae1 = $sp7e6fa3->withCount('products')->orderBy('sort')->paginate($spe8f5a8, array('*'), 'page', $spf69625); foreach ($sp966ae1->items() as $spd14ca3) { $spd14ca3->setAppends(array('url')); } return Response::success($sp966ae1); } function sort(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer')); $spd14ca3 = $this->authQuery($spa27895, \App\Category::class)->findOrFail($spa27895->post('id')); $spd14ca3->sort = (int) $spa27895->post('sort', 1000); $spd14ca3->save(); return Response::success(); } function edit(Request $spa27895) { $this->validate($spa27895, array('name' => 'required|string|max:128')); $sp104c39 = $spa27895->post('name'); $sp2a8f09 = (int) $spa27895->post('enabled'); $sp065312 = $spa27895->post('sort'); $sp065312 = $sp065312 === NULL ? 1000 : (int) $sp065312; if (System::_getInt('filter_words_open') === 1) { $spfe8b9b = explode('|', System::_get('filter_words')); if (($sp786169 = Helper::filterWords($sp104c39, $spfe8b9b)) !== false) { return Response::fail('提交失败! 分类名称包含敏感词: ' . $sp786169); } } if ($sp065312 < 0 || $sp065312 > 1000000) { return Response::fail('排序需要在0-1000000之间'); } $sp943c4c = $spa27895->post('password'); $sp637893 = $spa27895->post('password_open') === 'true'; if ((int) $spa27895->post('id')) { $spd14ca3 = $this->authQuery($spa27895, \App\Category::class)->findOrFail($spa27895->post('id')); } else { $spd14ca3 = new \App\Category(); $spd14ca3->user_id = $this->getUserIdOrFail($spa27895); } $spd14ca3->name = $sp104c39; $spd14ca3->sort = $sp065312; $spd14ca3->password = $sp943c4c; $spd14ca3->password_open = $sp637893; $spd14ca3->enabled = $sp2a8f09; $spd14ca3->saveOrFail(); return Response::success(); } function enable(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,1')); $sp8e4c06 = $spa27895->post('ids', ''); $sp2a8f09 = (int) $spa27895->post('enabled'); $this->authQuery($spa27895, \App\Category::class)->whereIn('id', explode(',', $sp8e4c06))->update(array('enabled' => $sp2a8f09)); return Response::success(); } function delete(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string')); $sp8e4c06 = $spa27895->post('ids', ''); $this->authQuery($spa27895, \App\Category::class)->whereIn('id', explode(',', $sp8e4c06))->delete(); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Merchant; use App\Library\Helper; use App\Library\Response; use App\System; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class Category extends Controller { function get(Request $spba756f) { $sp881a75 = $spba756f->post('current_page', 1); $sp2a01a9 = $spba756f->post('per_page', 20); $spca8acc = $this->authQuery($spba756f, \App\Category::class); $speeddd9 = $spba756f->post('search', false); $spe1fc85 = $spba756f->post('val', false); if ($speeddd9 && $spe1fc85) { if ($speeddd9 == 'simple') { return Response::success($spca8acc->get(array('id', 'name'))); } elseif ($speeddd9 == 'id') { $spca8acc->where('id', $spe1fc85); } else { $spca8acc->where($speeddd9, 'like', '%' . $spe1fc85 . '%'); } } $spc7c4ac = $spba756f->post('enabled'); if (strlen($spc7c4ac)) { $spca8acc->whereIn('enabled', explode(',', $spc7c4ac)); } $spfea7ce = $spca8acc->withCount('products')->orderBy('sort')->paginate($sp2a01a9, array('*'), 'page', $sp881a75); foreach ($spfea7ce->items() as $sp1cd1e4) { $sp1cd1e4->setAppends(array('url')); } return Response::success($spfea7ce); } function sort(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer')); $sp1cd1e4 = $this->authQuery($spba756f, \App\Category::class)->findOrFail($spba756f->post('id')); $sp1cd1e4->sort = (int) $spba756f->post('sort', 1000); $sp1cd1e4->save(); return Response::success(); } function edit(Request $spba756f) { $this->validate($spba756f, array('name' => 'required|string|max:128')); $sp387f04 = $spba756f->post('name'); $spc7c4ac = (int) $spba756f->post('enabled'); $spfdaefb = $spba756f->post('sort'); $spfdaefb = $spfdaefb === NULL ? 1000 : (int) $spfdaefb; if (System::_getInt('filter_words_open') === 1) { $sp585bcb = explode('|', System::_get('filter_words')); if (($sp5359c9 = Helper::filterWords($sp387f04, $sp585bcb)) !== false) { return Response::fail('提交失败! 分类名称包含敏感词: ' . $sp5359c9); } } if ($spfdaefb < 0 || $spfdaefb > 1000000) { return Response::fail('排序需要在0-1000000之间'); } $spdc3802 = $spba756f->post('password'); $spcb4f03 = $spba756f->post('password_open') === 'true'; if ((int) $spba756f->post('id')) { $sp1cd1e4 = $this->authQuery($spba756f, \App\Category::class)->findOrFail($spba756f->post('id')); } else { $sp1cd1e4 = new \App\Category(); $sp1cd1e4->user_id = $this->getUserIdOrFail($spba756f); } $sp1cd1e4->name = $sp387f04; $sp1cd1e4->sort = $spfdaefb; $sp1cd1e4->password = $spdc3802; $sp1cd1e4->password_open = $spcb4f03; $sp1cd1e4->enabled = $spc7c4ac; $sp1cd1e4->saveOrFail(); return Response::success(); } function enable(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,1')); $sp12026a = $spba756f->post('ids', ''); $spc7c4ac = (int) $spba756f->post('enabled'); $this->authQuery($spba756f, \App\Category::class)->whereIn('id', explode(',', $sp12026a))->update(array('enabled' => $spc7c4ac)); return Response::success(); } function delete(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string')); $sp12026a = $spba756f->post('ids', ''); $this->authQuery($spba756f, \App\Category::class)->whereIn('id', explode(',', $sp12026a))->delete(); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Coupon.php b/app/Http/Controllers/Merchant/Coupon.php index 5b8290c2b..9bc6fae04 100644 --- a/app/Http/Controllers/Merchant/Coupon.php +++ b/app/Http/Controllers/Merchant/Coupon.php @@ -1,3 +1,3 @@ authQuery($spa27895, \App\Coupon::class)->with(array('category' => function ($sp7e6fa3) { $sp7e6fa3->select(array('id', 'name')); }))->with(array('product' => function ($sp7e6fa3) { $sp7e6fa3->select(array('id', 'name')); })); $spfe451d = $spa27895->post('search', false); $sp0edb8f = $spa27895->post('val', false); if ($spfe451d && $sp0edb8f) { if ($spfe451d == 'id') { $sp7e6fa3->where('id', $sp0edb8f); } else { $sp7e6fa3->where($spfe451d, 'like', '%' . $sp0edb8f . '%'); } } $sp980f44 = (int) $spa27895->post('category_id'); $sp112a12 = $spa27895->post('product_id', -1); if ($sp980f44 > 0) { if ($sp112a12 > 0) { $sp7e6fa3->where('product_id', $sp112a12); } else { $sp7e6fa3->where('category_id', $sp980f44); } } $spf66c3d = $spa27895->post('status'); if (strlen($spf66c3d)) { $sp7e6fa3->whereIn('status', explode(',', $spf66c3d)); } $sp460df4 = $spa27895->post('type'); if (strlen($sp460df4)) { $sp7e6fa3->whereIn('type', explode(',', $sp460df4)); } $sp7e6fa3->orderByRaw('expire_at DESC,category_id,product_id,type,status'); $spf69625 = $spa27895->post('current_page', 1); $spe8f5a8 = $spa27895->post('per_page', 20); $sp966ae1 = $sp7e6fa3->paginate($spe8f5a8, array('*'), 'page', $spf69625); return Response::success($sp966ae1); } function create(Request $spa27895) { $spdf4a99 = $spa27895->post('count', 0); $sp460df4 = (int) $spa27895->post('type', \App\Coupon::TYPE_ONETIME); $sp9b3d20 = $spa27895->post('expire_at'); $sp39ae40 = (int) $spa27895->post('discount_val'); $spbade28 = (int) $spa27895->post('discount_type', \App\Coupon::DISCOUNT_TYPE_AMOUNT); $sp52fef6 = $spa27895->post('remark'); if ($spbade28 === \App\Coupon::DISCOUNT_TYPE_AMOUNT) { if ($sp39ae40 < 1 || $sp39ae40 > 1000000000) { return Response::fail('优惠券面额需要在0.01-10000000之间'); } } if ($spbade28 === \App\Coupon::DISCOUNT_TYPE_PERCENT) { if ($sp39ae40 < 1 || $sp39ae40 > 100) { return Response::fail('优惠券面额需要在1-100之间'); } } $sp980f44 = (int) $spa27895->post('category_id', -1); $sp112a12 = (int) $spa27895->post('product_id', -1); if ($sp460df4 === \App\Coupon::TYPE_REPEAT) { $sp2a00ee = $spa27895->post('coupon'); if (!$sp2a00ee) { $sp2a00ee = strtoupper(str_random()); } $sp1ea3c0 = new \App\Coupon(); $sp1ea3c0->user_id = $this->getUserIdOrFail($spa27895); $sp1ea3c0->category_id = $sp980f44; $sp1ea3c0->product_id = $sp112a12; $sp1ea3c0->coupon = $sp2a00ee; $sp1ea3c0->type = $sp460df4; $sp1ea3c0->discount_val = $sp39ae40; $sp1ea3c0->discount_type = $spbade28; $sp1ea3c0->count_all = (int) $spa27895->post('count_all', 1); if ($sp1ea3c0->count_all < 1 || $sp1ea3c0->count_all > 10000000) { return Response::fail('可用次数不能超过10000000'); } $sp1ea3c0->expire_at = $sp9b3d20; $sp1ea3c0->saveOrFail(); return Response::success(array($sp1ea3c0->coupon)); } elseif ($sp460df4 === \App\Coupon::TYPE_ONETIME) { if (!$spdf4a99) { return Response::forbidden('请输入生成数量'); } if ($spdf4a99 > 100) { return Response::forbidden('每次生成不能大于100张'); } $sp6de18e = array(); $spa97315 = array(); $sp258cf6 = $this->getUserIdOrFail($spa27895); $sp755c1b = Carbon::now(); for ($spe20094 = 0; $spe20094 < $spdf4a99; $spe20094++) { $sp1ea3c0 = strtoupper(str_random()); $spa97315[] = $sp1ea3c0; $sp6de18e[] = array('user_id' => $sp258cf6, 'coupon' => $sp1ea3c0, 'category_id' => $sp980f44, 'product_id' => $sp112a12, 'type' => $sp460df4, 'discount_val' => $sp39ae40, 'discount_type' => $spbade28, 'status' => \App\Coupon::STATUS_NORMAL, 'remark' => $sp52fef6, 'created_at' => $sp755c1b, 'expire_at' => $sp9b3d20); } \App\Coupon::insert($sp6de18e); return Response::success($spa97315); } else { return Response::forbidden('unknown type: ' . $sp460df4); } } function edit(Request $spa27895) { $sp746ee1 = (int) $spa27895->post('id'); $sp2a00ee = $spa27895->post('coupon'); $sp980f44 = (int) $spa27895->post('category_id', -1); $sp112a12 = (int) $spa27895->post('product_id', -1); $sp9b3d20 = $spa27895->post('expire_at', NULL); $spf66c3d = (int) $spa27895->post('status', \App\Coupon::STATUS_NORMAL); $sp460df4 = (int) $spa27895->post('type', \App\Coupon::TYPE_ONETIME); $sp39ae40 = (int) $spa27895->post('discount_val'); $spbade28 = (int) $spa27895->post('discount_type', \App\Coupon::DISCOUNT_TYPE_AMOUNT); if ($spbade28 === \App\Coupon::DISCOUNT_TYPE_AMOUNT) { if ($sp39ae40 < 1 || $sp39ae40 > 1000000000) { return Response::fail('优惠券面额需要在0.01-10000000之间'); } } if ($spbade28 === \App\Coupon::DISCOUNT_TYPE_PERCENT) { if ($sp39ae40 < 1 || $sp39ae40 > 100) { return Response::fail('优惠券面额需要在1-100之间'); } } $sp1ea3c0 = $this->authQuery($spa27895, \App\Coupon::class)->find($sp746ee1); if ($sp1ea3c0) { $sp1ea3c0->coupon = $sp2a00ee; $sp1ea3c0->category_id = $sp980f44; $sp1ea3c0->product_id = $sp112a12; $sp1ea3c0->status = $spf66c3d; $sp1ea3c0->type = $sp460df4; $sp1ea3c0->discount_val = $sp39ae40; $sp1ea3c0->discount_type = $spbade28; if ($sp460df4 === \App\Coupon::TYPE_REPEAT) { $sp1ea3c0->count_all = (int) $spa27895->post('count_all', 1); if ($sp1ea3c0->count_all < 1 || $sp1ea3c0->count_all > 10000000) { return Response::fail('可用次数不能超过10000000'); } } if ($sp9b3d20) { $sp1ea3c0->expire_at = $sp9b3d20; } $sp1ea3c0->saveOrFail(); } else { $spe64760 = explode(' -', $sp2a00ee); for ($spe20094 = 0; $spe20094 < count($spe64760); $spe20094++) { $sp643fe5 = str_replace(' ', '', trim($spe64760[$spe20094])); $sp1ea3c0 = new \App\Coupon(); $sp1ea3c0->coupon = $sp643fe5; $sp1ea3c0->category_id = $sp980f44; $sp1ea3c0->product_id = $sp112a12; $sp1ea3c0->status = $spf66c3d; $sp1ea3c0->type = $sp460df4; $sp1ea3c0->discount_val = $sp39ae40; $sp1ea3c0->discount_type = $spbade28; $spe64760[$spe20094] = $sp1ea3c0; } \App\Product::find($sp112a12)->coupons()->saveMany($spe64760); } return Response::success(); } function enable(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,1')); $sp8e4c06 = $spa27895->post('ids'); $sp2a8f09 = (int) $spa27895->post('enabled'); $this->authQuery($spa27895, \App\Coupon::class)->whereIn('id', explode(',', $sp8e4c06))->update(array('enabled' => $sp2a8f09)); return Response::success(); } function delete(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string')); $sp8e4c06 = $spa27895->post('ids'); $this->authQuery($spa27895, \App\Coupon::class)->whereIn('id', explode(',', $sp8e4c06))->delete(); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Merchant; use App\Library\Response; use Carbon\Carbon; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class Coupon extends Controller { function get(Request $spba756f) { $spca8acc = $this->authQuery($spba756f, \App\Coupon::class)->with(array('category' => function ($spca8acc) { $spca8acc->select(array('id', 'name')); }))->with(array('product' => function ($spca8acc) { $spca8acc->select(array('id', 'name')); })); $speeddd9 = $spba756f->post('search', false); $spe1fc85 = $spba756f->post('val', false); if ($speeddd9 && $spe1fc85) { if ($speeddd9 == 'id') { $spca8acc->where('id', $spe1fc85); } else { $spca8acc->where($speeddd9, 'like', '%' . $spe1fc85 . '%'); } } $sp55f32c = (int) $spba756f->post('category_id'); $sp1b83a8 = $spba756f->post('product_id', -1); if ($sp55f32c > 0) { if ($sp1b83a8 > 0) { $spca8acc->where('product_id', $sp1b83a8); } else { $spca8acc->where('category_id', $sp55f32c); } } $sp732cf7 = $spba756f->post('status'); if (strlen($sp732cf7)) { $spca8acc->whereIn('status', explode(',', $sp732cf7)); } $spe7b1c7 = $spba756f->post('type'); if (strlen($spe7b1c7)) { $spca8acc->whereIn('type', explode(',', $spe7b1c7)); } $spca8acc->orderByRaw('expire_at DESC,category_id,product_id,type,status'); $sp881a75 = $spba756f->post('current_page', 1); $sp2a01a9 = $spba756f->post('per_page', 20); $spfea7ce = $spca8acc->paginate($sp2a01a9, array('*'), 'page', $sp881a75); return Response::success($spfea7ce); } function create(Request $spba756f) { $sp99aae1 = $spba756f->post('count', 0); $spe7b1c7 = (int) $spba756f->post('type', \App\Coupon::TYPE_ONETIME); $sp72a1d0 = $spba756f->post('expire_at'); $sped6ef3 = (int) $spba756f->post('discount_val'); $sp8643d3 = (int) $spba756f->post('discount_type', \App\Coupon::DISCOUNT_TYPE_AMOUNT); $spd8e3f6 = $spba756f->post('remark'); if ($sp8643d3 === \App\Coupon::DISCOUNT_TYPE_AMOUNT) { if ($sped6ef3 < 1 || $sped6ef3 > 1000000000) { return Response::fail('优惠券面额需要在0.01-10000000之间'); } } if ($sp8643d3 === \App\Coupon::DISCOUNT_TYPE_PERCENT) { if ($sped6ef3 < 1 || $sped6ef3 > 100) { return Response::fail('优惠券面额需要在1-100之间'); } } $sp55f32c = (int) $spba756f->post('category_id', -1); $sp1b83a8 = (int) $spba756f->post('product_id', -1); if ($spe7b1c7 === \App\Coupon::TYPE_REPEAT) { $sp8bf4fa = $spba756f->post('coupon'); if (!$sp8bf4fa) { $sp8bf4fa = strtoupper(str_random()); } $sp4cb2ce = new \App\Coupon(); $sp4cb2ce->user_id = $this->getUserIdOrFail($spba756f); $sp4cb2ce->category_id = $sp55f32c; $sp4cb2ce->product_id = $sp1b83a8; $sp4cb2ce->coupon = $sp8bf4fa; $sp4cb2ce->type = $spe7b1c7; $sp4cb2ce->discount_val = $sped6ef3; $sp4cb2ce->discount_type = $sp8643d3; $sp4cb2ce->count_all = (int) $spba756f->post('count_all', 1); if ($sp4cb2ce->count_all < 1 || $sp4cb2ce->count_all > 10000000) { return Response::fail('可用次数不能超过10000000'); } $sp4cb2ce->expire_at = $sp72a1d0; $sp4cb2ce->saveOrFail(); return Response::success(array($sp4cb2ce->coupon)); } elseif ($spe7b1c7 === \App\Coupon::TYPE_ONETIME) { if (!$sp99aae1) { return Response::forbidden('请输入生成数量'); } if ($sp99aae1 > 100) { return Response::forbidden('每次生成不能大于100张'); } $sp97692a = array(); $spaf6261 = array(); $spf5ae13 = $this->getUserIdOrFail($spba756f); $sp54cd39 = Carbon::now(); for ($spc8f255 = 0; $spc8f255 < $sp99aae1; $spc8f255++) { $sp4cb2ce = strtoupper(str_random()); $spaf6261[] = $sp4cb2ce; $sp97692a[] = array('user_id' => $spf5ae13, 'coupon' => $sp4cb2ce, 'category_id' => $sp55f32c, 'product_id' => $sp1b83a8, 'type' => $spe7b1c7, 'discount_val' => $sped6ef3, 'discount_type' => $sp8643d3, 'status' => \App\Coupon::STATUS_NORMAL, 'remark' => $spd8e3f6, 'created_at' => $sp54cd39, 'expire_at' => $sp72a1d0); } \App\Coupon::insert($sp97692a); return Response::success($spaf6261); } else { return Response::forbidden('unknown type: ' . $spe7b1c7); } } function edit(Request $spba756f) { $sp8e8060 = (int) $spba756f->post('id'); $sp8bf4fa = $spba756f->post('coupon'); $sp55f32c = (int) $spba756f->post('category_id', -1); $sp1b83a8 = (int) $spba756f->post('product_id', -1); $sp72a1d0 = $spba756f->post('expire_at', NULL); $sp732cf7 = (int) $spba756f->post('status', \App\Coupon::STATUS_NORMAL); $spe7b1c7 = (int) $spba756f->post('type', \App\Coupon::TYPE_ONETIME); $sped6ef3 = (int) $spba756f->post('discount_val'); $sp8643d3 = (int) $spba756f->post('discount_type', \App\Coupon::DISCOUNT_TYPE_AMOUNT); if ($sp8643d3 === \App\Coupon::DISCOUNT_TYPE_AMOUNT) { if ($sped6ef3 < 1 || $sped6ef3 > 1000000000) { return Response::fail('优惠券面额需要在0.01-10000000之间'); } } if ($sp8643d3 === \App\Coupon::DISCOUNT_TYPE_PERCENT) { if ($sped6ef3 < 1 || $sped6ef3 > 100) { return Response::fail('优惠券面额需要在1-100之间'); } } $sp4cb2ce = $this->authQuery($spba756f, \App\Coupon::class)->find($sp8e8060); if ($sp4cb2ce) { $sp4cb2ce->coupon = $sp8bf4fa; $sp4cb2ce->category_id = $sp55f32c; $sp4cb2ce->product_id = $sp1b83a8; $sp4cb2ce->status = $sp732cf7; $sp4cb2ce->type = $spe7b1c7; $sp4cb2ce->discount_val = $sped6ef3; $sp4cb2ce->discount_type = $sp8643d3; if ($spe7b1c7 === \App\Coupon::TYPE_REPEAT) { $sp4cb2ce->count_all = (int) $spba756f->post('count_all', 1); if ($sp4cb2ce->count_all < 1 || $sp4cb2ce->count_all > 10000000) { return Response::fail('可用次数不能超过10000000'); } } if ($sp72a1d0) { $sp4cb2ce->expire_at = $sp72a1d0; } $sp4cb2ce->saveOrFail(); } else { $spe1ba81 = explode(' +', $sp8bf4fa); for ($spc8f255 = 0; $spc8f255 < count($spe1ba81); $spc8f255++) { $spf8ca88 = str_replace(' ', '', trim($spe1ba81[$spc8f255])); $sp4cb2ce = new \App\Coupon(); $sp4cb2ce->coupon = $spf8ca88; $sp4cb2ce->category_id = $sp55f32c; $sp4cb2ce->product_id = $sp1b83a8; $sp4cb2ce->status = $sp732cf7; $sp4cb2ce->type = $spe7b1c7; $sp4cb2ce->discount_val = $sped6ef3; $sp4cb2ce->discount_type = $sp8643d3; $spe1ba81[$spc8f255] = $sp4cb2ce; } \App\Product::find($sp1b83a8)->coupons()->saveMany($spe1ba81); } return Response::success(); } function enable(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,1')); $sp12026a = $spba756f->post('ids'); $spc7c4ac = (int) $spba756f->post('enabled'); $this->authQuery($spba756f, \App\Coupon::class)->whereIn('id', explode(',', $sp12026a))->update(array('enabled' => $spc7c4ac)); return Response::success(); } function delete(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string')); $sp12026a = $spba756f->post('ids'); $this->authQuery($spba756f, \App\Coupon::class)->whereIn('id', explode(',', $sp12026a))->delete(); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/File.php b/app/Http/Controllers/Merchant/File.php index b8fabf81c..8631cc1d1 100644 --- a/app/Http/Controllers/Merchant/File.php +++ b/app/Http/Controllers/Merchant/File.php @@ -1,2 +1,2 @@ extension(); } catch (\Throwable $sp45f5f1) { return Response::fail($sp45f5f1->getMessage()); } if (!$spe041e4 || !in_array(strtolower($spf7bf29), array('jpg', 'jpeg', 'png', 'gif'))) { return Response::fail('图片错误, 系统支持jpg/png/gif格式'); } if ($spe041e4->getSize() > 5 * 1024 * 1024) { return Response::fail('图片不能大于5MB'); } try { $spde3d9c = $spe041e4->store($spdecae6, array('disk' => System::_get('storage_driver'))); } catch (\Exception $sp45f5f1) { \Log::error('File.uploadImg folder:' . $spdecae6 . ', error:' . $sp45f5f1->getMessage(), array('exception' => $sp45f5f1)); if (config('app.debug')) { return Response::fail($sp45f5f1->getMessage()); } else { return Response::fail('上传文件失败, 内部错误, 请联系客服'); } } if (!$spde3d9c) { return Response::fail('系统保存文件出错, 请稍后再试'); } $sp1f9a35 = System::_get('storage_driver'); $spddf3f5 = Storage::disk($sp1f9a35)->url($spde3d9c); $sp663a21 = \App\File::insertGetId(array('user_id' => $sp258cf6, 'driver' => $sp1f9a35, 'path' => $spde3d9c, 'url' => $spddf3f5)); if ($sp663a21 < 1) { Storage::disk($sp1f9a35)->delete($spde3d9c); return Response::fail('数据库繁忙,请稍后再试'); } $sp786169 = array('id' => $sp663a21, 'url' => $spddf3f5, 'name' => pathinfo($spde3d9c, PATHINFO_BASENAME)); if ($sp14cfd6) { return $sp786169; } return Response::success($sp786169); } function upload_merchant(Request $spa27895) { $sp845283 = $this->getUser($spa27895); if ($sp845283 === null) { return Response::forbidden('无效的用户'); } $spe041e4 = $spa27895->file('file'); return $this->uploadImg($spe041e4, $sp845283->id, \App\File::getProductFolder()); } public function renderImage(Request $spa27895, $spa37169) { if (str_contains($spa37169, '..') || str_contains($spa37169, './') || str_contains($spa37169, '.\\') || !starts_with($spa37169, 'images/')) { $spb59363 = file_get_contents(public_path('images/illegal.jpg')); } else { $spa37169 = str_replace('\\', '/', $spa37169); $spe041e4 = \App\File::wherePath($spa37169)->first(); if ($spe041e4) { $sp1f9a35 = $spe041e4->driver; } else { $sp1f9a35 = System::_get('storage_driver'); } if (!in_array($sp1f9a35, array('local', 's3', 'oss', 'qiniu'))) { return response()->view('message', array('title' => '404', 'message' => '404 Driver NotFound'), 404); } try { $spb59363 = Storage::disk($sp1f9a35)->get($spa37169); } catch (\Illuminate\Contracts\Filesystem\FileNotFoundException $sp45f5f1) { \Log::error('File.renderImage error: ' . $sp45f5f1->getMessage(), array('exception' => $sp45f5f1)); return response()->view('message', array('title' => '404', 'message' => '404 NotFound'), 404); } } ob_end_clean(); header('Content-Type: ' . mimetype_from_filename($spa37169)); die($spb59363); } } \ No newline at end of file +namespace App\Http\Controllers\Merchant; use App\Library\Response; use App\System; use function GuzzleHttp\Psr7\mimetype_from_filename; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Storage; class File extends Controller { public static function uploadImg($sp23c04a, $spf5ae13, $sp61b6a5, $sp3bf139 = false) { try { $sp6e0fc7 = $sp23c04a->extension(); } catch (\Throwable $sp6a7295) { return Response::fail($sp6a7295->getMessage()); } if (!$sp23c04a || !in_array(strtolower($sp6e0fc7), array('jpg', 'jpeg', 'png', 'gif'))) { return Response::fail('图片错误, 系统支持jpg/png/gif格式'); } if ($sp23c04a->getSize() > 5 * 1024 * 1024) { return Response::fail('图片不能大于5MB'); } try { $spffbc51 = $sp23c04a->store($sp61b6a5, array('disk' => System::_get('storage_driver'))); } catch (\Exception $sp6a7295) { \Log::error('File.uploadImg folder:' . $sp61b6a5 . ', error:' . $sp6a7295->getMessage(), array('exception' => $sp6a7295)); if (config('app.debug')) { return Response::fail($sp6a7295->getMessage()); } else { return Response::fail('上传文件失败, 内部错误, 请联系客服'); } } if (!$spffbc51) { return Response::fail('系统保存文件出错, 请稍后再试'); } $spa28d5a = System::_get('storage_driver'); $sp0784c1 = Storage::disk($spa28d5a)->url($spffbc51); $sp19b5a1 = \App\File::insertGetId(array('user_id' => $spf5ae13, 'driver' => $spa28d5a, 'path' => $spffbc51, 'url' => $sp0784c1)); if ($sp19b5a1 < 1) { Storage::disk($spa28d5a)->delete($spffbc51); return Response::fail('数据库繁忙,请稍后再试'); } $sp5359c9 = array('id' => $sp19b5a1, 'url' => $sp0784c1, 'name' => pathinfo($spffbc51, PATHINFO_BASENAME)); if ($sp3bf139) { return $sp5359c9; } return Response::success($sp5359c9); } function upload_merchant(Request $spba756f) { $spac34b1 = $this->getUser($spba756f); if ($spac34b1 === null) { return Response::forbidden('无效的用户'); } $sp23c04a = $spba756f->file('file'); return $this->uploadImg($sp23c04a, $spac34b1->id, \App\File::getProductFolder()); } public function renderImage(Request $spba756f, $spd6f30a) { if (str_contains($spd6f30a, '..') || str_contains($spd6f30a, './') || str_contains($spd6f30a, '.\\') || !starts_with($spd6f30a, 'images/')) { $sp95c9b0 = file_get_contents(public_path('images/illegal.jpg')); } else { $spd6f30a = str_replace('\\', '/', $spd6f30a); $sp23c04a = \App\File::wherePath($spd6f30a)->first(); if ($sp23c04a) { $spa28d5a = $sp23c04a->driver; } else { $spa28d5a = System::_get('storage_driver'); } if (!in_array($spa28d5a, array('local', 's3', 'oss', 'qiniu'))) { return response()->view('message', array('title' => '404', 'message' => '404 Driver NotFound'), 404); } try { $sp95c9b0 = Storage::disk($spa28d5a)->get($spd6f30a); } catch (\Illuminate\Contracts\Filesystem\FileNotFoundException $sp6a7295) { \Log::error('File.renderImage error: ' . $sp6a7295->getMessage(), array('exception' => $sp6a7295)); return response()->view('message', array('title' => '404', 'message' => '404 NotFound'), 404); } } ob_end_clean(); header('Content-Type: ' . mimetype_from_filename($spd6f30a)); die($sp95c9b0); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Log.php b/app/Http/Controllers/Merchant/Log.php index fcf3759bb..5940c8395 100644 --- a/app/Http/Controllers/Merchant/Log.php +++ b/app/Http/Controllers/Merchant/Log.php @@ -1,2 +1,2 @@ post('user_id'); $sp351722 = $spa27895->post('action', \App\Log::ACTION_LOGIN); $sp7e6fa3 = \App\Log::where('action', $sp351722); $sp7e6fa3->where('user_id', Auth::id()); $sp4faace = $spa27895->post('start_at'); if (strlen($sp4faace)) { $sp7e6fa3->where('created_at', '>=', $sp4faace . ' 00:00:00'); } $sp66bad0 = $spa27895->post('end_at'); if (strlen($sp66bad0)) { $sp7e6fa3->where('created_at', '<=', $sp66bad0 . ' 23:59:59'); } $spf69625 = $spa27895->post('current_page', 1); $spe8f5a8 = $spa27895->post('per_page', 20); $sp966ae1 = $sp7e6fa3->orderBy('created_at', 'DESC')->paginate($spe8f5a8, array('*'), 'page', $spf69625); return Response::success($sp966ae1); } } \ No newline at end of file +namespace App\Http\Controllers\Merchant; use App\Library\Response; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; class Log extends Controller { function get(Request $spba756f) { $spf5ae13 = $spba756f->post('user_id'); $sp898a26 = $spba756f->post('action', \App\Log::ACTION_LOGIN); $spca8acc = \App\Log::where('action', $sp898a26); $spca8acc->where('user_id', Auth::id()); $sp5a57fe = $spba756f->post('start_at'); if (strlen($sp5a57fe)) { $spca8acc->where('created_at', '>=', $sp5a57fe . ' 00:00:00'); } $sp4e495c = $spba756f->post('end_at'); if (strlen($sp4e495c)) { $spca8acc->where('created_at', '<=', $sp4e495c . ' 23:59:59'); } $sp881a75 = $spba756f->post('current_page', 1); $sp2a01a9 = $spba756f->post('per_page', 20); $spfea7ce = $spca8acc->orderBy('created_at', 'DESC')->paginate($sp2a01a9, array('*'), 'page', $sp881a75); return Response::success($spfea7ce); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Order.php b/app/Http/Controllers/Merchant/Order.php index 74cb3580b..08b451d4b 100644 --- a/app/Http/Controllers/Merchant/Order.php +++ b/app/Http/Controllers/Merchant/Order.php @@ -1,4 +1,4 @@ authQuery($spa27895, \App\Order::class); $sp980f44 = (int) $spa27895->input('category_id'); $sp112a12 = (int) $spa27895->input('product_id'); $sp279498 = (int) $spa27895->input('profit'); $sp7c02b6 = $sp980f44 === \App\Product::ID_API || $sp112a12 === \App\Product::ID_API; $spfe451d = $spa27895->input('search', false); $sp0edb8f = $spa27895->input('val', false); if ($spfe451d && $sp0edb8f) { if ($spfe451d == 'id' || $spfe451d == 'order_no' || $spfe451d === 'pay_trade_no' || $spfe451d === 'api_out_no') { $sp7e6fa3->where($spfe451d, $sp0edb8f); } else { $sp7e6fa3->where($spfe451d, 'like', '%' . $sp0edb8f . '%'); } } if ($sp980f44 > 0) { if ($sp112a12 > 0) { $sp7e6fa3->where('product_id', $sp112a12); } else { $sp7e6fa3->whereHas('product', function ($sp7e6fa3) use($sp980f44) { $sp7e6fa3->where('category_id', $sp980f44); }); } } $specd399 = (int) $spa27895->input('recent', 0); if ($specd399) { $sp4faace = (new Carbon())->addDay(-$specd399); $sp7e6fa3->where(function ($sp7e6fa3) use($sp4faace) { $sp7e6fa3->where('paid_at', '>=', $sp4faace)->orWhere(function ($sp7e6fa3) use($sp4faace) { $sp7e6fa3->whereNull('paid_at')->where('created_at', '>=', $sp4faace); }); }); } else { $sp4faace = $spa27895->input('start_at', false); if (strlen($sp4faace)) { $sp7e6fa3->where(function ($sp7e6fa3) use($sp4faace) { $sp7e6fa3->where('paid_at', '>=', $sp4faace . ' 00:00:00')->orWhere(function ($sp7e6fa3) use($sp4faace) { $sp7e6fa3->whereNull('paid_at')->where('created_at', '>=', $sp4faace . ' 00:00:00'); }); }); } $sp66bad0 = $spa27895->input('end_at', false); if (strlen($sp66bad0)) { $sp7e6fa3->where(function ($sp7e6fa3) use($sp66bad0) { $sp7e6fa3->where('paid_at', '<=', $sp66bad0 . ' 23:59:59')->orWhere(function ($sp7e6fa3) use($sp66bad0) { $sp7e6fa3->whereNull('paid_at')->where('created_at', '<=', $sp66bad0 . ' 23:59:59'); }); }); } } if ($sp279498) { $sp7e6fa3->where('status', \App\Order::STATUS_SUCCESS); $sp8f49dc = clone $sp7e6fa3; $spb21619 = $sp8f49dc->selectRaw('SUM(`income`) as income, SUM(`paid`-`sms_price`-`cost`-`fee`) as profit')->first(); } else { $spf66c3d = $spa27895->input('status'); if (strlen($spf66c3d)) { $sp7e6fa3->whereIn('status', explode(',', $spf66c3d)); } else { $sp7e6fa3->where('status', '!=', \App\Order::STATUS_UNPAY); } } if ($sp7c02b6) { $sp7e6fa3->where('product_id', \App\Product::ID_API); } else { $sp7e6fa3->where('product_id', '>', 0); $sp7e6fa3->with(array('product' => function (Relation $sp7e6fa3) { $sp7e6fa3->select(array('id', 'name', 'delivery')); }, 'card_orders.card' => function (Relation $sp7e6fa3) { $sp7e6fa3->select(array('id', 'card')); })); } $sp7e6fa3->with(array('pay' => function (Relation $sp7e6fa3) { $sp7e6fa3->select(array('id', 'name')); })); $sp7e6fa3->orderBy('id', 'DESC'); if ($sp4de76b === true) { $sp9ff49b = (int) $spa27895->input('export_update_status'); $spb7d1f5 = $spa27895->input('export_update_card'); $sp89027b = ''; $sp89027b .= '"订单号","商品名称","下单时间","订单金额","优惠金额","实付金额","手续费","成本价","利润","支付方式","支付流水号","支付时间","订单状态","买家联系方式","买家附加信息"' . ' -'; $sp7e6fa3->chunk(100, function ($spcc3b3e) use(&$sp89027b, $sp9ff49b, $spb7d1f5) { foreach ($spcc3b3e as $sp7b2cfc) { if ($sp7b2cfc->status === \App\Order::STATUS_PAID) { if ($sp9ff49b === \App\Order::SEND_STATUS_CARD_PROCESSING) { $sp7b2cfc->send_status = $sp9ff49b; $sp7b2cfc->saveOrFail(); } elseif ($sp9ff49b === \App\Order::SEND_STATUS_CARD_SUCCESS) { $sp7b2cfc->send_status = $sp9ff49b; $sp7b2cfc->saveOrFail(); $this->ship(new Request(array('id' => $sp7b2cfc->id, 'card' => $spb7d1f5))); } } $spa3a8ba = $sp7b2cfc->contact_ext; if ($spa3a8ba) { if ($spa3a8ba[0] === '[') { $spa3a8ba = substr($spa3a8ba, 2); } if ($spa3a8ba[strlen($spa3a8ba) - 1] === ']') { $spa3a8ba = substr($spa3a8ba, 0, -2); } } $sp89027b .= '"' . $sp7b2cfc->order_no . '","' . $sp7b2cfc->product_name . '","' . $sp7b2cfc->created_at . '","' . sprintf('%.2f', $sp7b2cfc->price / 100) . '","' . sprintf('%.2f', $sp7b2cfc->discount / 100) . '","' . sprintf('%.2f', $sp7b2cfc->paid / 100) . '","' . sprintf('%.2f', $sp7b2cfc->fee / 100) . '","' . sprintf('%.2f', $sp7b2cfc->cost / 100) . '","' . sprintf('%.2f', ($sp7b2cfc->paid - $sp7b2cfc->fee - $sp7b2cfc->cost) / 100) . '","' . ($sp7b2cfc->pay ? $sp7b2cfc->pay->name : '未知#' . $sp7b2cfc->pay_id) . '","' . $sp7b2cfc->pay_trade_no . '","' . $sp7b2cfc->paid_at . '","' . \App\Order::STATUS[$sp7b2cfc->status] . '","' . $sp7b2cfc->contact . '","' . $spa3a8ba . '"'; $sp89027b .= ' -'; } }); $sp69a6c1 = 'export_orders_' . $this->getUserIdOrFail($spa27895) . '_' . date('YmdHis') . '.csv'; $sp697dbb = array('Content-type' => 'text/plain', 'Content-Disposition' => sprintf('attachment; filename="%s"', $sp69a6c1), 'Content-Length' => strlen($sp89027b)); return response()->make($sp89027b, 200, $sp697dbb); } $spf69625 = $spa27895->input('current_page', 1); $spe8f5a8 = $spa27895->input('per_page', 20); $sp966ae1 = $sp7e6fa3->paginate($spe8f5a8, array('*'), 'page', $spf69625); if ($sp279498) { $sp966ae1 = $sp966ae1->toArray(); $sp966ae1['profit_sum'] = $spb21619; } return Response::success($sp966ae1); } function export(Request $spa27895) { return self::get($spa27895, true); } function stat(Request $spa27895) { $this->validate($spa27895, array('day' => 'required|integer|between:7,30')); $spcb4d2f = (int) $spa27895->input('day'); if ($spcb4d2f === 30) { $sp118ccb = Carbon::now()->addMonths(-1); } else { $sp118ccb = Carbon::now()->addDays(-$spcb4d2f); } $sp966ae1 = $this->authQuery($spa27895, \App\Order::class)->where(function ($sp7e6fa3) { $sp7e6fa3->where('status', \App\Order::STATUS_PAID)->orWhere('status', \App\Order::STATUS_SUCCESS); })->where('paid_at', '>=', $sp118ccb)->groupBy('date')->orderBy('date', 'DESC')->selectRaw('DATE(`paid_at`) as "date",COUNT(*) as "count",SUM(`paid`) as "paid",SUM(`paid`-`sms_price`-`cost`-`fee`) as "profit"')->get()->toArray(); $sp786169 = array(); foreach ($sp966ae1 as $spc6f905) { $sp786169[$spc6f905['date']] = array((int) $spc6f905['count'], (int) $spc6f905['paid'], (int) $spc6f905['profit']); } return Response::success($sp786169); } function info(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer')); $sp746ee1 = $spa27895->input('id'); $sp7b2cfc = $this->authQuery($spa27895, \App\Order::class)->with(array('pay' => function (Relation $sp7e6fa3) { $sp7e6fa3->select(array('id', 'name')); }, 'card_orders.card' => function (Relation $sp7e6fa3) { $sp7e6fa3->select(array('id', 'card')); }))->findOrFail($sp746ee1); $sp7b2cfc->addHidden(array('system_fee')); return Response::success($sp7b2cfc); } function remark(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer', 'remark' => 'required|string')); $sp746ee1 = $spa27895->input('id'); $sp7b2cfc = $this->authQuery($spa27895, \App\Order::class)->findOrFail($sp746ee1); $sp7b2cfc->remark = $spa27895->input('remark'); $sp7b2cfc->save(); return Response::success(); } function set_send_status(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer', 'send_status' => 'required|integer')); $sp746ee1 = $spa27895->input('id'); $sp7b2cfc = $this->authQuery($spa27895, \App\Order::class)->findOrFail($sp746ee1); if ($sp7b2cfc->status !== \App\Order::STATUS_PAID) { return Response::fail('此订单不是未发货状态, 无法增加发货标记'); } $sp7b2cfc->send_status = $spa27895->input('send_status'); $sp7b2cfc->saveOrFail(); return Response::success(); } function ship(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer')); $sp7b2cfc = $this->authQuery($spa27895, \App\Order::class)->with('product')->findOrFail($spa27895->input('id')); if ($sp7b2cfc->status !== \App\Order::STATUS_PAID) { return Response::fail('订单不是待发货状态, 无法发货'); } if ($sp7b2cfc->product === null) { return Response::fail('订单对应商品不存在, 无法发货'); } $spee4e15 = $sp7b2cfc->product->delivery; $spc9eeab = ''; if ($spee4e15 === \App\Product::DELIVERY_MANUAL) { $this->validate($spa27895, array('card' => 'required|string')); $spc9eeab = $spa27895->input('card'); } $spd39d17 = null; $sp7c8ced = array(); if (FundHelper::orderSuccess($sp7b2cfc->id, function () use(&$sp7b2cfc, &$spd39d17, &$sp7c8ced, $spee4e15, $spc9eeab) { $sp7b2cfc = \App\Order::where('id', $sp7b2cfc->id)->lockForUpdate()->firstOrFail(); if ($sp7b2cfc->cards && count($sp7b2cfc->cards)) { $spd39d17 = '该订单已经发货,无需再次发货'; return false; } $sp1a3ec5 = $sp7b2cfc->product()->lockForUpdate()->firstOrFail(); if ($spee4e15 === \App\Product::DELIVERY_MANUAL) { $sp7b2cfc->status = \App\Order::STATUS_SUCCESS; $sp7b2cfc->send_status = \App\Order::SEND_STATUS_CARD_SUCCESS; $sp7b2cfc->saveOrFail(); $sp089eb8 = \App\Card::create(array('user_id' => Auth::id(), 'product_id' => $sp1a3ec5->id, 'card' => $spc9eeab, 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_SOLD, 'count_sold' => 1, 'count_all' => 1)); $sp7c8ced[] = $sp089eb8->card; $sp7b2cfc->cards()->attach($sp089eb8->id); $sp1a3ec5->count_sold += $sp7b2cfc->count; $sp1a3ec5->saveOrFail(); return FundHelper::ACTION_CONTINUE; } $sp16ec83 = \App\Card::where('product_id', $sp1a3ec5->id)->whereRaw('`count_sold`<`count_all`')->take($sp7b2cfc->count)->lockForUpdate()->get(); if (count($sp16ec83) !== $sp7b2cfc->count) { $spd39d17 = '商品卡密不足, 请添加卡密后再发货'; return false; } else { $sp7b2cfc->status = \App\Order::STATUS_SUCCESS; $sp7b2cfc->saveOrFail(); $sp5be395 = array(); foreach ($sp16ec83 as $sp089eb8) { $sp5be395[] = $sp089eb8->id; $sp7c8ced[] = $sp089eb8->card; } $sp7b2cfc->cards()->attach($sp5be395); \App\Card::whereIn('id', $sp5be395)->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+1'))); $sp1a3ec5->count_sold += $sp7b2cfc->count; $sp1a3ec5->saveOrFail(); return FundHelper::ACTION_CONTINUE; } })) { if (System::_getInt('mail_send_order')) { $sp98ce8d = @json_decode($sp7b2cfc->contact_ext, true)['_mail']; if ($sp98ce8d) { $sp7b2cfc->sendEmail($sp98ce8d); } } if ($sp7b2cfc->status === \App\Order::STATUS_SUCCESS && System::_getInt('sms_send_order')) { $spd9b726 = @json_decode($sp7b2cfc->contact_ext, true)['_mobile']; if ($spd9b726) { $sp7b2cfc->sendSms($spd9b726); } } $sp7b2cfc['card_orders'] = array_map(function ($spc6f905) { return array('card' => array('card' => $spc6f905)); }, $sp7c8ced); $sp7b2cfc->addHidden(array('system_fee')); return Response::success($sp7b2cfc); } else { return Response::fail($spd39d17 ?? '数据库繁忙, 请联系客服'); } } } \ No newline at end of file +namespace App\Http\Controllers\Merchant; use App\Http\Controllers\Shop\ApiPay; use App\Library\CurlRequest; use App\Library\FundHelper; use App\Library\Helper; use App\Library\Response; use App\Mail\OrderShipped; use App\System; use Carbon\Carbon; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Mail; class Order extends Controller { function get(Request $spba756f, $spe71412 = false) { $spca8acc = $this->authQuery($spba756f, \App\Order::class); $sp55f32c = (int) $spba756f->input('category_id'); $sp1b83a8 = (int) $spba756f->input('product_id'); $sp67ac4f = (int) $spba756f->input('profit'); $sp8dd439 = $sp55f32c === \App\Product::ID_API || $sp1b83a8 === \App\Product::ID_API; $speeddd9 = $spba756f->input('search', false); $spe1fc85 = $spba756f->input('val', false); if ($speeddd9 && $spe1fc85) { if ($speeddd9 == 'id' || $speeddd9 == 'order_no' || $speeddd9 === 'pay_trade_no' || $speeddd9 === 'api_out_no') { $spca8acc->where($speeddd9, $spe1fc85); } else { $spca8acc->where($speeddd9, 'like', '%' . $spe1fc85 . '%'); } } if ($sp55f32c > 0) { if ($sp1b83a8 > 0) { $spca8acc->where('product_id', $sp1b83a8); } else { $spca8acc->whereHas('product', function ($spca8acc) use($sp55f32c) { $spca8acc->where('category_id', $sp55f32c); }); } } $sp79f3fc = (int) $spba756f->input('recent', 0); if ($sp79f3fc) { $sp5a57fe = (new Carbon())->addDay(-$sp79f3fc); $spca8acc->where(function ($spca8acc) use($sp5a57fe) { $spca8acc->where('paid_at', '>=', $sp5a57fe)->orWhere(function ($spca8acc) use($sp5a57fe) { $spca8acc->whereNull('paid_at')->where('created_at', '>=', $sp5a57fe); }); }); } else { $sp5a57fe = $spba756f->input('start_at', false); if (strlen($sp5a57fe)) { $spca8acc->where(function ($spca8acc) use($sp5a57fe) { $spca8acc->where('paid_at', '>=', $sp5a57fe . ' 00:00:00')->orWhere(function ($spca8acc) use($sp5a57fe) { $spca8acc->whereNull('paid_at')->where('created_at', '>=', $sp5a57fe . ' 00:00:00'); }); }); } $sp4e495c = $spba756f->input('end_at', false); if (strlen($sp4e495c)) { $spca8acc->where(function ($spca8acc) use($sp4e495c) { $spca8acc->where('paid_at', '<=', $sp4e495c . ' 23:59:59')->orWhere(function ($spca8acc) use($sp4e495c) { $spca8acc->whereNull('paid_at')->where('created_at', '<=', $sp4e495c . ' 23:59:59'); }); }); } } if ($sp67ac4f) { $spca8acc->where('status', \App\Order::STATUS_SUCCESS); $sp0b8d05 = clone $spca8acc; $sp927bae = $sp0b8d05->selectRaw('SUM(`income`) as income, SUM(`paid`-`sms_price`-`cost`-`fee`) as profit')->first(); } else { $sp732cf7 = $spba756f->input('status'); if (strlen($sp732cf7)) { $spca8acc->whereIn('status', explode(',', $sp732cf7)); } else { $spca8acc->where('status', '!=', \App\Order::STATUS_UNPAY); } } if ($sp8dd439) { $spca8acc->where('product_id', \App\Product::ID_API); } else { $spca8acc->where('product_id', '>', 0); $spca8acc->with(array('product' => function (Relation $spca8acc) { $spca8acc->select(array('id', 'name', 'delivery')); }, 'card_orders.card' => function (Relation $spca8acc) { $spca8acc->select(array('id', 'card')); })); } $spca8acc->with(array('pay' => function (Relation $spca8acc) { $spca8acc->select(array('id', 'name')); })); $spca8acc->orderBy('id', 'DESC'); if ($spe71412 === true) { $sp208d8a = (int) $spba756f->input('export_update_status'); $sp955d21 = $spba756f->input('export_update_card'); $sp00db53 = ''; $sp00db53 .= '"订单号","商品名称","下单时间","订单金额","优惠金额","实付金额","手续费","成本价","利润","支付方式","支付流水号","支付时间","订单状态","买家联系方式","买家附加信息"' . ' +'; $spca8acc->chunk(100, function ($sp29dcf4) use(&$sp00db53, $sp208d8a, $sp955d21) { foreach ($sp29dcf4 as $spedec71) { if ($spedec71->status === \App\Order::STATUS_PAID) { if ($sp208d8a === \App\Order::SEND_STATUS_CARD_PROCESSING) { $spedec71->send_status = $sp208d8a; $spedec71->saveOrFail(); } elseif ($sp208d8a === \App\Order::SEND_STATUS_CARD_SUCCESS) { $spedec71->send_status = $sp208d8a; $spedec71->saveOrFail(); $this->ship(new Request(array('id' => $spedec71->id, 'card' => $sp955d21))); } } $sp682364 = $spedec71->contact_ext; if ($sp682364) { if ($sp682364[0] === '[') { $sp682364 = substr($sp682364, 2); } if ($sp682364[strlen($sp682364) - 1] === ']') { $sp682364 = substr($sp682364, 0, -2); } } $sp00db53 .= '"' . $spedec71->order_no . '","' . $spedec71->product_name . '","' . $spedec71->created_at . '","' . sprintf('%.2f', $spedec71->price / 100) . '","' . sprintf('%.2f', $spedec71->discount / 100) . '","' . sprintf('%.2f', $spedec71->paid / 100) . '","' . sprintf('%.2f', $spedec71->fee / 100) . '","' . sprintf('%.2f', $spedec71->cost / 100) . '","' . sprintf('%.2f', ($spedec71->paid - $spedec71->fee - $spedec71->cost) / 100) . '","' . ($spedec71->pay ? $spedec71->pay->name : '未知#' . $spedec71->pay_id) . '","' . $spedec71->pay_trade_no . '","' . $spedec71->paid_at . '","' . \App\Order::STATUS[$spedec71->status] . '","' . $spedec71->contact . '","' . $sp682364 . '"'; $sp00db53 .= ' +'; } }); $spe6c5dc = 'export_orders_' . $this->getUserIdOrFail($spba756f) . '_' . date('YmdHis') . '.csv'; $sp3e89cf = array('Content-type' => 'text/plain', 'Content-Disposition' => sprintf('attachment; filename="%s"', $spe6c5dc), 'Content-Length' => strlen($sp00db53)); return response()->make($sp00db53, 200, $sp3e89cf); } $sp881a75 = $spba756f->input('current_page', 1); $sp2a01a9 = $spba756f->input('per_page', 20); $spfea7ce = $spca8acc->paginate($sp2a01a9, array('*'), 'page', $sp881a75); if ($sp67ac4f) { $spfea7ce = $spfea7ce->toArray(); $spfea7ce['profit_sum'] = $sp927bae; } return Response::success($spfea7ce); } function export(Request $spba756f) { return self::get($spba756f, true); } function stat(Request $spba756f) { $this->validate($spba756f, array('day' => 'required|integer|between:7,30')); $sp8d35f0 = (int) $spba756f->input('day'); if ($sp8d35f0 === 30) { $sp20fe30 = Carbon::now()->addMonths(-1); } else { $sp20fe30 = Carbon::now()->addDays(-$sp8d35f0); } $spfea7ce = $this->authQuery($spba756f, \App\Order::class)->where(function ($spca8acc) { $spca8acc->where('status', \App\Order::STATUS_PAID)->orWhere('status', \App\Order::STATUS_SUCCESS); })->where('paid_at', '>=', $sp20fe30)->groupBy('date')->orderBy('date', 'DESC')->selectRaw('DATE(`paid_at`) as "date",COUNT(*) as "count",SUM(`paid`) as "paid",SUM(`paid`-`sms_price`-`cost`-`fee`) as "profit"')->get()->toArray(); $sp5359c9 = array(); foreach ($spfea7ce as $spbdd4b3) { $sp5359c9[$spbdd4b3['date']] = array((int) $spbdd4b3['count'], (int) $spbdd4b3['paid'], (int) $spbdd4b3['profit']); } return Response::success($sp5359c9); } function info(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer')); $sp8e8060 = $spba756f->input('id'); $spedec71 = $this->authQuery($spba756f, \App\Order::class)->with(array('pay' => function (Relation $spca8acc) { $spca8acc->select(array('id', 'name')); }, 'card_orders.card' => function (Relation $spca8acc) { $spca8acc->select(array('id', 'card')); }))->findOrFail($sp8e8060); $spedec71->addHidden(array('system_fee')); return Response::success($spedec71); } function remark(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer', 'remark' => 'required|string')); $sp8e8060 = $spba756f->input('id'); $spedec71 = $this->authQuery($spba756f, \App\Order::class)->findOrFail($sp8e8060); $spedec71->remark = $spba756f->input('remark'); $spedec71->save(); return Response::success(); } function set_send_status(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer', 'send_status' => 'required|integer')); $sp8e8060 = $spba756f->input('id'); $spedec71 = $this->authQuery($spba756f, \App\Order::class)->findOrFail($sp8e8060); if ($spedec71->status !== \App\Order::STATUS_PAID) { return Response::fail('此订单不是未发货状态, 无法增加发货标记'); } $spedec71->send_status = $spba756f->input('send_status'); $spedec71->saveOrFail(); return Response::success(); } function ship(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer')); $spedec71 = $this->authQuery($spba756f, \App\Order::class)->with('product')->findOrFail($spba756f->input('id')); if ($spedec71->status !== \App\Order::STATUS_PAID) { return Response::fail('订单不是待发货状态, 无法发货'); } if ($spedec71->product === null) { return Response::fail('订单对应商品不存在, 无法发货'); } $sp49c574 = $spedec71->product->delivery; $sp8841a6 = ''; if ($sp49c574 === \App\Product::DELIVERY_MANUAL) { $this->validate($spba756f, array('card' => 'required|string')); $sp8841a6 = $spba756f->input('card'); } $sp6e5de7 = null; $spb73662 = array(); if (FundHelper::orderSuccess($spedec71->id, function () use(&$spedec71, &$sp6e5de7, &$spb73662, $sp49c574, $sp8841a6) { $spedec71 = \App\Order::where('id', $spedec71->id)->lockForUpdate()->firstOrFail(); if ($spedec71->cards && count($spedec71->cards)) { $sp6e5de7 = '该订单已经发货,无需再次发货'; return false; } $sp9dfc99 = $spedec71->product()->lockForUpdate()->firstOrFail(); if ($sp49c574 === \App\Product::DELIVERY_MANUAL) { $spedec71->status = \App\Order::STATUS_SUCCESS; $spedec71->send_status = \App\Order::SEND_STATUS_CARD_SUCCESS; $spedec71->saveOrFail(); $spa9cef2 = \App\Card::create(array('user_id' => Auth::id(), 'product_id' => $sp9dfc99->id, 'card' => $sp8841a6, 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_SOLD, 'count_sold' => 1, 'count_all' => 1)); $spb73662[] = $spa9cef2->card; $spedec71->cards()->attach($spa9cef2->id); $sp9dfc99->count_sold += $spedec71->count; $sp9dfc99->saveOrFail(); return FundHelper::ACTION_CONTINUE; } $sp137cd7 = \App\Card::where('product_id', $sp9dfc99->id)->whereRaw('`count_sold`<`count_all`')->take($spedec71->count)->lockForUpdate()->get(); if (count($sp137cd7) !== $spedec71->count) { $sp6e5de7 = '商品卡密不足, 请添加卡密后再发货'; return false; } else { $spedec71->status = \App\Order::STATUS_SUCCESS; $spedec71->saveOrFail(); $speccfba = array(); foreach ($sp137cd7 as $spa9cef2) { $speccfba[] = $spa9cef2->id; $spb73662[] = $spa9cef2->card; } $spedec71->cards()->attach($speccfba); \App\Card::whereIn('id', $speccfba)->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+1'))); $sp9dfc99->count_sold += $spedec71->count; $sp9dfc99->saveOrFail(); return FundHelper::ACTION_CONTINUE; } })) { if (System::_getInt('mail_send_order')) { $spdf69a9 = @json_decode($spedec71->contact_ext, true)['_mail']; if ($spdf69a9) { $spedec71->sendEmail($spdf69a9); } } if ($spedec71->status === \App\Order::STATUS_SUCCESS && System::_getInt('sms_send_order')) { $spcd62a5 = @json_decode($spedec71->contact_ext, true)['_mobile']; if ($spcd62a5) { $spedec71->sendSms($spcd62a5); } } $spedec71['card_orders'] = array_map(function ($spbdd4b3) { return array('card' => array('card' => $spbdd4b3)); }, $spb73662); $spedec71->addHidden(array('system_fee')); return Response::success($spedec71); } else { return Response::fail($sp6e5de7 ?? '数据库繁忙, 请联系客服'); } } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Product.php b/app/Http/Controllers/Merchant/Product.php index ac05f68c5..a940d7446 100644 --- a/app/Http/Controllers/Merchant/Product.php +++ b/app/Http/Controllers/Merchant/Product.php @@ -1,2 +1,2 @@ authQuery($spa27895, \App\Product::class)->with(array('category' => function (Relation $sp7e6fa3) { $sp7e6fa3->select(array('id', 'name', 'password_open')); })); $spfe451d = $spa27895->post('search', false); $sp0edb8f = $spa27895->post('val', false); if ($spfe451d && $sp0edb8f) { if ($spfe451d == 'simple') { if ($spa27895->post('from') === 'card') { $sp7e6fa3->where('delivery', \App\Product::DELIVERY_AUTO); } return Response::success($sp7e6fa3->where('category_id', $sp0edb8f)->get(array('id', 'name'))); } elseif ($spfe451d == 'id') { $sp7e6fa3->where('id', $sp0edb8f); } elseif ($spfe451d == 'category_id') { $sp7e6fa3->where('category_id', $sp0edb8f); } else { $sp7e6fa3->where($spfe451d, 'like', '%' . $sp0edb8f . '%'); } } $sp980f44 = (int) $spa27895->post('category_id'); if ($sp980f44 > 0) { $sp7e6fa3->where('category_id', $sp980f44); } $sp2a8f09 = $spa27895->post('enabled'); if (strlen($sp2a8f09)) { $sp7e6fa3->whereIn('enabled', explode(',', $sp2a8f09)); } $spf69625 = (int) $spa27895->post('current_page', 1); $spe8f5a8 = (int) $spa27895->post('per_page', 20); $sp966ae1 = $sp7e6fa3->orderBy('sort')->paginate($spe8f5a8, array('*'), 'page', $spf69625); foreach ($sp966ae1->items() as $sp1a3ec5) { $sp1a3ec5->setAppends(array('count', 'url')); } return Response::success($sp966ae1); } function sort(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer', 'sort' => 'required|integer')); $sp1a3ec5 = $this->authQuery($spa27895, \App\Product::class)->findOrFail($spa27895->post('id')); $sp1a3ec5->sort = $spa27895->post('sort'); $sp1a3ec5->saveOrFail(); return Response::success(); } function set_count(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer', 'count' => 'required|integer')); $sp1a3ec5 = $this->authQuery($spa27895, \App\Product::class)->findOrFail($spa27895->post('id')); $sp1a3ec5->count_all = $sp1a3ec5->count_sold + $spa27895->post('count'); $sp1a3ec5->saveOrFail(); return Response::success(); } function category_change(Request $spa27895) { $this->validate($spa27895, array('id' => 'required|integer', 'category_id' => 'required')); $sp1a3ec5 = $this->authQuery($spa27895, \App\Product::class)->findOrFail($spa27895->post('id')); $sp980f44 = $spa27895->input('category_id'); if (is_string($sp980f44) && @$sp980f44[0] === '+') { $spd14ca3 = \App\Category::create(array('user_id' => $sp1a3ec5->user_id, 'name' => substr($sp980f44, 1), 'enabled' => true)); } else { $spd14ca3 = $this->authQuery($spa27895, \App\Category::class)->findOrFail($sp980f44); } $sp1a3ec5->category_id = $spd14ca3->id; $sp1a3ec5->save(); return Response::success($spd14ca3); } function edit(Request $spa27895) { $this->validate($spa27895, array('id' => 'sometimes|integer', 'category_id' => 'required', 'description' => 'required|string', 'instructions' => 'required|string', 'fields' => 'required|string', 'sort' => 'required|integer|min:0|max:10000000', 'inventory' => 'required|integer|between:0,2', 'buy_min' => 'required|integer|min:0|max:10000', 'buy_max' => 'required|integer|min:0|max:10000', 'cost' => 'required|numeric|min:0|max:10000000', 'price' => 'required|numeric|min:0.01|max:10000000', 'price_whole' => 'required|string', 'enabled' => 'required|integer|between:0,1')); $sp980f44 = $spa27895->post('category_id'); $sp3a2a1f = is_string($sp980f44) && @$sp980f44[0] === '+'; if ($sp3a2a1f) { $spd14ca3 = \App\Category::create(array('user_id' => $this->getUserIdOrFail($spa27895), 'name' => substr($sp980f44, 1), 'enabled' => true)); } else { $spd14ca3 = $this->authQuery($spa27895, \App\Category::class)->where('id', @intval($sp980f44))->first(); if (!$spd14ca3) { return Response::fail('商品分类不存在'); } } $sp104c39 = $spa27895->post('name'); $sp64c022 = $spa27895->post('description'); $sp769e0a = $spa27895->post('instructions'); $sp61b91e = (int) $spa27895->post('buy_min', 0); $sp8f725d = (int) $spa27895->post('buy_max', 0); $sp40d222 = (int) round($spa27895->post('cost') * 100); $sp2a8f2c = (int) round($spa27895->post('price') * 100); $sp7523bd = $spa27895->post('price_whole'); $sp256278 = @json_decode($sp7523bd, true); foreach ($sp256278 as $sp7f1160) { if ($sp7f1160[1] < 1 || $sp7f1160[1] > 1000000000) { return Response::fail('商品批发价需要在 0.01-10000000 之间'); } } if (System::_getInt('filter_words_open') === 1) { $spfe8b9b = explode('|', System::_get('filter_words')); if (($sp786169 = Helper::filterWords($sp104c39, $spfe8b9b)) !== false) { return Response::fail('提交失败! 商品名称包含敏感词: ' . $sp786169); } if (($sp786169 = Helper::filterWords($sp64c022, $spfe8b9b)) !== false) { return Response::fail('提交失败! 商品描述包含敏感词: ' . $sp786169); } if (($sp786169 = Helper::filterWords($sp769e0a, $spfe8b9b)) !== false) { return Response::fail('提交失败! 商品使用说明包含敏感词: ' . $sp786169); } } if ((int) $spa27895->post('id')) { $sp1a3ec5 = $this->authQuery($spa27895, \App\Product::class)->findOrFail($spa27895->post('id')); } else { $sp1a3ec5 = new \App\Product(); $sp1a3ec5->count_sold = 0; $sp1a3ec5->user_id = $this->getUserIdOrFail($spa27895); } $sp1a3ec5->category_id = $spd14ca3->id; $sp1a3ec5->name = $sp104c39; $sp1ea6f2 = new AntiXSS(); $sp1a3ec5->description = $sp1ea6f2->xss_clean($sp64c022); $sp1a3ec5->instructions = $sp1ea6f2->xss_clean($sp769e0a); $sp1a3ec5->fields = $spa27895->post('fields'); $sp1a3ec5->delivery = (int) $spa27895->post('delivery'); $sp1a3ec5->sort = $spa27895->post('sort'); $sp1a3ec5->buy_min = $sp61b91e; $sp1a3ec5->buy_max = $sp8f725d; $sp1a3ec5->count_warn = $spa27895->post('count_warn'); $sp1a3ec5->support_coupon = $spa27895->post('support_coupon') === 'true'; $sp1a3ec5->password = $spa27895->post('password'); $sp1a3ec5->password_open = $spa27895->post('password_open') === 'true'; $sp1a3ec5->cost = $sp40d222; $sp1a3ec5->price = $sp2a8f2c; $sp1a3ec5->price_whole = $sp7523bd; $sp1a3ec5->enabled = (int) $spa27895->post('enabled'); $sp1a3ec5->inventory = (int) $spa27895->post('inventory'); $sp1a3ec5->saveOrFail(); $spf16c1a = array(); if ($sp3a2a1f) { $spf16c1a['category'] = $spd14ca3; } return Response::success($spf16c1a); } function enable(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string', 'enabled' => 'required|integer')); $sp8e4c06 = $spa27895->post('ids'); $sp2a8f09 = (int) $spa27895->post('enabled'); $this->authQuery($spa27895, \App\Product::class)->whereIn('id', explode(',', $sp8e4c06))->update(array('enabled' => $sp2a8f09)); return Response::success(); } function delete(Request $spa27895) { $this->validate($spa27895, array('ids' => 'required|string')); $sp8e4c06 = $spa27895->post('ids'); $sp8e4c06 = explode(',', $sp8e4c06); $sp40a694 = $this->authQuery($spa27895, \App\Product::class)->whereIn('id', $sp8e4c06); $sp0c9f47 = $this->authQuery($spa27895, \App\Card::class)->whereIn('product_id', $sp8e4c06); return DB::transaction(function () use($sp40a694, $sp0c9f47) { $sp40a694->delete(); $sp0c9f47->forceDelete(); return Response::success(); }); } function count_sync(Request $spa27895) { \App\Product::refreshCount($this->getUser($spa27895)); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Merchant; use App\Library\Helper; use App\Library\Response; use App\System; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\DB; use voku\helper\AntiXSS; class Product extends Controller { function get(Request $spba756f) { $spca8acc = $this->authQuery($spba756f, \App\Product::class)->with(array('category' => function (Relation $spca8acc) { $spca8acc->select(array('id', 'name', 'password_open')); })); $speeddd9 = $spba756f->post('search', false); $spe1fc85 = $spba756f->post('val', false); if ($speeddd9 && $spe1fc85) { if ($speeddd9 == 'simple') { if ($spba756f->post('from') === 'card') { $spca8acc->where('delivery', \App\Product::DELIVERY_AUTO); } return Response::success($spca8acc->where('category_id', $spe1fc85)->get(array('id', 'name'))); } elseif ($speeddd9 == 'id') { $spca8acc->where('id', $spe1fc85); } elseif ($speeddd9 == 'category_id') { $spca8acc->where('category_id', $spe1fc85); } else { $spca8acc->where($speeddd9, 'like', '%' . $spe1fc85 . '%'); } } $sp55f32c = (int) $spba756f->post('category_id'); if ($sp55f32c > 0) { $spca8acc->where('category_id', $sp55f32c); } $spc7c4ac = $spba756f->post('enabled'); if (strlen($spc7c4ac)) { $spca8acc->whereIn('enabled', explode(',', $spc7c4ac)); } $sp881a75 = (int) $spba756f->post('current_page', 1); $sp2a01a9 = (int) $spba756f->post('per_page', 20); $spfea7ce = $spca8acc->orderBy('sort')->paginate($sp2a01a9, array('*'), 'page', $sp881a75); foreach ($spfea7ce->items() as $sp9dfc99) { $sp9dfc99->setAppends(array('count', 'url')); } return Response::success($spfea7ce); } function sort(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer', 'sort' => 'required|integer')); $sp9dfc99 = $this->authQuery($spba756f, \App\Product::class)->findOrFail($spba756f->post('id')); $sp9dfc99->sort = $spba756f->post('sort'); $sp9dfc99->saveOrFail(); return Response::success(); } function set_count(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer', 'count' => 'required|integer')); $sp9dfc99 = $this->authQuery($spba756f, \App\Product::class)->findOrFail($spba756f->post('id')); $sp9dfc99->count_all = $sp9dfc99->count_sold + $spba756f->post('count'); $sp9dfc99->saveOrFail(); return Response::success(); } function category_change(Request $spba756f) { $this->validate($spba756f, array('id' => 'required|integer', 'category_id' => 'required')); $sp9dfc99 = $this->authQuery($spba756f, \App\Product::class)->findOrFail($spba756f->post('id')); $sp55f32c = $spba756f->input('category_id'); if (is_string($sp55f32c) && @$sp55f32c[0] === '+') { $sp1cd1e4 = \App\Category::create(array('user_id' => $sp9dfc99->user_id, 'name' => substr($sp55f32c, 1), 'enabled' => true)); } else { $sp1cd1e4 = $this->authQuery($spba756f, \App\Category::class)->findOrFail($sp55f32c); } $sp9dfc99->category_id = $sp1cd1e4->id; $sp9dfc99->save(); return Response::success($sp1cd1e4); } function edit(Request $spba756f) { $this->validate($spba756f, array('id' => 'sometimes|integer', 'category_id' => 'required', 'description' => 'required|string', 'instructions' => 'required|string', 'fields' => 'required|string', 'sort' => 'required|integer|min:0|max:10000000', 'inventory' => 'required|integer|between:0,2', 'buy_min' => 'required|integer|min:0|max:10000', 'buy_max' => 'required|integer|min:0|max:10000', 'cost' => 'required|numeric|min:0|max:10000000', 'price' => 'required|numeric|min:0.01|max:10000000', 'price_whole' => 'required|string', 'enabled' => 'required|integer|between:0,1')); $sp55f32c = $spba756f->post('category_id'); $spf001d7 = is_string($sp55f32c) && @$sp55f32c[0] === '+'; if ($spf001d7) { $sp1cd1e4 = \App\Category::create(array('user_id' => $this->getUserIdOrFail($spba756f), 'name' => substr($sp55f32c, 1), 'enabled' => true)); } else { $sp1cd1e4 = $this->authQuery($spba756f, \App\Category::class)->where('id', @intval($sp55f32c))->first(); if (!$sp1cd1e4) { return Response::fail('商品分类不存在'); } } $sp387f04 = $spba756f->post('name'); $spfed9d4 = $spba756f->post('description'); $sp95255c = $spba756f->post('instructions'); $sp6f2b2c = (int) $spba756f->post('buy_min', 0); $spea57b7 = (int) $spba756f->post('buy_max', 0); $spdd18a5 = (int) round($spba756f->post('cost') * 100); $sp61875e = (int) round($spba756f->post('price') * 100); $sp75624c = $spba756f->post('price_whole'); $sp43ecd3 = @json_decode($sp75624c, true); foreach ($sp43ecd3 as $sp2cd3a5) { if ($sp2cd3a5[1] < 1 || $sp2cd3a5[1] > 1000000000) { return Response::fail('商品批发价需要在 0.01-10000000 之间'); } } if (System::_getInt('filter_words_open') === 1) { $sp585bcb = explode('|', System::_get('filter_words')); if (($sp5359c9 = Helper::filterWords($sp387f04, $sp585bcb)) !== false) { return Response::fail('提交失败! 商品名称包含敏感词: ' . $sp5359c9); } if (($sp5359c9 = Helper::filterWords($spfed9d4, $sp585bcb)) !== false) { return Response::fail('提交失败! 商品描述包含敏感词: ' . $sp5359c9); } if (($sp5359c9 = Helper::filterWords($sp95255c, $sp585bcb)) !== false) { return Response::fail('提交失败! 商品使用说明包含敏感词: ' . $sp5359c9); } } if ((int) $spba756f->post('id')) { $sp9dfc99 = $this->authQuery($spba756f, \App\Product::class)->findOrFail($spba756f->post('id')); } else { $sp9dfc99 = new \App\Product(); $sp9dfc99->count_sold = 0; $sp9dfc99->user_id = $this->getUserIdOrFail($spba756f); } $sp9dfc99->category_id = $sp1cd1e4->id; $sp9dfc99->name = $sp387f04; $sp183456 = new AntiXSS(); $sp9dfc99->description = $sp183456->xss_clean($spfed9d4); $sp9dfc99->instructions = $sp183456->xss_clean($sp95255c); $sp9dfc99->fields = $spba756f->post('fields'); $sp9dfc99->delivery = (int) $spba756f->post('delivery'); $sp9dfc99->sort = $spba756f->post('sort'); $sp9dfc99->buy_min = $sp6f2b2c; $sp9dfc99->buy_max = $spea57b7; $sp9dfc99->count_warn = $spba756f->post('count_warn'); $sp9dfc99->support_coupon = $spba756f->post('support_coupon') === 'true'; $sp9dfc99->password = $spba756f->post('password'); $sp9dfc99->password_open = $spba756f->post('password_open') === 'true'; $sp9dfc99->cost = $spdd18a5; $sp9dfc99->price = $sp61875e; $sp9dfc99->price_whole = $sp75624c; $sp9dfc99->enabled = (int) $spba756f->post('enabled'); $sp9dfc99->inventory = (int) $spba756f->post('inventory'); $sp9dfc99->saveOrFail(); $spb9364a = array(); if ($spf001d7) { $spb9364a['category'] = $sp1cd1e4; } return Response::success($spb9364a); } function enable(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string', 'enabled' => 'required|integer')); $sp12026a = $spba756f->post('ids'); $spc7c4ac = (int) $spba756f->post('enabled'); $this->authQuery($spba756f, \App\Product::class)->whereIn('id', explode(',', $sp12026a))->update(array('enabled' => $spc7c4ac)); return Response::success(); } function delete(Request $spba756f) { $this->validate($spba756f, array('ids' => 'required|string')); $sp12026a = $spba756f->post('ids'); $sp12026a = explode(',', $sp12026a); $sp94e351 = $this->authQuery($spba756f, \App\Product::class)->whereIn('id', $sp12026a); $spd6fbf5 = $this->authQuery($spba756f, \App\Card::class)->whereIn('product_id', $sp12026a); return DB::transaction(function () use($sp94e351, $spd6fbf5) { $sp94e351->delete(); $spd6fbf5->forceDelete(); return Response::success(); }); } function count_sync(Request $spba756f) { \App\Product::refreshCount($this->getUser($spba756f)); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Shop/Coupon.php b/app/Http/Controllers/Shop/Coupon.php index d9deb2cca..cd8223829 100644 --- a/app/Http/Controllers/Shop/Coupon.php +++ b/app/Http/Controllers/Shop/Coupon.php @@ -1,2 +1,2 @@ post('category_id', -1); $sp112a12 = (int) $spa27895->post('product_id', -1); $sp2a00ee = $spa27895->post('coupon'); if (!$sp2a00ee) { return Response::fail('请输入优惠券'); } if ($sp980f44 > 0) { $spd14ca3 = Category::findOrFail($sp980f44); $sp258cf6 = $spd14ca3->user_id; } elseif ($sp112a12 > 0) { $sp1a3ec5 = Product::findOrFail($sp112a12); $sp258cf6 = $sp1a3ec5->user_id; } else { return Response::fail('请先选择分类或商品'); } $sp6de18e = \App\Coupon::where('user_id', $sp258cf6)->where('coupon', $sp2a00ee)->where('expire_at', '>', Carbon::now())->whereRaw('`count_used`<`count_all`')->get(); foreach ($sp6de18e as $sp2a00ee) { if ($sp2a00ee->category_id === -1 || $sp2a00ee->category_id === $sp980f44 && ($sp2a00ee->product_id === -1 || $sp2a00ee->product_id === $sp112a12)) { $sp2a00ee->setVisible(array('discount_type', 'discount_val')); return Response::success($sp2a00ee); } } return Response::fail('您输入的优惠券信息无效
如果没有优惠券请不要填写'); } } \ No newline at end of file +namespace App\Http\Controllers\Shop; use App\Category; use App\Product; use App\Library\Response; use Carbon\Carbon; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class Coupon extends Controller { function info(Request $spba756f) { $sp55f32c = (int) $spba756f->post('category_id', -1); $sp1b83a8 = (int) $spba756f->post('product_id', -1); $sp8bf4fa = $spba756f->post('coupon'); if (!$sp8bf4fa) { return Response::fail('请输入优惠券'); } if ($sp55f32c > 0) { $sp1cd1e4 = Category::findOrFail($sp55f32c); $spf5ae13 = $sp1cd1e4->user_id; } elseif ($sp1b83a8 > 0) { $sp9dfc99 = Product::findOrFail($sp1b83a8); $spf5ae13 = $sp9dfc99->user_id; } else { return Response::fail('请先选择分类或商品'); } $sp97692a = \App\Coupon::where('user_id', $spf5ae13)->where('coupon', $sp8bf4fa)->where('expire_at', '>', Carbon::now())->whereRaw('`count_used`<`count_all`')->get(); foreach ($sp97692a as $sp8bf4fa) { if ($sp8bf4fa->category_id === -1 || $sp8bf4fa->category_id === $sp55f32c && ($sp8bf4fa->product_id === -1 || $sp8bf4fa->product_id === $sp1b83a8)) { $sp8bf4fa->setVisible(array('discount_type', 'discount_val')); return Response::success($sp8bf4fa); } } return Response::fail('您输入的优惠券信息无效
如果没有优惠券请不要填写'); } } \ No newline at end of file diff --git a/app/Http/Controllers/Shop/Order.php b/app/Http/Controllers/Shop/Order.php index b0f5ce213..9badc3326 100644 --- a/app/Http/Controllers/Shop/Order.php +++ b/app/Http/Controllers/Shop/Order.php @@ -1,2 +1,2 @@ post('geetest_challenge'), $spa27895->post('geetest_validate'), $spa27895->post('geetest_seccode')); if (!$sp786169) { return Response::fail('系统无法接受您的验证结果,请刷新页面后重试。'); } } $sp7e6fa3 = \App\Order::where('created_at', '>=', (new Carbon())->addDay(-\App\System::_getInt('order_query_day', 30))); $sp460df4 = $spa27895->post('type', ''); if ($sp460df4 === 'cookie') { $spe44380 = Cookie::get('customer'); if (strlen($spe44380) !== 32) { return Response::success(); } $sp7e6fa3->where('customer', $spe44380); } elseif ($sp460df4 === 'order_no') { $sp0dbaa3 = $spa27895->post('order_no', ''); if (strlen($sp0dbaa3) !== 19) { return Response::success(); } $sp7e6fa3->where('order_no', $sp0dbaa3); } elseif ($sp460df4 === 'contact') { $sp0c9f2e = $spa27895->post('contact', ''); if (strlen($sp0c9f2e) < 6) { return Response::success(); } $sp7e6fa3->where('contact', $sp0c9f2e); } else { return Response::fail('请选择查询类型'); } $sp587ad4 = array('id', 'created_at', 'order_no', 'contact', 'status', 'send_status', 'count', 'paid'); if (1) { $sp587ad4[] = 'product_name'; $sp587ad4[] = 'contact'; $sp587ad4[] = 'contact_ext'; } $sp966ae1 = $sp7e6fa3->orderBy('id', 'DESC')->get($sp587ad4); $spde7fa0 = ''; return Response::success(array('list' => $sp966ae1, 'msg' => count($sp966ae1) ? $spde7fa0 : '')); } } \ No newline at end of file +namespace App\Http\Controllers\Shop; use Carbon\Carbon; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Library\Response; use App\Library\Geetest; use Illuminate\Support\Facades\Cookie; class Order extends Controller { function get(Request $spba756f) { if ((int) \App\System::_get('vcode_shop_search') === 1) { $sp5359c9 = Geetest\API::verify($spba756f->post('geetest_challenge'), $spba756f->post('geetest_validate'), $spba756f->post('geetest_seccode')); if (!$sp5359c9) { return Response::fail('系统无法接受您的验证结果,请刷新页面后重试。'); } } $spca8acc = \App\Order::where('created_at', '>=', (new Carbon())->addDay(-\App\System::_getInt('order_query_day', 30))); $spe7b1c7 = $spba756f->post('type', ''); if ($spe7b1c7 === 'cookie') { $sp5ac530 = Cookie::get('customer'); if (strlen($sp5ac530) !== 32) { return Response::success(); } $spca8acc->where('customer', $sp5ac530); } elseif ($spe7b1c7 === 'order_no') { $spf34e1a = $spba756f->post('order_no', ''); if (strlen($spf34e1a) !== 19) { return Response::success(); } $spca8acc->where('order_no', $spf34e1a); } elseif ($spe7b1c7 === 'contact') { $spa04ff6 = $spba756f->post('contact', ''); if (strlen($spa04ff6) < 6) { return Response::success(); } $spca8acc->where('contact', $spa04ff6); } else { return Response::fail('请选择查询类型'); } $sp1bb3f5 = array('id', 'created_at', 'order_no', 'contact', 'status', 'send_status', 'count', 'paid'); if (1) { $sp1bb3f5[] = 'product_name'; $sp1bb3f5[] = 'contact'; $sp1bb3f5[] = 'contact_ext'; } $spfea7ce = $spca8acc->orderBy('id', 'DESC')->get($sp1bb3f5); $sp28477e = ''; return Response::success(array('list' => $spfea7ce, 'msg' => count($spfea7ce) ? $sp28477e : '')); } } \ No newline at end of file diff --git a/app/Http/Controllers/Shop/Pay.php b/app/Http/Controllers/Shop/Pay.php index 550d87adc..ca2426524 100644 --- a/app/Http/Controllers/Shop/Pay.php +++ b/app/Http/Controllers/Shop/Pay.php @@ -1,15 +1,15 @@ goPay($sp460280, $sp0dbaa3, $spbcc226, $spbcc226, $sp3cd8b6); return self::renderResultPage($spa27895, array('success' => false, 'title' => '请稍后', 'msg' => '支付方式加载中,请稍后')); } catch (\Exception $sp45f5f1) { return self::renderResultPage($spa27895, array('msg' => $sp45f5f1->getMessage())); } } function buy(Request $spa27895) { $spe44380 = $spa27895->input('customer'); if (strlen($spe44380) !== 32) { return self::renderResultPage($spa27895, array('msg' => '提交超时,请刷新购买页面并重新提交

-当前网址: ' . $spa27895->getQueryString() . ' -提交内容: ' . var_export($spe44380) . ', 提交长度:' . strlen($spe44380) . '
-若您刷新后仍然出现此问题. 请加网站客服反馈')); } if ((int) System::_get('vcode_shop_buy') === 1) { $sp786169 = Geetest\API::verify($spa27895->input('geetest_challenge'), $spa27895->input('geetest_validate'), $spa27895->input('geetest_seccode')); if (!$sp786169) { return self::renderResultPage($spa27895, array('msg' => '滑动验证超时,请返回页面重试。')); } } $sp980f44 = (int) $spa27895->input('category_id'); $sp112a12 = (int) $spa27895->input('product_id'); $spdf4a99 = (int) $spa27895->input('count'); $sp2a00ee = $spa27895->input('coupon'); $sp0c9f2e = $spa27895->input('contact'); $spa3a8ba = $spa27895->input('contact_ext') ?? null; $sp710247 = !empty(@json_decode($spa3a8ba, true)['_mobile']); $sp70c8c8 = (int) $spa27895->input('pay_id'); if (!$sp980f44 || !$sp112a12) { return self::renderResultPage($spa27895, array('msg' => '请选择商品')); } if (strlen($sp0c9f2e) < 1) { return self::renderResultPage($spa27895, array('msg' => '请输入联系方式')); } $spd14ca3 = Category::findOrFail($sp980f44); $sp1a3ec5 = Product::where('id', $sp112a12)->where('category_id', $sp980f44)->where('enabled', 1)->with(array('user'))->first(); if ($sp1a3ec5 == null || $sp1a3ec5->user == null) { return self::renderResultPage($spa27895, array('msg' => '该商品未找到,请重新选择')); } if ($sp1a3ec5->password_open) { if ($sp1a3ec5->password !== $spa27895->input('product_password')) { return self::renderResultPage($spa27895, array('msg' => '商品密码输入错误')); } } else { if ($spd14ca3->password_open) { if ($spd14ca3->password !== $spa27895->input('category_password')) { if ($spd14ca3->getTmpPassword() !== $spa27895->input('category_password')) { return self::renderResultPage($spa27895, array('msg' => '分类密码输入错误')); } } } } if ($spdf4a99 < $sp1a3ec5->buy_min) { return self::renderResultPage($spa27895, array('msg' => '该商品最少购买' . $sp1a3ec5->buy_min . '件,请重新选择')); } if ($spdf4a99 > $sp1a3ec5->buy_max) { return self::renderResultPage($spa27895, array('msg' => '该商品限购' . $sp1a3ec5->buy_max . '件,请重新选择')); } if ($sp1a3ec5->count < $spdf4a99) { return self::renderResultPage($spa27895, array('msg' => '该商品库存不足')); } $sp1d1f3d = \App\Pay::find($sp70c8c8); if ($sp1d1f3d == null || !$sp1d1f3d->enabled) { return self::renderResultPage($spa27895, array('msg' => '支付方式未找到,请重新选择')); } $sp228f7b = $sp1a3ec5->price; if ($sp1a3ec5->price_whole) { $sp7523bd = json_decode($sp1a3ec5->price_whole, true); for ($spe20094 = count($sp7523bd) - 1; $spe20094 >= 0; $spe20094--) { if ($spdf4a99 >= (int) $sp7523bd[$spe20094][0]) { $sp228f7b = (int) $sp7523bd[$spe20094][1]; break; } } } $sp2a8f2c = $spdf4a99 * $sp228f7b; $sp3cd8b6 = $sp2a8f2c; $spe60e57 = 0; $sp298ce7 = null; if ($sp1a3ec5->support_coupon && strlen($sp2a00ee) > 0) { $sp6de18e = \App\Coupon::where('user_id', $sp1a3ec5->user_id)->where('coupon', $sp2a00ee)->where('expire_at', '>', Carbon::now())->whereRaw('`count_used`<`count_all`')->get(); foreach ($sp6de18e as $sp1ea3c0) { if ($sp1ea3c0->category_id === -1 || $sp1ea3c0->category_id === $sp980f44 && ($sp1ea3c0->product_id === -1 || $sp1ea3c0->product_id === $sp112a12)) { if ($sp1ea3c0->discount_type === \App\Coupon::DISCOUNT_TYPE_AMOUNT && $sp3cd8b6 >= $sp1ea3c0->discount_val) { $sp298ce7 = $sp1ea3c0; $spe60e57 = $sp1ea3c0->discount_val; break; } if ($sp1ea3c0->discount_type === \App\Coupon::DISCOUNT_TYPE_PERCENT) { $sp298ce7 = $sp1ea3c0; $spe60e57 = (int) round($sp3cd8b6 * $sp1ea3c0->discount_val / 100); break; } } } if ($sp298ce7 === null) { return self::renderResultPage($spa27895, array('msg' => '优惠券信息错误,请重新输入')); } $sp3cd8b6 -= $spe60e57; } $spccc361 = (int) round($sp3cd8b6 * $sp1d1f3d->fee_system); $spbcd262 = $sp3cd8b6 - $spccc361; $sp65ab2f = $sp710247 ? System::_getInt('sms_price', 10) : 0; $sp3cd8b6 += $sp65ab2f; $sp40d222 = $spdf4a99 * $sp1a3ec5->cost; $sp0dbaa3 = \App\Order::unique_no(); try { DB::transaction(function () use($sp1a3ec5, $sp0dbaa3, $sp298ce7, $sp0c9f2e, $spa3a8ba, $spe44380, $spdf4a99, $sp40d222, $sp2a8f2c, $sp65ab2f, $spe60e57, $sp3cd8b6, $sp1d1f3d, $spccc361, $spbcd262) { if ($sp298ce7) { $sp298ce7->status = \App\Coupon::STATUS_USED; $sp298ce7->count_used++; $sp298ce7->save(); $sp52fef6 = '使用优惠券: ' . $sp298ce7->coupon; } else { $sp52fef6 = null; } $sp7b2cfc = \App\Order::create(array('user_id' => $sp1a3ec5->user_id, 'order_no' => $sp0dbaa3, 'product_id' => $sp1a3ec5->id, 'product_name' => $sp1a3ec5->name, 'count' => $spdf4a99, 'ip' => Helper::getIP(), 'customer' => $spe44380, 'contact' => $sp0c9f2e, 'contact_ext' => $spa3a8ba, 'cost' => $sp40d222, 'price' => $sp2a8f2c, 'sms_price' => $sp65ab2f, 'discount' => $spe60e57, 'paid' => $sp3cd8b6, 'pay_id' => $sp1d1f3d->id, 'fee' => $spccc361, 'system_fee' => $spccc361, 'income' => $spbcd262, 'status' => \App\Order::STATUS_UNPAY, 'remark' => $sp52fef6, 'created_at' => Carbon::now())); assert($sp7b2cfc !== null); }); } catch (\Throwable $sp45f5f1) { Log::error('Shop.Pay.buy 下单失败', array('Exception' => $sp45f5f1)); return self::renderResultPage($spa27895, array('msg' => '发生错误,下单失败,请稍后重试')); } if ($sp3cd8b6 === 0) { $this->shipOrder($spa27895, $sp0dbaa3, $sp3cd8b6, null); return redirect('/pay/result/' . $sp0dbaa3); } $spbcc226 = $sp0dbaa3; return $this->goPay($spa27895, $sp0dbaa3, $spbcc226, $sp1d1f3d, $sp3cd8b6); } function pay(Request $spa27895, $sp0dbaa3) { $sp7b2cfc = \App\Order::whereOrderNo($sp0dbaa3)->first(); if ($sp7b2cfc == null) { return self::renderResultPage($spa27895, array('msg' => '订单未找到,请重试')); } if ($sp7b2cfc->status !== \App\Order::STATUS_UNPAY) { return redirect('/pay/result/' . $sp0dbaa3); } $sp860109 = 'pay: ' . $sp7b2cfc->pay_id; $sp460280 = $sp7b2cfc->pay; if (!$sp460280) { \Log::error($sp860109 . ' cannot find Pay'); return $this->renderResultPage($spa27895, array('msg' => '支付方式未找到')); } $sp860109 .= ',' . $sp460280->driver; $spfd6e52 = json_decode($sp460280->config, true); $spfd6e52['payway'] = $sp460280->way; $spfd6e52['out_trade_no'] = $sp0dbaa3; try { $this->payApi = GatewayPay::getDriver($sp460280->id, $sp460280->driver); } catch (\Exception $sp45f5f1) { \Log::error($sp860109 . ' cannot find Driver: ' . $sp45f5f1->getMessage()); return $this->renderResultPage($spa27895, array('msg' => '支付驱动未找到')); } if ($this->payApi->verify($spfd6e52, function ($sp0dbaa3, $spa468fd, $sp002509) use($spa27895) { try { $this->shipOrder($spa27895, $sp0dbaa3, $spa468fd, $sp002509); } catch (\Exception $sp45f5f1) { $this->renderResultPage($spa27895, array('success' => false, 'msg' => $sp45f5f1->getMessage())); } })) { \Log::notice($sp860109 . ' already success' . ' +namespace App\Http\Controllers\Shop; use App\Card; use App\Category; use App\Library\FundHelper; use App\Library\Helper; use App\Library\LogHelper; use App\Product; use App\Library\Response; use Gateway\Pay\Pay as GatewayPay; use App\Library\Geetest; use App\Mail\ProductCountWarn; use App\System; use Carbon\Carbon; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; class Pay extends Controller { public function __construct() { define('SYS_NAME', config('app.name')); define('SYS_URL', config('app.url')); define('SYS_URL_API', config('app.url_api')); } private $payApi = null; public function goPay($spba756f, $spf34e1a, $sp15079e, $sp6485f6, $sp29e1a9) { try { $spf3616d = json_decode($sp6485f6->config, true); $spf3616d['payway'] = $sp6485f6->way; GatewayPay::getDriver($sp6485f6)->goPay($spf3616d, $spf34e1a, $sp15079e, $sp15079e, $sp29e1a9); return self::renderResultPage($spba756f, array('success' => false, 'title' => '请稍后', 'msg' => '支付方式加载中,请稍后')); } catch (\Exception $sp6a7295) { return self::renderResultPage($spba756f, array('msg' => $sp6a7295->getMessage())); } } function buy(Request $spba756f) { $sp5ac530 = $spba756f->input('customer'); if (strlen($sp5ac530) !== 32) { return self::renderResultPage($spba756f, array('msg' => '提交超时,请刷新购买页面并重新提交

+当前网址: ' . $spba756f->getQueryString() . ' +提交内容: ' . var_export($sp5ac530) . ', 提交长度:' . strlen($sp5ac530) . '
+若您刷新后仍然出现此问题. 请加网站客服反馈')); } if ((int) System::_get('vcode_shop_buy') === 1) { $sp5359c9 = Geetest\API::verify($spba756f->input('geetest_challenge'), $spba756f->input('geetest_validate'), $spba756f->input('geetest_seccode')); if (!$sp5359c9) { return self::renderResultPage($spba756f, array('msg' => '滑动验证超时,请返回页面重试。')); } } $sp55f32c = (int) $spba756f->input('category_id'); $sp1b83a8 = (int) $spba756f->input('product_id'); $sp99aae1 = (int) $spba756f->input('count'); $sp8bf4fa = $spba756f->input('coupon'); $spa04ff6 = $spba756f->input('contact'); $sp682364 = $spba756f->input('contact_ext') ?? null; $spa2291d = !empty(@json_decode($sp682364, true)['_mobile']); $sp8e6264 = (int) $spba756f->input('pay_id'); if (!$sp55f32c || !$sp1b83a8) { return self::renderResultPage($spba756f, array('msg' => '请选择商品')); } if (strlen($spa04ff6) < 1) { return self::renderResultPage($spba756f, array('msg' => '请输入联系方式')); } $sp1cd1e4 = Category::findOrFail($sp55f32c); $sp9dfc99 = Product::where('id', $sp1b83a8)->where('category_id', $sp55f32c)->where('enabled', 1)->with(array('user'))->first(); if ($sp9dfc99 == null || $sp9dfc99->user == null) { return self::renderResultPage($spba756f, array('msg' => '该商品未找到,请重新选择')); } if ($sp9dfc99->password_open) { if ($sp9dfc99->password !== $spba756f->input('product_password')) { return self::renderResultPage($spba756f, array('msg' => '商品密码输入错误')); } } else { if ($sp1cd1e4->password_open) { if ($sp1cd1e4->password !== $spba756f->input('category_password')) { if ($sp1cd1e4->getTmpPassword() !== $spba756f->input('category_password')) { return self::renderResultPage($spba756f, array('msg' => '分类密码输入错误')); } } } } if ($sp99aae1 < $sp9dfc99->buy_min) { return self::renderResultPage($spba756f, array('msg' => '该商品最少购买' . $sp9dfc99->buy_min . '件,请重新选择')); } if ($sp99aae1 > $sp9dfc99->buy_max) { return self::renderResultPage($spba756f, array('msg' => '该商品限购' . $sp9dfc99->buy_max . '件,请重新选择')); } if ($sp9dfc99->count < $sp99aae1) { return self::renderResultPage($spba756f, array('msg' => '该商品库存不足')); } $sp91f0ec = \App\Pay::find($sp8e6264); if ($sp91f0ec == null || !$sp91f0ec->enabled) { return self::renderResultPage($spba756f, array('msg' => '支付方式未找到,请重新选择')); } $spfc2da2 = $sp9dfc99->price; if ($sp9dfc99->price_whole) { $sp75624c = json_decode($sp9dfc99->price_whole, true); for ($spc8f255 = count($sp75624c) - 1; $spc8f255 >= 0; $spc8f255--) { if ($sp99aae1 >= (int) $sp75624c[$spc8f255][0]) { $spfc2da2 = (int) $sp75624c[$spc8f255][1]; break; } } } $sp61875e = $sp99aae1 * $spfc2da2; $sp29e1a9 = $sp61875e; $sp24f85c = 0; $sp5b1ef4 = null; if ($sp9dfc99->support_coupon && strlen($sp8bf4fa) > 0) { $sp97692a = \App\Coupon::where('user_id', $sp9dfc99->user_id)->where('coupon', $sp8bf4fa)->where('expire_at', '>', Carbon::now())->whereRaw('`count_used`<`count_all`')->get(); foreach ($sp97692a as $sp4cb2ce) { if ($sp4cb2ce->category_id === -1 || $sp4cb2ce->category_id === $sp55f32c && ($sp4cb2ce->product_id === -1 || $sp4cb2ce->product_id === $sp1b83a8)) { if ($sp4cb2ce->discount_type === \App\Coupon::DISCOUNT_TYPE_AMOUNT && $sp29e1a9 >= $sp4cb2ce->discount_val) { $sp5b1ef4 = $sp4cb2ce; $sp24f85c = $sp4cb2ce->discount_val; break; } if ($sp4cb2ce->discount_type === \App\Coupon::DISCOUNT_TYPE_PERCENT) { $sp5b1ef4 = $sp4cb2ce; $sp24f85c = (int) round($sp29e1a9 * $sp4cb2ce->discount_val / 100); break; } } } if ($sp5b1ef4 === null) { return self::renderResultPage($spba756f, array('msg' => '优惠券信息错误,请重新输入')); } $sp29e1a9 -= $sp24f85c; } $sp052c39 = (int) round($sp29e1a9 * $sp91f0ec->fee_system); $spe40be8 = $sp29e1a9 - $sp052c39; $sp06b9c0 = $spa2291d ? System::_getInt('sms_price', 10) : 0; $sp29e1a9 += $sp06b9c0; $spdd18a5 = $sp99aae1 * $sp9dfc99->cost; $spf34e1a = \App\Order::unique_no(); try { DB::transaction(function () use($sp9dfc99, $spf34e1a, $sp5b1ef4, $spa04ff6, $sp682364, $sp5ac530, $sp99aae1, $spdd18a5, $sp61875e, $sp06b9c0, $sp24f85c, $sp29e1a9, $sp91f0ec, $sp052c39, $spe40be8) { if ($sp5b1ef4) { $sp5b1ef4->status = \App\Coupon::STATUS_USED; $sp5b1ef4->count_used++; $sp5b1ef4->save(); $spd8e3f6 = '使用优惠券: ' . $sp5b1ef4->coupon; } else { $spd8e3f6 = null; } $spedec71 = \App\Order::create(array('user_id' => $sp9dfc99->user_id, 'order_no' => $spf34e1a, 'product_id' => $sp9dfc99->id, 'product_name' => $sp9dfc99->name, 'count' => $sp99aae1, 'ip' => Helper::getIP(), 'customer' => $sp5ac530, 'contact' => $spa04ff6, 'contact_ext' => $sp682364, 'cost' => $spdd18a5, 'price' => $sp61875e, 'sms_price' => $sp06b9c0, 'discount' => $sp24f85c, 'paid' => $sp29e1a9, 'pay_id' => $sp91f0ec->id, 'fee' => $sp052c39, 'system_fee' => $sp052c39, 'income' => $spe40be8, 'status' => \App\Order::STATUS_UNPAY, 'remark' => $spd8e3f6, 'created_at' => Carbon::now())); assert($spedec71 !== null); }); } catch (\Throwable $sp6a7295) { Log::error('Shop.Pay.buy 下单失败', array('Exception' => $sp6a7295)); return self::renderResultPage($spba756f, array('msg' => '发生错误,下单失败,请稍后重试')); } if ($sp29e1a9 === 0) { $this->shipOrder($spba756f, $spf34e1a, $sp29e1a9, null); return redirect('/pay/result/' . $spf34e1a); } $sp15079e = $spf34e1a; return $this->goPay($spba756f, $spf34e1a, $sp15079e, $sp91f0ec, $sp29e1a9); } function pay(Request $spba756f, $spf34e1a) { $spedec71 = \App\Order::whereOrderNo($spf34e1a)->first(); if ($spedec71 == null) { return self::renderResultPage($spba756f, array('msg' => '订单未找到,请重试')); } if ($spedec71->status !== \App\Order::STATUS_UNPAY) { return redirect('/pay/result/' . $spf34e1a); } $sp591089 = 'pay: ' . $spedec71->pay_id; $sp6485f6 = $spedec71->pay; if (!$sp6485f6) { \Log::error($sp591089 . ' cannot find Pay'); return $this->renderResultPage($spba756f, array('msg' => '支付方式未找到')); } $sp591089 .= ',' . $sp6485f6->driver; $spf3616d = json_decode($sp6485f6->config, true); $spf3616d['payway'] = $sp6485f6->way; $spf3616d['out_trade_no'] = $spf34e1a; try { $this->payApi = GatewayPay::getDriver($sp6485f6); } catch (\Exception $sp6a7295) { \Log::error($sp591089 . ' cannot find Driver: ' . $sp6a7295->getMessage()); return $this->renderResultPage($spba756f, array('msg' => '支付驱动未找到')); } if ($this->payApi->verify($spf3616d, function ($spf34e1a, $sp246f65, $sp9db197) use($spba756f) { try { $this->shipOrder($spba756f, $spf34e1a, $sp246f65, $sp9db197); } catch (\Exception $sp6a7295) { $this->renderResultPage($spba756f, array('success' => false, 'msg' => $sp6a7295->getMessage())); } })) { \Log::notice($sp591089 . ' already success' . ' -'); return redirect('/pay/result/' . $sp0dbaa3); } if ($sp7b2cfc->created_at < Carbon::now()->addMinutes(-5)) { return $this->renderResultPage($spa27895, array('msg' => '当前订单长时间未支付已作废, 请重新下单')); } $sp1a3ec5 = Product::where('id', $sp7b2cfc->product_id)->where('enabled', 1)->first(); if ($sp1a3ec5 == null) { return self::renderResultPage($spa27895, array('msg' => '该商品已下架')); } $sp1a3ec5->setAttribute('count', count($sp1a3ec5->cards) ? $sp1a3ec5->cards[0]->count : 0); if ($sp1a3ec5->count < $sp7b2cfc->count) { return self::renderResultPage($spa27895, array('msg' => '该商品库存不足')); } $spbcc226 = $sp0dbaa3; return $this->goPay($spa27895, $sp0dbaa3, $spbcc226, $sp460280, $sp7b2cfc->paid); } function qrcode(Request $spa27895, $sp0dbaa3, $sp64a576) { $sp7b2cfc = \App\Order::whereOrderNo($sp0dbaa3)->with('product')->first(); if ($sp7b2cfc == null) { return self::renderResultPage($spa27895, array('msg' => '订单未找到,请重试')); } if ($sp7b2cfc->product_id !== \App\Product::ID_API && $sp7b2cfc->product == null) { return self::renderResultPage($spa27895, array('msg' => '商品未找到,请重试')); } return view('pay/' . $sp64a576, array('pay_id' => $sp7b2cfc->pay_id, 'name' => $sp7b2cfc->product->name . ' x ' . $sp7b2cfc->count . '件', 'amount' => $sp7b2cfc->paid, 'qrcode' => $spa27895->get('url'), 'id' => $sp0dbaa3)); } function qrQuery(Request $spa27895, $sp70c8c8) { $sp4c9240 = $spa27895->input('id', ''); return self::payReturn($spa27895, $sp70c8c8, $sp4c9240); } function payReturn(Request $spa27895, $sp70c8c8, $spe3eeee = '') { $sp860109 = 'payReturn: ' . $sp70c8c8; \Log::debug($sp860109); $sp460280 = \App\Pay::where('id', $sp70c8c8)->first(); if (!$sp460280) { return $this->renderResultPage($spa27895, array('success' => 0, 'msg' => '支付方式错误')); } $sp860109 .= ',' . $sp460280->driver; if (strlen($spe3eeee) > 0) { $sp7b2cfc = \App\Order::whereOrderNo($spe3eeee)->first(); if ($sp7b2cfc && ($sp7b2cfc->status === \App\Order::STATUS_PAID || $sp7b2cfc->status === \App\Order::STATUS_SUCCESS)) { \Log::notice($sp860109 . ' already success' . ' +'); return redirect('/pay/result/' . $spf34e1a); } if ($spedec71->created_at < Carbon::now()->addMinutes(-5)) { return $this->renderResultPage($spba756f, array('msg' => '当前订单长时间未支付已作废, 请重新下单')); } $sp9dfc99 = Product::where('id', $spedec71->product_id)->where('enabled', 1)->first(); if ($sp9dfc99 == null) { return self::renderResultPage($spba756f, array('msg' => '该商品已下架')); } $sp9dfc99->setAttribute('count', count($sp9dfc99->cards) ? $sp9dfc99->cards[0]->count : 0); if ($sp9dfc99->count < $spedec71->count) { return self::renderResultPage($spba756f, array('msg' => '该商品库存不足')); } $sp15079e = $spf34e1a; return $this->goPay($spba756f, $spf34e1a, $sp15079e, $sp6485f6, $spedec71->paid); } function qrcode(Request $spba756f, $spf34e1a, $sp51d94f) { $spedec71 = \App\Order::whereOrderNo($spf34e1a)->with('product')->first(); if ($spedec71 == null) { return self::renderResultPage($spba756f, array('msg' => '订单未找到,请重试')); } if ($spedec71->product_id !== \App\Product::ID_API && $spedec71->product == null) { return self::renderResultPage($spba756f, array('msg' => '商品未找到,请重试')); } return view('pay/' . $sp51d94f, array('pay_id' => $spedec71->pay_id, 'name' => $spedec71->product->name . ' x ' . $spedec71->count . '件', 'amount' => $spedec71->paid, 'qrcode' => $spba756f->get('url'), 'id' => $spf34e1a)); } function qrQuery(Request $spba756f, $sp8e6264) { $sp86fcb1 = $spba756f->input('id', ''); return self::payReturn($spba756f, $sp8e6264, $sp86fcb1); } function payReturn(Request $spba756f, $sp8e6264, $sp5fcd9d = '') { $sp591089 = 'payReturn: ' . $sp8e6264; \Log::debug($sp591089); $sp6485f6 = \App\Pay::where('id', $sp8e6264)->first(); if (!$sp6485f6) { return $this->renderResultPage($spba756f, array('success' => 0, 'msg' => '支付方式错误')); } $sp591089 .= ',' . $sp6485f6->driver; if (strlen($sp5fcd9d) > 0) { $spedec71 = \App\Order::whereOrderNo($sp5fcd9d)->first(); if ($spedec71 && ($spedec71->status === \App\Order::STATUS_PAID || $spedec71->status === \App\Order::STATUS_SUCCESS)) { \Log::notice($sp591089 . ' already success' . ' -'); if ($spa27895->ajax()) { return self::renderResultPage($spa27895, array('success' => 1, 'data' => '/pay/result/' . $spe3eeee), array('order' => $sp7b2cfc)); } else { return redirect('/pay/result/' . $spe3eeee); } } } try { $this->payApi = GatewayPay::getDriver($sp460280->id, $sp460280->driver); } catch (\Exception $sp45f5f1) { \Log::error($sp860109 . ' cannot find Driver: ' . $sp45f5f1->getMessage()); return $this->renderResultPage($spa27895, array('success' => 0, 'msg' => '支付驱动未找到')); } $spfd6e52 = json_decode($sp460280->config, true); $spfd6e52['out_trade_no'] = $spe3eeee; $spfd6e52['payway'] = $sp460280->way; \Log::debug($sp860109 . ' will verify'); if ($this->payApi->verify($spfd6e52, function ($sp0dbaa3, $spa468fd, $sp002509) use($spa27895, $sp860109, &$spe3eeee) { $spe3eeee = $sp0dbaa3; try { \Log::debug($sp860109 . " shipOrder start, order_no: {$sp0dbaa3}, amount: {$spa468fd}, trade_no: {$sp002509}"); $this->shipOrder($spa27895, $sp0dbaa3, $spa468fd, $sp002509); \Log::debug($sp860109 . ' shipOrder end, order_no: ' . $sp0dbaa3); } catch (\Exception $sp45f5f1) { \Log::error($sp860109 . ' shipOrder Exception: ' . $sp45f5f1->getMessage()); } })) { \Log::debug($sp860109 . ' verify finished: 1' . ' +'); if ($spba756f->ajax()) { return self::renderResultPage($spba756f, array('success' => 1, 'data' => '/pay/result/' . $sp5fcd9d), array('order' => $spedec71)); } else { return redirect('/pay/result/' . $sp5fcd9d); } } } try { $this->payApi = GatewayPay::getDriver($sp6485f6); } catch (\Exception $sp6a7295) { \Log::error($sp591089 . ' cannot find Driver: ' . $sp6a7295->getMessage()); return $this->renderResultPage($spba756f, array('success' => 0, 'msg' => '支付驱动未找到')); } $spf3616d = json_decode($sp6485f6->config, true); $spf3616d['out_trade_no'] = $sp5fcd9d; $spf3616d['payway'] = $sp6485f6->way; \Log::debug($sp591089 . ' will verify'); if ($this->payApi->verify($spf3616d, function ($spf34e1a, $sp246f65, $sp9db197) use($spba756f, $sp591089, &$sp5fcd9d) { $sp5fcd9d = $spf34e1a; try { \Log::debug($sp591089 . " shipOrder start, order_no: {$spf34e1a}, amount: {$sp246f65}, trade_no: {$sp9db197}"); $this->shipOrder($spba756f, $spf34e1a, $sp246f65, $sp9db197); \Log::debug($sp591089 . ' shipOrder end, order_no: ' . $spf34e1a); } catch (\Exception $sp6a7295) { \Log::error($sp591089 . ' shipOrder Exception: ' . $sp6a7295->getMessage()); } })) { \Log::debug($sp591089 . ' verify finished: 1' . ' -'); if ($spa27895->ajax()) { return self::renderResultPage($spa27895, array('success' => 1, 'data' => '/pay/result/' . $spe3eeee)); } else { return redirect('/pay/result/' . $spe3eeee); } } else { \Log::debug($sp860109 . ' verify finished: 0' . ' +'); if ($spba756f->ajax()) { return self::renderResultPage($spba756f, array('success' => 1, 'data' => '/pay/result/' . $sp5fcd9d)); } else { return redirect('/pay/result/' . $sp5fcd9d); } } else { \Log::debug($sp591089 . ' verify finished: 0' . ' -'); return $this->renderResultPage($spa27895, array('success' => 0, 'msg' => '支付验证失败,您可以稍后查看支付状态。')); } } function payNotify(Request $spa27895, $sp70c8c8) { $sp860109 = 'payNotify pay_id: ' . $sp70c8c8; \Log::debug($sp860109); $sp460280 = \App\Pay::where('id', $sp70c8c8)->first(); if (!$sp460280) { \Log::error($sp860109 . ' cannot find PayModel'); echo 'fail'; die; } $sp860109 .= ',' . $sp460280->driver; try { $this->payApi = GatewayPay::getDriver($sp460280->id, $sp460280->driver); } catch (\Exception $sp45f5f1) { \Log::error($sp860109 . ' cannot find Driver: ' . $sp45f5f1->getMessage()); echo 'fail'; die; } $spfd6e52 = json_decode($sp460280->config, true); $spfd6e52['payway'] = $sp460280->way; $spfd6e52['isNotify'] = true; \Log::debug($sp860109 . ' will verify'); $sp786169 = $this->payApi->verify($spfd6e52, function ($sp0dbaa3, $spa468fd, $sp002509) use($spa27895, $sp860109) { try { \Log::debug($sp860109 . " shipOrder start, order_no: {$sp0dbaa3}, amount: {$spa468fd}, trade_no: {$sp002509}"); $this->shipOrder($spa27895, $sp0dbaa3, $spa468fd, $sp002509); \Log::debug($sp860109 . ' shipOrder end, order_no: ' . $sp0dbaa3); } catch (\Exception $sp45f5f1) { \Log::error($sp860109 . ' shipOrder Exception: ' . $sp45f5f1->getMessage()); } }); \Log::debug($sp860109 . ' notify finished: ' . (int) $sp786169 . ' +'); return $this->renderResultPage($spba756f, array('success' => 0, 'msg' => '支付验证失败,您可以稍后查看支付状态。')); } } function payNotify(Request $spba756f, $sp8e6264) { $sp591089 = 'payNotify pay_id: ' . $sp8e6264; \Log::debug($sp591089); $sp6485f6 = \App\Pay::where('id', $sp8e6264)->first(); if (!$sp6485f6) { \Log::error($sp591089 . ' cannot find PayModel'); echo 'fail'; die; } $sp591089 .= ',' . $sp6485f6->driver; try { $this->payApi = GatewayPay::getDriver($sp6485f6); } catch (\Exception $sp6a7295) { \Log::error($sp591089 . ' cannot find Driver: ' . $sp6a7295->getMessage()); echo 'fail'; die; } $spf3616d = json_decode($sp6485f6->config, true); $spf3616d['payway'] = $sp6485f6->way; $spf3616d['isNotify'] = true; \Log::debug($sp591089 . ' will verify'); $sp5359c9 = $this->payApi->verify($spf3616d, function ($spf34e1a, $sp246f65, $sp9db197) use($spba756f, $sp591089) { try { \Log::debug($sp591089 . " shipOrder start, order_no: {$spf34e1a}, amount: {$sp246f65}, trade_no: {$sp9db197}"); $this->shipOrder($spba756f, $spf34e1a, $sp246f65, $sp9db197); \Log::debug($sp591089 . ' shipOrder end, order_no: ' . $spf34e1a); } catch (\Exception $sp6a7295) { \Log::error($sp591089 . ' shipOrder Exception: ' . $sp6a7295->getMessage()); } }); \Log::debug($sp591089 . ' notify finished: ' . (int) $sp5359c9 . ' -'); die; } function result(Request $spa27895, $sp0dbaa3) { $sp7b2cfc = \App\Order::where('order_no', $sp0dbaa3)->first(); if ($sp7b2cfc == null) { return self::renderResultPage($spa27895, array('msg' => '订单未找到,请重试')); } if ($sp7b2cfc->status === \App\Order::STATUS_PAID) { $speb4458 = $sp7b2cfc->user->qq; if ($sp7b2cfc->product->delivery === \App\Product::DELIVERY_MANUAL) { $spa9bccc = '您购买的为手动充值商品,请耐心等待处理'; } else { $spa9bccc = '商家库存不足,因此没有自动发货,请联系商家客服发货'; } if ($speb4458) { $spa9bccc .= '
客服QQ:' . $speb4458 . ''; } return self::renderResultPage($spa27895, array('success' => false, 'title' => '订单已支付', 'msg' => $spa9bccc), array('order' => $sp7b2cfc)); } elseif ($sp7b2cfc->status === \App\Order::STATUS_SUCCESS) { return self::showOrderResult($spa27895, $sp7b2cfc); } return self::renderResultPage($spa27895, array('success' => false, 'msg' => $sp7b2cfc->remark ? '失败原因:
' . $sp7b2cfc->remark : '订单支付失败,请重试'), array('order' => $sp7b2cfc)); } function renderResultPage(Request $spa27895, $sp0cbff8, $sp1d26e1 = array()) { if ($spa27895->ajax()) { if (@$sp0cbff8['success']) { return Response::success($sp0cbff8['data']); } else { return Response::fail('error', $sp0cbff8['msg']); } } else { return view('pay.result', array_merge(array('result' => $sp0cbff8, 'data' => $sp1d26e1), $sp1d26e1)); } } function shipOrder($spa27895, $sp0dbaa3, $spa468fd, $sp002509) { $sp7b2cfc = \App\Order::whereOrderNo($sp0dbaa3)->first(); if ($sp7b2cfc === null) { \Log::error('shipOrder: No query results for model [App\\Order:' . $sp0dbaa3 . ',trade_no:' . $sp002509 . ',amount:' . $spa468fd . ']. die(\'success\');'); die('success'); } if ($sp7b2cfc->paid > $spa468fd) { \Log::alert('shipOrder, price may error, order_no:' . $sp0dbaa3 . ', paid:' . $sp7b2cfc->paid . ', $amount get:' . $spa468fd); $sp7b2cfc->remark = '支付金额(' . sprintf('%0.2f', $spa468fd / 100) . ') 小于 订单金额(' . sprintf('%0.2f', $sp7b2cfc->paid / 100) . ')'; $sp7b2cfc->save(); throw new \Exception($sp7b2cfc->remark); } $sp1a3ec5 = null; if ($sp7b2cfc->status === \App\Order::STATUS_UNPAY) { Log::debug('shipOrder.first_process:' . $sp0dbaa3); if (FundHelper::orderSuccess($sp7b2cfc->id, function ($sp358313) use($sp002509, &$sp7b2cfc, &$sp1a3ec5) { $sp7b2cfc = $sp358313; if ($sp7b2cfc->status !== \App\Order::STATUS_UNPAY) { \Log::debug('Shop.Pay.shipOrder: .first_process:' . $sp7b2cfc->order_no . ' already processed! #2'); return false; } $sp1a3ec5 = $sp7b2cfc->product()->lockForUpdate()->firstOrFail(); $sp7b2cfc->pay_trade_no = $sp002509; $sp7b2cfc->paid_at = Carbon::now(); if ($sp1a3ec5->delivery === \App\Product::DELIVERY_MANUAL) { $sp7b2cfc->status = \App\Order::STATUS_PAID; $sp7b2cfc->send_status = \App\Order::SEND_STATUS_CARD_UN; $sp7b2cfc->saveOrFail(); return true; } if ($sp1a3ec5->delivery === \App\Product::DELIVERY_API) { $sp16ec83 = $sp1a3ec5->createApiCards($sp7b2cfc); } else { $sp16ec83 = Card::where('product_id', $sp1a3ec5->retail_root->id)->whereRaw('`count_sold`<`count_all`')->take($sp7b2cfc->count)->lockForUpdate()->get(); } $spe810a6 = false; if (count($sp16ec83) === $sp7b2cfc->count) { $spe810a6 = true; } else { $spe810a6 = false; if (count($sp16ec83)) { foreach ($sp16ec83 as $sp089eb8) { if ($sp089eb8->type === \App\Card::TYPE_REPEAT && $sp089eb8->count >= $sp7b2cfc->count) { $sp16ec83 = array($sp089eb8); $spe810a6 = true; break; } } } } if ($spe810a6 === false) { Log::alert('Shop.Pay.shipOrder: 订单:' . $sp7b2cfc->order_no . ', 购买数量:' . $sp7b2cfc->count . ', 卡数量:' . count($sp16ec83) . ' 卡密不足(已支付 未发货)'); $sp7b2cfc->status = \App\Order::STATUS_PAID; $sp7b2cfc->saveOrFail(); return true; } else { $sp5be395 = array(); foreach ($sp16ec83 as $sp089eb8) { $sp5be395[] = $sp089eb8->id; } $sp7b2cfc->cards()->attach($sp5be395); if (count($sp16ec83) === 1 && $sp16ec83[0]->type === \App\Card::TYPE_REPEAT) { \App\Card::where('id', $sp5be395[0])->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+' . $sp7b2cfc->count))); } else { \App\Card::whereIn('id', $sp5be395)->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+1'))); } $sp7b2cfc->status = \App\Order::STATUS_SUCCESS; $sp7b2cfc->saveOrFail(); $sp1a3ec5->count_sold += $sp7b2cfc->count; $sp1a3ec5->saveOrFail(); return FundHelper::ACTION_CONTINUE; } })) { if ($sp1a3ec5->count_warn > 0 && $sp1a3ec5->count < $sp1a3ec5->count_warn) { try { Mail::to($sp7b2cfc->user->email)->Queue(new ProductCountWarn($sp1a3ec5, $sp1a3ec5->count)); } catch (\Throwable $sp45f5f1) { LogHelper::setLogFile('mail'); Log::error('shipOrder.count_warn error', array('product_id' => $sp7b2cfc->product_id, 'email' => $sp7b2cfc->user->email, 'exception' => $sp45f5f1->getMessage())); LogHelper::setLogFile('card'); } } if (System::_getInt('mail_send_order')) { $sp98ce8d = @json_decode($sp7b2cfc->contact_ext, true)['_mail']; if ($sp98ce8d) { $sp7b2cfc->sendEmail($sp98ce8d); } } if ($sp7b2cfc->status === \App\Order::STATUS_SUCCESS && System::_getInt('sms_send_order')) { $spd9b726 = @json_decode($sp7b2cfc->contact_ext, true)['_mobile']; if ($spd9b726) { $sp7b2cfc->sendSms($spd9b726); } } } else { } } else { Log::debug('Shop.Pay.shipOrder: .order_no:' . $sp7b2cfc->order_no . ' already processed! #1'); } return FALSE; } private function showOrderResult($spa27895, $sp7b2cfc) { return self::renderResultPage($spa27895, array('success' => true, 'msg' => $sp7b2cfc->getSendMessage()), array('card_txt' => join(' ', $sp7b2cfc->getCardsArray()), 'order' => $sp7b2cfc, 'product' => $sp7b2cfc->product)); } } \ No newline at end of file +'); die; } function result(Request $spba756f, $spf34e1a) { $spedec71 = \App\Order::where('order_no', $spf34e1a)->first(); if ($spedec71 == null) { return self::renderResultPage($spba756f, array('msg' => '订单未找到,请重试')); } if ($spedec71->status === \App\Order::STATUS_PAID) { $sp19dce7 = $spedec71->user->qq; if ($spedec71->product->delivery === \App\Product::DELIVERY_MANUAL) { $spa24442 = '您购买的为手动充值商品,请耐心等待处理'; } else { $spa24442 = '商家库存不足,因此没有自动发货,请联系商家客服发货'; } if ($sp19dce7) { $spa24442 .= '
客服QQ:' . $sp19dce7 . ''; } return self::renderResultPage($spba756f, array('success' => false, 'title' => '订单已支付', 'msg' => $spa24442), array('order' => $spedec71)); } elseif ($spedec71->status === \App\Order::STATUS_SUCCESS) { return self::showOrderResult($spba756f, $spedec71); } return self::renderResultPage($spba756f, array('success' => false, 'msg' => $spedec71->remark ? '失败原因:
' . $spedec71->remark : '订单支付失败,请重试'), array('order' => $spedec71)); } function renderResultPage(Request $spba756f, $spe6807d, $spe99d4c = array()) { if ($spba756f->ajax()) { if (@$spe6807d['success']) { return Response::success($spe6807d['data']); } else { return Response::fail('error', $spe6807d['msg']); } } else { return view('pay.result', array_merge(array('result' => $spe6807d, 'data' => $spe99d4c), $spe99d4c)); } } function shipOrder($spba756f, $spf34e1a, $sp246f65, $sp9db197) { $spedec71 = \App\Order::whereOrderNo($spf34e1a)->first(); if ($spedec71 === null) { \Log::error('shipOrder: No query results for model [App\\Order:' . $spf34e1a . ',trade_no:' . $sp9db197 . ',amount:' . $sp246f65 . ']. die(\'success\');'); die('success'); } if ($spedec71->paid > $sp246f65) { \Log::alert('shipOrder, price may error, order_no:' . $spf34e1a . ', paid:' . $spedec71->paid . ', $amount get:' . $sp246f65); $spedec71->remark = '支付金额(' . sprintf('%0.2f', $sp246f65 / 100) . ') 小于 订单金额(' . sprintf('%0.2f', $spedec71->paid / 100) . ')'; $spedec71->save(); throw new \Exception($spedec71->remark); } $sp9dfc99 = null; if ($spedec71->status === \App\Order::STATUS_UNPAY) { Log::debug('shipOrder.first_process:' . $spf34e1a); if (FundHelper::orderSuccess($spedec71->id, function ($sp88aec6) use($sp9db197, &$spedec71, &$sp9dfc99) { $spedec71 = $sp88aec6; if ($spedec71->status !== \App\Order::STATUS_UNPAY) { \Log::debug('Shop.Pay.shipOrder: .first_process:' . $spedec71->order_no . ' already processed! #2'); return false; } $sp9dfc99 = $spedec71->product()->lockForUpdate()->firstOrFail(); $spedec71->pay_trade_no = $sp9db197; $spedec71->paid_at = Carbon::now(); if ($sp9dfc99->delivery === \App\Product::DELIVERY_MANUAL) { $spedec71->status = \App\Order::STATUS_PAID; $spedec71->send_status = \App\Order::SEND_STATUS_CARD_UN; $spedec71->saveOrFail(); return true; } if ($sp9dfc99->delivery === \App\Product::DELIVERY_API) { $sp137cd7 = $sp9dfc99->createApiCards($spedec71); } else { $sp137cd7 = Card::where('product_id', $sp9dfc99->retail_root->id)->whereRaw('`count_sold`<`count_all`')->take($spedec71->count)->lockForUpdate()->get(); } $spe97000 = false; if (count($sp137cd7) === $spedec71->count) { $spe97000 = true; } else { $spe97000 = false; if (count($sp137cd7)) { foreach ($sp137cd7 as $spa9cef2) { if ($spa9cef2->type === \App\Card::TYPE_REPEAT && $spa9cef2->count >= $spedec71->count) { $sp137cd7 = array($spa9cef2); $spe97000 = true; break; } } } } if ($spe97000 === false) { Log::alert('Shop.Pay.shipOrder: 订单:' . $spedec71->order_no . ', 购买数量:' . $spedec71->count . ', 卡数量:' . count($sp137cd7) . ' 卡密不足(已支付 未发货)'); $spedec71->status = \App\Order::STATUS_PAID; $spedec71->saveOrFail(); return true; } else { $speccfba = array(); foreach ($sp137cd7 as $spa9cef2) { $speccfba[] = $spa9cef2->id; } $spedec71->cards()->attach($speccfba); if (count($sp137cd7) === 1 && $sp137cd7[0]->type === \App\Card::TYPE_REPEAT) { \App\Card::where('id', $speccfba[0])->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+' . $spedec71->count))); } else { \App\Card::whereIn('id', $speccfba)->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+1'))); } $spedec71->status = \App\Order::STATUS_SUCCESS; $spedec71->saveOrFail(); $sp9dfc99->count_sold += $spedec71->count; $sp9dfc99->saveOrFail(); return FundHelper::ACTION_CONTINUE; } })) { if ($sp9dfc99->count_warn > 0 && $sp9dfc99->count < $sp9dfc99->count_warn) { try { Mail::to($spedec71->user->email)->Queue(new ProductCountWarn($sp9dfc99, $sp9dfc99->count)); } catch (\Throwable $sp6a7295) { LogHelper::setLogFile('mail'); Log::error('shipOrder.count_warn error', array('product_id' => $spedec71->product_id, 'email' => $spedec71->user->email, 'exception' => $sp6a7295->getMessage())); LogHelper::setLogFile('card'); } } if (System::_getInt('mail_send_order')) { $spdf69a9 = @json_decode($spedec71->contact_ext, true)['_mail']; if ($spdf69a9) { $spedec71->sendEmail($spdf69a9); } } if ($spedec71->status === \App\Order::STATUS_SUCCESS && System::_getInt('sms_send_order')) { $spcd62a5 = @json_decode($spedec71->contact_ext, true)['_mobile']; if ($spcd62a5) { $spedec71->sendSms($spcd62a5); } } } else { } } else { Log::debug('Shop.Pay.shipOrder: .order_no:' . $spedec71->order_no . ' already processed! #1'); } return FALSE; } private function showOrderResult($spba756f, $spedec71) { return self::renderResultPage($spba756f, array('success' => true, 'msg' => $spedec71->getSendMessage()), array('card_txt' => join(' ', $spedec71->getCardsArray()), 'order' => $spedec71, 'product' => $spedec71->product)); } } \ No newline at end of file diff --git a/app/Http/Controllers/Shop/Product.php b/app/Http/Controllers/Shop/Product.php index d53d45ed1..cda3012f8 100644 --- a/app/Http/Controllers/Shop/Product.php +++ b/app/Http/Controllers/Shop/Product.php @@ -1,2 +1,2 @@ post('category_id'); if (!$sp980f44) { return Response::forbidden('请选择商品分类'); } $spd14ca3 = \App\Category::where('id', $sp980f44)->first(); if (!$spd14ca3) { return Response::forbidden('商品分类未找到'); } if ($spd14ca3->password_open && $spa27895->post('password') !== $spd14ca3->password) { return Response::fail('分类密码输入错误'); } $sp8fefde = \App\Product::where('category_id', $sp980f44)->where('enabled', 1)->orderBy('sort')->get(); foreach ($sp8fefde as $sp1a3ec5) { $sp1a3ec5->setForShop(); } return Response::success($sp8fefde); } function verifyPassword(Request $spa27895) { $sp112a12 = (int) $spa27895->post('product_id'); if (!$sp112a12) { return Response::forbidden('请选择商品'); } $sp1a3ec5 = \App\Product::where('id', $sp112a12)->first(); if (!$sp1a3ec5) { return Response::forbidden('商品未找到'); } if ($sp1a3ec5->password_open && $spa27895->post('password') !== $sp1a3ec5->password) { return Response::fail('商品密码输入错误'); } return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Shop; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Library\Response; class Product extends Controller { function get(Request $spba756f) { $sp55f32c = (int) $spba756f->post('category_id'); if (!$sp55f32c) { return Response::forbidden('请选择商品分类'); } $sp1cd1e4 = \App\Category::where('id', $sp55f32c)->first(); if (!$sp1cd1e4) { return Response::forbidden('商品分类未找到'); } if ($sp1cd1e4->password_open && $spba756f->post('password') !== $sp1cd1e4->password) { return Response::fail('分类密码输入错误'); } $spde3992 = \App\Product::where('category_id', $sp55f32c)->where('enabled', 1)->orderBy('sort')->get(); foreach ($spde3992 as $sp9dfc99) { $sp9dfc99->setForShop(); } return Response::success($spde3992); } function verifyPassword(Request $spba756f) { $sp1b83a8 = (int) $spba756f->post('product_id'); if (!$sp1b83a8) { return Response::forbidden('请选择商品'); } $sp9dfc99 = \App\Product::where('id', $sp1b83a8)->first(); if (!$sp9dfc99) { return Response::forbidden('商品未找到'); } if ($sp9dfc99->password_open && $spba756f->post('password') !== $sp9dfc99->password) { return Response::fail('商品密码输入错误'); } return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Shop/VerifyCode.php b/app/Http/Controllers/Shop/VerifyCode.php index 7ec596ed8..709fd7e1d 100644 --- a/app/Http/Controllers/Shop/VerifyCode.php +++ b/app/Http/Controllers/Shop/VerifyCode.php @@ -1,2 +1,2 @@ 'geetest', 'geetest' => Geetest\API::get()); return Response::success($sp6bda17); } } \ No newline at end of file +namespace App\Http\Controllers\Shop; use App\Library\Response; use App\Library\Geetest; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class VerifyCode extends Controller { function getVerify() { $spe9df6d = array('driver' => 'geetest', 'geetest' => Geetest\API::get()); return Response::success($spe9df6d); } } \ No newline at end of file diff --git a/app/Http/Middleware/CORS.php b/app/Http/Middleware/CORS.php index 44159e62b..6d70e4778 100644 --- a/app/Http/Middleware/CORS.php +++ b/app/Http/Middleware/CORS.php @@ -1,2 +1,2 @@ $spa27895->header('Origin'), 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE', 'Access-Control-Allow-Headers' => 'Content-Type, Accept, Authorization, Cookie, X-Requested-With, X-XSRF-TOKEN', 'Access-Control-Allow-Credentials' => 'true'); if ($spa27895->isMethod('OPTIONS')) { return response()->make('', 200, $sp697dbb); } $spf16c1a = $sp5a8deb($spa27895); foreach ($sp697dbb as $sp0d678a => $sp1b5dd9) { $spf16c1a->headers->set($sp0d678a, $sp1b5dd9); } return $spf16c1a; } return $sp5a8deb($spa27895); } } \ No newline at end of file +namespace App\Http\Middleware; use Closure; class CORS { public function handle($spba756f, Closure $spb59aac) { if (config('app.debug')) { $sp3e89cf = array('Access-Control-Allow-Origin' => $spba756f->header('Origin'), 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE', 'Access-Control-Allow-Headers' => 'Content-Type, Accept, Authorization, Cookie, X-Requested-With, X-XSRF-TOKEN', 'Access-Control-Allow-Credentials' => 'true'); if ($spba756f->isMethod('OPTIONS')) { return response()->make('', 200, $sp3e89cf); } $spb9364a = $spb59aac($spba756f); foreach ($sp3e89cf as $sp4450cf => $sp4a2047) { $spb9364a->headers->set($sp4450cf, $sp4a2047); } return $spb9364a; } return $spb59aac($spba756f); } } \ No newline at end of file diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 4f771b45c..8779d6c73 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -1,2 +1,2 @@ check()) { return redirect('/home'); } return $sp5a8deb($spa27895); } } \ No newline at end of file +namespace App\Http\Middleware; use Closure; use Illuminate\Support\Facades\Auth; class RedirectIfAuthenticated { public function handle($spba756f, Closure $spb59aac, $sp922c15 = null) { if (Auth::guard($sp922c15)->check()) { return redirect('/home'); } return $spb59aac($spba756f); } } \ No newline at end of file diff --git a/app/Jobs/OrderSms.php b/app/Jobs/OrderSms.php index da0ff1efc..a5804b43d 100644 --- a/app/Jobs/OrderSms.php +++ b/app/Jobs/OrderSms.php @@ -1,2 +1,2 @@ mobile = $spd9b726; $this->order = $sp7b2cfc; } public function handle() { CurlRequest::post('https://api.his.cat/api/sms/send', http_build_query(array('id' => System::_get('sms_api_id'), 'key' => System::_get('sms_api_key'), 'to' => $this->mobile, 'msg' => config('app.url') . '/pay/result/' . $this->order->order_no))); } } \ No newline at end of file +namespace App\Jobs; use App\Library\CurlRequest; use App\System; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; class OrderSms implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; private $mobile = null; private $order = null; public function __construct($spcd62a5, $spedec71) { $this->mobile = $spcd62a5; $this->order = $spedec71; } public function handle() { CurlRequest::post('https://api.his.cat/api/sms/send', http_build_query(array('id' => System::_get('sms_api_id'), 'key' => System::_get('sms_api_key'), 'to' => $this->mobile, 'msg' => config('app.url') . '/pay/result/' . $this->order->order_no))); } } \ No newline at end of file diff --git a/app/Library/CurlRequest.php b/app/Library/CurlRequest.php index ecb1467e3..e38a3b698 100644 --- a/app/Library/CurlRequest.php +++ b/app/Library/CurlRequest.php @@ -1,3 +1,3 @@ $sp2aacb2) { $sp330405[] = $sp665b4f . ': ' . $sp2aacb2; } $sp330405[] = 'Expect:'; $spa9fd67 = curl_init(); curl_setopt($spa9fd67, CURLOPT_URL, $spddf3f5); curl_setopt($spa9fd67, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($spa9fd67, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($spa9fd67, CURLOPT_FOLLOWLOCATION, true); curl_setopt($spa9fd67, CURLOPT_MAXREDIRS, 3); if ($sp701759 == 1) { curl_setopt($spa9fd67, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($spa9fd67, CURLOPT_POST, 1); if ($spa99fc2 !== '') { curl_setopt($spa9fd67, CURLOPT_POSTFIELDS, $spa99fc2); curl_setopt($spa9fd67, CURLOPT_POSTREDIR, 3); } } if (defined('MY_PROXY')) { $sp554d3f = MY_PROXY; $sp0e1f77 = CURLPROXY_HTTP; if (strpos($sp554d3f, 'http://') || strpos($sp554d3f, 'https://')) { $sp554d3f = str_replace('http://', $sp554d3f, $sp554d3f); $sp554d3f = str_replace('https://', $sp554d3f, $sp554d3f); $sp0e1f77 = CURLPROXY_HTTP; } elseif (strpos($sp554d3f, 'socks4://')) { $sp554d3f = str_replace('socks4://', $sp554d3f, $sp554d3f); $sp0e1f77 = CURLPROXY_SOCKS4; } elseif (strpos($sp554d3f, 'socks4a://')) { $sp554d3f = str_replace('socks4a://', $sp554d3f, $sp554d3f); $sp0e1f77 = CURLPROXY_SOCKS4A; } elseif (strpos($sp554d3f, 'socks5://')) { $sp554d3f = str_replace('socks5://', $sp554d3f, $sp554d3f); $sp0e1f77 = CURLPROXY_SOCKS5_HOSTNAME; } curl_setopt($spa9fd67, CURLOPT_PROXY, $sp554d3f); curl_setopt($spa9fd67, CURLOPT_PROXYTYPE, $sp0e1f77); if (defined('MY_PROXY_PASS')) { curl_setopt($spa9fd67, CURLOPT_PROXYUSERPWD, MY_PROXY_PASS); } } curl_setopt($spa9fd67, CURLOPT_TIMEOUT, $spb43dc2); curl_setopt($spa9fd67, CURLOPT_CONNECTTIMEOUT, $spb43dc2); curl_setopt($spa9fd67, CURLOPT_RETURNTRANSFER, 1); curl_setopt($spa9fd67, CURLOPT_HEADER, 1); curl_setopt($spa9fd67, CURLOPT_HTTPHEADER, $sp330405); $spf16c1a = curl_exec($spa9fd67); $sp69396e = curl_getinfo($spa9fd67, CURLINFO_HEADER_SIZE); $sp24d031 = substr($spf16c1a, 0, $sp69396e); $sp7337bd = substr($spf16c1a, $sp69396e); curl_close($spa9fd67); if ($sp620f5b !== false) { $sp697dbb = explode(' -', $sp24d031); $sp78c6a2 = ''; foreach ($sp697dbb as $sp24d031) { if (strpos($sp24d031, 'Set-Cookie') !== false) { if (strpos($sp24d031, ';') !== false) { $sp78c6a2 = $sp78c6a2 . trim(Helper::str_between($sp24d031, 'Set-Cookie:', ';')) . ';'; } else { $sp78c6a2 = $sp78c6a2 . trim(str_replace('Set-Cookie:', '', $sp24d031)) . ';'; } } } $sp620f5b = self::combineCookie($sp620f5b, $sp78c6a2); } return $sp7337bd; } public static function get($spddf3f5, $sp697dbb = array(), $spb43dc2 = 5, &$sp620f5b = false) { return self::curl($spddf3f5, 0, '', $sp697dbb, $spb43dc2, $sp620f5b); } public static function post($spddf3f5, $spa99fc2 = '', $sp697dbb = array(), $spb43dc2 = 5, &$sp620f5b = false) { return self::curl($spddf3f5, 1, $spa99fc2, $sp697dbb, $spb43dc2, $sp620f5b); } public static function combineCookie($sp5fd1b4, $sp49fe0d) { $spf6089a = explode(';', $sp5fd1b4); $sp20f4af = explode(';', $sp49fe0d); foreach ($spf6089a as $sp8723dc) { if (self::cookieIsExists($sp20f4af, self::cookieGetName($sp8723dc)) == false) { array_push($sp20f4af, $sp8723dc); } } $sp31cad8 = ''; foreach ($sp20f4af as $sp8723dc) { if (substr($sp8723dc, -8, 8) != '=deleted' && strlen($sp8723dc) > 1) { $sp31cad8 .= $sp8723dc . '; '; } } return substr($sp31cad8, 0, strlen($sp31cad8) - 2); } public static function cookieGetName($sp1e61a3) { $spf5edea = strpos($sp1e61a3, '='); return substr($sp1e61a3, 0, $spf5edea); } public static function cookieGetValue($sp1e61a3) { $spf5edea = strpos($sp1e61a3, '='); $spa846c8 = substr($sp1e61a3, $spf5edea + 1, strlen($sp1e61a3) - $spf5edea); return $spa846c8; } public static function cookieGet($sp620f5b, $sp104c39, $sp98ec33 = false) { $sp620f5b = str_replace(' ', '', $sp620f5b); if (substr($sp620f5b, -1, 1) != ';') { $sp620f5b = ';' . $sp620f5b . ';'; } else { $sp620f5b = ';' . $sp620f5b; } $spda03ca = Helper::str_between($sp620f5b, ';' . $sp104c39 . '=', ';'); if (!$sp98ec33 || $spda03ca == '') { return $spda03ca; } else { return $sp104c39 . '=' . $spda03ca; } } private static function cookieIsExists($spd64748, $sp572747) { foreach ($spd64748 as $sp8723dc) { if (self::cookieGetName($sp8723dc) == $sp572747) { return true; } } return false; } function test() { $spa846c8 = self::combineCookie('a=1;b=2;c=3', 'c=5'); var_dump($spa846c8); } } \ No newline at end of file +namespace App\Library; use Illuminate\Support\Facades\Log; class CurlRequest { private static function curl($sp0784c1, $sp75c26f = 0, $spefc554 = '', $sp3e89cf = array(), $sp47c3be = 5, &$speed4bf = false) { if (!isset($sp3e89cf['Accept'])) { $sp3e89cf['Accept'] = '*/*'; } if (!isset($sp3e89cf['Referer'])) { $sp3e89cf['Referer'] = $sp0784c1; } if (!isset($sp3e89cf['Content-Type'])) { $sp3e89cf['Content-Type'] = 'application/x-www-form-urlencoded'; } if (!isset($sp3e89cf['User-Agent'])) { $sp3e89cf['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'; } if ($speed4bf !== false) { $sp3e89cf['Cookie'] = $speed4bf; } $sp195769 = array(); foreach ($sp3e89cf as $sp5253dc => $sp1db901) { $sp195769[] = $sp5253dc . ': ' . $sp1db901; } $sp195769[] = 'Expect:'; $spf86e31 = curl_init(); curl_setopt($spf86e31, CURLOPT_URL, $sp0784c1); curl_setopt($spf86e31, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($spf86e31, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($spf86e31, CURLOPT_FOLLOWLOCATION, true); curl_setopt($spf86e31, CURLOPT_MAXREDIRS, 3); if ($sp75c26f == 1) { curl_setopt($spf86e31, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($spf86e31, CURLOPT_POST, 1); if ($spefc554 !== '') { curl_setopt($spf86e31, CURLOPT_POSTFIELDS, $spefc554); curl_setopt($spf86e31, CURLOPT_POSTREDIR, 3); } } if (defined('MY_PROXY')) { $spee5a33 = MY_PROXY; $sp1437c3 = CURLPROXY_HTTP; if (strpos($spee5a33, 'http://') || strpos($spee5a33, 'https://')) { $spee5a33 = str_replace('http://', $spee5a33, $spee5a33); $spee5a33 = str_replace('https://', $spee5a33, $spee5a33); $sp1437c3 = CURLPROXY_HTTP; } elseif (strpos($spee5a33, 'socks4://')) { $spee5a33 = str_replace('socks4://', $spee5a33, $spee5a33); $sp1437c3 = CURLPROXY_SOCKS4; } elseif (strpos($spee5a33, 'socks4a://')) { $spee5a33 = str_replace('socks4a://', $spee5a33, $spee5a33); $sp1437c3 = CURLPROXY_SOCKS4A; } elseif (strpos($spee5a33, 'socks5://')) { $spee5a33 = str_replace('socks5://', $spee5a33, $spee5a33); $sp1437c3 = CURLPROXY_SOCKS5_HOSTNAME; } curl_setopt($spf86e31, CURLOPT_PROXY, $spee5a33); curl_setopt($spf86e31, CURLOPT_PROXYTYPE, $sp1437c3); if (defined('MY_PROXY_PASS')) { curl_setopt($spf86e31, CURLOPT_PROXYUSERPWD, MY_PROXY_PASS); } } curl_setopt($spf86e31, CURLOPT_TIMEOUT, $sp47c3be); curl_setopt($spf86e31, CURLOPT_CONNECTTIMEOUT, $sp47c3be); curl_setopt($spf86e31, CURLOPT_RETURNTRANSFER, 1); curl_setopt($spf86e31, CURLOPT_HEADER, 1); curl_setopt($spf86e31, CURLOPT_HTTPHEADER, $sp195769); $spb9364a = curl_exec($spf86e31); $sp7501e7 = curl_getinfo($spf86e31, CURLINFO_HEADER_SIZE); $sp5a4bfe = substr($spb9364a, 0, $sp7501e7); $spe007d4 = substr($spb9364a, $sp7501e7); curl_close($spf86e31); if ($speed4bf !== false) { $sp3e89cf = explode(' +', $sp5a4bfe); $spc07e85 = ''; foreach ($sp3e89cf as $sp5a4bfe) { if (strpos($sp5a4bfe, 'Set-Cookie') !== false) { if (strpos($sp5a4bfe, ';') !== false) { $spc07e85 = $spc07e85 . trim(Helper::str_between($sp5a4bfe, 'Set-Cookie:', ';')) . ';'; } else { $spc07e85 = $spc07e85 . trim(str_replace('Set-Cookie:', '', $sp5a4bfe)) . ';'; } } } $speed4bf = self::combineCookie($speed4bf, $spc07e85); } return $spe007d4; } public static function get($sp0784c1, $sp3e89cf = array(), $sp47c3be = 5, &$speed4bf = false) { return self::curl($sp0784c1, 0, '', $sp3e89cf, $sp47c3be, $speed4bf); } public static function post($sp0784c1, $spefc554 = '', $sp3e89cf = array(), $sp47c3be = 5, &$speed4bf = false) { return self::curl($sp0784c1, 1, $spefc554, $sp3e89cf, $sp47c3be, $speed4bf); } public static function combineCookie($sp31e536, $spb12e25) { $sp74ee5e = explode(';', $sp31e536); $sp8925e2 = explode(';', $spb12e25); foreach ($sp74ee5e as $sp738483) { if (self::cookieIsExists($sp8925e2, self::cookieGetName($sp738483)) == false) { array_push($sp8925e2, $sp738483); } } $spc7f0e3 = ''; foreach ($sp8925e2 as $sp738483) { if (substr($sp738483, -8, 8) != '=deleted' && strlen($sp738483) > 1) { $spc7f0e3 .= $sp738483 . '; '; } } return substr($spc7f0e3, 0, strlen($spc7f0e3) - 2); } public static function cookieGetName($spfe3049) { $spc977ba = strpos($spfe3049, '='); return substr($spfe3049, 0, $spc977ba); } public static function cookieGetValue($spfe3049) { $spc977ba = strpos($spfe3049, '='); $sp13c12f = substr($spfe3049, $spc977ba + 1, strlen($spfe3049) - $spc977ba); return $sp13c12f; } public static function cookieGet($speed4bf, $sp387f04, $sp430a40 = false) { $speed4bf = str_replace(' ', '', $speed4bf); if (substr($speed4bf, -1, 1) != ';') { $speed4bf = ';' . $speed4bf . ';'; } else { $speed4bf = ';' . $speed4bf; } $spf97afb = Helper::str_between($speed4bf, ';' . $sp387f04 . '=', ';'); if (!$sp430a40 || $spf97afb == '') { return $spf97afb; } else { return $sp387f04 . '=' . $spf97afb; } } private static function cookieIsExists($sp79e36e, $spe9e840) { foreach ($sp79e36e as $sp738483) { if (self::cookieGetName($sp738483) == $spe9e840) { return true; } } return false; } function test() { $sp13c12f = self::combineCookie('a=1;b=2;c=3', 'c=5'); var_dump($sp13c12f); } } \ No newline at end of file diff --git a/app/Library/FundHelper.php b/app/Library/FundHelper.php index b23e7a4da..946028dde 100644 --- a/app/Library/FundHelper.php +++ b/app/Library/FundHelper.php @@ -1,2 +1,2 @@ lockForUpdate()->firstOrFail(); $sp786169 = $sp483b7b($sp7b2cfc); if ($sp786169 !== self::ACTION_CONTINUE) { return $sp786169; } $sp845283 = User::where('id', $sp7b2cfc->user_id)->lockForUpdate()->firstOrFail(); $sp845283->m_all += $sp7b2cfc->income; $sp845283->saveOrFail(); $sp9c3375 = new FundRecord(); $sp9c3375->user_id = $sp7b2cfc->user_id; $sp9c3375->type = FundRecord::TYPE_IN; $sp9c3375->amount = $sp7b2cfc->income; $sp9c3375->all = $sp845283->m_all; $sp9c3375->frozen = $sp845283->m_frozen; $sp9c3375->paid = $sp845283->m_paid; $sp9c3375->balance = $sp845283->m_balance; $sp9c3375->remark = '订单#' . $sp7b2cfc->order_no; $sp9c3375->order_id = $sp7b2cfc->id; $sp9c3375->saveOrFail(); return true; }); } catch (\Throwable $sp45f5f1) { $spa9bccc = 'FundHelper.orderSuccess error, order_id:' . $sp748f3f; if ($sp7b2cfc) { $spa9bccc .= ', user_id:' . $sp7b2cfc->user_id . ',income:' . $sp7b2cfc->income . ',order_no:' . $sp7b2cfc->order_no; } Log::error($spa9bccc . ' with exception:', array('Exception' => $sp45f5f1)); return false; } } public static function orderFreeze($sp748f3f, $sp01391f) { $sp7b2cfc = null; try { return DB::transaction(function () use($sp748f3f, &$sp7b2cfc, $sp01391f) { $sp7b2cfc = \App\Order::where('id', $sp748f3f)->lockForUpdate()->firstOrFail(); if ($sp7b2cfc->status === Order::STATUS_REFUND) { return false; } if ($sp7b2cfc->status === Order::STATUS_FROZEN) { return true; } $sp3b8d13 = $sp7b2cfc->status; if ($sp3b8d13 === \App\Order::STATUS_SUCCESS) { $spc60774 = '已发货'; } elseif ($sp3b8d13 === \App\Order::STATUS_UNPAY) { $spc60774 = '未付款'; } elseif ($sp3b8d13 === \App\Order::STATUS_PAID) { $spc60774 = '未发货'; } else { throw new \Exception('unknown'); } $sp845283 = User::where('id', $sp7b2cfc->user_id)->lockForUpdate()->firstOrFail(); $sp9c3375 = new FundRecord(); $sp9c3375->user_id = $sp7b2cfc->user_id; $sp9c3375->type = FundRecord::TYPE_OUT; $sp9c3375->order_id = $sp7b2cfc->id; $sp9c3375->remark = $sp7b2cfc === $sp7b2cfc ? '' : '关联订单#' . $sp7b2cfc->order_no . ': '; if ($sp3b8d13 === \App\Order::STATUS_SUCCESS) { $sp845283->m_frozen += $sp7b2cfc->income; $sp845283->saveOrFail(); $sp9c3375->amount = -$sp7b2cfc->income; $sp9c3375->remark .= $sp01391f . ', 冻结订单#' . $sp7b2cfc->order_no; } else { $sp9c3375->amount = 0; $sp9c3375->remark .= $sp01391f . ', 冻结订单(' . $spc60774 . ')#' . $sp7b2cfc->order_no; } $sp9c3375->all = $sp845283->m_all; $sp9c3375->frozen = $sp845283->m_frozen; $sp9c3375->paid = $sp845283->m_paid; $sp9c3375->balance = $sp845283->m_balance; $sp9c3375->saveOrFail(); $sp7b2cfc->status = \App\Order::STATUS_FROZEN; $sp7b2cfc->frozen_reason = ($sp7b2cfc === $sp7b2cfc ? '' : '关联订单#' . $sp7b2cfc->order_no . ': ') . $sp01391f; $sp7b2cfc->saveOrFail(); return true; }); } catch (\Throwable $sp45f5f1) { $spa9bccc = 'FundHelper.orderFreeze error'; if ($sp7b2cfc) { $spa9bccc .= ', order_no:' . $sp7b2cfc->order_no . ', user_id:' . $sp7b2cfc->user_id . ', amount:' . $sp7b2cfc->income; } else { $spa9bccc .= ', order_no: null'; } Log::error($spa9bccc . ' with exception:', array('Exception' => $sp45f5f1)); return false; } } public static function orderUnfreeze($sp748f3f, $sp96e2b0, callable $spbd18af = null, &$sp2fc4dd = null) { $sp7b2cfc = null; try { return DB::transaction(function () use($sp748f3f, &$sp7b2cfc, $sp96e2b0, $spbd18af, &$sp2fc4dd) { $sp7b2cfc = \App\Order::where('id', $sp748f3f)->lockForUpdate()->firstOrFail(); if ($spbd18af !== null) { $sp786169 = $spbd18af(); if ($sp786169 !== self::ACTION_CONTINUE) { return $sp786169; } } if ($sp7b2cfc->status === Order::STATUS_REFUND) { $sp2fc4dd = $sp7b2cfc->status; return false; } if ($sp7b2cfc->status !== Order::STATUS_FROZEN) { $sp2fc4dd = $sp7b2cfc->status; return true; } $spa3de69 = $sp7b2cfc->card_orders()->exists(); if ($spa3de69) { $sp2fc4dd = \App\Order::STATUS_SUCCESS; $spc60774 = '已发货'; } else { if ($sp7b2cfc->paid_at === NULL) { $sp2fc4dd = \App\Order::STATUS_UNPAY; $spc60774 = '未付款'; } else { $sp2fc4dd = \App\Order::STATUS_PAID; $spc60774 = '未发货'; } } $sp845283 = User::where('id', $sp7b2cfc->user_id)->lockForUpdate()->firstOrFail(); $sp9c3375 = new FundRecord(); $sp9c3375->user_id = $sp7b2cfc->user_id; $sp9c3375->type = FundRecord::TYPE_IN; $sp9c3375->remark = $sp7b2cfc === $sp7b2cfc ? '' : '关联订单#' . $sp7b2cfc->order_no . ': '; $sp9c3375->order_id = $sp7b2cfc->id; if ($spa3de69) { $sp845283->m_frozen -= $sp7b2cfc->income; $sp845283->saveOrFail(); $sp9c3375->amount = $sp7b2cfc->income; $sp9c3375->remark .= $sp96e2b0 . ', 解冻订单#' . $sp7b2cfc->order_no; } else { $sp9c3375->amount = 0; $sp9c3375->remark .= $sp96e2b0 . ', 解冻订单(' . $spc60774 . ')#' . $sp7b2cfc->order_no; } $sp9c3375->all = $sp845283->m_all; $sp9c3375->frozen = $sp845283->m_frozen; $sp9c3375->paid = $sp845283->m_paid; $sp9c3375->balance = $sp845283->m_balance; $sp9c3375->saveOrFail(); $sp7b2cfc->status = $sp2fc4dd; $sp7b2cfc->saveOrFail(); return true; }); } catch (\Throwable $sp45f5f1) { $spa9bccc = 'FundHelper.orderUnfreeze error'; if ($sp7b2cfc) { $spa9bccc .= ', order_no:' . $sp7b2cfc->order_no . ', user_id:' . $sp7b2cfc->user_id . ',amount:' . $sp7b2cfc->income; } else { $spa9bccc .= ', order_no: null'; } Log::error($spa9bccc . ' with exception:', array('Exception' => $sp45f5f1)); return false; } } } \ No newline at end of file +namespace App\Library; use App\Order; use App\User; use App\FundRecord; use Illuminate\Support\Facades\DB; class FundHelper { const ACTION_CONTINUE = 1001; public static function orderSuccess($spe5a302, callable $spac2b89) { $spedec71 = null; try { return DB::transaction(function () use($spe5a302, &$spedec71, $spac2b89) { $spedec71 = \App\Order::where('id', $spe5a302)->lockForUpdate()->firstOrFail(); $sp5359c9 = $spac2b89($spedec71); if ($sp5359c9 !== self::ACTION_CONTINUE) { return $sp5359c9; } $spac34b1 = User::where('id', $spedec71->user_id)->lockForUpdate()->firstOrFail(); $spac34b1->m_all += $spedec71->income; $spac34b1->saveOrFail(); $sp792da7 = new FundRecord(); $sp792da7->user_id = $spedec71->user_id; $sp792da7->type = FundRecord::TYPE_IN; $sp792da7->amount = $spedec71->income; $sp792da7->all = $spac34b1->m_all; $sp792da7->frozen = $spac34b1->m_frozen; $sp792da7->paid = $spac34b1->m_paid; $sp792da7->balance = $spac34b1->m_balance; $sp792da7->remark = '订单#' . $spedec71->order_no; $sp792da7->order_id = $spedec71->id; $sp792da7->saveOrFail(); return true; }); } catch (\Throwable $sp6a7295) { $spa24442 = 'FundHelper.orderSuccess error, order_id:' . $spe5a302; if ($spedec71) { $spa24442 .= ', user_id:' . $spedec71->user_id . ',income:' . $spedec71->income . ',order_no:' . $spedec71->order_no; } Log::error($spa24442 . ' with exception:', array('Exception' => $sp6a7295)); return false; } } public static function orderFreeze($spe5a302, $sp35d759) { $spedec71 = null; try { return DB::transaction(function () use($spe5a302, &$spedec71, $sp35d759) { $spedec71 = \App\Order::where('id', $spe5a302)->lockForUpdate()->firstOrFail(); if ($spedec71->status === Order::STATUS_REFUND) { return false; } if ($spedec71->status === Order::STATUS_FROZEN) { return true; } $spf336f5 = $spedec71->status; if ($spf336f5 === \App\Order::STATUS_SUCCESS) { $spc6c487 = '已发货'; } elseif ($spf336f5 === \App\Order::STATUS_UNPAY) { $spc6c487 = '未付款'; } elseif ($spf336f5 === \App\Order::STATUS_PAID) { $spc6c487 = '未发货'; } else { throw new \Exception('unknown'); } $spac34b1 = User::where('id', $spedec71->user_id)->lockForUpdate()->firstOrFail(); $sp792da7 = new FundRecord(); $sp792da7->user_id = $spedec71->user_id; $sp792da7->type = FundRecord::TYPE_OUT; $sp792da7->order_id = $spedec71->id; $sp792da7->remark = $spedec71 === $spedec71 ? '' : '关联订单#' . $spedec71->order_no . ': '; if ($spf336f5 === \App\Order::STATUS_SUCCESS) { $spac34b1->m_frozen += $spedec71->income; $spac34b1->saveOrFail(); $sp792da7->amount = -$spedec71->income; $sp792da7->remark .= $sp35d759 . ', 冻结订单#' . $spedec71->order_no; } else { $sp792da7->amount = 0; $sp792da7->remark .= $sp35d759 . ', 冻结订单(' . $spc6c487 . ')#' . $spedec71->order_no; } $sp792da7->all = $spac34b1->m_all; $sp792da7->frozen = $spac34b1->m_frozen; $sp792da7->paid = $spac34b1->m_paid; $sp792da7->balance = $spac34b1->m_balance; $sp792da7->saveOrFail(); $spedec71->status = \App\Order::STATUS_FROZEN; $spedec71->frozen_reason = ($spedec71 === $spedec71 ? '' : '关联订单#' . $spedec71->order_no . ': ') . $sp35d759; $spedec71->saveOrFail(); return true; }); } catch (\Throwable $sp6a7295) { $spa24442 = 'FundHelper.orderFreeze error'; if ($spedec71) { $spa24442 .= ', order_no:' . $spedec71->order_no . ', user_id:' . $spedec71->user_id . ', amount:' . $spedec71->income; } else { $spa24442 .= ', order_no: null'; } Log::error($spa24442 . ' with exception:', array('Exception' => $sp6a7295)); return false; } } public static function orderUnfreeze($spe5a302, $sp82af3d, callable $sp6adede = null, &$sp172c79 = null) { $spedec71 = null; try { return DB::transaction(function () use($spe5a302, &$spedec71, $sp82af3d, $sp6adede, &$sp172c79) { $spedec71 = \App\Order::where('id', $spe5a302)->lockForUpdate()->firstOrFail(); if ($sp6adede !== null) { $sp5359c9 = $sp6adede(); if ($sp5359c9 !== self::ACTION_CONTINUE) { return $sp5359c9; } } if ($spedec71->status === Order::STATUS_REFUND) { $sp172c79 = $spedec71->status; return false; } if ($spedec71->status !== Order::STATUS_FROZEN) { $sp172c79 = $spedec71->status; return true; } $sp0cd54e = $spedec71->card_orders()->exists(); if ($sp0cd54e) { $sp172c79 = \App\Order::STATUS_SUCCESS; $spc6c487 = '已发货'; } else { if ($spedec71->paid_at === NULL) { $sp172c79 = \App\Order::STATUS_UNPAY; $spc6c487 = '未付款'; } else { $sp172c79 = \App\Order::STATUS_PAID; $spc6c487 = '未发货'; } } $spac34b1 = User::where('id', $spedec71->user_id)->lockForUpdate()->firstOrFail(); $sp792da7 = new FundRecord(); $sp792da7->user_id = $spedec71->user_id; $sp792da7->type = FundRecord::TYPE_IN; $sp792da7->remark = $spedec71 === $spedec71 ? '' : '关联订单#' . $spedec71->order_no . ': '; $sp792da7->order_id = $spedec71->id; if ($sp0cd54e) { $spac34b1->m_frozen -= $spedec71->income; $spac34b1->saveOrFail(); $sp792da7->amount = $spedec71->income; $sp792da7->remark .= $sp82af3d . ', 解冻订单#' . $spedec71->order_no; } else { $sp792da7->amount = 0; $sp792da7->remark .= $sp82af3d . ', 解冻订单(' . $spc6c487 . ')#' . $spedec71->order_no; } $sp792da7->all = $spac34b1->m_all; $sp792da7->frozen = $spac34b1->m_frozen; $sp792da7->paid = $spac34b1->m_paid; $sp792da7->balance = $spac34b1->m_balance; $sp792da7->saveOrFail(); $spedec71->status = $sp172c79; $spedec71->saveOrFail(); return true; }); } catch (\Throwable $sp6a7295) { $spa24442 = 'FundHelper.orderUnfreeze error'; if ($spedec71) { $spa24442 .= ', order_no:' . $spedec71->order_no . ', user_id:' . $spedec71->user_id . ',amount:' . $spedec71->income; } else { $spa24442 .= ', order_no: null'; } Log::error($spa24442 . ' with exception:', array('Exception' => $sp6a7295)); return false; } } } \ No newline at end of file diff --git a/app/Library/Geetest/API.php b/app/Library/Geetest/API.php index 8b4f46e34..8f2f3d3b1 100644 --- a/app/Library/Geetest/API.php +++ b/app/Library/Geetest/API.php @@ -1,2 +1,2 @@ geetest_conf = $spfd6e52; } public static function get() { $sp746ee1 = config('services.geetest.id'); $sp0d678a = config('services.geetest.key'); if (!strlen($sp746ee1) || !strlen($sp0d678a)) { return null; } $sp078aa4 = new Lib($sp746ee1, $sp0d678a); $sp258cf6 = time() . rand(1, 10000); $spf66c3d = $sp078aa4->pre_process($sp258cf6); $sp786169 = json_decode($sp078aa4->get_response_str()); Session::put('gt_server', $spf66c3d); Session::put('gt_user_id', $sp258cf6); return $sp786169; } public static function verify($sp8929f8, $spe8aa70, $spb99309) { $sp078aa4 = new Lib(config('services.geetest.id'), config('services.geetest.key')); $sp258cf6 = Session::get('gt_user_id'); if (Session::get('gt_server') == 1) { $sp0cbff8 = $sp078aa4->success_validate($sp8929f8, $spe8aa70, $spb99309, $sp258cf6); if ($sp0cbff8) { return true; } else { return false; } } else { if ($sp078aa4->fail_validate($sp8929f8, $spe8aa70, $spb99309)) { return true; } else { return false; } } } } \ No newline at end of file +namespace App\Library\Geetest; use Illuminate\Support\Facades\Session; class API { private $geetest_conf = null; public function __construct($spf3616d) { $this->geetest_conf = $spf3616d; } public static function get() { $sp8e8060 = config('services.geetest.id'); $sp4450cf = config('services.geetest.key'); if (!strlen($sp8e8060) || !strlen($sp4450cf)) { return null; } $sp239ed4 = new Lib($sp8e8060, $sp4450cf); $spf5ae13 = time() . rand(1, 10000); $sp732cf7 = $sp239ed4->pre_process($spf5ae13); $sp5359c9 = json_decode($sp239ed4->get_response_str()); Session::put('gt_server', $sp732cf7); Session::put('gt_user_id', $spf5ae13); return $sp5359c9; } public static function verify($sp387b7b, $sp2b7c7c, $sp0161e8) { $sp239ed4 = new Lib(config('services.geetest.id'), config('services.geetest.key')); $spf5ae13 = Session::get('gt_user_id'); if (Session::get('gt_server') == 1) { $spe6807d = $sp239ed4->success_validate($sp387b7b, $sp2b7c7c, $sp0161e8, $spf5ae13); if ($spe6807d) { return true; } else { return false; } } else { if ($sp239ed4->fail_validate($sp387b7b, $sp2b7c7c, $sp0161e8)) { return true; } else { return false; } } } } \ No newline at end of file diff --git a/app/Library/Geetest/Lib.php b/app/Library/Geetest/Lib.php index ccc90d087..07d3281eb 100644 --- a/app/Library/Geetest/Lib.php +++ b/app/Library/Geetest/Lib.php @@ -1,4 +1,4 @@ captcha_id = $sp467b7f; $this->private_key = $sp673b97; } public function pre_process($sp258cf6 = null) { $spddf3f5 = 'http://api.geetest.com/register.php?gt=' . $this->captcha_id; if ($sp258cf6 != null and is_string($sp258cf6)) { $spddf3f5 = $spddf3f5 . '&user_id=' . $sp258cf6; } $sp7e57f7 = $this->send_request($spddf3f5); if (strlen($sp7e57f7) != 32) { $this->failback_process(); return 0; } $this->success_process($sp7e57f7); return 1; } private function success_process($sp7e57f7) { $sp7e57f7 = md5($sp7e57f7 . $this->private_key); $sp0cbff8 = array('success' => 1, 'gt' => $this->captcha_id, 'challenge' => $sp7e57f7); $this->response = $sp0cbff8; } private function failback_process() { $sp74588e = md5(rand(0, 100)); $sp03ef85 = md5(rand(0, 100)); $sp7e57f7 = $sp74588e . substr($sp03ef85, 0, 2); $sp0cbff8 = array('success' => 0, 'gt' => $this->captcha_id, 'challenge' => $sp7e57f7); $this->response = $sp0cbff8; } public function get_response_str() { return json_encode($this->response); } public function get_response() { return $this->response; } public function success_validate($sp7e57f7, $sp84a849, $sp73c3fd, $sp258cf6 = null) { if (!$this->check_validate($sp7e57f7, $sp84a849)) { return 0; } $spe036ec = array('seccode' => $sp73c3fd, 'sdk' => self::GT_SDK_VERSION); if ($sp258cf6 != null and is_string($sp258cf6)) { $spe036ec['user_id'] = $sp258cf6; } $spddf3f5 = 'http://api.geetest.com/validate.php'; $spe4212a = $this->post_request($spddf3f5, $spe036ec); if ($spe4212a == md5($sp73c3fd)) { return 1; } else { if ($spe4212a == 'false') { return 0; } else { return 0; } } } public function fail_validate($sp7e57f7, $sp84a849, $sp73c3fd) { if ($sp84a849) { $sp1b5dd9 = explode('_', $sp84a849); try { $spa22ffa = $this->decode_response($sp7e57f7, $sp1b5dd9['0']); $sp05174e = $this->decode_response($sp7e57f7, $sp1b5dd9['1']); $sp80e0c9 = $this->decode_response($sp7e57f7, $sp1b5dd9['2']); $sp116c29 = $this->get_failback_pic_ans($sp05174e, $sp80e0c9); $sp91a927 = abs($spa22ffa - $sp116c29); } catch (\Exception $sp45f5f1) { return 1; } if ($sp91a927 < 4) { return 1; } else { return 0; } } else { return 0; } } private function check_validate($sp7e57f7, $sp84a849) { if (strlen($sp84a849) != 32) { return false; } if (md5($this->private_key . 'geetest' . $sp7e57f7) != $sp84a849) { return false; } return true; } private function send_request($spddf3f5) { if (function_exists('curl_exec')) { $spa9fd67 = curl_init(); curl_setopt($spa9fd67, CURLOPT_URL, $spddf3f5); curl_setopt($spa9fd67, CURLOPT_CONNECTTIMEOUT, self::$connectTimeout); curl_setopt($spa9fd67, CURLOPT_TIMEOUT, self::$socketTimeout); curl_setopt($spa9fd67, CURLOPT_RETURNTRANSFER, 1); $spe036ec = curl_exec($spa9fd67); if (curl_errno($spa9fd67)) { $sp4bde26 = sprintf('curl[%s] error[%s]', $spddf3f5, curl_errno($spa9fd67) . ':' . curl_error($spa9fd67)); $this->triggerError($sp4bde26); } curl_close($spa9fd67); } else { $sp9b16cd = array('http' => array('method' => 'GET', 'timeout' => self::$connectTimeout + self::$socketTimeout)); $sp84c4ea = stream_context_create($sp9b16cd); $spe036ec = file_get_contents($spddf3f5, false, $sp84c4ea); } return $spe036ec; } private function post_request($spddf3f5, $spd2e949 = '') { if (!$spd2e949) { return false; } $spe036ec = http_build_query($spd2e949); if (function_exists('curl_exec')) { $spa9fd67 = curl_init(); curl_setopt($spa9fd67, CURLOPT_URL, $spddf3f5); curl_setopt($spa9fd67, CURLOPT_RETURNTRANSFER, 1); curl_setopt($spa9fd67, CURLOPT_CONNECTTIMEOUT, self::$connectTimeout); curl_setopt($spa9fd67, CURLOPT_TIMEOUT, self::$socketTimeout); if (!$spd2e949) { curl_setopt($spa9fd67, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); } else { curl_setopt($spa9fd67, CURLOPT_POST, 1); curl_setopt($spa9fd67, CURLOPT_POSTFIELDS, $spe036ec); } $spe036ec = curl_exec($spa9fd67); if (curl_errno($spa9fd67)) { $sp4bde26 = sprintf('curl[%s] error[%s]', $spddf3f5, curl_errno($spa9fd67) . ':' . curl_error($spa9fd67)); $this->triggerError($sp4bde26); } curl_close($spa9fd67); } else { if ($spd2e949) { $sp9b16cd = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded -' . 'Content-Length: ' . strlen($spe036ec) . ' -', 'content' => $spe036ec, 'timeout' => self::$connectTimeout + self::$socketTimeout)); $sp84c4ea = stream_context_create($sp9b16cd); $spe036ec = file_get_contents($spddf3f5, false, $sp84c4ea); } } return $spe036ec; } private function decode_response($sp7e57f7, $sp8ed49d) { if (strlen($sp8ed49d) > 100) { return 0; } $sp0d678a = array(); $spb3be9f = array(); $sp26243a = array('0' => 1, '1' => 2, '2' => 5, '3' => 10, '4' => 50); $spdf4a99 = 0; $sp815cba = 0; $sp83f0f7 = str_split($sp7e57f7); $sp538caf = str_split($sp8ed49d); for ($spe20094 = 0; $spe20094 < strlen($sp7e57f7); $spe20094++) { $spc6f905 = $sp83f0f7[$spe20094]; if (in_array($spc6f905, $spb3be9f)) { continue; } else { $sp1b5dd9 = $sp26243a[$spdf4a99 % 5]; array_push($spb3be9f, $spc6f905); $spdf4a99++; $sp0d678a[$spc6f905] = $sp1b5dd9; } } for ($sp3e8837 = 0; $sp3e8837 < strlen($sp8ed49d); $sp3e8837++) { $sp815cba += $sp0d678a[$sp538caf[$sp3e8837]]; } $sp815cba = $sp815cba - $this->decodeRandBase($sp7e57f7); return $sp815cba; } private function get_x_pos_from_str($spa70c2b) { if (strlen($spa70c2b) != 5) { return 0; } $sp79a188 = 0; $sp5ef48f = 200; $sp79a188 = base_convert($spa70c2b, 16, 10); $sp0cbff8 = $sp79a188 % $sp5ef48f; $sp0cbff8 = $sp0cbff8 < 40 ? 40 : $sp0cbff8; return $sp0cbff8; } private function get_failback_pic_ans($sp890149, $spda6f0f) { $sp56870e = substr(md5($sp890149), 0, 9); $spe11c95 = substr(md5($spda6f0f), 10, 9); $spd94244 = ''; for ($spe20094 = 0; $spe20094 < 9; $spe20094++) { if ($spe20094 % 2 == 0) { $spd94244 = $spd94244 . $sp56870e[$spe20094]; } elseif ($spe20094 % 2 == 1) { $spd94244 = $spd94244 . $spe11c95[$spe20094]; } } $spa13a69 = substr($spd94244, 4, 5); $sp116c29 = $this->get_x_pos_from_str($spa13a69); return $sp116c29; } private function decodeRandBase($sp7e57f7) { $sp8af5db = substr($sp7e57f7, 32, 2); $sp52253e = array(); for ($spe20094 = 0; $spe20094 < strlen($sp8af5db); $spe20094++) { $spa587bb = ord($sp8af5db[$spe20094]); $sp0cbff8 = $spa587bb > 57 ? $spa587bb - 87 : $spa587bb - 48; array_push($sp52253e, $sp0cbff8); } $sp1986e9 = $sp52253e['0'] * 36 + $sp52253e['1']; return $sp1986e9; } private function triggerError($sp4bde26) { } } \ No newline at end of file +namespace App\Library\Geetest; class Lib { const GT_SDK_VERSION = 'php_3.2.0'; public static $connectTimeout = 1; public static $socketTimeout = 1; private $response; public $captcha_id; public $private_key; public function __construct($sp971d6f, $sp753ab8) { $this->captcha_id = $sp971d6f; $this->private_key = $sp753ab8; } public function pre_process($spf5ae13 = null) { $sp0784c1 = 'http://api.geetest.com/register.php?gt=' . $this->captcha_id; if ($spf5ae13 != null and is_string($spf5ae13)) { $sp0784c1 = $sp0784c1 . '&user_id=' . $spf5ae13; } $spcd755b = $this->send_request($sp0784c1); if (strlen($spcd755b) != 32) { $this->failback_process(); return 0; } $this->success_process($spcd755b); return 1; } private function success_process($spcd755b) { $spcd755b = md5($spcd755b . $this->private_key); $spe6807d = array('success' => 1, 'gt' => $this->captcha_id, 'challenge' => $spcd755b); $this->response = $spe6807d; } private function failback_process() { $sp7cf554 = md5(rand(0, 100)); $sp88e0c9 = md5(rand(0, 100)); $spcd755b = $sp7cf554 . substr($sp88e0c9, 0, 2); $spe6807d = array('success' => 0, 'gt' => $this->captcha_id, 'challenge' => $spcd755b); $this->response = $spe6807d; } public function get_response_str() { return json_encode($this->response); } public function get_response() { return $this->response; } public function success_validate($spcd755b, $sp81e372, $spf24dc9, $spf5ae13 = null) { if (!$this->check_validate($spcd755b, $sp81e372)) { return 0; } $spacc152 = array('seccode' => $spf24dc9, 'sdk' => self::GT_SDK_VERSION); if ($spf5ae13 != null and is_string($spf5ae13)) { $spacc152['user_id'] = $spf5ae13; } $sp0784c1 = 'http://api.geetest.com/validate.php'; $spc2fe9e = $this->post_request($sp0784c1, $spacc152); if ($spc2fe9e == md5($spf24dc9)) { return 1; } else { if ($spc2fe9e == 'false') { return 0; } else { return 0; } } } public function fail_validate($spcd755b, $sp81e372, $spf24dc9) { if ($sp81e372) { $sp4a2047 = explode('_', $sp81e372); try { $sp34f252 = $this->decode_response($spcd755b, $sp4a2047['0']); $sp2c96eb = $this->decode_response($spcd755b, $sp4a2047['1']); $sp130436 = $this->decode_response($spcd755b, $sp4a2047['2']); $spa66852 = $this->get_failback_pic_ans($sp2c96eb, $sp130436); $spa76c5d = abs($sp34f252 - $spa66852); } catch (\Exception $sp6a7295) { return 1; } if ($spa76c5d < 4) { return 1; } else { return 0; } } else { return 0; } } private function check_validate($spcd755b, $sp81e372) { if (strlen($sp81e372) != 32) { return false; } if (md5($this->private_key . 'geetest' . $spcd755b) != $sp81e372) { return false; } return true; } private function send_request($sp0784c1) { if (function_exists('curl_exec')) { $spf86e31 = curl_init(); curl_setopt($spf86e31, CURLOPT_URL, $sp0784c1); curl_setopt($spf86e31, CURLOPT_CONNECTTIMEOUT, self::$connectTimeout); curl_setopt($spf86e31, CURLOPT_TIMEOUT, self::$socketTimeout); curl_setopt($spf86e31, CURLOPT_RETURNTRANSFER, 1); $spacc152 = curl_exec($spf86e31); if (curl_errno($spf86e31)) { $sp13c288 = sprintf('curl[%s] error[%s]', $sp0784c1, curl_errno($spf86e31) . ':' . curl_error($spf86e31)); $this->triggerError($sp13c288); } curl_close($spf86e31); } else { $sp239cb0 = array('http' => array('method' => 'GET', 'timeout' => self::$connectTimeout + self::$socketTimeout)); $sp32b641 = stream_context_create($sp239cb0); $spacc152 = file_get_contents($sp0784c1, false, $sp32b641); } return $spacc152; } private function post_request($sp0784c1, $spd49a63 = '') { if (!$spd49a63) { return false; } $spacc152 = http_build_query($spd49a63); if (function_exists('curl_exec')) { $spf86e31 = curl_init(); curl_setopt($spf86e31, CURLOPT_URL, $sp0784c1); curl_setopt($spf86e31, CURLOPT_RETURNTRANSFER, 1); curl_setopt($spf86e31, CURLOPT_CONNECTTIMEOUT, self::$connectTimeout); curl_setopt($spf86e31, CURLOPT_TIMEOUT, self::$socketTimeout); if (!$spd49a63) { curl_setopt($spf86e31, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); } else { curl_setopt($spf86e31, CURLOPT_POST, 1); curl_setopt($spf86e31, CURLOPT_POSTFIELDS, $spacc152); } $spacc152 = curl_exec($spf86e31); if (curl_errno($spf86e31)) { $sp13c288 = sprintf('curl[%s] error[%s]', $sp0784c1, curl_errno($spf86e31) . ':' . curl_error($spf86e31)); $this->triggerError($sp13c288); } curl_close($spf86e31); } else { if ($spd49a63) { $sp239cb0 = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded +' . 'Content-Length: ' . strlen($spacc152) . ' +', 'content' => $spacc152, 'timeout' => self::$connectTimeout + self::$socketTimeout)); $sp32b641 = stream_context_create($sp239cb0); $spacc152 = file_get_contents($sp0784c1, false, $sp32b641); } } return $spacc152; } private function decode_response($spcd755b, $spebcddc) { if (strlen($spebcddc) > 100) { return 0; } $sp4450cf = array(); $sp4b9d07 = array(); $sp33c957 = array('0' => 1, '1' => 2, '2' => 5, '3' => 10, '4' => 50); $sp99aae1 = 0; $sp162b98 = 0; $spc3ad4b = str_split($spcd755b); $sp18f418 = str_split($spebcddc); for ($spc8f255 = 0; $spc8f255 < strlen($spcd755b); $spc8f255++) { $spbdd4b3 = $spc3ad4b[$spc8f255]; if (in_array($spbdd4b3, $sp4b9d07)) { continue; } else { $sp4a2047 = $sp33c957[$sp99aae1 % 5]; array_push($sp4b9d07, $spbdd4b3); $sp99aae1++; $sp4450cf[$spbdd4b3] = $sp4a2047; } } for ($sp8ec0e5 = 0; $sp8ec0e5 < strlen($spebcddc); $sp8ec0e5++) { $sp162b98 += $sp4450cf[$sp18f418[$sp8ec0e5]]; } $sp162b98 = $sp162b98 - $this->decodeRandBase($spcd755b); return $sp162b98; } private function get_x_pos_from_str($spe0bcf2) { if (strlen($spe0bcf2) != 5) { return 0; } $spd5c80e = 0; $sp833cb0 = 200; $spd5c80e = base_convert($spe0bcf2, 16, 10); $spe6807d = $spd5c80e % $sp833cb0; $spe6807d = $spe6807d < 40 ? 40 : $spe6807d; return $spe6807d; } private function get_failback_pic_ans($sp2e7c57, $sp121a36) { $spaac8fe = substr(md5($sp2e7c57), 0, 9); $sp9f4f43 = substr(md5($sp121a36), 10, 9); $sp8956d0 = ''; for ($spc8f255 = 0; $spc8f255 < 9; $spc8f255++) { if ($spc8f255 % 2 == 0) { $sp8956d0 = $sp8956d0 . $spaac8fe[$spc8f255]; } elseif ($spc8f255 % 2 == 1) { $sp8956d0 = $sp8956d0 . $sp9f4f43[$spc8f255]; } } $sp239f75 = substr($sp8956d0, 4, 5); $spa66852 = $this->get_x_pos_from_str($sp239f75); return $spa66852; } private function decodeRandBase($spcd755b) { $sp28cda4 = substr($spcd755b, 32, 2); $sp679035 = array(); for ($spc8f255 = 0; $spc8f255 < strlen($sp28cda4); $spc8f255++) { $sp6c993e = ord($sp28cda4[$spc8f255]); $spe6807d = $sp6c993e > 57 ? $sp6c993e - 87 : $sp6c993e - 48; array_push($sp679035, $spe6807d); } $sp40b376 = $sp679035['0'] * 36 + $sp679035['1']; return $sp40b376; } private function triggerError($sp13c288) { } } \ No newline at end of file diff --git a/app/Library/Helper.php b/app/Library/Helper.php index 526681715..354b7bf92 100644 --- a/app/Library/Helper.php +++ b/app/Library/Helper.php @@ -1,2 +1,2 @@ = $spb43247) { return ''; } $sp566e44 = strlen($sp8c6d14); $sp786169 = substr($spd31ac9, $sp814ff5 + $sp566e44, $spb43247 - $sp814ff5 - $sp566e44); return $sp786169; } public static function str_between_longest($spd31ac9, $sp8c6d14, $spd99f87) { $sp814ff5 = strpos($spd31ac9, $sp8c6d14); if ($sp814ff5 === false) { return ''; } $spb43247 = strrpos($spd31ac9, $spd99f87, $sp814ff5 + strlen($sp8c6d14)); if ($spb43247 === false || $sp814ff5 >= $spb43247) { return ''; } $sp566e44 = strlen($sp8c6d14); $sp786169 = substr($spd31ac9, $sp814ff5 + $sp566e44, $spb43247 - $sp814ff5 - $sp566e44); return $sp786169; } public static function format_url($spddf3f5) { if (!strlen($spddf3f5)) { return $spddf3f5; } if (!starts_with($spddf3f5, 'http://') && !starts_with($spddf3f5, 'https://')) { $spddf3f5 = 'http://' . $spddf3f5; } while (ends_with($spddf3f5, '/')) { $spddf3f5 = substr($spddf3f5, 0, -1); } return $spddf3f5; } public static function lite_hash($spd31ac9) { $spf7d648 = crc32((string) $spd31ac9); if ($spf7d648 < 0) { $spf7d648 &= 1 << 7; } return $spf7d648; } const ID_TYPE_USER = 0; const ID_TYPE_CATEGORY = 1; const ID_TYPE_PRODUCT = 2; public static function id_encode($sp746ee1, $sp460df4) { $sp5ee1d6 = new Hashids(config('app.key'), 8, 'abcdefghijklmnopqrstuvwxyz1234567890'); return @$sp5ee1d6->encode(self::lite_hash($sp746ee1), $sp746ee1, self::lite_hash($sp460df4), $sp460df4); } public static function id_decode($spaace48, $sp460df4) { if (strlen($spaace48) < 8) { $sp5ee1d6 = new Hashids(config('app.key')); if ($sp460df4 === self::ID_TYPE_USER) { return intval(@$sp5ee1d6->decodeHex($spaace48)); } else { return intval(@$sp5ee1d6->decode($spaace48)[0]); } } $sp5ee1d6 = new Hashids(config('app.key'), 8, 'abcdefghijklmnopqrstuvwxyz1234567890'); return intval(@$sp5ee1d6->decode($spaace48)[1]); } public static function is_mobile() { if (isset($_SERVER['HTTP_USER_AGENT'])) { if (preg_match('/(iPhone|iPod|Android|ios|SymbianOS|Windows Phone)/i', $_SERVER['HTTP_USER_AGENT'])) { return true; } } return false; } public static function b1_rand_background() { if (self::is_mobile()) { $spb369d8 = array('//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpgyq8n5j20u01hcne2.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpfyjbd0j20u01hcte2.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpw3b5mkj20u01hcnfh.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxoybkicbj20u01hc7de.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpes8rmmj20u01hctn7.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxp8ond6gj20u01hctji.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxp4ljhhvj20u01hck0r.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpstrwnsj20u01hc7he.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxq2a1vthj20u01hc4gs.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpiebjztj20u01hcaom.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxow4b14kj20u01hc43x.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxohtyvgfj20u01hc7gk.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxp6vexa3j20u01hcdj3.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxqa0zhc6j20u01hc14e.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxomnbr0gj20u01hc79r.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpx57f0sj20u01hcqmd.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxoozjilyj20u01hcgt9.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxprigfw1j20u01hcam9.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxod70fcpj20u01hcajj.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpzb5p1tj20u01hcnca.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxozvry57j20u01hcgwo.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpv092lfj20u01hcx1o.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpdz6s0bj20u01hcaqj.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxoso79ayj20u01hcq9c.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpqjrtjhj20u01hcapi.jpg'); } else { $spb369d8 = array('//ww1.sinaimg.cn/large/ac1a0c4agy1ftz78cfrj2j21hc0u0kio.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7qj6l3xj21hc0u0b29.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9tqa2fvpj21hc0u017a.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz71m76skj21hc0u0nnq.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz709py6fj21hc0u0wx2.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9sgqv33lj21hc0u04qp.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9s9soh4sj21hc0u01kx.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9s9r2vkzj21hc0u0x4e.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7etbcs8j21hc0u07p3.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9sgn1bluj21hc0u0kiy.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7r6tmv1j21hc0u0anj.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7c4h0xzj21hc0u01kx.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9tq7uypvj21hc0u01be.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1fwr4pjgbncj21hc0u0kjl.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7i6u1gxj21hc0u0tyk.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1fwr4s0fb2tj21hc0u01ky.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz72wkr9dj21hc0u0h1r.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7tj5ohrj21hc0u0qnp.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9sgp23zbj21hc0u0txl.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7l9dcokj21hc0u0k9k.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1fwr4lvumu1j21hc0u0x6p.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7alxyhnj21hc0u0nkh.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz799gvb3j21hc0u0qdt.jpg'); } return $spb369d8[rand(0, count($spb369d8))]; } } \ No newline at end of file +namespace App\Library; use Hashids\Hashids; class Helper { public static function getMysqlDate($sp1f7516 = 0) { return date('Y-m-d', time() + $sp1f7516 * 24 * 3600); } public static function getIP() { if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $spec8c4f = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { if (isset($_SERVER['HTTP_CLIENT_IP'])) { $spec8c4f = $_SERVER['HTTP_CLIENT_IP']; } else { $spec8c4f = @$_SERVER['REMOTE_ADDR']; } } } else { if (getenv('HTTP_X_FORWARDED_FOR')) { $spec8c4f = getenv('HTTP_X_FORWARDED_FOR'); } else { if (getenv('HTTP_CLIENT_IP')) { $spec8c4f = getenv('HTTP_CLIENT_IP'); } else { $spec8c4f = getenv('REMOTE_ADDR'); } } } if (strpos($spec8c4f, ',') !== FALSE) { $sp56ce6d = explode(',', $spec8c4f); return $sp56ce6d[0]; } return $spec8c4f; } public static function getClientIP() { if (isset($_SERVER)) { $spec8c4f = $_SERVER['REMOTE_ADDR']; } else { $spec8c4f = getenv('REMOTE_ADDR'); } if (strpos($spec8c4f, ',') !== FALSE) { $sp56ce6d = explode(',', $spec8c4f); return $sp56ce6d[0]; } return $spec8c4f; } public static function filterWords($spa09134, $sp585bcb) { if (!$spa09134) { return false; } if (!is_array($sp585bcb)) { $sp585bcb = explode('|', $sp585bcb); } foreach ($sp585bcb as $spb469c9) { if ($spb469c9 && strpos($spa09134, $spb469c9) !== FALSE) { return $spb469c9; } } return false; } public static function is_idcard($spdf357f) { if (strlen($spdf357f) == 18) { return self::idcard_checksum18($spdf357f); } elseif (strlen($spdf357f) == 15) { $spdf357f = self::idcard_15to18($spdf357f); return self::idcard_checksum18($spdf357f); } else { return false; } } private static function idcard_verify_number($spa18e81) { if (strlen($spa18e81) != 17) { return false; } $sp5db430 = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); $sp7802b2 = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); $sp4fc36c = 0; for ($spc8f255 = 0; $spc8f255 < strlen($spa18e81); $spc8f255++) { $sp4fc36c += substr($spa18e81, $spc8f255, 1) * $sp5db430[$spc8f255]; } $sp113e0a = $sp4fc36c % 11; $specf8c0 = $sp7802b2[$sp113e0a]; return $specf8c0; } private static function idcard_15to18($sp041450) { if (strlen($sp041450) != 15) { return false; } else { if (array_search(substr($sp041450, 12, 3), array('996', '997', '998', '999')) !== false) { $sp041450 = substr($sp041450, 0, 6) . '18' . substr($sp041450, 6, 9); } else { $sp041450 = substr($sp041450, 0, 6) . '19' . substr($sp041450, 6, 9); } } $sp041450 = $sp041450 . self::idcard_verify_number($sp041450); return $sp041450; } private static function idcard_checksum18($sp041450) { if (strlen($sp041450) != 18) { return false; } $spa18e81 = substr($sp041450, 0, 17); if (self::idcard_verify_number($spa18e81) != strtoupper(substr($sp041450, 17, 1))) { return false; } else { return true; } } public static function str_between($spa09134, $sp8f79c6, $sp07e1ad) { $spe1d3f8 = strpos($spa09134, $sp8f79c6); if ($spe1d3f8 === false) { return ''; } $spb6d13b = strpos($spa09134, $sp07e1ad, $spe1d3f8 + strlen($sp8f79c6)); if ($spb6d13b === false || $spe1d3f8 >= $spb6d13b) { return ''; } $sp683f83 = strlen($sp8f79c6); $sp5359c9 = substr($spa09134, $spe1d3f8 + $sp683f83, $spb6d13b - $spe1d3f8 - $sp683f83); return $sp5359c9; } public static function str_between_longest($spa09134, $sp8f79c6, $sp07e1ad) { $spe1d3f8 = strpos($spa09134, $sp8f79c6); if ($spe1d3f8 === false) { return ''; } $spb6d13b = strrpos($spa09134, $sp07e1ad, $spe1d3f8 + strlen($sp8f79c6)); if ($spb6d13b === false || $spe1d3f8 >= $spb6d13b) { return ''; } $sp683f83 = strlen($sp8f79c6); $sp5359c9 = substr($spa09134, $spe1d3f8 + $sp683f83, $spb6d13b - $spe1d3f8 - $sp683f83); return $sp5359c9; } public static function format_url($sp0784c1) { if (!strlen($sp0784c1)) { return $sp0784c1; } if (!starts_with($sp0784c1, 'http://') && !starts_with($sp0784c1, 'https://')) { $sp0784c1 = 'http://' . $sp0784c1; } while (ends_with($sp0784c1, '/')) { $sp0784c1 = substr($sp0784c1, 0, -1); } return $sp0784c1; } public static function lite_hash($spa09134) { $sp85c180 = crc32((string) $spa09134); if ($sp85c180 < 0) { $sp85c180 &= 1 << 7; } return $sp85c180; } const ID_TYPE_USER = 0; const ID_TYPE_CATEGORY = 1; const ID_TYPE_PRODUCT = 2; public static function id_encode($sp8e8060, $spe7b1c7) { $sp9cfa51 = new Hashids(config('app.key'), 8, 'abcdefghijklmnopqrstuvwxyz1234567890'); return @$sp9cfa51->encode(self::lite_hash($sp8e8060), $sp8e8060, self::lite_hash($spe7b1c7), $spe7b1c7); } public static function id_decode($sp1bcdb5, $spe7b1c7) { if (strlen($sp1bcdb5) < 8) { $sp9cfa51 = new Hashids(config('app.key')); if ($spe7b1c7 === self::ID_TYPE_USER) { return intval(@$sp9cfa51->decodeHex($sp1bcdb5)); } else { return intval(@$sp9cfa51->decode($sp1bcdb5)[0]); } } $sp9cfa51 = new Hashids(config('app.key'), 8, 'abcdefghijklmnopqrstuvwxyz1234567890'); return intval(@$sp9cfa51->decode($sp1bcdb5)[1]); } public static function is_mobile() { if (isset($_SERVER['HTTP_USER_AGENT'])) { if (preg_match('/(iPhone|iPod|Android|ios|SymbianOS|Windows Phone)/i', $_SERVER['HTTP_USER_AGENT'])) { return true; } } return false; } public static function b1_rand_background() { if (self::is_mobile()) { $spe49ca3 = array('//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpgyq8n5j20u01hcne2.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpfyjbd0j20u01hcte2.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpw3b5mkj20u01hcnfh.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxoybkicbj20u01hc7de.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpes8rmmj20u01hctn7.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxp8ond6gj20u01hctji.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxp4ljhhvj20u01hck0r.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpstrwnsj20u01hc7he.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxq2a1vthj20u01hc4gs.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpiebjztj20u01hcaom.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxow4b14kj20u01hc43x.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxohtyvgfj20u01hc7gk.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxp6vexa3j20u01hcdj3.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxqa0zhc6j20u01hc14e.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxomnbr0gj20u01hc79r.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpx57f0sj20u01hcqmd.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxoozjilyj20u01hcgt9.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxprigfw1j20u01hcam9.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxod70fcpj20u01hcajj.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpzb5p1tj20u01hcnca.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxozvry57j20u01hcgwo.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpv092lfj20u01hcx1o.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpdz6s0bj20u01hcaqj.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxoso79ayj20u01hcq9c.jpg', '//ww2.sinaimg.cn/large/ac1a0c4agy1ftxpqjrtjhj20u01hcapi.jpg'); } else { $spe49ca3 = array('//ww1.sinaimg.cn/large/ac1a0c4agy1ftz78cfrj2j21hc0u0kio.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7qj6l3xj21hc0u0b29.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9tqa2fvpj21hc0u017a.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz71m76skj21hc0u0nnq.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz709py6fj21hc0u0wx2.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9sgqv33lj21hc0u04qp.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9s9soh4sj21hc0u01kx.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9s9r2vkzj21hc0u0x4e.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7etbcs8j21hc0u07p3.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9sgn1bluj21hc0u0kiy.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7r6tmv1j21hc0u0anj.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7c4h0xzj21hc0u01kx.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9tq7uypvj21hc0u01be.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1fwr4pjgbncj21hc0u0kjl.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7i6u1gxj21hc0u0tyk.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1fwr4s0fb2tj21hc0u01ky.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz72wkr9dj21hc0u0h1r.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7tj5ohrj21hc0u0qnp.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ft9sgp23zbj21hc0u0txl.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7l9dcokj21hc0u0k9k.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1fwr4lvumu1j21hc0u0x6p.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz7alxyhnj21hc0u0nkh.jpg', '//ww1.sinaimg.cn/large/ac1a0c4agy1ftz799gvb3j21hc0u0qdt.jpg'); } return $spe49ca3[rand(0, count($spe49ca3))]; } } \ No newline at end of file diff --git a/app/Library/LogHelper.php b/app/Library/LogHelper.php index 6d679fe12..25ccbefde 100644 --- a/app/Library/LogHelper.php +++ b/app/Library/LogHelper.php @@ -1,2 +1,2 @@ setHandlers(array()); \Log::useDailyFiles(storage_path() . '/logs/' . $spe041e4 . '.log', 0, config('app.log_level')); } } \ No newline at end of file +namespace App\Library; class LogHelper { public static function setLogFile($sp23c04a) { \Log::getMonolog()->setHandlers(array()); \Log::useDailyFiles(storage_path() . '/logs/' . $sp23c04a . '.log', 0, config('app.log_level')); } } \ No newline at end of file diff --git a/app/Library/Response.php b/app/Library/Response.php index bcf9f50ab..9767f97b6 100644 --- a/app/Library/Response.php +++ b/app/Library/Response.php @@ -1,2 +1,2 @@ json($spe036ec, $spf66c3d, $sp697dbb, $spb108c2); } public static function success($spe036ec = array()) { return self::json(array('message' => 'success', 'data' => $spe036ec)); } public static function fail($spa9bccc = 'fail', $spe036ec = array()) { return self::json(array('message' => $spa9bccc, 'data' => $spe036ec), 500); } public static function forbidden($spa9bccc = 'forbidden', $spe036ec = array()) { return self::json(array('message' => $spa9bccc, 'data' => $spe036ec), 403); } } \ No newline at end of file +namespace App\Library; class Response { public static function json($spacc152 = array(), $sp732cf7 = 200, array $sp3e89cf = array(), $sp96cd2f = 0) { return response()->json($spacc152, $sp732cf7, $sp3e89cf, $sp96cd2f); } public static function success($spacc152 = array()) { return self::json(array('message' => 'success', 'data' => $spacc152)); } public static function fail($spa24442 = 'fail', $spacc152 = array()) { return self::json(array('message' => $spa24442, 'data' => $spacc152), 500); } public static function forbidden($spa24442 = 'forbidden', $spacc152 = array()) { return self::json(array('message' => $spa24442, 'data' => $spacc152), 403); } } \ No newline at end of file diff --git a/app/Library/UrlShorten.php b/app/Library/UrlShorten.php index 84bd0834d..bbce26e7f 100644 --- a/app/Library/UrlShorten.php +++ b/app/Library/UrlShorten.php @@ -1,2 +1,2 @@ order = $sp7b2cfc; $this->card_msg = $spcbea9e; $this->cards_txt = $spd93a9d; } public function build() { return $this->subject('订单提醒(#' . $this->order->order_no . ')-' . config('app.name'))->view('emails.order'); } } \ No newline at end of file +namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; class OrderShipped extends Mailable { use Queueable, SerializesModels; public $order; public $card_msg; public $cards_txt; public function __construct($spedec71, $spe94958, $sp8627ee) { $this->order = $spedec71; $this->card_msg = $spe94958; $this->cards_txt = $sp8627ee; } public function build() { return $this->subject('订单提醒(#' . $this->order->order_no . ')-' . config('app.name'))->view('emails.order'); } } \ No newline at end of file diff --git a/app/Mail/ProductCountWarn.php b/app/Mail/ProductCountWarn.php index 1a22bae8e..de6b1a3f7 100644 --- a/app/Mail/ProductCountWarn.php +++ b/app/Mail/ProductCountWarn.php @@ -1,2 +1,2 @@ product = $sp1a3ec5; $this->product_count = $spb3c282; } public function build() { return $this->subject('您的商品库存不足-' . config('app.name'))->view('emails.product_count_warn'); } } \ No newline at end of file +namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; class ProductCountWarn extends Mailable { use Queueable, SerializesModels; public $product = null; public $product_count = null; public function __construct($sp9dfc99, $sp235148) { $this->product = $sp9dfc99; $this->product_count = $sp235148; } public function build() { return $this->subject('您的商品库存不足-' . config('app.name'))->view('emails.product_count_warn'); } } \ No newline at end of file diff --git a/app/Order.php b/app/Order.php index 61410fe95..13406aca9 100644 --- a/app/Order.php +++ b/app/Order.php @@ -1,2 +1,2 @@ '未支付', 1 => '未发货', 2 => '已发货', 3 => '已冻结', 4 => '已退款'); const SEND_STATUS_UN = 0; const SEND_STATUS_EMAIL_SUCCESS = 1; const SEND_STATUS_EMAIL_FAILED = 2; const SEND_STATUS_MOBILE_SUCCESS = 3; const SEND_STATUS_MOBILE_FAILED = 4; const SEND_STATUS_CARD_UN = 100; const SEND_STATUS_CARD_PROCESSING = 101; const SEND_STATUS_CARD_SUCCESS = 102; const SEND_STATUS_CARD_FAILED = 103; protected $casts = array('api_info' => 'array'); public static function unique_no() { $sp0dbaa3 = date('YmdHis') . str_random(5); while (\App\Order::where('order_no', $sp0dbaa3)->exists()) { $sp0dbaa3 = date('YmdHis') . str_random(5); } return $sp0dbaa3; } function user() { return $this->belongsTo(User::class); } function product() { return $this->belongsTo(Product::class); } function pay() { return $this->belongsTo(Pay::class); } function cards() { $sp1938e8 = $this->belongsToMany(Card::class); return $sp1938e8->withTrashed(); } function card_orders() { return $this->hasMany(CardOrder::class); } function fundRecord() { return $this->hasMany(FundRecord::class); } function getCardsArray() { $sp16ec83 = array(); $this->cards->each(function ($sp089eb8) use(&$sp16ec83) { $sp16ec83[] = $sp089eb8->card; }); return $sp16ec83; } function getSendMessage() { if (count($this->cards)) { if (count($this->cards) == $this->count) { $spcbea9e = '订单#' . $this->order_no . ' 已支付,您购买的内容如下:'; } else { if ($this->cards[0]->type === \App\Card::TYPE_REPEAT || @$this->product->delivery === \App\Product::DELIVERY_MANUAL) { $spcbea9e = '订单#' . $this->order_no . ' 已支付,您购买的内容如下:'; } else { $spcbea9e = '订单#' . $this->order_no . ' 已支付,目前库存不足,您还有' . ($this->count - count($this->cards)) . '件未发货,请联系商家客服发货
已发货商品见下方:
'; $spcbea9e .= '商家客服QQ:' . $this->user->qq . '
'; } } } else { $spcbea9e = '订单#' . $this->order_no . ' 已支付,目前库存不足,您购买的' . ($this->count - count($this->cards)) . '件未发货,请联系商家客服发货
'; $spcbea9e .= '商家客服QQ:' . $this->user->qq . '
'; } return $spcbea9e; } function sendEmail($sp98ce8d = false) { if ($sp98ce8d === false) { $sp98ce8d = @json_decode($this->contact_ext)['_mail']; } if (!$sp98ce8d || !@filter_var($sp98ce8d, FILTER_VALIDATE_EMAIL)) { return; } $sp16ec83 = $this->getCardsArray(); try { Mail::to($sp98ce8d)->Queue(new OrderShipped($this, $this->getSendMessage(), join('
', $sp16ec83))); $this->send_status = \App\Order::SEND_STATUS_EMAIL_SUCCESS; $this->saveOrFail(); } catch (\Throwable $sp45f5f1) { $this->send_status = \App\Order::SEND_STATUS_EMAIL_FAILED; $this->saveOrFail(); LogHelper::setLogFile('mail'); LogWriter::error('Order.sendEmail error', array('order_no' => $this->order_no, 'email' => $sp98ce8d, 'cards' => $sp16ec83, 'exception' => $sp45f5f1->getMessage())); LogHelper::setLogFile('card'); } } function sendSms($spd9b726 = false) { if ($spd9b726 === false) { $spd9b726 = @json_decode($this->contact_ext)['_mobile']; } if (!$spd9b726 || strlen($spd9b726) !== 11) { return; } OrderSms::dispatch($spd9b726, $this); } } \ No newline at end of file +namespace App; use App\Jobs\OrderSms; use App\Library\LogHelper; use App\Mail\OrderShipped; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Log as LogWriter; class Order extends Model { protected $guarded = array(); const STATUS_UNPAY = 0; const STATUS_PAID = 1; const STATUS_SUCCESS = 2; const STATUS_FROZEN = 3; const STATUS_REFUND = 4; const STATUS = array(0 => '未支付', 1 => '未发货', 2 => '已发货', 3 => '已冻结', 4 => '已退款'); const SEND_STATUS_UN = 0; const SEND_STATUS_EMAIL_SUCCESS = 1; const SEND_STATUS_EMAIL_FAILED = 2; const SEND_STATUS_MOBILE_SUCCESS = 3; const SEND_STATUS_MOBILE_FAILED = 4; const SEND_STATUS_CARD_UN = 100; const SEND_STATUS_CARD_PROCESSING = 101; const SEND_STATUS_CARD_SUCCESS = 102; const SEND_STATUS_CARD_FAILED = 103; protected $casts = array('api_info' => 'array'); public static function unique_no() { $spf34e1a = date('YmdHis') . str_random(5); while (\App\Order::where('order_no', $spf34e1a)->exists()) { $spf34e1a = date('YmdHis') . str_random(5); } return $spf34e1a; } function user() { return $this->belongsTo(User::class); } function product() { return $this->belongsTo(Product::class); } function pay() { return $this->belongsTo(Pay::class); } function cards() { $sp17764c = $this->belongsToMany(Card::class); return $sp17764c->withTrashed(); } function card_orders() { return $this->hasMany(CardOrder::class); } function fundRecord() { return $this->hasMany(FundRecord::class); } function getCardsArray() { $sp137cd7 = array(); $this->cards->each(function ($spa9cef2) use(&$sp137cd7) { $sp137cd7[] = $spa9cef2->card; }); return $sp137cd7; } function getSendMessage() { if (count($this->cards)) { if (count($this->cards) == $this->count) { $spe94958 = '订单#' . $this->order_no . ' 已支付,您购买的内容如下:'; } else { if ($this->cards[0]->type === \App\Card::TYPE_REPEAT || @$this->product->delivery === \App\Product::DELIVERY_MANUAL) { $spe94958 = '订单#' . $this->order_no . ' 已支付,您购买的内容如下:'; } else { $spe94958 = '订单#' . $this->order_no . ' 已支付,目前库存不足,您还有' . ($this->count - count($this->cards)) . '件未发货,请联系商家客服发货
已发货商品见下方:
'; $spe94958 .= '商家客服QQ:' . $this->user->qq . '
'; } } } else { $spe94958 = '订单#' . $this->order_no . ' 已支付,目前库存不足,您购买的' . ($this->count - count($this->cards)) . '件未发货,请联系商家客服发货
'; $spe94958 .= '商家客服QQ:' . $this->user->qq . '
'; } return $spe94958; } function sendEmail($spdf69a9 = false) { if ($spdf69a9 === false) { $spdf69a9 = @json_decode($this->contact_ext)['_mail']; } if (!$spdf69a9 || !@filter_var($spdf69a9, FILTER_VALIDATE_EMAIL)) { return; } $sp137cd7 = $this->getCardsArray(); try { Mail::to($spdf69a9)->Queue(new OrderShipped($this, $this->getSendMessage(), join('
', $sp137cd7))); $this->send_status = \App\Order::SEND_STATUS_EMAIL_SUCCESS; $this->saveOrFail(); } catch (\Throwable $sp6a7295) { $this->send_status = \App\Order::SEND_STATUS_EMAIL_FAILED; $this->saveOrFail(); LogHelper::setLogFile('mail'); LogWriter::error('Order.sendEmail error', array('order_no' => $this->order_no, 'email' => $spdf69a9, 'cards' => $sp137cd7, 'exception' => $sp6a7295->getMessage())); LogHelper::setLogFile('card'); } } function sendSms($spcd62a5 = false) { if ($spcd62a5 === false) { $spcd62a5 = @json_decode($this->contact_ext)['_mobile']; } if (!$spcd62a5 || strlen($spcd62a5) !== 11) { return; } OrderSms::dispatch($spcd62a5, $this); } } \ No newline at end of file diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index c7528f3e0..6dedd850c 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -1,2 +1,2 @@ id, Helper::ID_TYPE_PRODUCT); } function getCountAttribute() { return $this->count_all - $this->count_sold; } function category() { return $this->belongsTo(Category::class); } function cards() { return $this->hasMany(Card::class); } function coupons() { return $this->hasMany(Coupon::class); } function orders() { return $this->hasMany(Order::class); } function user() { return $this->belongsTo(User::class); } public static function refreshCount($sp845283) { \App\Card::where('user_id', $sp845283->id)->selectRaw('`product_id`,SUM(`count_sold`) as `count_sold`,SUM(`count_all`) as `count_all`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(1000, function ($sp5b0739) { foreach ($sp5b0739 as $sp1d0a77) { $sp1a3ec5 = \App\Product::where('id', $sp1d0a77->product_id)->first(); if ($sp1a3ec5) { if ($sp1a3ec5->delivery === \App\Product::DELIVERY_MANUAL) { $sp1a3ec5->update(array('count_sold' => $sp1d0a77->count_sold)); } else { $sp1a3ec5->update(array('count_sold' => $sp1d0a77->count_sold, 'count_all' => $sp1d0a77->count_all)); } } else { } } }); } function createApiCards($sp7b2cfc) { $spd93a9d = array(); $spae5ca3 = array(); $spb16993 = array(); for ($spe20094 = 0; $spe20094 < $sp7b2cfc->count; $spe20094++) { $spd93a9d[] = strtoupper(str_random(16)); $sp6030dc = date('Y-m-d H:i:s'); switch ($this->id) { case 6: $sp1f13cd = 1; break; case 11: $sp1f13cd = 2; break; case 37: $sp1f13cd = 3; break; default: die('App.Products fatal error#1'); } $spb16993[] = array('user_id' => $this->user_id, 'product_id' => $this->id, 'card' => $spd93a9d[$spe20094], 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1); $spae5ca3[] = "(NULL, '{$spd93a9d[$spe20094]}', '1', '{$sp1f13cd}', NULL, NULL, NULL, NULL, NULL, '0', '{$sp6030dc}', '0000-00-00 00:00:00')"; } $sp1c15be = mysqli_connect('localhost', 'udiddz', 'tRihPm3sh6yKedtX', 'udiddz', '3306'); $sp3a97ab = 'INSERT INTO `udiddz`.`ac_kms` (`id`, `km`, `value`, `task`, `udid`, `diz`, `task_id`, `install_url`, `plist_url`, `jh`, `addtime`, `tjtime`) VALUES ' . join(',', $spae5ca3); $sp815cba = mysqli_query($sp1c15be, $sp3a97ab); if (!$sp815cba) { LogWriter::error('App.Products, connect udid database failed', array('sql' => $sp3a97ab, 'error' => mysqli_error($sp1c15be))); return array(); } $this->count_all += $sp7b2cfc->count; return $this->cards()->createMany($spb16993); } function setForShop($sp845283 = null) { $sp1a3ec5 = $this; $spdf4a99 = $sp1a3ec5->count; $sp6b4f6d = $sp1a3ec5->inventory; if ($sp6b4f6d == User::INVENTORY_AUTO) { $sp6b4f6d = System::_getInt('shop_inventory'); } if ($sp6b4f6d == User::INVENTORY_RANGE) { if ($spdf4a99 <= 0) { $sp0b9d8a = '不足'; } elseif ($spdf4a99 <= 10) { $sp0b9d8a = '少量'; } elseif ($spdf4a99 <= 20) { $sp0b9d8a = '一般'; } else { $sp0b9d8a = '大量'; } $sp1a3ec5->setAttribute('count2', $sp0b9d8a); } else { $sp1a3ec5->setAttribute('count2', $spdf4a99); } $sp1a3ec5->setAttribute('count', $spdf4a99); $sp1a3ec5->setVisible(array('id', 'name', 'description', 'fields', 'delivery', 'count', 'count2', 'buy_min', 'buy_max', 'support_coupon', 'password_open', 'price', 'price_whole')); } } \ No newline at end of file +namespace App; use App\Library\Helper; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Log as LogWriter; class Product extends Model { protected $guarded = array(); protected $hidden = array(); const ID_API = -1001; const DELIVERY_AUTO = 0; const DELIVERY_MANUAL = 1; const DELIVERY_API = 2; function getUrlAttribute() { return config('app.url') . '/p/' . Helper::id_encode($this->id, Helper::ID_TYPE_PRODUCT); } function getCountAttribute() { return $this->count_all - $this->count_sold; } function category() { return $this->belongsTo(Category::class); } function cards() { return $this->hasMany(Card::class); } function coupons() { return $this->hasMany(Coupon::class); } function orders() { return $this->hasMany(Order::class); } function user() { return $this->belongsTo(User::class); } public static function refreshCount($spac34b1) { \App\Card::where('user_id', $spac34b1->id)->selectRaw('`product_id`,SUM(`count_sold`) as `count_sold`,SUM(`count_all`) as `count_all`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(1000, function ($sp43445b) { foreach ($sp43445b as $sp78bb46) { $sp9dfc99 = \App\Product::where('id', $sp78bb46->product_id)->first(); if ($sp9dfc99) { if ($sp9dfc99->delivery === \App\Product::DELIVERY_MANUAL) { $sp9dfc99->update(array('count_sold' => $sp78bb46->count_sold)); } else { $sp9dfc99->update(array('count_sold' => $sp78bb46->count_sold, 'count_all' => $sp78bb46->count_all)); } } else { } } }); } function createApiCards($spedec71) { $sp8627ee = array(); $sp8eba90 = array(); $sp9f186e = array(); for ($spc8f255 = 0; $spc8f255 < $spedec71->count; $spc8f255++) { $sp8627ee[] = strtoupper(str_random(16)); $sp85ce68 = date('Y-m-d H:i:s'); switch ($this->id) { case 6: $sp7a1e84 = 1; break; case 11: $sp7a1e84 = 2; break; case 37: $sp7a1e84 = 3; break; default: die('App.Products fatal error#1'); } $sp9f186e[] = array('user_id' => $this->user_id, 'product_id' => $this->id, 'card' => $sp8627ee[$spc8f255], 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1); $sp8eba90[] = "(NULL, '{$sp8627ee[$spc8f255]}', '1', '{$sp7a1e84}', NULL, NULL, NULL, NULL, NULL, '0', '{$sp85ce68}', '0000-00-00 00:00:00')"; } $spd38dc6 = mysqli_connect('localhost', 'udiddz', 'tRihPm3sh6yKedtX', 'udiddz', '3306'); $sp28e1e9 = 'INSERT INTO `udiddz`.`ac_kms` (`id`, `km`, `value`, `task`, `udid`, `diz`, `task_id`, `install_url`, `plist_url`, `jh`, `addtime`, `tjtime`) VALUES ' . join(',', $sp8eba90); $sp162b98 = mysqli_query($spd38dc6, $sp28e1e9); if (!$sp162b98) { LogWriter::error('App.Products, connect udid database failed', array('sql' => $sp28e1e9, 'error' => mysqli_error($spd38dc6))); return array(); } $this->count_all += $spedec71->count; return $this->cards()->createMany($sp9f186e); } function setForShop($spac34b1 = null) { $sp9dfc99 = $this; $sp99aae1 = $sp9dfc99->count; $sp7d508e = $sp9dfc99->inventory; if ($sp7d508e == User::INVENTORY_AUTO) { $sp7d508e = System::_getInt('shop_inventory'); } if ($sp7d508e == User::INVENTORY_RANGE) { if ($sp99aae1 <= 0) { $spb54b58 = '不足'; } elseif ($sp99aae1 <= 10) { $spb54b58 = '少量'; } elseif ($sp99aae1 <= 20) { $spb54b58 = '一般'; } else { $spb54b58 = '大量'; } $sp9dfc99->setAttribute('count2', $spb54b58); } else { $sp9dfc99->setAttribute('count2', $sp99aae1); } $sp9dfc99->setAttribute('count', $sp99aae1); $sp9dfc99->setVisible(array('id', 'name', 'description', 'fields', 'delivery', 'count', 'count2', 'buy_min', 'buy_max', 'support_coupon', 'password_open', 'price', 'price_whole')); } } \ No newline at end of file diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index 76950dd83..fff4c5641 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -1,2 +1,2 @@ set(array('app.project' => 'card_free', 'app.version' => '2.95d', 'app.name' => System::_get('app_name'), 'app.title' => System::_get('app_title'), 'app.url' => System::_get('app_url'), 'app.url_api' => System::_get('app_url_api'), 'app.logo' => System::_get('logo'), 'app.description' => System::_get('description'), 'app.keywords' => System::_get('keywords'), 'app.company' => System::_get('company'), 'app.icp' => System::_get('icp'), 'services.geetest.id' => System::_get('vcode_geetest_id'), 'services.geetest.key' => System::_get('vcode_geetest_key'), 'mail.driver' => System::_get('mail_driver'), 'mail.host' => System::_get('mail_smtp_host'), 'mail.port' => System::_get('mail_smtp_port'), 'mail.username' => System::_get('mail_smtp_username'), 'mail.password' => System::_get('mail_smtp_password'), 'mail.from.address' => System::_get('mail_smtp_from_address'), 'mail.from.name' => System::_get('mail_smtp_from_name'), 'mail.encryption' => System::_get('mail_smtp_encryption') === 'null' ? null : System::_get('mail_smtp_encryption'), 'services.sendcloud.api_user' => System::_get('sendcloud_user'), 'services.sendcloud.api_key' => System::_get('sendcloud_key'), 'filesystems.default' => System::_get('storage_driver'), 'filesystems.disks.s3.key' => System::_get('storage_s3_access_key'), 'filesystems.disks.s3.secret' => System::_get('storage_s3_secret_key'), 'filesystems.disks.s3.region' => System::_get('storage_s3_region'), 'filesystems.disks.s3.bucket' => System::_get('storage_s3_bucket'), 'filesystems.disks.oss.access_id' => System::_get('storage_oss_access_key'), 'filesystems.disks.oss.access_key' => System::_get('storage_oss_secret_key'), 'filesystems.disks.oss.bucket' => System::_get('storage_oss_bucket'), 'filesystems.disks.oss.endpoint' => System::_get('storage_oss_endpoint'), 'filesystems.disks.oss.cdnDomain' => System::_get('storage_oss_cdn_domain'), 'filesystems.disks.oss.ssl' => (int) System::_get('storage_oss_is_ssl') === 1, 'filesystems.disks.oss.isCName' => (int) System::_get('storage_oss_is_cname') === 1, 'filesystems.disks.qiniu.access_key' => System::_get('storage_qiniu_access_key'), 'filesystems.disks.qiniu.secret_key' => System::_get('storage_qiniu_secret_key'), 'filesystems.disks.qiniu.bucket' => System::_get('storage_qiniu_bucket'), 'filesystems.disks.qiniu.domains.default' => System::_get('storage_qiniu_domains_default'), 'filesystems.disks.qiniu.domains.https' => System::_get('storage_qiniu_domains_https'))); } catch (\Exception $sp45f5f1) { \Log::error('Config init failed: ' . $sp45f5f1->getMessage(), array('exception' => $sp45f5f1)); } } public function register() { } } \ No newline at end of file +namespace App\Providers; use App\System; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; class ConfigServiceProvider extends ServiceProvider { public function boot() { try { config()->set(array('app.project' => 'card_free', 'app.version' => '2.95d', 'app.name' => System::_get('app_name'), 'app.title' => System::_get('app_title'), 'app.url' => System::_get('app_url'), 'app.url_api' => System::_get('app_url_api'), 'app.logo' => System::_get('logo'), 'app.description' => System::_get('description'), 'app.keywords' => System::_get('keywords'), 'app.company' => System::_get('company'), 'app.icp' => System::_get('icp'), 'services.geetest.id' => System::_get('vcode_geetest_id'), 'services.geetest.key' => System::_get('vcode_geetest_key'), 'mail.driver' => System::_get('mail_driver'), 'mail.host' => System::_get('mail_smtp_host'), 'mail.port' => System::_get('mail_smtp_port'), 'mail.username' => System::_get('mail_smtp_username'), 'mail.password' => System::_get('mail_smtp_password'), 'mail.from.address' => System::_get('mail_smtp_from_address'), 'mail.from.name' => System::_get('mail_smtp_from_name'), 'mail.encryption' => System::_get('mail_smtp_encryption') === 'null' ? null : System::_get('mail_smtp_encryption'), 'services.sendcloud.api_user' => System::_get('sendcloud_user'), 'services.sendcloud.api_key' => System::_get('sendcloud_key'), 'filesystems.default' => System::_get('storage_driver'), 'filesystems.disks.s3.key' => System::_get('storage_s3_access_key'), 'filesystems.disks.s3.secret' => System::_get('storage_s3_secret_key'), 'filesystems.disks.s3.region' => System::_get('storage_s3_region'), 'filesystems.disks.s3.bucket' => System::_get('storage_s3_bucket'), 'filesystems.disks.oss.access_id' => System::_get('storage_oss_access_key'), 'filesystems.disks.oss.access_key' => System::_get('storage_oss_secret_key'), 'filesystems.disks.oss.bucket' => System::_get('storage_oss_bucket'), 'filesystems.disks.oss.endpoint' => System::_get('storage_oss_endpoint'), 'filesystems.disks.oss.cdnDomain' => System::_get('storage_oss_cdn_domain'), 'filesystems.disks.oss.ssl' => (int) System::_get('storage_oss_is_ssl') === 1, 'filesystems.disks.oss.isCName' => (int) System::_get('storage_oss_is_cname') === 1, 'filesystems.disks.qiniu.access_key' => System::_get('storage_qiniu_access_key'), 'filesystems.disks.qiniu.secret_key' => System::_get('storage_qiniu_secret_key'), 'filesystems.disks.qiniu.bucket' => System::_get('storage_qiniu_bucket'), 'filesystems.disks.qiniu.domains.default' => System::_get('storage_qiniu_domains_default'), 'filesystems.disks.qiniu.domains.https' => System::_get('storage_qiniu_domains_https'))); } catch (\Exception $sp6a7295) { \Log::error('Config init failed: ' . $sp6a7295->getMessage(), array('exception' => $sp6a7295)); } } public function register() { } } \ No newline at end of file diff --git a/app/ShopTheme.php b/app/ShopTheme.php index 0a1d56d98..9fe5c6009 100644 --- a/app/ShopTheme.php +++ b/app/ShopTheme.php @@ -1,2 +1,2 @@ 'array', 'config' => 'array'); private static $default_theme; public static function defaultTheme() { if (!static::$default_theme) { static::$default_theme = ShopTheme::query()->where('name', \App\System::_get('shop_theme_default', 'Material'))->first(); if (!static::$default_theme) { static::$default_theme = ShopTheme::query()->firstOrFail(); } } return static::$default_theme; } public static function freshList() { $spde3d9c = realpath(app_path('..' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'shop_theme')); \App\ShopTheme::query()->get()->each(function ($spe0ff89) use($spde3d9c) { if (!file_exists($spde3d9c . DIRECTORY_SEPARATOR . $spe0ff89->name . DIRECTORY_SEPARATOR . 'config.php')) { $spe0ff89->delete(); } }); foreach (scandir($spde3d9c) as $sp45207a) { if ($sp45207a === '.' || $sp45207a === '..') { continue; } try { @($spe0ff89 = (include $spde3d9c . DIRECTORY_SEPARATOR . $sp45207a . DIRECTORY_SEPARATOR . 'config.php')); } catch (\Exception $sp45f5f1) { continue; } $spe0ff89['config'] = array_map(function ($spc6f905) { return $spc6f905['value']; }, @$spe0ff89['options'] ?? array()); $sp5fd1b4 = \App\ShopTheme::query()->where('name', $sp45207a)->first(); if ($sp5fd1b4) { $sp5fd1b4->description = $spe0ff89['description']; $sp5fd1b4->options = @$spe0ff89['options'] ?? array(); $sp5fd1b4->config = ($sp5fd1b4->config ?? array()) + $spe0ff89['config']; $sp5fd1b4->saveOrFail(); } else { if ($spe0ff89 && isset($spe0ff89['description'])) { \App\ShopTheme::query()->create(array('name' => $sp45207a, 'description' => $spe0ff89['description'], 'options' => @$spe0ff89['options'] ?? array(), 'config' => $spe0ff89['config'])); } } } } } \ No newline at end of file +namespace App; use Illuminate\Database\Eloquent\Model; class ShopTheme extends Model { protected $guarded = array(); public $timestamps = false; protected $casts = array('options' => 'array', 'config' => 'array'); private static $default_theme; public static function defaultTheme() { if (!static::$default_theme) { static::$default_theme = ShopTheme::query()->where('name', \App\System::_get('shop_theme_default', 'Material'))->first(); if (!static::$default_theme) { static::$default_theme = ShopTheme::query()->firstOrFail(); } } return static::$default_theme; } public static function freshList() { $spffbc51 = realpath(app_path('..' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'shop_theme')); \App\ShopTheme::query()->get()->each(function ($sp6612a9) use($spffbc51) { if (!file_exists($spffbc51 . DIRECTORY_SEPARATOR . $sp6612a9->name . DIRECTORY_SEPARATOR . 'config.php')) { $sp6612a9->delete(); } }); foreach (scandir($spffbc51) as $sp4d4390) { if ($sp4d4390 === '.' || $sp4d4390 === '..') { continue; } try { @($sp6612a9 = (include $spffbc51 . DIRECTORY_SEPARATOR . $sp4d4390 . DIRECTORY_SEPARATOR . 'config.php')); } catch (\Exception $sp6a7295) { continue; } $sp6612a9['config'] = array_map(function ($spbdd4b3) { return $spbdd4b3['value']; }, @$sp6612a9['options'] ?? array()); $sp31e536 = \App\ShopTheme::query()->where('name', $sp4d4390)->first(); if ($sp31e536) { $sp31e536->description = $sp6612a9['description']; $sp31e536->options = @$sp6612a9['options'] ?? array(); $sp31e536->config = ($sp31e536->config ?? array()) + $sp6612a9['config']; $sp31e536->saveOrFail(); } else { if ($sp6612a9 && isset($sp6612a9['description'])) { \App\ShopTheme::query()->create(array('name' => $sp4d4390, 'description' => $sp6612a9['description'], 'options' => @$sp6612a9['options'] ?? array(), 'config' => $sp6612a9['config'])); } } } } } \ No newline at end of file diff --git a/app/System.php b/app/System.php index 41df5fa60..d72764efa 100644 --- a/app/System.php +++ b/app/System.php @@ -1,2 +1,2 @@ get()->toArray(); foreach ($sp4b367b as $sp838de4) { static::$systems[$sp838de4['name']] = $sp838de4['value']; } return static::$systems; }); static::$systems['_initialized'] = true; } public static function _get($sp104c39, $spa5f8fb = NULL) { if (!isset(static::$systems['_initialized'])) { static::_init(); } if (isset(static::$systems[$sp104c39])) { return static::$systems[$sp104c39]; } return $spa5f8fb; } public static function _getInt($sp104c39, $spa5f8fb = NULL) { return (int) static::_get($sp104c39, $spa5f8fb); } public static function _set($sp104c39, $sp1b5dd9) { static::$systems[$sp104c39] = $sp1b5dd9; $spc0aae1 = System::query()->where('name', $sp104c39)->first(); if ($spc0aae1) { $spc0aae1->value = $sp1b5dd9; $spc0aae1->save(); } else { try { System::query()->insert(array('name' => $sp104c39, 'value' => $sp1b5dd9)); } catch (\Exception $sp45f5f1) { } } self::flushCache(); } public static function flushCache() { Log::debug('SystemSetting.flushCache'); Cache::forget('settings.all'); } protected static function boot() { parent::boot(); static::updated(function () { self::flushCache(); }); static::created(function () { self::flushCache(); }); } } \ No newline at end of file +namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Log; class System extends Model { protected $guarded = array(); private static $systems = array(); public static function _init() { static::$systems = Cache::remember('settings.all', 1, function () { $sp1d893d = System::query()->get()->toArray(); foreach ($sp1d893d as $spbaf206) { static::$systems[$spbaf206['name']] = $spbaf206['value']; } return static::$systems; }); static::$systems['_initialized'] = true; } public static function _get($sp387f04, $sp8cd907 = NULL) { if (!isset(static::$systems['_initialized'])) { static::_init(); } if (isset(static::$systems[$sp387f04])) { return static::$systems[$sp387f04]; } return $sp8cd907; } public static function _getInt($sp387f04, $sp8cd907 = NULL) { return (int) static::_get($sp387f04, $sp8cd907); } public static function _set($sp387f04, $sp4a2047) { static::$systems[$sp387f04] = $sp4a2047; $spa1e244 = System::query()->where('name', $sp387f04)->first(); if ($spa1e244) { $spa1e244->value = $sp4a2047; $spa1e244->save(); } else { try { System::query()->insert(array('name' => $sp387f04, 'value' => $sp4a2047)); } catch (\Exception $sp6a7295) { } } self::flushCache(); } public static function flushCache() { Log::debug('SystemSetting.flushCache'); Cache::forget('settings.all'); } protected static function boot() { parent::boot(); static::updated(function () { self::flushCache(); }); static::created(function () { self::flushCache(); }); } } \ No newline at end of file diff --git a/app/User.php b/app/User.php index 2edff8900..1a8c71341 100644 --- a/app/User.php +++ b/app/User.php @@ -1,2 +1,2 @@ 'array'); const ID_CUSTOMER = -1; const INVENTORY_RANGE = 0; const INVENTORY_REAL = 1; const INVENTORY_AUTO = 2; const FEE_TYPE_MERCHANT = 0; const FEE_TYPE_CUSTOMER = 1; const FEE_TYPE_AUTO = 2; const STATUS_OK = 0; const STATUS_FROZEN = 1; function getMBalanceAttribute() { return $this->m_all - $this->m_paid - $this->m_frozen; } function getRoleAttribute() { return 'admin'; } function getMBalanceWithoutTodayAttribute() { $sp9f0f5a = (int) \App\Order::where('user_id', $this->user_id)->where('status', \App\Order::STATUS_SUCCESS)->whereDate('paid_at', Carbon::today())->sum('income'); return $this->m_all - $this->m_paid - $this->m_frozen - $sp9f0f5a; } function getShopThemeAttribute() { if ($this->theme_config) { $sp786169 = \App\ShopTheme::whereName($this->theme_config['theme'])->first(); if ($sp786169) { return $sp786169; } } return \App\ShopTheme::defaultTheme(); } function categories() { return $this->hasMany(Category::class); } function products() { return $this->hasMany(Product::class); } function cards() { return $this->hasMany(Card::class); } function orders() { return $this->hasMany(Order::class); } function coupons() { return $this->hasMany(Coupon::class); } function logs() { return $this->hasMany(Log::class); } function shop_theme() { return $this->belongsTo(ShopTheme::class); } } \ No newline at end of file +namespace App; use Carbon\Carbon; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; protected $guarded = array(); protected $hidden = array('password', 'remember_token'); protected $appends = array('m_balance', 'role'); protected $casts = array('theme_config' => 'array'); const ID_CUSTOMER = -1; const INVENTORY_RANGE = 0; const INVENTORY_REAL = 1; const INVENTORY_AUTO = 2; const FEE_TYPE_MERCHANT = 0; const FEE_TYPE_CUSTOMER = 1; const FEE_TYPE_AUTO = 2; const STATUS_OK = 0; const STATUS_FROZEN = 1; function getMBalanceAttribute() { return $this->m_all - $this->m_paid - $this->m_frozen; } function getRoleAttribute() { return 'admin'; } function getMBalanceWithoutTodayAttribute() { $sp0d15e7 = (int) \App\Order::where('user_id', $this->user_id)->where('status', \App\Order::STATUS_SUCCESS)->whereDate('paid_at', Carbon::today())->sum('income'); return $this->m_all - $this->m_paid - $this->m_frozen - $sp0d15e7; } function getShopThemeAttribute() { if ($this->theme_config) { $sp5359c9 = \App\ShopTheme::whereName($this->theme_config['theme'])->first(); if ($sp5359c9) { return $sp5359c9; } } return \App\ShopTheme::defaultTheme(); } function categories() { return $this->hasMany(Category::class); } function products() { return $this->hasMany(Product::class); } function cards() { return $this->hasMany(Card::class); } function orders() { return $this->hasMany(Order::class); } function coupons() { return $this->hasMany(Coupon::class); } function logs() { return $this->hasMany(Log::class); } function shop_theme() { return $this->belongsTo(ShopTheme::class); } } \ No newline at end of file diff --git a/bootstrap/app.php b/bootstrap/app.php index 3a6fbd9b8..83f641124 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,2 +1,2 @@ singleton(Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class); $sped665a->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class); $sped665a->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class); return $sped665a; \ No newline at end of file +$spe4a088 = new Illuminate\Foundation\Application(realpath(__DIR__ . '/../')); $spe4a088->singleton(Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class); $spe4a088->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class); $spe4a088->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class); return $spe4a088; \ No newline at end of file diff --git a/database/factories/OrderFactory.php b/database/factories/OrderFactory.php index 1851820a6..ec0242ace 100644 --- a/database/factories/OrderFactory.php +++ b/database/factories/OrderFactory.php @@ -1,2 +1,2 @@ define(App\Order::class, function (Faker $sp5d54bf) { $sp0dbaa3 = date('YmdHis') . mt_rand(10000, 99999); while (\App\Order::whereOrderNo($sp0dbaa3)->exists()) { $sp0dbaa3 = date('YmdHis') . mt_rand(10000, 99999); } $spd347b9 = random_int(0, 1) ? $sp5d54bf->email : 'user01@qq.com'; $sp2a8f2c = 1000; $spbd8327 = random_int(0, 1) * 100; $sp906ef5 = $sp2a8f2c - $spbd8327; return array('user_id' => 2, 'order_no' => $sp0dbaa3, 'product_id' => 1, 'count' => 1); }); \ No newline at end of file +use Faker\Generator as Faker; $spdd02e4->define(App\Order::class, function (Faker $speabcec) { $spf34e1a = date('YmdHis') . mt_rand(10000, 99999); while (\App\Order::whereOrderNo($spf34e1a)->exists()) { $spf34e1a = date('YmdHis') . mt_rand(10000, 99999); } $sp667296 = random_int(0, 1) ? $speabcec->email : 'user01@qq.com'; $sp61875e = 1000; $sp2b7b41 = random_int(0, 1) * 100; $sp323589 = $sp61875e - $sp2b7b41; return array('user_id' => 2, 'order_no' => $spf34e1a, 'product_id' => 1, 'count' => 1); }); \ No newline at end of file diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index f7bafd3e7..d1e68ab7f 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->string('email', 100)->unique(); $sp79d26d->string('mobile')->nullable(); $sp79d26d->string('password', 100); $sp79d26d->integer('m_paid')->default(0); $sp79d26d->integer('m_frozen')->default(0); $sp79d26d->integer('m_all')->default(0); $sp79d26d->rememberToken(); $sp79d26d->timestamps(); }); } public function down() { Schema::dropIfExists('users'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { public function up() { Schema::create('users', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->string('email', 100)->unique(); $sp580417->string('mobile')->nullable(); $sp580417->string('password', 100); $sp580417->integer('m_paid')->default(0); $sp580417->integer('m_frozen')->default(0); $sp580417->integer('m_all')->default(0); $sp580417->rememberToken(); $sp580417->timestamps(); }); } public function down() { Schema::dropIfExists('users'); } } \ No newline at end of file diff --git a/database/migrations/2017_12_23_223031_create_categories_table.php b/database/migrations/2017_12_23_223031_create_categories_table.php index 2af0b3208..a3a56a91d 100644 --- a/database/migrations/2017_12_23_223031_create_categories_table.php +++ b/database/migrations/2017_12_23_223031_create_categories_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('user_id')->index(); $sp79d26d->text('name'); $sp79d26d->integer('sort')->default(1000); $sp79d26d->string('password')->nullable(); $sp79d26d->boolean('password_open')->default(false); $sp79d26d->boolean('enabled'); $sp79d26d->timestamps(); }); } public function down() { Schema::dropIfExists('groups'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCategoriesTable extends Migration { public function up() { Schema::create('categories', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('user_id')->index(); $sp580417->text('name'); $sp580417->integer('sort')->default(1000); $sp580417->string('password')->nullable(); $sp580417->boolean('password_open')->default(false); $sp580417->boolean('enabled'); $sp580417->timestamps(); }); } public function down() { Schema::dropIfExists('groups'); } } \ No newline at end of file diff --git a/database/migrations/2017_12_23_223124_create_products_table.php b/database/migrations/2017_12_23_223124_create_products_table.php index c9932cb6b..e677ab4a9 100644 --- a/database/migrations/2017_12_23_223124_create_products_table.php +++ b/database/migrations/2017_12_23_223124_create_products_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('user_id')->index(); $sp79d26d->integer('category_id')->index(); $sp79d26d->string('name'); $sp79d26d->longText('description'); $sp79d26d->integer('sort')->default(1000); $sp79d26d->integer('buy_min')->default(1); $sp79d26d->integer('buy_max')->default(10); $sp79d26d->integer('count_sold')->default(0); $sp79d26d->integer('count_all')->default(0); $sp79d26d->integer('count_warn')->default(0); $sp79d26d->boolean('support_coupon')->default(false); $sp79d26d->string('password')->nullable(); $sp79d26d->boolean('password_open')->default(false); $sp79d26d->integer('cost')->default(0); $sp79d26d->integer('price'); $sp79d26d->text('price_whole')->nullable(); $sp79d26d->text('instructions')->nullable(); $sp79d26d->text('fields')->nullable(); $sp79d26d->boolean('enabled'); $sp79d26d->tinyInteger('inventory')->default(\App\User::INVENTORY_AUTO); $sp79d26d->tinyInteger('fee_type')->default(\App\User::FEE_TYPE_AUTO); $sp79d26d->tinyInteger('delivery')->default(\App\Product::DELIVERY_AUTO); $sp79d26d->timestamps(); }); } public function down() { Schema::dropIfExists('goods'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\DB; class CreateProductsTable extends Migration { public function up() { Schema::create('products', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('user_id')->index(); $sp580417->integer('category_id')->index(); $sp580417->string('name'); $sp580417->longText('description'); $sp580417->integer('sort')->default(1000); $sp580417->integer('buy_min')->default(1); $sp580417->integer('buy_max')->default(10); $sp580417->integer('count_sold')->default(0); $sp580417->integer('count_all')->default(0); $sp580417->integer('count_warn')->default(0); $sp580417->boolean('support_coupon')->default(false); $sp580417->string('password')->nullable(); $sp580417->boolean('password_open')->default(false); $sp580417->integer('cost')->default(0); $sp580417->integer('price'); $sp580417->text('price_whole')->nullable(); $sp580417->text('instructions')->nullable(); $sp580417->text('fields')->nullable(); $sp580417->boolean('enabled'); $sp580417->tinyInteger('inventory')->default(\App\User::INVENTORY_AUTO); $sp580417->tinyInteger('fee_type')->default(\App\User::FEE_TYPE_AUTO); $sp580417->tinyInteger('delivery')->default(\App\Product::DELIVERY_AUTO); $sp580417->timestamps(); }); } public function down() { Schema::dropIfExists('goods'); } } \ No newline at end of file diff --git a/database/migrations/2017_12_23_223252_create_cards_table.php b/database/migrations/2017_12_23_223252_create_cards_table.php index d58ed4262..d2662f44b 100644 --- a/database/migrations/2017_12_23_223252_create_cards_table.php +++ b/database/migrations/2017_12_23_223252_create_cards_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('user_id')->index(); $sp79d26d->integer('product_id')->index(); $sp79d26d->text('card'); $sp79d26d->integer('type'); $sp79d26d->integer('status')->default(\App\Card::STATUS_NORMAL); $sp79d26d->integer('count_sold')->default(0); $sp79d26d->integer('count_all')->default(1); $sp79d26d->timestamps(); $sp79d26d->softDeletes(); }); DB::unprepared('ALTER TABLE `cards` CHANGE COLUMN `created_at` `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP;'); } public function down() { Schema::dropIfExists('cards'); try { DB::unprepared('DROP PROCEDURE `add_cards`;'); } catch (\Exception $sp45f5f1) { } } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCardsTable extends Migration { public function up() { Schema::create('cards', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('user_id')->index(); $sp580417->integer('product_id')->index(); $sp580417->text('card'); $sp580417->integer('type'); $sp580417->integer('status')->default(\App\Card::STATUS_NORMAL); $sp580417->integer('count_sold')->default(0); $sp580417->integer('count_all')->default(1); $sp580417->timestamps(); $sp580417->softDeletes(); }); DB::unprepared('ALTER TABLE `cards` CHANGE COLUMN `created_at` `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP;'); } public function down() { Schema::dropIfExists('cards'); try { DB::unprepared('DROP PROCEDURE `add_cards`;'); } catch (\Exception $sp6a7295) { } } } \ No newline at end of file diff --git a/database/migrations/2017_12_23_223508_create_orders_table.php b/database/migrations/2017_12_23_223508_create_orders_table.php index a4db3e852..c595bdf7f 100644 --- a/database/migrations/2017_12_23_223508_create_orders_table.php +++ b/database/migrations/2017_12_23_223508_create_orders_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('user_id')->index(); $sp79d26d->string('order_no', 128)->index(); $sp79d26d->integer('product_id'); $sp79d26d->string('product_name')->nullable(); $sp79d26d->integer('count'); $sp79d26d->string('ip')->nullable(); $sp79d26d->string('customer', 32)->nullable(); $sp79d26d->string('contact')->nullable(); $sp79d26d->text('contact_ext')->nullable(); $sp79d26d->tinyInteger('send_status')->default(App\Order::SEND_STATUS_UN); $sp79d26d->text('remark')->nullable(); $sp79d26d->integer('cost')->default(0); $sp79d26d->integer('price')->default(0); $sp79d26d->integer('discount')->default(0); $sp79d26d->integer('paid')->default(0); $sp79d26d->integer('fee')->default(0); $sp79d26d->integer('system_fee')->default(0); $sp79d26d->integer('income')->default(0); $sp79d26d->integer('pay_id'); $sp79d26d->string('pay_trade_no')->nullable(); $sp79d26d->integer('status')->default(\App\Order::STATUS_UNPAY); $sp79d26d->string('frozen_reason')->nullable(); $sp79d26d->string('api_out_no', 128)->nullable(); $sp79d26d->text('api_info')->nullable(); $sp79d26d->dateTime('paid_at')->nullable(); $sp79d26d->timestamps(); }); } public function down() { Schema::dropIfExists('orders'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateOrdersTable extends Migration { public function up() { Schema::create('orders', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('user_id')->index(); $sp580417->string('order_no', 128)->index(); $sp580417->integer('product_id'); $sp580417->string('product_name')->nullable(); $sp580417->integer('count'); $sp580417->string('ip')->nullable(); $sp580417->string('customer', 32)->nullable(); $sp580417->string('contact')->nullable(); $sp580417->text('contact_ext')->nullable(); $sp580417->tinyInteger('send_status')->default(App\Order::SEND_STATUS_UN); $sp580417->text('remark')->nullable(); $sp580417->integer('cost')->default(0); $sp580417->integer('price')->default(0); $sp580417->integer('discount')->default(0); $sp580417->integer('paid')->default(0); $sp580417->integer('fee')->default(0); $sp580417->integer('system_fee')->default(0); $sp580417->integer('income')->default(0); $sp580417->integer('pay_id'); $sp580417->string('pay_trade_no')->nullable(); $sp580417->integer('status')->default(\App\Order::STATUS_UNPAY); $sp580417->string('frozen_reason')->nullable(); $sp580417->string('api_out_no', 128)->nullable(); $sp580417->text('api_info')->nullable(); $sp580417->dateTime('paid_at')->nullable(); $sp580417->timestamps(); }); } public function down() { Schema::dropIfExists('orders'); } } \ No newline at end of file diff --git a/database/migrations/2017_12_23_223755_create_pays_table.php b/database/migrations/2017_12_23_223755_create_pays_table.php index dc2ffda5d..eebdedc4d 100644 --- a/database/migrations/2017_12_23_223755_create_pays_table.php +++ b/database/migrations/2017_12_23_223755_create_pays_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->string('name'); $sp79d26d->integer('sort')->default(1000); $sp79d26d->string('img'); $sp79d26d->string('driver'); $sp79d26d->string('way'); $sp79d26d->text('config'); $sp79d26d->text('comment')->nullable(); $sp79d26d->float('fee_system', 8, 4)->default(0.01); $sp79d26d->boolean('enabled'); $sp79d26d->timestamps(); }); } public function down() { Schema::dropIfExists('pays'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreatePaysTable extends Migration { public function up() { Schema::create('pays', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->string('name'); $sp580417->integer('sort')->default(1000); $sp580417->string('img'); $sp580417->string('driver'); $sp580417->string('way'); $sp580417->text('config'); $sp580417->text('comment')->nullable(); $sp580417->float('fee_system', 8, 4)->default(0.01); $sp580417->boolean('enabled'); $sp580417->timestamps(); }); } public function down() { Schema::dropIfExists('pays'); } } \ No newline at end of file diff --git a/database/migrations/2018_01_02_142012_create_card_order_table.php b/database/migrations/2018_01_02_142012_create_card_order_table.php index dfb42a2bc..9a36829d0 100644 --- a/database/migrations/2018_01_02_142012_create_card_order_table.php +++ b/database/migrations/2018_01_02_142012_create_card_order_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('order_id')->index(); $sp79d26d->integer('card_id'); }); } public function down() { Schema::dropIfExists('card_order'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCardOrderTable extends Migration { public function up() { Schema::create('card_order', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('order_id')->index(); $sp580417->integer('card_id'); }); } public function down() { Schema::dropIfExists('card_order'); } } \ No newline at end of file diff --git a/database/migrations/2018_01_28_183143_create_coupons_table.php b/database/migrations/2018_01_28_183143_create_coupons_table.php index a4aca4f44..3435014a3 100644 --- a/database/migrations/2018_01_28_183143_create_coupons_table.php +++ b/database/migrations/2018_01_28_183143_create_coupons_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('user_id')->index(); $sp79d26d->integer('category_id')->default(-1); $sp79d26d->integer('product_id')->default(-1); $sp79d26d->integer('type')->default(\App\Coupon::TYPE_REPEAT); $sp79d26d->integer('status')->default(\App\Coupon::STATUS_NORMAL); $sp79d26d->string('coupon', 100)->index(); $sp79d26d->integer('discount_type'); $sp79d26d->integer('discount_val'); $sp79d26d->integer('count_used')->default(0); $sp79d26d->integer('count_all')->default(1); $sp79d26d->string('remark')->nullable(); $sp79d26d->dateTime('expire_at')->nullable(); $sp79d26d->timestamps(); }); } public function down() { Schema::dropIfExists('coupons'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCouponsTable extends Migration { public function up() { Schema::create('coupons', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('user_id')->index(); $sp580417->integer('category_id')->default(-1); $sp580417->integer('product_id')->default(-1); $sp580417->integer('type')->default(\App\Coupon::TYPE_REPEAT); $sp580417->integer('status')->default(\App\Coupon::STATUS_NORMAL); $sp580417->string('coupon', 100)->index(); $sp580417->integer('discount_type'); $sp580417->integer('discount_val'); $sp580417->integer('count_used')->default(0); $sp580417->integer('count_all')->default(1); $sp580417->string('remark')->nullable(); $sp580417->dateTime('expire_at')->nullable(); $sp580417->timestamps(); }); } public function down() { Schema::dropIfExists('coupons'); } } \ No newline at end of file diff --git a/database/migrations/2018_01_29_195459_create_logs_table.php b/database/migrations/2018_01_29_195459_create_logs_table.php index 925665104..5c8d3df62 100644 --- a/database/migrations/2018_01_29_195459_create_logs_table.php +++ b/database/migrations/2018_01_29_195459_create_logs_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('user_id')->index(); $sp79d26d->string('ip'); $sp79d26d->integer('action')->default(\App\Log::ACTION_LOGIN); $sp79d26d->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); }); } public function down() { Schema::dropIfExists('logs'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\DB; class CreateLogsTable extends Migration { public function up() { Schema::create('logs', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('user_id')->index(); $sp580417->string('ip'); $sp580417->integer('action')->default(\App\Log::ACTION_LOGIN); $sp580417->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); }); } public function down() { Schema::dropIfExists('logs'); } } \ No newline at end of file diff --git a/database/migrations/2018_01_29_205026_create_systems_table.php b/database/migrations/2018_01_29_205026_create_systems_table.php index ba2da4fda..d0343b866 100644 --- a/database/migrations/2018_01_29_205026_create_systems_table.php +++ b/database/migrations/2018_01_29_205026_create_systems_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->string('name', 100)->unique(); $sp79d26d->longText('value')->nullable(); $sp79d26d->timestamps(); }); } public function down() { Schema::dropIfExists('systems'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateSystemsTable extends Migration { public function up() { Schema::create('systems', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->string('name', 100)->unique(); $sp580417->longText('value')->nullable(); $sp580417->timestamps(); }); } public function down() { Schema::dropIfExists('systems'); } } \ No newline at end of file diff --git a/database/migrations/2018_02_01_174100_create_fund_records_table.php b/database/migrations/2018_02_01_174100_create_fund_records_table.php index 9a4bfae31..0cee2e290 100644 --- a/database/migrations/2018_02_01_174100_create_fund_records_table.php +++ b/database/migrations/2018_02_01_174100_create_fund_records_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('user_id')->index(); $sp79d26d->integer('type')->default(\App\FundRecord::TYPE_OUT); $sp79d26d->integer('amount'); $sp79d26d->integer('balance')->default(0); $sp79d26d->integer('order_id')->nullable(); $sp79d26d->string('withdraw_id')->nullable(); $sp79d26d->string('remark')->nullable(); $sp79d26d->timestamps(); }); DB::unprepared('ALTER TABLE `fund_records` CHANGE COLUMN `created_at` `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP;'); } public function down() { Schema::dropIfExists('fund_records'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateFundRecordsTable extends Migration { public function up() { Schema::create('fund_records', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('user_id')->index(); $sp580417->integer('type')->default(\App\FundRecord::TYPE_OUT); $sp580417->integer('amount'); $sp580417->integer('balance')->default(0); $sp580417->integer('order_id')->nullable(); $sp580417->string('withdraw_id')->nullable(); $sp580417->string('remark')->nullable(); $sp580417->timestamps(); }); DB::unprepared('ALTER TABLE `fund_records` CHANGE COLUMN `created_at` `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP;'); } public function down() { Schema::dropIfExists('fund_records'); } } \ No newline at end of file diff --git a/database/migrations/2018_02_01_202439_create_jobs_table.php b/database/migrations/2018_02_01_202439_create_jobs_table.php index 33568c2b2..a6219a2e6 100644 --- a/database/migrations/2018_02_01_202439_create_jobs_table.php +++ b/database/migrations/2018_02_01_202439_create_jobs_table.php @@ -1,2 +1,2 @@ bigIncrements('id'); $sp79d26d->string('queue', 128)->index(); $sp79d26d->longText('payload'); $sp79d26d->unsignedTinyInteger('attempts'); $sp79d26d->unsignedInteger('reserved_at')->nullable(); $sp79d26d->unsignedInteger('available_at'); $sp79d26d->unsignedInteger('created_at'); }); } public function down() { Schema::dropIfExists('jobs'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateJobsTable extends Migration { public function up() { Schema::create('jobs', function (Blueprint $sp580417) { $sp580417->bigIncrements('id'); $sp580417->string('queue', 128)->index(); $sp580417->longText('payload'); $sp580417->unsignedTinyInteger('attempts'); $sp580417->unsignedInteger('reserved_at')->nullable(); $sp580417->unsignedInteger('available_at'); $sp580417->unsignedInteger('created_at'); }); } public function down() { Schema::dropIfExists('jobs'); } } \ No newline at end of file diff --git a/database/migrations/2018_02_01_234941_create_files_table.php b/database/migrations/2018_02_01_234941_create_files_table.php index ea02b023a..eb1c3fd08 100644 --- a/database/migrations/2018_02_01_234941_create_files_table.php +++ b/database/migrations/2018_02_01_234941_create_files_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->integer('user_id'); $sp79d26d->string('driver'); $sp79d26d->string('path'); $sp79d26d->string('url'); $sp79d26d->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); }); } public function down() { Schema::dropIfExists('files'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\DB; class CreateFilesTable extends Migration { public function up() { Schema::create('files', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->integer('user_id'); $sp580417->string('driver'); $sp580417->string('path'); $sp580417->string('url'); $sp580417->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); }); } public function down() { Schema::dropIfExists('files'); } } \ No newline at end of file diff --git a/database/migrations/2018_05_17_112228_create_shop_themes_table.php b/database/migrations/2018_05_17_112228_create_shop_themes_table.php index fbd1ad45b..50642b376 100644 --- a/database/migrations/2018_05_17_112228_create_shop_themes_table.php +++ b/database/migrations/2018_05_17_112228_create_shop_themes_table.php @@ -1,2 +1,2 @@ increments('id'); $sp79d26d->string('name', 128)->unique(); $sp79d26d->string('description')->nullable(); $sp79d26d->text('options')->nullable(); $sp79d26d->text('config')->nullable(); $sp79d26d->boolean('enabled')->default(true); }); \App\ShopTheme::freshList(); } public function down() { Schema::dropIfExists('shop_themes'); } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateShopThemesTable extends Migration { public function up() { Schema::create('shop_themes', function (Blueprint $sp580417) { $sp580417->increments('id'); $sp580417->string('name', 128)->unique(); $sp580417->string('description')->nullable(); $sp580417->text('options')->nullable(); $sp580417->text('config')->nullable(); $sp580417->boolean('enabled')->default(true); }); \App\ShopTheme::freshList(); } public function down() { Schema::dropIfExists('shop_themes'); } } \ No newline at end of file diff --git a/database/migrations/2019_02_07_195259_add_count_to_products.php b/database/migrations/2019_02_07_195259_add_count_to_products.php index 1ae356571..65a7b4415 100644 --- a/database/migrations/2019_02_07_195259_add_count_to_products.php +++ b/database/migrations/2019_02_07_195259_add_count_to_products.php @@ -1,2 +1,2 @@ integer('count_all')->default(0)->after('count_sold'); }); App\Product::whereRaw('1')->update(array('count_sold' => 0, 'count_all' => 0)); \App\Card::selectRaw('`product_id`,SUM(`count_sold`) as `count_sold`,SUM(`count_all`) as `count_all`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp5b0739) { foreach ($sp5b0739 as $sp1d0a77) { \App\Product::where('id', $sp1d0a77->product_id)->update(array('count_sold' => $sp1d0a77->count_sold, 'count_all' => $sp1d0a77->count_all)); } }); } } public function down() { if (Schema::hasColumn('products', 'count_all')) { Schema::table('products', function (Blueprint $sp79d26d) { $sp79d26d->dropColumn(array('count_all')); }); } } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddCountToProducts extends Migration { public function up() { if (!Schema::hasColumn('products', 'count_all')) { Schema::table('products', function (Blueprint $sp580417) { $sp580417->integer('count_all')->default(0)->after('count_sold'); }); App\Product::whereRaw('1')->update(array('count_sold' => 0, 'count_all' => 0)); \App\Card::selectRaw('`product_id`,SUM(`count_sold`) as `count_sold`,SUM(`count_all`) as `count_all`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp43445b) { foreach ($sp43445b as $sp78bb46) { \App\Product::where('id', $sp78bb46->product_id)->update(array('count_sold' => $sp78bb46->count_sold, 'count_all' => $sp78bb46->count_all)); } }); } } public function down() { if (Schema::hasColumn('products', 'count_all')) { Schema::table('products', function (Blueprint $sp580417) { $sp580417->dropColumn(array('count_all')); }); } } } \ No newline at end of file diff --git a/database/migrations/2019_02_14_203213_add_name_to_orders.php b/database/migrations/2019_02_14_203213_add_name_to_orders.php index f5eb587eb..e65db0011 100644 --- a/database/migrations/2019_02_14_203213_add_name_to_orders.php +++ b/database/migrations/2019_02_14_203213_add_name_to_orders.php @@ -1,2 +1,2 @@ string('product_name')->nullable()->after('product_id'); }); } } public function down() { } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddNameToOrders extends Migration { public function up() { if (!Schema::hasColumn('orders', 'product_name')) { Schema::table('orders', function (Blueprint $sp580417) { $sp580417->string('product_name')->nullable()->after('product_id'); }); } } public function down() { } } \ No newline at end of file diff --git a/database/migrations/2019_04_28_230220_add_inventory_to_products.php b/database/migrations/2019_04_28_230220_add_inventory_to_products.php index 2a0c5b297..50e4bc357 100644 --- a/database/migrations/2019_04_28_230220_add_inventory_to_products.php +++ b/database/migrations/2019_04_28_230220_add_inventory_to_products.php @@ -1,2 +1,2 @@ tinyInteger('inventory')->default(\App\User::INVENTORY_AUTO)->after('enabled'); $sp79d26d->tinyInteger('fee_type')->default(\App\User::FEE_TYPE_AUTO)->after('inventory'); }); } } public function down() { foreach (array('inventory', 'fee_type') as $sp61f792) { try { Schema::table('products', function (Blueprint $sp79d26d) use($sp61f792) { $sp79d26d->dropColumn($sp61f792); }); } catch (\Throwable $sp45f5f1) { } } } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddInventoryToProducts extends Migration { public function up() { if (!Schema::hasColumn('products', 'inventory')) { Schema::table('products', function (Blueprint $sp580417) { $sp580417->tinyInteger('inventory')->default(\App\User::INVENTORY_AUTO)->after('enabled'); $sp580417->tinyInteger('fee_type')->default(\App\User::FEE_TYPE_AUTO)->after('inventory'); }); } } public function down() { foreach (array('inventory', 'fee_type') as $sp3dcdfd) { try { Schema::table('products', function (Blueprint $sp580417) use($sp3dcdfd) { $sp580417->dropColumn($sp3dcdfd); }); } catch (\Throwable $sp6a7295) { } } } } \ No newline at end of file diff --git a/database/migrations/2019_05_18_131719_add_all_to_fund_records.php b/database/migrations/2019_05_18_131719_add_all_to_fund_records.php index 954529f05..d525e0e89 100644 --- a/database/migrations/2019_05_18_131719_add_all_to_fund_records.php +++ b/database/migrations/2019_05_18_131719_add_all_to_fund_records.php @@ -1,2 +1,2 @@ integer('all')->nullable()->after('amount'); $sp79d26d->integer('frozen')->nullable()->after('all'); $sp79d26d->integer('paid')->nullable()->after('frozen'); }); } } public function down() { foreach (array('all', 'frozen', 'paid') as $sp61f792) { try { Schema::table('fund_records', function (Blueprint $sp79d26d) use($sp61f792) { $sp79d26d->dropColumn($sp61f792); }); } catch (\Throwable $sp45f5f1) { } } } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddAllToFundRecords extends Migration { public function up() { if (!Schema::hasColumn('fund_records', 'all')) { Schema::table('fund_records', function (Blueprint $sp580417) { $sp580417->integer('all')->nullable()->after('amount'); $sp580417->integer('frozen')->nullable()->after('all'); $sp580417->integer('paid')->nullable()->after('frozen'); }); } } public function down() { foreach (array('all', 'frozen', 'paid') as $sp3dcdfd) { try { Schema::table('fund_records', function (Blueprint $sp580417) use($sp3dcdfd) { $sp580417->dropColumn($sp3dcdfd); }); } catch (\Throwable $sp6a7295) { } } } } \ No newline at end of file diff --git a/database/migrations/2019_06_17_185712_add_options_to_shop_theme.php b/database/migrations/2019_06_17_185712_add_options_to_shop_theme.php index 3b914b9d1..fd0a45986 100644 --- a/database/migrations/2019_06_17_185712_add_options_to_shop_theme.php +++ b/database/migrations/2019_06_17_185712_add_options_to_shop_theme.php @@ -1,2 +1,2 @@ text('options')->nullable()->after('description'); }); } } public function down() { } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddOptionsToShopTheme extends Migration { public function up() { if (!Schema::hasColumn('shop_themes', 'options')) { Schema::table('shop_themes', function (Blueprint $sp580417) { $sp580417->text('options')->nullable()->after('description'); }); } } public function down() { } } \ No newline at end of file diff --git a/database/migrations/2019_06_18_112211_add_manual_products.php b/database/migrations/2019_06_18_112211_add_manual_products.php index 869b6869b..56da12351 100644 --- a/database/migrations/2019_06_18_112211_add_manual_products.php +++ b/database/migrations/2019_06_18_112211_add_manual_products.php @@ -1,6 +1,6 @@ text('fields')->nullable()->after('instructions'); $sp79d26d->tinyInteger('delivery')->default(\App\Product::DELIVERY_AUTO)->after('fee_type'); }); } if (!Schema::hasColumn('orders', 'contact_ext')) { DB::unprepared(' +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddManualProducts extends Migration { public function up() { if (!Schema::hasColumn('products', 'fields')) { Schema::table('products', function (Blueprint $sp580417) { $sp580417->text('fields')->nullable()->after('instructions'); $sp580417->tinyInteger('delivery')->default(\App\Product::DELIVERY_AUTO)->after('fee_type'); }); } if (!Schema::hasColumn('orders', 'contact_ext')) { DB::unprepared(' ALTER TABLE `orders` CHANGE COLUMN `email` `contact` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL AFTER `customer`, CHANGE COLUMN `email_sent` `send_status` tinyint(4) NOT NULL DEFAULT 0 AFTER `contact`; - '); Schema::table('orders', function (Blueprint $sp79d26d) { $sp79d26d->text('contact_ext')->nullable()->after('contact'); }); } } public function down() { } } \ No newline at end of file + '); Schema::table('orders', function (Blueprint $sp580417) { $sp580417->text('contact_ext')->nullable()->after('contact'); }); } } public function down() { } } \ No newline at end of file diff --git a/database/migrations/2019_07_03_213426_add_sms_price_to_orders.php b/database/migrations/2019_07_03_213426_add_sms_price_to_orders.php index 3da7f79b0..712440453 100644 --- a/database/migrations/2019_07_03_213426_add_sms_price_to_orders.php +++ b/database/migrations/2019_07_03_213426_add_sms_price_to_orders.php @@ -1,2 +1,2 @@ integer('sms_price')->default(0)->after('discount'); }); } } public function down() { } } \ No newline at end of file +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddSmsPriceToOrders extends Migration { public function up() { if (!Schema::hasColumn('orders', 'sms_price')) { Schema::table('orders', function (Blueprint $sp580417) { $sp580417->integer('sms_price')->default(0)->after('discount'); }); } } public function down() { } } \ No newline at end of file diff --git a/database/seeds/CardsSeeder.php b/database/seeds/CardsSeeder.php index d8c7010ac..8b697b6f1 100644 --- a/database/seeds/CardsSeeder.php +++ b/database/seeds/CardsSeeder.php @@ -1,2 +1,2 @@ id; \App\Card::insert(array(array('user_id' => $sp258cf6, 'product_id' => 1, 'card' => '11111', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1), array('user_id' => $sp258cf6, 'product_id' => 1, 'card' => '11112', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_SOLD, 'count_sold' => 1, 'count_all' => 1), array('user_id' => $sp258cf6, 'product_id' => 1, 'card' => '11113', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1), array('user_id' => $sp258cf6, 'product_id' => 2, 'card' => '123456', 'type' => \App\Card::TYPE_REPEAT, 'status' => \App\Card::STATUS_SOLD, 'count_sold' => 2, 'count_all' => 100))); } } \ No newline at end of file +use Illuminate\Database\Seeder; class CardsSeeder extends Seeder { public function run() { $spf5ae13 = \App\User::first()->id; \App\Card::insert(array(array('user_id' => $spf5ae13, 'product_id' => 1, 'card' => '11111', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1), array('user_id' => $spf5ae13, 'product_id' => 1, 'card' => '11112', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_SOLD, 'count_sold' => 1, 'count_all' => 1), array('user_id' => $spf5ae13, 'product_id' => 1, 'card' => '11113', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1), array('user_id' => $spf5ae13, 'product_id' => 2, 'card' => '123456', 'type' => \App\Card::TYPE_REPEAT, 'status' => \App\Card::STATUS_SOLD, 'count_sold' => 2, 'count_all' => 100))); } } \ No newline at end of file diff --git a/database/seeds/OrdersSeeder.php b/database/seeds/OrdersSeeder.php index 4bb2bef34..be763afdc 100644 --- a/database/seeds/OrdersSeeder.php +++ b/database/seeds/OrdersSeeder.php @@ -1,2 +1,2 @@ 1000, 'user_id' => 0, 'order_no' => '123456', 'product_id' => \App\Product::first()->id, 'count' => 0, 'contact' => '', 'pay_id' => 0, 'status' => \App\Order::STATUS_UNPAY)); try { \App\Order::where('id', 1000)->delete(); } catch (Exception $sp45f5f1) { } } public function run() { self::increaseId(); } } \ No newline at end of file +use Illuminate\Database\Seeder; class OrdersSeeder extends Seeder { private function increaseId() { \App\Order::insert(array('id' => 1000, 'user_id' => 0, 'order_no' => '123456', 'product_id' => \App\Product::first()->id, 'count' => 0, 'contact' => '', 'pay_id' => 0, 'status' => \App\Order::STATUS_UNPAY)); try { \App\Order::where('id', 1000)->delete(); } catch (Exception $sp6a7295) { } } public function run() { self::increaseId(); } } \ No newline at end of file diff --git a/database/seeds/PayTableSeeder.php b/database/seeds/PayTableSeeder.php index 1eddbf464..a82ea651a 100644 --- a/database/seeds/PayTableSeeder.php +++ b/database/seeds/PayTableSeeder.php @@ -1,70 +1,70 @@ name = '支付宝'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'Fakala'; $sp1d1f3d->way = 'alipay'; $sp1d1f3d->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp1d1f3d->config = '{ +use Illuminate\Database\Seeder; class PayTableSeeder extends Seeder { private function initPay() { $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'Fakala'; $sp91f0ec->way = 'alipay'; $sp91f0ec->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp91f0ec->config = '{ "gateway": "https://www.327ka.com", "api_id": "your api_id", "api_key": "your api_key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_PC; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '支付宝'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'Fakala'; $sp1d1f3d->way = 'alipaywap'; $sp1d1f3d->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_PC; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'Fakala'; $sp91f0ec->way = 'alipaywap'; $sp91f0ec->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp91f0ec->config = '{ "gateway": "https://www.327ka.com", "api_id": "your api_id", "api_key": "your api_key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_MOBILE; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '微信'; $sp1d1f3d->img = '/plugins/images/wx.png'; $sp1d1f3d->driver = 'Fakala'; $sp1d1f3d->way = 'wx'; $sp1d1f3d->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_MOBILE; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '微信'; $sp91f0ec->img = '/plugins/images/wx.png'; $sp91f0ec->driver = 'Fakala'; $sp91f0ec->way = 'wx'; $sp91f0ec->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp91f0ec->config = '{ "gateway": "https://www.327ka.com", "api_id": "your api_id", "api_key": "your api_key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_PC; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '微信'; $sp1d1f3d->img = '/plugins/images/wx.png'; $sp1d1f3d->driver = 'Fakala'; $sp1d1f3d->way = 'wxwap'; $sp1d1f3d->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_PC; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '微信'; $sp91f0ec->img = '/plugins/images/wx.png'; $sp91f0ec->driver = 'Fakala'; $sp91f0ec->way = 'wxwap'; $sp91f0ec->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp91f0ec->config = '{ "gateway": "https://www.327ka.com", "api_id": "your api_id", "api_key": "your api_key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_MOBILE; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '支付宝'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'Alipay'; $sp1d1f3d->way = 'pc'; $sp1d1f3d->comment = '支付宝 - 即时到账套餐(企业)V2'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_MOBILE; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'Alipay'; $sp91f0ec->way = 'pc'; $sp91f0ec->comment = '支付宝 - 即时到账套餐(企业)V2'; $sp91f0ec->config = '{ "partner": "partner", "key": "key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '支付宝'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'Aliwap'; $sp1d1f3d->way = 'wap'; $sp1d1f3d->comment = '支付宝 - 高级手机网站支付V4'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'Aliwap'; $sp91f0ec->way = 'wap'; $sp91f0ec->comment = '支付宝 - 高级手机网站支付V4'; $sp91f0ec->config = '{ "partner": "partner", "key": "key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '支付宝扫码'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'AliAop'; $sp1d1f3d->way = 'f2f'; $sp1d1f3d->comment = '支付宝 - 当面付'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '支付宝扫码'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'AliAop'; $sp91f0ec->way = 'f2f'; $sp91f0ec->comment = '支付宝 - 当面付'; $sp91f0ec->config = '{ "app_id": "app_id", "alipay_public_key": "alipay_public_key", "merchant_private_key": "merchant_private_key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '支付宝'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'AliAop'; $sp1d1f3d->way = 'pc'; $sp1d1f3d->comment = '支付宝 - 电脑网站支付 (新)'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'AliAop'; $sp91f0ec->way = 'pc'; $sp91f0ec->comment = '支付宝 - 电脑网站支付 (新)'; $sp91f0ec->config = '{ "app_id": "app_id", "alipay_public_key": "alipay_public_key", "merchant_private_key": "merchant_private_key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '手机支付宝'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'AliAop'; $sp1d1f3d->way = 'mobile'; $sp1d1f3d->comment = '支付宝 - 手机网站支付 (新)'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '手机支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'AliAop'; $sp91f0ec->way = 'mobile'; $sp91f0ec->comment = '支付宝 - 手机网站支付 (新)'; $sp91f0ec->config = '{ "app_id": "app_id", "alipay_public_key": "alipay_public_key", "merchant_private_key": "merchant_private_key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '微信扫码'; $sp1d1f3d->img = '/plugins/images/wx.png'; $sp1d1f3d->driver = 'WeChat'; $sp1d1f3d->way = 'NATIVE'; $sp1d1f3d->comment = '微信支付 - 扫码'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '微信扫码'; $sp91f0ec->img = '/plugins/images/wx.png'; $sp91f0ec->driver = 'WeChat'; $sp91f0ec->way = 'NATIVE'; $sp91f0ec->comment = '微信支付 - 扫码'; $sp91f0ec->config = '{ "APPID": "APPID", "APPSECRET": "APPSECRET", "MCHID": "商户ID", "KEY": "KEY" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '微信H5'; $sp1d1f3d->img = '/plugins/images/wx.png'; $sp1d1f3d->driver = 'WeChat'; $sp1d1f3d->way = 'MWEB'; $sp1d1f3d->comment = '微信支付 - H5 (需要开通权限)'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '微信H5'; $sp91f0ec->img = '/plugins/images/wx.png'; $sp91f0ec->driver = 'WeChat'; $sp91f0ec->way = 'MWEB'; $sp91f0ec->comment = '微信支付 - H5 (需要开通权限)'; $sp91f0ec->config = '{ "APPID": "APPID", "APPSECRET": "APPSECRET", "MCHID": "商户ID", "KEY": "KEY" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '手机QQ'; $sp1d1f3d->img = '/plugins/images/qq.png'; $sp1d1f3d->driver = 'QPay'; $sp1d1f3d->way = 'NATIVE'; $sp1d1f3d->comment = '手机QQ - 扫码'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '手机QQ'; $sp91f0ec->img = '/plugins/images/qq.png'; $sp91f0ec->driver = 'QPay'; $sp91f0ec->way = 'NATIVE'; $sp91f0ec->comment = '手机QQ - 扫码'; $sp91f0ec->config = '{ "mch_id": "mch_id", "mch_key": "mch_key" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '支付宝'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'Youzan'; $sp1d1f3d->way = 'alipay'; $sp1d1f3d->comment = '有赞支付 - 支付宝'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'Youzan'; $sp91f0ec->way = 'alipay'; $sp91f0ec->comment = '有赞支付 - 支付宝'; $sp91f0ec->config = '{ "client_id": "client_id", "client_secret": "client_secret", "kdt_id": "kdt_id" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '微信'; $sp1d1f3d->img = '/plugins/images/wx.png'; $sp1d1f3d->driver = 'Youzan'; $sp1d1f3d->way = 'wechat'; $sp1d1f3d->comment = '有赞支付 - 微信'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '微信'; $sp91f0ec->img = '/plugins/images/wx.png'; $sp91f0ec->driver = 'Youzan'; $sp91f0ec->way = 'wechat'; $sp91f0ec->comment = '有赞支付 - 微信'; $sp91f0ec->config = '{ "client_id": "client_id", "client_secret": "client_secret", "kdt_id": "kdt_id" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '手机QQ'; $sp1d1f3d->img = '/plugins/images/qq.png'; $sp1d1f3d->driver = 'Youzan'; $sp1d1f3d->way = 'qq'; $sp1d1f3d->comment = '有赞支付 - 手机QQ'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '手机QQ'; $sp91f0ec->img = '/plugins/images/qq.png'; $sp91f0ec->driver = 'Youzan'; $sp91f0ec->way = 'qq'; $sp91f0ec->comment = '有赞支付 - 手机QQ'; $sp91f0ec->config = '{ "client_id": "client_id", "client_secret": "client_secret", "kdt_id": "kdt_id" -}'; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '支付宝'; $sp1d1f3d->img = '/plugins/images/ali.png'; $sp1d1f3d->driver = 'CodePay'; $sp1d1f3d->way = 'alipay'; $sp1d1f3d->comment = '码支付 - 支付宝'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'CodePay'; $sp91f0ec->way = 'alipay'; $sp91f0ec->comment = '码支付 - 支付宝'; $sp91f0ec->config = '{ "id": "id", "key": "key" -}'; $sp1d1f3d->fee_system = 0; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '微信'; $sp1d1f3d->img = '/plugins/images/wx.png'; $sp1d1f3d->driver = 'CodePay'; $sp1d1f3d->way = 'weixin'; $sp1d1f3d->comment = '码支付 - 微信'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->fee_system = 0; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '微信'; $sp91f0ec->img = '/plugins/images/wx.png'; $sp91f0ec->driver = 'CodePay'; $sp91f0ec->way = 'weixin'; $sp91f0ec->comment = '码支付 - 微信'; $sp91f0ec->config = '{ "id": "id", "key": "key" -}'; $sp1d1f3d->fee_system = 0; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); $sp1d1f3d = new \App\Pay(); $sp1d1f3d->name = '手机QQ'; $sp1d1f3d->img = '/plugins/images/qq.png'; $sp1d1f3d->driver = 'CodePay'; $sp1d1f3d->way = 'qq'; $sp1d1f3d->comment = '码支付 - 手机QQ'; $sp1d1f3d->config = '{ +}'; $sp91f0ec->fee_system = 0; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); $sp91f0ec = new \App\Pay(); $sp91f0ec->name = '手机QQ'; $sp91f0ec->img = '/plugins/images/qq.png'; $sp91f0ec->driver = 'CodePay'; $sp91f0ec->way = 'qq'; $sp91f0ec->comment = '码支付 - 手机QQ'; $sp91f0ec->config = '{ "id": "id", "key": "key" -}'; $sp1d1f3d->fee_system = 0; $sp1d1f3d->enabled = \App\Pay::ENABLED_DISABLED; $sp1d1f3d->save(); } public function run() { self::initPay(); } } \ No newline at end of file +}'; $sp91f0ec->fee_system = 0; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); } public function run() { self::initPay(); } } \ No newline at end of file diff --git a/database/seeds/ProductsSeeder.php b/database/seeds/ProductsSeeder.php index 38f7bc129..b514e48b5 100644 --- a/database/seeds/ProductsSeeder.php +++ b/database/seeds/ProductsSeeder.php @@ -1,2 +1,2 @@ id; $spd14ca3 = new \App\Category(); $spd14ca3->user_id = $sp258cf6; $spd14ca3->name = '测试分组'; $spd14ca3->enabled = true; $spd14ca3->save(); $spd14ca3 = new \App\Category(); $spd14ca3->user_id = $sp258cf6; $spd14ca3->name = '这里是一个啦啦啦啦啦啦超级无敌爆炸螺旋长的商品类别标题'; $spd14ca3->enabled = true; $spd14ca3->save(); $spd14ca3 = new \App\Category(); $spd14ca3->user_id = $sp258cf6; $spd14ca3->name = '密码123456'; $spd14ca3->enabled = true; $spd14ca3->password = '123456'; $spd14ca3->password_open = true; $spd14ca3->save(); $sp1a3ec5 = new \App\Product(); $sp1a3ec5->id = 1; $sp1a3ec5->user_id = $sp258cf6; $sp1a3ec5->category_id = 1; $sp1a3ec5->name = '测试商品'; $sp1a3ec5->description = '这里是测试商品的一段简短的描述'; $sp1a3ec5->price = 1; $sp1a3ec5->enabled = true; $sp1a3ec5->support_coupon = true; $sp1a3ec5->count_sold = 1; $sp1a3ec5->count_all = 3; $sp1a3ec5->instructions = '充值网址: XXXXX'; $sp1a3ec5->save(); $sp1a3ec5 = new \App\Product(); $sp1a3ec5->id = 2; $sp1a3ec5->user_id = $sp258cf6; $sp1a3ec5->category_id = 1; $sp1a3ec5->name = '重复测试密码123456'; $sp1a3ec5->description = '

商品描述

所十二星座运势查询,提前预测2016年十二星座运势内容,让你能够占卜吉凶;2016年生肖运势测算,生肖开运,周易风水。'; $sp1a3ec5->instructions = '充值网址: XXXXX'; $sp1a3ec5->password = '123456'; $sp1a3ec5->password_open = true; $sp1a3ec5->support_coupon = true; $sp1a3ec5->price = 10; $sp1a3ec5->price_whole = '[["2","8"],["10","5"]]'; $sp1a3ec5->enabled = true; $sp1a3ec5->count_sold = 2; $sp1a3ec5->count_all = 100; $sp1a3ec5->count_warn = 10; $sp1a3ec5->save(); $sp1a3ec5 = new \App\Product(); $sp1a3ec5->user_id = $sp258cf6; $sp1a3ec5->category_id = 2; $sp1a3ec5->name = '测试商品_2'; $sp1a3ec5->description = '这里是测试商品的一段简短的描述, 可以插入多媒体文本'; $sp1a3ec5->price = 1; $sp1a3ec5->enabled = true; $sp1a3ec5->save(); $sp1a3ec5 = new \App\Product(); $sp1a3ec5->user_id = $sp258cf6; $sp1a3ec5->category_id = 3; $sp1a3ec5->name = '测试商品_3'; $sp1a3ec5->description = '这里是测试商品的一段简短的描述, 可以插入多媒体文本'; $sp1a3ec5->price = 1; $sp1a3ec5->enabled = true; $sp1a3ec5->save(); } } \ No newline at end of file +use Illuminate\Database\Seeder; class ProductsSeeder extends Seeder { public function run() { $spf5ae13 = \App\User::first()->id; $sp1cd1e4 = new \App\Category(); $sp1cd1e4->user_id = $spf5ae13; $sp1cd1e4->name = '测试分组'; $sp1cd1e4->enabled = true; $sp1cd1e4->save(); $sp1cd1e4 = new \App\Category(); $sp1cd1e4->user_id = $spf5ae13; $sp1cd1e4->name = '这里是一个啦啦啦啦啦啦超级无敌爆炸螺旋长的商品类别标题'; $sp1cd1e4->enabled = true; $sp1cd1e4->save(); $sp1cd1e4 = new \App\Category(); $sp1cd1e4->user_id = $spf5ae13; $sp1cd1e4->name = '密码123456'; $sp1cd1e4->enabled = true; $sp1cd1e4->password = '123456'; $sp1cd1e4->password_open = true; $sp1cd1e4->save(); $sp9dfc99 = new \App\Product(); $sp9dfc99->id = 1; $sp9dfc99->user_id = $spf5ae13; $sp9dfc99->category_id = 1; $sp9dfc99->name = '测试商品'; $sp9dfc99->description = '这里是测试商品的一段简短的描述'; $sp9dfc99->price = 1; $sp9dfc99->enabled = true; $sp9dfc99->support_coupon = true; $sp9dfc99->count_sold = 1; $sp9dfc99->count_all = 3; $sp9dfc99->instructions = '充值网址: XXXXX'; $sp9dfc99->save(); $sp9dfc99 = new \App\Product(); $sp9dfc99->id = 2; $sp9dfc99->user_id = $spf5ae13; $sp9dfc99->category_id = 1; $sp9dfc99->name = '重复测试密码123456'; $sp9dfc99->description = '

商品描述

所十二星座运势查询,提前预测2016年十二星座运势内容,让你能够占卜吉凶;2016年生肖运势测算,生肖开运,周易风水。'; $sp9dfc99->instructions = '充值网址: XXXXX'; $sp9dfc99->password = '123456'; $sp9dfc99->password_open = true; $sp9dfc99->support_coupon = true; $sp9dfc99->price = 10; $sp9dfc99->price_whole = '[["2","8"],["10","5"]]'; $sp9dfc99->enabled = true; $sp9dfc99->count_sold = 2; $sp9dfc99->count_all = 100; $sp9dfc99->count_warn = 10; $sp9dfc99->save(); $sp9dfc99 = new \App\Product(); $sp9dfc99->user_id = $spf5ae13; $sp9dfc99->category_id = 2; $sp9dfc99->name = '测试商品_2'; $sp9dfc99->description = '这里是测试商品的一段简短的描述, 可以插入多媒体文本'; $sp9dfc99->price = 1; $sp9dfc99->enabled = true; $sp9dfc99->save(); $sp9dfc99 = new \App\Product(); $sp9dfc99->user_id = $spf5ae13; $sp9dfc99->category_id = 3; $sp9dfc99->name = '测试商品_3'; $sp9dfc99->description = '这里是测试商品的一段简短的描述, 可以插入多媒体文本'; $sp9dfc99->price = 1; $sp9dfc99->enabled = true; $sp9dfc99->save(); } } \ No newline at end of file diff --git a/database/seeds/SystemSeeder.php b/database/seeds/SystemSeeder.php index ca087d6b5..2379f8cfd 100644 --- a/database/seeds/SystemSeeder.php +++ b/database/seeds/SystemSeeder.php @@ -1,2 +1,2 @@ 'XX小店', 'app_title' => '自动发卡, 自动发货', 'app_url' => 'http://www.example.com', 'app_url_api' => 'http://www.example.com', 'company' => '©2019 Windy', 'keywords' => '在线发卡系统', 'description' => '我是一个发卡系统, 这里填写描述', 'shop_bkg' => 'http://api.izhao.me/img', 'shop_ann' => '欢迎来到XXX小店', 'shop_ann_pop' => '', 'shop_inventory' => 1, 'js_tj' => '
', 'js_kf' => '', 'vcode_driver' => 'geetest', 'vcode_login' => '0', 'vcode_shop_buy' => '0', 'vcode_shop_search' => '0', 'storage_driver' => 'local', 'order_query_day' => '30', 'order_clean_unpay_open' => '0', 'order_clean_unpay_day' => '7', 'mail_driver' => 'smtp', 'mail_smtp_host' => 'smtp.mailtrap.io', 'mail_smtp_port' => '25', 'mail_smtp_username' => 'xxx', 'mail_smtp_password' => 'xxx', 'mail_smtp_from_address' => 'hello@example.com', 'mail_smtp_from_name' => 'test', 'mail_smtp_encryption' => 'null'); $sp4b367b = array(); foreach ($sp8f73e0 as $spec1d68 => $spc0aae1) { $sp4b367b[] = array('name' => $spec1d68, 'value' => $spc0aae1); } DB::table('systems')->insert($sp4b367b); } } \ No newline at end of file +use Illuminate\Database\Seeder; class SystemSeeder extends Seeder { public function run() { $sp1c4322 = array('app_name' => 'XX小店', 'app_title' => '自动发卡, 自动发货', 'app_url' => 'http://www.example.com', 'app_url_api' => 'http://www.example.com', 'company' => '©2019 Windy', 'keywords' => '在线发卡系统', 'description' => '我是一个发卡系统, 这里填写描述', 'shop_bkg' => 'http://api.izhao.me/img', 'shop_ann' => '欢迎来到XXX小店', 'shop_ann_pop' => '', 'shop_inventory' => 1, 'js_tj' => '
', 'js_kf' => '', 'vcode_driver' => 'geetest', 'vcode_login' => '0', 'vcode_shop_buy' => '0', 'vcode_shop_search' => '0', 'storage_driver' => 'local', 'order_query_day' => '30', 'order_clean_unpay_open' => '0', 'order_clean_unpay_day' => '7', 'mail_driver' => 'smtp', 'mail_smtp_host' => 'smtp.mailtrap.io', 'mail_smtp_port' => '25', 'mail_smtp_username' => 'xxx', 'mail_smtp_password' => 'xxx', 'mail_smtp_from_address' => 'hello@example.com', 'mail_smtp_from_name' => 'test', 'mail_smtp_encryption' => 'null'); $sp1d893d = array(); foreach ($sp1c4322 as $spf2a422 => $spa1e244) { $sp1d893d[] = array('name' => $spf2a422, 'value' => $spa1e244); } DB::table('systems')->insert($sp1d893d); } } \ No newline at end of file diff --git a/public/index.php b/public/index.php index 7ab6c4bff..2976635f9 100644 --- a/public/index.php +++ b/public/index.php @@ -1,2 +1,2 @@ make(Illuminate\Contracts\Http\Kernel::class); $spf16c1a = $sp327d6b->handle($spa27895 = Illuminate\Http\Request::capture()); $spf16c1a->send(); $sp327d6b->terminate($spa27895, $spf16c1a); \ No newline at end of file +if (isset($_SERVER['HTTP_ALI_SWIFT_STAT_HOST'])) { $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_ALI_SWIFT_STAT_HOST']; $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_ALI_SWIFT_STAT_HOST']; } define('LARAVEL_START', microtime(true)); require __DIR__ . '/../vendor/autoload.php'; $spe4a088 = (require_once __DIR__ . '/../bootstrap/app.php'); $sp3419ed = $spe4a088->make(Illuminate\Contracts\Http\Kernel::class); $spb9364a = $sp3419ed->handle($spba756f = Illuminate\Http\Request::capture()); $spb9364a->send(); $sp3419ed->terminate($spba756f, $spb9364a); \ No newline at end of file diff --git a/routes/channels.php b/routes/channels.php index ddeb6f8f0..556277969 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -1,2 +1,2 @@ id === (int) $sp746ee1; }); \ No newline at end of file +Broadcast::channel('App.User.{id}', function ($spac34b1, $sp8e8060) { return (int) $spac34b1->id === (int) $sp8e8060; }); \ No newline at end of file