Browse Source

Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix

master
Lemon 5 years ago
parent
commit
9c2e6865c4
  1. 20
      app/Constants/v3/ErrorCode.php
  2. 22
      app/Controller/v3/OrderOfflineController.php
  3. 5
      app/Service/v3/Implementations/OrderOfflineService.php
  4. 13
      app/Service/v3/Implementations/PaymentService.php
  5. 1
      config/routes.php

20
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 */
/************************************/

22
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]);
}
}

5
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()]);

13
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;

1
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]]);
// 微信支付回调

Loading…
Cancel
Save