diff --git a/app/Constants/v3/ErrorCode.php b/app/Constants/v3/ErrorCode.php index 6af0f88..362d532 100644 --- a/app/Constants/v3/ErrorCode.php +++ b/app/Constants/v3/ErrorCode.php @@ -98,6 +98,26 @@ class ErrorCode extends AbstractConstants */ const PAYMENT_FAIL = 651; + /** + * @Message("今日次数已达上限") + */ + const PAYMENT_SEND_NUM_LIMIT = 652; + + /** + * @Message("微信未实名认证") + */ + const PAYMENT_V2_ACCOUNT_SIMPLE_BAN = 653; + + /** + * @Message("姓名校验出错") + */ + const PAYMENT_NAME_MISMATCH = 654; + + /** + * @Message("金额超限了") + */ + const PAYMENT_AMOUNT_LIMIT = 655; + /************************************/ /* 用户相关 701-750 */ /************************************/ diff --git a/app/Controller/v3/OrderOfflineController.php b/app/Controller/v3/OrderOfflineController.php index 5951e52..c53fb05 100644 --- a/app/Controller/v3/OrderOfflineController.php +++ b/app/Controller/v3/OrderOfflineController.php @@ -2,7 +2,10 @@ namespace App\Controller\v3; +use App\Constants\v3\ErrorCode; use App\Controller\BaseController; +use App\Exception\ErrorCodeException; +use App\Model\v3\OrderMain; use App\Request\v3\OrderOfflineRequest; use App\Request\v3\OrderOnlineRequest; use App\Service\v3\Interfaces\OrderOfflineServiceInterface; @@ -65,4 +68,23 @@ class OrderOfflineController extends BaseController ); return $this->success(['data' => $data]); } + + /** + * 当面付完成页 + */ + public function completePage() + { + $globalOrderId = $this->request->input('global_order_id', 0); + $userId = $this->request->input('user_id', 0); + $orderMain = OrderMain::query() + ->with('orders.store') + ->where(['global_order_id' => $globalOrderId, 'user_id' => $userId]) + ->first(); + + if (empty($orderMain)) { + throw new ErrorCodeException(ErrorCode::ORDER_NOT_AVAILABLE); + } + + return $this->success(['order_main' => $orderMain]); + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/OrderOfflineService.php b/app/Service/v3/Implementations/OrderOfflineService.php index 2b8f35d..9e41a25 100644 --- a/app/Service/v3/Implementations/OrderOfflineService.php +++ b/app/Service/v3/Implementations/OrderOfflineService.php @@ -92,7 +92,10 @@ class OrderOfflineService implements OrderOfflineServiceInterface Db::commit(); // 支付 - return $this->paymentService->do($globalOrderId, $money, $userId, config('wechat.notify_url.offline')); + $parameters = $this->paymentService->do($globalOrderId, $money, $userId, config('wechat.notify_url.offline')); + $parameters['$globalOrderId'] = $globalOrderId; + + return $parameters; } catch (\Exception $e) { Db::rollBack(); $this->log->event(LogLabel::ORDER_OFFLINE_LOG, ['exception_msg' => $e->getMessage()]); diff --git a/app/Service/v3/Implementations/PaymentService.php b/app/Service/v3/Implementations/PaymentService.php index d3fa31d..a2cff77 100644 --- a/app/Service/v3/Implementations/PaymentService.php +++ b/app/Service/v3/Implementations/PaymentService.php @@ -207,7 +207,18 @@ class PaymentService implements PaymentServiceInterface if (in_array($result['error_code'], $arr)) { $msg = $result['error_code_des']; } - throw new ErrorCodeException(ErrorCode::PAYMENT_FAIL, $msg); + + if ($result['error_code'] == 'SENDNUM_LIMIT') { + throw new ErrorCodeException(ErrorCode::PAYMENT_SEND_NUM_LIMIT); + } elseif ($result['error_code'] == 'V2_ACCOUNT_SIMPLE_BAN') { + throw new ErrorCodeException(ErrorCode::PAYMENT_V2_ACCOUNT_SIMPLE_BAN); + } elseif ($result['error_code'] == 'NAME_MISMATCH') { + throw new ErrorCodeException(ErrorCode::PAYMENT_NAME_MISMATCH); + } elseif ($result['error_code'] == 'AMOUNT_LIMIT') { + throw new ErrorCodeException(ErrorCode::PAYMENT_AMOUNT_LIMIT); + } + + throw new ErrorCodeException(ErrorCode::PAYMENT_FAIL); } return true; diff --git a/config/routes.php b/config/routes.php index 199a63a..f37e0b7 100644 --- a/config/routes.php +++ b/config/routes.php @@ -150,6 +150,7 @@ Router::addGroup('/v3/', function () { Router::post('device/bind', 'App\Controller\v3\DeviceController@bind'); Router::post('device/list', 'App\Controller\v3\DeviceController@list'); Router::post('device/unbind', 'App\Controller\v3\DeviceController@unbind'); + Router::post('orderOffline/completePage', 'App\Controller\v3\OrderOfflineController@completePage'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); // 微信支付回调