|
@@ -24,8 +24,8 @@ class Refund{
|
|
|
}
|
|
|
$this->{$this->types[$this->type]}();
|
|
|
}
|
|
|
- public function getAmount(){
|
|
|
- return $this->mobileOrder['amount_refund']*100;
|
|
|
+ public function getAmount($unit='f'){
|
|
|
+ return $unit=='y'?$this->mobileOrder['amount_refund']:$this->mobileOrder['amount_refund']*100;
|
|
|
}
|
|
|
public function wechat(){
|
|
|
$res=Service::getApp('wechat',Service::refundUrl('wechat',$this->mobileOrder['pay_no']))->refund([
|
|
@@ -43,18 +43,20 @@ class Refund{
|
|
|
}
|
|
|
}
|
|
|
public function alipay(){
|
|
|
- $res=Service::getApp('wechat',Service::refundUrl('alipay',$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(),
|
|
|
+ $res=Service::getApp('alipay',Service::refundUrl('alipay',$this->mobileOrder['pay_no']))->refund([
|
|
|
+ 'trade_no'=>$this->mobileOrder['pay_no'],
|
|
|
+ 'refund_amount'=>$this->getAmount('y'),
|
|
|
+ 'refund_reason'=>$this->reason(),
|
|
|
+ 'out_request_no'=>$this->mobileOrder['refund_no'],
|
|
|
]);
|
|
|
- if($res['return_code']!=='SUCCESS'){
|
|
|
- throw_user($res['return_msg']);
|
|
|
+ if($res['code']!=10000){
|
|
|
+ throw_user($res['msg']);
|
|
|
}
|
|
|
- if($res['result_code']!='SUCCESS'){
|
|
|
- throw_user($res['err_code_des']);
|
|
|
+ if($res['sub_code']!='TRADE_HAS_SUCCESS'){
|
|
|
+ throw_user($res['sub_msg']);
|
|
|
}
|
|
|
}
|
|
|
+ public function reason(){
|
|
|
+ return sprintf("订单[%s]退款",$this->mobileOrder['order_no']);
|
|
|
+ }
|
|
|
}
|