作者 lihan
1 个管道 的构建 通过 耗费 1 秒

退货&退款

@@ -341,15 +341,16 @@ class ZjOrderController extends AdminBaseController @@ -341,15 +341,16 @@ class ZjOrderController extends AdminBaseController
341 } 341 }
342 $param['step'] = 9; 342 $param['step'] = 9;
343 unset($param['tui']);//删除无用数据 343 unset($param['tui']);//删除无用数据
344 - $return = $this->wxRefund($param['id'], 1);  
345 - $this->error($return);  
346 - exit();  
347 -  
348 - $edit = Db::name('zj_order')->update($param);  
349 - if (empty($edit)) {  
350 - $this->error('订单退款失败'); 344 + $return = $this->wxRefund($param['id'], $param['refund_fee'] * 100);
  345 + if ($return) {
  346 + $edit = Db::name('zj_order')->update($param);
  347 + if (empty($edit)) {
  348 + $this->error('订单退款失败');
  349 + } else {
  350 + $this->success('订单退款成功');
  351 + }
351 } else { 352 } else {
352 - $this->success('订单退款成功'); 353 + $this->error('订单退款失败');
353 } 354 }
354 } else { 355 } else {
355 $this->error('非法操作'); 356 $this->error('非法操作');
@@ -362,20 +363,21 @@ class ZjOrderController extends AdminBaseController @@ -362,20 +363,21 @@ class ZjOrderController extends AdminBaseController
362 $info = Db::name('zj_order')->field('order_num,whole,whole_num,out_trade_no,step')->where(['id' => $oid])->find(); 363 $info = Db::name('zj_order')->field('order_num,whole,whole_num,out_trade_no,step')->where(['id' => $oid])->find();
363 if ($info['step'] == 8) { 364 if ($info['step'] == 8) {
364 $totalFee = $info['whole'] - $info['whole_num']; 365 $totalFee = $info['whole'] - $info['whole_num'];
365 - if($refundFee > $totalFee) { 366 + if ($refundFee > $totalFee) {
366 $this->error('退款金额不能大于实际支付金额'); 367 $this->error('退款金额不能大于实际支付金额');
367 - }else { 368 + } else {
368 require_once EXTEND_PATH . '/Refund.php'; 369 require_once EXTEND_PATH . '/Refund.php';
369 $refund = new \Refund($info['out_trade_no'], $totalFee * 100, $info['order_num'], $refundFee); 370 $refund = new \Refund($info['out_trade_no'], $totalFee * 100, $info['order_num'], $refundFee);
370 - var_dump($refund->refund()); 371 + $return = $refund->refund();
  372 + if ($return['return_code'] == 'SUCCESS' && $return['result_code'] == 'SUCCESS') {
  373 + return true;
  374 + } else {
  375 + return false;
  376 + }
371 } 377 }
372 } else { 378 } else {
373 $this->error('非法操作'); 379 $this->error('非法操作');
374 } 380 }
375 } 381 }
376 382
377 - public function test() {  
378 - $this->wxRefund(148, 1);  
379 - }  
380 -  
381 } 383 }
@@ -127,7 +127,7 @@ @@ -127,7 +127,7 @@
127 <tr> 127 <tr>
128 <th>退款额度</th> 128 <th>退款额度</th>
129 <td> 129 <td>
130 - <input type="number" name="tui" class="form-control"> 130 + <input type="number" name="refund_fee" class="form-control">
131 </td> 131 </td>
132 </tr> 132 </tr>
133 <tr> 133 <tr>