Status.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/4/17
  6. * Time: 下午11:34
  7. */
  8. namespace app\frontend\modules\order\services\status;
  9. use app\common\models\Order;
  10. abstract class Status
  11. {
  12. const PAY = 1; // 支付
  13. const COMPLETE = 5; // 确认收货
  14. const EXPRESS = 8; // 查看物流
  15. const CANCEL = 9; // 取消订单
  16. const COMMENT = 10; // 评论
  17. const DELETE = 12; // 删除订单
  18. const REFUND = 13; // 申请退款
  19. const REFUND_INFO = 18; // 已退款/退款中
  20. const COMMENTED = 19; // 已评价
  21. const STORE_PAY = 20; // 确认核销(核销员)
  22. const REMITTANCE_RECORD = 21; // 转账信息
  23. const STORE_MANAGER_PAY = 22;// 店长确认支付
  24. const STORE_MANAGER_SEND = 23;// 店长确认发货
  25. const STORE_MANAGER_CANCEL_SEND = 24;// 店长取消发货
  26. const STORE_MANAGER_COMPLETE = 25;// 店长确认收货
  27. const STORE_MANAGER_CLOSE = 26;// 店长关闭订单
  28. abstract function getStatusName();
  29. /**
  30. * 退款按钮
  31. * @param $order
  32. * @return array
  33. */
  34. public static function getRefundButtons(Order $order)
  35. {
  36. if ($order['status'] >= Order::COMPLETE) {
  37. // 完成后不许退款
  38. if (\Setting::get('shop.trade.refund_days') === '0') {
  39. return [];
  40. }
  41. // 完成后n天不许退款
  42. if ($order->finish_time->diffInDays() > \Setting::get('shop.trade.refund_days')) {
  43. return [];
  44. }
  45. }
  46. if($order['status'] <= Order::WAIT_PAY){
  47. return [];
  48. }
  49. if (!empty($order->refund_id) && isset($order->hasOneRefundApply)) {
  50. // 退款处理中
  51. if ($order->hasOneRefundApply->isRefunded()) {
  52. $result[] = [
  53. 'name' => '已退款',
  54. 'api' => 'refund.detail',
  55. 'value' => static::REFUND_INFO
  56. ];
  57. } else {
  58. $result[] = [
  59. 'name' => '退款中',
  60. 'api' => 'refund.detail',
  61. 'value' => static::REFUND_INFO
  62. ];
  63. }
  64. } else {
  65. // 可申请
  66. $result[] = [
  67. 'name' => '申请退款',
  68. 'api' => 'refund.apply',
  69. 'value' => static::REFUND
  70. ];
  71. }
  72. return $result;
  73. }
  74. /**
  75. * 评论按钮
  76. * @param $orderGoods
  77. * @return array
  78. */
  79. public static function getCommentButtons($orderGoods)
  80. {
  81. if ($orderGoods->comment_status == 0) {
  82. $result[] = [
  83. 'name' => '评价',
  84. 'api' => '',
  85. 'value' => static::COMMENT
  86. ];
  87. } else {
  88. $result[] = [
  89. 'name' => '已评价',
  90. 'api' => '',
  91. 'value' => static::COMMENTED
  92. ];
  93. }
  94. return $result;
  95. }
  96. }