238 lines
9.5 KiB
PHP
238 lines
9.5 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\admin\service\BocCfService;
|
|
use app\admin\service\SyncHttpService;
|
|
use think\Db;
|
|
use think\facade\Log;
|
|
|
|
class Boccf extends Base //
|
|
{
|
|
|
|
public function do_estimate()
|
|
{
|
|
$data = $this->request->post();
|
|
$header = $this->request->header();
|
|
Log::debug('data:');
|
|
Log::debug($data);
|
|
Log::debug('header:');
|
|
Log::debug($header);
|
|
$boc_service = new BocCfService();
|
|
// 验证请求参数
|
|
if (!$boc_service->checkRequestParams($data)) {
|
|
return $boc_service->buildResponseData(BocCfService::RETURN_CODE_ARRAY['1002']);
|
|
}
|
|
// 验证header信息
|
|
if (!$boc_service->checkRequestHeader(
|
|
$header,
|
|
$data['content']
|
|
)) {
|
|
return $boc_service->buildResponseData(BocCfService::RETURN_CODE_ARRAY['1001']);
|
|
}
|
|
|
|
switch ($data['tranno']) {
|
|
case BocCfService::INQUIRY_APPLY: // 询价申请
|
|
return $boc_service->inquiryApply($data);
|
|
case BocCfService::APPLY_TO_PROVIDE_EVA_REPORT: // 申请出具评估报告
|
|
// todo
|
|
return $boc_service->applyToProvideEvaReport($data);
|
|
}
|
|
return $boc_service->buildResponseData(BocCfService::RETURN_CODE_ARRAY['1000']);
|
|
}
|
|
|
|
public function returnPriceToBoccf()
|
|
{
|
|
$quot_id = $this->request->post('quot_id');
|
|
if (empty($quot_id)) return $this->buildFailed('参数错误');
|
|
|
|
try {
|
|
$inquiry_info = Db::name('inquiry')->where('id', $quot_id)->find();
|
|
if (empty($inquiry_info)) return $this->buildFailed('询价信息不存在');
|
|
|
|
// todo 中行消金
|
|
if ($inquiry_info['bank_name'] == '中国银行' && in_array($inquiry_info['loan_type'], ['二手按揭', '普惠', '消费'])) {
|
|
$boc_cf_service = new BocCfService();
|
|
$res = $boc_cf_service->inquiryResultFeedback($inquiry_info['business_no']);
|
|
if (!$res) {
|
|
return $this->buildFailed('回价请求到中行方失败');
|
|
}
|
|
Db::startTrans();
|
|
$res = Db::name('boc_cf_inquiry_apply')->where('dealNo', $inquiry_info['business_no'])->update([
|
|
'biz_status' => 20,
|
|
'update_time' => date('Y-m-d H:i:s')
|
|
]);
|
|
if (!$res) {
|
|
Db::rollback();
|
|
return $this->buildFailed('中行数据:business_no=' . $inquiry_info['business_no'] . ' 业务状态更新失败');
|
|
}
|
|
$res = Db::name('inquiry')->where('id', $quot_id)->update([
|
|
'biz_status' => 20,
|
|
'update_time' => date('Y-m-d H:i:s')
|
|
]);
|
|
if (!$res) {
|
|
Db::rollback();
|
|
return $this->buildFailed('询价数据:quot_id=' . $quot_id . ' 业务状态更新失败');
|
|
}
|
|
Db::commit();
|
|
return $this->buildSuccess([]);
|
|
}
|
|
return $this->buildFailed('非中行消金产品,无法回价到中行方');
|
|
} catch (\Exception $e) {
|
|
Log::error('错误文件:' . $e->getFile());
|
|
Log::error('错误行数:' . $e->getLine());
|
|
Log::error('错误编码:' . $e->getCode());
|
|
Log::error('错误信息:' . $e->getMessage());
|
|
return $this->buildFailed('系统错误');
|
|
}
|
|
}
|
|
|
|
public function sendEstimateReport()
|
|
{
|
|
/*SyncHttpService::post('admin/Boccf/syncSendFileToBoccf', [
|
|
'isn' => '123456789123456789123456789',
|
|
'tranno' => 'E001',
|
|
'contents' => ['encrypt' => '111', 'decrypt' => [
|
|
'a' => 1,
|
|
'b' => 2
|
|
]]
|
|
]);
|
|
return $this->buildSuccess([]);*/
|
|
|
|
|
|
$quot_id = $this->request->post('quot_id');
|
|
$bnkno = $this->request->post('bnkno');
|
|
$tlrname = $this->request->post('tlrname');
|
|
if (empty($quot_id)) return $this->buildFailed('参数错误');
|
|
$inquiry_info = Db::name('inquiry')->where('id', $quot_id)->find();
|
|
if (empty($inquiry_info)) return $this->buildFailed('询价信息不存在');
|
|
if (empty($inquiry_info['bnkno']) && empty($inquiry_info['tlrname'])) {
|
|
if (empty($bnkno)) return $this->buildFailed('请填写支行机构号');
|
|
if (empty($tlrname)) return $this->buildFailed('请填写客户经理名称');
|
|
} else {
|
|
$bnkno = $inquiry_info['bnkno'];
|
|
$tlrname = $inquiry_info['tlrname'];
|
|
}
|
|
|
|
|
|
$boc_cf_service = new BocCfService();
|
|
$res = $boc_cf_service->sendEstimateReport($quot_id, $bnkno, $tlrname);
|
|
if (!$res) {
|
|
return $this->buildFailed('发送预估报告失败');
|
|
}
|
|
return $this->buildSuccess([]);
|
|
}
|
|
|
|
public function sendReport()
|
|
{
|
|
$report_no = $this->request->post('report_no');
|
|
$bnkno = $this->request->post('bnkno');
|
|
$tlrname = $this->request->post('tlrname');
|
|
if (empty($report_no)) return $this->buildFailed('参数错误');
|
|
|
|
$boc_cf_service = new BocCfService();
|
|
$res = $boc_cf_service->evaReportSuccessProvide($report_no, $bnkno, $tlrname);
|
|
if (!$res) {
|
|
return $this->buildFailed('发送评估报告失败');
|
|
}
|
|
return $this->buildSuccess([]);
|
|
}
|
|
|
|
public function getAccountManagerInfo()
|
|
{
|
|
$name = $this->request->post('name');
|
|
if (empty($name)) return $this->buildFailed('参数错误');
|
|
|
|
$boc_cf_service = new BocCfService();
|
|
$res = $boc_cf_service->getAccountManagerInfo($name);
|
|
if (!$res) {
|
|
return $this->buildFailed('获取客户信息失败');
|
|
}
|
|
return $this->buildSuccess($boc_cf_service->orgInfoResp);
|
|
}
|
|
|
|
public function syncSendFileToBoccf()
|
|
{
|
|
set_time_limit(0);
|
|
ini_set('memory_limit', '2048M'); // 动态覆盖php.ini
|
|
ini_set('max_execution_time', 0); // 动态覆盖php.ini
|
|
$file_url = $this->request->param('file_url');
|
|
$isn = $this->request->param('isn');
|
|
$tranno = $this->request->param('tranno');
|
|
$estimateinfoReq = $this->request->param('estimateinfoReq');
|
|
if (empty($file_url)) return $this->buildFailed('缺少参数file_url');
|
|
if (empty($isn)) return $this->buildFailed('缺少参数isn');
|
|
if (empty($tranno)) return $this->buildFailed('缺少参数tranno');
|
|
if (empty($estimateinfoReq)) return $this->buildFailed('缺少参数estimateinfoReq');
|
|
|
|
$boc_cf_service = new BocCfService();
|
|
if (!$boc_cf_service->syncSendBoccfFileRequest($file_url, $isn, $tranno, $estimateinfoReq)) {
|
|
return $this->buildFailed('异步请求中行消金失败');
|
|
}
|
|
return $this->buildSuccess([]);
|
|
}
|
|
|
|
/**************业务后台接口**************/
|
|
|
|
public function inquiryApplyList()
|
|
{
|
|
$is_related = $this->request->post('is_related', '', 'trim');
|
|
$keyword = $this->request->post('keyword', '', 'trim');
|
|
$page = $this->request->post('page', 1, 'intval');
|
|
$limit = $this->request->post('limit', 10, 'intval');
|
|
|
|
$where = [];
|
|
if ($is_related) {
|
|
$where[] = ['is_related', '=', $is_related];
|
|
}
|
|
if ($keyword) {
|
|
$where[] = ['dealNo', 'like', '%' . $keyword . '%'];
|
|
}
|
|
|
|
$fileTypeList = ['01' => '房产证', '02' => '不动产证'];
|
|
$estimateTimesList = ['01' => '首次', '02' => '重评'];
|
|
$typeList = ['01' => '房贷'];
|
|
$is_related_list = ['1' => '未关联', '2' => '已关联'];
|
|
$biz_status_text = ['10' => '待回价', '20' => '已回价', '30' => '已发送预估单', '40' => '申请出具报告', '50' => '已发送报告'];
|
|
|
|
$list = Db::name('boc_cf_inquiry_apply')
|
|
->field('id, dealNo, fileType, fileUrl, estimateTimes, message, tlrname, oprTel,
|
|
bnkno, type, is_related, biz_status')
|
|
->where($where)
|
|
->order('id desc')
|
|
->paginate([
|
|
'list_rows' => $limit,
|
|
'page' => $page
|
|
])->each(function ($item, $key) use (
|
|
$fileTypeList,
|
|
$estimateTimesList,
|
|
$typeList,
|
|
$is_related_list,
|
|
$biz_status_text
|
|
) {
|
|
$item['fileTypeName'] = $fileTypeList[$item['fileType']] ?? '';
|
|
$item['estimateTimesName'] = $estimateTimesList[$item['estimateTimes']] ?? '';
|
|
$item['typeName'] = $typeList[$item['type']] ?? '';
|
|
$item['is_related_text'] = $is_related_list[$item['is_related']] ?? '';
|
|
$item['biz_status_text'] = '';
|
|
if ($item['is_related'] == 2) {
|
|
$item['biz_status_text'] = $biz_status_text[$item['biz_status']] ?? '';
|
|
}
|
|
|
|
return $item;
|
|
})->toArray();
|
|
return $this->buildSuccess($list);
|
|
}
|
|
|
|
public function isRelatedInquiry()
|
|
{
|
|
$dealNo = $this->request->post('dealNo');
|
|
if (empty($dealNo)) return $this->buildFailed('参数错误');
|
|
|
|
$res = Db::name('boc_cf_inquiry_apply')->where('dealNo', $dealNo)->find();
|
|
if (!$res) {
|
|
return $this->buildFailed('未找到中行消金的询价申请');
|
|
}
|
|
return $this->buildSuccess(['is_related' => $res['is_related'] == 2]);
|
|
}
|
|
} |