Commit bf308296 by 朱继来

调整发票公司

parent 0cfaa07d
......@@ -8,6 +8,9 @@ dns="LabxsuT:Plz2#$afsPqmz@#5@tcp(172.18.137.34:3306)/lie_labels?parseTime=true"
[Liexincms_databases]
dns="dtuser:dAtaL#ym2902m2lLX2y33@tcp(appdb-master.ichunt.db:3306)/icdata?parseTime=true"
[Liexincrm_databases]
dns="dtuser:LxCrmUser#xUTmu0XsdUqoZIim2y@tcp(172.18.137.21:3306)/liexin_crm?parseTime=true"
[Bom_databases]
dns="BomUserIc:mLssyDxmsymBomy@tcp(172.18.137.21:3306)/liexin_bom?parseTime=true"
......
......@@ -9,6 +9,7 @@ var (
DB *sqlx.DB
LabelDB *sqlx.DB
CmsDB *sqlx.DB
CrmDB *sqlx.DB
BomDB *sqlx.DB
)
......@@ -74,6 +75,22 @@ func InitCmslDB(dns string) error{
return nil
}
func InitCrmDB(dns string) error{
var err error
CrmDB, err = sqlx.Open("mysql", dns)
if err != nil {
return err
}
err = CrmDB.Ping()
if err != nil {
return err
}
CrmDB.SetMaxOpenConns(20)
CrmDB.SetMaxIdleConns(10)
return nil
}
func CreateDB(action string,dns string) error{
var err error
switch action {
......@@ -83,8 +100,10 @@ func CreateDB(action string,dns string) error{
err = InitLabelDB(dns)
case "InitCmsDB":
err = InitCmslDB(dns)
case "InitCmsDB":
err = InitCrmDB(dns)
case "BomDB":
err = InitBomDB(dns)
err = InitBomDB(dns)
}
return err
}
......
package InvoiceCompany
import (
_ "encoding/json"
_ "github.com/ichunt2019/logger"
)
type Company struct {
Id int `db:"id"`
CompanyType int `db:"company_type"`
ComSn string `db:"com_sn"`
ErpComSn string `db:"erp_com_sn"`
ComName string `db:"com_name"`
UserId int `db:"user_id"`
TaxId int `db:"tax_id"`
ComName string `db:"com_name"`
OverseasComNameCn string `db:"overseas_com_name_cn"`
ComAddr string `db:"com_addr"`
ComTel string `db:"com_tel"`
ComTaxRegistration string `db:"com_tax_registration"`
......@@ -42,4 +38,5 @@ type Company struct {
Status int `db:"status"`
CreateTime int `db:"create_time"`
UpdateTime int `db:"update_time"`
ComCnName string `db:"com_cn_name"`
}
......@@ -15,7 +15,7 @@ import (
)
func initDb(dns string) (err error) {
err = db.Init(dns)
err = db.InitCrmDB(dns)
if err != nil {
return
}
......@@ -49,7 +49,7 @@ func main() {
logger.Init()
//初始化db
initDb(util.Configs.Liexin_databases.Dns)
initDb(util.Configs.Liexincrm_databases.Dns)
updateData()
......@@ -59,7 +59,7 @@ func main() {
// 修改DB
func updateData() (err error) {
// 获取未评分的公司
row, err := db.DB.Queryx("select * from lie_invoice_company where total_credit_score = 0")
row, err := db.CrmDB.Queryx("select * from lie_invoice_company where total_credit_score = 0")
if err != nil {
logger.Info("获取未评分公司失败,DB错误原因: ", err.Error())
......@@ -99,7 +99,7 @@ func updateData() (err error) {
curr_time := time.Now().Unix()
// 更新发票公司表
_, err = db.DB.Exec("update lie_invoice_company set erp_com_sn = ?, com_addr = ?, establishment_time = ?, registered_capital = ?, com_organization = ?," +
_, err = db.CrmDB.Exec("update lie_invoice_company set erp_com_sn = ?, com_addr = ?, establishment_time = ?, registered_capital = ?, com_organization = ?," +
"legal_representative = ?, five_legal_change = ?, two_years_no_lawsuit = ?, total_credit_score = ?, ichunt_hunting_core = ?, blacklist_hit = ?, " +
"risk_type = ?, update_time = ? where com_name = ?", erp_com_sn, com_addr, establishment_time, registered_capital, com_organization, legal_representative,
five_legal_change, two_years_no_lawsuit, total_credit_score, ichunt_hunting_core, blacklist_hit, risk_type, curr_time, company.ComName)
......
......@@ -9,6 +9,7 @@ type Config struct {
Liexin_databases *LiexinMysqlConfig
LiexinLabel_databases *LiexinLabelMysqlConfig
Liexincms_databases *LiexinCmsMysqlConfig
Liexincrm_databases *LiexinCrmMysqlConfig
Bom_databases *BomDatabasesMysqlConfig
Special_databases *SpecialDatabasesMysqlConfig
Mongo_config *MongoConn
......@@ -35,6 +36,9 @@ type LiexinLabelMysqlConfig struct {
type LiexinCmsMysqlConfig struct {
Dns string `toml:"dns"`
}
type LiexinCrmMysqlConfig struct {
Dns string `toml:"dns"`
}
type BomDatabasesMysqlConfig struct {
Dns string `toml:"dns"`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment