diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index ea84f05..e1d5c81 100644 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -2,12 +2,16 @@ namespace app\api\controller; - +use app\common\enum\PayEnum; use app\common\enum\user\UserTerminalEnum; +use app\common\logic\PayNotifyLogic; +use app\common\model\retail\Cashierclass; use app\common\service\pay\WeChatPayService; use app\Request; use Error; use support\Log; +use Webman\Config; +use Yansongda\Pay\Pay; /** * 支付 @@ -17,7 +21,7 @@ use support\Log; class PayController extends BaseApiController { - public $notNeedLogin = ['notifyMnp','aa']; + public $notNeedLogin = ['notifyMnp', 'aa']; /** * @notes 小程序支付回调 @@ -31,10 +35,24 @@ class PayController extends BaseApiController */ public function notifyMnp() { - return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify(); + $config = Config::get('payment'); + Pay::config($config); + $message = Pay::wechat()->callback(); + if ($message['trade_state'] === 'SUCCESS') { + $extra['transaction_id'] = $message['transaction_id']; + $attach = $message['attach']; + $message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18); + switch ($attach) { + case 'cashierclass': + $order = Cashierclass::where(['number' => $message['out_trade_no']])->findOrEmpty(); + if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) { + return true; + } + PayNotifyLogic::handle('cashierclass', $message['out_trade_no'], $extra); + break; + } + return Pay::wechat()->success(); + } + // return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify(); } - - - - } diff --git a/composer.json b/composer.json index 9acbc69..33fc984 100644 --- a/composer.json +++ b/composer.json @@ -48,8 +48,7 @@ "next/var-dumper": "^0.1.0", "w7corp/easywechat": "^6.8", "hyperf/pimple": "~2.2.0", - "yansongda/pay": "^3.6", - "guzzlehttp/guzzle": "^7.8" + "yansongda/pay": "^3.6" }, "suggest": { "ext-event": "For better performance. " diff --git a/composer.lock b/composer.lock index bcb76e7..6d0c7c3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aec3bdabbcd3d781fd7d055878ca0a66", + "content-hash": "10536b047d5ed5c08b1aa7a603970cb7", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -6996,16 +6996,16 @@ }, { "name": "workerman/webman-framework", - "version": "v1.5.5", + "version": "v1.5.16", "source": { "type": "git", "url": "https://github.com/walkor/webman-framework.git", - "reference": "7c2a987e43077ce85b2ee242f64cae791fd7976f" + "reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/walkor/webman-framework/zipball/7c2a987e43077ce85b2ee242f64cae791fd7976f", - "reference": "7c2a987e43077ce85b2ee242f64cae791fd7976f", + "url": "https://api.github.com/repos/walkor/webman-framework/zipball/84335520a340ee60adf7cf17aeb0edb9536c24e8", + "reference": "84335520a340ee60adf7cf17aeb0edb9536c24e8", "shasum": "", "mirrors": [ { @@ -7060,7 +7060,7 @@ "source": "https://github.com/walkor/webman-framework", "wiki": "https://doc.workerman.net/" }, - "time": "2023-04-04T02:11:22+00:00" + "time": "2024-01-15T12:11:49+00:00" }, { "name": "workerman/workerman", diff --git a/support/bootstrap.php b/support/bootstrap.php index 8e47e63..d9471e6 100644 --- a/support/bootstrap.php +++ b/support/bootstrap.php @@ -36,11 +36,11 @@ if ($worker) { }, time()); } -if (class_exists('Dotenv\Dotenv') && file_exists(base_path() . '/.env')) { +if (class_exists('Dotenv\Dotenv') && file_exists(base_path(false) . '/.env')) { if (method_exists('Dotenv\Dotenv', 'createUnsafeMutable')) { - Dotenv::createUnsafeMutable(base_path())->load(); + Dotenv::createUnsafeMutable(base_path(false))->load(); } else { - Dotenv::createMutable(base_path())->load(); + Dotenv::createMutable(base_path(false))->load(); } } diff --git a/support/helpers.php b/support/helpers.php index f6d25b5..8de22c0 100644 --- a/support/helpers.php +++ b/support/helpers.php @@ -27,6 +27,7 @@ use Twig\Error\SyntaxError; use Webman\App; use Webman\Config; use Webman\Route; +use Workerman\Protocols\Http\Session; use Workerman\Worker; // Project base path @@ -300,7 +301,7 @@ function route(string $name, ...$parameters): string * Session * @param mixed $key * @param mixed $default - * @return mixed + * @return mixed|bool|Session */ function session($key = null, $default = null) { @@ -379,7 +380,7 @@ function copy_dir(string $source, string $dest, bool $overwrite = false) $files = scandir($source); foreach ($files as $file) { if ($file !== "." && $file !== "..") { - copy_dir("$source/$file", "$dest/$file"); + copy_dir("$source/$file", "$dest/$file", $overwrite); } } } else if (file_exists($source) && ($overwrite || !file_exists($dest))) { @@ -514,3 +515,14 @@ function cpu_count(): int } return $count > 0 ? $count : 4; } + +/** + * Get request parameters, if no parameter name is passed, an array of all values is returned, default values is supported + * @param string|null $param param's name + * @param mixed|null $default default value + * @return mixed|null + */ +function input(string $param = null, $default = null) +{ + return is_null($param) ? request()->all() : request()->input($param, $default); +} diff --git a/windows.php b/windows.php index d1975d6..21fa888 100644 --- a/windows.php +++ b/windows.php @@ -61,6 +61,7 @@ function write_process_file($runtimeProcessPath, $processName, $firm): string require_once __DIR__ . '/../../vendor/autoload.php'; use Workerman\Worker; +use Workerman\Connection\TcpConnection; use Webman\Config; use support\App; @@ -77,6 +78,7 @@ worker_start('$processParam', $configParam); if (DIRECTORY_SEPARATOR != "/") { Worker::\$logFile = config('server')['log_file'] ?? Worker::\$logFile; + TcpConnection::\$defaultMaxPackageSize = config('server')['max_package_size'] ?? 10*1024*1024; } Worker::runAll();