'wechat', 2=>'alipay', ]; public static function setType(MobileOrder $mobileOrder){ $a=new self; $a->mobileOrder=$mobileOrder; $a->type=$mobileOrder['pay_type']; } public function refund(){ if(!isset($this->types[$this->type])){ throw_user('此付款方式不支持退款'); } $this->{$this->types[$this->type]}(); } public function getAmount(){ return $this->mobileOrder['amount_refund']*100; } public function wechat(){ $res=Service::getApp('wechat',Service::refundUrl('wechat',$this->mobileOrder['pay_no']))->refund([ 'transaction_id'=>$this->mobileOrder['pay_no'], 'out_refund_no'=>$this->mobileOrder['refund_no'], 'total_fee'=>$this->mobileOrder['amount'], 'refund_fee'=>$this->getAmount(), 'op_user_id'=>Service::getWechatOpUser(), ]); if($res['return_code']!=='SUCCESS'){ throw_user($res['return_msg']); } if($res['result_code']!='SUCCESS'){ throw_user($res['err_code_des']); } } }