Context.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\api\model\order;
  3. use app\api\model\order\RiceCardPay;
  4. use app\api\model\order\IOrder;
  5. use app\common\enum\OrderType AS OrderTypeEnum;
  6. use app\api\model\order\GroupBuyPay;
  7. use app\api\model\order\GroupBuyLbPay;
  8. USE app\api\model\order\ZaPay;
  9. class Context {
  10. private $order;
  11. private $args;
  12. public function __construct($order_type,$args){
  13. //米卡
  14. if($order_type==OrderTypeEnum::RCORDER){
  15. $this->order = new RiceCardPay();
  16. $this->args = $args;
  17. }
  18. //拼团
  19. if($order_type==OrderTypeEnum::GROUPBUY){
  20. $this->order = new GroupBuyPay;
  21. $this->args = $args;
  22. }
  23. //拼团裂变
  24. if($order_type==OrderTypeEnum::GROUPBUYLB){
  25. $this->order = new GroupBuyLbPay;
  26. $this->args = $args;
  27. }
  28. //会员卡
  29. if($order_type==OrderTypeEnum::MEMBERCARDBUY){
  30. $this->order = new MemberCardPay();
  31. $this->args = $args;
  32. }
  33. if($order_type==OrderTypeEnum::ZA){
  34. $this->order = new ZaPay;
  35. $this->args = $args;
  36. }
  37. }
  38. //准备支付
  39. public function prePay(){
  40. if(isset($this->order)){
  41. return $this->order->prePay($this->args);
  42. }
  43. }
  44. //重新支付
  45. public function rePay(){
  46. if(isset($this->order)){
  47. return $this->order->rePay($this->args);
  48. }
  49. }
  50. //异步回调
  51. public function notifyPay(){
  52. return $this->order->notifyPay($this->args);
  53. }
  54. public function getInstance(){
  55. return $this->order;
  56. }
  57. }