207 lines
8.2 KiB
PHP
207 lines
8.2 KiB
PHP
<?php
|
|
/**
|
|
* 结单管理
|
|
*/
|
|
namespace app\admin\controller;
|
|
|
|
use app\model\Charge as ChargeModel;
|
|
use think\Response;
|
|
use app\admin\service\ChargeService;
|
|
|
|
class StatementManage extends Base
|
|
{
|
|
|
|
public function __construct(){
|
|
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
|
|
header("Access-Control-Allow-Origin: *");
|
|
header("Access-Control-Allow-Headers: userId, ApiAuth, Category, User-Agent, Keep-Alive, Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With");
|
|
header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
|
|
header('Access-Control-Allow-Credentials:true');
|
|
exit;
|
|
}
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* 待结单列表
|
|
*/
|
|
public function waitStatementList() {
|
|
$data = $this->getStatementList(1);
|
|
return $this->buildSuccess($data);
|
|
}
|
|
|
|
/**
|
|
* 待结单列表导出
|
|
*/
|
|
public function waitExport() {
|
|
$data = $this->getStatementListExport(1);
|
|
$indexKey = ['report_no', 'bank_customer_mgr_name', 'city', 'region', 'building_name', 'assessment_purpose', 'is_confirm_str', 'collection_status_str', 'receivable', 'received', 'confirm_amount', 'uncollected_amount', 'report_completion_time', 'salesman_name', 'youhui_amount', 'tui_amount'];
|
|
$indexValue = ['报告编号', '银行', '城市', '城区', '物业名称', '评估目的','实收状态', '收款状态', '应收金额', '实收金额', '确认金额', '未收金额', '出报告日期', '业务员', '优惠金额', '退费金额'];
|
|
(new ChargeManage())->exportExcel($data['data'], 'wait_'.date('Ymd'), $indexKey, $indexValue);
|
|
}
|
|
|
|
/**
|
|
* 预结单列表
|
|
*/
|
|
public function preStatementList()
|
|
{
|
|
$data = $this->getStatementList(2);
|
|
return $this->buildSuccess($data);
|
|
}
|
|
|
|
/**
|
|
* 预结单列表导出
|
|
*/
|
|
public function preExport() {
|
|
$data = $this->getStatementListExport(2);
|
|
$indexKey = ['report_no', 'bank_customer_mgr_name', 'city', 'region', 'building_name', 'assessment_purpose', 'is_confirm_str', 'collection_status_str', 'receivable', 'received', 'confirm_amount', 'uncollected_amount', 'check_time', 'report_completion_time', 'salesman_name', 'youhui_amount', 'tui_amount'];
|
|
$indexValue = ['报告编号', '银行', '城市', '城区', '物业名称', '评估目的','实收状态', '收款状态', '应收金额', '实收金额', '确认金额', '未收金额', '预结单时间', '出报告日期', '业务员', '优惠金额', '退费金额'];
|
|
(new ChargeManage())->exportExcel($data['data'], 'pre_'.date('Ymd'), $indexKey, $indexValue);
|
|
}
|
|
|
|
/**
|
|
* 实结单列表
|
|
*/
|
|
public function realStatementList() {
|
|
$data = $this->getStatementList(3);
|
|
return $this->buildSuccess($data);
|
|
}
|
|
|
|
/**
|
|
* 实结单列表导出
|
|
*/
|
|
public function realExport() {
|
|
$data = $this->getStatementListExport(3);
|
|
$indexKey = ['report_no', 'bank_customer_mgr_name', 'city', 'region', 'building_name', 'assessment_purpose', 'is_confirm_str', 'collection_status_str', 'receivable', 'received', 'confirm_amount', 'uncollected_amount', 'check_amount', 'check_time', 'report_completion_time', 'salesman_name', 'youhui_amount', 'tui_amount'];
|
|
$indexValue = ['报告编号', '银行', '城市', '城区', '物业名称', '评估目的','实收状态', '收款状态', '应收金额', '实收金额', '确认金额', '未收金额', '结单金额', '实结单时间', '出报告日期', '业务员', '优惠金额', '退费金额'];
|
|
(new ChargeManage())->exportExcel($data['data'], 'real_'.date('Ymd'), $indexKey, $indexValue);
|
|
}
|
|
|
|
public function getStatementListExport($charge_status) {
|
|
$charge_service = new ChargeService();
|
|
$map = $charge_service->summarySearchCondition();
|
|
$map[] = ['a.charge_status', '=', $charge_status];
|
|
|
|
$charge = new ChargeModel();
|
|
$order = ['a.report_completion_time'];
|
|
return $charge->getSummaryList($map, $order, ['list_rows' => 10000000, 'page' => 1]);
|
|
|
|
}
|
|
|
|
public function getStatementList($charge_status) {
|
|
$charge_service = new ChargeService();
|
|
$map = $charge_service->summarySearchCondition();
|
|
$map[] = ['a.charge_status', '=', $charge_status];
|
|
|
|
$charge = new ChargeModel();
|
|
$order = ['a.report_completion_time'];
|
|
return $charge->getSummaryList($map, $order, $this->getPage());
|
|
|
|
}
|
|
|
|
/**
|
|
* 结单列表查看详情
|
|
*/
|
|
public function getStatementDetail() {
|
|
$charge_id = $this->request->param('charge_id');
|
|
if (empty($charge_id)) {
|
|
return $this->buildFailed('参数错误');
|
|
}
|
|
$charge_c = new Charge();
|
|
$data = $charge_c->getChargeDetail($charge_id);
|
|
return $this->buildSuccess($data);
|
|
}
|
|
|
|
/**
|
|
* 发起预结单
|
|
*/
|
|
public function doPreStatementStatus() {
|
|
$charge_id = $this->request->param('charge_id');
|
|
if (empty($charge_id)) {
|
|
return $this->buildFailed('参数错误');
|
|
}
|
|
$result = (new ChargeModel())->updStatementStatus($charge_id, 2);
|
|
if ($result) {
|
|
return Response::create(['code'=>1, 'msg'=>'发起预结单成功'], 'json');
|
|
} else {
|
|
return $this->buildFailed('发起预结单失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 确认实结单
|
|
*/
|
|
public function doRealStatementStatus() {
|
|
$charge_id = $this->request->param('charge_id');
|
|
if (empty($charge_id)) {
|
|
return $this->buildFailed('参数错误');
|
|
}
|
|
$charge_ids = [];
|
|
if (strpos($charge_id, ',') !== false) {
|
|
$charge_ids = explode(',', $charge_id);
|
|
} else {
|
|
$charge_ids[] = $charge_id;
|
|
}
|
|
$i = 0;
|
|
$report_no_str = '';
|
|
$chargeModel = new ChargeModel();
|
|
foreach ($charge_ids as $key=>$value) {
|
|
$amount = $chargeModel->where(['charge_id'=>$value])->field('report_no,confirm_amount')->find();
|
|
// $result = $chargeModel->save(['charge_status'=>3, 'check_time'=>date('Y-m-d H:i:s'), 'check_amount'=>$amount['confirm_amount']], ['charge_id'=>$value]);
|
|
$result = ChargeModel::where(['charge_id'=>$value])->update(['charge_status'=>3, 'check_time'=>date('Y-m-d H:i:s'), 'check_amount'=>$amount['confirm_amount']]);
|
|
if ($result) {
|
|
$i++;
|
|
} else {
|
|
$report_no_str .= ','.$amount['report_no'];
|
|
}
|
|
}
|
|
if (count($charge_ids) == $i) {
|
|
return Response::create(['code'=>1, 'msg'=>'确认实结单成功'], 'json');
|
|
} else {
|
|
$report_no_str = trim($report_no_str, ',');
|
|
return $this->buildFailed('报告编号为['.$report_no_str.']确认实结单失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 退回待结单
|
|
*/
|
|
public function returnWaitStatementStatus() {
|
|
$charge_id = $this->request->param('charge_id');
|
|
if (empty($charge_id)) {
|
|
return $this->buildFailed('参数错误');
|
|
}
|
|
$result = (new ChargeModel())->updStatementStatus($charge_id, 1);
|
|
if ($result) {
|
|
return Response::create(['code'=>1, 'msg'=>'退回待结单成功'], 'json');
|
|
} else {
|
|
return $this->buildFailed('退回待结单失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 退回预结单
|
|
*/
|
|
public function returnPreStatementStatus() {
|
|
$charge_id = $this->request->param('charge_id');
|
|
if (empty($charge_id)) {
|
|
return $this->buildFailed('参数错误');
|
|
}
|
|
$charge_ids = [];
|
|
if (strpos($charge_id, ',') !== false) {
|
|
$charge_ids = explode(',', $charge_id);
|
|
} else {
|
|
$charge_ids[] = $charge_id;
|
|
}
|
|
$chargeModel = new ChargeModel();
|
|
$result = $chargeModel->save(['charge_status'=>2, 'check_time'=>date('Y-m-d H:i:s'), 'check_amount'=>0], ['charge_id'=>$charge_ids]);
|
|
if ($result) {
|
|
return Response::create(['code'=>1, 'msg'=>'退回预结单成功'], 'json');
|
|
} else {
|
|
return $this->buildFailed('退回预结单失败');
|
|
}
|
|
}
|
|
|
|
}
|
|
|