From 7f019f8504e881ada96c22d67019116594dedd95 Mon Sep 17 00:00:00 2001 From: devil Date: Wed, 23 Sep 2020 17:14:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/service/OrderService.php | 9 ++--- extend/payment/IEPayAliPay.php | 54 +++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/application/service/OrderService.php b/application/service/OrderService.php index f505ae569..df08a9d06 100755 --- a/application/service/OrderService.php +++ b/application/service/OrderService.php @@ -597,14 +597,15 @@ class OrderService } // 获取支付日志订单 - $pay_log_data = Db::name('PayLog')->where([ - 'log_no' => $pay_ret['data']['out_trade_no'], - 'status' => 0, - ])->find(); + $pay_log_data = Db::name('PayLog')->where(['log_no'=>$pay_ret['data']['out_trade_no']])->find(); if(empty($pay_log_data)) { return DataReturn('日志订单有误', -1); } + if($pay_log_data['status'] == 1) + { + return DataReturn('日志订单已支付、无需再次处理', -1); + } // 获取关联信息 $pay_log_value = Db::name('PayLogValue')->where(['pay_log_id'=>$pay_log_data['id']])->column('business_id'); diff --git a/extend/payment/IEPayAliPay.php b/extend/payment/IEPayAliPay.php index 64ad69b83..46de5073e 100644 --- a/extend/payment/IEPayAliPay.php +++ b/extend/payment/IEPayAliPay.php @@ -247,11 +247,50 @@ class IEPayAliPay $data['buyer_user'] = $data['pay_type']; // 支付平台 - 用户 $data['out_trade_no'] = $data['out_trade_no']; // 本系统发起支付的 - 订单号 $data['subject'] = isset($data['order_status']) ? '状态:'.$data['order_status'] : ''; // 本系统发起支付的 - 商品名称 - $data['pay_price'] = $data['total_fee']/100; // 本系统发起支付的 - 总价 + $data['pay_price'] = $this->RespondReversePrice($data['out_trade_no'], $data['total_fee']); // 本系统发起支付的 - 总价 return $data; } + /** + * 金额转换 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-09-23 + * @desc description + * @param [string] $out_trade_no [支付日志订单号] + * @param [float] $total_fee [平台返回的支付金额] + */ + private function RespondReversePrice($out_trade_no, $total_fee) + { + $total_fee /= 100; + + // 金额转换 + if(isset($this->config['is_reverse_price']) && $this->config['is_reverse_price'] == 1) + { + // 获取订单信息 + $log_data = \app\service\PayLogService::PayLogList(['where'=>['log_no'=>$out_trade_no]]); + if($log_data['code'] == 0 && !empty($log_data['data']) && !empty($log_data['data'][0]) && !empty($log_data['data'][0]['business_list']) && count($log_data['data'][0]['business_list']) == 1) + { + switch($log_data['data'][0]['business_type']) + { + // 订单 + case \app\service\OrderService::$business_type_name : + // 获取订单汇率 + $currency_data = \app\service\OrderCurrencyService::OrderCurrencyGroupList($log_data['data'][0]['business_list'][0]['business_id']); + if(isset($currency_data['currency_rate']) && $currency_data['currency_rate'] > 0) + { + $total_fee *= $currency_data['currency_rate']; + } + break; + } + } + } + + return PriceNumberFormat($total_fee); + } + /** * 退款处理 * @author Devil @@ -388,5 +427,18 @@ class IEPayAliPay } return strtolower(md5(substr($sign, 0, -1).$this->config['key'])); } + + /** + * 自定义成功返回内容 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-07-01 + * @desc description + */ + public function SuccessReturn() + { + return '成功'; + } } ?> \ No newline at end of file