123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\api\model\order;
- use app\api\model\order\RiceCardPay;
- use app\api\model\order\IOrder;
- use app\common\enum\OrderType AS OrderTypeEnum;
- use app\api\model\order\GroupBuyPay;
- use app\api\model\order\GroupBuyLbPay;
- USE app\api\model\order\ZaPay;
- class Context {
- private $order;
- private $args;
- public function __construct($order_type,$args){
- //米卡
- if($order_type==OrderTypeEnum::RCORDER){
- $this->order = new RiceCardPay();
- $this->args = $args;
- }
- //拼团
- if($order_type==OrderTypeEnum::GROUPBUY){
- $this->order = new GroupBuyPay;
- $this->args = $args;
- }
- //拼团裂变
- if($order_type==OrderTypeEnum::GROUPBUYLB){
- $this->order = new GroupBuyLbPay;
- $this->args = $args;
- }
- //会员卡
- if($order_type==OrderTypeEnum::MEMBERCARDBUY){
- $this->order = new MemberCardPay();
- $this->args = $args;
- }
- if($order_type==OrderTypeEnum::ZA){
- $this->order = new ZaPay;
- $this->args = $args;
- }
- }
- //准备支付
- public function prePay(){
- if(isset($this->order)){
- return $this->order->prePay($this->args);
- }
- }
- //重新支付
- public function rePay(){
- if(isset($this->order)){
- return $this->order->rePay($this->args);
- }
- }
- //异步回调
- public function notifyPay(){
- return $this->order->notifyPay($this->args);
- }
- public function getInstance(){
- return $this->order;
- }
- }
|