ExpeditingDelivery.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: yunzhong
  5. * Date: 2020/7/13
  6. * Time: 15:35
  7. */
  8. namespace app\frontend\modules\order\operations\member;
  9. use app\common\models\Order;
  10. use app\frontend\modules\order\operations\OrderOperation;
  11. class ExpeditingDelivery extends OrderOperation
  12. {
  13. public $expediting_delivery;
  14. public $expediting_set;
  15. public $order;
  16. public function __construct(Order $order)
  17. {
  18. parent::__construct($order);
  19. if ($this->getExpediting()) {
  20. $this->expediting_delivery = 1;
  21. } else {
  22. $this->expediting_delivery = 2;
  23. }
  24. $this->order = $order;
  25. $this->expediting_set = \Setting::get('shop.order');
  26. }
  27. public function enable()
  28. {
  29. // TODO: Implement enable() method.
  30. if ($this->expediting_set['expediting_delivery'] == 1 && in_array($this->order->plugin_id,[0,92,32])) {
  31. return true;
  32. } else {
  33. return false;
  34. }
  35. }
  36. /**
  37. * @return string
  38. */
  39. public function getName()
  40. {
  41. // TODO: Implement getName() method.
  42. if ($this->expediting_delivery == 1) {
  43. return '已催发货';
  44. }
  45. return '催发货';
  46. }
  47. /**
  48. * @return string
  49. */
  50. public function getValue()
  51. {
  52. // TODO: Implement getValue() method.
  53. return 'expediting_delivery';
  54. }
  55. /**
  56. * @return string
  57. */
  58. public function getApi()
  59. {
  60. // TODO: Implement getApi() method.
  61. if ($this->expediting_delivery == 1) {
  62. return '';
  63. }
  64. return 'order.order-expediting-delivery.index';
  65. }
  66. private function getExpediting()
  67. {
  68. $order = \app\common\models\ExpeditingDelivery::where("order_id",$this->order->id)->first();
  69. if ($order) {
  70. return true;
  71. }
  72. return false;
  73. }
  74. }