alias('SWR') ->join('payment_tool PT', 'PT.payment_tool_id=SWR.payment_tool_id') ->join('supplier_asset SA', 'SA.id=SWR.asset_id') ->join('currency C', 'C.id=SA.currency_id') ->where($condition)->count(); $list = Db::name('supplier_withdrawal_record') ->alias('SWR') ->field("SWR.*,PT.payment_tool_name,C.currency_name") ->join('payment_tool PT', 'PT.payment_tool_id=SWR.payment_tool_id') ->join('supplier_asset SA', 'SA.id=SWR.asset_id') ->join('currency C', 'C.id=SA.currency_id') ->where($condition)->order($order)->page($p, $other['page_size'])->withAttr('add_time', function ($value) { return date('Y-m-d H:i', $value); }) ->select()->toArray(); $other['count'] = $count; $result['other'] = $other; if (!$list) { throw new Exception(lang('no_data_found')); } else { $result['list'] = $list; return $this->successResponse($result); } } catch (\Exception $exc) { return $this->errorResponse($exc->getMessage()); } } /** * 汇款审核 */ public function reviewWithdrawalRecord() { // 开始数据库事务 Db::startTrans(); try { if (!Request::isPost()) { throw new Exception(lang('request_method_incorrect')); } $record_id = input('post.record_id'); if (!is_numeric($record_id)) { throw new Exception(lang('parameter_error')); } $status = input('post.status'); //更新数据 $info = Db::name('supplier_withdrawal_record')->field('id,status,asset_id,payment_amount,supplier_id')->where('id', $record_id)->find(); if (!$info) { throw new Exception(lang('no_data_found')); } if ($info['status'] == 1) { throw new Exception('该申请已审核通过,请勿重复审核'); } $payment_amount = $info['payment_amount']; if ($status == 1) { $service_charge = input('post.service_charge'); if (!is_numeric($service_charge)) { throw new Exception('请输入手续费'); } $add_fee = $payment_amount - $service_charge;//实际收款金额:充值金额-手续费 $asset_update['mnyusd'] = Db::raw("mnyusd+$payment_amount");//提现总额 $asset_update['mnylck'] = Db::raw("mnylck-$payment_amount");//冻结金额 Db::name('supplier_asset')->where('id', $info['asset_id'])->update($asset_update); $record_update = [ 'status' => 1, 'service_charge' => $service_charge, 'review_time' => time()//审核时间 ]; Db::name('supplier_withdrawal_record')->where('id', $record_id)->update($record_update);//更新状态 $LogData = [ 'amount' => $add_fee, 'type' => 2,//1增加,2减少 'remark' => '提现确认', 'user_id' => $this->admin_id, 'supplier_id' => $info['supplier_id'], 'target_type' => 2,//提现 'target_id' => $info['asset_id'], ]; event('SupplierBillLog', $LogData);//提现确认日志 $message = '操作成功,审核通过'; } else { $review_comments = input('post.review_comments'); //审核不通过处理 $asset_update['mnyavl'] = Db::raw("mnyavl+$payment_amount");//可用余额恢复 $asset_update['mnylck'] = Db::raw("mnylck-$payment_amount");//冻结金额恢复 Db::name('supplier_asset')->where('id', $info['asset_id'])->update($asset_update); $no_record_update = [ 'status' => 2, 'review_comments' => $review_comments, 'review_time' => time()//审核时间 ]; Db::name('supplier_withdrawal_record')->where('id', $record_id)->update($no_record_update); $message = '操作成功,审核不通过'; } // 提交事务 Db::commit(); return $this->successResponse($message); } catch (Exception $exc) { // 回滚事务 Db::rollback(); return $this->errorResponse($exc->getMessage()); } } }