You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
<?php
|
|
|
|
namespace app\model;
|
|
|
|
use app\service\invoice\InvoiceIssuanceService;
|
|
use fast\FuncException;
|
|
use think\Model;
|
|
|
|
class InvoiceHead extends Model
|
|
{
|
|
|
|
public static $typeArr = ['单位', '个人'];
|
|
|
|
/**
|
|
*
|
|
* @param $wechat_user_id
|
|
* @param $pucode
|
|
* @param $data
|
|
* @return mixed
|
|
* @throws FuncException
|
|
*/
|
|
public static function createHead($wechat_user_id, $pucode, $data)
|
|
{
|
|
|
|
$feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($data['pucode']);
|
|
|
|
$tax_number = $data['tax_number'] ?? '';
|
|
if (!$tax_number) $tax_number = $feeUserInfo['CertificateCode'] ?? '';
|
|
|
|
$param = [
|
|
'tax_number' => $tax_number,
|
|
'pucode' => $pucode,
|
|
'wechat_user_id' => $wechat_user_id
|
|
];
|
|
|
|
$id = self::where($param)->value('id');
|
|
if ($id) {
|
|
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']: '';
|
|
$param['bank_account'] = isset($feeUserInfo['BankAccountCode']) && !empty($feeUserInfo['BankAccountCode']) ? $feeUserInfo['BankAccountCode']: '';
|
|
$param['create_time'] = time();
|
|
$param['pucode'] = $pucode;
|
|
|
|
|
|
return self::insertGetId($param);
|
|
}
|
|
|
|
}
|
|
|