You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.6 KiB
90 lines
2.6 KiB
<?php
|
|
|
|
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;
|
|
use App\Service\v3\Interfaces\StoreServiceInterface;
|
|
use Hyperf\Validation\ValidationException;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
class OrderOfflineController extends BaseController
|
|
{
|
|
/**
|
|
* @Inject
|
|
* @var StoreServiceInterface
|
|
*/
|
|
protected $storeService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var OrderOfflineServiceInterface
|
|
*/
|
|
protected $orderOfflineService;
|
|
|
|
/**
|
|
* 当面付的页面详情
|
|
* 1、上传store_id,获取商户相关信息
|
|
* 2、返回商户相关信息即可
|
|
*/
|
|
public function review()
|
|
{
|
|
$validator = $this->validationFactory->make(
|
|
$this->request->all(),
|
|
['store_id' => 'required|nonempty'],
|
|
['*.*' => '商户ID参数异常']
|
|
);
|
|
|
|
if ($validator->fails()) {
|
|
throw new ValidationException($validator);
|
|
}
|
|
|
|
$params = $validator->validated();
|
|
$store = $this->storeService->detail($params['store_id']);
|
|
return $this->success(['store' => $store, 'digit_length' => 7]);
|
|
}
|
|
|
|
/**
|
|
* 当面付下单支付
|
|
* 1、用户id、去商户id下支付、支付的金额
|
|
* 2、下单同时支付,下发支付参数
|
|
* @param OrderOfflineRequest $request
|
|
* @return ResponseInterface
|
|
*/
|
|
public function add(OrderOfflineRequest $request)
|
|
{
|
|
$params = $request->validated();
|
|
$data = $this->orderOfflineService->do(
|
|
$params['store_id'],
|
|
$params['user_id'],
|
|
$params['money'],
|
|
$params['plat']
|
|
);
|
|
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, '', ['message' => '当面付订单完成页', 'data' => ['global_order_id' => $globalOrderId,'user_id' => $userId]]);
|
|
}
|
|
|
|
return $this->success(['order_main' => $orderMain]);
|
|
}
|
|
}
|