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

修改退款为0

... ... @@ -125,12 +125,18 @@ class Order extends Backend
{
if ($ids) {
$pk = $this->model->getPk();
$res = Db::name('order')->where($pk,$ids)->field('id,pay_order_sn,total_goods_price')->find();
$res = Db::name('order')->where($pk,$ids)->field('id,pay_order_sn,total_expense_price,total_price')->find();
if($res){
if($res['total_price'] == 0){
//支付总金额为0,
$this->success('成功');
}
$status = config('verify.status');
//处理退款逻辑
$config = config('verify.wx_pay');
$app = Factory::payment($config);
// $security_price = $res['total_goods_price']*100;
//退款金额 支付金额-运费
// $security_price = ($res['total_price'] - $res['total_expense_price'])*100;
$security_price = 1;
$refundNumber = $this->genPayOrderSn('refund');//商户退款单号
$result = $app->refund->byOutTradeNumber($res['pay_order_sn'], $refundNumber, $security_price, $security_price, [
... ... @@ -168,6 +174,8 @@ class Order extends Backend
}else{
$this->error('退款失败');
}
}
$this->error('未查到订单');
}
$this->error(__('Parameter %s can not be empty', 'ids'));
... ...
... ... @@ -6,6 +6,7 @@ use app\admin\model\Collection;
use app\admin\model\Rcoupon;
use app\common\controller\Api;
use fast\Http;
use think\db\Query;
use think\Validate;
use think\Db;
use think\db\Expression;
... ...