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.
50 lines
1.2 KiB
50 lines
1.2 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 $data
|
|
* @return mixed
|
|
* @throws FuncException
|
|
*/
|
|
public static function createHead($wechat_user_id, $data)
|
|
{
|
|
|
|
$feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($data['pucode']);
|
|
|
|
$param = [
|
|
'type' => $data['type'],
|
|
'title' => $feeUserInfo['UserName'] ?? '',
|
|
'tax_number' => $feeUserInfo['CertificateCode'] ?? '',
|
|
'wechat_user_id' => $wechat_user_id
|
|
];
|
|
|
|
$id = self::where($param)->value('id');
|
|
if ($id) {
|
|
return $id;
|
|
}
|
|
|
|
$param['address'] = $feeUserInfo['MaillingAddress'] ?? '';
|
|
$param['telephone'] = $feeUserInfo['Telephone'] ?? '';
|
|
$param['bank_name'] = $feeUserInfo['BankName'] ?? '';
|
|
$param['bank_account'] = $feeUserInfo['BankAccountCode'] ?? '';
|
|
$param['create_time'] = time();
|
|
|
|
|
|
$model = self::create($param);
|
|
|
|
return $model->where($param)->value('id');
|
|
}
|
|
|
|
}
|
|
|