From c8f6dd78856a373fc129b71380a04fbbce73d246 Mon Sep 17 00:00:00 2001 From: lihan <3398341942@qq.com> Date: Mon, 22 Oct 2018 17:21:25 +0800 Subject: [PATCH] 退货&退款 --- app/admin/controller/ZjOrderController.php | 32 +++++++++++++++++--------------- public/themes/admin_simpleboot3/admin/zj_order/refund.html | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/admin/controller/ZjOrderController.php b/app/admin/controller/ZjOrderController.php index 4bef83f..63be701 100644 --- a/app/admin/controller/ZjOrderController.php +++ b/app/admin/controller/ZjOrderController.php @@ -341,15 +341,16 @@ class ZjOrderController extends AdminBaseController } $param['step'] = 9; unset($param['tui']);//删除无用数据 - $return = $this->wxRefund($param['id'], 1); - $this->error($return); - exit(); - - $edit = Db::name('zj_order')->update($param); - if (empty($edit)) { - $this->error('订单退款失败'); + $return = $this->wxRefund($param['id'], $param['refund_fee'] * 100); + if ($return) { + $edit = Db::name('zj_order')->update($param); + if (empty($edit)) { + $this->error('订单退款失败'); + } else { + $this->success('订单退款成功'); + } } else { - $this->success('订单退款成功'); + $this->error('订单退款失败'); } } else { $this->error('非法操作'); @@ -362,20 +363,21 @@ class ZjOrderController extends AdminBaseController $info = Db::name('zj_order')->field('order_num,whole,whole_num,out_trade_no,step')->where(['id' => $oid])->find(); if ($info['step'] == 8) { $totalFee = $info['whole'] - $info['whole_num']; - if($refundFee > $totalFee) { + if ($refundFee > $totalFee) { $this->error('退款金额不能大于实际支付金额'); - }else { + } else { require_once EXTEND_PATH . '/Refund.php'; $refund = new \Refund($info['out_trade_no'], $totalFee * 100, $info['order_num'], $refundFee); - var_dump($refund->refund()); + $return = $refund->refund(); + if ($return['return_code'] == 'SUCCESS' && $return['result_code'] == 'SUCCESS') { + return true; + } else { + return false; + } } } else { $this->error('非法操作'); } } - public function test() { - $this->wxRefund(148, 1); - } - } \ No newline at end of file diff --git a/public/themes/admin_simpleboot3/admin/zj_order/refund.html b/public/themes/admin_simpleboot3/admin/zj_order/refund.html index 77851dd..ef05cf7 100644 --- a/public/themes/admin_simpleboot3/admin/zj_order/refund.html +++ b/public/themes/admin_simpleboot3/admin/zj_order/refund.html @@ -127,7 +127,7 @@ <tr> <th>退款额度</th> <td> - <input type="number" name="tui" class="form-control"> + <input type="number" name="refund_fee" class="form-control"> </td> </tr> <tr> -- libgit2 0.24.0