| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808 |
- <?php
- namespace app\common\modules\refund\services;
- use app\backend\modules\refund\models\RefundApply;
- use app\backend\modules\refund\services\RefundOperationService;
- use app\common\events\order\BeforeOrderApplyRefundedEvent;
- use app\common\events\order\BeforeOrderRefundedPendingEvent;
- use app\common\exceptions\AdminException;
- use app\common\facades\Setting;
- use app\common\models\finance\Balance;
- use app\common\models\Order;
- use app\common\models\PayType;
- use app\common\services\credit\ConstService;
- use app\common\services\finance\BalanceChange;
- use app\common\services\PayFactory;
- /**
- * Created by PhpStorm.
- * Author: 芸众商城 www.yunzshop.com
- * Date: 2017/5/10
- * Time: 下午4:29
- */
- class RefundService
- {
- protected $refundApply;
- public function fastRefund($order_id)
- {
- $order = Order::find($order_id);
- return RefundOperationService::orderCloseAndRefund($order);
- }
- public function pay($refund_id)
- {
- $this->refundApply = RefundApply::find($refund_id);
- if (!isset($this->refundApply)) {
- throw new AdminException('未找到退款记录');
- }
- if (bccomp($this->refundApply->price, 0, 2) !== 1) {
- throw new AdminException('退款金额为0,请使用:手动退款');
- }
- if ($this->refundApply->status < RefundApply::WAIT_CHECK) {
- throw new AdminException($this->refundApply->status_name . '的退款申请,无法执同意退款操作');
- }
- if (in_array($this->refundApply->status,[RefundApply::COMPLETE,RefundApply::CONSENSUS])) {
- throw new AdminException('已退款,无法执同意退款操作');
- }
- event(new BeforeOrderApplyRefundedEvent($this->refundApply->order));
- //订单锁定时不能退款
- if ($this->refundApply->order->isPending()) {
- event(new BeforeOrderRefundedPendingEvent($this->refundApply->order));
- if ($this->refundApply->order->isPending()){
- throw new AdminException("订单已锁定,无法继续操作");
- }
- }
- //必须保证请求支付退款接口成功才能改变售后状态
- //如果先改变退款状态会触发退款成功监听,实际请求支付退款接口失败了
- switch ($this->refundApply->order->pay_type_id) {
- case PayType::WECHAT_PAY:
- case PayType::WECHAT_MIN_PAY:
- case PayType::WECHAT_H5:
- case PayType::WECHAT_NATIVE:
- case PayType::WECHAT_JSAPI_PAY:
- case PayType::WECHAT_SCAN_PAY:
- $result = $this->wechat();
- break;
- case PayType::ALIPAY:
- case PayType::ALIPAY_JSAPI_PAY:
- $result = $this->alipay2();
- break;
- case PayType::CREDIT:
- $result = $this->balance();
- break;
- case PayType::BACKEND:
- $result = $this->backend();
- break;
- case PayType::WechatApp:
- $result = $this->wechat();
- break;
- case PayType::AlipayApp:
- $result = $this->alipayapp();
- break;
- case PayType::PAY_YUN_WECHAT:
- $result = $this->yunWechat();
- break;
- case PayType::HXQUICK:
- $result = $this->hxquick();
- break;
- case PayType::HXWECHAT:
- $result = $this->hxwechat();
- break;
- case PayType::STORE_PAY:
- $result = $this->backend();
- break;
- case PayType::YOP:
- $result = $this->yopWechat();
- break;
- case PayType::WECHAT_HJ_PAY:
- $result = $this->ConvergeWechat();
- break;
- case PayType::ALIPAY_HJ_PAY:
- $result = $this->ConvergeWechat();
- break;
- case PayType::PAY_TEAM_DEPOSIT:
- $result = $this->deposit();
- break;
- case PayType::LCG_BALANCE:
- case PayType::LCG_BANK_CARD:
- $result = $this->lcg();
- break;
- case PayType::YOP_PRO_WECHAT:
- case PayType::YOP_PRO_ALIPAY:
- $result = $this->yopPro();
- break;
- case PayType::HK_SCAN_PAY:
- $result = $this->hkPay();
- break;
- case PayType::PAY_PAL:
- $result = $this->payPal();
- break;
- case PayType::CONVERGE_QUICK_PAY:
- $result = $this->convergeQuickPay();
- break;
- case PayType::HK_SCAN_ALIPAY:
- $result = $this->hkAliPay();
- break;
- case PayType::CONFIRM_PAY:
- $result = $this->confirmPay();
- break;
- case PayType::STORE_AGGREGATE_WECHAT:
- $result = $this->storeAggregatePay();
- break;
- case PayType::STORE_AGGREGATE_ALIPAY:
- $result = $this->storeAggregatePay();
- break;
- case PayType::STORE_AGGREGATE_SCAN:
- $result = $this->storeAggregatePay();
- break;
- case PayType::WECHAT_CPS_APP_PAY:
- $result = $this->wechat();
- break;
- case PayType::XFPAY_WECHAT:
- case PayType::XFPAY_ALIPAY:
- $result = $this->xfpayPay();
- break;
- case PayType::SANDPAY_ALIPAY:
- case PayType::SANDPAY_WECHAT:
- $result = $this->sandpayPay();
- break;
- case PayType::LAKALA_ALIPAY:
- case PayType::LAKALA_WECHAT:
- $result = $this->lakalaPay();
- break;
- case PayType::LESHUA_ALIPAY:
- case PayType::LESHUA_WECHAT:
- case PayType::LESHUA_POS:
- $result = $this->leshuaPay();
- break;
- case PayType::LSP_PAY:
- $result = $this->lspPay();
- break;
- case PayType::WECHAT_TRADE_PAY:
- $result = $this->wechatTradePay();
- break;
- case PayType::CONVERGE_UNION_PAY:
- $result = $this->convergePayRefund();
- break;
- case PayType::SILVER_POINT_ALIPAY:
- case PayType::SILVER_POINT_WECHAT:
- case PayType::SILVER_POINT_UNION:
- $result = $this->silverPointRefund();
- break;
- case PayType::CODE_SCIENCE_PAY_YU:
- $result = $this->codeScienceRefund();
- break;
- case PayType::EPLUS_WECHAT_PAY:
- case PayType::EPLUS_MINI_PAY:
- case PayType::EPLUS_ALI_PAY:
- $result = $this->eplusPay();
- break;
- case PayType::LSP_WALLET_PAY:
- $result = $this->lspWalletPay();
- break;
- case PayType::JINEPAY:
- $result = $this->jinepayRefund();
- break;
- case PayType::AUTH_PAY:
- $result = $this->authPayRefund();
- break;
- default:
- $result = $this->unknownPay();
- }
- return $result;
- }
- private function unknownPay()
- {
- \Log::debug('------售后确认退款支付类型无对应退款方法--'.$this->refundApply->order->pay_type_id,[$this->refundApply->order->order_sn]);
- $payAdapter = new \app\common\modules\refund\RefundPayAdapter($this->refundApply->order->pay_type_id);
- $result = $payAdapter->pay($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result['status']) {
- throw new AdminException($result['msg']);
- }
- //微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return true;
- }
- private function eplusPay(){
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('智E+退款失败');
- }
- //微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function wechatTradePay(){
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- //dd([$this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price]);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('微信视频号退款失败');
- }
- //微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- //微信JSAPI、H5、NATIVE、小程序、APP支付退款入口
- private function wechat()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- //dd([$this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price]);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('微信退款失败');
- }
- //微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function alipay()
- {
- //RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if ($result === false) {
- throw new AdminException('支付宝退款失败');
- }
- //保存batch_no,回调成功后根据batch_no找到对应的退款记录
- $this->refundApply->alipay_batch_sn = $result['batch_no'];
- $this->refundApply->save();
- return $result['url'];
- }
- private function alipay2()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if ($result === false) {
- throw new AdminException('支付宝退款失败');
- }
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function alipayapp()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if ($result === false) {
- throw new AdminException('支付宝退款失败');
- }
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function backend()
- {
- $refundApply = $this->refundApply;
- //退款状态设为完成
- $result = RefundOperationService::refundComplete(['id' => $refundApply->id]);
- if ($result !== true) {
- throw new AdminException($result);
- }
- return $result;
- }
- private function yopWechat()
- {
- $result = PayFactory::create($this->refundApply->order->pay_type_id)->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if ($result !== true) {
- throw new AdminException($result);
- }
- //退款状态设为完成
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function deposit()
- {
- $result = PayFactory::create($this->refundApply->order->pay_type_id)->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if ($result !== true) {
- throw new AdminException(TEAM_REWARDS_DEPOSIT . '退款失败');
- }
- //退款状态设为完成
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function lspPay()
- {
- $refundApply = $this->refundApply;
- //退款状态设为完成
- RefundOperationService::refundComplete(['id' => $refundApply->id]);
- // $order = Order::select('id', 'order_pay_id')
- // ->with([
- // 'hasOneOrderPay'
- // ])
- // ->find($refundApply->order_id);
- // if (!$order || !$order->hasOneOrderPay) {
- // throw new AdminException("加速池支付:未找到订单");
- // }
- $order = $refundApply->order;
- $orderPay = $order->hasOneOrderPay;
- $pay = PayFactory::create($order->pay_type_id);
- //$lspPay = new LSPPay();
- return $pay->doRefund($orderPay->pay_sn, $orderPay->amount, $refundApply->price);
- }
- private function lspWalletPay(){
- $refundApply = $this->refundApply;
- $pay = PayFactory::create($refundApply->order->pay_type_id);
- $result = $pay->doRefund($refundApply->order->hasOneOrderPay->pay_sn, $refundApply->order->hasOneOrderPay->amount, $refundApply->price);
- if (!$result) {
- throw new AdminException('爱心值加速池钱包退款失败');
- }
- //退款状态设为完成
- RefundOperationService::refundComplete(['id' => $refundApply->id]);
- return $result;
- }
- private function balance()
- {
- $refundApply = $this->refundApply;
- //退款状态设为完成
- RefundOperationService::refundComplete(['id' => $refundApply->id]);
- $data = [
- 'member_id' => $refundApply->uid,
- 'remark' => '订单(ID' . $refundApply->order->id . ')余额支付退款(ID' . $refundApply->id . ')' . $refundApply->price,
- 'source' => ConstService::SOURCE_CANCEL_CONSUME,
- 'relation' => $refundApply->refund_sn,
- 'operator' => ConstService::OPERATOR_ORDER,
- 'operator_id' => $refundApply->uid,
- 'change_value' => $refundApply->price
- ];
- if ($refundApply->order->hasOneOrderPay->behalfPay) {
- $data['member_id'] = $refundApply->order->hasOneOrderPay->behalfPay->behalf_id;
- $data['remark'] .= "(代付退款)";
- }
- $result = (new BalanceChange())->cancelConsume($data);
- if ($result !== true) {
- throw new AdminException($result);
- }
- return $result;
- }
- private function yunWechat()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('芸支付微信退款失败');
- }
- //芸支付微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- public static function allowRefund()
- {
- $refund_status = Setting::get('shop.trade.refund_status');
- if ($refund_status == 1 || $refund_status == null) {
- return true;
- }
- }
- private function hxquick()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('环迅快捷退款失败');
- }
- //环迅快捷退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function hxwechat()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('环迅微信退款失败');
- }
- //环迅微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function ConvergeWechat()
- {
- $pay = PayFactory::create(PayFactory::PAY_WECHAT_HJ); //修复支付宝无法退款,退款处理统一写在了汇聚微信支付类里了
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn,
- $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if ($result['ra_Status'] == '101') {
- \Log::debug('汇聚微信或支付宝退款失败,失败原因' . $result['rc_CodeMsg'] . '-----失败参数-----' . json_encode($result));
- throw new AdminException('汇聚微信或支付宝退款失败,失败原因' . $result['rc_CodeMsg'] . '-----失败参数-----' . json_encode($result));
- }
- //汇聚微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- /**
- * 龙存管-支付退款
- * @return array
- * @throws AdminException
- * @throws \app\common\exceptions\AppException
- */
- protected function lcg()
- {
- $pay_sn = $this->refundApply->order->hasOneOrderPay->pay_sn;
- $amount = $this->refundApply->order->hasOneOrderPay->amount;
- $result = PayFactory::create($this->refundApply->order->pay_type_id)->doRefund($pay_sn, $amount, $this->refundApply->price, $this->refundApply->order->order_sn);
- if ($result['code'] !== true) {
- throw new AdminException($result['msg']);
- }
- //退款状态设为完成
- //RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- //throw new AdminException('退款申请成功,等待商家确认退款中。。。');
- return ['action' => $result['data']['action_url'], 'input' => $result['data']['form_data']];
- //return $result['code'];
- }
- /**
- * 易宝专业版 微信、支付宝退款
- * @return array|bool|mixed|void
- * @throws AdminException
- * @throws \app\common\exceptions\AppException
- */
- private function yopPro()
- {
- $pay_sn = $this->refundApply->order->hasOneOrderPay->pay_sn;
- $amount = $this->refundApply->order->hasOneOrderPay->amount;
- $result = PayFactory::create($this->refundApply->order->pay_type_id)->doRefund($pay_sn, $amount, $this->refundApply->price, $this->refundApply->order->order_sn);
- if ($result !== true) {
- throw new AdminException($result);
- }
- //退款状态设为完成
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- /**
- * 港版微信退款
- * @return array|bool|mixed|void
- * @throws AdminException
- * @throws \app\common\exceptions\AppException
- */
- private function hkPay()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('微信退款失败');
- }
- //港版微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function payPal()
- {
- $pay_sn = $this->refundApply->order->hasOneOrderPay->pay_sn;
- $amount = $this->refundApply->order->hasOneOrderPay->amount;
- $result = PayFactory::create($this->refundApply->order->pay_type_id)->doRefund($pay_sn, $amount, $this->refundApply->price);
- if ($result !== true) {
- throw new AdminException('退款失败');
- }
- //退款状态设为完成
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function convergeQuickPay()
- {
- $pay_sn = $this->refundApply->order->hasOneOrderPay->pay_sn;
- $amount = $this->refundApply->order->hasOneOrderPay->amount;
- $result = PayFactory::create($this->refundApply->order->pay_type_id)->doRefund($pay_sn, $amount, $this->refundApply->price);
- if (!$result['code']) {
- throw new AdminException($result['msg']);
- }
- //同步改变退款和订单状态
- //RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return true;
- }
- /**
- * 港版支付宝H5退款
- * @return array|bool|mixed|void
- * @throws AdminException
- * @throws \app\common\exceptions\AppException
- */
- private function hkAliPay()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('退款失败');
- }
- //港版微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function xfpayPay()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('商云客退款失败');
- }
- //商云客微信支付宝退款
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function sandpayPay()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('杉德退款失败');
- }
- // 杉德支付宝微信退款
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function lakalaPay()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('拉卡拉支付退款失败');
- }
- // 拉卡拉支付宝微信退款
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function leshuaPay()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('乐刷支付退款失败');
- }
- // 拉卡拉支付宝微信退款
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function silverPointRefund()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('银典支付退款失败');
- }
- // 银典支付支付宝微信退款
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function codeScienceRefund()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('豫章行代金券支付退款失败');
- }
- // 银典支付支付宝微信退款
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- /**
- * 确认支付退款操作
- * @return bool
- * @throws AdminException
- */
- private function confirmPay()
- {
- //改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return true;
- //$pay = PayFactory::create($this->refundApply->order->pay_type_id);
- //$pay_sn = $this->refundApply->order->hasOneOrderPay->pay_sn;
- //$amount = $this->refundApply->order->hasOneOrderPay->amount;
- //$result = $pay->doRefund($pay_sn, $amount, $this->refundApply->price);
- }
- public function storeAggregatePay()
- {
- $pay_sn = $this->refundApply->order->hasOneOrderPay->pay_sn;
- $amount = $this->refundApply->order->hasOneOrderPay->amount;
- $result = PayFactory::create($this->refundApply->order->pay_type_id)->doRefund($pay_sn, $amount, $this->refundApply->price);
- //同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return true;
- }
- /**
- * 汇聚聚合支付统一退款方法
- * @return array|bool|mixed|string
- * @throws AdminException
- * @throws \app\common\exceptions\AppException
- */
- protected function convergePayRefund()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id); //修复支付宝无法退款,退款处理统一写在了汇聚微信支付类里了
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn,
- $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if ($result['ra_Status'] == '101') {
- \Log::debug('汇聚退款失败,失败原因' . $result['rc_CodeMsg'] . '-----失败参数-----' . json_encode($result));
- throw new AdminException('汇聚支付退款失败,失败原因' . $result['rc_CodeMsg'] . '-----失败参数-----' . json_encode($result));
- }
- //汇聚微信退款 同步改变退款和订单状态
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function jinepayRefund()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('锦银E付退款失败');
- }
- // 银典支付支付宝微信退款
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- private function authPayRefund()
- {
- $pay = PayFactory::create($this->refundApply->order->pay_type_id);
- $result = $pay->doRefund($this->refundApply->order->hasOneOrderPay->pay_sn, $this->refundApply->order->hasOneOrderPay->amount, $this->refundApply->price);
- if (!$result) {
- throw new AdminException('微信借权支付退款失败');
- }
- // 银典支付支付宝微信退款
- RefundOperationService::refundComplete(['id' => $this->refundApply->id]);
- return $result;
- }
- }
|