first commit
This commit is contained in:
291
pgserver/application/admin/controller/Index.php
Normal file
291
pgserver/application/admin/controller/Index.php
Normal file
@@ -0,0 +1,291 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\util\ReturnCode;
|
||||
use think\Db;
|
||||
use app\admin\service\FileService;
|
||||
use TCPDF;
|
||||
|
||||
|
||||
|
||||
class Index extends Base
|
||||
{
|
||||
// 企业微信access_token
|
||||
private $_QYWX_access_token;
|
||||
|
||||
// 国中的且为corpid
|
||||
const corpid = 'ww991aba6dd6acfc18'; //
|
||||
|
||||
const QYWX_SECRET_KEY = 'ED8eeWCGiLy12BOoLPAf87ITa46DmSz50sPYwgXNAzk';
|
||||
|
||||
public function index()
|
||||
{
|
||||
return $this->buildSuccess();
|
||||
}
|
||||
|
||||
public function hello($name = '国中评估')
|
||||
{
|
||||
return 'hello,' . $name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 登陆企业微信:获取access_token
|
||||
public function loginQYWX()
|
||||
{
|
||||
// 请求获取access_token
|
||||
$url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=ww7320658149a7bf0&corpsecret='. $this->QYWX_SECRET_KEY;
|
||||
$res = file_get_contents($url);
|
||||
$res = json_decode($res, true);
|
||||
$this->_QYWX_access_token = $res['access_token'];
|
||||
return $this->buildSuccess($this->_QYWX_access_token);
|
||||
}
|
||||
|
||||
|
||||
public function testQYWX()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//获取银行列表
|
||||
public function getBankList()
|
||||
{
|
||||
$f_bank = Db::name('bank')->where('pid', 0)->select();
|
||||
$a = array_walk($f_bank, array($this, 'getSubBankInfo'));
|
||||
p($f_bank, 1);///1111
|
||||
}
|
||||
|
||||
private function getSubBankInfo(&$value, $key)
|
||||
{
|
||||
$id = $value['id'];
|
||||
if ($value['type'] != 3) {
|
||||
$subBankInfo = Db::name('bank')->where('pid', $id)->select();
|
||||
$a = array_walk($subBankInfo, array($this, 'getSubBankInfo'));
|
||||
$value['child'] = $subBankInfo;
|
||||
} else {
|
||||
$value['child'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
public function testTcpdf()
|
||||
{
|
||||
// Create new TCPDF object
|
||||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||
|
||||
// Set document information
|
||||
$pdf->SetCreator(PDF_CREATOR);
|
||||
$pdf->SetAuthor('John Doe');
|
||||
$pdf->SetTitle('Example PDF');
|
||||
$pdf->SetSubject('This is an example PDF document');
|
||||
$pdf->writeHTML('');
|
||||
// Add a page
|
||||
$pdf->AddPage();
|
||||
|
||||
// Set content
|
||||
$pdf->SetFont('helvetica', '', 12);
|
||||
$pdf->Write(5, 'Hello World!');
|
||||
|
||||
// Output the PDF file to the browser
|
||||
$pdf->Output('example.pdf', 'I');
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} admin/Index/fileUpload 图片上传
|
||||
*
|
||||
* @apiParam {file} pic 文件文件
|
||||
*
|
||||
* @apiSuccess {string} url 文件链接地址
|
||||
* @apiSuccess {string} name 文件原始名称
|
||||
* @apiSuccess {int} id 附件表主键id
|
||||
* @apiSuccess {string} thumb_url 缩略图的地址(上传图片才返回该字段)
|
||||
*/
|
||||
public function fileUpload(FileService $fileService)
|
||||
{
|
||||
$file = request()->file('pic');
|
||||
if (empty($file)) return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '文件不能为空!');
|
||||
try {
|
||||
$result = $fileService->upload($file);
|
||||
return $this->buildSuccess($result);
|
||||
} catch (\Exception $e) {
|
||||
return $this->buildFailed($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function createEInfo()
|
||||
{
|
||||
// 查询满足条件的数据
|
||||
$data = Db::name('property_cert_info')->limit(200)->select();
|
||||
|
||||
// 创建输出的txt文件
|
||||
$filename = 'output.txt';
|
||||
$file = fopen($filename, 'w');
|
||||
|
||||
// 输出每一条数据到txt文件
|
||||
foreach ($data as $item)
|
||||
{
|
||||
$question = "问题:'" . $item['property_full_name'] . "的信息'\n";
|
||||
$answer = "答案:'";
|
||||
foreach( $item as $k => $v )
|
||||
{
|
||||
$cname = $this->findColnameCN($k);
|
||||
if($cname)
|
||||
$answer = $answer. ',' .$cname .':'.$v;
|
||||
}
|
||||
|
||||
$answer = $answer."'\n";
|
||||
|
||||
fwrite($file, $question);
|
||||
fwrite($file, $answer);
|
||||
}
|
||||
|
||||
// 关闭文件
|
||||
fclose($file);
|
||||
|
||||
// 提示输出完成
|
||||
echo "数据已输出到" . $filename;
|
||||
}
|
||||
|
||||
private function findColnameCN( $strENColName)
|
||||
{
|
||||
$TRANSLATE = [
|
||||
'city'=>'所在城市',
|
||||
'property_full_name'=>'物业全名',
|
||||
'building_name'=>'楼盘名',
|
||||
'size'=>'面积',
|
||||
'reg_price'=>'登记价',
|
||||
'is_tran_tax_free'=>'是否满2年',
|
||||
'cert_no'=>'证件号码',
|
||||
'property_cert'=>'房产证号',
|
||||
'evaluated_unit_price' =>'评估单价'
|
||||
];
|
||||
|
||||
if(!array_key_exists( $strENColName, $TRANSLATE))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return $TRANSLATE[ $strENColName ];
|
||||
}
|
||||
|
||||
// 修改支行和客户经理
|
||||
public function updBranchBank() {
|
||||
$data = input('');
|
||||
if (empty($data['order_no'])) {
|
||||
return $this->buildFailed('询价单号不能为空!');
|
||||
}
|
||||
$where[] = ['order_no', '=', trim($data['order_no'])];
|
||||
$inquiry_data = Db::name('inquiry')->where($where)->find();
|
||||
if (!$inquiry_data) {
|
||||
return $this->buildFailed('不存在的询价!');
|
||||
}
|
||||
$flag = true;
|
||||
$bank_name = Db::name('bank')->where('id='.$data['bank_id'])->value('name');
|
||||
$bank_branch_name = Db::name('bank')->where('id='.$data['bank_branch_id'])->value('name');
|
||||
$bank_sub_name = Db::name('bank')->where('id='.$data['bank_sub_id'])->value('name');
|
||||
$bank_customer_mgr_name = Db::name('account_manager')->where('id='.$data['bank_customer_mgr_id'])->field('name,mobile')->find();
|
||||
$inquiry_data['bank_id'] = $data['bank_id'];
|
||||
$inquiry_data['bank_name'] = $bank_name;
|
||||
$inquiry_data['bank_branch_id'] = $data['bank_branch_id'];
|
||||
$inquiry_data['bank_branch_name'] = $bank_branch_name;
|
||||
$inquiry_data['bank_sub_id'] = $data['bank_sub_id'];
|
||||
$inquiry_data['bank_sub_name'] = $bank_sub_name;
|
||||
$inquiry_data['bank_customer_mgr_id'] = $data['bank_customer_mgr_id'];
|
||||
$inquiry_data['bank_customer_mgr_name'] = $bank_customer_mgr_name['name'];
|
||||
$inquiry_data['bank_customer_mgr_phone'] = $bank_customer_mgr_name['mobile'];
|
||||
$inquiry_upd_result = Db::name('inquiry')->update($inquiry_data);
|
||||
if (!$inquiry_upd_result) {
|
||||
$flag = false;
|
||||
}
|
||||
$charge_data = Db::name('charge')->where($where)->find();
|
||||
if ($charge_data) {
|
||||
$charge_data['bank_id'] = $data['bank_id'];
|
||||
$charge_data['bank'] = $bank_name;
|
||||
$charge_data['bank_branch_id'] = $data['bank_branch_id'];
|
||||
$charge_data['bank_branch'] = $bank_branch_name;
|
||||
$charge_data['bank_sub_branch_id'] = $data['bank_sub_id'];
|
||||
$charge_data['bank_sub_branch'] = $bank_sub_name;
|
||||
$charge_data['account_manager_id'] = $data['bank_customer_mgr_id'];
|
||||
$charge_data['account_manager_name'] = $bank_customer_mgr_name['name'];
|
||||
$charge_upd_result = Db::name('charge')->update($charge_data);
|
||||
if (!$charge_upd_result) {
|
||||
$flag = false;
|
||||
}
|
||||
}
|
||||
if ($flag) {
|
||||
return $this->buildSuccess('', '更新成功!');
|
||||
} else {
|
||||
return $this->buildFailed('更新失败!');
|
||||
}
|
||||
}
|
||||
|
||||
public function reqBankList() {
|
||||
return Db::name('bank')->where('pid=0 && bank_is_visible<>-1')->order("bank_index DESC")->select();
|
||||
}
|
||||
|
||||
public function getSubBank() {
|
||||
$bank_id = input('bank_id');
|
||||
return Db::name('bank')->where('pid='.$bank_id)->select();
|
||||
}
|
||||
|
||||
public function getBranchBank() {
|
||||
$bank_branch_id = input('bank_branch_id');
|
||||
return Db::name('bank')->where('pid='.$bank_branch_id)->select();
|
||||
}
|
||||
|
||||
public function getCustomer() {
|
||||
$bank_sub_id = input('bank_sub_id');
|
||||
return Db::name('account_manager')->where('bank_sub_id='.$bank_sub_id)->select();
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
return $this->fetch('edit');
|
||||
}
|
||||
|
||||
public function returnThird() {
|
||||
return $this->fetch('return');
|
||||
}
|
||||
|
||||
// 修改支行和客户经理
|
||||
public function returnToThird() {
|
||||
$data = input('');
|
||||
if (empty($data['e_case_code'])) {
|
||||
return $this->buildFailed('提取码不能为空!');
|
||||
}
|
||||
$where[] = ['e_case_code', '=', trim($data['e_case_code'])];
|
||||
$report_data = Db::name('report')->where($where)->find();
|
||||
if (!$report_data || $report_data['status']!=3) {
|
||||
return $this->buildFailed('不存在的报告提取码或报告未完成!');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try{
|
||||
$report_upd_data['id'] = $report_data['id'];
|
||||
$report_upd_data['status'] = 2;
|
||||
$report_upd_data['reviewer2_id'] = null;
|
||||
$report_upd_data['reviewer2_name'] = null;
|
||||
$report_upd_data['reviewer2_time'] = null;
|
||||
$report_upd_data['review2_status'] = 1;
|
||||
$report_upd_result = Db::name('report')->update($report_upd_data);
|
||||
|
||||
$inquiry_upd_data['id'] = $report_data['quot_id'];
|
||||
$inquiry_upd_data['status'] = 7;
|
||||
$inquiry_upd_result = Db::name('inquiry')->update($inquiry_upd_data);
|
||||
|
||||
$charge_del_result = Db::name('charge')->where(['report_code'=>$data['e_case_code']])->delete();
|
||||
|
||||
if ($report_upd_result && $inquiry_upd_result && $charge_del_result) {
|
||||
Db::commit();
|
||||
return $this->buildSuccess('', '退回成功!');
|
||||
} else {
|
||||
Db::rollback();
|
||||
return $this->buildFailed('退回失败!');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $this->buildFailed('退回失败!'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user