wxpay($order, $money); } // 2.余额支付退款 if ($order['pay_type']['value'] == PayTypeEnum::BALANCE) { return $this->balance($order, $money); } return false; } /** * 余额支付退款 * @param $order * @param $money * @return bool * @throws \think\Exception * @throws \think\exception\DbException */ private function balance(&$order, $money) { // 回退用户余额 $user = UserModel::detail($order['user_id']); $user->setInc('balance', $money); // 记录余额明细 BalanceLogModel::add(SceneEnum::REFUND, [ 'user_id' => $user['user_id'], 'money' => $money, ], ['order_no' => $order['order_no']]); return true; } /** * 微信支付退款 * @param $order * @param double $money * @return bool * @throws \app\common\exception\BaseException * @throws \think\exception\DbException */ private function wxpay(&$order, $money) { $wxConfig = WxappModel::getWxappCache($order['wxapp_id']); $WxPay = new WxPay($wxConfig); return $WxPay->refund($order['transaction_id'], $order['pay_price'], $money); } }