StatusFactory.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/3/2
  6. * Time: 下午4:52
  7. */
  8. namespace app\frontend\modules\order\services\status;
  9. use app\common\models\Order;
  10. use Yunshop\StoreCashier\common\models\Store;
  11. class StatusFactory
  12. {
  13. /**
  14. * @var Order
  15. */
  16. private $order;
  17. function __construct($order)
  18. {
  19. $this->order = $order;
  20. }
  21. /**
  22. * @return Close|Complete|WaitPay|WaitReceive|WaitSend|\Yunshop\StoreCashier\common\order\status\MemberWaitReceive|\Yunshop\StoreCashier\common\order\status\StoreWaitPay|\Yunshop\StoreCashier\common\order\status\VerifierWaitPay|\Yunshop\StoreCashier\common\order\status\VerifierWaitReceive
  23. * @throws \app\common\exceptions\AppException
  24. */
  25. public function create()
  26. {
  27. $order = $this->order;
  28. switch ($order->status) {
  29. case -1:
  30. return new Close($this->order);
  31. break;
  32. case 0:
  33. return $this->waitPay();
  34. break;
  35. case 1:
  36. return $this->waitSend();
  37. break;
  38. case 2:
  39. return $this->waitReceive();
  40. break;
  41. case 3:
  42. return new Complete($this->order);
  43. break;
  44. }
  45. }
  46. /**
  47. * @return WaitPay|\Yunshop\StoreCashier\common\order\status\StoreWaitPay|\Yunshop\StoreCashier\common\order\status\VerifierWaitPay
  48. * @throws \app\common\exceptions\AppException
  49. */
  50. private function waitPay()
  51. {
  52. if (app('plugins')->isEnabled('store-cashier') && $this->order->plugin_id == Store::PLUGIN_ID) {
  53. //门店订单
  54. return (new \Yunshop\StoreCashier\common\order\status\WaitPay())->handle($this->order);
  55. } else {
  56. // 正常订单
  57. return new WaitPay($this->order);
  58. }
  59. }
  60. /**
  61. * @return WaitSend
  62. */
  63. private function waitSend()
  64. {
  65. // 正常订单
  66. return new WaitSend($this->order);
  67. }
  68. /**
  69. * @return WaitReceive|\Yunshop\StoreCashier\common\order\status\MemberWaitReceive|\Yunshop\StoreCashier\common\order\status\VerifierWaitReceive
  70. */
  71. private function waitReceive()
  72. {
  73. if (app('plugins')->isEnabled('store-cashier') && $this->order->plugin_id == Store::PLUGIN_ID) {
  74. //门店订单
  75. return (new \Yunshop\StoreCashier\common\order\status\WaitReceive())->handle($this->order);
  76. } else {
  77. // 正常订单
  78. return new WaitReceive($this->order);
  79. }
  80. }
  81. }