Browse Source

下单修改数据返回格式

master
weigang 5 years ago
parent
commit
f6aea0af8c
  1. 8
      app/Constants/ErrorCode.php
  2. 8
      app/Controller/NotifyController.php
  3. 5
      app/Controller/OrderController.php
  4. 2
      app/Controller/PaymentController.php

8
app/Constants/ErrorCode.php

@ -37,4 +37,10 @@ class ErrorCode extends AbstractConstants
/**
* @Message("Upload failure!")
*/
const UPLOAD_INVALID = 200;}
const UPLOAD_INVALID = 200;
/**
* @Message("Order failure!")
*/
const ORDER_FAILURE = 300;
}

8
app/Controller/NotifyController.php

@ -6,8 +6,14 @@ use App\Constants\LogLabel;
class NotifyController extends BaseController
{
public function wxmini()
public function wxminiOnline()
{
// 获取参数
// 查询订单
// 开始处理
$this->log->event(
LogLabel::PAY_NOTIFY_WXMINI,
json_encode($this->request->input())

5
app/Controller/OrderController.php

@ -2,6 +2,7 @@
namespace App\Controller;
use App\Constants\ErrorCode;
use App\Request\OrderOnlineRequest;
use Hyperf\Di\Annotation\Inject;
use App\Service\OrderServiceInterface;
@ -20,8 +21,8 @@ class OrderController extends BaseController
{
$orderMainId = $this->orderService->addOnlineOrder($request->validated());
if (!is_int($orderMainId)) {
return $this->w7result(500, (string)$orderMainId);
return $this->result(ErrorCode::ORDER_FAILURE, '', $orderMainId);
}
return $this->w7result(200, (string)$orderMainId);
return $this->success(['order_id' => $orderMainId]);
}
}

2
app/Controller/PaymentController.php

@ -34,7 +34,7 @@ class PaymentController extends BaseController
'body' => '懒族生活 - 外卖下单',
'out_trade_no' => $orderMain->global_order_id,
'total_fee' => bcmul(floatval($orderMain->money), 100),
'notify_url' => config('site_host') . '/v1/notify/wxmini',
'notify_url' => config('site_host') . '/v1/notify/wxminiOnline',
'trade_type' => 'JSAPI',
'openid' => $data['openid'],
]);

Loading…
Cancel
Save