Browse Source

生成抬头信息优化,导入用户信息优化

master
wanghongjun 9 months ago
parent
commit
c8cbbc0763
  1. 4
      app/controller/api/InvoiceIssuance.php
  2. 9
      app/model/InvoiceHead.php
  3. 7
      app/service/invoice/InvoiceIssuanceService.php
  4. 53
      app/service/user/UserService.php

4
app/controller/api/InvoiceIssuance.php

@ -85,13 +85,15 @@ class InvoiceIssuance extends Base
throw new \Exception('纳税人编号格式错误');
}
}
$wechat_user_id = $this->request->wechat_user_id;
$res = InvoiceIssuanceService::validateFeePay(
$param['pucode'],
$param['expire_time'],
$param['project_id'],
$param['merge'],
$tax_number
$tax_number,
$wechat_user_id
);
return $this->buildSuccess($res);

9
app/model/InvoiceHead.php

@ -23,12 +23,10 @@ class InvoiceHead extends Model
$feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($data['pucode']);
$tax_number = $feeUserInfo['CertificateCode'] ?? '';
if (!$tax_number) $tax_number = $data['tax_number'];
$tax_number = $data['tax_number'] ?? '';
if (!$tax_number) $tax_number = $feeUserInfo['CertificateCode'] ?? '';
$param = [
'type' => $data['type'],
'title' => $feeUserInfo['UserName'] ?? '',
'tax_number' => $tax_number,
'wechat_user_id' => $wechat_user_id
];
@ -38,6 +36,9 @@ class InvoiceHead extends Model
return $id;
}
$param['type'] = $data['type'];
$param['title'] = $feeUserInfo['UserName'] ?? '';
$param['address'] = isset($feeUserInfo['MaillingAddress']) && !empty($feeUserInfo['MaillingAddress']) ? $feeUserInfo['MaillingAddress']: '';
$param['telephone'] = isset($feeUserInfo['Telephone']) && !empty($feeUserInfo['Telephone']) ? $feeUserInfo['Telephone']: '';
$param['bank_name'] = isset($feeUserInfo['BankName']) && !empty($feeUserInfo['BankName']) ? $feeUserInfo['BankName']: '';

7
app/service/invoice/InvoiceIssuanceService.php

@ -85,10 +85,11 @@ class InvoiceIssuanceService
* @param $project_id
* @param string $merge 是否合并
* @param string $tax_number
* @param int $wechat_user_id
* @return string[]
* @throws FuncException
*/
public static function validateFeePay($pucode, $expire_time, $project_id, string $merge = '', string $tax_number = ''): array
public static function validateFeePay($pucode, $expire_time, $project_id, string $merge = '', string $tax_number = '', int $wechat_user_id = 0): array
{
$expire_date = date('Ym', strtotime($expire_time));
@ -103,7 +104,7 @@ class InvoiceIssuanceService
throw new FuncException('请填写纳税人编号');
}
$pucodeArr = UserService::getTaxUser($tax_number);
$pucodeArr = UserService::getTaxUser($tax_number, $wechat_user_id);
if (empty($pucodeArr)) {
throw new FuncException('登录的用户id与纳税人编号不符,请重新输入');
}
@ -252,7 +253,7 @@ class InvoiceIssuanceService
$pucodeArr = [$pucode];
if ($invoiceIssuance['merge'] == 1) {
$pucodeArr = UserService::getTaxUser($bdznsrsbh);
$pucodeArr = UserService::getTaxUser($bdznsrsbh, $invoiceIssuance['wechat_user_id']);
}
// 多组用户编号

53
app/service/user/UserService.php

@ -67,32 +67,50 @@ class UserService extends BaseService
$save = [
'nickname' => '导入用户',
'phone' => $phone,
'email' => $email
'email' => $email,
'create_time' => time()
];
$id = (new WechatUser())->insertGetId($save);
} else {
$id = $query['id'];
$query->email = $email;
$query->save();
}
if ($id) {
if ($id) {
$puCodeQuery = (new WechatPucode())->where('wechat_user_id', $id)->find();
if ($puCodeQuery) {
$puCodeQuery->pucode = $pucode;
$puCodeQuery->create_time = time();
$puCodeQuery->save();
} else {
$codeSave = [
'wechat_user_id' => $id,
'pucode' => $pucode,
'create_time' => time()
];
(new WechatPucode())->save($codeSave);
}
$headSave = [
'wechat_user_id' => $id
];
if ($codeSave) {
$headSave = [
'tax_number' => $tax_number,
];
$headQuery = InvoiceHead::where($headSave)->find();
if (!$headQuery) {
$headSave['type'] = $type;
$headSave['phone'] = $phone;
$headSave['wechat_user_id'] = $id;
$headSave['create_time'] = time();
(new InvoiceHead())->save($headSave);
}
}
$headQuery = (new InvoiceHead())->where($headSave)->order('id desc')->find();
if ($headQuery) {
$headQuery->type = $type;
$headQuery->tax_number = $tax_number;
$headQuery->phone = $phone;
$headQuery->create_time = time();
$headQuery->save();
} else {
$headSave['type'] = $type;
$headSave['tax_number'] = $tax_number;
$headSave['phone'] = $phone;
$headSave['create_time'] = time();
(new InvoiceHead())->save($headSave);
}
return 1;
@ -100,10 +118,11 @@ class UserService extends BaseService
return 0;
}
public static function getTaxUser($tax_id)
public static function getTaxUser($tax_id, $wechat_user_id)
{
$where = [
'tax_number' => $tax_id
['tax_number', '=', $tax_id],
['wechat_user_id', '<>', $wechat_user_id],
];
$user_ids = InvoiceHead::where($where)->column('wechat_user_id');

Loading…
Cancel
Save