|
@@ -471,19 +471,35 @@ class Order extends Api
|
|
|
$user_id = $this->auth->id;
|
|
|
$order_id = input('order_id');
|
|
|
$good_order_model = new Goodorder();
|
|
|
- $status = $good_order_model->where('id',$order_id)->where('user_id',$user_id)->value('status');
|
|
|
- if($status==1){
|
|
|
+ $status = $good_order_model->where('id',$order_id)->where('user_id',$user_id)->find();
|
|
|
+ if($status['status']==1){
|
|
|
$good_order_model->where('id',$order_id)->where('user_id',$user_id)->delete();
|
|
|
$this->success('订单已取消');
|
|
|
}
|
|
|
- if($status==2){
|
|
|
+ if($status['status']==2){
|
|
|
//退款
|
|
|
+ $config = [
|
|
|
+ 'app_id' => 'wxdc450b7c5d0a0f80',
|
|
|
+ 'mch_id' => '1635096198',
|
|
|
+ 'key' => 'e3NkU3L7vmz84H92kfKT5d9qBCOmvdEB', // API v2 密钥 (注意: 是v2密钥 是v2密钥 是v2密钥)
|
|
|
+ 'cert_path' => ROOT_PATH.'public/cert/apiclient_cert.pem', // XXX: 绝对路径!!!!
|
|
|
+ 'key_path' => ROOT_PATH.'public/cert/apiclient_key.pem', // XXX: 绝对路径!!!
|
|
|
+ 'notify_url' => common_url() . '/api/Notice/tableware_notify', // 你也可以在下单时单独设置来想覆盖它
|
|
|
+ ];
|
|
|
+
|
|
|
+ $app = Factory::payment($config);
|
|
|
+ $refund_no = 'TK' . pay_no(999);
|
|
|
+ $result = $app->refund->byOutTradeNumber($status['pay_no'], $refund_no, $status['total'], $status['total'], [
|
|
|
+ // 可在此处传入其他参数,详细参数见微信支付文档
|
|
|
+ 'refund_desc' => '退款',
|
|
|
+ ]);
|
|
|
+ if($result['return_code']=='FAIL'||$result['result_code']=='FAIL'){
|
|
|
+ $this->error('退款出错请联系商家');
|
|
|
+ }
|
|
|
$good_order_model->save(['status' => 7], ['id' => $order_id, 'user_id' => $user_id]);
|
|
|
$this->success('支付金额退回,注意查收');
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
- if($status==3) {
|
|
|
+ if($status['status']==3) {
|
|
|
$good_order_model->save(['status' => 5], ['id' => $order_id, 'user_id' => $user_id]);
|
|
|
$this->success('订单已取消等待审核');
|
|
|
|