public function tuikuan()
{
$ids=$this->request->param("ids");
$row=$this->model->get($ids);
if(empty($row)){
$this->error("未找到该订单");
}
// 退款
$order = [
'transaction_id' => $row["payid"], //微信支付transaction_id
'out_refund_no' => time(), //退款订单号
'total_fee' => intval($row["payamount"]*100), //付款总额
'refund_fee' => intval($row["payamount"]*100),//退款额
'refund_desc' => "订单:{$row['orderid']}退款", //备注
//'type' => $row['method'] //支付方式
];
try {
$config = \addons\epay\library\Service::getConfig("wechat");
$result = \Yansongda\Pay\Pay::wechat($config)->refund($order);
} catch (\Exception $e) {
$this->error($e->getMessage());
}
if(!isset($result)){
$this->error("操作失败!");
}
if($result->result_code=="SUCCESS"){
$row->save(['status' => 'refunded']);
$this->success("退款成功");
}else{
$this->error("操作失败!!");
}
}
快捷键:weixintuikuan
源:
sublime_text格式
<snippet>
<content><![CDATA[
public function tuikuan()
{
\$ids=\$this->request->param("ids");
\$row=\$this->model->get(\$ids);
if(empty(\$row)){
\$this->error("未找到该订单");
}
// 退款
\$order = [
'transaction_id' => \$row["payid"], //微信支付transaction_id
'out_refund_no' => time(), //退款订单号
'total_fee' => intval(\$row["payamount"]*100), //付款总额
'refund_fee' => intval(\$row["payamount"]*100),//退款额
'refund_desc' => "订单:{\$row['orderid']}退款", //备注
//'type' => \$row['method'] //支付方式
];
try {
\$config = \addons\epay\library\Service::getConfig("wechat");
\$result = \Yansongda\Pay\Pay::wechat(\$config)->refund(\$order);
} catch (\Exception \$e) {
\$this->error(\$e->getMessage());
}
if(!isset(\$result)){
\$this->error("操作失败!");
}
if(\$result->result_code=="SUCCESS"){
\$row->save(['status' => 'refunded']);
\$this->success("退款成功");
}else{
\$this->error("操作失败!!");
}
}
]]></content>
<tabTrigger>weixintuikuan(微信退款)</tabTrigger>
<scope></scope>
</snippet>
发表评论 取消回复