企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` 安装 首次安装 线上版本(稳定) composer require zoujingli/wechat-developer ``` 微信退款 ``` public function wx_refund(){ $config= config('config.wechat'); $pay = new Pay($config); $plaint_id=input('plaint_id'); $plaint=db('complaint')->alias('a')->leftJoin('orders b','a.order_id=b.order_id')->where('a.plaint_id',$plaint_id)-> where('a.plaint_state',1)->field('a.*,b.money_sum,b.transaction_id,b.pay_way')->find(); if(empty($plaint)){ return ['status' => 1, 'message' => '未查询到投诉订单']; } if($plaint['sys_result']==1){ return ['status' => 1, 'message' => '已完成退款']; } $options = [ 'transaction_id'=>$plaint['transaction_id'], 'out_refund_no'=>$plaint['plaint_id'], 'total_fee' =>$plaint['money_sum']*100, 'refund_fee' =>$plaint['money_sum']*100, ]; $result = $pay->createRefund($options); if($result['return_code']=='SUCCESS' and $result['result_code']=='SUCCESS' ){ Db::startTrans(); try { $this->plaint_bill($plaint,$result); $this->plaint_sys_update($plaint_id,$result['refund_id']); $this->user_cash($plaint['shop_id'],$plaint['money_sum']); // 提交事务 Db::commit(); return ['status' => 0, 'message' => '退款成功']; } catch (\Exception $e) { // 回滚事务 Db::rollback(); return ['status' => 1, 'message' => $e->getMessage()]; } }else{ return ['status' => 1, 'message' => '退款失败']; } } ``` 微信订单查询 ``` public function pay_find(){ $config= config('config.wechat'); $pay = new Pay($config); $transaction_id=input('transaction_id'); $options = [ 'transaction_id' => $transaction_id, ]; $result = $pay->queryOrder($options); return json($result); } ```