|
|
|
@ -3,6 +3,9 @@ declare (strict_types = 1); |
|
|
|
|
|
|
|
namespace app\command; |
|
|
|
|
|
|
|
use app\model\InvoiceHead; |
|
|
|
use app\model\WechatPucode; |
|
|
|
use app\service\invoice\InvoiceIssuanceService; |
|
|
|
use app\service\user\UserService; |
|
|
|
use app\service\webService\FeeService; |
|
|
|
use think\console\Command; |
|
|
|
@ -27,6 +30,7 @@ class ExportExcel extends Command |
|
|
|
set_time_limit(0); // 无时间限制 |
|
|
|
ini_set('memory_limit', '512M'); // 增加内存限制 |
|
|
|
$this->runData(); |
|
|
|
//$this->runHeadData(); |
|
|
|
// 指令输出 |
|
|
|
$output->writeln('exportexcel'); |
|
|
|
} |
|
|
|
@ -80,20 +84,28 @@ class ExportExcel extends Command |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($taxId) { |
|
|
|
// $str = '0-9A-HJ-NPQRTUWXY'; |
|
|
|
// $pattern = '/^[' . $str . ']{2}\d{6}[' . $str . ']{10}$/'; |
|
|
|
// if (!preg_match($pattern, $taxId)) { |
|
|
|
// $error_array[] = "第{$key}行:纳税人编号格式不符合"; |
|
|
|
// continue; |
|
|
|
// } |
|
|
|
} |
|
|
|
$typeArr = ['单位', '个人']; |
|
|
|
if (!in_array($type, $typeArr)) { |
|
|
|
$error_array[] = "第{$key}行:抬头类型不符合"; |
|
|
|
continue; |
|
|
|
} |
|
|
|
$type = array_search($type, $typeArr); |
|
|
|
if ($taxId) { |
|
|
|
if ($type === 1) { |
|
|
|
$str = '0-9A-HJ-NPQRTUWXY'; |
|
|
|
$pattern = '/^[' . $str . ']{2}\d{6}[' . $str . ']{10}$/'; |
|
|
|
if (!preg_match($pattern, $taxId)) { |
|
|
|
$error_array[] = "第{$key}行:纳税人编号格式不符合"; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} else { |
|
|
|
$pattern = '/^\d{15}$|^\d{17}[\dXx]$/'; |
|
|
|
if (!preg_match($pattern, $taxId)) { |
|
|
|
$error_array[] = "第{$key}行:纳税人编号格式不符合"; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
UserService::addUser((int)$phone, $email, $pucode, $taxId, (int)$type); |
|
|
|
} |
|
|
|
|
|
|
|
@ -101,4 +113,39 @@ class ExportExcel extends Command |
|
|
|
\think\facade\Log::info(json_encode($error_array)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected function runHeadData() |
|
|
|
{ |
|
|
|
$data = InvoiceHead::where('pucode','=','')->select()->toArray(); |
|
|
|
foreach ($data as $item) { |
|
|
|
|
|
|
|
$wechatPucode = WechatPucode::where('wechat_user_id',$item['wechat_user_id'])->select()->toArray(); |
|
|
|
foreach ($wechatPucode as $pucodeItem) { |
|
|
|
|
|
|
|
$pucode = $pucodeItem['pucode']; |
|
|
|
try { |
|
|
|
$feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($pucode); |
|
|
|
} catch (\Exception $e) { |
|
|
|
// 不存在跳过 |
|
|
|
continue; |
|
|
|
} |
|
|
|
$CertificateCode = $feeUserInfo['CertificateCode'] ?? ''; |
|
|
|
$UserName = $feeUserInfo['UserName'] ?? ''; |
|
|
|
if (empty($UserName) && empty($CertificateCode)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 存在更新pucode |
|
|
|
if ($CertificateCode == $item['tax_number'] || $UserName == $item['title']) { |
|
|
|
$save = ['pucode' => $pucode]; |
|
|
|
if (empty($item['tax_number'])) { |
|
|
|
$save['tax_number'] = $CertificateCode; |
|
|
|
} |
|
|
|
if (empty($item['title'])) { |
|
|
|
$save['title'] = $UserName; |
|
|
|
} |
|
|
|
InvoiceHead::update($save,['id' => $item['id']]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|