|
@@ -4,7 +4,6 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"time"
|
|
|
- "youngee_b_api/app/consts"
|
|
|
"youngee_b_api/app/dao"
|
|
|
"youngee_b_api/app/entity"
|
|
|
"youngee_b_api/app/util"
|
|
@@ -13,38 +12,43 @@ import (
|
|
|
|
|
|
type InvoiceService struct{}
|
|
|
|
|
|
-// 设置默认开票抬头
|
|
|
-func (s InvoiceService) UpdateInvoiceDefault(param *vo.InvoiceDefaultParam) (*int64, error) {
|
|
|
- var err error
|
|
|
- invoiceInfo, err := dao.InvoiceInfoDao{}.SelectDefault(param.EnterpriseId, param.InvoiceType, 1)
|
|
|
+// 获取企业公司名、税号、注册地址
|
|
|
+func (s InvoiceService) GetEnterpriseMessage(param *vo.InvoiceDefaultParam) (*vo.ReInvoiceInfo, error) {
|
|
|
+ enterpriseInfor, err := dao.EnterpriseDao{}.GetEnterpriseInfo(param.EnterpriseId)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- if invoiceInfo != nil && invoiceInfo.InvoiceID != 0 {
|
|
|
- err := dao.InvoiceInfoDao{}.Delete(invoiceInfo.InvoiceID)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- }
|
|
|
- if param.HeadType == 0 {
|
|
|
- param.HeadType = 1
|
|
|
+ reInvoiceInfo := &vo.ReInvoiceInfo{
|
|
|
+ InvoiceHeader: enterpriseInfor.BusinessName,
|
|
|
+ TaxCode: enterpriseInfor.TaxNumber,
|
|
|
+ RegisteredAddress: enterpriseInfor.Address,
|
|
|
}
|
|
|
- enterprise, err1 := dao.EnterpriseDao{}.GetEnterpriseInfo(param.EnterpriseId)
|
|
|
- if err1 != nil {
|
|
|
- return nil, err1
|
|
|
+ return reInvoiceInfo, nil
|
|
|
+}
|
|
|
+
|
|
|
+// 设置默认开票抬头(只针对数电专票)
|
|
|
+func (s InvoiceService) UpdateInvoiceDefault(param *vo.InvoiceDefaultParam) (*int64, error) {
|
|
|
+ err := dao.InvoiceInfoDao{}.Delete(entity.InvoiceInfo{
|
|
|
+ EnterpriseID: param.EnterpriseId,
|
|
|
+ InvoiceType: 2,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
}
|
|
|
+ //enterprise, err1 := dao.EnterpriseDao{}.GetEnterpriseInfo(param.EnterpriseId)
|
|
|
+ //if err1 != nil {
|
|
|
+ // return nil, err1
|
|
|
+ //}
|
|
|
invoiceInfoAdd := entity.InvoiceInfo{
|
|
|
- EnterpriseID: param.EnterpriseId,
|
|
|
- InvoiceType: param.InvoiceType,
|
|
|
- HeadType: consts.GetHeadType(param.HeadType),
|
|
|
- InvoiceHeader: enterprise.BusinessName,
|
|
|
- TaxCode: enterprise.TaxNumber,
|
|
|
- RegisteredAddress: enterprise.Address,
|
|
|
- RegisteredPhone: param.RegisteredPhone,
|
|
|
- Bank: param.Bank,
|
|
|
- BankCardNumber: param.BankCardNumber,
|
|
|
- IsDefault: 1,
|
|
|
- UpdateAt: time.Now(),
|
|
|
+ EnterpriseID: param.EnterpriseId,
|
|
|
+ InvoiceType: 2,
|
|
|
+ //InvoiceHeader: enterprise.BusinessName,
|
|
|
+ //TaxCode: enterprise.TaxNumber,
|
|
|
+ //RegisteredAddress: enterprise.Address,
|
|
|
+ // 只有数电专票且注册电话、开户银行、银行账号可修改
|
|
|
+ RegisteredPhone: param.RegisteredPhone,
|
|
|
+ Bank: param.Bank,
|
|
|
+ BankCardNumber: param.BankCardNumber,
|
|
|
}
|
|
|
err = dao.InvoiceInfoDao{}.Insert(&invoiceInfoAdd)
|
|
|
if err != nil {
|
|
@@ -54,22 +58,19 @@ func (s InvoiceService) UpdateInvoiceDefault(param *vo.InvoiceDefaultParam) (*in
|
|
|
return &invoiceInfoAdd.InvoiceID, nil
|
|
|
}
|
|
|
|
|
|
-// 获取默认开票抬头
|
|
|
+// 获取默认数电专票开票抬头
|
|
|
func (s InvoiceService) GetInvoiceDefault(param *vo.InvoiceDefaultParam) (*vo.ReInvoiceInfo, error) {
|
|
|
- invoiceInfo, err := dao.InvoiceInfoDao{}.SelectDefault(param.EnterpriseId, param.InvoiceType, 1)
|
|
|
+ invoiceInfo, err := dao.InvoiceInfoDao{}.SelectDefault(param.EnterpriseId, 2)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- reInvoiceInfo := &vo.ReInvoiceInfo{
|
|
|
- InvoiceHeader: invoiceInfo.InvoiceHeader,
|
|
|
- TaxCode: invoiceInfo.TaxCode,
|
|
|
- RegisteredAddress: invoiceInfo.RegisteredAddress,
|
|
|
- RegisteredPhone: invoiceInfo.RegisteredPhone,
|
|
|
- Bank: invoiceInfo.Bank,
|
|
|
- BankCardNumber: invoiceInfo.BankCardNumber,
|
|
|
- IsDefault: invoiceInfo.IsDefault,
|
|
|
+ var reInvoiceInfo vo.ReInvoiceInfo
|
|
|
+ if invoiceInfo != nil {
|
|
|
+ reInvoiceInfo.RegisteredPhone = invoiceInfo.RegisteredPhone
|
|
|
+ reInvoiceInfo.Bank = invoiceInfo.Bank
|
|
|
+ reInvoiceInfo.BankCardNumber = invoiceInfo.BankCardNumber
|
|
|
}
|
|
|
- return reInvoiceInfo, nil
|
|
|
+ return &reInvoiceInfo, nil
|
|
|
}
|
|
|
|
|
|
// 确认开票
|