作者 何书鹏

取消订单bug修改

@@ -644,22 +644,29 @@ class Order extends Api @@ -644,22 +644,29 @@ class Order extends Api
644 $skumodel->where('goods_spec_id',$value['goods_spec_id'])->setInc('stock_num',$value['total_num']); 644 $skumodel->where('goods_spec_id',$value['goods_spec_id'])->setInc('stock_num',$value['total_num']);
645 } 645 }
646 } 646 }
647 - $config = Service::getConfig('wechat');  
648 - $config['notify_url'] = $this->request->domain().'api/notify/refund/type/wechat';  
649 - $config['return_url'] = '';  
650 - $wechat = Pay::wechat($config);  
651 - $refund_no = 'LQ-'.time().mt_rand(10000,99999);  
652 - $param = [ 647 + // 已支付就退款
  648 + if($order['pay_status'] == '20'){
  649 + $config = Service::getConfig('wechat');
  650 + $config['app_id'] = $config['miniapp_id'];
  651 + $config['notify_url'] = $this->request->domain().'api/notify/refund/type/wechat';
  652 + $config['return_url'] = '';
  653 + $wechat = Pay::wechat($config);
  654 + $refund_no = 'LQ-'.time().mt_rand(10000,99999);
  655 + $param = [
653 // 'total_fee' => $order['pay_price'], 656 // 'total_fee' => $order['pay_price'],
654 // 'refund_fee' => $order['pay_price'], 657 // 'refund_fee' => $order['pay_price'],
655 - 'total_fee' => 0.01,  
656 - 'refund_fee' => 0.01,  
657 - 'out_trade_no' => $order['order_no'],  
658 - 'out_refund_no' => $refund_no  
659 - ];  
660 - $wechat->refund($param);  
661 - $order->refund_no = $refund_no;  
662 - $order->isUpdate()->save(); 658 + 'total_fee' => 1,
  659 + 'refund_fee' => 1,
  660 + 'out_trade_no' => $order['order_no'],
  661 + 'out_refund_no' => $refund_no
  662 + ];
  663 + $wechat->refund($param);
  664 + $order->refund_no = $refund_no;
  665 + $order->refund_time = time();
  666 + }
  667 + // 状态变为已取消
  668 + $order->order_status = '20';
  669 + $order->isUpdate(true)->save();
663 $this->success('取消成功'); 670 $this->success('取消成功');
664 } 671 }
665 672