first commit

This commit is contained in:
annnj-company
2026-04-17 18:29:53 +08:00
parent e49fa5a215
commit 130c1026c4
5615 changed files with 1639145 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace app\util;
class Aes {
public $key = '';
public $iv = '';
public $method = '';
/**
* 构造方法
*/
public function __construct($key, $iv = '', $method = 'AES-128-ECB')
{
$this->method = $method;
$this->key = $key;
$this->iv = $iv;
}
// 加密
public function aesEn($data){
return base64_encode(openssl_encrypt($data, $this->method,$this->key, OPENSSL_RAW_DATA , $this->iv));
}
//解密
public function aesDe($data){
return openssl_decrypt(base64_decode($data), $this->method, $this->key, OPENSSL_RAW_DATA, $this->iv);
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace app\util;
use think\facade\Cache;
class BOCSign {
/**
* md5 加密
*/
public static function serPassword($data){
return md5($data,\config('api.password_pre_halt'));
}
/**
* 生成每次请求Sign字符串
*/
public static function setSign($data = []) {
// 按字段排序
\ksort($data);
//拼接字符串数据
$string = \http_build_query($data);
//通过 aes 来加密
$string = (new Aes(\config('api.aes_key')))->aesEn($string);
return $string;
}
/**
* 检测sign是否正常
*/
public static function checkSignPass($data) {
$str = (new Aes(\config('api.aes_key')))->aesDe($data);
// 判断解析出来的数据是否为空
if(empty($str)){
return false;
}
// 字符串转数组
parse_str($str,$arr);
// 判断是否是数组,数组内的字段是否正确
if(!\is_array($arr) || empty($arr['mg'])){
return false;
}
// 检测缓存,如果有缓存,说明这个sign已经被使用
if(Cache::get($data)){
return false;
}
return true;
}
/**
*'aes_key' =>[
* 'key' => 'reter4446fdfgdfgdfg', //加密key这个可以随便定义
* 'iv' => md5(time(). uniqid(),true), //保证偏移量为16位
* 'method' => 'AES-128-CBC' //加密方式 # AES-256-CBC等这个可以搭配的形式有很多具体的你可以去了解一下AES加密算法
* ],
*/
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
<?php
/**
* 错误码统一维护
* @since 2017/02/28 创建
* @author zhaoxiang <zhaoxiang051405@gmail.com>
*/
namespace app\util;
class ReturnCode {
const SUCCESS = 1;
const INVALID = -1;
const DB_SAVE_ERROR = -2;
const DB_READ_ERROR = -3;
const CACHE_SAVE_ERROR = -4;
const CACHE_READ_ERROR = -5;
const FILE_SAVE_ERROR = -6;
const LOGIN_ERROR = -7;
const NOT_EXISTS = -8;
const JSON_PARSE_FAIL = -9;
const TYPE_ERROR = -10;
const NUMBER_MATCH_ERROR = -11;
const EMPTY_PARAMS = -12;
const DATA_EXISTS = -13;
const AUTH_ERROR = -14;
const OTHER_LOGIN = -16;
const VERSION_INVALID = -17;
const CURL_ERROR = -18;
const RECORD_NOT_FOUND = -19; // 记录未找到
const DELETE_FAILED = -20; // 删除失败
const ADD_FAILED = -21; // 添加记录失败
const UPDATE_FAILED = -22; // 添加记录失败
const PARAM_INVALID = -995; // 参数无效
const ACCESS_TOKEN_TIMEOUT = -996;
const SESSION_TIMEOUT = -997;
const UNKNOWN = -998;
const EXCEPTION = -999;
const WITHDRAWAL = -888;//未满足撤单条件
const AUTH_PARAMETER = -4001; //缺少参数
const AUTH_TOKEN = -4002; //获取token失败
const AUTH_USER_TOKEN = -4003; //缺少token参数
const AUTH_USER = -4004; //获取用户权限失败
const AUTH_ROLE = -4005; //获取角色用户失败
static public function getConstants() {
$oClass = new \ReflectionClass(__CLASS__);
return $oClass->getConstants();
}
}

View File

@@ -0,0 +1,132 @@
<?php
//多套物业模板参数
namespace app\util;
use app\admin\exception\LogicException;
use app\model\Inquiry;
use app\model\Report;
use app\model\ReportDetail;
use app\model\Attachment;
use app\model\Property_cert_info;
use think\Db;
use think\Db\Where;
use think\facade\Env;
class SimpleTemplate
{
public function getValue($reportid) {
$reportInfo = Report::where('id', $reportid)->find();
$inquiryInfo = Inquiry::where('id', $reportInfo['quot_id'])->find();
$inquiryDetailInfo = Property_cert_info::where('quot_id', $reportInfo['quot_id'])->select();
$reportDetailInfoIndex = ReportDetail::where('property_cert_info_id', $inquiryDetailInfo[0]['id'])->find();
$valuerInfo = Db::name('valuer')->field('name,mobile,certificate_number,mark,certificate')->whereIn('id', [$reportInfo['appraiser_id'], $reportInfo['appraiser2_id']])->select();
//注册房地产估价师
$valuerName = '';
$valuerimg = [];
if (!empty($valuerInfo)) {
$i = 1;
foreach ($valuerInfo as &$value1) {
$valuerName .= $value1['name'] . '' . $value1['certificate_number'] . '<br/>';
$value1['nod'] = $i++;
if (!empty($value1['certificate'])) {
$valuerimg[] = $value1['certificate'];
}
}
}
$year = substr($reportInfo['report_no'], 0, 4);
$report_no = explode('-', $reportInfo['report_no']);
$numberings = substr($reportInfo['report_no'], 4, 10);
$suffix = substr($reportInfo['report_no'], 14);
$item_name = [];
foreach ($inquiryDetailInfo as $key => $value) {
$item_name[] = $value['property_full_name'];//项目名称
$reportDetailInfo = ReportDetail::where('property_cert_info_id', $value['id'])->find();
//估 价 结 果 明 细 表
$data = [];
$data['full_estate_name'] = $value['property_full_name'];
$data['size'] = $value['size'];
$data['unit_price'] = number_format($reportDetailInfo['eva_unit_price']);
$data['total_price'] = number_format($reportDetailInfo['eva_total_value']);
$appraiserData[] = $data;
//估价对象位置示意图
if (!empty($reportDetailInfo['loc_img_ids'])) {
$location_imgs_ids[] = $reportDetailInfo['loc_img_ids'];
}
//根据首套物业所在城市获取报告code
if (empty($code)) {
if ($value['city'] == '北京') {
$code = 'B';
} elseif ($value['city'] == '武汉') {
$code = 'C';
} else {
$code = 'A';
}
}
}
//第一页
$info['report_no'] = '深国中评字['.$year.$code.']第'.$numberings.'号'.$suffix;//估价报告编号
$info['client_name'] = $inquiryInfo['client_name'];//委托人
$usage_name = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo[0]['usage']);
// $info['item_name'] = implode('、', $item_name);//估价项目名称
$info['item_name'] = $reportDetailInfoIndex['land_location'] . $inquiryDetailInfo[0]['property_full_name'] . '一套' . $usage_name . '用途';//估价项目名称(首页)
$info['employee_name'] = $valuerName;//注册房地产估价师
$info['report_qrcode'] = $reportInfo['report_qrcode'];//防伪二维码
//第二页
$info['cost_date'] = !empty($reportInfo['valuation_time']) ? date('Y年m月d日', strtotime($reportInfo['valuation_time'])) : '';//价值时点
$info['gross_value_str'] = convertAmountToCn($reportInfo['eva_total_value'], $type = 1);//市场价值
$info['gross_value'] = number_format($reportInfo['eva_total_value']);//市场价值
$appraisal_time = !empty($reportInfo['appraisal_time']) ? explode('-', $reportInfo['appraisal_time']) : '';
$info['finish_date_cn'] = !empty($appraisal_time) ? numToWordone($appraisal_time[0]) .'年'. numToWordone(intval($appraisal_time[1])) .'月'. numToWordone(intval($appraisal_time[2])) . '日' : '';//二〇二〇年五月九日
// 简易报告有效期
$info['simple_valid'] = date('Y-m-d', strtotime("$appraisal_time +3 months"));
$info['appraiserData'] = $appraiserData;//估 价 结 果 明 细 表
$owner_name = $this->array_column($inquiryDetailInfo, 'owner_name');
$info['owner_name'] = implode('、', array_unique($owner_name));
//第三页
$attachmnet = new Attachment();
//物业位置图
$loc_img_ids = [];
if (!empty($location_imgs_ids)) {
foreach ($location_imgs_ids as $lk => $lv) {
$locationIds = explode(',', $lv);
$loc_img_ids[] = ['name' => numToWordone($lk + 1), 'info' => $attachmnet->getUrls($locationIds)];
}
}
$info['location_imgs'] = $loc_img_ids;
//估价师证件
$valuer_img = [];
if (!empty($valuerimg)) {
$valuer_img = $attachmnet->getUrls($valuerimg);
}
$info['valuer_img'] = $valuer_img;
$company_img = [
array('url' => Env::get('uploadFile.host_url') . DS . 'image' . DS .'business_license1.png'),
array('url' => Env::get('uploadFile.host_url') . DS . 'image' . DS .'business_license3.jpg')
];
$info['company_img'] = $company_img;
return $info;
}
//多位数组获取列数据
public function array_column($rows, $column_key, $index_key = null) {
$data = [];
foreach ($rows as $row) {
if (empty($index_key)) {
$data[] = $row[$column_key];
} else {
$data[$row[$index_key]] = $row[$column_key];
}
}
return $data;
}
}

View File

@@ -0,0 +1,480 @@
<?php
namespace app\util;
use phpqrcode\QRcode;
use app\model\Inquiry;
use app\model\bank;
use think\Db;
use app\common\config\EnumCfg;
use think\facade\Log;
class Tools {
/**
* 把返回的数据集转换成Tree
* @param $list
* @param string $pk
* @param string $pid
* @param string $child
* @param string $root
* @return array
*/
public static function listToTree($list, $pk = 'id', $pid = 'fid', $child = '_child', $root = '0') {
$tree = array();
if (is_array($list)) {
$refer = array();
foreach ($list as $key => $data) {
$refer[$data[$pk]] = &$list[$key];
}
foreach ($list as $key => $data) {
$parentId = $data[$pid];
if ($root == $parentId) {
$tree[] = &$list[$key];
} else {
if (isset($refer[$parentId])) {
$parent = &$refer[$parentId];
$parent[$child][] = &$list[$key];
}
}
}
}
return $tree;
}
/**
* 生成报告编号
* 国中规则区域inquiry.brankCom_id + 报告方向report.report_dir + 年份 +
* 报告(对象)类型report.report_obj_type + 客户类型bank.custom_type +
* 类型report.report_class + 月份 + 流水号 + 机构简称 bank.short_name
*
* @param $quot_id 询价ID
* @param string $business_type
* @return array
*/
/**
* 生成报告类型: 1:报告类型2预估类型3、咨询类型
*/
public const GENERATE_TYPE_REPORT = 1; // 鉴证类型
public const GENERATE_TYPE_ESTIMATE = 2;// 预估类型
public const GENERATE_TYPE_CONSULT = 3; // 咨询类型
public const GENERATE_TYPE_REVIEW = 4; // 复合类型
/**
* Generates a report number based on specific business rules
*
* The report number follows GZI rules combining:
* - Region (inquiry.brankCom_id)
* - Report direction (report.report_dir)
* - Year
* - Report object type (report.report_obj_type)
* - Customer type (bank.custom_type)
* - Report class (report.report_class)
* - Month
* - Serial number
* - Institution abbreviation (bank.short_name)
*
* @param int $quot_id The inquiry ID to generate number for
* @param string $generate_type Type of generation, e.g.,1-报告2-预估3、咨询.
* @param string $business_type Business type identifier
* @return array Returns array with generated number and status:
* ['report_no' => string,
* 'second' => string,
* 'code' => int,
* 'msg' => string]
*/
/*public static function generateNo($quot_id ,$generate_type ,$business_type = '' ) {
$number_array = ['report_no' => "", 'second' => "", 'code'=>'0','msg'=>'success'];
// 国中规则区域inquiry.brankCom_id + 报告方向report.report_dir + 年份 +
// 报告(对象)类型report.report_obj_type + 客户类型bank.custom_type +
// 类型report.report_class + 月份 + 流水号 + 机构简称 bank.short_name
// 区域
$inquiry = Db::name('inquiry')->field('type,bank_id,eva_purpose,is_simple,branchCom_id,report_class,report_obj_type')->where('id', $quot_id)->find();
//检查inquiry表数据是否存在
if(!$inquiry){
$number_array['code'] = -1;
$number_array['msg'] = '询价ID:['.$quot_id.']的询价表数据不存在';
return $number_array;
}
// 报告方向 鉴证类:(评)字、预估类:(预)字、咨询类:(咨)字、复核类:(核)字
$reportDirItem = Enumcfg::findById(Enumcfg::reportDir, $generate_type);
if(null == $reportDirItem){
$number_array['code'] = -5;
$number_array['msg'] = '报告方向:['.$generate_type.']的枚举表数据不存在';
return $number_array;
}
$reportDir = $reportDirItem['shortName'];
// 报告对象类型 F:房产 T:土地 Z:资产
$reportObjTypeItem = Enumcfg::findById( Enumcfg::reportObjType, $inquiry['report_obj_type']);
if(null == $reportObjTypeItem){
$number_array['code'] = -6;
$number_array['msg'] = '报告对象类型:['.$inquiry['report_obj_type'].']的枚举表数据不存在';
return $number_array;
}
$reportObjType = $reportObjTypeItem['shortName'];
// 报告类型:
$reportClassItem = Enumcfg::findById( Enumcfg::reportClass, $inquiry['report_class']);
if(null == $reportClassItem){
$number_array['code'] = -7;
$number_array['msg'] = '报告类型:['.$inquiry['report_class'].']的枚举表数据不存在';
return $number_array;
}
$reportClass = $reportClassItem ['shortName'];
// 机构简称
$branchComConfig = Db::name('branchcom_config')->where('id', $inquiry['branchCom_id']) // 或者根据实际关联字段调整查询条件
->field('short_name')
->find();
if(!$branchComConfig){
$number_array['code'] = -2;
$number_array['msg'] = '机构代码:['.$inquiry['branchCom_id'].']的机构表数据不存在';
return $number_array;
}
$short_name = $branchComConfig['short_name'];
// 机构简称 暂时用银行简称代替,后续需要改成机构简称
$bankInfo = Db::name('bank')->field('bank_abbreviation,bank_type,bank_code')->where('id', $inquiry['bank_id'])->find();
if(!$bankInfo){
$number_array['code'] = -3;
$number_array['msg'] = '询价ID:['.$quot_id.']的机构表数据不存在';
return $number_array;
}
$customType = $bankInfo['bank_type']; // 机构客户类型
// 机构代码
$bankCode = $bankInfo['bank_code']; // 机构代码
$s_no = -1;
$now_year = date('Y');
$now_month = date('m');
switch ($generate_type) {
case Tools::GENERATE_TYPE_ESTIMATE:
//计算一个流水号:要求 当年的流水号从1开始branchCom_id与report_dir相同的所有的询价数量+1
$s_no = $inquirisCountINfo = Db::name('inquiry')->field('id')
->where('seal_time', 'like', $now_year . '-' . $now_month . '%')
->where('branchCom_id', $inquiry['branchCom_id'])
->where('estimated_no','<>', '')
->whereNotNull('estimated_no')
->count()+1;
break;
case Tools::GENERATE_TYPE_REPORT:
case Tools::GENERATE_TYPE_CONSULT:
case Tools::GENERATE_TYPE_REVIEW:
$s_no = Db::name('report')->field('id')
->where('branchCom_id', $inquiry['branchCom_id'])
->where('report_no','<>', '')
->whereNotNull('report_no')
->where('create_time', 'like', $now_year . '-' . $now_month . '%')
->count() + 1;
break;
default: // 报错
$number_array['code'] = -4;
$number_array['msg'] = '生成类型:['.$generate_type.']的枚举表数据不存在';
return $number_array;
}
// 生成报告编号
$new_number = env('service.estimate_short_name').
$short_name .
''. $reportDir . ''.
'字【'.$now_year .'】第'.
$reportObjType .
$customType .
$reportClass .
$now_month .
str_pad($s_no, 4, '0', STR_PAD_LEFT).
'-'.$bankCode.'号';
$number_array['code'] = 0;
$number_array['msg'] = '生成成功';
$number_array['data'] = $new_number;
return $number_array;
}*/
/**
* Generates a report number based on specific business rules
*
* The report number follows GZI rules combining:
* - Region (inquiry.brankCom_id)
* - Report direction (report.report_dir)
* - Year
* - Report object type (report.report_obj_type)
* - Customer type (bank.custom_type)
* - Report class (report.report_class)
* - Month
* - Serial number
* - Institution abbreviation (bank.short_name)
*
* @param int $quot_id The inquiry ID to generate number for
* @param string $generate_type Type of generation, e.g.,1-报告2-预估3、咨询.
* @param string $business_type Business type identifier
* @return array Returns array with generated number and status:
* ['report_no' => string,
* 'second' => string,
* 'code' => int,
* 'msg' => string]
*/
// 深国中评字SZ[2025]第GA-1127001-PA号
public static function generateNo($quot_id ,$generate_type ,$business_type = '' ) {
$number_array = ['report_no' => "", 'second' => "", 'code'=>'0','msg'=>'success'];
$now_year = date('Y');
$now_month = date('m');
$now_day = date('d');
if ($generate_type == static::GENERATE_TYPE_REPORT) { //报告编号
$inquiry = Db::name('inquiry')->field('loan_type,type,bank_id,eva_purpose,is_simple,branchCom_id,report_class,report_obj_type')->where('id', $quot_id)->find();
if(!$inquiry){
$number_array['code'] = -1;
$number_array['msg'] = '询价ID:['.$quot_id.']的询价表数据不存在';
return $number_array;
}
$cnStr = '评'; // 除了报告类型是Z(咨询)类的叫咨,其他都叫评。
// 对公
if ($inquiry['loan_type'] == '对公') {
$dateStr = $now_month;
$reportType = 'C';
if (strtoupper($inquiry['report_obj_type']) == 'T') {
$reportType = 'TD';
} else if (strtoupper($inquiry['report_obj_type']) == 'Z') {
$cnStr = '咨';
$reportType = 'A';
}
$s_no = Db::name('report')->field('id')
->where('report_no', 'like', '%第' . $reportType . '%')
->where('create_time', 'like', $now_year . '-' . $now_month . '%')
->count() + 1;
$s_no = str_pad($s_no, 4, '0', STR_PAD_LEFT);
} else { // 其他的非对公
$dateStr = $now_month.$now_day;
$property_cert_info = Db::name('property_cert_info')->where('quot_id', $quot_id)->select();
if (!$property_cert_info) {
$number_array['code'] = -1;
$number_array['msg'] = '询价ID:['.$quot_id.']的物业表数据不存在';
return $number_array;
}
$ownership_type = array_column($property_cert_info, 'ownership_type');
$reportTypeConcatStr = 'A';
if (in_array('2', $ownership_type)) {
$reportTypeConcatStr = 'B';
}
$reportType = 'G' . $reportTypeConcatStr;
$s_no = Db::name('report')->field('id')
->where('report_no', 'like', '%第G%')
->where('create_time', 'like', $now_year . '-' . $now_month . '-' . $now_day . '%')
->count() + 1;
$s_no = str_pad($s_no, 3, '0', STR_PAD_LEFT);
}
// 机构简称
$branchComConfig = Db::name('branchcom_config')
->where('id', $inquiry['branchCom_id']) // 或者根据实际关联字段调整查询条件
->field('short_name')
->find();
if(!$branchComConfig){
$number_array['code'] = -2;
$number_array['msg'] = '机构代码:['.$inquiry['branchCom_id'].']的机构表数据不存在';
return $number_array;
}
$short_name = $branchComConfig['short_name'];
// 机构简称 暂时用银行简称代替,后续需要改成机构简称
$bankInfo = Db::name('bank')->field('bank_abbreviation,bank_type,bank_code')->where('id', $inquiry['bank_id'])->find();
if(!$bankInfo){
$number_array['code'] = -3;
$number_array['msg'] = '询价ID:['.$quot_id.']的机构表数据不存在';
return $number_array;
}
// 机构代码
$bankCode = $bankInfo['bank_code']; // 机构代码
// 生成报告编号
$new_number = '深'.
env('service.estimate_short_name').
$cnStr.
'字'.
EnumCfg::branchComShortNameToEnName[$short_name].
'['.$now_year.']'.
'第'.
$reportType .
'-'.
$dateStr.
$s_no.
'-'.
$bankCode.
'号';
} else if ($generate_type == static::GENERATE_TYPE_ESTIMATE) { //预估编号
$estimated_no = Db::name('inquiry')->field('id')
->where('estimated_no', 'like', $now_year . '-GZ' . $now_month . $now_day . '%')
->count()+1;
$new_number = $now_year.'-GZ'.$now_month.$now_day.str_pad($estimated_no,5,'0',STR_PAD_LEFT);
} else {
$number_array['code'] = -4;
$number_array['msg'] = '生成类型:['.$generate_type.']的枚举表数据不存在';
return $number_array;
}
Log::error('生成编号:'.$new_number);
$number_array['data'] = $new_number;
return $number_array;
}
/**
* 创建二维码
*
* @param string $url 目录 http://www.xxx.com or https://xx.xx.xx.xx
* @param string $type
* @return void
*/
public static function createQRCode($url, $type=''){
require_once "../vendor/phpqrcode/phpqrcode.php";
$value = $url; //二维码内容
$errorCorrectionLevel = 'L'; //容错级别
$matrixPointSize = 7; //生成图片大小
//生成二维码图片
$sha1 = "GZQR";//"qrcode";
$path = date("YmdHis",time()).rand(1000,9999);
$extract = $sha1."_".$path;
$date = date('Ymd');
$Path = config('uploadFile.img_path') . DS . 'uploads' . DS . $date;
if (!file_exists($Path)) {
//检查是否有该文件夹,如果没有就创建,并给予最高权限
mkdir($Path, 0777, true);
}
if (empty($type)) {
$filename = DS . 'uploads' . DS . $date . DS . $extract . ".png";
$filePath = $Path . DS . "$extract.png";
QRcode::png($value,$filePath , $errorCorrectionLevel, $matrixPointSize, 2);
$QR = $filePath; //已经生成的原始二维码图片文件
$QR = imagecreatefromstring(file_get_contents($QR));
//输出图片
imagepng($QR, 'qrcode.png');
imagedestroy($QR);
} else {//报告防伪二维码
$errorCorrectionLevel = 'H';//容错级别
$matrixPointSize = 4;//生成图片大小
$filename = DS . 'uploads' . DS . $date . DS . $extract . ".png";
$filePath = $Path . DS . "$extract.png";
$logo = ROOT_PATH . 'public' . DS . 'static/Qrcode.png';
QRcode::png($value, $filePath , $errorCorrectionLevel, $matrixPointSize, 2);
$QR = $filePath; //已经生成的原始二维码图片文件
$QR = imagecreatefromstring(file_get_contents($QR));
$logo = imagecreatefromstring(file_get_contents($logo));
$QR_width = imagesx($QR);//二维码图片宽度
$QR_height = imagesy($QR);//二维码图片高度
$logo_width = imagesx($logo);//logo图片宽度
$logo_height = imagesy($logo);//logo图片高度
$logo_qr_width = $QR_width / 5;
$scale = $logo_width/$logo_qr_width;
$logo_qr_height = $logo_height/$scale;
$from_width = ($QR_width - $logo_qr_width) / 2;
//重新组合图片并调整大小
imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
//输出图片
imagepng($QR, $filePath);
imagedestroy($QR);
}
$upload = ossUpload(trim(str_replace("\\", "/", $filename), '/'), $filePath);
unlink($filePath); //把本地图片删除(原图)
//二维码地址
$url = config('uploadFile.url') . str_replace("\\", "/", $filename);
return $url;
}
/**
* 数字转金额
* @param $num
* @return string
* @api
* @author fd
* @date-time 2020/5/13-10:22
*/
public function get_amount($num){
$c1 = "零壹贰叁肆伍陆柒捌玖";
$c2 = "分角元拾佰仟万拾佰仟亿";
$num = round($num, 2);
$num = $num * 100;
if (strlen($num) > 10) {
return "数据太长,检查下";
}
$i = 0;
$c = "";
while (1) {
if ($i == 0) {
$n = substr($num, strlen($num)-1, 1);
} else {
$n = $num % 10;
}
$p1 = substr($c1, 3 * $n, 3);
$p2 = substr($c2, 3 * $i, 3);
if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
$c = $p1 . $p2 . $c;
} else {
$c = $p1 . $c;
}
$i = $i + 1;
$num = $num / 10;
$num = (int)$num;
if ($num == 0) {
break;
}
}
$j = 0;
$slen = strlen($c);
while ($j < $slen) {
$m = substr($c, $j, 6);
if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
$left = substr($c, 0, $j);
$right = substr($c, $j + 3);
$c = $left . $right;
$j = $j-3;
$slen = $slen-3;
}
$j = $j + 3;
}
if (substr($c, strlen($c)-3, 3) == '零') {
$c = substr($c, 0, strlen($c)-3);
}
if (empty($c)) {
return "零元整";
}else{
return $c . "";
}
}
/**
* 将日期中数字转成大写
* @param $str
* @return string
* @api
* @author fd
* @date-time 2020/5/13-10:53
*/
function chinanum($str){
$china=array('','一','二','三','四','五','六','七','八','九',);
$arr=str_split($str);
$strChange = '';
for($i=0;$i<count($arr);$i++){
if(is_numeric($arr[$i])){
$strChange = $strChange.$china[$arr[$i]];
}else{
$strChange = $strChange.$arr[$i];
}
}
return $strChange;
}
}