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.

65 lines
1.7 KiB

  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Controller\BaseController;
  4. use App\Request\v3\OrderOfflineRequest;
  5. use App\Request\v3\OrderOnlineRequest;
  6. use App\Service\v3\Interfaces\OrderOfflineServiceInterface;
  7. use App\Service\v3\Interfaces\StoreServiceInterface;
  8. use Hyperf\Validation\ValidationException;
  9. use Hyperf\Di\Annotation\Inject;
  10. class OrderOfflineController extends BaseController
  11. {
  12. /**
  13. * @Inject
  14. * @var StoreServiceInterface
  15. */
  16. protected $storeService;
  17. /**
  18. * @Inject
  19. * @var OrderOfflineServiceInterface
  20. */
  21. protected $orderOfflineService;
  22. /**
  23. * 当面付的页面详情
  24. * 1、上传store_id,获取商户相关信息
  25. * 2、返回商户相关信息即可
  26. */
  27. public function review()
  28. {
  29. $validator = $this->validationFactory->make(
  30. $this->request->all(),
  31. ['store_id' => 'required|nonempty'],
  32. ['*.*' => '商户ID参数异常']
  33. );
  34. if ($validator->fails()) {
  35. throw new ValidationException($validator);
  36. }
  37. $params = $validator->validated();
  38. $store = $this->storeService->detail($params['store_id']);
  39. return $this->success(['store' => $store]);
  40. }
  41. /**
  42. * 当面付下单支付
  43. * 1、用户id、去商户id下支付、支付的金额
  44. * 2、下单同时支付,下发支付参数
  45. * @param OrderOfflineRequest $request
  46. */
  47. public function add(OrderOfflineRequest $request)
  48. {
  49. $params = $request->validated();
  50. $data = $this->orderOfflineService->do(
  51. $params['store_id'],
  52. $params['user_id'],
  53. $params['money'],
  54. $params['plat']
  55. );
  56. return $this->success(['data' => $data]);
  57. }
  58. }