Browse Source

同步线上代码3

master
wanghongjun 3 weeks ago
parent
commit
6ad76578d2
  1. 24
      app/controller/admin/WechatUser.php
  2. 7
      app/controller/api/InvoiceIssuance.php
  3. 18
      app/service/invoice/InvoiceIssuanceService.php
  4. 8
      app/service/user/UserService.php

24
app/controller/admin/WechatUser.php

@ -129,22 +129,15 @@ class WechatUser extends Base
$error_array = []; $error_array = [];
foreach ($excel_array as $key => $data) { foreach ($excel_array as $key => $data) {
$key = $key + 1; $key = $key + 1;
// 验证不能为空
$is_empty = false;
foreach ($data as $value) {
if (empty($value)) {
$is_empty = true;
break;
}
}
if ($is_empty) {
continue;
}
$phone = $data[0]; $phone = $data[0];
$email = $data[1]; $email = $data[1] ?? '';
$pucode = $data[2]; $pucode = $data[2];
$taxId = $data[3]; $taxId = $data[3] ?? '';
$type = $data[4]; $type = $data[4];
// 验证不能为空
if (empty($phone) || empty($pucode) || empty($type)) {
continue;
}
if (!preg_match('/^1[3-9]\d{9}$/', $phone)) { if (!preg_match('/^1[3-9]\d{9}$/', $phone)) {
$error_array[] = "第{$key}行:手机号格式不符合"; $error_array[] = "第{$key}行:手机号格式不符合";
continue; continue;
@ -161,17 +154,20 @@ class WechatUser extends Base
$error_array[] = "第{$key}行:手机号或用户编号错误"; $error_array[] = "第{$key}行:手机号或用户编号错误";
continue; continue;
} }
if ($email) {
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
$error_array[] = "第{$key}行:邮箱格式不符合"; $error_array[] = "第{$key}行:邮箱格式不符合";
continue; continue;
} }
}
if ($taxId) {
$str = '0-9A-HJ-NPQRTUWXY'; $str = '0-9A-HJ-NPQRTUWXY';
$pattern = '/^[' . $str . ']{2}\d{6}[' . $str . ']{10}$/'; $pattern = '/^[' . $str . ']{2}\d{6}[' . $str . ']{10}$/';
if (!preg_match($pattern, $taxId)) { if (!preg_match($pattern, $taxId)) {
$error_array[] = "第{$key}行:纳税人编号格式不符合"; $error_array[] = "第{$key}行:纳税人编号格式不符合";
continue; continue;
} }
}
$typeArr = ['单位', '个人']; $typeArr = ['单位', '个人'];
if (!in_array($type, $typeArr)) { if (!in_array($type, $typeArr)) {
$error_array[] = "第{$key}行:抬头类型不符合"; $error_array[] = "第{$key}行:抬头类型不符合";

7
app/controller/api/InvoiceIssuance.php

@ -141,12 +141,11 @@ class InvoiceIssuance extends Base
$userRes = (new WechatUser())->where('id', $wechat_user_id)->find(); $userRes = (new WechatUser())->where('id', $wechat_user_id)->find();
$data['email'] = $userRes['email']; $data['email'] = $userRes['email'];
$feeUserInfo = [];
if (!isset($data['tax_number']) || empty($userRes['email'])) {
$pucode = (new WechatPucode())->where('wechat_user_id', $wechat_user_id)->value('pucode'); $pucode = (new WechatPucode())->where('wechat_user_id', $wechat_user_id)->value('pucode');
$feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($pucode); $feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($pucode);
if ($data['title'] != $feeUserInfo['UserName'] && isset($data['tax_number'])) {
unset($data['tax_number']);
} }
if (empty($data['email'])) { if (empty($data['email'])) {
@ -190,7 +189,7 @@ class InvoiceIssuance extends Base
$wechat_user_id = $this->request->wechat_user_id; $wechat_user_id = $this->request->wechat_user_id;
$pucode = $param['pucode'] ?? ''; $pucode = $params['pucode'] ?? '';
if (!$pucode) { if (!$pucode) {
$pucode = WechatPucode::where('wechat_user_id', $wechat_user_id)->order('create_time desc')->value('pucode'); $pucode = WechatPucode::where('wechat_user_id', $wechat_user_id)->order('create_time desc')->value('pucode');
if (!$pucode) throw new \Exception('请先绑定用户编号'); if (!$pucode) throw new \Exception('请先绑定用户编号');

18
app/service/invoice/InvoiceIssuanceService.php

@ -188,13 +188,18 @@ class InvoiceIssuanceService
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
public function getTaxNumber($invoice_head_id) public function getTaxNumber($invoice_head_id, $CertificateCode = '')
{ {
$bdznsrsbh = '91440300772709730N'; // 被代征纳税人识别号 【默认大工业水务税号】 $bdznsrsbh = '91440300772709730N'; // 被代征纳税人识别号 【默认大工业水务税号】
// 如果是企业 需要取填写抬头的税号 // 如果是企业 需要取填写抬头的税号
$invoice_head = (new InvoiceHead())->where('id', $invoice_head_id)->where('type', 0)->field('tax_number')->find(); $invoice_head = (new InvoiceHead())->where('id', $invoice_head_id)->where('type', 0)->field('tax_number')->find();
if ($invoice_head) { if ($invoice_head) {
$bdznsrsbh = $invoice_head['tax_number'] ?? ''; $bdznsrsbh = $invoice_head['tax_number'] ?? '';
if (!empty($CertificateCode) && $bdznsrsbh != $CertificateCode) {
$bdznsrsbh = $CertificateCode;
}
} elseif (!empty($CertificateCode)) {
$bdznsrsbh = $CertificateCode;
} }
return $bdznsrsbh; return $bdznsrsbh;
} }
@ -219,10 +224,6 @@ class InvoiceIssuanceService
$feeUsers = $this->getFeeUserData($pucode); $feeUsers = $this->getFeeUserData($pucode);
$bdznsrsbh = $this->getTaxNumber($invoiceIssuance['invoice_head_id']); // 被代征纳税人识别号
$feeUsers['bdznsrsbh'] = $bdznsrsbh;
// 获取用户应收费信息 // 获取用户应收费信息
$FeeComputeDetail = self::getFeeComputeDetail($pucode, date("Ym", $invoiceIssuance['expire_time'])); $FeeComputeDetail = self::getFeeComputeDetail($pucode, date("Ym", $invoiceIssuance['expire_time']));
if ($FeeComputeDetail['MsgID'] != 1) { if ($FeeComputeDetail['MsgID'] != 1) {
@ -240,6 +241,9 @@ class InvoiceIssuanceService
$feeUsers['WaterPrice'] = $FeeComputeDetail['WaterPrice']; $feeUsers['WaterPrice'] = $FeeComputeDetail['WaterPrice'];
$feeUsers['ThisLastReadingTime'] = $FeeComputeDetail['ThisLastReadingTime']; $feeUsers['ThisLastReadingTime'] = $FeeComputeDetail['ThisLastReadingTime'];
$CertificateCode = !empty($feeUsers['CertificateCode']) ? $feeUsers['CertificateCode'] : '';
$bdznsrsbh = $this->getTaxNumber($invoiceIssuance['invoice_head_id'],$CertificateCode); // 被代征纳税人识别号
$feeUsers['bdznsrsbh'] = $bdznsrsbh;
// 保存 // 保存
$ChinaTaxes = new ChinaTaxes($feeUsers, $invoiceDate); $ChinaTaxes = new ChinaTaxes($feeUsers, $invoiceDate);
@ -314,8 +318,8 @@ class InvoiceIssuanceService
if (!isset($queryUploadErrorData['mxGrid']['sbMxsjVOList']['ycms'])) { if (!isset($queryUploadErrorData['mxGrid']['sbMxsjVOList']['ycms'])) {
throw new FuncException('异常信息返回有误'); throw new FuncException('异常信息返回有误');
} }
// 查询待开具电子缴款 // 查询待开具电子缴款(无法调用)
$queryIssuedPaymentVoucher = $ChinaTaxes->queryIssuedPaymentVoucher($bdznsrsbh); //$queryIssuedPaymentVoucher = $ChinaTaxes->queryIssuedPaymentVoucher($bdznsrsbh);
// 保存用户异常状态 // 保存用户异常状态
$ycms = $queryUploadErrorData['data']['mxGrid']['sbMxsjVOList']['ycms']; // 数据异常描述 $ycms = $queryUploadErrorData['data']['mxGrid']['sbMxsjVOList']['ycms']; // 数据异常描述

8
app/service/user/UserService.php

@ -80,9 +80,9 @@ class UserService extends BaseService
if ($id) { if ($id) {
$puCodeQuery = (new WechatPucode())->where('wechat_user_id', $id)->find(); $puCodeQuery = (new WechatPucode())->where('pucode', $pucode)->where('wechat_user_id', $id)->find();
if ($puCodeQuery) { if ($puCodeQuery) {
$puCodeQuery->pucode = $pucode; $puCodeQuery->wechat_user_id = $id;
$puCodeQuery->create_time = time(); $puCodeQuery->create_time = time();
$puCodeQuery->save(); $puCodeQuery->save();
} else { } else {
@ -98,7 +98,8 @@ class UserService extends BaseService
'wechat_user_id' => $id 'wechat_user_id' => $id
]; ];
$headQuery = (new InvoiceHead())->where($headSave)->order('id desc')->find(); if ($tax_number) {
$headQuery = (new InvoiceHead())->where($headSave)->find();
if ($headQuery) { if ($headQuery) {
$headQuery->type = $type; $headQuery->type = $type;
$headQuery->tax_number = $tax_number; $headQuery->tax_number = $tax_number;
@ -113,6 +114,7 @@ class UserService extends BaseService
$headSave['create_time'] = time(); $headSave['create_time'] = time();
(new InvoiceHead())->save($headSave); (new InvoiceHead())->save($headSave);
} }
}
return 1; return 1;
} }

Loading…
Cancel
Save