Commit a3c0c928 authored by zhuwei's avatar zhuwei

excel

parent b5aa7b10
......@@ -3044,19 +3044,22 @@ class Finance extends Basic
} else {
$pageNo = 1;
$pageSize = 50000; //最多5万条数据
$field = 'a.create_time,c.user_name,c.user_phone,c.report_agent_name,c.report_agent_phone,f.store_name,g.district_name,a.money,a.real_money,a.transaction_fee,a.type,a.pay_type,d.internal_address,a.house_number,a.source';
$data = $order->getAddPayLogOrderListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$field = 'a.id,a.create_time,c.user_name,c.user_phone,c.report_agent_name,c.report_agent_phone,
f.store_name,g.district_name,a.money,a.real_money,a.transaction_fee,a.type,a.pay_type,
d.internal_address,a.house_number,a.source';
$data = $order->getAddPayLogOrderListLimitExcel($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
foreach ($data as $k => $v) {
if (!empty($v['user_phone'])) {
$data[$k]['user_phone'] = substr_replace($v['user_phone'], '****', 3, 4);
}
}
$data = $this->numberTransitionString($data);
$export = new ExportExcelUntil();
$title = ['收款时间', '客户姓名', '客户手机号', '约带看人姓名', '约带看人手机号', '约带看人所属门店', '约带看人所属部门', '收款金额(元)', '实付金额(元)', '手续费(元)', '入账类型', '入账方式', '商铺地址', '商铺号'];
$export->exportTable('收款记录', $data, 9, '收款记录', $title);
$title = ['提交时间', '收款ID', '带看ID', '成交报告ID', '入账日期', '提交人', '对应业务员', '所属门店', '类型', '收款金额(元)', '实付金额', '来源', '状态'];
$export->exportTable('收款记录', $excel_data, 14, '收款记录', $title);
}
} catch (\Exception $e) {
$msg = '内部错误:' . $e->getMessage();
......@@ -3068,6 +3071,245 @@ class Finance extends Basic
return $this->response(200, $msg, $data);
}
public function getCollectionExcel() {
$pageNo = 1;
$pageSize = 40000;
$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*/
//商铺地址
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) {
$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];
}
$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 (!empty($this->params['bargain_id'])) {
$where['a.bargain_id'] = $this->params['bargain_id'];
}
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,';
$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);
$data['total'] = $order->getAddPayLogOrderListLimitTotal($where);
$m_store = new AStore();
$m_pay_adjustment = new OPayLogAdjustment();
$m_report = new OReportModel();
$m_agent_house = new GHousesToAgents();
$m_house = new GHouses();
$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) {
$is_exclusive_type = $m_house->getHouseValue('is_exclusive_type', ['id'=>$v['house_id']]);
//案场费 对应业务员:盘方
$current_where['a.is_del'] = 0;
if ($is_exclusive_type) {
$current_where['a.type'] = 3;
} else {
$current_where['a.type'] = 2;
}
$current_agent_name = $m_agent_house->getHousesAgents($v['house_id'], 'b.name,b.store_id', $current_where);
$list[$k]['current_agent_name'] = empty($current_agent_name[0]['name']) ? '':$current_agent_name[0]['name'];
$store_name = $m_store->getStoreKeyById('store_name', ['id'=>$current_agent_name[0]['store_id']]);
$list[$k]['store_name'] = empty($store_name)? '' : $store_name;
}
if ($v['type'] == 10 || $v['type'] == 30 || $v['type'] == 91) {
//意向金/保管金 10/30 对应业务员:约带看的人 即 反签方
//中介费 对应业务员:约带看的人 即 反签方
$current_agent_name = $m_report->selectReportById('report_agent_name,report_store_id', ['id'=>$v['f_id']]);
if (!empty($current_agent_name[0]['report_store_id'])) {
$store_name = $m_store->getStoreKeyById('store_name', ['id'=>$current_agent_name[0]['report_store_id']]);
$list[$k]['store_name'] = empty($store_name)? '' : $store_name;
}
$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']);
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['name'];//对应业务员
$excel_data_[] = $v['store_name'];//所属门店
$excel_data_[] = $v['type'];//类型
$excel_data_[] = $v['store_name'];//收款金额
$excel_data_[] = $v['real_money'];//实付金额
$excel_data_[] = $v['address'];//来源
$excel_data_[] = $v['address'];//状态
$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);
}
}
/**
* 返回对应类型
*
......
......@@ -348,6 +348,24 @@ class OPayLogModel extends Model
->select();
}
public function getAddPayLogOrderListLimitExcel($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '')
{
$params["a.is_del"] = 0;
return $this->db_->field($field)
->alias("a")
->join("o_order b", "a.order_id = b.id", "left")
->join("o_report c", "a.report_id = c.id", "left")
->join('g_houses d', 'b.house_id = d.id', 'left')
->join('a_agents e', 'a.agent_id=e.id', 'left')
->join('a_store f', 'e.store_id=f.id', 'left')
->join('a_district g', 'e.district_id=g.id', 'left')
->limit($pageSize)
->page($pageNo)
->order($order_)
->where($params)
->select();
}
/**
* 收款记录总数
*
......
......@@ -260,6 +260,7 @@ Route::group('index', [
'getTallAgeList' => ['index/Finance/getTallAgeList', ['method' => 'GET']], //税费承担明细表
'getCommissionTotalList' => ['index/Finance/getCommissionTotalList', ['method' => 'GET']], //分佣提成汇总表
'getCollection' => ['index/Finance/getCollection', ['method' => 'post|get']],//收款记录
'getCollectionExcel' => ['index/Finance/getCollectionExcel', ['method' => 'post|get']],//收款记录
'addRealMoney' => ['index/Finance/addRealMoney', ['method' => 'post|get']],//新增实收
'visitShop' => ['index/Supervise/visitShop', ['method' => 'get']],//门店拜访
'carryOut' => ['index/Supervise/carryOut', ['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