Commit ae991583 authored by hujun's avatar hujun

收款

parent 301cd458
...@@ -3053,531 +3053,6 @@ class Finance extends Basic ...@@ -3053,531 +3053,6 @@ class Finance extends Basic
return; return;
} }
/**
* 收款记录
*
* @return \think\Response|\think\response\View|void
*/
public function getCollection()
{
if (!$this->request->isAjax() && $this->params['excel'] != 1) {
return view('getCollection');
}
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$data = [];
$where['a.is_del'] = 0;
$is_show = 0;
$msg = '';
/*提交时间 start*/
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time', $this->params['start_time'] . ' 00:00:00'];
$is_show = 1;
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
$is_show = 1;
}
if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) {
$where['a.create_time'] = [
'between time', [
$this->params['start_time'] . ' 00:00:00', $this->params['end_time'] . ' 23:59:59'
]
];
$is_show = 1;
}
/*提交时间 end*/
/*入账日期 start*/
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['a.income_time'] = ['> time', $this->params['income_start_time'] . ' 00:00:00'];
$is_show = 1;
}
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
$is_show = 1;
}
if (!empty($this->params['income_end_time']) && !empty($this->params['income_start_time'])) {
$where['a.income_time'] = [
'between time', [
$this->params['income_start_time'] . ' 00:00:00', $this->params['income_end_time'] . ' 23:59:59'
]
];
$is_show = 1;
}
/*入账日期 end*/
/*收款确认日期 start*/
if (!empty($this->params['open_time_start']) && empty($this->params['open_end_time'])) {
$where['a.open_time'] = ['> time', $this->params['open_time_start'] . ' 00:00:00'];
$is_show = 1;
}
if (!empty($this->params['open_time_end']) && empty($this->params['open_time_start'])) {
$where['a.open_time'] = ['< time', $this->params['open_time_end'] . ' 23:59:59'];
$is_show = 1;
}
if (!empty($this->params['open_time_end']) && !empty($this->params['open_time_start'])) {
$where['a.open_time'] = [
'between time', [
$this->params['open_time_start'] . ' 00:00:00', $this->params['open_time_end'] . ' 23:59:59'
]
];
$is_show = 1;
}
/*入账日期 end*/
//商铺地址
if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%' . $this->params['internal_address'] . '%'];
$is_show = 1;
}
//商铺ID
if (!empty($this->params['house_id'])) {
$where['b.house_id'] = $this->params['house_id'];
$is_show = 1;
}
//提交人所在门店
if (!empty($this->params['store_id'])) {
$where['e.store_id'] = $this->params['store_id'];
$is_show = 1;
}
//提交人所在部门
if (!empty($this->params['district_id'])) {
$where['e.district_id'] = $this->params['district_id'];
$is_show = 1;
}
//提交人姓名
if (!empty($this->params['agent_id'])) {
$where['a.agent_id'] = $this->params['agent_id'];
$is_show = 1;
}
//入账方式
if (!empty($this->params['pay_type'])) {
$where['a.pay_type'] = $this->params['pay_type'];
$is_show = 1;
}
//入账类型
if (!empty($this->params['type'])) {
$where['a.type'] = $this->params['type'];
$is_show = 1;
}
//来源
if ($this->params['source'] > -1) {
if ($this->params['source'] == 1) {
$where['a.source'] = ['in', '0,1'];
} else {
$where['a.source'] = $this->params['source'];
}
$is_show = 1;
}
if (!empty($this->params['bargain_id'])) {
// $order_id = $this->m_bargain->getFieldValue('order_id', ['id'=>$this->params['bargain_id'],'father_id'=>0]);
// if (!empty($order_id)) {
// $where[] = ['EXP', 'a.order_id='.$order_id];
// }
$where['a.bargain_id'] = $this->params['bargain_id'];
$is_show = 1;
}
if (!empty($this->params['pay_id'])) {
$where['a.id'] = $this->params['pay_id'];
}
if (!empty($this->params['order_id'])) {
$where['a.order_id'] = $this->params['order_id'];
}
if (is_numeric($this->params['source_type'])) {
if ($this->params['source_type'] == 1) {
$where['a.source'] = array('neq', 2);
} else {
$where['a.source'] = 2;
}
}
//案场费和中介费是否开业
if (isset($this->params['is_open'])) {
if ($this->params['is_open'] == 1) {
$where['a.is_open'] = 1;
} else {
$where['a.is_open'] = 0;
}
if (!isset($where['a.type'])) {
$where['a.type'] = ['in', '91,92'];
}
$is_show = 1;
}
if (isset($this->params['is_normality']) && $this->params['is_normality'] == 1) {
$where[] = ['EXP', '(select id from o_refund where pay_log_id=a.id and is_del = 0 group by pay_log_id) is null'];
$where[] = ['EXP', '(select id from o_paylog_adjustment where paylog_id=a.id and is_del = 0 group by paylog_id) is null '];
$is_show = 1;
}
if (!empty($this->params['is_del'])) {
$where['a.is_del'] = 1;
}
try {
$order = new OPayLogModel();
$field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,';
$field .= 'a.transaction_fee,a.source,b.f_id,a.transfer_name,a.receipt_number,a.bargain_id,a.is_open,';
$field .= 'e.name,a.income_time,e.store_id,b.house_id,b.order_no,a.report_id,a.house_number,a.is_dividend,';
$field .= 'a.last_transfer_time,a.industry_type,a.agent_id,d.internal_address as address,e.name as agent_name';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$data['total'] = $order->getAddPayLogOrderListLimitTotal($where);
$m_pay_adjustment = new OPayLogAdjustment();
$m_refund = new ORefundModel();
$m_open = new OPayLogOpen();
foreach ($list as $k => $v) {
$list[$k]['source_id'] = $list[$k]['is_adjustment'] = '';
if ($v['source'] == 2) {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['new_paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$adjustment_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['is_adjustment'] = $adjustment_id ? 1 : 0;
} else {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$list[$k]['is_adjustment'] = $source_id ? 1 : 0;
}
$num = $m_refund->getFind('id', ['pay_log_id' => $v['id'], 'is_del' => 0]);
if ($num['id'] > 0) {
$list[$k]['is_refund'] = 1;
} else {
$list[$k]['is_refund'] = 0;
}
if ($v['type'] != 10 && $v['type'] != 30) {
$list[$k]['bargain_id'] = empty($v['bargain_id']) ? '' : $v['bargain_id'];
} else {
$list[$k]['bargain_id'] = '';
}
if (!empty($v['income_time'])) {
$income_time = date('Y-m-d H:i:s', strtotime($v['income_time']));
if ($income_time == $v['income_time']) {
$list[$k]['income_time'] = $income_time;
} else {
$list[$k]['income_time'] = '';
}
}
$list[$k]['pay_type_num'] = $v['pay_type'];
$list[$k]['type_num'] = $v['type'];
if (empty($v['is_open'])) {
$is_check = $m_open->getFieldOneValue('id', ['pay_log_id' => $v['id'], 'is_del' => 0]);
$list[$k]['is_check'] = $is_check > 0 ? 1 : 0;
} else {
$list[$k]['is_check'] = 0;
}
}
$data['list'] = $list;
//加时间条件
if ($is_show) {
$where['a.source'] = array('neq', 2);
$data['money_total'] = $order->getMoneyTotal($where, 'a.money'); //收款总计(正常)
$where['a.source'] = 2;
$data['money_change_total'] = $order->getMoneyTotal($where, 'a.money'); //收款总计(调整)
$where['a.source'] = array('neq', 2);
$data['real_money_total'] = $order->getMoneyTotal($where, 'a.real_money'); //实付总计(正常)
$where['a.source'] = 2;
$data['real_money_change_total'] = $order->getMoneyTotal($where, 'a.real_money'); //实付总计(调整)
} else {
$data['money_total'] = '';
$data['money_change_total'] = '';
$data['real_money_total'] = '';
$data['real_money_change_total'] = '';
}
$data['list'] = $this->numberTransitionString($data['list']);
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
if ($this->params['excel'] == 1) {
return $this->error($msg);
}
}
return $this->response(200, $msg, $data);
}
/**
* 收款记录 Excel
*/
public function getCollectionExcel()
{
set_time_limit(0);
$pageNo = 1;
$pageSize = 10000;
$data = [];
$where['a.is_del'] = 0;
$is_show = 0;
$msg = '';
/*提交时间 start*/
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time', $this->params['start_time'] . ' 00:00:00'];
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
}
if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) {
$where['a.create_time'] = [
'between time', [
$this->params['start_time'] . ' 00:00:00', $this->params['end_time'] . ' 23:59:59'
]
];
}
/*提交时间 end*/
/*入账日期 start*/
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['a.income_time'] = ['> time', $this->params['income_start_time'] . ' 00:00:00'];
}
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
$is_show = 1;
}
if (!empty($this->params['income_end_time']) && !empty($this->params['income_start_time'])) {
$where['a.income_time'] = [
'between time', [
$this->params['income_start_time'] . ' 00:00:00', $this->params['income_end_time'] . ' 23:59:59'
]
];
}
/*入账日期 end*/
//商铺地址
if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%' . $this->params['internal_address'] . '%'];
}
//商铺ID
if (!empty($this->params['house_id'])) {
$where['b.house_id'] = $this->params['house_id'];
}
//提交人所在门店
if (!empty($this->params['store_id'])) {
$where['e.store_id'] = $this->params['store_id'];
}
//提交人所在部门
if (!empty($this->params['district_id'])) {
$where['e.district_id'] = $this->params['district_id'];
}
//提交人姓名
if (!empty($this->params['agent_id'])) {
$where['a.agent_id'] = $this->params['agent_id'];
}
//入账方式
if (!empty($this->params['pay_type'])) {
$where['a.pay_type'] = $this->params['pay_type'];
}
//入账类型
if (!empty($this->params['type'])) {
$where['a.type'] = $this->params['type'];
}
//来源
if ($this->params['source'] > -1) {
$where['a.source'] = $this->params['source'];
}
if (!empty($this->params['bargain_id'])) {
$order_id = $this->m_bargain->getFieldValue('order_id', ['id' => $this->params['bargain_id'], 'father_id' => 0]);
if (!empty($order_id)) {
$where[] = ['EXP', 'a.order_id=' . $order_id];
}
}
if (!empty($this->params['pay_id'])) {
$where['a.id'] = $this->params['pay_id'];
}
if (!empty($this->params['order_id'])) {
$where['a.order_id'] = $this->params['order_id'];
}
if (!empty($this->params['bargain_id'])) {
$where['a.bargain_id'] = $this->params['bargain_id'];
}
//案场费和中介费是否开业
if (isset($this->params['is_open'])) {
if ($this->params['is_open'] == 1) {
$where['a.is_open'] = 1;
} else {
$where['a.is_open'] = 0;
}
$where['a.type'] = ['in', '91,92'];
}
if (isset($this->params['is_normality']) && $this->params['is_normality'] == 1) {
$where[] = ['EXP', '(select id from o_refund where pay_log_id=a.id and is_del = 0 group by pay_log_id) is null'];
$where[] = ['EXP', '(select id from o_paylog_adjustment where paylog_id=a.id and is_del = 0 group by paylog_id) is null '];
}
try {
$order = new OPayLogModel();
if (empty($this->params['excel'])) {
$field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,a.transaction_fee,a.source,b.f_id,a.transfer_name,a.receipt_number,a.bargain_id,';
$field .= 'e.name,a.income_time,e.store_id,b.house_id,b.order_no,a.report_id,a.house_number,a.is_dividend,a.last_transfer_time,a.industry_type,a.agent_id,d.internal_address as address,e.name as agent_name';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$m_pay_adjustment = new OPayLogAdjustment();
$m_report = new OReportModel();
$m_refund = new ORefundModel();
foreach ($list as $k => $v) {
$list[$k]['source_id'] = $list[$k]['is_adjustment'] = '';
if ($v['source'] == 2) {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['new_paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$adjustment_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['is_adjustment'] = $adjustment_id ? 1 : 0;
} else {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$list[$k]['is_adjustment'] = $source_id ? 1 : 0;
}
$num = $m_refund->getFind('id', ['pay_log_id' => $v['id'], 'is_del' => 0]);
if ($num['id'] > 0) {
$list[$k]['is_refund'] = 1;
} else {
$list[$k]['is_refund'] = 0;
}
if ($v['type'] != 10 && $v['type'] != 30) {
$bargain_data = $this->m_bargain->getDetail('id,father_id', ['order_id' => $v['order_id']]);
$bargain_id = $bargain_data['id'];
if ($bargain_data['father_id'] != 0) {
$bargain_id = $bargain_data['father_id'];
}
$list[$k]['bargain_id'] = empty($bargain_id) ? '' : $bargain_id;
} else {
$list[$k]['bargain_id'] = '';
}
$list[$k]['current_agent_name'] = $list[$k]['store_name'] = "";
if (($v['type'] == 92 || $v['type'] == 91) && $v['bargain_id'] > 0) {
$bargain_where[] = ['EXP', 'a.id =' . $v['bargain_id'] . ' or father_id=' . $v['bargain_id']];
$bargain_where['a.status'] = ['in', '10,11,13'];
$bargain_where['a.role'] = ['in', '3,4,5'];
$bargain_data = $this->m_bargain->agentBargainAll('a.role,a.scale,b.name', $bargain_where);
$role_arr = [1 => '盘方', 2 => '客方', 3 => '反签', 4 => '独家', 5 => '合作方', 6 => 'APP盘下载方', 7 => 'APP客下载方'];
$name = '';
foreach ($bargain_data as $k2 => $v2) {
$name .= $v2['name'] . '(' . $role_arr[$v2['role']] . $v2['scale'] . '%),';
}
$list[$k]['current_agent_name'] = rtrim($name, ',');
}
if ($v['type'] == 10 || $v['type'] == 30) {
if (isset($house_data[0]['f_id'])) {
$current_agent_name = $m_report->selectReportById('report_agent_name,report_store_id', ['id' => $v['f_id']]);
$list[$k]['current_agent_name'] = empty($current_agent_name[0]['report_agent_name']) ? "" : $current_agent_name[0]['report_agent_name'];
}
}
if (!empty($v['income_time'])) {
$income_time = date('Y-m-d H:i:s', strtotime($v['income_time']));
if ($income_time == $v['income_time']) {
$list[$k]['income_time'] = $income_time;
} else {
$list[$k]['income_time'] = '';
}
}
$list[$k]['pay_type_num'] = $v['pay_type'];
$list[$k]['type_num'] = $v['type'];
}
$data['list'] = $list;
// //加时间条件
// if ($is_show) {
// $data['money_total'] = $order->getMoneyTotal($where, 'a.real_money'); //总额
// } else {
// $data['money_total'] = '';
// }
$data['list'] = $this->numberTransitionString($data['list']);
$excel_data = [];
foreach ($data['list'] as $k => $v) {
$excel_data_ = [];
$excel_data_[] = $v['create_time'];//提交时间
$excel_data_[] = $v['id'];//收款ID
$excel_data_[] = $v['order_id'];//带看ID
$excel_data_[] = $v['bargain_id'];//成交报告ID
$excel_data_[] = $v['income_time'];//入账日期
$excel_data_[] = $v['agent_name'];//提交人
$excel_data_[] = $v['current_agent_name'];//对应业务员
// $excel_data_[] = $v['store_name'];//所属门店
$excel_data_[] = $v['type'];//类型
$excel_data_[] = $v['money'];//收款金额
$excel_data_[] = $v['real_money'];//实付金额
$excel_data_[] = $v['transaction_fee'];//手续费
$excel_data_[] = $v['pay_type'];//支付方式
if ($v['source'] == 2) { //调整收款(调整ID:[%= it[item]['source_id'] %])
$excel_data_[] = '调整入账(调整ID:' . $v['source_id'];//来源
} else { //正常收款
$excel_data_[] = '正常入账';//来源
}
if ($v['is_refund'] != 1 && !$v['is_adjustment']) {
$excel_data_[] = '正常';
} else if ($v['is_refund'] == 1 && $v['is_adjustment']) {
$excel_data_[] = '被调整+被退款';
} else if ($v['is_refund'] == 1) {
$excel_data_[] = '被退款';
} else {
$excel_data_[] = '被调整';
}
$excel_data[] = $excel_data_;
}
$export = new ExportExcelUntil();
$title = ['提交时间', '收款ID', '带看ID', '成交报告ID', '入账日期', '提交人', '对应业务员', '类型', '收款金额(元)', '实付金额', '手续费', '支付方式', '来源', '状态'];
$export->exportTable('收款记录', $excel_data, 12, '收款记录', $title);
}
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
return $this->error($msg);
}
}
/** /**
* 返回对应类型 * 返回对应类型
* *
...@@ -3819,98 +3294,6 @@ class Finance extends Basic ...@@ -3819,98 +3294,6 @@ class Finance extends Basic
} }
} }
/**
* 收款详情
*
* @return \think\Response
*/
public function getCollectionDetail()
{
if (empty($this->params['pay_id'])) {
return $this->response(101, '参数错误');
}
$msg = "";
$pay_data = [];
try {
$m_pay = new OPayLogModel();
$pay_fields = 'id,order_id,agent_name,create_time,income_time,house_number,type,real_money,income_time,transfer_name,bargain_id,agent_id,reckon_in_store,';
$pay_fields .= 'transaction_fee,is_dividend,receipt_number,source,pay_type,last_transfer_time,money,industry_type,received_money,type_ext,is_open,open_time';
$pay_data = $m_pay->selectReceiptImgList($pay_fields, ['id' => $this->params['pay_id']]);
$pay_data = $pay_data[0];
//成交报告id
if (empty($pay_data['bargain_id'])) {
$pay_data['bargain_id'] = "";
$pay_data['is_open'] = 0;
$pay_data['price'] = 0;
} else {
$bargain_where['father_id'] = 0;
$bargain_where['id'] = $pay_data['bargain_id'];
$price = $this->m_bargain->getFieldValue('price', $bargain_where);
$pay_data['price'] = empty($price) ? 0 : $price;
}
$m_order = new OrderModel();
$house_data = $m_order->selectOrderByOrderId('b.id,b.internal_address,a.f_id', ['order_id' => $pay_data['order_id']]);
$pay_data['house_id'] = empty($house_data[0]['id']) ? '' : $house_data[0]['id'];
$pay_data['address'] = empty($house_data[0]['internal_address']) ? '' : $house_data[0]['internal_address'];
$m_pay_adjustment = new OPayLogAdjustment();
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $pay_data['id']]);
$pay_data['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$m_refund = new ORefundModel();
$num = $m_refund->getFind('id', ['pay_log_id' => $pay_data['id'], 'is_del' => 0]);
if ($num['id'] > 0) {
$pay_data['is_refund'] = 1;
} else {
$pay_data['is_refund'] = 0;
}
$pay_data['reckon_in_store_name'] = "";
if ($pay_data['reckon_in_store'] > 0) {
$agentModel = new AAgents();
$agentWhere_["b.id"] = $pay_data['reckon_in_store'];
$storeInfo = $agentModel->getAgentsStoreById($agentWhere_, "b.store_name");
$pay_data['reckon_in_store_name'] = $storeInfo['store_name'];
}
$m_report = new OReportModel();
$pay_data['current_agent_name'] = $pay_data['store_name'] = "";
if (($pay_data['type'] == 92 || $pay_data['type'] == 91) && $pay_data['bargain_id'] > 0) {
$where[] = ['EXP', 'a.id =' . $pay_data['bargain_id'] . ' or father_id=' . $pay_data['bargain_id']];
$where['a.status'] = ['in', '10,11,13'];
$where['a.role'] = ['in', '3,4,5'];
$bargain_data = $this->m_bargain->agentBargainAll('a.role,a.scale,b.name', $where);
$role_arr = [1 => '盘方', 2 => '客方', 3 => '反签', 4 => '独家', 5 => '合作方', 6 => 'APP盘下载方', 7 => 'APP客下载方'];
$name = '';
foreach ($bargain_data as $k => $v) {
$name .= $v['name'] . '(' . $role_arr[$v['role']] . $v['scale'] . '%),';
}
$pay_data['current_agent_name'] = rtrim($name, ',');
}
if (($pay_data['type'] == 10 || $pay_data['type'] == 30) && isset($house_data[0]['f_id'])) {
$current_agent_name = $m_report->selectReportById('report_agent_name,report_store_id', ['id' => $house_data[0]['f_id']]);
$pay_data['current_agent_name'] = empty($current_agent_name[0]['report_agent_name']) ? "" : $current_agent_name[0]['report_agent_name'];
}
$pay_data['site_id'] = '';
if ($pay_data['agent_id']) {
$redis_service = new RedisCacheService();
$agent_data = $redis_service->getRedisCache(2, $pay_data['agent_id']);
$pay_data['site_id'] = $agent_data['site_id'];
}
$pay_data['open_time'] = empty($pay_data['open_time']) ? '' : $pay_data['open_time'];
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
}
return $this->response(200, $msg, $pay_data);
}
/** /**
* 编辑收款详情 * 编辑收款详情
* *
......
...@@ -9,8 +9,17 @@ ...@@ -9,8 +9,17 @@
namespace app\index\controller; namespace app\index\controller;
use app\api_broker\service\RedisCacheService;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\index\untils\ExportExcelUntil;
use app\model\AAgents;
use app\model\OBargainModel;
use app\model\OPayLogAdjustment;
use app\model\OPayLogModel; use app\model\OPayLogModel;
use app\model\OPayLogOpen;
use app\model\OrderModel;
use app\model\ORefundModel;
use app\model\OReportModel;
class PayLog extends Basic class PayLog extends Basic
{ {
...@@ -113,4 +122,772 @@ class PayLog extends Basic ...@@ -113,4 +122,772 @@ class PayLog extends Basic
return $this->response($code, $msg); return $this->response($code, $msg);
} }
/**
* 构建搜索条件
*
* @param $params
* @return array
*/
private function buildWhere($params)
{
$where = [];
/*提交时间 start*/
if (!empty($params['start_time']) && empty($params['end_time'])) {
$where['a.create_time'] = ['> time', $params['start_time'] . ' 00:00:00'];
}
if (!empty($params['end_time']) && empty($params['start_time'])) {
$where['a.create_time'] = ['< time', $params['end_time'] . ' 23:59:59'];
}
if (!empty($params['end_time']) && !empty($params['start_time'])) {
$where['a.create_time'] = [
'between time', [
$params['start_time'] . ' 00:00:00', $params['end_time'] . ' 23:59:59'
]
];
}
/*提交时间 end*/
/*入账日期 start*/
if (!empty($params['income_start_time']) && empty($params['income_end_time'])) {
$where['a.income_time'] = ['> time', $params['income_start_time'] . ' 00:00:00'];
}
if (!empty($params['income_end_time']) && empty($params['income_start_time'])) {
$where['a.income_time'] = ['< time', $params['end_time'] . ' 23:59:59'];
}
if (!empty($params['income_end_time']) && !empty($params['income_start_time'])) {
$where['a.income_time'] = [
'between time', [
$params['income_start_time'] . ' 00:00:00', $params['income_end_time'] . ' 23:59:59'
]
];
}
/*入账日期 end*/
/*收款确认日期 start*/
if (!empty($params['open_time_start']) && empty($params['open_end_time'])) {
$where['a.open_time'] = ['> time', $params['open_time_start'] . ' 00:00:00'];
}
if (!empty($params['open_time_end']) && empty($params['open_time_start'])) {
$where['a.open_time'] = ['< time', $params['open_time_end'] . ' 23:59:59'];
}
if (!empty($params['open_time_end']) && !empty($params['open_time_start'])) {
$where['a.open_time'] = [
'between time', [
$params['open_time_start'] . ' 00:00:00', $params['open_time_end'] . ' 23:59:59'
]
];
}
/*入账日期 end*/
//商铺地址
if (!empty($params['internal_address'])) {
$where['d.internal_address'] = ['like', '%' . $params['internal_address'] . '%'];
}
//商铺ID
if (!empty($params['house_id'])) {
$where['b.house_id'] = $params['house_id'];
}
//提交人所在门店
if (!empty($params['store_id'])) {
$where['e.store_id'] = $params['store_id'];
}
//提交人所在部门
if (!empty($params['district_id'])) {
$where['e.district_id'] = $params['district_id'];
}
//提交人姓名
if (!empty($params['agent_id'])) {
$where['a.agent_id'] = $params['agent_id'];
}
//入账方式
if (!empty($params['pay_type'])) {
$where['a.pay_type'] = $params['pay_type'];
}
//入账类型
if (!empty($params['type'])) {
$where['a.type'] = $params['type'];
}
//来源
if ($params['source'] > -1) {
if ($params['source'] == 1) {
$where['a.source'] = ['in', '0,1'];
} else {
$where['a.source'] = $params['source'];
}
}
if (!empty($params['bargain_id'])) {
// $order_id = $this->m_bargain->getFieldValue('order_id', ['id'=>$params['bargain_id'],'father_id'=>0]);
// if (!empty($order_id)) {
// $where[] = ['EXP', 'a.order_id='.$order_id];
// }
$where['a.bargain_id'] = $params['bargain_id'];
}
if (!empty($params['pay_id'])) {
$where['a.id'] = $params['pay_id'];
}
if (!empty($params['order_id'])) {
$where['a.order_id'] = $params['order_id'];
}
if (is_numeric($params['source_type'])) {
if ($params['source_type'] == 1) {
$where['a.source'] = array('neq', 2);
} else {
$where['a.source'] = 2;
}
}
//案场费和中介费是否开业
if (isset($params['is_open'])) {
if ($params['is_open'] == 1) {
$where['a.is_open'] = 1;
} else {
$where['a.is_open'] = 0;
}
if (!isset($where['a.type'])) {
$where['a.type'] = ['in', '91,92'];
}
}
if (isset($params['is_normality']) && $params['is_normality'] == 1) {
$where[] = ['EXP', '(select id from o_refund where pay_log_id=a.id and is_del = 0 group by pay_log_id) is null'];
$where[] = ['EXP', '(select id from o_paylog_adjustment where paylog_id=a.id and is_del = 0 group by paylog_id) is null '];
}
if (!empty($params['is_del'])) {
$where['a.is_del'] = 1;
}
return $where;
}
/**
* 收款记录
*
* @return \think\Response|\think\response\View|void
*/
public function getCollection()
{
if (!$this->request->isAjax() && $this->params['excel'] != 1) {
return view('getCollection');
}
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$data = [];
$where = $this->buildWhere($this->params);
if (empty($where)) {
$is_show = 1;
} else {
$is_show = 0;
}
$where['a.is_del'] = 0;
$msg = '';
try {
$order = new OPayLogModel();
$field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,';
$field .= 'a.transaction_fee,a.source,b.f_id,a.transfer_name,a.receipt_number,a.bargain_id,a.is_open,';
$field .= 'e.name,a.income_time,e.store_id,b.house_id,b.order_no,a.report_id,a.house_number,a.is_dividend,';
$field .= 'a.last_transfer_time,a.industry_type,a.agent_id,d.internal_address as address,e.name as agent_name';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$data['total'] = $order->getAddPayLogOrderListLimitTotal($where);
$m_pay_adjustment = new OPayLogAdjustment();
$m_refund = new ORefundModel();
$m_open = new OPayLogOpen();
foreach ($list as $k => $v) {
$list[$k]['source_id'] = $list[$k]['is_adjustment'] = '';
if ($v['source'] == 2) {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['new_paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$adjustment_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['is_adjustment'] = $adjustment_id ? 1 : 0;
} else {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$list[$k]['is_adjustment'] = $source_id ? 1 : 0;
}
$num = $m_refund->getFind('id', ['pay_log_id' => $v['id'], 'is_del' => 0]);
if ($num['id'] > 0) {
$list[$k]['is_refund'] = 1;
} else {
$list[$k]['is_refund'] = 0;
}
if ($v['type'] != 10 && $v['type'] != 30) {
$list[$k]['bargain_id'] = empty($v['bargain_id']) ? '' : $v['bargain_id'];
} else {
$list[$k]['bargain_id'] = '';
}
if (!empty($v['income_time'])) {
$income_time = date('Y-m-d H:i:s', strtotime($v['income_time']));
if ($income_time == $v['income_time']) {
$list[$k]['income_time'] = $income_time;
} else {
$list[$k]['income_time'] = '';
}
}
$list[$k]['pay_type_num'] = $v['pay_type'];
$list[$k]['type_num'] = $v['type'];
if (empty($v['is_open'])) {
$is_check = $m_open->getFieldOneValue('id', ['pay_log_id' => $v['id'], 'is_del' => 0]);
$list[$k]['is_check'] = $is_check > 0 ? 1 : 0;
} else {
$list[$k]['is_check'] = 0;
}
}
$data['list'] = $list;
//加时间条件
if ($is_show) {
$where['a.source'] = array('neq', 2);
$data['money_total'] = $order->getMoneyTotal($where, 'a.money'); //收款总计(正常)
$where['a.source'] = 2;
$data['money_change_total'] = $order->getMoneyTotal($where, 'a.money'); //收款总计(调整)
$where['a.source'] = array('neq', 2);
$data['real_money_total'] = $order->getMoneyTotal($where, 'a.real_money'); //实付总计(正常)
$where['a.source'] = 2;
$data['real_money_change_total'] = $order->getMoneyTotal($where, 'a.real_money'); //实付总计(调整)
} else {
$data['money_total'] = '';
$data['money_change_total'] = '';
$data['real_money_total'] = '';
$data['real_money_change_total'] = '';
}
$data['list'] = $this->numberTransitionString($data['list']);
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
if ($this->params['excel'] == 1) {
return $this->error($msg);
}
}
return $this->response(200, $msg, $data);
}
/**
* 返回对应类型
*
* @param $data
* @return mixed
*/
public function numberTransitionString($data)
{
//pay_type支付方式 10施总支付宝 11林老师支付宝 20 施总微信 21林老师微信 30pos机器 40地产转账 41世家公账 42 3000账号 50现金 60其他
//type付款类型 10意向金 20定金 30保管金 40押金 50 租金 60 进场费 70转让费 80其他 90佣金 91中介费 92 案场费
foreach ($data as $k => $v) {
switch ($v['type']) {
case 10 :
$data[$k]['type'] = '意向金';
break;
case 20 :
$data[$k]['type'] = '定金';
break;
case 30 :
$data[$k]['type'] = '保管金';
break;
case 40 :
$data[$k]['type'] = '押金';
break;
case 50 :
$data[$k]['type'] = '租金';
break;
case 60 :
$data[$k]['type'] = '进场费';
break;
case 70 :
$data[$k]['type'] = '转让费';
break;
case 80 :
$data[$k]['type'] = '其他';
break;
case 90 :
$data[$k]['type'] = '佣金';
break;
case 91 :
$data[$k]['type'] = '中介费';
break;
case 92 :
$data[$k]['type'] = '案场费';
break;
}
switch ($v['pay_type']) {
case 10 :
$data[$k]['pay_type'] = '施总支付宝';
break;
case 11 :
$data[$k]['pay_type'] = '林老师支付宝';
break;
case 20 :
$data[$k]['pay_type'] = '施总微信';
break;
case 21 :
$data[$k]['pay_type'] = '林老师微信';
break;
case 30 :
if ($v['source'] == 0) {
$data[$k]['pay_type'] = 'POS机器';
} elseif ($v['source'] == 1) {
$data[$k]['pay_type'] = '智能POS机器';
}
break;
case 40 :
$data[$k]['pay_type'] = '地产转账';
break;
case 41 :
$data[$k]['pay_type'] = '世家公账';
break;
case 42 :
$data[$k]['pay_type'] = '3000账号';
break;
case 50 :
$data[$k]['pay_type'] = '现金';
break;
default :
$data[$k]['pay_type'] = '其他';
}
}
return $data;
}
public function getCollectionDel()
{
if (!$this->request->isAjax()) {
return view('delFinanceReport');
}
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$data = [];
$where = $this->buildWhere($this->params);
$msg = '';
try {
$order = new OPayLogModel();
$field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,';
$field .= 'a.transaction_fee,a.source,b.f_id,a.transfer_name,a.receipt_number,a.bargain_id,a.is_open,';
$field .= 'e.name,a.income_time,e.store_id,b.house_id,b.order_no,a.report_id,a.house_number,a.is_dividend,';
$field .= 'a.last_transfer_time,a.industry_type,a.agent_id,d.internal_address as address,e.name as agent_name';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$data['total'] = $order->getAddPayLogOrderListLimitTotal($where);
$m_pay_adjustment = new OPayLogAdjustment();
$m_refund = new ORefundModel();
$m_open = new OPayLogOpen();
foreach ($list as $k => $v) {
$list[$k]['source_id'] = $list[$k]['is_adjustment'] = '';
if ($v['source'] == 2) {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['new_paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$adjustment_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['is_adjustment'] = $adjustment_id ? 1 : 0;
} else {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$list[$k]['is_adjustment'] = $source_id ? 1 : 0;
}
$num = $m_refund->getFind('id', ['pay_log_id' => $v['id'], 'is_del' => 0]);
if ($num['id'] > 0) {
$list[$k]['is_refund'] = 1;
} else {
$list[$k]['is_refund'] = 0;
}
if ($v['type'] != 10 && $v['type'] != 30) {
$list[$k]['bargain_id'] = empty($v['bargain_id']) ? '' : $v['bargain_id'];
} else {
$list[$k]['bargain_id'] = '';
}
if (!empty($v['income_time'])) {
$income_time = date('Y-m-d H:i:s', strtotime($v['income_time']));
if ($income_time == $v['income_time']) {
$list[$k]['income_time'] = $income_time;
} else {
$list[$k]['income_time'] = '';
}
}
$list[$k]['pay_type_num'] = $v['pay_type'];
$list[$k]['type_num'] = $v['type'];
if (empty($v['is_open'])) {
$is_check = $m_open->getFieldOneValue('id', ['pay_log_id' => $v['id'], 'is_del' => 0]);
$list[$k]['is_check'] = $is_check > 0 ? 1 : 0;
} else {
$list[$k]['is_check'] = 0;
}
}
$data['list'] = $this->numberTransitionString($list);
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
if ($this->params['excel'] == 1) {
return $this->error($msg);
}
}
return $this->response(200, $msg, $data);
}
/**
* 收款记录 Excel
*/
public function getCollectionExcel()
{
set_time_limit(0);
$pageNo = 1;
$pageSize = 10000;
$data = [];
$where['a.is_del'] = 0;
/*提交时间 start*/
if (!empty($this->params['start_time']) && empty($this->params['end_time'])) {
$where['a.create_time'] = ['> time', $this->params['start_time'] . ' 00:00:00'];
}
if (!empty($this->params['end_time']) && empty($this->params['start_time'])) {
$where['a.create_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
}
if (!empty($this->params['end_time']) && !empty($this->params['start_time'])) {
$where['a.create_time'] = [
'between time', [
$this->params['start_time'] . ' 00:00:00', $this->params['end_time'] . ' 23:59:59'
]
];
}
/*提交时间 end*/
/*入账日期 start*/
if (!empty($this->params['income_start_time']) && empty($this->params['income_end_time'])) {
$where['a.income_time'] = ['> time', $this->params['income_start_time'] . ' 00:00:00'];
}
if (!empty($this->params['income_end_time']) && empty($this->params['income_start_time'])) {
$where['a.income_time'] = ['< time', $this->params['end_time'] . ' 23:59:59'];
}
if (!empty($this->params['income_end_time']) && !empty($this->params['income_start_time'])) {
$where['a.income_time'] = [
'between time', [
$this->params['income_start_time'] . ' 00:00:00', $this->params['income_end_time'] . ' 23:59:59'
]
];
}
/*入账日期 end*/
//商铺地址
if (!empty($this->params['internal_address'])) {
$where['d.internal_address'] = ['like', '%' . $this->params['internal_address'] . '%'];
}
//商铺ID
if (!empty($this->params['house_id'])) {
$where['b.house_id'] = $this->params['house_id'];
}
//提交人所在门店
if (!empty($this->params['store_id'])) {
$where['e.store_id'] = $this->params['store_id'];
}
//提交人所在部门
if (!empty($this->params['district_id'])) {
$where['e.district_id'] = $this->params['district_id'];
}
//提交人姓名
if (!empty($this->params['agent_id'])) {
$where['a.agent_id'] = $this->params['agent_id'];
}
//入账方式
if (!empty($this->params['pay_type'])) {
$where['a.pay_type'] = $this->params['pay_type'];
}
//入账类型
if (!empty($this->params['type'])) {
$where['a.type'] = $this->params['type'];
}
//来源
if ($this->params['source'] > -1) {
$where['a.source'] = $this->params['source'];
}
$m_bargain = new OBargainModel();
if (!empty($this->params['bargain_id'])) {
$order_id = $m_bargain->getFieldValue('order_id', ['id' => $this->params['bargain_id'], 'father_id' => 0]);
if (!empty($order_id)) {
$where[] = ['EXP', 'a.order_id=' . $order_id];
}
}
if (!empty($this->params['pay_id'])) {
$where['a.id'] = $this->params['pay_id'];
}
if (!empty($this->params['order_id'])) {
$where['a.order_id'] = $this->params['order_id'];
}
if (!empty($this->params['bargain_id'])) {
$where['a.bargain_id'] = $this->params['bargain_id'];
}
//案场费和中介费是否开业
if (isset($this->params['is_open'])) {
if ($this->params['is_open'] == 1) {
$where['a.is_open'] = 1;
} else {
$where['a.is_open'] = 0;
}
$where['a.type'] = ['in', '91,92'];
}
if (isset($this->params['is_normality']) && $this->params['is_normality'] == 1) {
$where[] = ['EXP', '(select id from o_refund where pay_log_id=a.id and is_del = 0 group by pay_log_id) is null'];
$where[] = ['EXP', '(select id from o_paylog_adjustment where paylog_id=a.id and is_del = 0 group by paylog_id) is null '];
}
try {
$order = new OPayLogModel();
if (empty($this->params['excel'])) {
$field = 'a.id,a.create_time,a.order_id,a.father_id,a.money,a.real_money,a.pay_type,a.type,a.source,a.transaction_fee,a.source,b.f_id,a.transfer_name,a.receipt_number,a.bargain_id,';
$field .= 'e.name,a.income_time,e.store_id,b.house_id,b.order_no,a.report_id,a.house_number,a.is_dividend,a.last_transfer_time,a.industry_type,a.agent_id,d.internal_address as address,e.name as agent_name';
$list = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$m_pay_adjustment = new OPayLogAdjustment();
$m_report = new OReportModel();
$m_refund = new ORefundModel();
foreach ($list as $k => $v) {
$list[$k]['source_id'] = $list[$k]['is_adjustment'] = '';
if ($v['source'] == 2) {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['new_paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$adjustment_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['is_adjustment'] = $adjustment_id ? 1 : 0;
} else {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $v['id'], 'is_del' => 0]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$list[$k]['is_adjustment'] = $source_id ? 1 : 0;
}
$num = $m_refund->getFind('id', ['pay_log_id' => $v['id'], 'is_del' => 0]);
if ($num['id'] > 0) {
$list[$k]['is_refund'] = 1;
} else {
$list[$k]['is_refund'] = 0;
}
if ($v['type'] != 10 && $v['type'] != 30) {
$bargain_data = $m_bargain->getDetail('id,father_id', ['order_id' => $v['order_id']]);
$bargain_id = $bargain_data['id'];
if ($bargain_data['father_id'] != 0) {
$bargain_id = $bargain_data['father_id'];
}
$list[$k]['bargain_id'] = empty($bargain_id) ? '' : $bargain_id;
} else {
$list[$k]['bargain_id'] = '';
}
$list[$k]['current_agent_name'] = $list[$k]['store_name'] = "";
if (($v['type'] == 92 || $v['type'] == 91) && $v['bargain_id'] > 0) {
$bargain_where[] = ['EXP', 'a.id =' . $v['bargain_id'] . ' or father_id=' . $v['bargain_id']];
$bargain_where['a.status'] = ['in', '10,11,13'];
$bargain_where['a.role'] = ['in', '3,4,5'];
$bargain_data = $m_bargain->agentBargainAll('a.role,a.scale,b.name', $bargain_where);
$role_arr = [1 => '盘方', 2 => '客方', 3 => '反签', 4 => '独家', 5 => '合作方', 6 => 'APP盘下载方', 7 => 'APP客下载方'];
$name = '';
foreach ($bargain_data as $k2 => $v2) {
$name .= $v2['name'] . '(' . $role_arr[$v2['role']] . $v2['scale'] . '%),';
}
$list[$k]['current_agent_name'] = rtrim($name, ',');
}
if ($v['type'] == 10 || $v['type'] == 30) {
if (isset($house_data[0]['f_id'])) {
$current_agent_name = $m_report->selectReportById('report_agent_name,report_store_id', ['id' => $v['f_id']]);
$list[$k]['current_agent_name'] = empty($current_agent_name[0]['report_agent_name']) ? "" : $current_agent_name[0]['report_agent_name'];
}
}
if (!empty($v['income_time'])) {
$income_time = date('Y-m-d H:i:s', strtotime($v['income_time']));
if ($income_time == $v['income_time']) {
$list[$k]['income_time'] = $income_time;
} else {
$list[$k]['income_time'] = '';
}
}
$list[$k]['pay_type_num'] = $v['pay_type'];
$list[$k]['type_num'] = $v['type'];
}
$data['list'] = $list;
$data['list'] = $this->numberTransitionString($data['list']);
$excel_data = [];
foreach ($data['list'] as $k => $v) {
$excel_data_ = [];
$excel_data_[] = $v['create_time'];//提交时间
$excel_data_[] = $v['id'];//收款ID
$excel_data_[] = $v['order_id'];//带看ID
$excel_data_[] = $v['bargain_id'];//成交报告ID
$excel_data_[] = $v['income_time'];//入账日期
$excel_data_[] = $v['agent_name'];//提交人
$excel_data_[] = $v['current_agent_name'];//对应业务员
// $excel_data_[] = $v['store_name'];//所属门店
$excel_data_[] = $v['type'];//类型
$excel_data_[] = $v['money'];//收款金额
$excel_data_[] = $v['real_money'];//实付金额
$excel_data_[] = $v['transaction_fee'];//手续费
$excel_data_[] = $v['pay_type'];//支付方式
if ($v['source'] == 2) { //调整收款(调整ID:[%= it[item]['source_id'] %])
$excel_data_[] = '调整入账(调整ID:' . $v['source_id'];//来源
} else { //正常收款
$excel_data_[] = '正常入账';//来源
}
if ($v['is_refund'] != 1 && !$v['is_adjustment']) {
$excel_data_[] = '正常';
} else if ($v['is_refund'] == 1 && $v['is_adjustment']) {
$excel_data_[] = '被调整+被退款';
} else if ($v['is_refund'] == 1) {
$excel_data_[] = '被退款';
} else {
$excel_data_[] = '被调整';
}
$excel_data[] = $excel_data_;
}
$export = new ExportExcelUntil();
$title = ['提交时间', '收款ID', '带看ID', '成交报告ID', '入账日期', '提交人', '对应业务员', '类型', '收款金额(元)', '实付金额', '手续费', '支付方式', '来源', '状态'];
$export->exportTable('收款记录', $excel_data, 12, '收款记录', $title);
}
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
return $this->error($msg);
}
}
/**
* 收款详情
*
* @return \think\Response
*/
public function getCollectionDetail()
{
if (empty($this->params['pay_id'])) {
return $this->response(101, '参数错误');
}
$msg = "";
$pay_data = [];
try {
$m_pay = new OPayLogModel();
$pay_fields = 'id,order_id,agent_name,create_time,income_time,house_number,type,real_money,income_time,transfer_name,bargain_id,agent_id,reckon_in_store,';
$pay_fields .= 'transaction_fee,is_dividend,receipt_number,source,pay_type,last_transfer_time,money,industry_type,received_money,type_ext,is_open,open_time';
$pay_data = $m_pay->selectReceiptImgList($pay_fields, ['id' => $this->params['pay_id']]);
$pay_data = $pay_data[0];
//成交报告id
if (empty($pay_data['bargain_id'])) {
$pay_data['bargain_id'] = "";
$pay_data['is_open'] = 0;
$pay_data['price'] = 0;
} else {
$m_bargain = new OBargainModel();
$bargain_where['father_id'] = 0;
$bargain_where['id'] = $pay_data['bargain_id'];
$price = $m_bargain->getFieldValue('price', $bargain_where);
$pay_data['price'] = empty($price) ? 0 : $price;
}
$m_order = new OrderModel();
$house_data = $m_order->selectOrderByOrderId('b.id,b.internal_address,a.f_id', ['order_id' => $pay_data['order_id']]);
$pay_data['house_id'] = empty($house_data[0]['id']) ? '' : $house_data[0]['id'];
$pay_data['address'] = empty($house_data[0]['internal_address']) ? '' : $house_data[0]['internal_address'];
$m_pay_adjustment = new OPayLogAdjustment();
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id' => $pay_data['id']]);
$pay_data['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
$m_refund = new ORefundModel();
$num = $m_refund->getFind('id', ['pay_log_id' => $pay_data['id'], 'is_del' => 0]);
if ($num['id'] > 0) {
$pay_data['is_refund'] = 1;
} else {
$pay_data['is_refund'] = 0;
}
$pay_data['reckon_in_store_name'] = "";
if ($pay_data['reckon_in_store'] > 0) {
$agentModel = new AAgents();
$agentWhere_["b.id"] = $pay_data['reckon_in_store'];
$storeInfo = $agentModel->getAgentsStoreById($agentWhere_, "b.store_name");
$pay_data['reckon_in_store_name'] = $storeInfo['store_name'];
}
$m_bargain = new OBargainModel();
$m_report = new OReportModel();
$pay_data['current_agent_name'] = $pay_data['store_name'] = "";
if (($pay_data['type'] == 92 || $pay_data['type'] == 91) && $pay_data['bargain_id'] > 0) {
$where[] = ['EXP', 'a.id =' . $pay_data['bargain_id'] . ' or father_id=' . $pay_data['bargain_id']];
$where['a.status'] = ['in', '10,11,13'];
$where['a.role'] = ['in', '3,4,5'];
$bargain_data = $m_bargain->agentBargainAll('a.role,a.scale,b.name', $where);
$role_arr = [1 => '盘方', 2 => '客方', 3 => '反签', 4 => '独家', 5 => '合作方', 6 => 'APP盘下载方', 7 => 'APP客下载方'];
$name = '';
foreach ($bargain_data as $k => $v) {
$name .= $v['name'] . '(' . $role_arr[$v['role']] . $v['scale'] . '%),';
}
$pay_data['current_agent_name'] = rtrim($name, ',');
}
if (($pay_data['type'] == 10 || $pay_data['type'] == 30) && isset($house_data[0]['f_id'])) {
$current_agent_name = $m_report->selectReportById('report_agent_name,report_store_id', ['id' => $house_data[0]['f_id']]);
$pay_data['current_agent_name'] = empty($current_agent_name[0]['report_agent_name']) ? "" : $current_agent_name[0]['report_agent_name'];
}
$pay_data['site_id'] = '';
if ($pay_data['agent_id']) {
$redis_service = new RedisCacheService();
$agent_data = $redis_service->getRedisCache(2, $pay_data['agent_id']);
$pay_data['site_id'] = $agent_data['site_id'];
}
$pay_data['open_time'] = empty($pay_data['open_time']) ? '' : $pay_data['open_time'];
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
}
return $this->response(200, $msg, $pay_data);
}
} }
\ No newline at end of file
...@@ -272,10 +272,10 @@ Route::group('index', [ ...@@ -272,10 +272,10 @@ Route::group('index', [
'searchOrderAgents' => ['index/Finance/searchOrderAgents', ['method' => 'GET']], //order_id获取盘方,客方,反签,独家,合作方 'searchOrderAgents' => ['index/Finance/searchOrderAgents', ['method' => 'GET']], //order_id获取盘方,客方,反签,独家,合作方
'getTallAgeList' => ['index/Finance/getTallAgeList', ['method' => 'GET']], //税费承担明细表 'getTallAgeList' => ['index/Finance/getTallAgeList', ['method' => 'GET']], //税费承担明细表
'getCommissionTotalList' => ['index/Finance/getCommissionTotalList', ['method' => 'GET']], //分佣提成汇总表 'getCommissionTotalList' => ['index/Finance/getCommissionTotalList', ['method' => 'GET']], //分佣提成汇总表
'getCollection' => ['index/Finance/getCollection', ['method' => 'post|get']],//收款记录 'getCollection' => ['index/PayLog/getCollection', ['method' => 'post|get']],//收款记录
'getCollectionDel' => ['index/Finance/getCollection', ['method' => 'post|get']],//收款记录删除 'getCollectionDel' => ['index/PayLog/getCollectionDel', ['method' => 'post|get']],//收款记录删除
'getCollectionDaily' => ['index/Finance/getCollection', ['method' => 'post|get']],//收款记录(财务日报用) 'getCollectionDaily' => ['index/PayLog/getCollection', ['method' => 'post|get']],//收款记录(财务日报用)
'getCollectionExcel' => ['index/Finance/getCollectionExcel', ['method' => 'post|get']],//收款记录 'getCollectionExcel' => ['index/PayLog/getCollectionExcel', ['method' => 'post|get']],//收款记录
'addRealMoney' => ['index/Finance/addRealMoney', ['method' => 'post|get']],//新增实收 'addRealMoney' => ['index/Finance/addRealMoney', ['method' => 'post|get']],//新增实收
'visitShop' => ['index/Supervise/visitShop', ['method' => 'get']],//门店拜访 'visitShop' => ['index/Supervise/visitShop', ['method' => 'get']],//门店拜访
'carryOut' => ['index/Supervise/carryOut', ['method' => 'get']],//监督执行 'carryOut' => ['index/Supervise/carryOut', ['method' => 'get']],//监督执行
...@@ -289,7 +289,7 @@ Route::group('index', [ ...@@ -289,7 +289,7 @@ Route::group('index', [
'addReceiptImg' => ['index/Finance/addReceiptImg', ['method' => 'post|get']],//收款图片信息保存 'addReceiptImg' => ['index/Finance/addReceiptImg', ['method' => 'post|get']],//收款图片信息保存
'deleteReceiptImg' => ['index/Finance/deleteReceiptImg', ['method' => 'post|get']],//删除收款图片 'deleteReceiptImg' => ['index/Finance/deleteReceiptImg', ['method' => 'post|get']],//删除收款图片
'receiptImgList' => ['index/Finance/receiptImgList', ['method' => 'post|get']],//收款列表-收款图片列表 'receiptImgList' => ['index/Finance/receiptImgList', ['method' => 'post|get']],//收款列表-收款图片列表
'getCollectionDetail' => ['index/Finance/getCollectionDetail', ['method' => 'post|get']],//收款详情 'getCollectionDetail' => ['index/PayLog/getCollectionDetail', ['method' => 'post|get']],//收款详情
'getCollectionEdit' => ['index/Finance/getCollectionEdit', ['method' => 'post']],//收款修改保存 'getCollectionEdit' => ['index/Finance/getCollectionEdit', ['method' => 'post']],//收款修改保存
'collectingBill' => ['index/Finance/collectingBill', ['method' => 'post']],//收款 'collectingBill' => ['index/Finance/collectingBill', ['method' => 'post']],//收款
'getBeForNum' => ['index/Finance/getBeForNum', ['method' => 'get']],//获取上次提交收款的门牌号等 'getBeForNum' => ['index/Finance/getBeForNum', ['method' => 'get']],//获取上次提交收款的门牌号等
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment