alias('SRR') ->join('pay_bank PA', 'PA.id=SRR.pay_bank_id') ->where($condition)->count(); $list = Db::name('seller_remit_record') ->alias('SRR') ->field("SRR.*,PA.payee_name") ->join('pay_bank PA', 'PA.id=SRR.pay_bank_id') ->where($condition)->order($order)->page($p, $other['page_size'])->withAttr('add_time', function ($value) { return date('Y-m-d H:i', $value); }) ->withAttr('remit_date_time', function ($value) { return $value ? date('Y-m-d', $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 reviewRemitRecord() { // 开始数据库事务 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('seller_remit_record')->field('id,status,asset_id,remit_amount,seller_id')->where('id', $record_id)->find(); if (!$info) { throw new Exception(lang('no_data_found')); } if ($info['status'] == 1) { throw new Exception('该申请已审核通过,不能重复审核'); } if ($status == 1) { $service_charge = input('post.service_charge'); $remit_amount = $info['remit_amount']; if (!$service_charge || !is_numeric($service_charge)) { throw new Exception('请输入手续费'); } $add_fee = $remit_amount - $service_charge;//实际收款金额:充值金额-手续费 $asset_update['mnyall'] = Db::raw("mnyall+$add_fee");//入库总额 $asset_update['mnyavl'] = Db::raw("mnyavl+$add_fee");//可用余额 Db::name('seller_asset')->where('id', $info['asset_id'])->update($asset_update); $record_update = [ 'status' => 1, 'service_charge'=> $service_charge, 'review_time' => time()//审核时间 ]; Db::name('seller_remit_record')->where('id', $record_id)->update($record_update);//更新状态 $LogData = [ 'amount' => $add_fee, 'type' => 1,//1增加,2减少 'remark' => '汇款确认', 'user_id' => $this->admin_id, 'seller_id' => $info['seller_id'], 'target_type' => 1, 'target_id' => $info['asset_id'], ]; event('SellerBillLog', $LogData);//汇款确认入账日志 $message = '操作成功,审核通过'; } else { Db::name('seller_remit_record')->where('id', $record_id)->update(['status' => 2]); $message = '操作成功,审核不通过'; } // 提交事务 Db::commit(); return $this->successResponse($message); } catch (Exception $exc) { // 回滚事务 Db::rollback(); return $this->errorResponse($exc->getMessage()); } } }