Commit 50d355f2 authored by hujun's avatar hujun

调整办公楼

parent c9be9c15
......@@ -4901,9 +4901,8 @@ class Finance extends Basic
$list[$k]['type_num'] = $v['type'];
}
$m_paylog_adjustment = new OPayLogAdjustment();
$field = 'a.create_time,a.id,b.order_id,a.paylog_id,a.money,b.income_time,a.type,a.new_paylog_id,a.operation_id,b.order_id,e.house_id';
$list_2 = $m_paylog_adjustment->getAdjustmentListLimit(1, 1000, '', $field, $where_2);
$list_2 = $m_pay_adjustment->getAdjustmentListLimit(1, 1000, '', $field, $where_2);
foreach ($list_2 as $k => $v) {
$list_2[$k]['name'] = $m_agent->getAgentsById($v['operation_id'], 'name');
if ($v['house_id']) {
......
......@@ -8,8 +8,11 @@ use app\api_broker\service\OfficePayLogService;
use app\api_broker\service\RedisCacheService;
use app\index\extend\Basic;
use app\index\untils\ExportExcelUntil;
use app\model\AAgents;
use app\model\AStore;
use app\model\OfficeGBuilding;
use app\model\OfficeGRoom;
use app\model\OfficeGRoomToAgent;
use app\model\OfficeOBargainModel;
use app\model\OfficeOImg;
use app\model\OfficeOPayLogAdjustment;
......@@ -1393,4 +1396,383 @@ class OfficePayLog extends Basic
}
return $this->response("200", "request success", $data);
}
/**
* 收款列表-删除上传图片
* 朱伟 2018-07-04
*/
public function deleteReceiptImg(){
$params = $this->params;
/*$params = array(
"id" => 3,
"img_name" => 123,
);*/
if(!isset($params["id"])){
return $this->response("101","请求参数错误");
}
$time = date("Y-m-d H:i:s", time());
$save_data["id"] = $params["id"];//id根据img_type区分是收款还是进场还是其他'
$save_data["img_status"] = 1 ;//删除状态 0正常 1删除
$save_data["update_time"] = $time;//更新时间
$order = new OfficeOImg();
$res = $order->updateImgStatus($save_data);
if($res){
return $this->response("200","成功");
}else{
return $this->response("101","失败");
}
}
/**
* 收款列表状态详情
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getPayLogData() {
if (empty($this->params['pay_id'])) {
return $this->response(101, '参数错误');
}
$m_store = new AStore();
$m_pay_adjustment = new OfficeOPayLogAdjustment();
$m_report = new OfficeOReportModel();
$m_agent_house = new OfficeGRoomToAgent();
$m_refund = new officeORefundModel();
$m_agent = new AAgents();
$m_paylog = new officeOPayLogModel();
$m_room = new OfficeGRoom();
$m_building = new OfficeGBuilding();
$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,g.address,e.name as agent_name';
$where['a.is_del'] = $where_2['a.is_del'] = $where_3['a.is_del'] = 0;
$where_2['a.paylog_id'] = $where_3['a.pay_log_id'] = $this->params['pay_id'];
$adjustment_id = $m_pay_adjustment->getFieldColumn('new_paylog_id',['paylog_id'=>$this->params['pay_id']]);
if ($adjustment_id) {
$sql_where = ' or a.id in ('.implode(',',$adjustment_id).')';
}
$where[] = ['EXP','a.father_id='.$this->params['pay_id']. $sql_where];
$list = $m_paylog->getAddPayLogOrderListLimit(1, 1000, '', $field, $where);
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']]);
$list[$k]['source_id'] = empty($source_id) ? 0 : implode(',', $source_id);
} else {
$source_id = $m_pay_adjustment->getFieldColumn('id', ['paylog_id'=> $v['id']]);
$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_room->getFieldOneValue('is_exclusive_type', ['id'=>$v['house_id']]);
//案场费 对应业务员:盘方
$current_where['a.house_id'] = $v['house_id'];
if ($is_exclusive_type) {
$current_where['a.type'] = 3;
} else {
$current_where['a.type'] = 2;
}
$current_agent_name = $m_agent_house->getAgentsByRoomId('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'];
}
$field = 'a.create_time,a.id,b.order_id,a.paylog_id,a.money,b.income_time,a.type,a.new_paylog_id,a.operation_id,b.order_id,e.house_id';
$list_2 = $m_pay_adjustment->getAdjustmentListLimit(1, 1000, '', $field, $where_2);
foreach ($list_2 as $k => $v) {
$list_2[$k]['name'] = $m_agent->getAgentsById($v['operation_id'], 'name');
if ($v['house_id']) {
$house_data = $m_building->getFindData('id,address', ['id'=>$v['house_id']]);
$list_2[$k]['house_id'] = $house_data['id'];
$list_2[$k]['address'] = $house_data['address'];
} else {
$list_2[$k]['house_id'] = '';
$list_2[$k]['address'] = '';
}
}
$fields = 'a.create_time,a.id,a.order_id,a.pay_log_id,a.refund_money,a.type,a.agent_id,a.agent_name,b.house_id,a.status,';
$fields .= 'd.income_time,a.type,c.store_id';
$list_3 = $m_refund->getCheckRefundList(1, 1000, '', $fields, $where_3);
foreach ($list_3 as $k=>$v) {
if (empty($v['house_id'])) {
$list_3[$k]['address'] = '';
} else {
$list_3[$k]['address'] = $m_building->getFieldOneValue('address', ['id'=>$v['house_id']]);
}
if (empty($v['store_id'])) {
$list_3[$k]['store_name'] = '';
} else {
$list_3[$k]['store_name'] = $m_store->getStoreKeyById('store_name', ['id'=> $v['store_id']]);
}
}
$data['pay_log'] = $list;
$data['pay_log_adjustment'] = $list_2;
$data['pay_log_refund'] = $list_3;
return $this->response(200, '', $data);
}
/**
* 调整出账
* @return \think\Response
*/
public function adjustmentList() {
// if (!$this->request->isAjax() && empty($this->params['excel'])) {
// return view("adjustment");
// }
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$data = [];
$where['a.is_del'] = $is_show = 0;
$msg = '';
$code = 200;
$m_paylog = new OfficeOPayLogAdjustment();
$m_house = new OfficeGRoom();
/*提交时间 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['b.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['b.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['b.income_time'] = ['between time', [
$this->params['income_start_time'] . ' 00:00:00', $this->params['income_end_time'] . ' 23:59:59'
]];
$is_show = 1;
}
/*入账日期 end*/
//商铺ID
if (!empty($this->params['house_id'])) {
$where['e.house_id'] = $this->params['house_id'];
$is_show = 1;
}
//商铺地址
if (!empty($this->params['address'])) {
$id = $m_house->getRoomInfo( 'a.id',['b.address'=>['like', '%' . $this->params['address'] . '%']]);
foreach ($id as $v) {
$id_arr[] = $v['id'];
}
if (!empty($where['e.house_id'])) {
$id_arr[] = $where['e.house_id'];
}
if (!empty($id_arr)) {
$id_arr = array_unique($id_arr);
$where['e.house_id'] = ['in', $id_arr];
}
$is_show = 1;
}
//提交人所在门店
if (!empty($this->params['store_id'])) {
$where['d.store_id'] = $this->params['store_id'];
$is_show = 1;
}
//提交人所在部门
if (!empty($this->params['district_id'])) {
$where['d.district_id'] = $this->params['district_id'];
$is_show = 1;
}
//提交人姓名
if (!empty($this->params['agent_id'])) {
$where['d.id'] = $this->params['agent_id'];
$is_show = 1;
}
//提交人手机号
if (!empty($this->params['phone'])) {
$where['d.phone'] = ['like', '%' . $this->params['phone'] . '%'];
$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 (!empty($this->params['source'])) {
$where['a.source'] = $this->params['source'];
$is_show = 1;
}
if (!empty($this->params['pay_id'])) {
$where['a.paylog_id'] = $this->params['pay_id'];
}
if (!empty($this->params['id'])) {
$where['a.id'] = $this->params['id'];
}
if (!empty($this->params['march_id'])) {
$where['b.order_id'] = $this->params['march_id'];
}
$field = 'a.create_time,a.id,b.order_id,e.house_id,a.paylog_id,a.money,b.income_time,a.type,a.new_paylog_id,a.operation_id';
$redis_service = new RedisCacheService();
if (empty($this->params['excel'])) {
$list = $m_paylog->getAdjustmentListLimit($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where);
$data['total'] = $m_paylog->getAdjustmentListTotal($where);
//加时间条件
if ($is_show) {
$data['money_total'] = $m_paylog->getMoneyTotal($where, 'a.money'); //总额
} else {
$data['money_total'] = '';
}
foreach ($list as $k => $v) {
if ($v['operation_id']) {
$agent_data = $redis_service->getRedisCache(2, $v['operation_id']);
$list[$k]['name'] = $agent_data['name'];
}
if ($v['house_id']) {
$house_data = $m_house->getHouseDetail('a.id,b.address', ['a.id'=>$v['house_id']]);
$list[$k]['house_id'] = $house_data['id'];
$list[$k]['address'] = $house_data['address'];
} else {
$list[$k]['house_id'] = '';
$list[$k]['address'] = '';
}
}
$data['list'] = $list;
$data['list'] = $this->numberTransitionString($data['list']);
} else {
$list = $m_paylog->getAdjustmentListLimit(1, 40000, $order_ = 'a.id desc', $field, $where);
if (empty($list)) {
$this->closeWin = 1;
$this->error('暂无数据,请关闭页面!');
} else {
$excel_data = [];
foreach ($list as $k => $v) {
$excel_data[$k]['create_time'] = $v['create_time'];
$excel_data[$k]['id'] = $v['id'];
$excel_data[$k]['order_id'] = $v['order_id'];
$excel_data[$k]['paylog_id'] = $v['paylog_id'];
if ($v['house_id']) {
$house_data = $m_house->getHouseDetail('a.id,b.address', ['a.id' => $v['house_id']]);
$excel_data[$k]['house_id'] = $house_data['id'];
$excel_data[$k]['address'] = $house_data['address'];
} else {
$excel_data[$k]['house_id'] = '';
$excel_data[$k]['address'] = '';
}
$excel_data[$k]['money'] = $v['money'];
$excel_data[$k]['income_time'] = $v['income_time'];
$excel_data[$k]['type_name'] = $this->getAdjustmentType($v['type']);
$excel_data[$k]['new_paylog_id'] = $v['new_paylog_id'];
if ($v['operation_id']) {
$agent_data = $redis_service->getRedisCache(2, $v['operation_id']);
$excel_data[$k]['name'] = $agent_data['name'];
}
}
$export = new ExportExcelUntil();
$title = ['提交时间', '调整ID', '调整前带看ID', '调整前收款ID', '调整前商铺ID', '调整前商铺地址', '调整金额', '入账日期', '调整类型', '调整后收款ID', '提交人'];
$export->exportTable('调整出账', $excel_data, 10, '调整出账', $title);
}
}
return $this->response($code, $msg, $data);
}
}
\ No newline at end of file
......@@ -373,7 +373,7 @@ Route::group('index', [
'remarkFollowOffice' => ['index/OfficeBuilding/remarkFollowOffice', ['method' => 'POST|GET']],//办公-客跟进liu
'getCollectionOffice' => ['index/OfficeBuilding/getCollectionOffice', ['method' => 'POST|GET']],//收款记录办公楼liu
'getCollectionShop' => ['index/OfficeBuilding/getCollectionShop', ['method' => 'POST|GET']],//收款记录商铺liu
'marchinListOffice' => ['index/OfficeBuilding/marchinListOffice', ['method' => 'POST|GET']],//进场记录办公楼liu
// 'marchinListOffice' => ['index/OfficeBuilding/marchinListOffice', ['method' => 'POST|GET']],//进场记录办公楼liu
'reportListOffice' => ['index/OfficeBuilding/reportListOffice', ['method' => 'POST|GET']],//约带看记录办公楼liu
'adjustmentOffice' => ['index/OfficeBuilding/adjustmentOffice', ['method' => 'POST|GET']],//调整出账办公楼liu
'adjustmentShop' => ['index/OfficeBuilding/adjustmentShop', ['method' => 'POST|GET']],//调整出账商铺liu
......@@ -1053,6 +1053,10 @@ Route::group('office_index', [
'bargainInfo' => ['index/officePayLog/bargainInfo', ['method' => 'GET']],//成交报告详情
'commissionList' => ['index/officePayLog/commissionList', ['method' => 'GET']],//成交报告分佣提成
'getTallAge' => ['index/officePayLog/getTallAgeV2', ['method' => 'GET']],//成交报告分佣提成
'deleteReceiptImg' => ['index/officePayLog/deleteReceiptImg', ['method' => 'post|get']],//删除收款图片
'getPayLogData' => ['index/officePayLog/getPayLogData', ['method' => 'GET']], //收款各种详情
'adjustmentList' => ['index/officePayLog/adjustmentList', ['method' => 'GET']], //调整列表
'inspectionRecordOur/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 0]], //我的约带看
'inspectionRecordStore/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 1]], //门店约带看
'inspectionRecordDistrict/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 2]], //部门约带看
......
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