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.

138 lines
4.8 KiB

  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Constants\v3\ErrorCode;
  4. use App\Controller\BaseController;
  5. use App\Exception\ErrorCodeException;
  6. use App\Request\v3\OrderOnlineDetailRequest;
  7. use App\Service\CouponServiceInterface;
  8. use Hyperf\Di\Annotation\Inject;
  9. use App\Service\v3\Interfaces\OrderOnlineServiceInterface;
  10. use App\Service\v3\Interfaces\UserBindTelServiceInterface;
  11. use App\Service\v3\Interfaces\AppointmentTimeServiceInterface;
  12. use Psr\Http\Message\ResponseInterface;
  13. class OrderOnlineController extends BaseController
  14. {
  15. /**
  16. * @Inject
  17. * @var UserBindTelServiceInterface
  18. */
  19. protected $userBindTelService;
  20. /**
  21. * @Inject
  22. * @var CouponServiceInterface
  23. */
  24. protected $couponService;
  25. /**
  26. * @Inject
  27. * @var AppointmentTimeServiceInterface
  28. */
  29. protected $appointmentTimeService;
  30. /**
  31. * @Inject
  32. * @var OrderOnlineServiceInterface
  33. */
  34. protected $orderOnlineService;
  35. /*
  36. * 如果没有绑手机号去绑定页面
  37. * 收货地址接口
  38. * 返回预约送达时间
  39. * 商品数据接口
  40. * 红包独立接口
  41. * 配送费独立接口 可根据距离动态计算费用
  42. * 增值服务接口
  43. * */
  44. public function review()
  45. {
  46. $params = $this->request->all();
  47. //判断用户有没有绑定手机
  48. // $telExists = $this->userBindTelService->check($params['user_id']);
  49. // if(!$telExists){
  50. // throw new ErrorCodeException(ErrorCode::NOT_BIND_TEL_ERROR);
  51. // }
  52. //获取用户收货地址
  53. $res['address'] = [
  54. 'address' => '南宁市良庆区五象海尔·青啤联合广场',
  55. 'area' => 'A栋八单元' ,
  56. 'lat' => '22.759950637817383',
  57. 'lng' => '108.3835678100586',
  58. 'sex' => '1',
  59. 'tel' => '15677717734',
  60. 'user_name' => '李小龙',
  61. 'user_id' => '214'
  62. ];
  63. //返回预约送达时间 数组
  64. $res['appointment_time'] = $this->appointmentTimeService->do();
  65. //
  66. $res['store_list'] = [
  67. [
  68. 'store_nmae' => '五金杂货铺',
  69. 'price' => '100.00',
  70. 'note' => '多放辣椒',
  71. 'store_id' => 66,
  72. 'goods_list' =>
  73. [
  74. [
  75. 'id' => 3971,
  76. 'goods_id' => 1301,
  77. 'name' => '半边手撕鸡',
  78. 'num' => 4,
  79. 'price' => '90.00',
  80. 'total' => '360.00'
  81. ]
  82. ]
  83. ],
  84. [
  85. 'store_nmae' => '回味手撕鸡J009',
  86. 'note' => '手撕鸡加辣',
  87. 'store_price' => '720.00',
  88. 'store_id' => 123,
  89. 'goods_list' =>
  90. [
  91. [
  92. 'id' => 3971,
  93. 'goods_id' => 1301,
  94. 'name' => '半边手撕鸡',
  95. 'num' => 4,
  96. 'price' => '90.00',
  97. 'total' => '360.00'
  98. ],
  99. [
  100. 'id' => 3971,
  101. 'goods_id' => 1301,
  102. 'name' => '半边手撕鸡',
  103. 'num' => 4,
  104. 'price' => '90.00',
  105. 'total' => '360.00'
  106. ]
  107. ]
  108. ],
  109. ];
  110. //获取用户优惠券
  111. $res['coupon'] = $this->couponService->getUserAvailableCoupons('',$params['user_id'],'',2,'','');
  112. //获取配送费
  113. $res['distribution'] = '5.0';
  114. //增值服务接口
  115. $res['value_added_service'] = [
  116. 'select' => 1,
  117. 'price' => 3.50
  118. ];
  119. return $this->success($res);
  120. }
  121. /**
  122. * 订单详情
  123. * 1、主订单信息,用户配送信息(地址、姓名、电话、配送时间、配送类型)、基础信息(订单ID、订单编号、下单时间、订单金额、付款时间、支付方式、红包优惠、服务站电话、增值服务费)
  124. * 2、子订单以及订单商品,按商户分组,有商户信息(ID、商户名、商户logo),商品信息(id、名字、封面、规格、tag、原价、售价、库存、总销、月销、是否失效、失效原因)
  125. * @param OrderOnlineDetailRequest $request
  126. * @return ResponseInterface
  127. */
  128. public function detailByUser(OrderOnlineDetailRequest $request)
  129. {
  130. $params = $request->validated();
  131. return $this->success(['detail' => $this->orderOnlineService->detailByUser($params['order_id'], $params['user_id'])]);
  132. }
  133. }