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. 39
      app/service/user/UserService.php

4
app/controller/api/InvoiceIssuance.php

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

9
app/model/InvoiceHead.php

@ -23,12 +23,10 @@ class InvoiceHead extends Model
$feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($data['pucode']); $feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($data['pucode']);
$tax_number = $feeUserInfo['CertificateCode'] ?? ''; $tax_number = $data['tax_number'] ?? '';
if (!$tax_number) $tax_number = $data['tax_number']; if (!$tax_number) $tax_number = $feeUserInfo['CertificateCode'] ?? '';
$param = [ $param = [
'type' => $data['type'],
'title' => $feeUserInfo['UserName'] ?? '',
'tax_number' => $tax_number, 'tax_number' => $tax_number,
'wechat_user_id' => $wechat_user_id 'wechat_user_id' => $wechat_user_id
]; ];
@ -38,6 +36,9 @@ class InvoiceHead extends Model
return $id; return $id;
} }
$param['type'] = $data['type'];
$param['title'] = $feeUserInfo['UserName'] ?? '';
$param['address'] = isset($feeUserInfo['MaillingAddress']) && !empty($feeUserInfo['MaillingAddress']) ? $feeUserInfo['MaillingAddress']: ''; $param['address'] = isset($feeUserInfo['MaillingAddress']) && !empty($feeUserInfo['MaillingAddress']) ? $feeUserInfo['MaillingAddress']: '';
$param['telephone'] = isset($feeUserInfo['Telephone']) && !empty($feeUserInfo['Telephone']) ? $feeUserInfo['Telephone']: ''; $param['telephone'] = isset($feeUserInfo['Telephone']) && !empty($feeUserInfo['Telephone']) ? $feeUserInfo['Telephone']: '';
$param['bank_name'] = isset($feeUserInfo['BankName']) && !empty($feeUserInfo['BankName']) ? $feeUserInfo['BankName']: ''; $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 $project_id
* @param string $merge 是否合并 * @param string $merge 是否合并
* @param string $tax_number * @param string $tax_number
* @param int $wechat_user_id
* @return string[] * @return string[]
* @throws FuncException * @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)); $expire_date = date('Ym', strtotime($expire_time));
@ -103,7 +104,7 @@ class InvoiceIssuanceService
throw new FuncException('请填写纳税人编号'); throw new FuncException('请填写纳税人编号');
} }
$pucodeArr = UserService::getTaxUser($tax_number); $pucodeArr = UserService::getTaxUser($tax_number, $wechat_user_id);
if (empty($pucodeArr)) { if (empty($pucodeArr)) {
throw new FuncException('登录的用户id与纳税人编号不符,请重新输入'); throw new FuncException('登录的用户id与纳税人编号不符,请重新输入');
} }
@ -252,7 +253,7 @@ class InvoiceIssuanceService
$pucodeArr = [$pucode]; $pucodeArr = [$pucode];
if ($invoiceIssuance['merge'] == 1) { if ($invoiceIssuance['merge'] == 1) {
$pucodeArr = UserService::getTaxUser($bdznsrsbh); $pucodeArr = UserService::getTaxUser($bdznsrsbh, $invoiceIssuance['wechat_user_id']);
} }
// 多组用户编号 // 多组用户编号

39
app/service/user/UserService.php

@ -67,43 +67,62 @@ class UserService extends BaseService
$save = [ $save = [
'nickname' => '导入用户', 'nickname' => '导入用户',
'phone' => $phone, 'phone' => $phone,
'email' => $email 'email' => $email,
'create_time' => time()
]; ];
$id = (new WechatUser())->insertGetId($save); $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 = [ $codeSave = [
'wechat_user_id' => $id, 'wechat_user_id' => $id,
'pucode' => $pucode, 'pucode' => $pucode,
'create_time' => time() 'create_time' => time()
]; ];
(new WechatPucode())->save($codeSave); (new WechatPucode())->save($codeSave);
}
if ($codeSave) {
$headSave = [ $headSave = [
'tax_number' => $tax_number, 'wechat_user_id' => $id
]; ];
$headQuery = InvoiceHead::where($headSave)->find();
if (!$headQuery) { $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['type'] = $type;
$headSave['tax_number'] = $tax_number;
$headSave['phone'] = $phone; $headSave['phone'] = $phone;
$headSave['wechat_user_id'] = $id;
$headSave['create_time'] = time(); $headSave['create_time'] = time();
(new InvoiceHead())->save($headSave); (new InvoiceHead())->save($headSave);
} }
}
}
return 1; return 1;
} }
return 0; return 0;
} }
public static function getTaxUser($tax_id) public static function getTaxUser($tax_id, $wechat_user_id)
{ {
$where = [ $where = [
'tax_number' => $tax_id ['tax_number', '=', $tax_id],
['wechat_user_id', '<>', $wechat_user_id],
]; ];
$user_ids = InvoiceHead::where($where)->column('wechat_user_id'); $user_ids = InvoiceHead::where($where)->column('wechat_user_id');

Loading…
Cancel
Save