diff --git a/.version b/.version index 428126bda..2fd1c73a5 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -{"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 +{"version":"2.95e","md5":"6d665cc909072a6fb5a2216b1e7061f9","url":"https:\/\/github.com\/Tai7sy\/card-system\/releases\/download\/2.95e\/card_release.tar.gz"} \ No newline at end of file diff --git a/README.md b/README.md index 9f751567b..7bdaf4693 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### 关于 -> 当前版本: 2.95d +> 当前版本: 2.95e > 支付网关: [card-gateway](https://github.com/Tai7sy/card-gateway) diff --git a/app/Card.php b/app/Card.php index 3655218a8..278b0dbae 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($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 +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($spdad372, $sp5d967e, $sp0fe7ec, $sp31859f, $sp3301fd, $sp0d89d4) { DB::statement('call add_cards(?,?,?,?,?,?)', array($spdad372, $sp5d967e, $sp0fe7ec, $sp31859f, $sp3301fd, (int) $sp0d89d4)); } public static function _trash($sp6cb35e) { DB::transaction(function () use($sp6cb35e) { $spb8b025 = clone $sp6cb35e; $spb8b025->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp1432b9) { foreach ($sp1432b9 as $sp4c126d) { $spe7d79d = \App\Product::where('id', $sp4c126d->product_id)->lockForUpdate()->first(); if ($spe7d79d) { $spe7d79d->count_all -= $sp4c126d->count_left; $spe7d79d->saveOrFail(); } } }); $sp6cb35e->delete(); return true; }); } public static function _restore($sp6cb35e) { DB::transaction(function () use($sp6cb35e) { $spb8b025 = clone $sp6cb35e; $spb8b025->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp1432b9) { foreach ($sp1432b9 as $sp4c126d) { $spe7d79d = \App\Product::where('id', $sp4c126d->product_id)->lockForUpdate()->first(); if ($spe7d79d) { $spe7d79d->count_all += $sp4c126d->count_left; $spe7d79d->saveOrFail(); } } }); $sp6cb35e->restore(); return true; }); } } \ No newline at end of file diff --git a/app/Category.php b/app/Category.php index 2adfa91c1..b7ef48c3f 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() { $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 +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() { $sp6c9c2f = Product::where('category_id', $this->id)->where('enabled', 1)->orderBy('sort')->get(); foreach ($sp6c9c2f as $spe7d79d) { $spe7d79d->setForShop($this->user); } $this->addVisible(array('products')); $this->setAttribute('products', $sp6c9c2f); return $sp6c9c2f; } } \ No newline at end of file diff --git a/app/Console/Commands/ResetPassword.php b/app/Console/Commands/ResetPassword.php index 03529ba71..76c50cac6 100644 --- a/app/Console/Commands/ResetPassword.php +++ b/app/Console/Commands/ResetPassword.php @@ -1,4 +1,4 @@ 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 +Usage: php artisan reset:password user@email.com'; public function __construct() { parent::__construct(); } public function handle() { $sp551dce = $this->argument('email'); if (!$sp551dce) { $this->warn('please input the user\'s email +'); return false; } $spb14cf0 = \App\User::where('email', $sp551dce)->first(); if (!$spb14cf0) { $this->warn("can't find the user: {$sp551dce} \nplease input the user's email\n"); return false; } $sp42016f = $this->argument('password'); $spb14cf0->password = bcrypt($sp42016f); $spb14cf0->save(); $this->info("the password of '{$sp551dce}' has been set to {$sp42016f}\n"); return true; } } \ No newline at end of file diff --git a/app/Console/Commands/Update.php b/app/Console/Commands/Update.php index 40b62e693..7e210eaa5 100644 --- a/app/Console/Commands/Update.php +++ b/app/Console/Commands/Update.php @@ -1,12 +1,12 @@ 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 +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($sp40b98a, $sp18714b) { $spd47e35 = fopen($sp18714b, 'w+'); if (!$spd47e35) { return false; } $sp1942b5 = curl_init(); curl_setopt($sp1942b5, CURLOPT_URL, $sp40b98a); curl_setopt($sp1942b5, CURLOPT_FOLLOWLOCATION, true); curl_setopt($sp1942b5, CURLOPT_RETURNTRANSFER, true); curl_setopt($sp1942b5, CURLOPT_FILE, $spd47e35); curl_setopt($sp1942b5, CURLOPT_PROGRESSFUNCTION, function ($sp9a93da, $spe88c84, $sp907eef, $sp64c1e8, $spd523a9) { if ($spe88c84 > 0) { echo ' download: ' . sprintf('%.2f', $sp907eef / $spe88c84 * 100) . '%'; } }); curl_setopt($sp1942b5, CURLOPT_NOPROGRESS, false); curl_setopt($sp1942b5, CURLOPT_HEADER, 0); curl_setopt($sp1942b5, CURLOPT_USERAGENT, 'card update'); if (defined('MY_PROXY')) { $sp34031d = MY_PROXY; $sp9e3584 = CURLPROXY_HTTP; if (strpos($sp34031d, 'http://') || strpos($sp34031d, 'https://')) { $sp34031d = str_replace('http://', $sp34031d, $sp34031d); $sp34031d = str_replace('https://', $sp34031d, $sp34031d); $sp9e3584 = CURLPROXY_HTTP; } elseif (strpos($sp34031d, 'socks4://')) { $sp34031d = str_replace('socks4://', $sp34031d, $sp34031d); $sp9e3584 = CURLPROXY_SOCKS4; } elseif (strpos($sp34031d, 'socks4a://')) { $sp34031d = str_replace('socks4a://', $sp34031d, $sp34031d); $sp9e3584 = CURLPROXY_SOCKS4A; } elseif (strpos($sp34031d, 'socks5://')) { $sp34031d = str_replace('socks5://', $sp34031d, $sp34031d); $sp9e3584 = CURLPROXY_SOCKS5_HOSTNAME; } curl_setopt($sp1942b5, CURLOPT_PROXY, $sp34031d); curl_setopt($sp1942b5, CURLOPT_PROXYTYPE, $sp9e3584); if (defined('MY_PROXY_PASS')) { curl_setopt($sp1942b5, CURLOPT_PROXYUSERPWD, MY_PROXY_PASS); } } curl_exec($sp1942b5); curl_close($sp1942b5); echo ' +'; return true; } public function handle() { set_time_limit(0); $sp34031d = $this->option('proxy'); if (!empty($sp34031d)) { define('MY_PROXY', $sp34031d); } $sp80c354 = $this->option('proxy-auth'); if (!empty($sp80c354)) { define('MY_PROXY_PASS', $sp80c354); } \Artisan::call('cache:clear'); \Artisan::call('config:clear'); echo ' +'; $this->comment('检查更新中...'); $this->info('当前版本: ' . config('app.version')); $spa8eada = @json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true); if (!@$spa8eada['version']) { $this->warn('检查更新失败!'); $this->warn('Error: ' . ($spa8eada ? json_encode($spa8eada) : 'Network error')); goto LABEL_EXIT; } if (config('app.version') >= $spa8eada['version']) { $this->comment('您的版本已是最新!'); goto LABEL_EXIT; } $this->info('最新版本: ' . $spa8eada['version']); $this->info('版本说明: ' . (@$spa8eada['description'] ?? '无')); $spa51178 = strtolower($this->ask('是否现在更新 (yes/no)', 'no')); if ($spa51178 !== 'yes') { goto LABEL_EXIT; } $sp0a9be2 = realpath(sys_get_temp_dir()); if (strlen($sp0a9be2) < 3) { $this->warn('获取临时目录失败!'); goto LABEL_EXIT; } $sp0a9be2 .= DIRECTORY_SEPARATOR . Str::random(16); if (!mkdir($sp0a9be2) || !is_writable($sp0a9be2) || !is_readable($sp0a9be2)) { $this->warn('临时目录不可读写!'); goto LABEL_EXIT; } if (!function_exists('exec')) { $this->warn('函数 exec 已被禁用, 无法继续更新!'); goto LABEL_EXIT; } if (PHP_OS === 'WINNT') { $sp83bf5d = 'C:\\Program Files\\7-Zip\\7z.exe'; if (!is_file($sp83bf5d)) { $sp83bf5d = strtolower($this->ask('未找到7-Zip, 请手动输入7zG.exe路径', $sp83bf5d)); } if (!is_file($sp83bf5d)) { $this->warn('7-Zip不可用, 请安装7-Zip后重试'); goto LABEL_EXIT; } $sp83bf5d = '"' . $sp83bf5d . '"'; } else { exec('tar --version', $sp2594b3, $sp13cfb3); if ($sp13cfb3) { $this->warn('Error: tar --version ' . join(' -', $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: 解压失败 +', $sp2594b3)); goto LABEL_EXIT; } } $this->comment('正在下载新版本...'); $sp18714b = $sp0a9be2 . DIRECTORY_SEPARATOR . 'ka_update_' . Str::random(16) . '.tmp'; if (!$this->download_progress($spa8eada['url'], $sp18714b)) { $this->warn('写入临时文件失败!'); goto LABEL_EXIT; } $sp68f444 = md5_file($sp18714b); if ($sp68f444 !== $spa8eada['md5']) { $this->warn('更新文件md5校验失败!, file:' . $sp68f444 . ', require:' . $spa8eada['md5']); goto LABEL_EXIT; } $this->comment('正在解压...'); unset($sp2594b3); if (PHP_OS === 'WINNT') { exec("{$sp83bf5d} x -so {$sp18714b} | {$sp83bf5d} x -aoa -si -ttar -o{$sp0a9be2}", $sp2594b3, $sp13cfb3); } else { exec("tar -zxf {$sp18714b} -C {$sp0a9be2}", $sp2594b3, $sp13cfb3); } if ($sp13cfb3) { $this->warn('Error: 解压失败 ' . join(' -', $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 ' +', $sp2594b3)); goto LABEL_EXIT; } $this->comment('正在关闭主站...'); \Artisan::call('down'); sleep(5); $this->comment(' --> 正在清理旧文件...'); $sp636584 = base_path(); foreach (array('app', 'bootstrap', 'config', 'public/dist', 'database', 'routes', 'vendor') as $sp5af18a) { \File::deleteDirectory($sp636584 . DIRECTORY_SEPARATOR . $sp5af18a); } $this->comment(' --> 正在复制新文件...'); \File::copyDirectory($sp0a9be2 . DIRECTORY_SEPARATOR . 'card_system_free_dist', $sp636584); $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'); $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 ' +'; } 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'); $sp2c96d9 = true; LABEL_EXIT: if (isset($sp0a9be2) && strlen($sp0a9be2) > 19) { $this->comment('清理临时目录...'); \File::deleteDirectory($sp0a9be2); } if (isset($sp2c96d9) && $sp2c96d9) { $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 b2581961a..fc992e96b 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -1,4 +1,4 @@ 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 +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 $sp83720d) { if (!app()->runningInConsole()) { return; } try { System::_init(); } catch (\Throwable $sp96dd17) { return; } if (System::_getInt('order_clean_unpay_open') === 1) { $spcefb4d = System::_getInt('order_clean_unpay_day', 7); $sp83720d->call(function () use($spcefb4d) { echo '[' . date('Y-m-d H:i:s') . "] cleaning unpaid orders({$spcefb4d} days ago)...\n"; \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new Carbon())->addDays(-$spcefb4d))->delete(); $sp6ffaef = '[' . date('Y-m-d H:i:s') . '] unpaid-orders cleaned +'; echo $sp6ffaef; })->dailyAt('01:00'); } $sp83720d->call(function () { $spcefb4d = 7; echo '[' . date('Y-m-d H:i:s') . "] cleaning deleted cards({$spcefb4d} days ago)...\n"; \App\Card::onlyTrashed()->where('deleted_at', '<', (new Carbon())->addDays(-$spcefb4d))->forceDelete(); $sp6ffaef = '[' . date('Y-m-d H:i:s') . '] deleted-cards cleaned +'; echo $sp6ffaef; })->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 77923067f..592ede1ee 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -1,2 +1,2 @@ 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 +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 $spa1b46b) { parent::report($spa1b46b); } private function msg($sp3c91bd, $sp6ffaef, $sp31859f) { return $sp3c91bd->isXmlHttpRequest() ? response()->json(array('message' => $sp6ffaef), $sp31859f) : response()->view('errors._', array('code' => $sp31859f, 'message' => $sp6ffaef), $sp31859f); } public function render($sp3c91bd, Exception $sp96dd17) { if ($sp96dd17 instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { return $this->msg($sp3c91bd, '记录未找到', 404); } elseif ($sp96dd17 instanceof \Illuminate\Auth\AuthenticationException) { return $this->msg($sp3c91bd, '您需要登录您的账户再进行此操作', 401); } elseif ($sp96dd17 instanceof \Illuminate\Auth\Access\AuthorizationException) { return $this->msg($sp3c91bd, '未授权的操作', 403); } elseif ($sp96dd17 instanceof \Illuminate\Validation\ValidationException) { return parent::render($sp3c91bd, $sp96dd17); } elseif ($sp96dd17 instanceof \Illuminate\Session\TokenMismatchException) { return $this->msg($sp3c91bd, '请刷新页面后重试', 403); } elseif ($sp96dd17 instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return $this->msg($sp3c91bd, '页面未找到', 404); } elseif ($sp96dd17 instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) { return $this->msg($sp3c91bd, '请求方法不允许', 405); } elseif ($sp96dd17 instanceof \Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException) { Log::error('Caught a ServiceUnavailableHttpException', array('Exception' => $sp96dd17)); return $this->msg($sp3c91bd, '当前服务不可用,请稍后重试', 503); } elseif ($sp96dd17 instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { $sp2cc7d8 = $sp96dd17->getStatusCode(); switch ($sp2cc7d8) { case 429: return $this->msg($sp3c91bd, '您的请求过于频繁,请稍后重试', 429); break; default: Log::error('Caught a UnknownHttpException', array('Exception' => $sp96dd17)); return $this->msg($sp3c91bd, '当前服务不可用,请稍后重试', 500); } } Log::error('Uncaught error', array('exception' => $sp96dd17, 'method' => $sp3c91bd->method(), 'url' => $sp3c91bd->fullUrl(), 'data' => file_get_contents('php://input'), 'ip' => Helper::getIP(), 'client_ip' => $sp3c91bd->getClientIp(), 'headers' => $sp3c91bd->header())); if (config('app.debug')) { return parent::render($sp3c91bd, $sp96dd17); } else { return $this->msg($sp3c91bd, '未知错误,请联系客服', 500); } } } \ No newline at end of file diff --git a/app/File.php b/app/File.php index d8e853bc4..b39d9e106 100644 --- a/app/File.php +++ b/app/File.php @@ -1,2 +1,2 @@ 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 +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 $sp96dd17) { \Log::error('File.deleteFile Error: ' . $sp96dd17->getMessage(), array('exception' => $sp96dd17)); } } 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 28fb97b59..dd1be102d 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)); $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 +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 $sp3c91bd) { $spd43bb3 = array('today' => array('count' => 0, 'paid' => 0, 'profit' => 0), 'yesterday' => array('count' => 0, 'paid' => 0, 'profit' => 0)); $sp534358 = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::now()->toDateString())->where(function ($sp6cb35e) { $sp6cb35e->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(); $spd6427e = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::yesterday()->toDateString())->where(function ($sp6cb35e) { $sp6cb35e->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($sp534358[0]) && isset($sp534358[0]['count'])) { $spd43bb3['today'] = array('count' => (int) $sp534358[0]['count'], 'paid' => (int) $sp534358[0]['paid'], 'profit' => (int) $sp534358[0]['profit']); } if (isset($spd6427e[0]) && isset($spd6427e[0]['count'])) { $spd43bb3['yesterday'] = array('count' => (int) $spd6427e[0]['count'], 'paid' => (int) $spd6427e[0]['paid'], 'profit' => (int) $spd6427e[0]['profit']); } $spd43bb3['need_ship_count'] = Order::whereUserId(\Auth::Id())->where('status', Order::STATUS_PAID)->count(); $spd43bb3['login'] = \App\Log::where('action', \App\Log::ACTION_LOGIN)->latest()->firstOrFail(); return Response::success($spd43bb3); } function clearCache() { if (function_exists('opcache_reset')) { opcache_reset(); } try { \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); } catch (\Throwable $sp96dd17) { return Response::fail($sp96dd17->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 ac6326968..194b5dcda 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($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 +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() { $spcb9bf9 = array('driver' => 'geetest', 'geetest' => Geetest\API::get()); return Response::success($spcb9bf9); } public function login(Request $sp3c91bd) { if ((int) \App\System::_get('vcode_login') === 1) { $sp6a22d6 = Geetest\API::verify($sp3c91bd->post('gt_c'), $sp3c91bd->post('gt_v'), $sp3c91bd->post('gt_s')); if (!$sp6a22d6) { return Response::fail('滑动验证超时,请返回页面重试。'); } } $sp3efd11 = $sp3c91bd->input('remember') == 'true'; if (!Auth::attempt(array('email' => $sp3c91bd->input('email'), 'password' => $sp3c91bd->input('password')), $sp3efd11)) { return Response::fail('邮箱或密码错误, 请检查'); } else { $spa58538 = new \App\Log(); $spa58538->user_id = Auth::Id(); $spa58538->ip = Helper::getIP(); $spa58538->action = \App\Log::ACTION_LOGIN; $spa58538->save(); $spb14cf0 = Auth::getUser(); $spb14cf0->addHidden(array('created_at', 'updated_at')); return Response::success(array('token' => 'login', 'user' => $spb14cf0->toArray())); } } function info() { $spb14cf0 = Auth::getUser(); $spb14cf0->addHidden(array('created_at', 'updated_at')); $spb14cf0->setAttribute('shop_name', \App\System::_get('app_name')); return Response::success(array('token' => 'login', 'user' => $spb14cf0->toArray())); } function logout(Request $sp3c91bd) { @Auth::logout(); return Response::success(); } function changePassword(Request $sp3c91bd) { $spb14cf0 = Auth::getUser(); $sp265a87 = $sp3c91bd->post('old', null); $sp42016f = $sp3c91bd->post('password', null); if (strlen($sp42016f) < 6 || strlen($sp42016f) > 32) { return Response::fail('请输入6-32位密码'); } if (!Hash::check($sp265a87, $spb14cf0->password)) { return Response::fail('旧密码错误,请检查'); } $spb14cf0->password = Hash::make($sp42016f); $spb14cf0->setRememberToken(str_random(60)); $spb14cf0->saveOrFail(); event(new PasswordReset($spb14cf0)); Auth::guard()->login($spb14cf0); 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 2090c055b..e1e3467a3 100644 --- a/app/Http/Controllers/Admin/Order.php +++ b/app/Http/Controllers/Admin/Order.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string', 'income' => 'required|integer', 'balance' => 'required|integer')); $spdbdb98 = $sp3c91bd->post('ids'); $sp1447ec = (int) $sp3c91bd->post('income'); $spf48d7e = (int) $sp3c91bd->post('balance'); \App\Order::whereIn('id', explode(',', $spdbdb98))->chunk(100, function ($sp58ab08) use($sp1447ec, $spf48d7e) { foreach ($sp58ab08 as $sp600a89) { $sp600a89->cards()->detach(); try { if ($sp1447ec) { $sp600a89->fundRecord()->delete(); } if ($spf48d7e) { $spb14cf0 = \App\User::lockForUpdate()->firstOrFail(); $spb14cf0->m_all -= $sp600a89->income; $spb14cf0->saveOrFail(); } $sp600a89->delete(); } catch (\Exception $sp96dd17) { } } }); return Response::success(); } function freeze(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string')); $spdbdb98 = explode(',', $sp3c91bd->post('ids')); $spf7a183 = $sp3c91bd->post('reason'); $spdba6bb = 0; $spb92e62 = 0; foreach ($spdbdb98 as $sp91aca1) { $spdba6bb++; if (FundHelper::orderFreeze($sp91aca1, $spf7a183)) { $spb92e62++; } } return Response::success(array($spdba6bb, $spb92e62)); } function unfreeze(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string')); $spdbdb98 = explode(',', $sp3c91bd->post('ids')); $spdba6bb = 0; $spb92e62 = 0; $spd977b7 = \App\Order::STATUS_FROZEN; foreach ($spdbdb98 as $sp91aca1) { $spdba6bb++; if (FundHelper::orderUnfreeze($sp91aca1, '后台操作', null, $spd977b7)) { $spb92e62++; } } return Response::success(array($spdba6bb, $spb92e62, $spd977b7)); } function set_paid(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer')); $spbabe1d = $sp3c91bd->post('id', ''); $sp3b1b1d = $sp3c91bd->post('trade_no', ''); if (strlen($sp3b1b1d) < 1) { return Response::forbidden('请输入支付系统内单号'); } $sp600a89 = \App\Order::findOrFail($spbabe1d); if ($sp600a89->status !== \App\Order::STATUS_UNPAY) { return Response::forbidden('只能操作未支付订单'); } $spc2269a = 'Admin.SetPaid'; $spd10b1a = $sp600a89->order_no; $sp0b9841 = $sp600a89->paid; try { Log::debug($spc2269a . " shipOrder start, order_no: {$spd10b1a}, amount: {$sp0b9841}, trade_no: {$sp3b1b1d}"); (new \App\Http\Controllers\Shop\Pay())->shipOrder($sp3c91bd, $spd10b1a, $sp0b9841, $sp3b1b1d); Log::debug($spc2269a . ' shipOrder end, order_no: ' . $spd10b1a); $spb92e62 = true; $sp6edbee = '发货成功'; } catch (\Exception $sp96dd17) { $spb92e62 = false; $sp6edbee = $sp96dd17->getMessage(); Log::error($spc2269a . ' shipOrder Exception: ' . $sp96dd17->getMessage()); } $sp600a89 = \App\Order::with(array('pay' => function (Relation $sp6cb35e) { $sp6cb35e->select(array('id', 'name')); }, 'card_orders.card' => function (Relation $sp6cb35e) { $sp6cb35e->select(array('id', 'card')); }))->findOrFail($spbabe1d); if ($sp600a89->status === \App\Order::STATUS_PAID) { if ($sp600a89->product->delivery === \App\Product::DELIVERY_MANUAL) { $spb92e62 = true; $sp6edbee = '已标记为付款成功
当前商品为手动发货商品, 请手动进行发货。'; } else { $spb92e62 = false; $sp6edbee = '已标记为付款成功,
但是买家库存不足, 发货失败, 请稍后尝试手动发货。'; } } return Response::success(array('code' => $spb92e62 ? 0 : -1, 'msg' => $sp6edbee, 'order' => $sp600a89)); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/Pay.php b/app/Http/Controllers/Admin/Pay.php index b04539792..13da40f52 100644 --- a/app/Http/Controllers/Admin/Pay.php +++ b/app/Http/Controllers/Admin/Pay.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd) { $sp6cb35e = \App\Pay::orderBy('sort'); $spa20949 = $sp3c91bd->post('enabled'); if (strlen($spa20949)) { $sp6cb35e->whereIn('enabled', explode(',', $spa20949)); } $sp98fed8 = $sp3c91bd->post('search', false); $sp7f8b1d = $sp3c91bd->post('val', false); if ($sp98fed8 && $sp7f8b1d) { if ($sp98fed8 == 'simple') { return Response::success($sp6cb35e->get(array('id', 'name'))); } elseif ($sp98fed8 == 'id') { $sp6cb35e->where('id', $sp7f8b1d); } else { $sp6cb35e->where($sp98fed8, 'like', '%' . $sp7f8b1d . '%'); } } $spdecb4c = $sp6cb35e->get(); return Response::success(array('list' => $spdecb4c, 'urls' => array('url' => config('app.url'), 'url_api' => config('app.url_api')))); } function stat(Request $sp3c91bd) { $this->validate($sp3c91bd, array('day' => 'required|integer|between:1,30')); $spcefb4d = (int) $sp3c91bd->input('day'); if ($spcefb4d === 30) { $spb62a88 = Carbon::now()->addMonths(-1); } else { $spb62a88 = Carbon::now()->addDays(-$spcefb4d); } $spdecb4c = $this->authQuery($sp3c91bd, \App\Order::class)->where(function ($sp6cb35e) { $sp6cb35e->where('status', \App\Order::STATUS_PAID)->orWhere('status', \App\Order::STATUS_SUCCESS); })->where('paid_at', '>=', $spb62a88)->with(array('pay' => function ($sp6cb35e) { $sp6cb35e->select(array('id', 'name')); }))->groupBy('pay_id')->selectRaw('`pay_id`,COUNT(*) as "count",SUM(`paid`) as "sum"')->get()->toArray(); $sp6a22d6 = array(); foreach ($spdecb4c as $sp807bd0) { if (isset($sp807bd0['pay']) && isset($sp807bd0['pay']['name'])) { $spcbea9e = $sp807bd0['pay']['name']; } else { $spcbea9e = '未知方式#' . $sp807bd0['pay_id']; } $sp6a22d6[$spcbea9e] = array((int) $sp807bd0['count'], (int) $sp807bd0['sum']); } return Response::success($sp6a22d6); } function edit(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer', 'name' => 'required|string', 'img' => 'required|string', 'driver' => 'required|string', 'way' => 'required|string', 'config' => 'required|string', 'fee_system' => 'required|numeric')); $spbabe1d = (int) $sp3c91bd->post('id'); $sp6b4dc2 = $sp3c91bd->post('name'); $sp379503 = $sp3c91bd->post('img'); $spa9508a = $sp3c91bd->post('comment'); $sp1feac0 = $sp3c91bd->post('driver'); $sp181543 = $sp3c91bd->post('way'); $sp8a1f10 = $sp3c91bd->post('config'); $spa20949 = (int) $sp3c91bd->post('enabled'); $sp1b768e = \App\Pay::find($spbabe1d); if (!$sp1b768e) { $sp1b768e = new \App\Pay(); } $sp1b768e->name = $sp6b4dc2; $sp1b768e->img = $sp379503; $sp1b768e->comment = $spa9508a; $sp1b768e->driver = $sp1feac0; $sp1b768e->way = $sp181543; $sp1b768e->config = $sp8a1f10; $sp1b768e->enabled = $spa20949; $sp1b768e->fee_system = $sp3c91bd->post('fee_system'); $sp1b768e->saveOrFail(); return Response::success(); } function comment(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer')); $spbabe1d = (int) $sp3c91bd->post('id'); $sp1b768e = \App\Pay::findOrFail($spbabe1d); $sp1b768e->comment = $sp3c91bd->post('comment'); $sp1b768e->save(); return Response::success(); } function sort(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer')); $spbabe1d = (int) $sp3c91bd->post('id'); $sp1b768e = \App\Pay::findOrFail($spbabe1d); $sp1b768e->sort = (int) $sp3c91bd->post('sort', 1000); $sp1b768e->save(); return Response::success(); } function fee_system(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer')); $spbabe1d = (int) $sp3c91bd->post('id'); $sp1b768e = \App\Pay::findOrFail($spbabe1d); $sp1b768e->fee_system = $sp3c91bd->post('fee_system'); $sp1b768e->saveOrFail(); return Response::success(); } function enable(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $spdbdb98 = $sp3c91bd->post('ids'); $spa20949 = (int) $sp3c91bd->post('enabled'); \App\Pay::whereIn('id', explode(',', $spdbdb98))->update(array('enabled' => $spa20949)); return Response::success(); } function delete(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer')); $spbabe1d = (int) $sp3c91bd->post('id'); \App\Pay::whereId($spbabe1d)->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 81fcb7f81..3c757b243 100644 --- a/app/Http/Controllers/Admin/System.php +++ b/app/Http/Controllers/Admin/System.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd, $spdddbaf) { foreach ($spdddbaf as $sp6b4dc2) { if ($sp3c91bd->has($sp6b4dc2)) { \App\System::_set($sp6b4dc2, $sp3c91bd->post($sp6b4dc2)); } } } private function setMoney(Request $sp3c91bd, $spdddbaf) { foreach ($spdddbaf as $sp6b4dc2) { if ($sp3c91bd->has($sp6b4dc2)) { \App\System::_set($sp6b4dc2, (int) round($sp3c91bd->post($sp6b4dc2) * 100)); } } } private function setInt(Request $sp3c91bd, $spdddbaf) { foreach ($spdddbaf as $sp6b4dc2) { if ($sp3c91bd->has($sp6b4dc2)) { \App\System::_set($sp6b4dc2, (int) $sp3c91bd->post($sp6b4dc2)); } } } function setItem(Request $sp3c91bd) { $sp6b4dc2 = $sp3c91bd->post('name'); $spae23f7 = $sp3c91bd->post('value'); if (!$sp6b4dc2 || !$spae23f7) { return Response::forbidden(); } \App\System::_set($sp6b4dc2, $spae23f7); return Response::success(); } function info(Request $sp3c91bd) { $spe4afb1 = array('app_name', 'app_title', 'app_url', 'app_url_api', 'keywords', 'description', 'shop_ann', 'shop_ann_pop', 'shop_qq', 'company', 'js_tj', 'js_kf'); $sp6e9465 = array('shop_inventory'); if ($sp3c91bd->isMethod('GET')) { $sp8a1f10 = array(); foreach ($spe4afb1 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = \App\System::_get($sp6b4dc2); } foreach ($sp6e9465 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = (int) \App\System::_get($sp6b4dc2); } return Response::success($sp8a1f10); } $sp40b98a = array('app_url' => Helper::format_url($_POST['app_url']), 'app_url_api' => Helper::format_url($_POST['app_url_api'])); $sp3c91bd->merge($sp40b98a); $this->set($sp3c91bd, $spe4afb1); $this->setInt($sp3c91bd, $sp6e9465); return Response::success(); } function theme(Request $sp3c91bd) { if ($sp3c91bd->isMethod('GET')) { \App\ShopTheme::freshList(); return Response::success(array('themes' => \App\ShopTheme::get(), 'default' => \App\ShopTheme::defaultTheme()->name)); } $spf85c53 = \App\ShopTheme::whereName($sp3c91bd->post('shop_theme'))->firstOrFail(); \App\System::_set('shop_theme_default', $spf85c53->name); $spf85c53->config = @json_decode($sp3c91bd->post('theme_config')) ?? array(); $spf85c53->saveOrFail(); return Response::success(); } function order(Request $sp3c91bd) { $spdddbaf = array('order_clean_unpay_open', 'order_clean_unpay_day'); if ($sp3c91bd->isMethod('GET')) { $sp8a1f10 = array(); foreach ($spdddbaf as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = (int) \App\System::_get($sp6b4dc2); } return Response::success($sp8a1f10); } $this->setInt($sp3c91bd, $spdddbaf); return Response::success(); } function vcode(Request $sp3c91bd) { $spe4afb1 = array('vcode_driver', 'vcode_geetest_id', 'vcode_geetest_key'); $sp6e9465 = array('vcode_login', 'vcode_shop_buy', 'vcode_shop_search'); if ($sp3c91bd->isMethod('GET')) { $sp8a1f10 = array(); foreach ($spe4afb1 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = \App\System::_get($sp6b4dc2); } foreach ($sp6e9465 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = (int) \App\System::_get($sp6b4dc2); } return Response::success($sp8a1f10); } $this->set($sp3c91bd, $spe4afb1); $this->setInt($sp3c91bd, $sp6e9465); return Response::success(); } function email(Request $sp3c91bd) { $spe4afb1 = 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'); $sp6e9465 = array('mail_send_order', 'mail_send_order_use_contact'); if ($sp3c91bd->isMethod('GET')) { $sp8a1f10 = array(); foreach ($spe4afb1 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = \App\System::_get($sp6b4dc2); } foreach ($sp6e9465 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = (int) \App\System::_get($sp6b4dc2); } return Response::success($sp8a1f10); } $this->set($sp3c91bd, $spe4afb1); $this->setInt($sp3c91bd, $sp6e9465); return Response::success(); } function sms(Request $sp3c91bd) { $spe4afb1 = array('sms_api_id', 'sms_api_key'); $sp6e9465 = array('sms_send_order', 'sms_price'); if ($sp3c91bd->isMethod('GET')) { $sp8a1f10 = array(); foreach ($spe4afb1 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = \App\System::_get($sp6b4dc2); } foreach ($sp6e9465 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = (int) \App\System::_get($sp6b4dc2); } return Response::success($sp8a1f10); } $this->set($sp3c91bd, $spe4afb1); $this->setInt($sp3c91bd, $sp6e9465); return Response::success(); } function storage(Request $sp3c91bd) { $spe4afb1 = 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'); $sp6e9465 = array('storage_oss_is_ssl', 'storage_oss_is_cname'); if ($sp3c91bd->isMethod('GET')) { $sp8a1f10 = array(); foreach ($spe4afb1 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = \App\System::_get($sp6b4dc2); } foreach ($sp6e9465 as $sp6b4dc2) { $sp8a1f10[$sp6b4dc2] = (int) \App\System::_get($sp6b4dc2); } return Response::success($sp8a1f10); } $this->set($sp3c91bd, $spe4afb1); $this->set($sp3c91bd, $sp6e9465); return Response::success(); } function emailTest(Request $sp3c91bd) { $this->validate($sp3c91bd, array('to' => 'required')); $sp5eb78e = $sp3c91bd->post('to'); try { $sp6a22d6 = Mail::to($sp5eb78e)->send(new \App\Mail\Test()); return Response::success($sp6a22d6); } catch (\Throwable $sp96dd17) { \App\Library\LogHelper::setLogFile('mail'); \Log::error('Mail Test Exception:' . $sp96dd17->getMessage()); return Response::fail($sp96dd17->getMessage(), $sp96dd17); } } function orderClean(Request $sp3c91bd) { $this->validate($sp3c91bd, array('day' => 'required|integer|min:1')); $spcefb4d = (int) $sp3c91bd->post('day'); \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new \Carbon\Carbon())->addDays(-$spcefb4d))->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 2d6840644..d881e96ba 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,2 +1,2 @@ '维护中', '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 +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 $sp3c91bd, $spea9609, $spf5be84 = 'user_id', $sp682acf = 'user_id') { return $spea9609::where($spf5be84, \Auth::id()); } protected function getUserId(Request $sp3c91bd, $sp682acf = 'user_id') { return \Auth::id(); } protected function getUserIdOrFail(Request $sp3c91bd, $sp682acf = 'user_id') { $spdad372 = self::getUserId($sp3c91bd, $sp682acf); if ($spdad372) { return $spdad372; } else { throw new \Exception('参数缺少 ' . $sp682acf); } } protected function getUser(Request $sp3c91bd) { return \Auth::getUser(); } protected function checkIsInMaintain() { if ((int) System::_get('maintain') === 1) { $sp5d56d6 = System::_get('maintain_info'); echo view('message', array('title' => '维护中', 'message' => $sp5d56d6)); die; } } protected function msg($sp6ffaef, $spfc686a = null, $spa1b46b = null) { return view('message', array('message' => $sp6ffaef, 'title' => $spfc686a, 'exception' => $spa1b46b)); } } \ No newline at end of file diff --git a/app/Http/Controllers/DevController.php b/app/Http/Controllers/DevController.php index bc245f63e..7e76ac12c 100644 --- a/app/Http/Controllers/DevController.php +++ b/app/Http/Controllers/DevController.php @@ -1,2 +1,2 @@ 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 +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($sp94d423) { if (is_dir($sp94d423)) { if (is_readable($sp94d423)) { $spf15613 = scandir($sp94d423); foreach ($spf15613 as $sp6367f7) { if ($sp6367f7 != '.' && $sp6367f7 != '..') { if (!self::check_readable_r($sp94d423 . '/' . $sp6367f7)) { return false; } else { continue; } } } echo $sp94d423 . ' ...... R
'; return true; } else { echo $sp94d423 . ' ...... R
'; return false; } } else { if (file_exists($sp94d423)) { return is_readable($sp94d423); } } echo $sp94d423 . ' ...... 文件不存在
'; return false; } private function check_writable_r($sp94d423) { if (is_dir($sp94d423)) { if (is_writable($sp94d423)) { $spf15613 = scandir($sp94d423); foreach ($spf15613 as $sp6367f7) { if ($sp6367f7 != '.' && $sp6367f7 != '..') { if (!self::check_writable_r($sp94d423 . '/' . $sp6367f7)) { return false; } else { continue; } } } echo $sp94d423 . ' ...... W
'; return true; } else { echo $sp94d423 . ' ...... W
'; return false; } } else { if (file_exists($sp94d423)) { return is_writable($sp94d423); } } echo $sp94d423 . ' ...... 文件不存在
'; return false; } private function checkPathPermission($sp5af18a) { self::check_readable_r($sp5af18a); self::check_writable_r($sp5af18a); } public function install() { $sp26326e = array(); @ob_start(); self::checkPathPermission(base_path('storage')); self::checkPathPermission(base_path('bootstrap/cache')); $sp26326e['permission'] = @ob_get_clean(); return view('install', array('var' => $sp26326e)); } public function test(Request $sp3c91bd) { } } \ No newline at end of file diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index e7ec33b17..43ccc80f9 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')) { $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') ? '密码错误,请重新输入' : '请输入密码') . '
+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($spb14cf0, $spa74819 = null, $spe7d79d = null) { $sp8a1f10 = array('url' => config('app.url'), 'company' => config('app.company'), 'name' => config('app.name'), 'logo' => config('app.logo'), 'functions' => array()); if (System::_getInt('product_manual')) { $sp8a1f10['functions'][] = 'product_manual'; } if (System::_getInt('mail_send_order')) { $sp8a1f10['functions'][] = 'mail_send_order'; if (System::_getInt('mail_send_order_use_contact')) { $sp8a1f10['functions'][] = 'mail_send_order_use_contact'; } } if (System::_getInt('sms_send_order')) { $sp8a1f10['functions'][] = 'sms_send_order'; $sp8a1f10['sms_send_order'] = array('sms_price' => System::_getInt('sms_price')); } $sp8a1f10['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 ($spe7d79d) { $spa74819->setVisible(array('id', 'name', 'password_open')); if ($spa74819->password_open) { $spa74819->setAttribute('password', $spa74819->getTmpPassword()); $spa74819->addVisible(array('password')); } $spe7d79d->setForShop($spb14cf0); $sp8a1f10['categories'] = array($spa74819); $sp8a1f10['product'] = $spe7d79d; $sp6b4dc2 = $spe7d79d->name . ' - ' . $sp8a1f10['name']; $spdab1b1 = $spe7d79d->description; if (@$spdab1b1[0] === '{') { $sp7e4469 = array(); preg_match_all('/"insert":"(.+?)"/', $spdab1b1, $sp7e4469); $spdab1b1 = str_replace('\\n', ' ', @join(' ', $sp7e4469[1])); } } elseif ($spa74819) { $spa74819->setVisible(array('id', 'name', 'password_open')); $sp8a1f10['categories'] = array($spa74819); $sp8a1f10['product'] = null; $sp6b4dc2 = $spa74819->name . ' - ' . $sp8a1f10['name']; $spdab1b1 = $spa74819->name; } else { $sp0f87c6 = Category::where('user_id', $spb14cf0->id)->orderBy('sort')->where('enabled', 1)->get(); foreach ($sp0f87c6 as $spa74819) { $spa74819->setVisible(array('id', 'name', 'password_open')); } $sp8a1f10['categories'] = $sp0f87c6; $sp6b4dc2 = $sp8a1f10['name']; $spdab1b1 = $sp8a1f10['shop']['ann']; if (@$spdab1b1[0] === '{') { $sp7e4469 = array(); preg_match_all('/"insert":"(.+?)"/', $spdab1b1, $sp7e4469); $spdab1b1 = str_replace('\\n', ' ', @join(' ', $sp7e4469[1])); } } $sp8a1f10['vcode'] = array('driver' => System::_get('vcode_driver'), 'buy' => (int) System::_get('vcode_shop_buy'), 'search' => (int) System::_get('vcode_shop_search')); if ($sp8a1f10['vcode']['driver'] === 'geetest' && ($sp8a1f10['vcode'] || $sp8a1f10['search'])) { $sp8a1f10['vcode']['geetest'] = Geetest\API::get(); } $sp8a1f10['pays'] = Pay::whereRaw('enabled&' . (Helper::is_mobile() ? Pay::ENABLED_MOBILE : Pay::ENABLED_PC) . '!=0')->orderBy('sort')->get(array('id', 'name', 'img')); $sp7eb55c = Cookie::get('customer'); $sp4bbe0a = Cookie::make('customer', strlen($sp7eb55c) !== 32 ? md5(str_random(16)) : $sp7eb55c, 43200, null, null, false, false); $spf85c53 = null; if (isset($_GET['theme'])) { $spf85c53 = \App\ShopTheme::whereName($_GET['theme'])->first(); } if (!$spf85c53) { $spf85c53 = \App\ShopTheme::defaultTheme(); } $sp8a1f10['theme'] = $spb14cf0->theme_config && isset($spb14cf0->theme_config[$spf85c53->name]) ? $spb14cf0->theme_config[$spf85c53->name] : $spf85c53->config; if (isset($sp8a1f10['theme']['background']) && $sp8a1f10['theme']['background'] === '内置1') { $sp8a1f10['theme']['background'] = Helper::b1_rand_background(); } if ($spe7d79d === null) { if (@$sp8a1f10['theme']['list_type'] === 'list') { foreach ($sp8a1f10['categories'] as $spb8b025) { if (!$spb8b025->password_open) { $spb8b025->getProductsForShop(); } } } else { if (count($sp8a1f10['categories']) === 1) { $spb8b025 = $sp8a1f10['categories'][0]; if (!$spb8b025->password_open) { $spb8b025->getProductsForShop(); } } } } return response()->view('shop_theme.' . $spf85c53->name . '.index', array('name' => $sp6b4dc2, 'title' => config('app.title'), 'keywords' => preg_replace('/[、,;。!?]/', ', ', $sp6b4dc2), 'description' => $spdab1b1, 'js_tj' => System::_get('js_tj'), 'js_kf' => System::_get('js_kf'), 'config' => $sp8a1f10))->cookie($sp4bbe0a); } private function _shop_404() { $this->checkIsInMaintain(); return view('message', array('title' => '404 NotFound', 'message' => '该链接不存在
+查询订单')); } public function shop_default(Request $sp3c91bd) { $spc996e3 = $sp3c91bd->get('tab', ''); return response()->redirectTo('/?theme=Material#/record?tab=' . $spc996e3); } public function shop_category($sp5aaeda) { $this->checkIsInMaintain(); $spa74819 = Category::whereId(Helper::id_decode($sp5aaeda, Helper::ID_TYPE_CATEGORY))->with('user')->first(); if (!$spa74819 && is_numeric($spa74819)) { $spa74819 = Category::whereId($sp5aaeda)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with('user')->first(); } if (!$spa74819) { return $this->_shop_404(); } return $this->_shop_render($spa74819->user, $spa74819); } public function shop_product(Request $sp3c91bd, $spb3db9e) { $this->checkIsInMaintain(); $spe7d79d = Product::whereId(Helper::id_decode($spb3db9e, Helper::ID_TYPE_PRODUCT))->with(array('user', 'category'))->first(); if (!$spe7d79d && is_numeric($spb3db9e)) { $spe7d79d = Product::whereId($spb3db9e)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with(array('user', 'category'))->first(); } if (!$spe7d79d || !$spe7d79d->category) { return $this->_shop_404(); } if ($spe7d79d->password_open && $spe7d79d->password !== $sp3c91bd->input('p')) { return view('message', array('title' => '当前商品需要密码', 'message' => ($sp3c91bd->has('p') ? '密码错误,请重新输入' : '请输入密码') . '
-')); } 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 +')); } return $this->_shop_render($spe7d79d->user, $spe7d79d->category, $spe7d79d); } public function shop() { $this->checkIsInMaintain(); $spb14cf0 = User::firstOrFail(); return $this->_shop_render($spb14cf0); } public function admin() { $sp8a1f10 = array(); $sp8a1f10['url'] = config('app.url'); if (System::_getInt('product_manual')) { $sp8a1f10['functions'] = array('product_manual'); } $sp8a1f10['vcode'] = array('driver' => System::_get('vcode_driver'), 'login' => (int) System::_get('vcode_login')); if ($sp8a1f10['vcode']['driver'] === 'geetest') { $sp8a1f10['vcode']['geetest'] = Geetest\API::get(); } return view('admin', array('config' => $sp8a1f10)); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Card.php b/app/Http/Controllers/Merchant/Card.php index 4823fbb41..c1c2de572 100644 --- a/app/Http/Controllers/Merchant/Card.php +++ b/app/Http/Controllers/Merchant/Card.php @@ -1,4 +1,4 @@ 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 +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 $sp3c91bd, $spbf8e79 = false, $spd76466 = false, $spf634c5 = false) { $sp6cb35e = $this->authQuery($sp3c91bd, \App\Card::class)->with(array('product' => function ($sp6cb35e) { $sp6cb35e->select(array('id', 'name')); })); $sp98fed8 = $sp3c91bd->input('search', false); $sp7f8b1d = $sp3c91bd->input('val', false); if ($sp98fed8 && $sp7f8b1d) { if ($sp98fed8 == 'id') { $sp6cb35e->where('id', $sp7f8b1d); } else { $sp6cb35e->where($sp98fed8, 'like', '%' . $sp7f8b1d . '%'); } } $sp8af541 = (int) $sp3c91bd->input('category_id'); $sp5d967e = $sp3c91bd->input('product_id', -1); if ($sp8af541 > 0) { if ($sp5d967e > 0) { $sp6cb35e->where('product_id', $sp5d967e); } else { $sp6cb35e->whereHas('product', function ($sp6cb35e) use($sp8af541) { $sp6cb35e->where('category_id', $sp8af541); }); } } $sp31859f = $sp3c91bd->input('status'); if (strlen($sp31859f)) { $sp6cb35e->whereIn('status', explode(',', $sp31859f)); } $sp19a35c = (int) $sp3c91bd->input('onlyCanSell'); if ($sp19a35c) { $sp6cb35e->whereRaw('`count_all`>`count_sold`'); } $sp0fe7ec = $sp3c91bd->input('type'); if (strlen($sp0fe7ec)) { $sp6cb35e->whereIn('type', explode(',', $sp0fe7ec)); } $sp24dca8 = $sp3c91bd->input('trashed') === 'true'; if ($sp24dca8) { $sp6cb35e->onlyTrashed(); } if ($spd76466 === true) { if ($sp24dca8) { $sp6cb35e->forceDelete(); } else { \App\Card::_trash($sp6cb35e); } return Response::success(); } else { if ($sp24dca8 && $spf634c5 === true) { \App\Card::_restore($sp6cb35e); return Response::success(); } else { $sp6cb35e->orderByRaw('`product_id`,`type`,`status`,`id`'); if ($spbf8e79 === true) { $sp8c364b = ''; $sp6cb35e->chunk(100, function ($spf7b822) use(&$sp8c364b) { foreach ($spf7b822 as $sp3fbb89) { $sp8c364b .= $sp3fbb89->card . ' +'; } }); $sp491909 = 'export_cards_' . $this->getUserIdOrFail($sp3c91bd) . '_' . date('YmdHis') . '.txt'; $spa565dd = array('Content-type' => 'text/plain', 'Content-Disposition' => sprintf('attachment; filename="%s"', $sp491909), 'Content-Length' => strlen($sp8c364b)); return response()->make($sp8c364b, 200, $spa565dd); } $spf8ae2a = $sp3c91bd->input('current_page', 1); $spa4d3d7 = $sp3c91bd->input('per_page', 20); $spdecb4c = $sp6cb35e->paginate($spa4d3d7, array('*'), 'page', $spf8ae2a); return Response::success($spdecb4c); } } } function export(Request $sp3c91bd) { return self::get($sp3c91bd, true); } function trash(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string')); $spdbdb98 = $sp3c91bd->post('ids'); $sp6cb35e = $this->authQuery($sp3c91bd, \App\Card::class)->whereIn('id', explode(',', $spdbdb98)); \App\Card::_trash($sp6cb35e); return Response::success(); } function restoreTrashed(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string')); $spdbdb98 = $sp3c91bd->post('ids'); $sp6cb35e = $this->authQuery($sp3c91bd, \App\Card::class)->whereIn('id', explode(',', $spdbdb98)); \App\Card::_restore($sp6cb35e); return Response::success(); } function deleteTrashed(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string')); $spdbdb98 = $sp3c91bd->post('ids'); $this->authQuery($sp3c91bd, \App\Card::class)->whereIn('id', explode(',', $spdbdb98))->forceDelete(); return Response::success(); } function deleteAll(Request $sp3c91bd) { return $this->get($sp3c91bd, false, true); } function restoreAll(Request $sp3c91bd) { return $this->get($sp3c91bd, false, false, true); } function add(Request $sp3c91bd) { $sp5d967e = (int) $sp3c91bd->post('product_id'); $spf7b822 = $sp3c91bd->post('card'); $sp0fe7ec = (int) $sp3c91bd->post('type', \App\Card::TYPE_ONETIME); $sp0d89d4 = $sp3c91bd->post('is_check') === 'true'; if (str_contains($spf7b822, '<') || str_contains($spf7b822, '>')) { return Response::fail('卡密不能包含 < 或 > 符号'); } $spdad372 = $this->getUserIdOrFail($sp3c91bd); $sp8f7ce7 = $this->authQuery($sp3c91bd, \App\Product::class)->where('id', $sp5d967e); $sp8f7ce7->firstOrFail(array('id')); if ($sp0fe7ec === \App\Card::TYPE_REPEAT) { if ($sp0d89d4) { if (\App\Card::where('product_id', $sp5d967e)->where('card', $spf7b822)->exists()) { return Response::fail('该卡密已经存在,添加失败'); } } $sp3fbb89 = new \App\Card(array('user_id' => $spdad372, 'product_id' => $sp5d967e, 'card' => $spf7b822, 'type' => \App\Card::TYPE_REPEAT, 'count_sold' => 0, 'count_all' => (int) $sp3c91bd->post('count_all', 1))); if ($sp3fbb89->count_all < 1 || $sp3fbb89->count_all > 10000000) { return Response::forbidden('可售总次数不能超过10000000'); } return DB::transaction(function () use($sp8f7ce7, $sp3fbb89) { $sp3fbb89->saveOrFail(); $spe7d79d = $sp8f7ce7->lockForUpdate()->firstOrFail(); $spe7d79d->count_all += $sp3fbb89->count_all; $spe7d79d->saveOrFail(); return Response::success(); }); } else { $sp3301fd = explode(' +', $spf7b822); $speef520 = count($sp3301fd); $sp485aa2 = 50000; if ($speef520 > $sp485aa2) { return Response::fail('每次添加不能超过 ' . $sp485aa2 . ' 张'); } $spcd19cb = array(); if ($sp0d89d4) { $sp6378bd = \App\Card::where('user_id', $spdad372)->where('product_id', $sp5d967e)->get(array('card'))->all(); foreach ($sp6378bd as $sp0fd495) { $spcd19cb[] = $sp0fd495['card']; } } $spdbab8f = array(); $sp82c5ea = 0; for ($spe89d11 = 0; $spe89d11 < $speef520; $spe89d11++) { $sp2e3b9a = trim($sp3301fd[$spe89d11]); if (strlen($sp2e3b9a) < 1) { continue; } if (strlen($sp2e3b9a) > 255) { return Response::fail('第 ' . $spe89d11 . ' 张卡密 ' . $sp2e3b9a . ' 长度错误
卡密最大长度为255'); } if ($sp0d89d4) { if (in_array($sp2e3b9a, $spcd19cb)) { continue; } $spcd19cb[] = $sp2e3b9a; } $spdbab8f[] = array('user_id' => $spdad372, 'product_id' => $sp5d967e, 'card' => $sp2e3b9a, 'type' => \App\Card::TYPE_ONETIME); $sp82c5ea++; } if ($sp82c5ea === 0) { return Response::success(); } return DB::transaction(function () use($sp8f7ce7, $spdbab8f, $sp82c5ea) { \App\Card::insert($spdbab8f); $spe7d79d = $sp8f7ce7->lockForUpdate()->firstOrFail(); $spe7d79d->count_all += $sp82c5ea; $spe7d79d->saveOrFail(); return Response::success(); }); } } function edit(Request $sp3c91bd) { $spbabe1d = (int) $sp3c91bd->post('id'); $sp3fbb89 = $this->authQuery($sp3c91bd, \App\Card::class)->findOrFail($spbabe1d); if ($sp3fbb89) { $sp93b5fa = $sp3c91bd->post('card'); $sp0fe7ec = (int) $sp3c91bd->post('type', \App\Card::TYPE_ONETIME); $sp879eed = (int) $sp3c91bd->post('count_all', 1); return DB::transaction(function () use($sp3fbb89, $sp93b5fa, $sp0fe7ec, $sp879eed) { $sp3fbb89 = \App\Card::where('id', $sp3fbb89->id)->lockForUpdate()->firstOrFail(); $sp3fbb89->card = $sp93b5fa; $sp3fbb89->type = $sp0fe7ec; if ($sp3fbb89->type === \App\Card::TYPE_REPEAT) { if ($sp879eed < $sp3fbb89->count_sold) { return Response::forbidden('可售总次数不能低于当前已售次数'); } if ($sp879eed < 1 || $sp879eed > 10000000) { return Response::forbidden('可售总次数不能超过10000000'); } $sp3fbb89->count_all = $sp879eed; } else { $sp3fbb89->count_all = 1; } $sp3fbb89->saveOrFail(); $spe7d79d = $sp3fbb89->product()->lockForUpdate()->firstOrFail(); $spe7d79d->count_all -= $sp3fbb89->count_all; $spe7d79d->count_all += $sp879eed; $spe7d79d->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 8711d1264..ca097ac07 100644 --- a/app/Http/Controllers/Merchant/Category.php +++ b/app/Http/Controllers/Merchant/Category.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd) { $spf8ae2a = $sp3c91bd->post('current_page', 1); $spa4d3d7 = $sp3c91bd->post('per_page', 20); $sp6cb35e = $this->authQuery($sp3c91bd, \App\Category::class); $sp98fed8 = $sp3c91bd->post('search', false); $sp7f8b1d = $sp3c91bd->post('val', false); if ($sp98fed8 && $sp7f8b1d) { if ($sp98fed8 == 'simple') { return Response::success($sp6cb35e->get(array('id', 'name'))); } elseif ($sp98fed8 == 'id') { $sp6cb35e->where('id', $sp7f8b1d); } else { $sp6cb35e->where($sp98fed8, 'like', '%' . $sp7f8b1d . '%'); } } $spa20949 = $sp3c91bd->post('enabled'); if (strlen($spa20949)) { $sp6cb35e->whereIn('enabled', explode(',', $spa20949)); } $spdecb4c = $sp6cb35e->withCount('products')->orderBy('sort')->paginate($spa4d3d7, array('*'), 'page', $spf8ae2a); foreach ($spdecb4c->items() as $spa74819) { $spa74819->setAppends(array('url')); } return Response::success($spdecb4c); } function sort(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer')); $spa74819 = $this->authQuery($sp3c91bd, \App\Category::class)->findOrFail($sp3c91bd->post('id')); $spa74819->sort = (int) $sp3c91bd->post('sort', 1000); $spa74819->save(); return Response::success(); } function edit(Request $sp3c91bd) { $this->validate($sp3c91bd, array('name' => 'required|string|max:128')); $sp6b4dc2 = $sp3c91bd->post('name'); $spa20949 = (int) $sp3c91bd->post('enabled'); $sp6dd879 = $sp3c91bd->post('sort'); $sp6dd879 = $sp6dd879 === NULL ? 1000 : (int) $sp6dd879; if (System::_getInt('filter_words_open') === 1) { $spcd9c68 = explode('|', System::_get('filter_words')); if (($sp6a22d6 = Helper::filterWords($sp6b4dc2, $spcd9c68)) !== false) { return Response::fail('提交失败! 分类名称包含敏感词: ' . $sp6a22d6); } } if ($sp6dd879 < 0 || $sp6dd879 > 1000000) { return Response::fail('排序需要在0-1000000之间'); } $sp42016f = $sp3c91bd->post('password'); $sp48ffe1 = $sp3c91bd->post('password_open') === 'true'; if ((int) $sp3c91bd->post('id')) { $spa74819 = $this->authQuery($sp3c91bd, \App\Category::class)->findOrFail($sp3c91bd->post('id')); } else { $spa74819 = new \App\Category(); $spa74819->user_id = $this->getUserIdOrFail($sp3c91bd); } $spa74819->name = $sp6b4dc2; $spa74819->sort = $sp6dd879; $spa74819->password = $sp42016f; $spa74819->password_open = $sp48ffe1; $spa74819->enabled = $spa20949; $spa74819->saveOrFail(); return Response::success(); } function enable(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,1')); $spdbdb98 = $sp3c91bd->post('ids', ''); $spa20949 = (int) $sp3c91bd->post('enabled'); $this->authQuery($sp3c91bd, \App\Category::class)->whereIn('id', explode(',', $spdbdb98))->update(array('enabled' => $spa20949)); return Response::success(); } function delete(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string')); $spdbdb98 = $sp3c91bd->post('ids', ''); $this->authQuery($sp3c91bd, \App\Category::class)->whereIn('id', explode(',', $spdbdb98))->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 9bc6fae04..89b294b31 100644 --- a/app/Http/Controllers/Merchant/Coupon.php +++ b/app/Http/Controllers/Merchant/Coupon.php @@ -1,3 +1,3 @@ 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 +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 $sp3c91bd) { $sp6cb35e = $this->authQuery($sp3c91bd, \App\Coupon::class)->with(array('category' => function ($sp6cb35e) { $sp6cb35e->select(array('id', 'name')); }))->with(array('product' => function ($sp6cb35e) { $sp6cb35e->select(array('id', 'name')); })); $sp98fed8 = $sp3c91bd->post('search', false); $sp7f8b1d = $sp3c91bd->post('val', false); if ($sp98fed8 && $sp7f8b1d) { if ($sp98fed8 == 'id') { $sp6cb35e->where('id', $sp7f8b1d); } else { $sp6cb35e->where($sp98fed8, 'like', '%' . $sp7f8b1d . '%'); } } $sp8af541 = (int) $sp3c91bd->post('category_id'); $sp5d967e = $sp3c91bd->post('product_id', -1); if ($sp8af541 > 0) { if ($sp5d967e > 0) { $sp6cb35e->where('product_id', $sp5d967e); } else { $sp6cb35e->where('category_id', $sp8af541); } } $sp31859f = $sp3c91bd->post('status'); if (strlen($sp31859f)) { $sp6cb35e->whereIn('status', explode(',', $sp31859f)); } $sp0fe7ec = $sp3c91bd->post('type'); if (strlen($sp0fe7ec)) { $sp6cb35e->whereIn('type', explode(',', $sp0fe7ec)); } $sp6cb35e->orderByRaw('expire_at DESC,category_id,product_id,type,status'); $spf8ae2a = $sp3c91bd->post('current_page', 1); $spa4d3d7 = $sp3c91bd->post('per_page', 20); $spdecb4c = $sp6cb35e->paginate($spa4d3d7, array('*'), 'page', $spf8ae2a); return Response::success($spdecb4c); } function create(Request $sp3c91bd) { $spdba6bb = $sp3c91bd->post('count', 0); $sp0fe7ec = (int) $sp3c91bd->post('type', \App\Coupon::TYPE_ONETIME); $spfb7a8e = $sp3c91bd->post('expire_at'); $sp2e2da2 = (int) $sp3c91bd->post('discount_val'); $sp2ba462 = (int) $sp3c91bd->post('discount_type', \App\Coupon::DISCOUNT_TYPE_AMOUNT); $sp7b8ff5 = $sp3c91bd->post('remark'); if ($sp2ba462 === \App\Coupon::DISCOUNT_TYPE_AMOUNT) { if ($sp2e2da2 < 1 || $sp2e2da2 > 1000000000) { return Response::fail('优惠券面额需要在0.01-10000000之间'); } } if ($sp2ba462 === \App\Coupon::DISCOUNT_TYPE_PERCENT) { if ($sp2e2da2 < 1 || $sp2e2da2 > 100) { return Response::fail('优惠券面额需要在1-100之间'); } } $sp8af541 = (int) $sp3c91bd->post('category_id', -1); $sp5d967e = (int) $sp3c91bd->post('product_id', -1); if ($sp0fe7ec === \App\Coupon::TYPE_REPEAT) { $spda423d = $sp3c91bd->post('coupon'); if (!$spda423d) { $spda423d = strtoupper(str_random()); } $sp9ac414 = new \App\Coupon(); $sp9ac414->user_id = $this->getUserIdOrFail($sp3c91bd); $sp9ac414->category_id = $sp8af541; $sp9ac414->product_id = $sp5d967e; $sp9ac414->coupon = $spda423d; $sp9ac414->type = $sp0fe7ec; $sp9ac414->discount_val = $sp2e2da2; $sp9ac414->discount_type = $sp2ba462; $sp9ac414->count_all = (int) $sp3c91bd->post('count_all', 1); if ($sp9ac414->count_all < 1 || $sp9ac414->count_all > 10000000) { return Response::fail('可用次数不能超过10000000'); } $sp9ac414->expire_at = $spfb7a8e; $sp9ac414->saveOrFail(); return Response::success(array($sp9ac414->coupon)); } elseif ($sp0fe7ec === \App\Coupon::TYPE_ONETIME) { if (!$spdba6bb) { return Response::forbidden('请输入生成数量'); } if ($spdba6bb > 100) { return Response::forbidden('每次生成不能大于100张'); } $sp5984c3 = array(); $sp3c8dfc = array(); $spdad372 = $this->getUserIdOrFail($sp3c91bd); $spd8f589 = Carbon::now(); for ($spe89d11 = 0; $spe89d11 < $spdba6bb; $spe89d11++) { $sp9ac414 = strtoupper(str_random()); $sp3c8dfc[] = $sp9ac414; $sp5984c3[] = array('user_id' => $spdad372, 'coupon' => $sp9ac414, 'category_id' => $sp8af541, 'product_id' => $sp5d967e, 'type' => $sp0fe7ec, 'discount_val' => $sp2e2da2, 'discount_type' => $sp2ba462, 'status' => \App\Coupon::STATUS_NORMAL, 'remark' => $sp7b8ff5, 'created_at' => $spd8f589, 'expire_at' => $spfb7a8e); } \App\Coupon::insert($sp5984c3); return Response::success($sp3c8dfc); } else { return Response::forbidden('unknown type: ' . $sp0fe7ec); } } function edit(Request $sp3c91bd) { $spbabe1d = (int) $sp3c91bd->post('id'); $spda423d = $sp3c91bd->post('coupon'); $sp8af541 = (int) $sp3c91bd->post('category_id', -1); $sp5d967e = (int) $sp3c91bd->post('product_id', -1); $spfb7a8e = $sp3c91bd->post('expire_at', NULL); $sp31859f = (int) $sp3c91bd->post('status', \App\Coupon::STATUS_NORMAL); $sp0fe7ec = (int) $sp3c91bd->post('type', \App\Coupon::TYPE_ONETIME); $sp2e2da2 = (int) $sp3c91bd->post('discount_val'); $sp2ba462 = (int) $sp3c91bd->post('discount_type', \App\Coupon::DISCOUNT_TYPE_AMOUNT); if ($sp2ba462 === \App\Coupon::DISCOUNT_TYPE_AMOUNT) { if ($sp2e2da2 < 1 || $sp2e2da2 > 1000000000) { return Response::fail('优惠券面额需要在0.01-10000000之间'); } } if ($sp2ba462 === \App\Coupon::DISCOUNT_TYPE_PERCENT) { if ($sp2e2da2 < 1 || $sp2e2da2 > 100) { return Response::fail('优惠券面额需要在1-100之间'); } } $sp9ac414 = $this->authQuery($sp3c91bd, \App\Coupon::class)->find($spbabe1d); if ($sp9ac414) { $sp9ac414->coupon = $spda423d; $sp9ac414->category_id = $sp8af541; $sp9ac414->product_id = $sp5d967e; $sp9ac414->status = $sp31859f; $sp9ac414->type = $sp0fe7ec; $sp9ac414->discount_val = $sp2e2da2; $sp9ac414->discount_type = $sp2ba462; if ($sp0fe7ec === \App\Coupon::TYPE_REPEAT) { $sp9ac414->count_all = (int) $sp3c91bd->post('count_all', 1); if ($sp9ac414->count_all < 1 || $sp9ac414->count_all > 10000000) { return Response::fail('可用次数不能超过10000000'); } } if ($spfb7a8e) { $sp9ac414->expire_at = $spfb7a8e; } $sp9ac414->saveOrFail(); } else { $sp309243 = explode(' +', $spda423d); for ($spe89d11 = 0; $spe89d11 < count($sp309243); $spe89d11++) { $sp352dfa = str_replace(' ', '', trim($sp309243[$spe89d11])); $sp9ac414 = new \App\Coupon(); $sp9ac414->coupon = $sp352dfa; $sp9ac414->category_id = $sp8af541; $sp9ac414->product_id = $sp5d967e; $sp9ac414->status = $sp31859f; $sp9ac414->type = $sp0fe7ec; $sp9ac414->discount_val = $sp2e2da2; $sp9ac414->discount_type = $sp2ba462; $sp309243[$spe89d11] = $sp9ac414; } \App\Product::find($sp5d967e)->coupons()->saveMany($sp309243); } return Response::success(); } function enable(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,1')); $spdbdb98 = $sp3c91bd->post('ids'); $spa20949 = (int) $sp3c91bd->post('enabled'); $this->authQuery($sp3c91bd, \App\Coupon::class)->whereIn('id', explode(',', $spdbdb98))->update(array('enabled' => $spa20949)); return Response::success(); } function delete(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string')); $spdbdb98 = $sp3c91bd->post('ids'); $this->authQuery($sp3c91bd, \App\Coupon::class)->whereIn('id', explode(',', $spdbdb98))->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 8631cc1d1..965f5df49 100644 --- a/app/Http/Controllers/Merchant/File.php +++ b/app/Http/Controllers/Merchant/File.php @@ -1,2 +1,2 @@ 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 +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($spefa168, $spdad372, $spdeba28, $sp48d2d8 = false) { try { $sp9cc497 = $spefa168->extension(); } catch (\Throwable $sp96dd17) { return Response::fail($sp96dd17->getMessage()); } if (!$spefa168 || !in_array(strtolower($sp9cc497), array('jpg', 'jpeg', 'png', 'gif'))) { return Response::fail('图片错误, 系统支持jpg/png/gif格式'); } if ($spefa168->getSize() > 5 * 1024 * 1024) { return Response::fail('图片不能大于5MB'); } try { $sp5af18a = $spefa168->store($spdeba28, array('disk' => System::_get('storage_driver'))); } catch (\Exception $sp96dd17) { \Log::error('File.uploadImg folder:' . $spdeba28 . ', error:' . $sp96dd17->getMessage(), array('exception' => $sp96dd17)); if (config('app.debug')) { return Response::fail($sp96dd17->getMessage()); } else { return Response::fail('上传文件失败, 内部错误, 请联系客服'); } } if (!$sp5af18a) { return Response::fail('系统保存文件出错, 请稍后再试'); } $sp1feac0 = System::_get('storage_driver'); $sp40b98a = Storage::disk($sp1feac0)->url($sp5af18a); $sp4332c9 = \App\File::insertGetId(array('user_id' => $spdad372, 'driver' => $sp1feac0, 'path' => $sp5af18a, 'url' => $sp40b98a)); if ($sp4332c9 < 1) { Storage::disk($sp1feac0)->delete($sp5af18a); return Response::fail('数据库繁忙,请稍后再试'); } $sp6a22d6 = array('id' => $sp4332c9, 'url' => $sp40b98a, 'name' => pathinfo($sp5af18a, PATHINFO_BASENAME)); if ($sp48d2d8) { return $sp6a22d6; } return Response::success($sp6a22d6); } function upload_merchant(Request $sp3c91bd) { $spb14cf0 = $this->getUser($sp3c91bd); if ($spb14cf0 === null) { return Response::forbidden('无效的用户'); } $spefa168 = $sp3c91bd->file('file'); return $this->uploadImg($spefa168, $spb14cf0->id, \App\File::getProductFolder()); } public function renderImage(Request $sp3c91bd, $sp6bb33d) { if (str_contains($sp6bb33d, '..') || str_contains($sp6bb33d, './') || str_contains($sp6bb33d, '.\\') || !starts_with($sp6bb33d, 'images/')) { $sp60c0bb = file_get_contents(public_path('images/illegal.jpg')); } else { $sp6bb33d = str_replace('\\', '/', $sp6bb33d); $spefa168 = \App\File::wherePath($sp6bb33d)->first(); if ($spefa168) { $sp1feac0 = $spefa168->driver; } else { $sp1feac0 = System::_get('storage_driver'); } if (!in_array($sp1feac0, array('local', 's3', 'oss', 'qiniu'))) { return response()->view('message', array('title' => '404', 'message' => '404 Driver NotFound'), 404); } try { $sp60c0bb = Storage::disk($sp1feac0)->get($sp6bb33d); } catch (\Illuminate\Contracts\Filesystem\FileNotFoundException $sp96dd17) { \Log::error('File.renderImage error: ' . $sp96dd17->getMessage(), array('exception' => $sp96dd17)); return response()->view('message', array('title' => '404', 'message' => '404 NotFound'), 404); } } ob_end_clean(); header('Content-Type: ' . mimetype_from_filename($sp6bb33d)); die($sp60c0bb); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Log.php b/app/Http/Controllers/Merchant/Log.php index 5940c8395..bff2bbb25 100644 --- a/app/Http/Controllers/Merchant/Log.php +++ b/app/Http/Controllers/Merchant/Log.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd) { $spdad372 = $sp3c91bd->post('user_id'); $sp60a232 = $sp3c91bd->post('action', \App\Log::ACTION_LOGIN); $sp6cb35e = \App\Log::where('action', $sp60a232); $sp6cb35e->where('user_id', Auth::id()); $spabaafc = $sp3c91bd->post('start_at'); if (strlen($spabaafc)) { $sp6cb35e->where('created_at', '>=', $spabaafc . ' 00:00:00'); } $sp250c03 = $sp3c91bd->post('end_at'); if (strlen($sp250c03)) { $sp6cb35e->where('created_at', '<=', $sp250c03 . ' 23:59:59'); } $spf8ae2a = $sp3c91bd->post('current_page', 1); $spa4d3d7 = $sp3c91bd->post('per_page', 20); $spdecb4c = $sp6cb35e->orderBy('created_at', 'DESC')->paginate($spa4d3d7, array('*'), 'page', $spf8ae2a); return Response::success($spdecb4c); } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Order.php b/app/Http/Controllers/Merchant/Order.php index 08b451d4b..8fed1146b 100644 --- a/app/Http/Controllers/Merchant/Order.php +++ b/app/Http/Controllers/Merchant/Order.php @@ -1,4 +1,4 @@ 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 +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 $sp3c91bd, $spbf8e79 = false) { $sp6cb35e = $this->authQuery($sp3c91bd, \App\Order::class); $sp8af541 = (int) $sp3c91bd->input('category_id'); $sp5d967e = (int) $sp3c91bd->input('product_id'); $speb6e00 = (int) $sp3c91bd->input('profit'); $sp3c2842 = $sp8af541 === \App\Product::ID_API || $sp5d967e === \App\Product::ID_API; $sp98fed8 = $sp3c91bd->input('search', false); $sp7f8b1d = $sp3c91bd->input('val', false); if ($sp98fed8 && $sp7f8b1d) { if ($sp98fed8 == 'id' || $sp98fed8 == 'order_no' || $sp98fed8 === 'pay_trade_no' || $sp98fed8 === 'api_out_no') { $sp6cb35e->where($sp98fed8, $sp7f8b1d); } else { $sp6cb35e->where($sp98fed8, 'like', '%' . $sp7f8b1d . '%'); } } if ($sp8af541 > 0) { if ($sp5d967e > 0) { $sp6cb35e->where('product_id', $sp5d967e); } else { $sp6cb35e->whereHas('product', function ($sp6cb35e) use($sp8af541) { $sp6cb35e->where('category_id', $sp8af541); }); } } $sp684603 = (int) $sp3c91bd->input('recent', 0); if ($sp684603) { $spabaafc = (new Carbon())->addDay(-$sp684603); $sp6cb35e->where(function ($sp6cb35e) use($spabaafc) { $sp6cb35e->where('paid_at', '>=', $spabaafc)->orWhere(function ($sp6cb35e) use($spabaafc) { $sp6cb35e->whereNull('paid_at')->where('created_at', '>=', $spabaafc); }); }); } else { $spabaafc = $sp3c91bd->input('start_at', false); if (strlen($spabaafc)) { $sp6cb35e->where(function ($sp6cb35e) use($spabaafc) { $sp6cb35e->where('paid_at', '>=', $spabaafc . ' 00:00:00')->orWhere(function ($sp6cb35e) use($spabaafc) { $sp6cb35e->whereNull('paid_at')->where('created_at', '>=', $spabaafc . ' 00:00:00'); }); }); } $sp250c03 = $sp3c91bd->input('end_at', false); if (strlen($sp250c03)) { $sp6cb35e->where(function ($sp6cb35e) use($sp250c03) { $sp6cb35e->where('paid_at', '<=', $sp250c03 . ' 23:59:59')->orWhere(function ($sp6cb35e) use($sp250c03) { $sp6cb35e->whereNull('paid_at')->where('created_at', '<=', $sp250c03 . ' 23:59:59'); }); }); } } if ($speb6e00) { $sp6cb35e->where('status', \App\Order::STATUS_SUCCESS); $spe70484 = clone $sp6cb35e; $sp2e5125 = $spe70484->selectRaw('SUM(`income`) as income, SUM(`paid`-`sms_price`-`cost`-`fee`) as profit')->first(); } else { $sp31859f = $sp3c91bd->input('status'); if (strlen($sp31859f)) { $sp6cb35e->whereIn('status', explode(',', $sp31859f)); } else { $sp6cb35e->where('status', '!=', \App\Order::STATUS_UNPAY); } } if ($sp3c2842) { $sp6cb35e->where('product_id', \App\Product::ID_API); } else { $sp6cb35e->where('product_id', '>', 0); $sp6cb35e->with(array('product' => function (Relation $sp6cb35e) { $sp6cb35e->select(array('id', 'name', 'delivery')); }, 'card_orders.card' => function (Relation $sp6cb35e) { $sp6cb35e->select(array('id', 'card')); })); } $sp6cb35e->with(array('pay' => function (Relation $sp6cb35e) { $sp6cb35e->select(array('id', 'name')); })); $sp6cb35e->orderBy('id', 'DESC'); if ($spbf8e79 === true) { $sp9fa9f0 = (int) $sp3c91bd->input('export_update_status'); $sp9a5d7c = $sp3c91bd->input('export_update_card'); $sp51da13 = ''; $sp51da13 .= '"订单号","商品名称","下单时间","订单金额","优惠金额","实付金额","手续费","成本价","利润","支付方式","支付流水号","支付时间","订单状态","买家联系方式","买家附加信息"' . ' +'; $sp6cb35e->chunk(100, function ($sp58ab08) use(&$sp51da13, $sp9fa9f0, $sp9a5d7c) { foreach ($sp58ab08 as $sp600a89) { if ($sp600a89->status === \App\Order::STATUS_PAID) { if ($sp9fa9f0 === \App\Order::SEND_STATUS_CARD_PROCESSING) { $sp600a89->send_status = $sp9fa9f0; $sp600a89->saveOrFail(); } elseif ($sp9fa9f0 === \App\Order::SEND_STATUS_CARD_SUCCESS) { $sp600a89->send_status = $sp9fa9f0; $sp600a89->saveOrFail(); $this->ship(new Request(array('id' => $sp600a89->id, 'card' => $sp9a5d7c))); } } $spe00d1f = $sp600a89->contact_ext; if ($spe00d1f) { if ($spe00d1f[0] === '[') { $spe00d1f = substr($spe00d1f, 2); } if ($spe00d1f[strlen($spe00d1f) - 1] === ']') { $spe00d1f = substr($spe00d1f, 0, -2); } } $sp51da13 .= '"' . $sp600a89->order_no . '","' . $sp600a89->product_name . '","' . $sp600a89->created_at . '","' . sprintf('%.2f', $sp600a89->price / 100) . '","' . sprintf('%.2f', $sp600a89->discount / 100) . '","' . sprintf('%.2f', $sp600a89->paid / 100) . '","' . sprintf('%.2f', $sp600a89->fee / 100) . '","' . sprintf('%.2f', $sp600a89->cost / 100) . '","' . sprintf('%.2f', ($sp600a89->paid - $sp600a89->fee - $sp600a89->cost) / 100) . '","' . ($sp600a89->pay ? $sp600a89->pay->name : '未知#' . $sp600a89->pay_id) . '","' . $sp600a89->pay_trade_no . '","' . $sp600a89->paid_at . '","' . \App\Order::STATUS[$sp600a89->status] . '","' . $sp600a89->contact . '","' . $spe00d1f . '"'; $sp51da13 .= ' +'; } }); $sp491909 = 'export_orders_' . $this->getUserIdOrFail($sp3c91bd) . '_' . date('YmdHis') . '.csv'; $spa565dd = array('Content-type' => 'text/plain', 'Content-Disposition' => sprintf('attachment; filename="%s"', $sp491909), 'Content-Length' => strlen($sp51da13)); return response()->make($sp51da13, 200, $spa565dd); } $spf8ae2a = $sp3c91bd->input('current_page', 1); $spa4d3d7 = $sp3c91bd->input('per_page', 20); $spdecb4c = $sp6cb35e->paginate($spa4d3d7, array('*'), 'page', $spf8ae2a); if ($speb6e00) { $spdecb4c = $spdecb4c->toArray(); $spdecb4c['profit_sum'] = $sp2e5125; } return Response::success($spdecb4c); } function export(Request $sp3c91bd) { return self::get($sp3c91bd, true); } function stat(Request $sp3c91bd) { $this->validate($sp3c91bd, array('day' => 'required|integer|between:7,30')); $spcefb4d = (int) $sp3c91bd->input('day'); if ($spcefb4d === 30) { $spb62a88 = Carbon::now()->addMonths(-1); } else { $spb62a88 = Carbon::now()->addDays(-$spcefb4d); } $spdecb4c = $this->authQuery($sp3c91bd, \App\Order::class)->where(function ($sp6cb35e) { $sp6cb35e->where('status', \App\Order::STATUS_PAID)->orWhere('status', \App\Order::STATUS_SUCCESS); })->where('paid_at', '>=', $spb62a88)->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(); $sp6a22d6 = array(); foreach ($spdecb4c as $sp807bd0) { $sp6a22d6[$sp807bd0['date']] = array((int) $sp807bd0['count'], (int) $sp807bd0['paid'], (int) $sp807bd0['profit']); } return Response::success($sp6a22d6); } function info(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer')); $spbabe1d = $sp3c91bd->input('id'); $sp600a89 = $this->authQuery($sp3c91bd, \App\Order::class)->with(array('pay' => function (Relation $sp6cb35e) { $sp6cb35e->select(array('id', 'name')); }, 'card_orders.card' => function (Relation $sp6cb35e) { $sp6cb35e->select(array('id', 'card')); }))->findOrFail($spbabe1d); $sp600a89->addHidden(array('system_fee')); return Response::success($sp600a89); } function remark(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer', 'remark' => 'required|string')); $spbabe1d = $sp3c91bd->input('id'); $sp600a89 = $this->authQuery($sp3c91bd, \App\Order::class)->findOrFail($spbabe1d); $sp600a89->remark = $sp3c91bd->input('remark'); $sp600a89->save(); return Response::success(); } function set_send_status(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer', 'send_status' => 'required|integer')); $spbabe1d = $sp3c91bd->input('id'); $sp600a89 = $this->authQuery($sp3c91bd, \App\Order::class)->findOrFail($spbabe1d); if ($sp600a89->status !== \App\Order::STATUS_PAID) { return Response::fail('此订单不是未发货状态, 无法增加发货标记'); } $sp600a89->send_status = $sp3c91bd->input('send_status'); $sp600a89->saveOrFail(); return Response::success(); } function ship(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer')); $sp600a89 = $this->authQuery($sp3c91bd, \App\Order::class)->with('product')->findOrFail($sp3c91bd->input('id')); if ($sp600a89->status !== \App\Order::STATUS_PAID) { return Response::fail('订单不是待发货状态, 无法发货'); } if ($sp600a89->product === null) { return Response::fail('订单对应商品不存在, 无法发货'); } $sp108fd4 = $sp600a89->product->delivery; $spf4196a = ''; if ($sp108fd4 === \App\Product::DELIVERY_MANUAL) { $this->validate($sp3c91bd, array('card' => 'required|string')); $spf4196a = $sp3c91bd->input('card'); } $sp35e17a = null; $sp3301fd = array(); if (FundHelper::orderSuccess($sp600a89->id, function () use(&$sp600a89, &$sp35e17a, &$sp3301fd, $sp108fd4, $spf4196a) { $sp600a89 = \App\Order::where('id', $sp600a89->id)->lockForUpdate()->firstOrFail(); if ($sp600a89->cards && count($sp600a89->cards)) { $sp35e17a = '该订单已经发货,无需再次发货'; return false; } $spe7d79d = $sp600a89->product()->lockForUpdate()->firstOrFail(); if ($sp108fd4 === \App\Product::DELIVERY_MANUAL) { $sp600a89->status = \App\Order::STATUS_SUCCESS; $sp600a89->send_status = \App\Order::SEND_STATUS_CARD_SUCCESS; $sp600a89->saveOrFail(); $sp3fbb89 = \App\Card::create(array('user_id' => Auth::id(), 'product_id' => $spe7d79d->id, 'card' => $spf4196a, 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_SOLD, 'count_sold' => 1, 'count_all' => 1)); $sp3301fd[] = $sp3fbb89->card; $sp600a89->cards()->attach($sp3fbb89->id); $spe7d79d->count_sold += $sp600a89->count; $spe7d79d->saveOrFail(); return FundHelper::ACTION_CONTINUE; } $spf7b822 = \App\Card::where('product_id', $spe7d79d->id)->whereRaw('`count_sold`<`count_all`')->take($sp600a89->count)->lockForUpdate()->get(); if (count($spf7b822) !== $sp600a89->count) { $sp35e17a = '商品卡密不足, 请添加卡密后再发货'; return false; } else { $sp600a89->status = \App\Order::STATUS_SUCCESS; $sp600a89->saveOrFail(); $spf36bfb = array(); foreach ($spf7b822 as $sp3fbb89) { $spf36bfb[] = $sp3fbb89->id; $sp3301fd[] = $sp3fbb89->card; } $sp600a89->cards()->attach($spf36bfb); \App\Card::whereIn('id', $spf36bfb)->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+1'))); $spe7d79d->count_sold += $sp600a89->count; $spe7d79d->saveOrFail(); return FundHelper::ACTION_CONTINUE; } })) { if (System::_getInt('mail_send_order')) { $sp030dc3 = @json_decode($sp600a89->contact_ext, true)['_mail']; if ($sp030dc3) { $sp600a89->sendEmail($sp030dc3); } } if ($sp600a89->status === \App\Order::STATUS_SUCCESS && System::_getInt('sms_send_order')) { $spe34083 = @json_decode($sp600a89->contact_ext, true)['_mobile']; if ($spe34083) { $sp600a89->sendSms($spe34083); } } $sp600a89['card_orders'] = array_map(function ($sp807bd0) { return array('card' => array('card' => $sp807bd0)); }, $sp3301fd); $sp600a89->addHidden(array('system_fee')); return Response::success($sp600a89); } else { return Response::fail($sp35e17a ?? '数据库繁忙, 请联系客服'); } } } \ No newline at end of file diff --git a/app/Http/Controllers/Merchant/Product.php b/app/Http/Controllers/Merchant/Product.php index a940d7446..99735fb10 100644 --- a/app/Http/Controllers/Merchant/Product.php +++ b/app/Http/Controllers/Merchant/Product.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd) { $sp6cb35e = $this->authQuery($sp3c91bd, \App\Product::class)->with(array('category' => function (Relation $sp6cb35e) { $sp6cb35e->select(array('id', 'name', 'password_open')); })); $sp98fed8 = $sp3c91bd->post('search', false); $sp7f8b1d = $sp3c91bd->post('val', false); if ($sp98fed8 && $sp7f8b1d) { if ($sp98fed8 == 'simple') { if ($sp3c91bd->post('from') === 'card') { $sp6cb35e->where('delivery', \App\Product::DELIVERY_AUTO); } return Response::success($sp6cb35e->where('category_id', $sp7f8b1d)->get(array('id', 'name'))); } elseif ($sp98fed8 == 'id') { $sp6cb35e->where('id', $sp7f8b1d); } elseif ($sp98fed8 == 'category_id') { $sp6cb35e->where('category_id', $sp7f8b1d); } else { $sp6cb35e->where($sp98fed8, 'like', '%' . $sp7f8b1d . '%'); } } $sp8af541 = (int) $sp3c91bd->post('category_id'); if ($sp8af541 > 0) { $sp6cb35e->where('category_id', $sp8af541); } $spa20949 = $sp3c91bd->post('enabled'); if (strlen($spa20949)) { $sp6cb35e->whereIn('enabled', explode(',', $spa20949)); } $spf8ae2a = (int) $sp3c91bd->post('current_page', 1); $spa4d3d7 = (int) $sp3c91bd->post('per_page', 20); $spdecb4c = $sp6cb35e->orderBy('sort')->paginate($spa4d3d7, array('*'), 'page', $spf8ae2a); foreach ($spdecb4c->items() as $spe7d79d) { $spe7d79d->setAppends(array('count', 'url')); } return Response::success($spdecb4c); } function sort(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer', 'sort' => 'required|integer')); $spe7d79d = $this->authQuery($sp3c91bd, \App\Product::class)->findOrFail($sp3c91bd->post('id')); $spe7d79d->sort = $sp3c91bd->post('sort'); $spe7d79d->saveOrFail(); return Response::success(); } function set_count(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer', 'count' => 'required|integer')); $spe7d79d = $this->authQuery($sp3c91bd, \App\Product::class)->findOrFail($sp3c91bd->post('id')); $spe7d79d->count_all = $spe7d79d->count_sold + $sp3c91bd->post('count'); $spe7d79d->saveOrFail(); return Response::success(); } function category_change(Request $sp3c91bd) { $this->validate($sp3c91bd, array('id' => 'required|integer', 'category_id' => 'required')); $spe7d79d = $this->authQuery($sp3c91bd, \App\Product::class)->findOrFail($sp3c91bd->post('id')); $sp8af541 = $sp3c91bd->input('category_id'); if (is_string($sp8af541) && @$sp8af541[0] === '+') { $spa74819 = \App\Category::create(array('user_id' => $spe7d79d->user_id, 'name' => substr($sp8af541, 1), 'enabled' => true)); } else { $spa74819 = $this->authQuery($sp3c91bd, \App\Category::class)->findOrFail($sp8af541); } $spe7d79d->category_id = $spa74819->id; $spe7d79d->save(); return Response::success($spa74819); } function edit(Request $sp3c91bd) { $this->validate($sp3c91bd, 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')); $sp8af541 = $sp3c91bd->post('category_id'); $sp4237d5 = is_string($sp8af541) && @$sp8af541[0] === '+'; if ($sp4237d5) { $spa74819 = \App\Category::create(array('user_id' => $this->getUserIdOrFail($sp3c91bd), 'name' => substr($sp8af541, 1), 'enabled' => true)); } else { $spa74819 = $this->authQuery($sp3c91bd, \App\Category::class)->where('id', @intval($sp8af541))->first(); if (!$spa74819) { return Response::fail('商品分类不存在'); } } $sp6b4dc2 = $sp3c91bd->post('name'); $spdab1b1 = $sp3c91bd->post('description'); $sp5dbece = $sp3c91bd->post('instructions'); $spd6ba1c = (int) $sp3c91bd->post('buy_min', 0); $sp76ae21 = (int) $sp3c91bd->post('buy_max', 0); $sp971da7 = (int) round($sp3c91bd->post('cost') * 100); $sp8af8bc = (int) round($sp3c91bd->post('price') * 100); $spbd77db = $sp3c91bd->post('price_whole'); $sp89ebd3 = @json_decode($spbd77db, true); foreach ($sp89ebd3 as $spd87a95) { if ($spd87a95[1] < 1 || $spd87a95[1] > 1000000000) { return Response::fail('商品批发价需要在 0.01-10000000 之间'); } } if (System::_getInt('filter_words_open') === 1) { $spcd9c68 = explode('|', System::_get('filter_words')); if (($sp6a22d6 = Helper::filterWords($sp6b4dc2, $spcd9c68)) !== false) { return Response::fail('提交失败! 商品名称包含敏感词: ' . $sp6a22d6); } if (($sp6a22d6 = Helper::filterWords($spdab1b1, $spcd9c68)) !== false) { return Response::fail('提交失败! 商品描述包含敏感词: ' . $sp6a22d6); } if (($sp6a22d6 = Helper::filterWords($sp5dbece, $spcd9c68)) !== false) { return Response::fail('提交失败! 商品使用说明包含敏感词: ' . $sp6a22d6); } } if ((int) $sp3c91bd->post('id')) { $spe7d79d = $this->authQuery($sp3c91bd, \App\Product::class)->findOrFail($sp3c91bd->post('id')); } else { $spe7d79d = new \App\Product(); $spe7d79d->count_sold = 0; $spe7d79d->user_id = $this->getUserIdOrFail($sp3c91bd); } $spe7d79d->category_id = $spa74819->id; $spe7d79d->name = $sp6b4dc2; $sp63b7aa = new AntiXSS(); $spe7d79d->description = $sp63b7aa->xss_clean($spdab1b1); $spe7d79d->instructions = $sp63b7aa->xss_clean($sp5dbece); $spe7d79d->fields = $sp3c91bd->post('fields'); $spe7d79d->delivery = (int) $sp3c91bd->post('delivery'); $spe7d79d->sort = $sp3c91bd->post('sort'); $spe7d79d->buy_min = $spd6ba1c; $spe7d79d->buy_max = $sp76ae21; $spe7d79d->count_warn = $sp3c91bd->post('count_warn'); $spe7d79d->support_coupon = $sp3c91bd->post('support_coupon') === 'true'; $spe7d79d->password = $sp3c91bd->post('password'); $spe7d79d->password_open = $sp3c91bd->post('password_open') === 'true'; $spe7d79d->cost = $sp971da7; $spe7d79d->price = $sp8af8bc; $spe7d79d->price_whole = $spbd77db; $spe7d79d->enabled = (int) $sp3c91bd->post('enabled'); $spe7d79d->inventory = (int) $sp3c91bd->post('inventory'); $spe7d79d->saveOrFail(); $sp9d3345 = array(); if ($sp4237d5) { $sp9d3345['category'] = $spa74819; } return Response::success($sp9d3345); } function enable(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string', 'enabled' => 'required|integer')); $spdbdb98 = $sp3c91bd->post('ids'); $spa20949 = (int) $sp3c91bd->post('enabled'); $this->authQuery($sp3c91bd, \App\Product::class)->whereIn('id', explode(',', $spdbdb98))->update(array('enabled' => $spa20949)); return Response::success(); } function delete(Request $sp3c91bd) { $this->validate($sp3c91bd, array('ids' => 'required|string')); $spdbdb98 = $sp3c91bd->post('ids'); $spdbdb98 = explode(',', $spdbdb98); $sp8f7ce7 = $this->authQuery($sp3c91bd, \App\Product::class)->whereIn('id', $spdbdb98); $sp0a8e96 = $this->authQuery($sp3c91bd, \App\Card::class)->whereIn('product_id', $spdbdb98); return DB::transaction(function () use($sp8f7ce7, $sp0a8e96) { $sp8f7ce7->delete(); $sp0a8e96->forceDelete(); return Response::success(); }); } function count_sync(Request $sp3c91bd) { \App\Product::refreshCount($this->getUser($sp3c91bd)); 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 cd8223829..a5e09b7f6 100644 --- a/app/Http/Controllers/Shop/Coupon.php +++ b/app/Http/Controllers/Shop/Coupon.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd) { $sp8af541 = (int) $sp3c91bd->post('category_id', -1); $sp5d967e = (int) $sp3c91bd->post('product_id', -1); $spda423d = $sp3c91bd->post('coupon'); if (!$spda423d) { return Response::fail('请输入优惠券'); } if ($sp8af541 > 0) { $spa74819 = Category::findOrFail($sp8af541); $spdad372 = $spa74819->user_id; } elseif ($sp5d967e > 0) { $spe7d79d = Product::findOrFail($sp5d967e); $spdad372 = $spe7d79d->user_id; } else { return Response::fail('请先选择分类或商品'); } $sp5984c3 = \App\Coupon::where('user_id', $spdad372)->where('coupon', $spda423d)->where('expire_at', '>', Carbon::now())->whereRaw('`count_used`<`count_all`')->get(); foreach ($sp5984c3 as $spda423d) { if ($spda423d->category_id === -1 || $spda423d->category_id === $sp8af541 && ($spda423d->product_id === -1 || $spda423d->product_id === $sp5d967e)) { $spda423d->setVisible(array('discount_type', 'discount_val')); return Response::success($spda423d); } } 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 9badc3326..282b7f782 100644 --- a/app/Http/Controllers/Shop/Order.php +++ b/app/Http/Controllers/Shop/Order.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd) { if ((int) \App\System::_get('vcode_shop_search') === 1) { $sp6a22d6 = Geetest\API::verify($sp3c91bd->post('geetest_challenge'), $sp3c91bd->post('geetest_validate'), $sp3c91bd->post('geetest_seccode')); if (!$sp6a22d6) { return Response::fail('系统无法接受您的验证结果,请刷新页面后重试。'); } } $sp6cb35e = \App\Order::where('created_at', '>=', (new Carbon())->addDay(-\App\System::_getInt('order_query_day', 30))); $sp0fe7ec = $sp3c91bd->post('type', ''); if ($sp0fe7ec === 'cookie') { $sp7eb55c = Cookie::get('customer'); if (strlen($sp7eb55c) !== 32) { return Response::success(); } $sp6cb35e->where('customer', $sp7eb55c); } elseif ($sp0fe7ec === 'order_no') { $spd10b1a = $sp3c91bd->post('order_no', ''); if (strlen($spd10b1a) !== 19) { return Response::success(); } $sp6cb35e->where('order_no', $spd10b1a); } elseif ($sp0fe7ec === 'contact') { $sp10107a = $sp3c91bd->post('contact', ''); if (strlen($sp10107a) < 6) { return Response::success(); } $sp6cb35e->where('contact', $sp10107a); } else { return Response::fail('请选择查询类型'); } $spf3965e = array('id', 'created_at', 'order_no', 'contact', 'status', 'send_status', 'count', 'paid'); if (1) { $spf3965e[] = 'product_name'; $spf3965e[] = 'contact'; $spf3965e[] = 'contact_ext'; } $spdecb4c = $sp6cb35e->orderBy('id', 'DESC')->get($spf3965e); $sp163458 = ''; return Response::success(array('list' => $spdecb4c, 'msg' => count($spdecb4c) ? $sp163458 : '')); } } \ No newline at end of file diff --git a/app/Http/Controllers/Shop/Pay.php b/app/Http/Controllers/Shop/Pay.php index ca2426524..2f0b6a457 100644 --- a/app/Http/Controllers/Shop/Pay.php +++ b/app/Http/Controllers/Shop/Pay.php @@ -1,15 +1,15 @@ 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' . ' +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($sp3c91bd, $spd10b1a, $sp022d9d, $spe4dc53, $spa1bef3) { try { $sp8a1f10 = json_decode($spe4dc53->config, true); $sp8a1f10['payway'] = $spe4dc53->way; GatewayPay::getDriver($spe4dc53)->goPay($sp8a1f10, $spd10b1a, $sp022d9d, $sp022d9d, $spa1bef3); return self::renderResultPage($sp3c91bd, array('success' => false, 'title' => '请稍后', 'msg' => '支付方式加载中,请稍后')); } catch (\Exception $sp96dd17) { return self::renderResultPage($sp3c91bd, array('msg' => $sp96dd17->getMessage())); } } function buy(Request $sp3c91bd) { $sp7eb55c = $sp3c91bd->input('customer'); if (strlen($sp7eb55c) !== 32) { return self::renderResultPage($sp3c91bd, array('msg' => '提交超时,请刷新购买页面并重新提交

+当前网址: ' . $sp3c91bd->getQueryString() . ' +提交内容: ' . var_export($sp7eb55c) . ', 提交长度:' . strlen($sp7eb55c) . '
+若您刷新后仍然出现此问题. 请加网站客服反馈')); } if ((int) System::_get('vcode_shop_buy') === 1) { $sp6a22d6 = Geetest\API::verify($sp3c91bd->input('geetest_challenge'), $sp3c91bd->input('geetest_validate'), $sp3c91bd->input('geetest_seccode')); if (!$sp6a22d6) { return self::renderResultPage($sp3c91bd, array('msg' => '滑动验证超时,请返回页面重试。')); } } $sp8af541 = (int) $sp3c91bd->input('category_id'); $sp5d967e = (int) $sp3c91bd->input('product_id'); $spdba6bb = (int) $sp3c91bd->input('count'); $spda423d = $sp3c91bd->input('coupon'); $sp10107a = $sp3c91bd->input('contact'); $spe00d1f = $sp3c91bd->input('contact_ext') ?? null; $sp9e4a0c = !empty(@json_decode($spe00d1f, true)['_mobile']); $sp38072d = (int) $sp3c91bd->input('pay_id'); if (!$sp8af541 || !$sp5d967e) { return self::renderResultPage($sp3c91bd, array('msg' => '请选择商品')); } if (strlen($sp10107a) < 1) { return self::renderResultPage($sp3c91bd, array('msg' => '请输入联系方式')); } $spa74819 = Category::findOrFail($sp8af541); $spe7d79d = Product::where('id', $sp5d967e)->where('category_id', $sp8af541)->where('enabled', 1)->with(array('user'))->first(); if ($spe7d79d == null || $spe7d79d->user == null) { return self::renderResultPage($sp3c91bd, array('msg' => '该商品未找到,请重新选择')); } if ($spe7d79d->password_open) { if ($spe7d79d->password !== $sp3c91bd->input('product_password')) { return self::renderResultPage($sp3c91bd, array('msg' => '商品密码输入错误')); } } else { if ($spa74819->password_open) { if ($spa74819->password !== $sp3c91bd->input('category_password')) { if ($spa74819->getTmpPassword() !== $sp3c91bd->input('category_password')) { return self::renderResultPage($sp3c91bd, array('msg' => '分类密码输入错误')); } } } } if ($spdba6bb < $spe7d79d->buy_min) { return self::renderResultPage($sp3c91bd, array('msg' => '该商品最少购买' . $spe7d79d->buy_min . '件,请重新选择')); } if ($spdba6bb > $spe7d79d->buy_max) { return self::renderResultPage($sp3c91bd, array('msg' => '该商品限购' . $spe7d79d->buy_max . '件,请重新选择')); } if ($spe7d79d->count < $spdba6bb) { return self::renderResultPage($sp3c91bd, array('msg' => '该商品库存不足')); } $sp1b768e = \App\Pay::find($sp38072d); if ($sp1b768e == null || !$sp1b768e->enabled) { return self::renderResultPage($sp3c91bd, array('msg' => '支付方式未找到,请重新选择')); } $sp7ce46e = $spe7d79d->price; if ($spe7d79d->price_whole) { $spbd77db = json_decode($spe7d79d->price_whole, true); for ($spe89d11 = count($spbd77db) - 1; $spe89d11 >= 0; $spe89d11--) { if ($spdba6bb >= (int) $spbd77db[$spe89d11][0]) { $sp7ce46e = (int) $spbd77db[$spe89d11][1]; break; } } } $sp8af8bc = $spdba6bb * $sp7ce46e; $spa1bef3 = $sp8af8bc; $sp1ec34d = 0; $sp080079 = null; if ($spe7d79d->support_coupon && strlen($spda423d) > 0) { $sp5984c3 = \App\Coupon::where('user_id', $spe7d79d->user_id)->where('coupon', $spda423d)->where('expire_at', '>', Carbon::now())->whereRaw('`count_used`<`count_all`')->get(); foreach ($sp5984c3 as $sp9ac414) { if ($sp9ac414->category_id === -1 || $sp9ac414->category_id === $sp8af541 && ($sp9ac414->product_id === -1 || $sp9ac414->product_id === $sp5d967e)) { if ($sp9ac414->discount_type === \App\Coupon::DISCOUNT_TYPE_AMOUNT && $spa1bef3 >= $sp9ac414->discount_val) { $sp080079 = $sp9ac414; $sp1ec34d = $sp9ac414->discount_val; break; } if ($sp9ac414->discount_type === \App\Coupon::DISCOUNT_TYPE_PERCENT) { $sp080079 = $sp9ac414; $sp1ec34d = (int) round($spa1bef3 * $sp9ac414->discount_val / 100); break; } } } if ($sp080079 === null) { return self::renderResultPage($sp3c91bd, array('msg' => '优惠券信息错误,请重新输入')); } $spa1bef3 -= $sp1ec34d; } $sp1efa73 = (int) round($spa1bef3 * $sp1b768e->fee_system); $sp216075 = $spa1bef3 - $sp1efa73; $sp736d62 = $sp9e4a0c ? System::_getInt('sms_price', 10) : 0; $spa1bef3 += $sp736d62; $sp971da7 = $spdba6bb * $spe7d79d->cost; $spd10b1a = \App\Order::unique_no(); try { DB::transaction(function () use($spe7d79d, $spd10b1a, $sp080079, $sp10107a, $spe00d1f, $sp7eb55c, $spdba6bb, $sp971da7, $sp8af8bc, $sp736d62, $sp1ec34d, $spa1bef3, $sp1b768e, $sp1efa73, $sp216075) { if ($sp080079) { $sp080079->status = \App\Coupon::STATUS_USED; $sp080079->count_used++; $sp080079->save(); $sp7b8ff5 = '使用优惠券: ' . $sp080079->coupon; } else { $sp7b8ff5 = null; } $sp600a89 = \App\Order::create(array('user_id' => $spe7d79d->user_id, 'order_no' => $spd10b1a, 'product_id' => $spe7d79d->id, 'product_name' => $spe7d79d->name, 'count' => $spdba6bb, 'ip' => Helper::getIP(), 'customer' => $sp7eb55c, 'contact' => $sp10107a, 'contact_ext' => $spe00d1f, 'cost' => $sp971da7, 'price' => $sp8af8bc, 'sms_price' => $sp736d62, 'discount' => $sp1ec34d, 'paid' => $spa1bef3, 'pay_id' => $sp1b768e->id, 'fee' => $sp1efa73, 'system_fee' => $sp1efa73, 'income' => $sp216075, 'status' => \App\Order::STATUS_UNPAY, 'remark' => $sp7b8ff5, 'created_at' => Carbon::now())); assert($sp600a89 !== null); }); } catch (\Throwable $sp96dd17) { Log::error('Shop.Pay.buy 下单失败', array('Exception' => $sp96dd17)); return self::renderResultPage($sp3c91bd, array('msg' => '发生错误,下单失败,请稍后重试')); } if ($spa1bef3 === 0) { $this->shipOrder($sp3c91bd, $spd10b1a, $spa1bef3, null); return redirect('/pay/result/' . $spd10b1a); } $sp022d9d = $spd10b1a; return $this->goPay($sp3c91bd, $spd10b1a, $sp022d9d, $sp1b768e, $spa1bef3); } function pay(Request $sp3c91bd, $spd10b1a) { $sp600a89 = \App\Order::whereOrderNo($spd10b1a)->first(); if ($sp600a89 == null) { return self::renderResultPage($sp3c91bd, array('msg' => '订单未找到,请重试')); } if ($sp600a89->status !== \App\Order::STATUS_UNPAY) { return redirect('/pay/result/' . $spd10b1a); } $spc2269a = 'pay: ' . $sp600a89->pay_id; $spe4dc53 = $sp600a89->pay; if (!$spe4dc53) { \Log::error($spc2269a . ' cannot find Pay'); return $this->renderResultPage($sp3c91bd, array('msg' => '支付方式未找到')); } $spc2269a .= ',' . $spe4dc53->driver; $sp8a1f10 = json_decode($spe4dc53->config, true); $sp8a1f10['payway'] = $spe4dc53->way; $sp8a1f10['out_trade_no'] = $spd10b1a; try { $this->payApi = GatewayPay::getDriver($spe4dc53); } catch (\Exception $sp96dd17) { \Log::error($spc2269a . ' cannot find Driver: ' . $sp96dd17->getMessage()); return $this->renderResultPage($sp3c91bd, array('msg' => '支付驱动未找到')); } if ($this->payApi->verify($sp8a1f10, function ($spd10b1a, $sp0b9841, $sp3b1b1d) use($sp3c91bd) { try { $this->shipOrder($sp3c91bd, $spd10b1a, $sp0b9841, $sp3b1b1d); } catch (\Exception $sp96dd17) { $this->renderResultPage($sp3c91bd, array('success' => false, 'msg' => $sp96dd17->getMessage())); } })) { \Log::notice($spc2269a . ' 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' . ' +'); return redirect('/pay/result/' . $spd10b1a); } if ($sp600a89->created_at < Carbon::now()->addMinutes(-5)) { return $this->renderResultPage($sp3c91bd, array('msg' => '当前订单长时间未支付已作废, 请重新下单')); } $spe7d79d = Product::where('id', $sp600a89->product_id)->where('enabled', 1)->first(); if ($spe7d79d == null) { return self::renderResultPage($sp3c91bd, array('msg' => '该商品已下架')); } $spe7d79d->setAttribute('count', count($spe7d79d->cards) ? $spe7d79d->cards[0]->count : 0); if ($spe7d79d->count < $sp600a89->count) { return self::renderResultPage($sp3c91bd, array('msg' => '该商品库存不足')); } $sp022d9d = $spd10b1a; return $this->goPay($sp3c91bd, $spd10b1a, $sp022d9d, $spe4dc53, $sp600a89->paid); } function qrcode(Request $sp3c91bd, $spd10b1a, $sp08fc35) { $sp600a89 = \App\Order::whereOrderNo($spd10b1a)->with('product')->first(); if ($sp600a89 == null) { return self::renderResultPage($sp3c91bd, array('msg' => '订单未找到,请重试')); } if ($sp600a89->product_id !== \App\Product::ID_API && $sp600a89->product == null) { return self::renderResultPage($sp3c91bd, array('msg' => '商品未找到,请重试')); } return view('pay/' . $sp08fc35, array('pay_id' => $sp600a89->pay_id, 'name' => $sp600a89->product->name . ' x ' . $sp600a89->count . '件', 'amount' => $sp600a89->paid, 'qrcode' => $sp3c91bd->get('url'), 'id' => $spd10b1a)); } function qrQuery(Request $sp3c91bd, $sp38072d) { $spcc8735 = $sp3c91bd->input('id', ''); return self::payReturn($sp3c91bd, $sp38072d, $spcc8735); } function payReturn(Request $sp3c91bd, $sp38072d, $spf3e840 = '') { $spc2269a = 'payReturn: ' . $sp38072d; \Log::debug($spc2269a); $spe4dc53 = \App\Pay::where('id', $sp38072d)->first(); if (!$spe4dc53) { return $this->renderResultPage($sp3c91bd, array('success' => 0, 'msg' => '支付方式错误')); } $spc2269a .= ',' . $spe4dc53->driver; if (strlen($spf3e840) > 0) { $sp600a89 = \App\Order::whereOrderNo($spf3e840)->first(); if ($sp600a89 && ($sp600a89->status === \App\Order::STATUS_PAID || $sp600a89->status === \App\Order::STATUS_SUCCESS)) { \Log::notice($spc2269a . ' already success' . ' -'); 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 ($sp3c91bd->ajax()) { return self::renderResultPage($sp3c91bd, array('success' => 1, 'data' => '/pay/result/' . $spf3e840), array('order' => $sp600a89)); } else { return redirect('/pay/result/' . $spf3e840); } } } try { $this->payApi = GatewayPay::getDriver($spe4dc53); } catch (\Exception $sp96dd17) { \Log::error($spc2269a . ' cannot find Driver: ' . $sp96dd17->getMessage()); return $this->renderResultPage($sp3c91bd, array('success' => 0, 'msg' => '支付驱动未找到')); } $sp8a1f10 = json_decode($spe4dc53->config, true); $sp8a1f10['out_trade_no'] = $spf3e840; $sp8a1f10['payway'] = $spe4dc53->way; \Log::debug($spc2269a . ' will verify'); if ($this->payApi->verify($sp8a1f10, function ($spd10b1a, $sp0b9841, $sp3b1b1d) use($sp3c91bd, $spc2269a, &$spf3e840) { $spf3e840 = $spd10b1a; try { \Log::debug($spc2269a . " shipOrder start, order_no: {$spd10b1a}, amount: {$sp0b9841}, trade_no: {$sp3b1b1d}"); $this->shipOrder($sp3c91bd, $spd10b1a, $sp0b9841, $sp3b1b1d); \Log::debug($spc2269a . ' shipOrder end, order_no: ' . $spd10b1a); } catch (\Exception $sp96dd17) { \Log::error($spc2269a . ' shipOrder Exception: ' . $sp96dd17->getMessage()); } })) { \Log::debug($spc2269a . ' verify finished: 1' . ' -'); 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' . ' +'); if ($sp3c91bd->ajax()) { return self::renderResultPage($sp3c91bd, array('success' => 1, 'data' => '/pay/result/' . $spf3e840)); } else { return redirect('/pay/result/' . $spf3e840); } } else { \Log::debug($spc2269a . ' verify finished: 0' . ' -'); 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 . ' +'); return $this->renderResultPage($sp3c91bd, array('success' => 0, 'msg' => '支付验证失败,您可以稍后查看支付状态。')); } } function payNotify(Request $sp3c91bd, $sp38072d) { $spc2269a = 'payNotify pay_id: ' . $sp38072d; \Log::debug($spc2269a); $spe4dc53 = \App\Pay::where('id', $sp38072d)->first(); if (!$spe4dc53) { \Log::error($spc2269a . ' cannot find PayModel'); echo 'fail'; die; } $spc2269a .= ',' . $spe4dc53->driver; try { $this->payApi = GatewayPay::getDriver($spe4dc53); } catch (\Exception $sp96dd17) { \Log::error($spc2269a . ' cannot find Driver: ' . $sp96dd17->getMessage()); echo 'fail'; die; } $sp8a1f10 = json_decode($spe4dc53->config, true); $sp8a1f10['payway'] = $spe4dc53->way; $sp8a1f10['isNotify'] = true; \Log::debug($spc2269a . ' will verify'); $sp6a22d6 = $this->payApi->verify($sp8a1f10, function ($spd10b1a, $sp0b9841, $sp3b1b1d) use($sp3c91bd, $spc2269a) { try { \Log::debug($spc2269a . " shipOrder start, order_no: {$spd10b1a}, amount: {$sp0b9841}, trade_no: {$sp3b1b1d}"); $this->shipOrder($sp3c91bd, $spd10b1a, $sp0b9841, $sp3b1b1d); \Log::debug($spc2269a . ' shipOrder end, order_no: ' . $spd10b1a); } catch (\Exception $sp96dd17) { \Log::error($spc2269a . ' shipOrder Exception: ' . $sp96dd17->getMessage()); } }); \Log::debug($spc2269a . ' notify finished: ' . (int) $sp6a22d6 . ' -'); 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 +'); die; } function result(Request $sp3c91bd, $spd10b1a) { $sp600a89 = \App\Order::where('order_no', $spd10b1a)->first(); if ($sp600a89 == null) { return self::renderResultPage($sp3c91bd, array('msg' => '订单未找到,请重试')); } if ($sp600a89->status === \App\Order::STATUS_PAID) { $sp9ee8ed = $sp600a89->user->qq; if ($sp600a89->product->delivery === \App\Product::DELIVERY_MANUAL) { $sp6edbee = '您购买的为手动充值商品,请耐心等待处理'; } else { $sp6edbee = '商家库存不足,因此没有自动发货,请联系商家客服发货'; } if ($sp9ee8ed) { $sp6edbee .= '
客服QQ:' . $sp9ee8ed . ''; } return self::renderResultPage($sp3c91bd, array('success' => false, 'title' => '订单已支付', 'msg' => $sp6edbee), array('order' => $sp600a89)); } elseif ($sp600a89->status === \App\Order::STATUS_SUCCESS) { return self::showOrderResult($sp3c91bd, $sp600a89); } return self::renderResultPage($sp3c91bd, array('success' => false, 'msg' => $sp600a89->remark ? '失败原因:
' . $sp600a89->remark : '订单支付失败,请重试'), array('order' => $sp600a89)); } function renderResultPage(Request $sp3c91bd, $spf77edc, $spbb494e = array()) { if ($sp3c91bd->ajax()) { if (@$spf77edc['success']) { return Response::success($spf77edc['data']); } else { return Response::fail('error', $spf77edc['msg']); } } else { return view('pay.result', array_merge(array('result' => $spf77edc, 'data' => $spbb494e), $spbb494e)); } } function shipOrder($sp3c91bd, $spd10b1a, $sp0b9841, $sp3b1b1d) { $sp600a89 = \App\Order::whereOrderNo($spd10b1a)->first(); if ($sp600a89 === null) { \Log::error('shipOrder: No query results for model [App\\Order:' . $spd10b1a . ',trade_no:' . $sp3b1b1d . ',amount:' . $sp0b9841 . ']. die(\'success\');'); die('success'); } if ($sp600a89->paid > $sp0b9841) { \Log::alert('shipOrder, price may error, order_no:' . $spd10b1a . ', paid:' . $sp600a89->paid . ', $amount get:' . $sp0b9841); $sp600a89->remark = '支付金额(' . sprintf('%0.2f', $sp0b9841 / 100) . ') 小于 订单金额(' . sprintf('%0.2f', $sp600a89->paid / 100) . ')'; $sp600a89->save(); throw new \Exception($sp600a89->remark); } $spe7d79d = null; if ($sp600a89->status === \App\Order::STATUS_UNPAY) { Log::debug('shipOrder.first_process:' . $spd10b1a); if (FundHelper::orderSuccess($sp600a89->id, function ($spce8535) use($sp3b1b1d, &$sp600a89, &$spe7d79d) { $sp600a89 = $spce8535; if ($sp600a89->status !== \App\Order::STATUS_UNPAY) { \Log::debug('Shop.Pay.shipOrder: .first_process:' . $sp600a89->order_no . ' already processed! #2'); return false; } $spe7d79d = $sp600a89->product()->lockForUpdate()->firstOrFail(); $sp600a89->pay_trade_no = $sp3b1b1d; $sp600a89->paid_at = Carbon::now(); if ($spe7d79d->delivery === \App\Product::DELIVERY_MANUAL) { $sp600a89->status = \App\Order::STATUS_PAID; $sp600a89->send_status = \App\Order::SEND_STATUS_CARD_UN; $sp600a89->saveOrFail(); return true; } if ($spe7d79d->delivery === \App\Product::DELIVERY_API) { $spf7b822 = $spe7d79d->createApiCards($sp600a89); } else { $spf7b822 = Card::where('product_id', $spe7d79d->retail_root->id)->whereRaw('`count_sold`<`count_all`')->take($sp600a89->count)->lockForUpdate()->get(); } $spc08238 = false; if (count($spf7b822) === $sp600a89->count) { $spc08238 = true; } else { $spc08238 = false; if (count($spf7b822)) { foreach ($spf7b822 as $sp3fbb89) { if ($sp3fbb89->type === \App\Card::TYPE_REPEAT && $sp3fbb89->count >= $sp600a89->count) { $spf7b822 = array($sp3fbb89); $spc08238 = true; break; } } } } if ($spc08238 === false) { Log::alert('Shop.Pay.shipOrder: 订单:' . $sp600a89->order_no . ', 购买数量:' . $sp600a89->count . ', 卡数量:' . count($spf7b822) . ' 卡密不足(已支付 未发货)'); $sp600a89->status = \App\Order::STATUS_PAID; $sp600a89->saveOrFail(); return true; } else { $spf36bfb = array(); foreach ($spf7b822 as $sp3fbb89) { $spf36bfb[] = $sp3fbb89->id; } $sp600a89->cards()->attach($spf36bfb); if (count($spf7b822) === 1 && $spf7b822[0]->type === \App\Card::TYPE_REPEAT) { \App\Card::where('id', $spf36bfb[0])->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+' . $sp600a89->count))); } else { \App\Card::whereIn('id', $spf36bfb)->update(array('status' => \App\Card::STATUS_SOLD, 'count_sold' => DB::raw('`count_sold`+1'))); } $sp600a89->status = \App\Order::STATUS_SUCCESS; $sp600a89->saveOrFail(); $spe7d79d->count_sold += $sp600a89->count; $spe7d79d->saveOrFail(); return FundHelper::ACTION_CONTINUE; } })) { if ($spe7d79d->count_warn > 0 && $spe7d79d->count < $spe7d79d->count_warn) { try { Mail::to($sp600a89->user->email)->Queue(new ProductCountWarn($spe7d79d, $spe7d79d->count)); } catch (\Throwable $sp96dd17) { LogHelper::setLogFile('mail'); Log::error('shipOrder.count_warn error', array('product_id' => $sp600a89->product_id, 'email' => $sp600a89->user->email, 'exception' => $sp96dd17->getMessage())); LogHelper::setLogFile('card'); } } if (System::_getInt('mail_send_order')) { $sp030dc3 = @json_decode($sp600a89->contact_ext, true)['_mail']; if ($sp030dc3) { $sp600a89->sendEmail($sp030dc3); } } if ($sp600a89->status === \App\Order::STATUS_SUCCESS && System::_getInt('sms_send_order')) { $spe34083 = @json_decode($sp600a89->contact_ext, true)['_mobile']; if ($spe34083) { $sp600a89->sendSms($spe34083); } } } else { } } else { Log::debug('Shop.Pay.shipOrder: .order_no:' . $sp600a89->order_no . ' already processed! #1'); } return FALSE; } private function showOrderResult($sp3c91bd, $sp600a89) { return self::renderResultPage($sp3c91bd, array('success' => true, 'msg' => $sp600a89->getSendMessage()), array('card_txt' => join(' ', $sp600a89->getCardsArray()), 'order' => $sp600a89, 'product' => $sp600a89->product)); } } \ No newline at end of file diff --git a/app/Http/Controllers/Shop/Product.php b/app/Http/Controllers/Shop/Product.php index cda3012f8..6b07a6ca2 100644 --- a/app/Http/Controllers/Shop/Product.php +++ b/app/Http/Controllers/Shop/Product.php @@ -1,2 +1,2 @@ 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 +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 $sp3c91bd) { $sp8af541 = (int) $sp3c91bd->post('category_id'); if (!$sp8af541) { return Response::forbidden('请选择商品分类'); } $spa74819 = \App\Category::where('id', $sp8af541)->first(); if (!$spa74819) { return Response::forbidden('商品分类未找到'); } if ($spa74819->password_open && $sp3c91bd->post('password') !== $spa74819->password) { return Response::fail('分类密码输入错误'); } $sp6c9c2f = \App\Product::where('category_id', $sp8af541)->where('enabled', 1)->orderBy('sort')->get(); foreach ($sp6c9c2f as $spe7d79d) { $spe7d79d->setForShop(); } return Response::success($sp6c9c2f); } function verifyPassword(Request $sp3c91bd) { $sp5d967e = (int) $sp3c91bd->post('product_id'); if (!$sp5d967e) { return Response::forbidden('请选择商品'); } $spe7d79d = \App\Product::where('id', $sp5d967e)->first(); if (!$spe7d79d) { return Response::forbidden('商品未找到'); } if ($spe7d79d->password_open && $sp3c91bd->post('password') !== $spe7d79d->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 709fd7e1d..2f6aa1164 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($spe9df6d); } } \ 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() { $spcb9bf9 = array('driver' => 'geetest', 'geetest' => Geetest\API::get()); return Response::success($spcb9bf9); } } \ No newline at end of file diff --git a/app/Http/Middleware/CORS.php b/app/Http/Middleware/CORS.php index 6d70e4778..6965c9195 100644 --- a/app/Http/Middleware/CORS.php +++ b/app/Http/Middleware/CORS.php @@ -1,2 +1,2 @@ $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 +namespace App\Http\Middleware; use Closure; class CORS { public function handle($sp3c91bd, Closure $sp1ff554) { if (config('app.debug')) { $spa565dd = array('Access-Control-Allow-Origin' => $sp3c91bd->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 ($sp3c91bd->isMethod('OPTIONS')) { return response()->make('', 200, $spa565dd); } $sp9d3345 = $sp1ff554($sp3c91bd); foreach ($spa565dd as $spe57121 => $spae23f7) { $sp9d3345->headers->set($spe57121, $spae23f7); } return $sp9d3345; } return $sp1ff554($sp3c91bd); } } \ No newline at end of file diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 8779d6c73..45d345fc3 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -1,2 +1,2 @@ check()) { return redirect('/home'); } return $spb59aac($spba756f); } } \ No newline at end of file +namespace App\Http\Middleware; use Closure; use Illuminate\Support\Facades\Auth; class RedirectIfAuthenticated { public function handle($sp3c91bd, Closure $sp1ff554, $sp5494e3 = null) { if (Auth::guard($sp5494e3)->check()) { return redirect('/home'); } return $sp1ff554($sp3c91bd); } } \ No newline at end of file diff --git a/app/Jobs/OrderSms.php b/app/Jobs/OrderSms.php index a5804b43d..26ebb02f4 100644 --- a/app/Jobs/OrderSms.php +++ b/app/Jobs/OrderSms.php @@ -1,2 +1,2 @@ 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 +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($spe34083, $sp600a89) { $this->mobile = $spe34083; $this->order = $sp600a89; } 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 e38a3b698..a73e50cd4 100644 --- a/app/Library/CurlRequest.php +++ b/app/Library/CurlRequest.php @@ -1,3 +1,3 @@ $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 +namespace App\Library; use Illuminate\Support\Facades\Log; class CurlRequest { private static function curl($sp40b98a, $sp2219e5 = 0, $spdd30d2 = '', $spa565dd = array(), $spe83a5d = 5, &$sp4bbe0a = false) { if (!isset($spa565dd['Accept'])) { $spa565dd['Accept'] = '*/*'; } if (!isset($spa565dd['Referer'])) { $spa565dd['Referer'] = $sp40b98a; } if (!isset($spa565dd['Content-Type'])) { $spa565dd['Content-Type'] = 'application/x-www-form-urlencoded'; } if (!isset($spa565dd['User-Agent'])) { $spa565dd['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 ($sp4bbe0a !== false) { $spa565dd['Cookie'] = $sp4bbe0a; } $spa37e42 = array(); foreach ($spa565dd as $spd8e776 => $spbc0c98) { $spa37e42[] = $spd8e776 . ': ' . $spbc0c98; } $spa37e42[] = 'Expect:'; $sp1942b5 = curl_init(); curl_setopt($sp1942b5, CURLOPT_URL, $sp40b98a); curl_setopt($sp1942b5, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($sp1942b5, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($sp1942b5, CURLOPT_FOLLOWLOCATION, true); curl_setopt($sp1942b5, CURLOPT_MAXREDIRS, 3); if ($sp2219e5 == 1) { curl_setopt($sp1942b5, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($sp1942b5, CURLOPT_POST, 1); if ($spdd30d2 !== '') { curl_setopt($sp1942b5, CURLOPT_POSTFIELDS, $spdd30d2); curl_setopt($sp1942b5, CURLOPT_POSTREDIR, 3); } } if (defined('MY_PROXY')) { $sp34031d = MY_PROXY; $sp9e3584 = CURLPROXY_HTTP; if (strpos($sp34031d, 'http://') || strpos($sp34031d, 'https://')) { $sp34031d = str_replace('http://', $sp34031d, $sp34031d); $sp34031d = str_replace('https://', $sp34031d, $sp34031d); $sp9e3584 = CURLPROXY_HTTP; } elseif (strpos($sp34031d, 'socks4://')) { $sp34031d = str_replace('socks4://', $sp34031d, $sp34031d); $sp9e3584 = CURLPROXY_SOCKS4; } elseif (strpos($sp34031d, 'socks4a://')) { $sp34031d = str_replace('socks4a://', $sp34031d, $sp34031d); $sp9e3584 = CURLPROXY_SOCKS4A; } elseif (strpos($sp34031d, 'socks5://')) { $sp34031d = str_replace('socks5://', $sp34031d, $sp34031d); $sp9e3584 = CURLPROXY_SOCKS5_HOSTNAME; } curl_setopt($sp1942b5, CURLOPT_PROXY, $sp34031d); curl_setopt($sp1942b5, CURLOPT_PROXYTYPE, $sp9e3584); if (defined('MY_PROXY_PASS')) { curl_setopt($sp1942b5, CURLOPT_PROXYUSERPWD, MY_PROXY_PASS); } } curl_setopt($sp1942b5, CURLOPT_TIMEOUT, $spe83a5d); curl_setopt($sp1942b5, CURLOPT_CONNECTTIMEOUT, $spe83a5d); curl_setopt($sp1942b5, CURLOPT_RETURNTRANSFER, 1); curl_setopt($sp1942b5, CURLOPT_HEADER, 1); curl_setopt($sp1942b5, CURLOPT_HTTPHEADER, $spa37e42); $sp9d3345 = curl_exec($sp1942b5); $spf16b26 = curl_getinfo($sp1942b5, CURLINFO_HEADER_SIZE); $sp32acab = substr($sp9d3345, 0, $spf16b26); $sp219d02 = substr($sp9d3345, $spf16b26); curl_close($sp1942b5); if ($sp4bbe0a !== false) { $spa565dd = explode(' +', $sp32acab); $sp7b008c = ''; foreach ($spa565dd as $sp32acab) { if (strpos($sp32acab, 'Set-Cookie') !== false) { if (strpos($sp32acab, ';') !== false) { $sp7b008c = $sp7b008c . trim(Helper::str_between($sp32acab, 'Set-Cookie:', ';')) . ';'; } else { $sp7b008c = $sp7b008c . trim(str_replace('Set-Cookie:', '', $sp32acab)) . ';'; } } } $sp4bbe0a = self::combineCookie($sp4bbe0a, $sp7b008c); } return $sp219d02; } public static function get($sp40b98a, $spa565dd = array(), $spe83a5d = 5, &$sp4bbe0a = false) { return self::curl($sp40b98a, 0, '', $spa565dd, $spe83a5d, $sp4bbe0a); } public static function post($sp40b98a, $spdd30d2 = '', $spa565dd = array(), $spe83a5d = 5, &$sp4bbe0a = false) { return self::curl($sp40b98a, 1, $spdd30d2, $spa565dd, $spe83a5d, $sp4bbe0a); } public static function combineCookie($sp265a87, $sp636f3a) { $spebbd4e = explode(';', $sp265a87); $spc6a5ca = explode(';', $sp636f3a); foreach ($spebbd4e as $spec7d6d) { if (self::cookieIsExists($spc6a5ca, self::cookieGetName($spec7d6d)) == false) { array_push($spc6a5ca, $spec7d6d); } } $spefbb2a = ''; foreach ($spc6a5ca as $spec7d6d) { if (substr($spec7d6d, -8, 8) != '=deleted' && strlen($spec7d6d) > 1) { $spefbb2a .= $spec7d6d . '; '; } } return substr($spefbb2a, 0, strlen($spefbb2a) - 2); } public static function cookieGetName($spd2350f) { $spcbea9e = strpos($spd2350f, '='); return substr($spd2350f, 0, $spcbea9e); } public static function cookieGetValue($spd2350f) { $spcbea9e = strpos($spd2350f, '='); $sp0f5db4 = substr($spd2350f, $spcbea9e + 1, strlen($spd2350f) - $spcbea9e); return $sp0f5db4; } public static function cookieGet($sp4bbe0a, $sp6b4dc2, $sp7234c0 = false) { $sp4bbe0a = str_replace(' ', '', $sp4bbe0a); if (substr($sp4bbe0a, -1, 1) != ';') { $sp4bbe0a = ';' . $sp4bbe0a . ';'; } else { $sp4bbe0a = ';' . $sp4bbe0a; } $sp800386 = Helper::str_between($sp4bbe0a, ';' . $sp6b4dc2 . '=', ';'); if (!$sp7234c0 || $sp800386 == '') { return $sp800386; } else { return $sp6b4dc2 . '=' . $sp800386; } } private static function cookieIsExists($sp9db6f3, $sp1d1a8b) { foreach ($sp9db6f3 as $spec7d6d) { if (self::cookieGetName($spec7d6d) == $sp1d1a8b) { return true; } } return false; } function test() { $sp0f5db4 = self::combineCookie('a=1;b=2;c=3', 'c=5'); var_dump($sp0f5db4); } } \ No newline at end of file diff --git a/app/Library/FundHelper.php b/app/Library/FundHelper.php index 946028dde..e95dfe4bd 100644 --- a/app/Library/FundHelper.php +++ b/app/Library/FundHelper.php @@ -1,2 +1,2 @@ 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 +namespace App\Library; use App\Order; use App\User; use App\FundRecord; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class FundHelper { const ACTION_CONTINUE = 1001; public static function orderSuccess($sp91aca1, callable $spb52528) { $sp600a89 = null; try { return DB::transaction(function () use($sp91aca1, &$sp600a89, $spb52528) { $sp600a89 = \App\Order::where('id', $sp91aca1)->lockForUpdate()->firstOrFail(); $sp6a22d6 = $spb52528($sp600a89); if ($sp6a22d6 !== self::ACTION_CONTINUE) { return $sp6a22d6; } $spb14cf0 = User::where('id', $sp600a89->user_id)->lockForUpdate()->firstOrFail(); $spb14cf0->m_all += $sp600a89->income; $spb14cf0->saveOrFail(); $spbb6006 = new FundRecord(); $spbb6006->user_id = $sp600a89->user_id; $spbb6006->type = FundRecord::TYPE_IN; $spbb6006->amount = $sp600a89->income; $spbb6006->all = $spb14cf0->m_all; $spbb6006->frozen = $spb14cf0->m_frozen; $spbb6006->paid = $spb14cf0->m_paid; $spbb6006->balance = $spb14cf0->m_balance; $spbb6006->remark = '订单#' . $sp600a89->order_no; $spbb6006->order_id = $sp600a89->id; $spbb6006->saveOrFail(); return true; }); } catch (\Throwable $sp96dd17) { $sp6edbee = 'FundHelper.orderSuccess error, order_id:' . $sp91aca1; if ($sp600a89) { $sp6edbee .= ', user_id:' . $sp600a89->user_id . ',income:' . $sp600a89->income . ',order_no:' . $sp600a89->order_no; } Log::error($sp6edbee . ' with exception:', array('Exception' => $sp96dd17)); return false; } } public static function orderFreeze($sp91aca1, $spf7a183) { $sp600a89 = null; try { return DB::transaction(function () use($sp91aca1, &$sp600a89, $spf7a183) { $sp600a89 = \App\Order::where('id', $sp91aca1)->lockForUpdate()->firstOrFail(); if ($sp600a89->status === Order::STATUS_REFUND) { return false; } if ($sp600a89->status === Order::STATUS_FROZEN) { return true; } $spde0011 = $sp600a89->status; if ($spde0011 === \App\Order::STATUS_SUCCESS) { $spb296ac = '已发货'; } elseif ($spde0011 === \App\Order::STATUS_UNPAY) { $spb296ac = '未付款'; } elseif ($spde0011 === \App\Order::STATUS_PAID) { $spb296ac = '未发货'; } else { throw new \Exception('unknown'); } $spb14cf0 = User::where('id', $sp600a89->user_id)->lockForUpdate()->firstOrFail(); $spbb6006 = new FundRecord(); $spbb6006->user_id = $sp600a89->user_id; $spbb6006->type = FundRecord::TYPE_OUT; $spbb6006->order_id = $sp600a89->id; $spbb6006->remark = $sp600a89 === $sp600a89 ? '' : '关联订单#' . $sp600a89->order_no . ': '; if ($spde0011 === \App\Order::STATUS_SUCCESS) { $spb14cf0->m_frozen += $sp600a89->income; $spb14cf0->saveOrFail(); $spbb6006->amount = -$sp600a89->income; $spbb6006->remark .= $spf7a183 . ', 冻结订单#' . $sp600a89->order_no; } else { $spbb6006->amount = 0; $spbb6006->remark .= $spf7a183 . ', 冻结订单(' . $spb296ac . ')#' . $sp600a89->order_no; } $spbb6006->all = $spb14cf0->m_all; $spbb6006->frozen = $spb14cf0->m_frozen; $spbb6006->paid = $spb14cf0->m_paid; $spbb6006->balance = $spb14cf0->m_balance; $spbb6006->saveOrFail(); $sp600a89->status = \App\Order::STATUS_FROZEN; $sp600a89->frozen_reason = ($sp600a89 === $sp600a89 ? '' : '关联订单#' . $sp600a89->order_no . ': ') . $spf7a183; $sp600a89->saveOrFail(); return true; }); } catch (\Throwable $sp96dd17) { $sp6edbee = 'FundHelper.orderFreeze error'; if ($sp600a89) { $sp6edbee .= ', order_no:' . $sp600a89->order_no . ', user_id:' . $sp600a89->user_id . ', amount:' . $sp600a89->income; } else { $sp6edbee .= ', order_no: null'; } Log::error($sp6edbee . ' with exception:', array('Exception' => $sp96dd17)); return false; } } public static function orderUnfreeze($sp91aca1, $sp23a601, callable $sp47477c = null, &$spd977b7 = null) { $sp600a89 = null; try { return DB::transaction(function () use($sp91aca1, &$sp600a89, $sp23a601, $sp47477c, &$spd977b7) { $sp600a89 = \App\Order::where('id', $sp91aca1)->lockForUpdate()->firstOrFail(); if ($sp47477c !== null) { $sp6a22d6 = $sp47477c(); if ($sp6a22d6 !== self::ACTION_CONTINUE) { return $sp6a22d6; } } if ($sp600a89->status === Order::STATUS_REFUND) { $spd977b7 = $sp600a89->status; return false; } if ($sp600a89->status !== Order::STATUS_FROZEN) { $spd977b7 = $sp600a89->status; return true; } $spd4565c = $sp600a89->card_orders()->exists(); if ($spd4565c) { $spd977b7 = \App\Order::STATUS_SUCCESS; $spb296ac = '已发货'; } else { if ($sp600a89->paid_at === NULL) { $spd977b7 = \App\Order::STATUS_UNPAY; $spb296ac = '未付款'; } else { $spd977b7 = \App\Order::STATUS_PAID; $spb296ac = '未发货'; } } $spb14cf0 = User::where('id', $sp600a89->user_id)->lockForUpdate()->firstOrFail(); $spbb6006 = new FundRecord(); $spbb6006->user_id = $sp600a89->user_id; $spbb6006->type = FundRecord::TYPE_IN; $spbb6006->remark = $sp600a89 === $sp600a89 ? '' : '关联订单#' . $sp600a89->order_no . ': '; $spbb6006->order_id = $sp600a89->id; if ($spd4565c) { $spb14cf0->m_frozen -= $sp600a89->income; $spb14cf0->saveOrFail(); $spbb6006->amount = $sp600a89->income; $spbb6006->remark .= $sp23a601 . ', 解冻订单#' . $sp600a89->order_no; } else { $spbb6006->amount = 0; $spbb6006->remark .= $sp23a601 . ', 解冻订单(' . $spb296ac . ')#' . $sp600a89->order_no; } $spbb6006->all = $spb14cf0->m_all; $spbb6006->frozen = $spb14cf0->m_frozen; $spbb6006->paid = $spb14cf0->m_paid; $spbb6006->balance = $spb14cf0->m_balance; $spbb6006->saveOrFail(); $sp600a89->status = $spd977b7; $sp600a89->saveOrFail(); return true; }); } catch (\Throwable $sp96dd17) { $sp6edbee = 'FundHelper.orderUnfreeze error'; if ($sp600a89) { $sp6edbee .= ', order_no:' . $sp600a89->order_no . ', user_id:' . $sp600a89->user_id . ',amount:' . $sp600a89->income; } else { $sp6edbee .= ', order_no: null'; } Log::error($sp6edbee . ' with exception:', array('Exception' => $sp96dd17)); return false; } } } \ No newline at end of file diff --git a/app/Library/Geetest/API.php b/app/Library/Geetest/API.php index 8f2f3d3b1..f4c32287a 100644 --- a/app/Library/Geetest/API.php +++ b/app/Library/Geetest/API.php @@ -1,2 +1,2 @@ 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 +namespace App\Library\Geetest; use Illuminate\Support\Facades\Session; class API { private $geetest_conf = null; public function __construct($sp8a1f10) { $this->geetest_conf = $sp8a1f10; } public static function get() { $spbabe1d = config('services.geetest.id'); $spe57121 = config('services.geetest.key'); if (!strlen($spbabe1d) || !strlen($spe57121)) { return null; } $spc641e0 = new Lib($spbabe1d, $spe57121); $spdad372 = time() . rand(1, 10000); $sp31859f = $spc641e0->pre_process($spdad372); $sp6a22d6 = json_decode($spc641e0->get_response_str()); Session::put('gt_server', $sp31859f); Session::put('gt_user_id', $spdad372); return $sp6a22d6; } public static function verify($spedc927, $spfff427, $sp4662f8) { $spc641e0 = new Lib(config('services.geetest.id'), config('services.geetest.key')); $spdad372 = Session::get('gt_user_id'); if (Session::get('gt_server') == 1) { $spf77edc = $spc641e0->success_validate($spedc927, $spfff427, $sp4662f8, $spdad372); if ($spf77edc) { return true; } else { return false; } } else { if ($spc641e0->fail_validate($spedc927, $spfff427, $sp4662f8)) { 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 07d3281eb..cf93b46f4 100644 --- a/app/Library/Geetest/Lib.php +++ b/app/Library/Geetest/Lib.php @@ -1,4 +1,4 @@ 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 +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($sp812dd2, $sp09e553) { $this->captcha_id = $sp812dd2; $this->private_key = $sp09e553; } public function pre_process($spdad372 = null) { $sp40b98a = 'http://api.geetest.com/register.php?gt=' . $this->captcha_id; if ($spdad372 != null and is_string($spdad372)) { $sp40b98a = $sp40b98a . '&user_id=' . $spdad372; } $spfba865 = $this->send_request($sp40b98a); if (strlen($spfba865) != 32) { $this->failback_process(); return 0; } $this->success_process($spfba865); return 1; } private function success_process($spfba865) { $spfba865 = md5($spfba865 . $this->private_key); $spf77edc = array('success' => 1, 'gt' => $this->captcha_id, 'challenge' => $spfba865); $this->response = $spf77edc; } private function failback_process() { $spcbff25 = md5(rand(0, 100)); $spa0c30f = md5(rand(0, 100)); $spfba865 = $spcbff25 . substr($spa0c30f, 0, 2); $spf77edc = array('success' => 0, 'gt' => $this->captcha_id, 'challenge' => $spfba865); $this->response = $spf77edc; } public function get_response_str() { return json_encode($this->response); } public function get_response() { return $this->response; } public function success_validate($spfba865, $sp3d7030, $spabb1fb, $spdad372 = null) { if (!$this->check_validate($spfba865, $sp3d7030)) { return 0; } $sp86a999 = array('seccode' => $spabb1fb, 'sdk' => self::GT_SDK_VERSION); if ($spdad372 != null and is_string($spdad372)) { $sp86a999['user_id'] = $spdad372; } $sp40b98a = 'http://api.geetest.com/validate.php'; $sp183234 = $this->post_request($sp40b98a, $sp86a999); if ($sp183234 == md5($spabb1fb)) { return 1; } else { if ($sp183234 == 'false') { return 0; } else { return 0; } } } public function fail_validate($spfba865, $sp3d7030, $spabb1fb) { if ($sp3d7030) { $spae23f7 = explode('_', $sp3d7030); try { $sp3de5a0 = $this->decode_response($spfba865, $spae23f7['0']); $sp35ea94 = $this->decode_response($spfba865, $spae23f7['1']); $spd31810 = $this->decode_response($spfba865, $spae23f7['2']); $sp3a0747 = $this->get_failback_pic_ans($sp35ea94, $spd31810); $spa51178 = abs($sp3de5a0 - $sp3a0747); } catch (\Exception $sp96dd17) { return 1; } if ($spa51178 < 4) { return 1; } else { return 0; } } else { return 0; } } private function check_validate($spfba865, $sp3d7030) { if (strlen($sp3d7030) != 32) { return false; } if (md5($this->private_key . 'geetest' . $spfba865) != $sp3d7030) { return false; } return true; } private function send_request($sp40b98a) { if (function_exists('curl_exec')) { $sp1942b5 = curl_init(); curl_setopt($sp1942b5, CURLOPT_URL, $sp40b98a); curl_setopt($sp1942b5, CURLOPT_CONNECTTIMEOUT, self::$connectTimeout); curl_setopt($sp1942b5, CURLOPT_TIMEOUT, self::$socketTimeout); curl_setopt($sp1942b5, CURLOPT_RETURNTRANSFER, 1); $sp86a999 = curl_exec($sp1942b5); if (curl_errno($sp1942b5)) { $spf0770c = sprintf('curl[%s] error[%s]', $sp40b98a, curl_errno($sp1942b5) . ':' . curl_error($sp1942b5)); $this->triggerError($spf0770c); } curl_close($sp1942b5); } else { $sp60bd72 = array('http' => array('method' => 'GET', 'timeout' => self::$connectTimeout + self::$socketTimeout)); $sp6aba69 = stream_context_create($sp60bd72); $sp86a999 = file_get_contents($sp40b98a, false, $sp6aba69); } return $sp86a999; } private function post_request($sp40b98a, $sp6c3a25 = '') { if (!$sp6c3a25) { return false; } $sp86a999 = http_build_query($sp6c3a25); if (function_exists('curl_exec')) { $sp1942b5 = curl_init(); curl_setopt($sp1942b5, CURLOPT_URL, $sp40b98a); curl_setopt($sp1942b5, CURLOPT_RETURNTRANSFER, 1); curl_setopt($sp1942b5, CURLOPT_CONNECTTIMEOUT, self::$connectTimeout); curl_setopt($sp1942b5, CURLOPT_TIMEOUT, self::$socketTimeout); if (!$sp6c3a25) { curl_setopt($sp1942b5, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); } else { curl_setopt($sp1942b5, CURLOPT_POST, 1); curl_setopt($sp1942b5, CURLOPT_POSTFIELDS, $sp86a999); } $sp86a999 = curl_exec($sp1942b5); if (curl_errno($sp1942b5)) { $spf0770c = sprintf('curl[%s] error[%s]', $sp40b98a, curl_errno($sp1942b5) . ':' . curl_error($sp1942b5)); $this->triggerError($spf0770c); } curl_close($sp1942b5); } else { if ($sp6c3a25) { $sp60bd72 = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded +' . 'Content-Length: ' . strlen($sp86a999) . ' +', 'content' => $sp86a999, 'timeout' => self::$connectTimeout + self::$socketTimeout)); $sp6aba69 = stream_context_create($sp60bd72); $sp86a999 = file_get_contents($sp40b98a, false, $sp6aba69); } } return $sp86a999; } private function decode_response($spfba865, $sp9bd5ca) { if (strlen($sp9bd5ca) > 100) { return 0; } $spe57121 = array(); $sp716a05 = array(); $spa963ae = array('0' => 1, '1' => 2, '2' => 5, '3' => 10, '4' => 50); $spdba6bb = 0; $sp204119 = 0; $spa307a2 = str_split($spfba865); $sp1eec32 = str_split($sp9bd5ca); for ($spe89d11 = 0; $spe89d11 < strlen($spfba865); $spe89d11++) { $sp807bd0 = $spa307a2[$spe89d11]; if (in_array($sp807bd0, $sp716a05)) { continue; } else { $spae23f7 = $spa963ae[$spdba6bb % 5]; array_push($sp716a05, $sp807bd0); $spdba6bb++; $spe57121[$sp807bd0] = $spae23f7; } } for ($spdd959c = 0; $spdd959c < strlen($sp9bd5ca); $spdd959c++) { $sp204119 += $spe57121[$sp1eec32[$spdd959c]]; } $sp204119 = $sp204119 - $this->decodeRandBase($spfba865); return $sp204119; } private function get_x_pos_from_str($sp43e668) { if (strlen($sp43e668) != 5) { return 0; } $sp9d9897 = 0; $spe7bf51 = 200; $sp9d9897 = base_convert($sp43e668, 16, 10); $spf77edc = $sp9d9897 % $spe7bf51; $spf77edc = $spf77edc < 40 ? 40 : $spf77edc; return $spf77edc; } private function get_failback_pic_ans($spac7bd5, $sp69231a) { $sp304e8a = substr(md5($spac7bd5), 0, 9); $sp9e5709 = substr(md5($sp69231a), 10, 9); $spb8df5e = ''; for ($spe89d11 = 0; $spe89d11 < 9; $spe89d11++) { if ($spe89d11 % 2 == 0) { $spb8df5e = $spb8df5e . $sp304e8a[$spe89d11]; } elseif ($spe89d11 % 2 == 1) { $spb8df5e = $spb8df5e . $sp9e5709[$spe89d11]; } } $sp63cd38 = substr($spb8df5e, 4, 5); $sp3a0747 = $this->get_x_pos_from_str($sp63cd38); return $sp3a0747; } private function decodeRandBase($spfba865) { $spa97a2a = substr($spfba865, 32, 2); $sped92bd = array(); for ($spe89d11 = 0; $spe89d11 < strlen($spa97a2a); $spe89d11++) { $sp09f4b7 = ord($spa97a2a[$spe89d11]); $spf77edc = $sp09f4b7 > 57 ? $sp09f4b7 - 87 : $sp09f4b7 - 48; array_push($sped92bd, $spf77edc); } $spea3acd = $sped92bd['0'] * 36 + $sped92bd['1']; return $spea3acd; } private function triggerError($spf0770c) { } } \ No newline at end of file diff --git a/app/Library/Helper.php b/app/Library/Helper.php index 354b7bf92..001a6f25b 100644 --- a/app/Library/Helper.php +++ b/app/Library/Helper.php @@ -1,2 +1,2 @@ = $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 +namespace App\Library; use Hashids\Hashids; class Helper { public static function getMysqlDate($sp037eb2 = 0) { return date('Y-m-d', time() + $sp037eb2 * 24 * 3600); } public static function getIP() { if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $spa6e31b = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { if (isset($_SERVER['HTTP_CLIENT_IP'])) { $spa6e31b = $_SERVER['HTTP_CLIENT_IP']; } else { $spa6e31b = @$_SERVER['REMOTE_ADDR']; } } } else { if (getenv('HTTP_X_FORWARDED_FOR')) { $spa6e31b = getenv('HTTP_X_FORWARDED_FOR'); } else { if (getenv('HTTP_CLIENT_IP')) { $spa6e31b = getenv('HTTP_CLIENT_IP'); } else { $spa6e31b = getenv('REMOTE_ADDR'); } } } if (strpos($spa6e31b, ',') !== FALSE) { $sp80fc39 = explode(',', $spa6e31b); return $sp80fc39[0]; } return $spa6e31b; } public static function getClientIP() { if (isset($_SERVER)) { $spa6e31b = $_SERVER['REMOTE_ADDR']; } else { $spa6e31b = getenv('REMOTE_ADDR'); } if (strpos($spa6e31b, ',') !== FALSE) { $sp80fc39 = explode(',', $spa6e31b); return $sp80fc39[0]; } return $spa6e31b; } public static function filterWords($spa06bf2, $spcd9c68) { if (!$spa06bf2) { return false; } if (!is_array($spcd9c68)) { $spcd9c68 = explode('|', $spcd9c68); } foreach ($spcd9c68 as $spb8ad25) { if ($spb8ad25 && strpos($spa06bf2, $spb8ad25) !== FALSE) { return $spb8ad25; } } return false; } public static function is_idcard($sp55150a) { if (strlen($sp55150a) == 18) { return self::idcard_checksum18($sp55150a); } elseif (strlen($sp55150a) == 15) { $sp55150a = self::idcard_15to18($sp55150a); return self::idcard_checksum18($sp55150a); } else { return false; } } private static function idcard_verify_number($sp082d56) { if (strlen($sp082d56) != 17) { return false; } $spcc91ab = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); $sp140032 = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); $sp87ff12 = 0; for ($spe89d11 = 0; $spe89d11 < strlen($sp082d56); $spe89d11++) { $sp87ff12 += substr($sp082d56, $spe89d11, 1) * $spcc91ab[$spe89d11]; } $sp9f9140 = $sp87ff12 % 11; $sp3a02e6 = $sp140032[$sp9f9140]; return $sp3a02e6; } private static function idcard_15to18($spb0d385) { if (strlen($spb0d385) != 15) { return false; } else { if (array_search(substr($spb0d385, 12, 3), array('996', '997', '998', '999')) !== false) { $spb0d385 = substr($spb0d385, 0, 6) . '18' . substr($spb0d385, 6, 9); } else { $spb0d385 = substr($spb0d385, 0, 6) . '19' . substr($spb0d385, 6, 9); } } $spb0d385 = $spb0d385 . self::idcard_verify_number($spb0d385); return $spb0d385; } private static function idcard_checksum18($spb0d385) { if (strlen($spb0d385) != 18) { return false; } $sp082d56 = substr($spb0d385, 0, 17); if (self::idcard_verify_number($sp082d56) != strtoupper(substr($spb0d385, 17, 1))) { return false; } else { return true; } } public static function str_between($spa06bf2, $sp724ff9, $spc0201e) { $sp9ef85b = strpos($spa06bf2, $sp724ff9); if ($sp9ef85b === false) { return ''; } $spbf77fa = strpos($spa06bf2, $spc0201e, $sp9ef85b + strlen($sp724ff9)); if ($spbf77fa === false || $sp9ef85b >= $spbf77fa) { return ''; } $sp7c812f = strlen($sp724ff9); $sp6a22d6 = substr($spa06bf2, $sp9ef85b + $sp7c812f, $spbf77fa - $sp9ef85b - $sp7c812f); return $sp6a22d6; } public static function str_between_longest($spa06bf2, $sp724ff9, $spc0201e) { $sp9ef85b = strpos($spa06bf2, $sp724ff9); if ($sp9ef85b === false) { return ''; } $spbf77fa = strrpos($spa06bf2, $spc0201e, $sp9ef85b + strlen($sp724ff9)); if ($spbf77fa === false || $sp9ef85b >= $spbf77fa) { return ''; } $sp7c812f = strlen($sp724ff9); $sp6a22d6 = substr($spa06bf2, $sp9ef85b + $sp7c812f, $spbf77fa - $sp9ef85b - $sp7c812f); return $sp6a22d6; } public static function format_url($sp40b98a) { if (!strlen($sp40b98a)) { return $sp40b98a; } if (!starts_with($sp40b98a, 'http://') && !starts_with($sp40b98a, 'https://')) { $sp40b98a = 'http://' . $sp40b98a; } while (ends_with($sp40b98a, '/')) { $sp40b98a = substr($sp40b98a, 0, -1); } return $sp40b98a; } public static function lite_hash($spa06bf2) { $sp43e072 = crc32((string) $spa06bf2); if ($sp43e072 < 0) { $sp43e072 &= 1 << 7; } return $sp43e072; } const ID_TYPE_USER = 0; const ID_TYPE_CATEGORY = 1; const ID_TYPE_PRODUCT = 2; public static function id_encode($spbabe1d, $sp0fe7ec) { $speb9ebc = new Hashids(config('app.key'), 8, 'abcdefghijklmnopqrstuvwxyz1234567890'); return @$speb9ebc->encode(self::lite_hash($spbabe1d), $spbabe1d, self::lite_hash($sp0fe7ec), $sp0fe7ec); } public static function id_decode($spc182cd, $sp0fe7ec) { if (strlen($spc182cd) < 8) { $speb9ebc = new Hashids(config('app.key')); if ($sp0fe7ec === self::ID_TYPE_USER) { return intval(@$speb9ebc->decodeHex($spc182cd)); } else { return intval(@$speb9ebc->decode($spc182cd)[0]); } } $speb9ebc = new Hashids(config('app.key'), 8, 'abcdefghijklmnopqrstuvwxyz1234567890'); return intval(@$speb9ebc->decode($spc182cd)[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()) { $sp336fec = 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 { $sp336fec = 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 $sp336fec[rand(0, count($sp336fec))]; } } \ No newline at end of file diff --git a/app/Library/LogHelper.php b/app/Library/LogHelper.php index 25ccbefde..17df0e10d 100644 --- a/app/Library/LogHelper.php +++ b/app/Library/LogHelper.php @@ -1,2 +1,2 @@ setHandlers(array()); \Log::useDailyFiles(storage_path() . '/logs/' . $sp23c04a . '.log', 0, config('app.log_level')); } } \ No newline at end of file +namespace App\Library; class LogHelper { public static function setLogFile($spefa168) { \Log::getMonolog()->setHandlers(array()); \Log::useDailyFiles(storage_path() . '/logs/' . $spefa168 . '.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 9767f97b6..b67f8015d 100644 --- a/app/Library/Response.php +++ b/app/Library/Response.php @@ -1,2 +1,2 @@ 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 +namespace App\Library; class Response { public static function json($sp86a999 = array(), $sp31859f = 200, array $spa565dd = array(), $sp94c476 = 0) { return response()->json($sp86a999, $sp31859f, $spa565dd, $sp94c476); } public static function success($sp86a999 = array()) { return self::json(array('message' => 'success', 'data' => $sp86a999)); } public static function fail($sp6edbee = 'fail', $sp86a999 = array()) { return self::json(array('message' => $sp6edbee, 'data' => $sp86a999), 500); } public static function forbidden($sp6edbee = 'forbidden', $sp86a999 = array()) { return self::json(array('message' => $sp6edbee, 'data' => $sp86a999), 403); } } \ No newline at end of file diff --git a/app/Library/UrlShorten.php b/app/Library/UrlShorten.php index bbce26e7f..a9ff94cc0 100644 --- a/app/Library/UrlShorten.php +++ b/app/Library/UrlShorten.php @@ -1,2 +1,2 @@ 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 +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($sp600a89, $sp32fb2d, $spe1c2dd) { $this->order = $sp600a89; $this->card_msg = $sp32fb2d; $this->cards_txt = $spe1c2dd; } 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 de6b1a3f7..d171183f8 100644 --- a/app/Mail/ProductCountWarn.php +++ b/app/Mail/ProductCountWarn.php @@ -1,2 +1,2 @@ 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 +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($spe7d79d, $sp80b567) { $this->product = $spe7d79d; $this->product_count = $sp80b567; } 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 13406aca9..3790d0597 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() { $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 +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() { $spd10b1a = date('YmdHis') . str_random(5); while (\App\Order::where('order_no', $spd10b1a)->exists()) { $spd10b1a = date('YmdHis') . str_random(5); } return $spd10b1a; } function user() { return $this->belongsTo(User::class); } function product() { return $this->belongsTo(Product::class); } function pay() { return $this->belongsTo(Pay::class); } function cards() { $sp937c8f = $this->belongsToMany(Card::class); return $sp937c8f->withTrashed(); } function card_orders() { return $this->hasMany(CardOrder::class); } function fundRecord() { return $this->hasMany(FundRecord::class); } function getCardsArray() { $spf7b822 = array(); $this->cards->each(function ($sp3fbb89) use(&$spf7b822) { $spf7b822[] = $sp3fbb89->card; }); return $spf7b822; } function getSendMessage() { if (count($this->cards)) { if (count($this->cards) == $this->count) { $sp32fb2d = '订单#' . $this->order_no . ' 已支付,您购买的内容如下:'; } else { if ($this->cards[0]->type === \App\Card::TYPE_REPEAT || @$this->product->delivery === \App\Product::DELIVERY_MANUAL) { $sp32fb2d = '订单#' . $this->order_no . ' 已支付,您购买的内容如下:'; } else { $sp32fb2d = '订单#' . $this->order_no . ' 已支付,目前库存不足,您还有' . ($this->count - count($this->cards)) . '件未发货,请联系商家客服发货
已发货商品见下方:
'; $sp32fb2d .= '商家客服QQ:' . $this->user->qq . '
'; } } } else { $sp32fb2d = '订单#' . $this->order_no . ' 已支付,目前库存不足,您购买的' . ($this->count - count($this->cards)) . '件未发货,请联系商家客服发货
'; $sp32fb2d .= '商家客服QQ:' . $this->user->qq . '
'; } return $sp32fb2d; } function sendEmail($sp030dc3 = false) { if ($sp030dc3 === false) { $sp030dc3 = @json_decode($this->contact_ext)['_mail']; } if (!$sp030dc3 || !@filter_var($sp030dc3, FILTER_VALIDATE_EMAIL)) { return; } $spf7b822 = $this->getCardsArray(); try { Mail::to($sp030dc3)->Queue(new OrderShipped($this, $this->getSendMessage(), join('
', $spf7b822))); $this->send_status = \App\Order::SEND_STATUS_EMAIL_SUCCESS; $this->saveOrFail(); } catch (\Throwable $sp96dd17) { $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' => $sp030dc3, 'cards' => $spf7b822, 'exception' => $sp96dd17->getMessage())); LogHelper::setLogFile('card'); } } function sendSms($spe34083 = false) { if ($spe34083 === false) { $spe34083 = @json_decode($this->contact_ext)['_mobile']; } if (!$spe34083 || strlen($spe34083) !== 11) { return; } OrderSms::dispatch($spe34083, $this); } } \ No newline at end of file diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index 6dedd850c..a61e0a093 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($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 +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($spb14cf0) { \App\Card::where('user_id', $spb14cf0->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 ($sp1432b9) { foreach ($sp1432b9 as $sp4c126d) { $spe7d79d = \App\Product::where('id', $sp4c126d->product_id)->first(); if ($spe7d79d) { if ($spe7d79d->delivery === \App\Product::DELIVERY_MANUAL) { $spe7d79d->update(array('count_sold' => $sp4c126d->count_sold)); } else { $spe7d79d->update(array('count_sold' => $sp4c126d->count_sold, 'count_all' => $sp4c126d->count_all)); } } else { } } }); } function createApiCards($sp600a89) { $spe1c2dd = array(); $sp2887bd = array(); $sp072569 = array(); for ($spe89d11 = 0; $spe89d11 < $sp600a89->count; $spe89d11++) { $spe1c2dd[] = strtoupper(str_random(16)); $sp622402 = date('Y-m-d H:i:s'); switch ($this->id) { case 6: $spaa0f95 = 1; break; case 11: $spaa0f95 = 2; break; case 37: $spaa0f95 = 3; break; default: die('App.Products fatal error#1'); } $sp072569[] = array('user_id' => $this->user_id, 'product_id' => $this->id, 'card' => $spe1c2dd[$spe89d11], 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1); $sp2887bd[] = "(NULL, '{$spe1c2dd[$spe89d11]}', '1', '{$spaa0f95}', NULL, NULL, NULL, NULL, NULL, '0', '{$sp622402}', '0000-00-00 00:00:00')"; } $spb64b87 = mysqli_connect('localhost', 'udiddz', 'tRihPm3sh6yKedtX', 'udiddz', '3306'); $sp7e7d51 = 'INSERT INTO `udiddz`.`ac_kms` (`id`, `km`, `value`, `task`, `udid`, `diz`, `task_id`, `install_url`, `plist_url`, `jh`, `addtime`, `tjtime`) VALUES ' . join(',', $sp2887bd); $sp204119 = mysqli_query($spb64b87, $sp7e7d51); if (!$sp204119) { LogWriter::error('App.Products, connect udid database failed', array('sql' => $sp7e7d51, 'error' => mysqli_error($spb64b87))); return array(); } $this->count_all += $sp600a89->count; return $this->cards()->createMany($sp072569); } function setForShop($spb14cf0 = null) { $spe7d79d = $this; $spdba6bb = $spe7d79d->count; $sp315e13 = $spe7d79d->inventory; if ($sp315e13 == User::INVENTORY_AUTO) { $sp315e13 = System::_getInt('shop_inventory'); } if ($sp315e13 == User::INVENTORY_RANGE) { if ($spdba6bb <= 0) { $sp7c063c = '不足'; } elseif ($spdba6bb <= 10) { $sp7c063c = '少量'; } elseif ($spdba6bb <= 20) { $sp7c063c = '一般'; } else { $sp7c063c = '大量'; } $spe7d79d->setAttribute('count2', $sp7c063c); } else { $spe7d79d->setAttribute('count2', $spdba6bb); } $spe7d79d->setAttribute('count', $spdba6bb); $spe7d79d->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 fff4c5641..db8df4f42 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 $sp6a7295) { \Log::error('Config init failed: ' . $sp6a7295->getMessage(), array('exception' => $sp6a7295)); } } 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.95e', '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 $sp96dd17) { \Log::error('Config init failed: ' . $sp96dd17->getMessage(), array('exception' => $sp96dd17)); } } public function register() { } } \ No newline at end of file diff --git a/app/ShopTheme.php b/app/ShopTheme.php index 9fe5c6009..93340c478 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() { $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 +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() { $sp5af18a = realpath(app_path('..' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'shop_theme')); \App\ShopTheme::query()->get()->each(function ($spacd1cb) use($sp5af18a) { if (!file_exists($sp5af18a . DIRECTORY_SEPARATOR . $spacd1cb->name . DIRECTORY_SEPARATOR . 'config.php')) { $spacd1cb->delete(); } }); foreach (scandir($sp5af18a) as $spc485f4) { if ($spc485f4 === '.' || $spc485f4 === '..') { continue; } try { @($spacd1cb = (include $sp5af18a . DIRECTORY_SEPARATOR . $spc485f4 . DIRECTORY_SEPARATOR . 'config.php')); } catch (\Exception $sp96dd17) { continue; } $spacd1cb['config'] = array_map(function ($sp807bd0) { return $sp807bd0['value']; }, @$spacd1cb['options'] ?? array()); $sp265a87 = \App\ShopTheme::query()->where('name', $spc485f4)->first(); if ($sp265a87) { $sp265a87->description = $spacd1cb['description']; $sp265a87->options = @$spacd1cb['options'] ?? array(); $sp265a87->config = ($sp265a87->config ?? array()) + $spacd1cb['config']; $sp265a87->saveOrFail(); } else { if ($spacd1cb && isset($spacd1cb['description'])) { \App\ShopTheme::query()->create(array('name' => $spc485f4, 'description' => $spacd1cb['description'], 'options' => @$spacd1cb['options'] ?? array(), 'config' => $spacd1cb['config'])); } } } } } \ No newline at end of file diff --git a/app/System.php b/app/System.php index d72764efa..c1c44e910 100644 --- a/app/System.php +++ b/app/System.php @@ -1,2 +1,2 @@ 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 +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 () { $sp796309 = System::query()->get()->toArray(); foreach ($sp796309 as $sp2cd86b) { static::$systems[$sp2cd86b['name']] = $sp2cd86b['value']; } return static::$systems; }); static::$systems['_initialized'] = true; } public static function _get($sp6b4dc2, $spb2c558 = NULL) { if (!isset(static::$systems['_initialized'])) { static::_init(); } if (isset(static::$systems[$sp6b4dc2])) { return static::$systems[$sp6b4dc2]; } return $spb2c558; } public static function _getInt($sp6b4dc2, $spb2c558 = NULL) { return (int) static::_get($sp6b4dc2, $spb2c558); } public static function _set($sp6b4dc2, $spae23f7) { static::$systems[$sp6b4dc2] = $spae23f7; $spc06e14 = System::query()->where('name', $sp6b4dc2)->first(); if ($spc06e14) { $spc06e14->value = $spae23f7; $spc06e14->save(); } else { try { System::query()->insert(array('name' => $sp6b4dc2, 'value' => $spae23f7)); } catch (\Exception $sp96dd17) { } } 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 1a8c71341..eea6cb1e0 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() { $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 +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() { $sp645757 = (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 - $sp645757; } function getShopThemeAttribute() { if ($this->theme_config) { $sp6a22d6 = \App\ShopTheme::whereName($this->theme_config['theme'])->first(); if ($sp6a22d6) { return $sp6a22d6; } } 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 83f641124..f5993f09c 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,2 +1,2 @@ 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 +$sp64c9d2 = new Illuminate\Foundation\Application(realpath(__DIR__ . '/../')); $sp64c9d2->singleton(Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class); $sp64c9d2->singleton(Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class); $sp64c9d2->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class); return $sp64c9d2; \ No newline at end of file diff --git a/database/factories/OrderFactory.php b/database/factories/OrderFactory.php index ec0242ace..f47ac79d3 100644 --- a/database/factories/OrderFactory.php +++ b/database/factories/OrderFactory.php @@ -1,2 +1,2 @@ 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 +use Faker\Generator as Faker; $spbd692e->define(App\Order::class, function (Faker $sp1b1641) { $spd10b1a = date('YmdHis') . mt_rand(10000, 99999); while (\App\Order::whereOrderNo($spd10b1a)->exists()) { $spd10b1a = date('YmdHis') . mt_rand(10000, 99999); } $sp551dce = random_int(0, 1) ? $sp1b1641->email : 'user01@qq.com'; $sp8af8bc = 1000; $sp456ce1 = random_int(0, 1) * 100; $sp9de5ea = $sp8af8bc - $sp456ce1; return array('user_id' => 2, 'order_no' => $spd10b1a, '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 d1e68ab7f..ae834235d 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->string('email', 100)->unique(); $sp9906b2->string('mobile')->nullable(); $sp9906b2->string('password', 100); $sp9906b2->integer('m_paid')->default(0); $sp9906b2->integer('m_frozen')->default(0); $sp9906b2->integer('m_all')->default(0); $sp9906b2->rememberToken(); $sp9906b2->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 a3a56a91d..18ddcb008 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('user_id')->index(); $sp9906b2->text('name'); $sp9906b2->integer('sort')->default(1000); $sp9906b2->string('password')->nullable(); $sp9906b2->boolean('password_open')->default(false); $sp9906b2->boolean('enabled'); $sp9906b2->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 e677ab4a9..9327a57f9 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('user_id')->index(); $sp9906b2->integer('category_id')->index(); $sp9906b2->string('name'); $sp9906b2->longText('description'); $sp9906b2->integer('sort')->default(1000); $sp9906b2->integer('buy_min')->default(1); $sp9906b2->integer('buy_max')->default(10); $sp9906b2->integer('count_sold')->default(0); $sp9906b2->integer('count_all')->default(0); $sp9906b2->integer('count_warn')->default(0); $sp9906b2->boolean('support_coupon')->default(false); $sp9906b2->string('password')->nullable(); $sp9906b2->boolean('password_open')->default(false); $sp9906b2->integer('cost')->default(0); $sp9906b2->integer('price'); $sp9906b2->text('price_whole')->nullable(); $sp9906b2->text('instructions')->nullable(); $sp9906b2->text('fields')->nullable(); $sp9906b2->boolean('enabled'); $sp9906b2->tinyInteger('inventory')->default(\App\User::INVENTORY_AUTO); $sp9906b2->tinyInteger('fee_type')->default(\App\User::FEE_TYPE_AUTO); $sp9906b2->tinyInteger('delivery')->default(\App\Product::DELIVERY_AUTO); $sp9906b2->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 d2662f44b..00a1c939c 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('user_id')->index(); $sp9906b2->integer('product_id')->index(); $sp9906b2->text('card'); $sp9906b2->integer('type'); $sp9906b2->integer('status')->default(\App\Card::STATUS_NORMAL); $sp9906b2->integer('count_sold')->default(0); $sp9906b2->integer('count_all')->default(1); $sp9906b2->timestamps(); $sp9906b2->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 $sp96dd17) { } } } \ 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 c595bdf7f..fc1a2ed08 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('user_id')->index(); $sp9906b2->string('order_no', 128)->index(); $sp9906b2->integer('product_id'); $sp9906b2->string('product_name')->nullable(); $sp9906b2->integer('count'); $sp9906b2->string('ip')->nullable(); $sp9906b2->string('customer', 32)->nullable(); $sp9906b2->string('contact')->nullable(); $sp9906b2->text('contact_ext')->nullable(); $sp9906b2->tinyInteger('send_status')->default(App\Order::SEND_STATUS_UN); $sp9906b2->text('remark')->nullable(); $sp9906b2->integer('cost')->default(0); $sp9906b2->integer('price')->default(0); $sp9906b2->integer('discount')->default(0); $sp9906b2->integer('paid')->default(0); $sp9906b2->integer('fee')->default(0); $sp9906b2->integer('system_fee')->default(0); $sp9906b2->integer('income')->default(0); $sp9906b2->integer('pay_id'); $sp9906b2->string('pay_trade_no')->nullable(); $sp9906b2->integer('status')->default(\App\Order::STATUS_UNPAY); $sp9906b2->string('frozen_reason')->nullable(); $sp9906b2->string('api_out_no', 128)->nullable(); $sp9906b2->text('api_info')->nullable(); $sp9906b2->dateTime('paid_at')->nullable(); $sp9906b2->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 eebdedc4d..1a3c2f9a8 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->string('name'); $sp9906b2->integer('sort')->default(1000); $sp9906b2->string('img'); $sp9906b2->string('driver'); $sp9906b2->string('way'); $sp9906b2->text('config'); $sp9906b2->text('comment')->nullable(); $sp9906b2->float('fee_system', 8, 4)->default(0.01); $sp9906b2->boolean('enabled'); $sp9906b2->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 9a36829d0..8f15a1f58 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'); $sp580417->integer('order_id')->index(); $sp580417->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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('order_id')->index(); $sp9906b2->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 3435014a3..d9ab19c89 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('user_id')->index(); $sp9906b2->integer('category_id')->default(-1); $sp9906b2->integer('product_id')->default(-1); $sp9906b2->integer('type')->default(\App\Coupon::TYPE_REPEAT); $sp9906b2->integer('status')->default(\App\Coupon::STATUS_NORMAL); $sp9906b2->string('coupon', 100)->index(); $sp9906b2->integer('discount_type'); $sp9906b2->integer('discount_val'); $sp9906b2->integer('count_used')->default(0); $sp9906b2->integer('count_all')->default(1); $sp9906b2->string('remark')->nullable(); $sp9906b2->dateTime('expire_at')->nullable(); $sp9906b2->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 5c8d3df62..fb4b8889f 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('user_id')->index(); $sp9906b2->string('ip'); $sp9906b2->integer('action')->default(\App\Log::ACTION_LOGIN); $sp9906b2->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 d0343b866..b4552c40f 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'); $sp580417->string('name', 100)->unique(); $sp580417->longText('value')->nullable(); $sp580417->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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->string('name', 100)->unique(); $sp9906b2->longText('value')->nullable(); $sp9906b2->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 0cee2e290..24377a17a 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('user_id')->index(); $sp9906b2->integer('type')->default(\App\FundRecord::TYPE_OUT); $sp9906b2->integer('amount'); $sp9906b2->integer('balance')->default(0); $sp9906b2->integer('order_id')->nullable(); $sp9906b2->string('withdraw_id')->nullable(); $sp9906b2->string('remark')->nullable(); $sp9906b2->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 a6219a2e6..45683dc2a 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'); $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 +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 $sp9906b2) { $sp9906b2->bigIncrements('id'); $sp9906b2->string('queue', 128)->index(); $sp9906b2->longText('payload'); $sp9906b2->unsignedTinyInteger('attempts'); $sp9906b2->unsignedInteger('reserved_at')->nullable(); $sp9906b2->unsignedInteger('available_at'); $sp9906b2->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 eb1c3fd08..59b821b04 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->integer('user_id'); $sp9906b2->string('driver'); $sp9906b2->string('path'); $sp9906b2->string('url'); $sp9906b2->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 50642b376..126ed7282 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'); $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 +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 $sp9906b2) { $sp9906b2->increments('id'); $sp9906b2->string('name', 128)->unique(); $sp9906b2->string('description')->nullable(); $sp9906b2->text('options')->nullable(); $sp9906b2->text('config')->nullable(); $sp9906b2->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 65a7b4415..848ca3c1c 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 ($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 +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 $sp9906b2) { $sp9906b2->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 ($sp1432b9) { foreach ($sp1432b9 as $sp4c126d) { \App\Product::where('id', $sp4c126d->product_id)->update(array('count_sold' => $sp4c126d->count_sold, 'count_all' => $sp4c126d->count_all)); } }); } } public function down() { if (Schema::hasColumn('products', 'count_all')) { Schema::table('products', function (Blueprint $sp9906b2) { $sp9906b2->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 e65db0011..1cd08ea08 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 $sp9906b2) { $sp9906b2->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 50e4bc357..2dcf59508 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'); $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 +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 $sp9906b2) { $sp9906b2->tinyInteger('inventory')->default(\App\User::INVENTORY_AUTO)->after('enabled'); $sp9906b2->tinyInteger('fee_type')->default(\App\User::FEE_TYPE_AUTO)->after('inventory'); }); } } public function down() { foreach (array('inventory', 'fee_type') as $spebc2db) { try { Schema::table('products', function (Blueprint $sp9906b2) use($spebc2db) { $sp9906b2->dropColumn($spebc2db); }); } catch (\Throwable $sp96dd17) { } } } } \ 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 d525e0e89..178c898dc 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'); $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 +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 $sp9906b2) { $sp9906b2->integer('all')->nullable()->after('amount'); $sp9906b2->integer('frozen')->nullable()->after('all'); $sp9906b2->integer('paid')->nullable()->after('frozen'); }); } } public function down() { foreach (array('all', 'frozen', 'paid') as $spebc2db) { try { Schema::table('fund_records', function (Blueprint $sp9906b2) use($spebc2db) { $sp9906b2->dropColumn($spebc2db); }); } catch (\Throwable $sp96dd17) { } } } } \ 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 fd0a45986..29f427d60 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 $sp9906b2) { $sp9906b2->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 56da12351..c36b84880 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'); $sp580417->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 $sp9906b2) { $sp9906b2->text('fields')->nullable()->after('instructions'); $sp9906b2->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 $sp580417) { $sp580417->text('contact_ext')->nullable()->after('contact'); }); } } public function down() { } } \ No newline at end of file + '); Schema::table('orders', function (Blueprint $sp9906b2) { $sp9906b2->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 712440453..1648bf4dc 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 $sp9906b2) { $sp9906b2->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 8b697b6f1..45b9e13fd 100644 --- a/database/seeds/CardsSeeder.php +++ b/database/seeds/CardsSeeder.php @@ -1,2 +1,2 @@ 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 +use Illuminate\Database\Seeder; class CardsSeeder extends Seeder { public function run() { $spdad372 = \App\User::first()->id; \App\Card::insert(array(array('user_id' => $spdad372, 'product_id' => 1, 'card' => '11111', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1), array('user_id' => $spdad372, 'product_id' => 1, 'card' => '11112', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_SOLD, 'count_sold' => 1, 'count_all' => 1), array('user_id' => $spdad372, 'product_id' => 1, 'card' => '11113', 'type' => \App\Card::TYPE_ONETIME, 'status' => \App\Card::STATUS_NORMAL, 'count_sold' => 0, 'count_all' => 1), array('user_id' => $spdad372, '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 be763afdc..2cbad609b 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 $sp6a7295) { } } 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 $sp96dd17) { } } public function run() { self::increaseId(); } } \ No newline at end of file diff --git a/database/seeds/PayTableSeeder.php b/database/seeds/PayTableSeeder.php index a82ea651a..2a54dc667 100644 --- a/database/seeds/PayTableSeeder.php +++ b/database/seeds/PayTableSeeder.php @@ -1,70 +1,70 @@ name = '支付宝'; $sp91f0ec->img = '/plugins/images/ali.png'; $sp91f0ec->driver = 'Fakala'; $sp91f0ec->way = 'alipay'; $sp91f0ec->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp91f0ec->config = '{ +use Illuminate\Database\Seeder; class PayTableSeeder extends Seeder { private function initPay() { $sp1b768e = new \App\Pay(); $sp1b768e->name = '支付宝'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'Fakala'; $sp1b768e->way = 'alipay'; $sp1b768e->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp1b768e->config = '{ "gateway": "https://www.327ka.com", "api_id": "your api_id", "api_key": "your api_key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_PC; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '支付宝'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'Fakala'; $sp1b768e->way = 'alipaywap'; $sp1b768e->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp1b768e->config = '{ "gateway": "https://www.327ka.com", "api_id": "your api_id", "api_key": "your api_key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_MOBILE; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '微信'; $sp1b768e->img = '/plugins/images/wx.png'; $sp1b768e->driver = 'Fakala'; $sp1b768e->way = 'wx'; $sp1b768e->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp1b768e->config = '{ "gateway": "https://www.327ka.com", "api_id": "your api_id", "api_key": "your api_key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_PC; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '微信'; $sp1b768e->img = '/plugins/images/wx.png'; $sp1b768e->driver = 'Fakala'; $sp1b768e->way = 'wxwap'; $sp1b768e->comment = 'alipay、alipaywap、wx、wxwap、qq、qqwap'; $sp1b768e->config = '{ "gateway": "https://www.327ka.com", "api_id": "your api_id", "api_key": "your api_key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_MOBILE; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '支付宝'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'Alipay'; $sp1b768e->way = 'pc'; $sp1b768e->comment = '支付宝 - 即时到账套餐(企业)V2'; $sp1b768e->config = '{ "partner": "partner", "key": "key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '支付宝'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'Aliwap'; $sp1b768e->way = 'wap'; $sp1b768e->comment = '支付宝 - 高级手机网站支付V4'; $sp1b768e->config = '{ "partner": "partner", "key": "key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '支付宝扫码'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'AliAop'; $sp1b768e->way = 'f2f'; $sp1b768e->comment = '支付宝 - 当面付'; $sp1b768e->config = '{ "app_id": "app_id", "alipay_public_key": "alipay_public_key", "merchant_private_key": "merchant_private_key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '支付宝'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'AliAop'; $sp1b768e->way = 'pc'; $sp1b768e->comment = '支付宝 - 电脑网站支付 (新)'; $sp1b768e->config = '{ "app_id": "app_id", "alipay_public_key": "alipay_public_key", "merchant_private_key": "merchant_private_key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '手机支付宝'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'AliAop'; $sp1b768e->way = 'mobile'; $sp1b768e->comment = '支付宝 - 手机网站支付 (新)'; $sp1b768e->config = '{ "app_id": "app_id", "alipay_public_key": "alipay_public_key", "merchant_private_key": "merchant_private_key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '微信扫码'; $sp1b768e->img = '/plugins/images/wx.png'; $sp1b768e->driver = 'WeChat'; $sp1b768e->way = 'NATIVE'; $sp1b768e->comment = '微信支付 - 扫码'; $sp1b768e->config = '{ "APPID": "APPID", "APPSECRET": "APPSECRET", "MCHID": "商户ID", "KEY": "KEY" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '微信H5'; $sp1b768e->img = '/plugins/images/wx.png'; $sp1b768e->driver = 'WeChat'; $sp1b768e->way = 'MWEB'; $sp1b768e->comment = '微信支付 - H5 (需要开通权限)'; $sp1b768e->config = '{ "APPID": "APPID", "APPSECRET": "APPSECRET", "MCHID": "商户ID", "KEY": "KEY" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '手机QQ'; $sp1b768e->img = '/plugins/images/qq.png'; $sp1b768e->driver = 'QPay'; $sp1b768e->way = 'NATIVE'; $sp1b768e->comment = '手机QQ - 扫码'; $sp1b768e->config = '{ "mch_id": "mch_id", "mch_key": "mch_key" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '支付宝'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'Youzan'; $sp1b768e->way = 'alipay'; $sp1b768e->comment = '有赞支付 - 支付宝'; $sp1b768e->config = '{ "client_id": "client_id", "client_secret": "client_secret", "kdt_id": "kdt_id" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '微信'; $sp1b768e->img = '/plugins/images/wx.png'; $sp1b768e->driver = 'Youzan'; $sp1b768e->way = 'wechat'; $sp1b768e->comment = '有赞支付 - 微信'; $sp1b768e->config = '{ "client_id": "client_id", "client_secret": "client_secret", "kdt_id": "kdt_id" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '手机QQ'; $sp1b768e->img = '/plugins/images/qq.png'; $sp1b768e->driver = 'Youzan'; $sp1b768e->way = 'qq'; $sp1b768e->comment = '有赞支付 - 手机QQ'; $sp1b768e->config = '{ "client_id": "client_id", "client_secret": "client_secret", "kdt_id": "kdt_id" -}'; $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 = '{ +}'; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '支付宝'; $sp1b768e->img = '/plugins/images/ali.png'; $sp1b768e->driver = 'CodePay'; $sp1b768e->way = 'alipay'; $sp1b768e->comment = '码支付 - 支付宝'; $sp1b768e->config = '{ "id": "id", "key": "key" -}'; $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 = '{ +}'; $sp1b768e->fee_system = 0; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '微信'; $sp1b768e->img = '/plugins/images/wx.png'; $sp1b768e->driver = 'CodePay'; $sp1b768e->way = 'weixin'; $sp1b768e->comment = '码支付 - 微信'; $sp1b768e->config = '{ "id": "id", "key": "key" -}'; $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 = '{ +}'; $sp1b768e->fee_system = 0; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->save(); $sp1b768e = new \App\Pay(); $sp1b768e->name = '手机QQ'; $sp1b768e->img = '/plugins/images/qq.png'; $sp1b768e->driver = 'CodePay'; $sp1b768e->way = 'qq'; $sp1b768e->comment = '码支付 - 手机QQ'; $sp1b768e->config = '{ "id": "id", "key": "key" -}'; $sp91f0ec->fee_system = 0; $sp91f0ec->enabled = \App\Pay::ENABLED_DISABLED; $sp91f0ec->save(); } public function run() { self::initPay(); } } \ No newline at end of file +}'; $sp1b768e->fee_system = 0; $sp1b768e->enabled = \App\Pay::ENABLED_DISABLED; $sp1b768e->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 b514e48b5..2fdb090ce 100644 --- a/database/seeds/ProductsSeeder.php +++ b/database/seeds/ProductsSeeder.php @@ -1,2 +1,2 @@ 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 +use Illuminate\Database\Seeder; class ProductsSeeder extends Seeder { public function run() { $spdad372 = \App\User::first()->id; $spa74819 = new \App\Category(); $spa74819->user_id = $spdad372; $spa74819->name = '测试分组'; $spa74819->enabled = true; $spa74819->save(); $spa74819 = new \App\Category(); $spa74819->user_id = $spdad372; $spa74819->name = '这里是一个啦啦啦啦啦啦超级无敌爆炸螺旋长的商品类别标题'; $spa74819->enabled = true; $spa74819->save(); $spa74819 = new \App\Category(); $spa74819->user_id = $spdad372; $spa74819->name = '密码123456'; $spa74819->enabled = true; $spa74819->password = '123456'; $spa74819->password_open = true; $spa74819->save(); $spe7d79d = new \App\Product(); $spe7d79d->id = 1; $spe7d79d->user_id = $spdad372; $spe7d79d->category_id = 1; $spe7d79d->name = '测试商品'; $spe7d79d->description = '这里是测试商品的一段简短的描述'; $spe7d79d->price = 1; $spe7d79d->enabled = true; $spe7d79d->support_coupon = true; $spe7d79d->count_sold = 1; $spe7d79d->count_all = 3; $spe7d79d->instructions = '充值网址: XXXXX'; $spe7d79d->save(); $spe7d79d = new \App\Product(); $spe7d79d->id = 2; $spe7d79d->user_id = $spdad372; $spe7d79d->category_id = 1; $spe7d79d->name = '重复测试密码123456'; $spe7d79d->description = '

商品描述

所十二星座运势查询,提前预测2016年十二星座运势内容,让你能够占卜吉凶;2016年生肖运势测算,生肖开运,周易风水。'; $spe7d79d->instructions = '充值网址: XXXXX'; $spe7d79d->password = '123456'; $spe7d79d->password_open = true; $spe7d79d->support_coupon = true; $spe7d79d->price = 10; $spe7d79d->price_whole = '[["2","8"],["10","5"]]'; $spe7d79d->enabled = true; $spe7d79d->count_sold = 2; $spe7d79d->count_all = 100; $spe7d79d->count_warn = 10; $spe7d79d->save(); $spe7d79d = new \App\Product(); $spe7d79d->user_id = $spdad372; $spe7d79d->category_id = 2; $spe7d79d->name = '测试商品_2'; $spe7d79d->description = '这里是测试商品的一段简短的描述, 可以插入多媒体文本'; $spe7d79d->price = 1; $spe7d79d->enabled = true; $spe7d79d->save(); $spe7d79d = new \App\Product(); $spe7d79d->user_id = $spdad372; $spe7d79d->category_id = 3; $spe7d79d->name = '测试商品_3'; $spe7d79d->description = '这里是测试商品的一段简短的描述, 可以插入多媒体文本'; $spe7d79d->price = 1; $spe7d79d->enabled = true; $spe7d79d->save(); } } \ No newline at end of file diff --git a/database/seeds/SystemSeeder.php b/database/seeds/SystemSeeder.php index 2379f8cfd..f08b2966b 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'); $sp1d893d = array(); foreach ($sp1c4322 as $spf2a422 => $spa1e244) { $sp1d893d[] = array('name' => $spf2a422, 'value' => $spa1e244); } DB::table('systems')->insert($sp1d893d); } } \ No newline at end of file +use Illuminate\Database\Seeder; class SystemSeeder extends Seeder { public function run() { $sp399b3b = 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'); $sp796309 = array(); foreach ($sp399b3b as $sp393cef => $spc06e14) { $sp796309[] = array('name' => $sp393cef, 'value' => $spc06e14); } DB::table('systems')->insert($sp796309); } } \ No newline at end of file diff --git a/public/index.php b/public/index.php index 2976635f9..b98c472ab 100644 --- a/public/index.php +++ b/public/index.php @@ -1,2 +1,2 @@ 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 +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'; $sp64c9d2 = (require_once __DIR__ . '/../bootstrap/app.php'); $sp28af83 = $sp64c9d2->make(Illuminate\Contracts\Http\Kernel::class); $sp9d3345 = $sp28af83->handle($sp3c91bd = Illuminate\Http\Request::capture()); $sp9d3345->send(); $sp28af83->terminate($sp3c91bd, $sp9d3345); \ No newline at end of file diff --git a/routes/channels.php b/routes/channels.php index 556277969..94457ce51 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -1,2 +1,2 @@ id === (int) $sp8e8060; }); \ No newline at end of file +Broadcast::channel('App.User.{id}', function ($spb14cf0, $spbabe1d) { return (int) $spb14cf0->id === (int) $spbabe1d; }); \ No newline at end of file