Files
annnj-company 130c1026c4 first commit
2026-04-17 18:29:53 +08:00

228 lines
10 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\admin\controller;
use app\admin\service\BocCommonService;
use app\common\validate\boc\ApplyOfficialValidate;
use app\common\validate\boc\CommonValidate;
use app\common\validate\boc\PreApplyValidate;
use think\Db;
use think\facade\Log;
use think\facade\Response;
class BocCommon extends Base
{
private $data = [];
private $service = null;
private $plain_data = [];
public function initialize()
{
parent::initialize();
$this->service = new BocCommonService();
if (in_array($this->request->action(true), ['preApply', 'applyOfficial'])) {
$this->data = $this->request->post();
Log::debug('data:');
Log::debug($this->data);
$common_validate = new CommonValidate();
// 1.验证公共请求参数字段
if (!$common_validate->check($this->data)) {
Log::error('请求参数错误:');
Log::error($common_validate->getError());
return $this->service->buildResponseData(-1, '请求参数错误', []);
}
// 2.验签
if (!$this->service->verifySign($this->data['cipherkey'], $this->data['ciphertext'], $this->data['sign'])) {
return $this->service->buildResponseData(-1, '验签失败', $this->data);
}
// 3.解析数据明文
$this->plain_data = json_decode($this->service->getPlainText(), true);
Log::debug('plain_data:');
Log::debug($this->plain_data);
}
}
public function preApply()
{
$validate = new PreApplyValidate();
if (!$validate->check($this->plain_data)) {
Log::error("preApply请求参数错误");
Log::error($validate->getError());
return $this->service->buildResponseData(-1, '请求参数错误', $this->data);
}
if (($res = $this->service->savePreApply($this->plain_data)) !== true) {
return $this->service->buildResponseData(-1, $res, $this->data);
}
return $this->service->buildResponseData(0, '保存预评估数据成功', $this->data);
}
public function applyOfficial()
{
$validate = new ApplyOfficialValidate();
if (!$validate->check($this->plain_data)) {
Log::error("preApply请求参数错误");
Log::error($validate->getError());
return $this->service->buildResponseData(-1, '请求参数错误', $this->data);
}
if (($res = $this->service->saveApplyOfficial($this->plain_data)) !== true) {
return $this->service->buildResponseData(-1, $res, $this->data);
}
return $this->service->buildResponseData(0, '保存预评估数据成功', $this->data);
}
public function getPreApplyList()
{
$param = $this->request->param();
$page = $param['page'] ?? 1;
$limit = $param['limit'] ?? 10;
$where = [];
if (!empty($param['is_related'])) { //1未关联 2=已关联
$where['bcm.is_related'] = $param['is_related'];
}
if (!empty($param['bankPreEstimateNo'])) { //银行预评估申请编号
$where['bcp.bankPreEstimateNo'] = ['like', '%' . $param['bankPreEstimateNo'] . '%'];
}
if (!empty($param['bankerName'])) { //客户经理名字
$where['bcp.bankerName'] = ['like', '%' . $param['bankerName'] . '%'];
}
if (!empty($param['bankerPhone'])) { //客户经理电话
$where['bcp.bankerPhone'] = ['like', '%' . $param['bankerPhone'] . '%'];
}
if (!empty($param['propertyName'])) { //物业名称
$where['bcp.propertyName'] = ['like', '%' . $param['propertyName'] . '%'];
}
$estimateType = ['1' => '人工', '2' => '自动'];
$channelCode = ['XJ' => '消金', 'PH' => '普惠'];
$list = Db::name('boc_common_preapply')->alias('bcp')
->field('bcm.id boc_common_id, bcp.id boc_common_preapply_id, bcm.bankPreEstimateNo, bcp.bankerName,
bcp.bankerPhone, bcp.estimateType, bcp.propertyName, bcp.channelCode, bcm.is_related')
->leftJoin("boc_common_main bcm", "bcp.boc_common_id = bcm.id")
->where($where)
->order('bcm.id desc')
->paginate([
'list_rows' => $limit,
'page' => $page,
])->each(function ($item, $key) use ($estimateType, $channelCode) {
$item['estimateTypeStr'] = $item['estimateType'] ? $estimateType[$item['estimateType']] : '';
$item['channelCodeStr'] = $item['channelCode'] ? $channelCode[$item['channelCode']] : '';
$item['attachmentList'] = Db::name('boc_common_preapply_property_card')
->field('propertyCardFileUrl url')
->where('boc_common_id', $item['boc_common_id'])
->where('boc_common_preapply_id', $item['boc_common_preapply_id'])
->select();
$item['is_related_text'] = $item['is_related'] == 1 ? '未关联' : '已关联';
return $item;
});
return $this->buildSuccess($list);
}
public function getApplyOfficialList()
{
$param = $this->request->param();
$page = $param['page'] ?? 1;
$limit = $param['limit'] ?? 10;
$where = [];
if (!empty($param['is_related'])) { //1已关联 2=未关联
$where['bcm.is_related'] = $param['is_related'];
}
if (!empty($param['bankEstimateNo'])) { //银行正式评估申请编号
$where['bcao.bankEstimateNo'] = ['like', '%' . $param['bankEstimateNo'] . '%'];
}
if (!empty($param['bankPreEstimateNo'])) { //银行预评估申请编号
$where['bcaope.bankPreEstimateNo'] = ['like', '%' . $param['bankPreEstimateNo'] . '%'];
}
$reportType = ['01' => '简易评估报告', '02' => '正式评估报告', '04' => '询价单'];
$channelCode = ['XJ' => '消金', 'PH' => '普惠'];
$list = Db::name('boc_common_apply_official')->alias('bcao')
->field('bcm.id boc_common_id, bcao.id boc_common_apply_official_id, bcao.bankEstimateNo,
bcao.reportType, bcao.channelCode, bcm.is_related')
->leftJoin('boc_common_main bcm', "bcao.boc_common_id = bcm.id")
->leftJoin("boc_common_apply_official_pre_estimate bcaope", "bcaope.boc_common_id = bcm.id")
->where($where)
->where('bcao.bankEstimateNo is not null and bcao.bankEstimateNo != ""')
->order('bcm.id desc')
->group('bcao.id')
->paginate([
'list_rows' => $limit,
'page' => $page,
])->each(function ($item, $key) use ($reportType, $channelCode) {
$item['reportTypeStr'] = $item['reportType'] ? $reportType[$item['reportType']] : '';
$item['channelCodeStr'] = $item['channelCode'] ? $channelCode[$item['channelCode']] : '';
$item['bankPreEstimateList'] = Db::name('boc_common_apply_official_pre_estimate')->alias('a')
->field("d.bankPreEstimateNo, IF(c.is_related = 1, '未关联', '已关联') is_related, pci.property_full_name propertyName, d.bankerName, d.bankerPhone")
->leftJoin("boc_common_main b", 'a.boc_common_id = b.id')
->leftJoin("boc_common_main c", 'b.order_no = c.order_no')
->leftJoin("boc_common_preapply d", "d.boc_common_id = c.id")
->leftJoin('inquiry i', 'i.order_no = b.order_no')
->leftJoin('property_cert_info pci', 'i.id = pci.quot_id')
->where('a.boc_common_id', $item['boc_common_id'])
->where('a.boc_common_apply_official_id', $item['boc_common_apply_official_id'])
->group('a.boc_common_apply_official_id')
->select();
$item['is_related_text'] = $item['is_related'] == 1 ? '未关联' : '已关联';
return $item;
});
return $this->buildSuccess($list);
}
public function sendPreResult()
{
$quot_id = $this->request->post('quot_id');
if (empty($quot_id)) return $this->buildFailed("缺少询价ID");
if (($res = $this->service->sendPreResult($quot_id)) !== true) {
return $this->buildFailed($res);
}
$res = Db::name('inquiry')->where('id', $quot_id)->update(['is_send_estimate_to_boc' => 1]);
if ($res === false) {
return $this->buildFailed("更新发送预估单状态失败");
}
return $this->buildSuccess();
}
public function sendApplyOfficial()
{
ini_set("memory_limit", "1024M");
set_time_limit(0);
$quot_id = $this->request->post('quot_id');
if (empty($quot_id)) return $this->buildFailed("缺少询价ID");
if (($res = $this->service->sendApplyOfficialResult($quot_id)) !== true) {
return $this->buildFailed($res);
}
$res = Db::name('inquiry')->where('id', $quot_id)->where('is_send_report_to_boc', 2)->update(['is_send_report_to_boc' => 1]);
if ($res === false) {
return $this->buildFailed("更新发送报告状态失败");
}
return $this->buildSuccess();
}
public function isRelatedInquiry()
{
$boc_common_id = $this->request->post('boc_common_id');
$bankPreEstimateNo = $this->request->post('bankPreEstimateNo');
if (empty($boc_common_id)) return $this->buildFailed('参数错误');
if (empty($bankPreEstimateNo)) return $this->buildFailed('参数错误');
$res = Db::name('boc_common_main')->where('id', $boc_common_id)->where('bankPreEstimateNo', $bankPreEstimateNo)->find();
if (!$res) {
return $this->buildFailed('未找到中行的询价申请');
}
return $this->buildSuccess(['is_related' => $res['is_related'] == 2]);
}
/**************业务后台接口**************/
}