Ethan 4 сар өмнө
parent
commit
816e8c7c6f

+ 3 - 6
app/controller/account_controller.go

@@ -4,17 +4,14 @@ import (
 	"github.com/gin-gonic/gin"
 	"github.com/sirupsen/logrus"
 	"youngee_b_api/app/service/review_service"
+	"youngee_b_api/app/vo"
 )
 
 type AccountController struct{}
 
-type IdentifyParam struct {
-	BusinessLicenseUrl string `json:"business_license_url"`
-}
-
 // 营业执照OCR识别
 func (t AccountController) OCRIdentify(c *gin.Context) {
-	param := &IdentifyParam{}
+	param := &vo.IdentifyParam{}
 	err := c.BindJSON(param)
 	if err != nil {
 		logrus.Errorf("Request bind err:%+v\n", err)
@@ -22,7 +19,7 @@ func (t AccountController) OCRIdentify(c *gin.Context) {
 		return
 	}
 	reviewService := review_service.GetConfig()
-	resultMap, err := reviewService.CheckBusinessLicense(param.BusinessLicenseUrl)
+	resultMap, err := reviewService.CheckBusinessLicense(param)
 	if err != nil {
 		logrus.Errorf("[OCRIdentify] call Show err:%+v\n", err)
 		returnError(c, 40000, err.Error())

+ 9 - 0
app/dao/enterprise_dao.go

@@ -81,3 +81,12 @@ func (d EnterpriseDao) UpdateEnterpriseBalanceAndFrozen(enterpriseId string, amo
 	}
 	return &enterpriseId, nil
 }
+
+// 更新商家信息
+func (d EnterpriseDao) UpdateEnterprise(enterprise entity.Enterprise) error {
+	err := Db.Model(&entity.Enterprise{}).Where("enterprise_id = ?", enterprise.EnterpriseID).Updates(enterprise).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 1 - 1
app/dao/recharge_record_dao.go

@@ -9,7 +9,7 @@ import (
 type RechargeRecordDao struct{}
 
 func (d RechargeRecordDao) Insert(rechargeRecord *entity.RechargeRecord) error {
-	err := Db.Debug().Model(entity.RechargeRecord{}).Omit("confirm_at").Create(rechargeRecord).Error
+	err := Db.Debug().Model(entity.RechargeRecord{}).Omit("confirm_at", "refuse_at").Create(rechargeRecord).Error
 	if err != nil {
 		return err
 	}

+ 8 - 3
app/entity/enterprise.go

@@ -6,9 +6,12 @@ import (
 )
 
 type Enterprise struct {
-	EnterpriseID     string    `gorm:"column:enterprise_id"`     // 企业id,用户ID的生成规则为:1(企业用户代码)+分秒数字+四位随机数字
-	Industry         int64     `gorm:"column:industry"`          // 行业,1-14分别代表能源、化工、材料、机械设备/军工、企业服务/造纸印刷、运输设备、旅游酒店、媒体/信息通信服务、批发/零售、消费品、卫生保健/医疗、金融、建材/建筑/房地产、公共事业
-	BusinessName     string    `gorm:"column:business_name"`     // 公司或组织名称
+	EnterpriseID string `gorm:"column:enterprise_id"` // 企业id,用户ID的生成规则为:1(企业用户代码)+分秒数字+四位随机数字
+	Industry     int64  `gorm:"column:industry"`      // 行业,1-14分别代表能源、化工、材料、机械设备/军工、企业服务/造纸印刷、运输设备、旅游酒店、媒体/信息通信服务、批发/零售、消费品、卫生保健/医疗、金融、建材/建筑/房地产、公共事业
+	BusinessName string `gorm:"column:business_name"` // 公司或组织名称
+	TaxNumber    string `gorm:"column:tax_number"`
+	Address      string `gorm:"column:address"`
+
 	UserId           int64     `gorm:"column:user_id"`           // 对应用户id
 	Balance          float64   `gorm:"column:balance"`           // 账户余额
 	FrozenBalance    float64   `gorm:"column:frozen_balance"`    // 冻结余额
@@ -18,6 +21,8 @@ type Enterprise struct {
 	Recharging       float64   `gorm:"column:recharging"`        // 充值中金额
 	CreatedAt        time.Time `gorm:"column:created_at"`        // 创建时间
 	UpdatedAt        time.Time `gorm:"column:updated_at"`        // 更新时间
+	AuthStatus       int64     `gorm:"column:auth_status"`
+	Phone            string    `gorm:"column:phone"`
 }
 
 func (m *Enterprise) TableName() string {

+ 7 - 3
app/service/invoice_service.go

@@ -29,13 +29,17 @@ func (s InvoiceService) UpdateInvoiceDefault(param *vo.InvoiceDefaultParam) (*in
 	if param.HeadType == 0 {
 		param.HeadType = 1
 	}
+	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:     param.InvoiceHead,
-		TaxCode:           param.TaxCode,
-		RegisteredAddress: param.RegisteredAddress,
+		InvoiceHeader:     enterprise.BusinessName,
+		TaxCode:           enterprise.TaxNumber,
+		RegisteredAddress: enterprise.Address,
 		RegisteredPhone:   param.RegisteredPhone,
 		Bank:              param.Bank,
 		BankCardNumber:    param.BankCardNumber,

+ 20 - 3
app/service/review_service/business_license_check.go

@@ -2,12 +2,15 @@ package review_service
 
 import (
 	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ocr/v1/model"
+	"youngee_b_api/app/dao"
+	"youngee_b_api/app/entity"
+	"youngee_b_api/app/vo"
 )
 
-func (c *Config) CheckBusinessLicense(businessLicenseUrl string) (map[string]string, error) {
+func (c *Config) CheckBusinessLicense(param *vo.IdentifyParam) (map[string]string, error) {
 	request := &model.RecognizeBusinessLicenseRequest{}
 	request.Body = &model.BusinessLicenseRequestBody{
-		Url: &businessLicenseUrl,
+		Url: &param.BusinessLicenseUrl,
 	}
 	response, err := c.OcrClient.RecognizeBusinessLicense(request)
 	if err != nil {
@@ -19,9 +22,23 @@ func (c *Config) CheckBusinessLicense(businessLicenseUrl string) (map[string]str
 	result := response.Result
 	registrationNumber := result.RegistrationNumber
 	companyName := result.Name
+	address := result.Address
+	bodyType := result.Type // 公司/企业类型/主体类型/类型
+	err1 := dao.EnterpriseDao{}.UpdateEnterprise(entity.Enterprise{
+		EnterpriseID: param.EnterpriseId,
+		BusinessName: *companyName,
+		TaxNumber:    *registrationNumber,
+		Address:      *address,
+		AuthStatus:   1,
+	})
+	if err1 != nil {
+		return nil, err1
+	}
 	resultMap := make(map[string]string)
-	resultMap["registrationNumber"] = *registrationNumber
+	resultMap["registrationNumber"] = *registrationNumber // 企业税号
 	resultMap["companyName"] = *companyName
+	resultMap["address"] = *address
+	resultMap["type"] = *bodyType
 
 	return resultMap, nil
 }

+ 7 - 0
app/vo/identify_param.go

@@ -0,0 +1,7 @@
+package vo
+
+type IdentifyParam struct {
+	BusinessLicenseUrl string `json:"business_license_url"`
+	EnterpriseId       string `json:"enterprise_id"`
+	SubAccountId       int64  `json:"sub_account_id"`
+}

+ 6 - 6
app/vo/invoice_default_param.go

@@ -4,11 +4,11 @@ type InvoiceDefaultParam struct {
 	EnterpriseId string `json:"enterprise_id"`
 	HeadType     int64  `json:"head_type"`    // 抬头类型(1企业 2个人)
 	InvoiceType  int64  `json:"invoice_type"` // 发票类型(1数电普票 2数电专票)
-	InvoiceHead  string `json:"invoice_head"` //发票抬头(企业名称)
-	TaxCode      string `json:"tax_code"`     // 企业税号
+	//InvoiceHead  string `json:"invoice_head"` //发票抬头(企业名称)
+	//TaxCode      string `json:"tax_code"`     // 企业税号
 
-	RegisteredAddress string `json:"registered_address"` // 企业注册地址
-	RegisteredPhone   string `json:"registered_phone"`   // 企业注册电话
-	Bank              string `json:"bank"`               // 开户银行
-	BankCardNumber    string `json:"bank_card_number"`   // 银行账号
+	//RegisteredAddress string `json:"registered_address"` // 企业注册地址
+	RegisteredPhone string `json:"registered_phone"` // 企业注册电话
+	Bank            string `json:"bank"`             // 开户银行
+	BankCardNumber  string `json:"bank_card_number"` // 银行账号
 }