Order.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\api\controller;
  13. use think\App;
  14. use think\response\Json;
  15. use app\api\model\Order as OrderModel;
  16. use app\api\model\Setting as SettingModel;
  17. use app\api\service\User as UserService;
  18. use app\api\service\Order as OrderService;
  19. use cores\exception\BaseException;
  20. /**
  21. * 我的订单控制器
  22. * Class Order
  23. * @package app\api\controller
  24. */
  25. class Order extends Controller
  26. {
  27. /**
  28. * 我的订单列表
  29. * @param string $dataType 订单类型
  30. * @return Json
  31. * @throws BaseException
  32. * @throws \think\db\exception\DbException
  33. */
  34. public function list(string $dataType): Json
  35. {
  36. $model = new OrderModel;
  37. $list = $model->getList($dataType);
  38. return $this->renderSuccess(compact('list'));
  39. }
  40. /**
  41. * 订单详情信息
  42. * @param int $orderId 订单ID
  43. * @return Json
  44. * @throws BaseException
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\DbException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. */
  49. public function detail(int $orderId): Json
  50. {
  51. // 订单详情
  52. $model = OrderModel::getUserOrderDetail($orderId);
  53. return $this->renderSuccess([
  54. 'order' => $model, // 订单详情
  55. 'setting' => [
  56. // 积分名称
  57. 'points_name' => SettingModel::getPointsName(),
  58. ],
  59. ]);
  60. }
  61. /**
  62. * 获取物流跟踪信息
  63. * @param int $orderId 订单ID
  64. * @return Json
  65. * @throws BaseException
  66. * @throws \think\db\exception\DataNotFoundException
  67. * @throws \think\db\exception\DbException
  68. * @throws \think\db\exception\ModelNotFoundException
  69. */
  70. public function express(int $orderId): Json
  71. {
  72. $service = new OrderService;
  73. $express = $service->express($orderId);
  74. return $this->renderSuccess(compact('express'));
  75. }
  76. /**
  77. * 取消订单
  78. * @param int $orderId
  79. * @return Json
  80. * @throws BaseException
  81. */
  82. public function cancel(int $orderId): Json
  83. {
  84. $model = OrderModel::getDetail($orderId);
  85. if ($model->cancel()) {
  86. return $this->renderSuccess($model->getMessage());
  87. }
  88. return $this->renderError($model->getError() ?: '订单取消失败');
  89. }
  90. /**
  91. * 确认收货
  92. * @param int $orderId
  93. * @return Json
  94. * @throws BaseException
  95. */
  96. public function receipt(int $orderId): Json
  97. {
  98. $model = OrderModel::getDetail($orderId);
  99. if ($model->receipt()) {
  100. return $this->renderSuccess('确认收货成功');
  101. }
  102. return $this->renderError($model->getError());
  103. }
  104. /**
  105. * 获取当前用户待处理的订单数量
  106. * @return Json
  107. * @throws BaseException
  108. */
  109. public function todoCounts(): Json
  110. {
  111. $model = new OrderModel;
  112. $counts = $model->getTodoCounts();
  113. return $this->renderSuccess(compact('counts'));
  114. }
  115. public function createOrderPaypal()
  116. {
  117. $url = 'http://www.baidu.com';
  118. $a = curl_request($url,'get');
  119. dd($a);
  120. }
  121. }