Event.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 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\store\controller\order;
  13. use app\store\controller\Controller;
  14. use app\store\model\Order as OrderModel;
  15. use app\store\service\order\DeliveryByF1;
  16. /**
  17. * 订单操作控制器
  18. * Class Operate
  19. * @package app\store\controller\order
  20. */
  21. class Event extends Controller
  22. {
  23. /**
  24. * 确认发货
  25. * @param int $orderId
  26. * @return array
  27. * @throws \Exception
  28. */
  29. public function delivery(int $orderId)
  30. {
  31. // 订单详情
  32. $model = OrderModel::detail($orderId);
  33. if ($model->delivery($this->postForm())) {
  34. return $this->renderSuccess('发货成功');
  35. }
  36. return $this->renderError($model->getError() ?: '发货失败');
  37. }
  38. /**
  39. * 壹号专线发货
  40. * @param int $orderId
  41. * @return \think\response\Json
  42. * @throws \Exception
  43. */
  44. public function deliveryByF1(int $orderId)
  45. {
  46. $f1Service = new DeliveryByF1();
  47. $res = $f1Service->orderCreateYundan($orderId);
  48. return $this->renderError($res['message'] ?: '发货失败');
  49. }
  50. /**
  51. * 修改订单价格
  52. * @param int $orderId
  53. * @return array
  54. */
  55. public function updatePrice(int $orderId)
  56. {
  57. // 订单详情
  58. $model = OrderModel::detail($orderId);
  59. if ($model->updatePrice($this->postForm())) {
  60. return $this->renderSuccess('操作成功');
  61. }
  62. return $this->renderError($model->getError() ?: '操作失败');
  63. }
  64. /**
  65. * 审核:用户取消订单
  66. * @param $orderId
  67. * @return array|bool
  68. */
  69. public function confirmCancel($orderId)
  70. {
  71. // 订单详情
  72. $model = OrderModel::detail($orderId);
  73. if ($model->confirmCancel($this->postForm())) {
  74. return $this->renderSuccess('操作成功');
  75. }
  76. return $this->renderError($model->getError() ?: '操作失败');
  77. }
  78. /**
  79. * 删除订单记录
  80. * @param int $orderId
  81. * @return array|\think\response\Json
  82. */
  83. public function delete(int $orderId)
  84. {
  85. // 订单详情
  86. $model = OrderModel::detail($orderId);
  87. // 确认核销
  88. if ($model->setDelete()) {
  89. return $this->renderSuccess('删除成功');
  90. }
  91. return $this->renderError($model->getError() ?: '操作失败');
  92. }
  93. }