|
|
@ -7,7 +7,6 @@ use app\model\InvoiceIssuance as InvoiceIssuanceModel; |
|
|
use app\model\InvoiceIssuanceData; |
|
|
use app\model\InvoiceIssuanceData; |
|
|
use app\model\WechatPucode; |
|
|
use app\model\WechatPucode; |
|
|
use app\service\invoice\InvoiceIssuanceService; |
|
|
use app\service\invoice\InvoiceIssuanceService; |
|
|
use app\service\webService\FeeService; |
|
|
|
|
|
use app\util\ReturnCode; |
|
|
use app\util\ReturnCode; |
|
|
use app\validate\InvoiceHeadValidate; |
|
|
use app\validate\InvoiceHeadValidate; |
|
|
use app\validate\InvoiceIssuanceValidate; |
|
|
use app\validate\InvoiceIssuanceValidate; |
|
|
@ -130,13 +129,17 @@ class InvoiceIssuance extends Base |
|
|
try { |
|
|
try { |
|
|
$wechat_user_id = $this->request->wechat_user_id; |
|
|
$wechat_user_id = $this->request->wechat_user_id; |
|
|
|
|
|
|
|
|
|
|
|
$field = 'type, title, tax_number'; |
|
|
|
|
|
$where = [ |
|
|
|
|
|
['wechat_user_id', '=', $wechat_user_id], |
|
|
|
|
|
['tax_number', '<>', ''], |
|
|
|
|
|
]; |
|
|
|
|
|
$data = (new InvoiceHead())->where($where)->field($field)->order('id', 'DESC')->find(); |
|
|
|
|
|
if (!$data) { |
|
|
$pucode = (new WechatPucode())->where('wechat_user_id', $wechat_user_id)->value('pucode'); |
|
|
$pucode = (new WechatPucode())->where('wechat_user_id', $wechat_user_id)->value('pucode'); |
|
|
|
|
|
|
|
|
$FeeService = new FeeService($pucode); |
|
|
$feeUserInfo = (new InvoiceIssuanceService())->getFeeUserData($pucode); |
|
|
$feeUserInfo = $FeeService->getUsers(); |
|
|
|
|
|
if (!$feeUserInfo) { |
|
|
|
|
|
throw new \Exception('用户信息获取失败'); |
|
|
|
|
|
} |
|
|
|
|
|
$data = [ |
|
|
$data = [ |
|
|
'title' => $feeUserInfo['UserName'] ?? '', |
|
|
'title' => $feeUserInfo['UserName'] ?? '', |
|
|
]; |
|
|
]; |
|
|
@ -145,14 +148,7 @@ class InvoiceIssuance extends Base |
|
|
$data['type'] = 1; |
|
|
$data['type'] = 1; |
|
|
} |
|
|
} |
|
|
$data['tax_number'] = empty($feeUserInfo['CertificateCode']) ? $feeUserInfo['CertificateCode'] : ''; |
|
|
$data['tax_number'] = empty($feeUserInfo['CertificateCode']) ? $feeUserInfo['CertificateCode'] : ''; |
|
|
|
|
|
} |
|
|
// if ($data['type'] === 0) { |
|
|
|
|
|
// $data['address'] = $feeUserInfo['MaillingAddress']; |
|
|
|
|
|
// $data['telephone'] = $feeUserInfo['Telephone']; |
|
|
|
|
|
// $data['bank_name'] = $feeUserInfo['BankName']; |
|
|
|
|
|
// $data['bank_account'] = $feeUserInfo['BankAccountCode']; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
return $this->buildSuccess($data); |
|
|
return $this->buildSuccess($data); |
|
|
} catch (\Exception $e) { |
|
|
} catch (\Exception $e) { |
|
|
return $this->buildFailed(ReturnCode::NOT_EXISTS, $e->getMessage()); |
|
|
return $this->buildFailed(ReturnCode::NOT_EXISTS, $e->getMessage()); |
|
|
@ -200,7 +196,7 @@ class InvoiceIssuance extends Base |
|
|
//验证 、 新建抬头、获取抬头id |
|
|
//验证 、 新建抬头、获取抬头id |
|
|
validate(InvoiceHeadValidate::class)->scene('type')->check($params); |
|
|
validate(InvoiceHeadValidate::class)->scene('type')->check($params); |
|
|
validate(InvoiceHeadValidate::class)->scene('type'.$params['type'])->check($params); |
|
|
validate(InvoiceHeadValidate::class)->scene('type'.$params['type'])->check($params); |
|
|
$data['invoice_head_id'] = InvoiceHead::createHead($wechat_user_id,$params); |
|
|
$data['invoice_head_id'] = InvoiceHead::createHead($wechat_user_id, $params); |
|
|
|
|
|
|
|
|
if ($id) { |
|
|
if ($id) { |
|
|
validate(InvoiceIssuanceValidate::class)->scene('edit')->check($params); |
|
|
validate(InvoiceIssuanceValidate::class)->scene('edit')->check($params); |
|
|
|