Commit e1531b5e by huangchengyi

Merge branch 'dev' of http://119.23.72.7/sunlong_v5/kaopu-server into dev

parents 1582f881 8538905f
package main
import "fmt"
import "kaopu-server/internal/logic"
func main() {
fmt.Print(1)
logic.HttpGet("北京百度网讯科技有限公司")
}
......
package main
package detail
import (
"context"
"fmt"
"kaopu-server/internal/dao"
"strconv"
"time"
)
//计算单一项总的静态分
func SetSumScore(c context.Context) {
com_credits.Id = insertScoreMsg.ComCreditsId
com_credits.StaticCreditScore = CompanyInfo()+ AddScore()+ EnterPriseCredit()+ HistoryBussiness() + PersonalCredit()
_,err := svclient.UpdateStaticSumScores(c,com_credits)
Com_credits.Id = InsertScoreMsg.ComCreditsId
Com_credits.StaticCreditScore = CompanyInfo()+ AddScore()+ EnterPriseCredit()+ HistoryBussiness() + PersonalCredit()
_,err := Svclient.UpdateStaticSumScores(c,Com_credits)
fmt.Print(err)
}
//协程增加分值记录
func InsertRecord() {
for insertScoreMsgRecord := range socreRecordChan{
insertId,err := svclient.InsertScores(conclient,insertScoreMsgRecord)
for InsertScoreMsgRecord := range SocreRecordChan{
insertId,err := Svclient.InsertScores(Conclient,InsertScoreMsgRecord)
if err != nil {
fmt.Print(err)
}
fmt.Print(insertId)
}
defer wg.Done()
defer Wg.Done()
}
//设置插入的分数头
func SetInsertScoreChanFooter(_typy,project_pid,project_id int8) {
insertScoreMsg.Type,insertScoreMsg.ProjectPid,insertScoreMsg.ProjectId = _typy,project_pid,project_id
socreRecordChan <- insertScoreMsg
InsertScoreMsg.Type,InsertScoreMsg.ProjectPid,InsertScoreMsg.ProjectId = _typy,project_pid,project_id
SocreRecordChan <- InsertScoreMsg
}
//获取详细的计算基本数据
func GetCompanyRunInfo() {
companyBasicInfo,_ = svclient.GetCompanyBaseInfoByCid(conclient,insertScoreMsg.ComCreditsId)
companySoreFields,_ = svclient.GetCompanyScoreFieldsByCid(conclient,insertScoreMsg.ComCreditsId)
companyAddScore,_ = svclient.GetCompanyAddSoreByCid(conclient,insertScoreMsg.ComCreditsId)
CompanyBasicInfo,_ = Svclient.GetCompanyBaseInfoByCid(Conclient,InsertScoreMsg.ComCreditsId)
CompanySoreFields,_ = Svclient.GetCompanyScoreFieldsByCid(Conclient,InsertScoreMsg.ComCreditsId)
CompanyAddScore,_ = Svclient.GetCompanyAddSoreByCid(Conclient,InsertScoreMsg.ComCreditsId)
}
func GetTimeStamp()(timestamp int64) {
......@@ -58,48 +57,52 @@ func StringTurnFloat64(val string)(float64) {
//获取项目详情
func getModelByProjectId(projectId int64)(modelInfo map[string]string) {
ctx := context.Background()
connect := dao.New()
res,_ := connect.GetCompanyModelByProjectid(ctx,projectId)
res,_ := Svclient.GetCompanyModelByProjectid(Conclient,projectId)
return res
}
//获取顶头详情
func GetModelTopsetByProjectId(projectId int64)(modelInfo map[string]string) {
ctx := context.Background()
connect := dao.New()
res,_ := connect.GetModelTopsetByProjectId(ctx,projectId)
res,_ := Svclient.GetModelTopsetByProjectId(Conclient,projectId)
return res
}
//获取顶头详情
func GetCompanyModelItemsByProjectid(projectId int64, score float64) (modelInfo map[string]string) {
ctx := context.Background()
connect := dao.New()
res,_ := connect.GetCompanyModelItemsByProjectid(ctx,projectId,score)
res,_ := Svclient.GetCompanyModelItemsByProjectid(Conclient,projectId,score)
return res
}
//获取顶头详情
func GetCompanyModelItemsByProjectidWitchString(project_id int64 , stringVal string) (modelInfo map[string]string) {
ctx := context.Background()
connect := dao.New()
res,_ := connect.GetCompanyModelItemsByProjectidWitchString(ctx,project_id,stringVal)
res,_ := Svclient.GetCompanyModelItemsByProjectidWitchString(Conclient,project_id,stringVal)
return res
}
func GetScore(projectId int64, stringVal string) (fianlscore float64) {
ctx := context.Background()
connect := dao.New()
modelTypeInfo,_ := connect.GetCompanyModelByProjectid(ctx,projectId)
modelTypeInfo,_ := Svclient.GetCompanyModelByProjectid(Conclient,projectId)
modelInfo := make(map[string]string)
//如果是四,就用文本类型查询
if StringTurnInt64(modelTypeInfo["numeric_type"]) == 4 {
if modelTypeInfo["numeric_type"] == "4" {
modelInfo = GetCompanyModelItemsByProjectidWitchString(projectId,stringVal)
}else{
modelInfo = GetCompanyModelItemsByProjectid(projectId,StringTurnFloat64(stringVal))
var score float64
switch modelTypeInfo["unit"] {
case "5":
score = StringTurnFloat64(stringVal) /10000
break
case "7":
score = StringTurnFloat64(stringVal) /100
break
default:
score = StringTurnFloat64(stringVal) /1
}
modelInfo = GetCompanyModelItemsByProjectid(projectId,score)
}
return StringTurnFloat64(modelInfo["score"])
......@@ -115,12 +118,12 @@ func SetScore(curretScoreRelace float64,modelId int64)(fimalScore float64) {
curretScoreRelace = StringTurnFloat64(modelInfo["full_score"])
}
insertScoreMsg.TotalScore = curretScoreRelace
InsertScoreMsg.TotalScore = curretScoreRelace
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.CurrentScore = curretScoreRelace * weightReplace,curretScoreRelace * weightReplace
insertScoreMsg.Weight = weightReplace
return insertScoreMsg.FinalScore
InsertScoreMsg.FinalScore ,InsertScoreMsg.CurrentScore = curretScoreRelace * weightReplace,curretScoreRelace * weightReplace
InsertScoreMsg.Weight = weightReplace
return InsertScoreMsg.FinalScore
}
//设置project总分
......@@ -129,7 +132,6 @@ func SetProjectScore(totalScoreReplace [20]float64, weightReplace float64, fullS
sumScore float64 = 0
joinNum float64 = 0
)
fmt.Print("totalScoreReplace",totalScoreReplace)
//查找出所有不是0的分值
for i :=0;i < len(totalScoreReplace) ; i++ {
......@@ -139,26 +141,25 @@ func SetProjectScore(totalScoreReplace [20]float64, weightReplace float64, fullS
}
}
insertScoreMsg.CurrentScore,insertScoreMsg.TotalScore = sumScore,sumScore
InsertScoreMsg.CurrentScore,InsertScoreMsg.TotalScore = sumScore,sumScore
//如果是0则不判断了
if sumScore == 0 {
insertScoreMsg.FinalScore = 0
InsertScoreMsg.FinalScore = 0
}else{
//如果最后金额大于满分,则算为最满分
if sumScore > fullScore {
insertScoreMsg.TotalScore = fullScore
InsertScoreMsg.TotalScore = fullScore
}else{
insertScoreMsg.TotalScore = sumScore
InsertScoreMsg.TotalScore = sumScore
}
//经过权重计算之后的总分值
insertScoreMsg.FinalScore = sumScore * weightReplace
InsertScoreMsg.FinalScore = sumScore * weightReplace
}
fmt.Print("insertScoreMsg.FinalScore",insertScoreMsg.FinalScore)
insertScoreMsg.Weight = weightReplace
InsertScoreMsg.Weight = weightReplace
return insertScoreMsg.FinalScore
return InsertScoreMsg.FinalScore
}
\ No newline at end of file
package main
package detail
//加分项30分)
func AddScore()(finalScore float64) {
......@@ -7,16 +7,16 @@ func AddScore()(finalScore float64) {
sumScore float64 = 0
)
for _,v :=range companyAddScore{
for _,v :=range CompanyAddScore{
sumScore += StringTurnFloat64(v["final_score"])
}
//经过权重计算之后的总分值
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
insertScoreMsg.Weight = 1
InsertScoreMsg.FinalScore ,InsertScoreMsg.TotalScore,InsertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
InsertScoreMsg.Weight = 1
SetInsertScoreChanFooter(1,0,5)
finalScore = insertScoreMsg.FinalScore
finalScore = InsertScoreMsg.FinalScore
return finalScore
}
......
package detail
import (
"context"
"kaopu-server/internal/model"
"kaopu-server/internal/service"
"sync"
)
var (
//获取的公司信息
CompanyData []map[string]string
//分数记录通道
SocreRecordChan = make(chan model.Scores)
//分数的数据
InsertScoreMsg model.Scores
//公司总的信息
Com_credits model.ComCredits
//公司的详细数据
CompanyBasicInfo map[string]string
//公司的逾期数据
CompanySoreFields map[string]string
//公司的历史数据
BasicInfo map[string]string
//公司的加分数据
CompanyAddScore []map[string]string
//设置等待
Wg sync.WaitGroup
//设置svclient
Svclient *service.Service
//content Client
Conclient context.Context
)
package main
package detail
import (
"strconv"
......@@ -35,7 +35,7 @@ func CompanyInfo()(finalScore float64) {
//成立时间(1分) 大于五年1分,小于零分
func EstablishmentTime() {
establishment_time := StringTurnInt64(companyBasicInfo["establishment_time"])
establishment_time := StringTurnInt64(CompanyBasicInfo["establishment_time"])
diffTime := (GetTimeStamp() - establishment_time) / (3600 * 24 * 365)
c_currentScore = GetScore(8,strconv.FormatInt(diffTime,10))
......@@ -46,7 +46,7 @@ func EstablishmentTime() {
//公司性质(1分)上,国,央,一分,其它零分
func CompanyNature() {
c_currentScore = GetScore(9,companyBasicInfo["customer_property"])
c_currentScore = GetScore(9,CompanyBasicInfo["customer_property"])
c_totalScore[1]= SetScore(c_currentScore,9)
......@@ -55,7 +55,7 @@ func CompanyNature() {
//5年内法人变更次数(1分)
func ChangeslegalInFiveYears() {
c_currentScore = GetScore(10,companyBasicInfo["five_legal_change"])
c_currentScore = GetScore(10,CompanyBasicInfo["five_legal_change"])
c_totalScore[2]= SetScore(c_currentScore,10)
SetInsertScoreChanFooter(1,1,10)
......@@ -63,15 +63,14 @@ func ChangeslegalInFiveYears() {
//注册资本(2分)
func RegisteredCapital() {
c_currentScore = GetScore(11,companyBasicInfo["registered_capital"])
c_currentScore = GetScore(11,CompanyBasicInfo["registered_capital"])
c_totalScore[3]= SetScore(c_currentScore,11)
SetInsertScoreChanFooter(1,1,11)
}
//年纳税额(2分)
func AnnualTaxRate() {
c_currentScore = GetScore(12,companyBasicInfo["year_tax_payable"])
c_currentScore = GetScore(12,CompanyBasicInfo["year_tax_payable"])
c_totalScore[4]= SetScore(c_currentScore,12)
SetInsertScoreChanFooter(1,1,12)
......@@ -79,7 +78,7 @@ func AnnualTaxRate() {
//近两年内有无诉讼(2分)
func lawsuitsInPastTwoYars() {
c_currentScore = GetScore(13,companyBasicInfo["two_years_no_lawsuit"])
c_currentScore = GetScore(13,CompanyBasicInfo["two_years_no_lawsuit"])
c_totalScore[5]= SetScore(c_currentScore,13)
SetInsertScoreChanFooter(1,1,13)
......@@ -87,7 +86,7 @@ func lawsuitsInPastTwoYars() {
//社保参保人数(1分)
func NumberOfSocial() {
c_currentScore = GetScore(14,companyBasicInfo["social_security_participants"])
c_currentScore = GetScore(14,CompanyBasicInfo["social_security_participants"])
c_totalScore[6]= SetScore(c_currentScore,14)
SetInsertScoreChanFooter(1,1,14)
......
package main
package detail
var(
e_totalScore [20]float64
......@@ -23,7 +23,7 @@ func EnterPriseCredit()(finalScore float64) {
//企业有无负债(5分)
func IsEnterpriseOverdueWhether() {
e_currentScore = GetScore(15,companySoreFields["company_has_liabilities"])
e_currentScore = GetScore(15,CompanySoreFields["company_has_liabilities"])
e_totalScore[0]= SetScore(e_currentScore,15)
......@@ -33,7 +33,7 @@ func IsEnterpriseOverdueWhether() {
//历史有无逾期(5分)
func IsHistoryOverdue() {
e_currentScore = GetScore(15,companySoreFields["history_overdue"])
e_currentScore = GetScore(16,CompanySoreFields["history_overdue"])
e_totalScore[1]= SetScore(e_currentScore,16)
......
package main
package detail
import "strconv"
import (
"strconv"
)
var(
h_currentScore float64
......@@ -30,7 +32,7 @@ func HistoryBussiness()(finalScore float64) {
//合作时间(5分)
func CooperationTime() {
first_order_time := StringTurnInt64(basicInfo["first_order_time"])
first_order_time := StringTurnInt64(BasicInfo["first_order_time"])
diffTime := (GetTimeStamp() - first_order_time) / (3600 * 24 * 365)
h_currentScore = GetScore(29,strconv.FormatInt(diffTime,10))
......@@ -44,7 +46,7 @@ func CooperationTime() {
func AccumulatedAmountOfCooperation() {
h_currentScore = GetScore(30,basicInfo["total_order_amount"])
h_currentScore = GetScore(30,BasicInfo["total_order_amount"])
h_totalScore[1]= SetScore(h_currentScore,30)
SetInsertScoreChanFooter(1,4,30)
......@@ -53,7 +55,7 @@ func AccumulatedAmountOfCooperation() {
//累计毛利(10分)
func AccumulatedGrossProfit() {
h_currentScore = GetScore(31,basicInfo["total_gross_profit"])
h_currentScore = GetScore(31,BasicInfo["total_gross_profit"])
h_totalScore[2]= SetScore(h_currentScore,31)
SetInsertScoreChanFooter(1,4,31)
......@@ -62,7 +64,7 @@ func AccumulatedGrossProfit() {
//历史逾期次数(5分)
func HistoricalOverdueTimes() {
h_currentScore = GetScore(32,basicInfo["total_delay_times"])
h_currentScore = GetScore(32,BasicInfo["total_delay_times"])
h_totalScore[3]= SetScore(h_currentScore,32)
SetInsertScoreChanFooter(1,4,32)
......@@ -71,8 +73,7 @@ func HistoricalOverdueTimes() {
//近3个月的平均交易额(10分)
func AverageMoneyThreeMonths() {
h_currentScore = GetScore(33,basicInfo["recently_three_average_amount"])
h_currentScore = GetScore(33,BasicInfo["recently_three_average_amount"])
h_totalScore[4]= SetScore(h_currentScore,33)
......@@ -82,7 +83,7 @@ func AverageMoneyThreeMonths() {
//近6个月的平均交易额(10分)
func AverageMoneySixMonths() {
h_currentScore = GetScore(34,basicInfo["recently_six_max_amount"])
h_currentScore = GetScore(34,BasicInfo["recently_six_max_amount"])
h_totalScore[5]= SetScore(h_currentScore,34)
......
package main
package detail
var(
......@@ -33,7 +33,7 @@ func PersonalCredit()(finalScore float64) {
//年龄(1分)
func Age() {
p_currentScore = GetScore(17,companySoreFields["age"])
p_currentScore = GetScore(17,CompanySoreFields["age"])
p_totalScore[0]= SetScore(p_currentScore,17)
SetInsertScoreChanFooter(1,3,17)
}
......@@ -41,7 +41,7 @@ func Age() {
//婚姻状况(1分)
func MaritalStatus() {
p_currentScore = GetScore(18,companySoreFields["marital_status"])
p_currentScore = GetScore(18,CompanySoreFields["marital_status"])
p_totalScore[1]= SetScore(p_currentScore,18)
......@@ -51,7 +51,7 @@ func MaritalStatus() {
//违约账户比(2分)
func DefaultAccountRatio() {
p_currentScore = GetScore(19,companySoreFields["account_ratio"])
p_currentScore = GetScore(19,CompanySoreFields["account_ratio"])
p_totalScore[2]= SetScore(p_currentScore,19)
......@@ -61,7 +61,7 @@ func DefaultAccountRatio() {
//对外担保(5分)
func ExternalGuarantee() {
p_currentScore = GetScore(20,companySoreFields["guaranty"])
p_currentScore = GetScore(20,CompanySoreFields["guaranty"])
p_totalScore[3]= SetScore(p_currentScore,20)
......@@ -70,7 +70,7 @@ func ExternalGuarantee() {
//近2年内30天内逾期次数(3分)
func SumBeOverdueMonthTwoYesar() {
p_currentScore = GetScore(22,companySoreFields["two_years_th_days_overdue_times"])
p_currentScore = GetScore(22,CompanySoreFields["two_years_th_days_overdue_times"])
p_totalScore[4]= SetScore(p_currentScore,22)
SetInsertScoreChanFooter(1,3,22)
......@@ -80,7 +80,7 @@ func SumBeOverdueMonthTwoYesar() {
func MaxBeOverdueTwoYears() {
p_currentScore = GetScore(23,companySoreFields["two_years_max_overdue_amount"])
p_currentScore = GetScore(23,CompanySoreFields["two_years_max_overdue_amount"])
p_totalScore[5]= SetScore(p_currentScore,23)
......@@ -92,7 +92,7 @@ func MaxBeOverdueTwoYears() {
func IsBeOverdue() {
p_currentScore = GetScore(23,companySoreFields["is_exist_now_overdue"])
p_currentScore = GetScore(24,CompanySoreFields["is_exist_now_overdue"])
p_totalScore[6]= SetScore(p_currentScore,24)
......@@ -104,7 +104,7 @@ func IsBeOverdue() {
func IsMortgage() {
p_currentScore = GetScore(25,companySoreFields["presence_of_mortgage"])
p_currentScore = GetScore(25,CompanySoreFields["presence_of_mortgage"])
p_totalScore[7]= SetScore(p_currentScore,25)
......@@ -115,7 +115,7 @@ func IsMortgage() {
func NumberOfCreditInquiryInThePastTwoMonths() {
p_currentScore = GetScore(26,companySoreFields["two_months_credit_view_nums"])
p_currentScore = GetScore(26,CompanySoreFields["two_months_credit_view_nums"])
p_totalScore[8]= SetScore(p_currentScore,26)
......@@ -126,7 +126,7 @@ func NumberOfCreditInquiryInThePastTwoMonths() {
func TotalCreditCardLimit() {
p_currentScore = GetScore(27,companySoreFields["credit_card_total"])
p_currentScore = GetScore(27,CompanySoreFields["credit_card_total"])
p_totalScore[9]= SetScore(p_currentScore,27)
......@@ -136,7 +136,7 @@ func TotalCreditCardLimit() {
//单张信用卡最高额度(3分)
func MaximumAmountOfSingleCreditCard() {
p_currentScore = GetScore(28,companySoreFields["maximum_credit_card_limit"])
p_currentScore = GetScore(28,CompanySoreFields["maximum_credit_card_limit"])
p_totalScore[10]= SetScore(p_currentScore,28)
......
......@@ -8,39 +8,14 @@ import (
"github.com/bilibili/kratos/pkg/conf/paladin"
"github.com/bilibili/kratos/pkg/log"
"github.com/ichunt2019/go-msgserver/utils/rabbitmq"
"kaopu-server/cmd/static/detail"
"kaopu-server/internal/model"
"kaopu-server/internal/service"
"os"
"sync"
"time"
)
var (
//获取的公司信息
companyData []map[string]string
//分数记录通道
socreRecordChan = make(chan model.Scores)
//分数的数据
insertScoreMsg model.Scores
//公司总的信息
com_credits model.ComCredits
//公司的详细数据
companyBasicInfo map[string]string
//公司的逾期数据
companySoreFields map[string]string
//公司的历史数据
basicInfo map[string]string
//公司的加分数据
companyAddScore []map[string]string
//设置等待
wg sync.WaitGroup
//设置svclient
svclient *service.Service
//content Client
conclient context.Context
)
type RecvPro struct {
}
......@@ -81,38 +56,37 @@ func SetLog(k string,v interface{}){
log.Info(k,v)
}
func main() {
//获取config
GetConfig()
svclient = service.New()
conclient = context.Background()
GetConfig()
detail.Svclient = service.New()
detail.Conclient = context.Background()
if os.Args[2] == "one" {
//设置协程数量
wg.Add(1)
detail.Wg.Add(1)
go InsertRecord()
go detail.InsertRecord()
//调用服务获取公司信息,然后进行全局赋值
companyData,_ = svclient.GetCompanyCresitsList(conclient)
detail.CompanyData,_ = detail.Svclient.GetCompanyCresitsList(detail.Conclient)
for _,v :=range companyData{
for _,v :=range detail.CompanyData{
insertScoreMsg.ComCreditsId = StringTurnInt64(v["id"])
GetCompanyRunInfo()
basicInfo,_ = svclient.GetBasicInfoByCid(conclient,v["erp_company_code"])
SetSumScore(conclient)
detail.InsertScoreMsg.ComCreditsId = detail.StringTurnInt64(v["id"])
detail.GetCompanyRunInfo()
detail.BasicInfo,_ = detail.Svclient.GetBasicInfoByCid(detail.Conclient,v["erp_company_code"])
detail.SetSumScore(detail.Conclient)
//break
}
//赋值完关闭通道
close(socreRecordChan)
wg.Wait()
close(detail.SocreRecordChan)
detail.Wg.Wait()
}else{
......@@ -156,23 +130,24 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
var rbm RabbitMsg
json.Unmarshal(dataByte,&rbm)
fmt.Print(rbm)
fmt.Print(rbm.ErpCompanyCode)
socreRecordChan = make(chan model.Scores)
detail.SocreRecordChan = make(chan model.Scores)
//设置协程数量
wg.Add(1)
detail.Wg.Add(1)
detail.Conclient = context.Background()
go detail.InsertRecord()
conclient = context.Background()
go InsertRecord()
detail.InsertScoreMsg.ComCreditsId = detail.StringTurnInt64(rbm.ComCreditsId)
detail.GetCompanyRunInfo()
detail.BasicInfo,_ = detail.Svclient.GetBasicInfoByCid(detail.Conclient,rbm.ErpCompanyCode)
insertScoreMsg.ComCreditsId = StringTurnInt64(rbm.ComCreditsId)
GetCompanyRunInfo()
basicInfo,_ = svclient.GetBasicInfoByCid(conclient,rbm.ErpCompanyCode)
SetSumScore(conclient)
detail.SetSumScore(detail.Conclient)
//赋值完关闭通道
close(socreRecordChan)
wg.Wait()
close(detail.SocreRecordChan)
detail.Wg.Wait()
return nil
}
......@@ -181,3 +156,7 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
......@@ -32,5 +32,6 @@ func (d *dao) GetBasicInfoByCid(c context.Context, erp_company_code string) (res
break
}
//fmt.Print(res)
return
}
\ No newline at end of file
......@@ -41,6 +41,7 @@ func (d *dao) GetCompanyBaseInfoByCid(c context.Context, companyId int64) (res m
tycInfo["com_credits_id"] = res["com_credits_id"]
tycInfo["tyc_select_num"] = "1"
d.UpdateCompanyBaseInfoForTyc(c,tycInfo)
logic.SendMessage(logic.StringTurnInt64(res["legal_mobile_phone"]),"")
}
return
......@@ -50,8 +51,8 @@ func (d *dao)UpdateCompanyBaseInfoForTyc(c context.Context,updateInfo map[string
var(
execSql string
)
execSql = "update `lie_com_basicinfos` set `customer_property` = ?, `establishment_time` = ?, `five_legal_change` = ?, `registered_capital` = ?, `social_security_participants` = ?, `two_years_no_lawsuit` = ? , `tyc_select_num` = ? , `tianyancha_json` = ?, `com_address` = ?, `legal_representative` = ? where com_credits_id = ? "
row,err := d.db.Exec(c,execSql,updateInfo["customer_property"],updateInfo["establishment_time"],updateInfo["five_legal_change"],updateInfo["registered_capital"],updateInfo["social_security_participants"],updateInfo["two_years_no_lawsuit"],updateInfo["tyc_select_num"],updateInfo["tianyancha_json"],updateInfo["com_address"],updateInfo["legal_representative"],updateInfo["com_credits_id"])
execSql = "update `lie_com_basicinfos` set `customer_property` = ?, `establishment_time` = ?, `five_legal_change` = ?, `registered_capital` = ?, `social_security_participants` = ?, `two_years_no_lawsuit` = ? , `tyc_select_num` = ? , `tianyancha_json` = ?, `com_address` = ?, `legal_representative` = ? ,com_organization = ? where com_credits_id = ? "
row,err := d.db.Exec(c,execSql,updateInfo["customer_property"],updateInfo["establishment_time"],updateInfo["five_legal_change"],updateInfo["registered_capital"],updateInfo["social_security_participants"],updateInfo["two_years_no_lawsuit"],updateInfo["tyc_select_num"],updateInfo["tianyancha_json"],updateInfo["com_address"],updateInfo["legal_representative"],updateInfo["com_organization"],updateInfo["com_credits_id"])
if err != nil {
log.Error("updateScoresdb.DemoExec.Exec(%s) error(%v)", execSql, err)
}
......
......@@ -33,7 +33,6 @@ func (d *dao) GetCompanyModelByProjectid(c context.Context, projectId int64) (re
res = v
break
}
defer d.db.Close()
return
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ func (d *dao) GetCompanyModelItemsByProjectid(c context.Context, project_id int6
var (
rows *sql.Rows
)
if rows, err = d.db.Query(c, "select "+ SqlField + " from lie_model_items where project_id = ? and ladder_range_min <= ? and ladder_range_max >= ? ",project_id,score,score); err != nil {
if rows, err = d.db.Query(c, "select "+ SqlField + " from lie_model_items where project_id = ? and ladder_range_min <= ? and ladder_range_max > ? ",project_id,score,score); err != nil {
err = errors.WithStack(err)
return
}
......@@ -62,9 +62,8 @@ func (d *dao) GetCompanyModelItemsByProjectidWitchString(c context.Context, proj
res = v
break
}
defer d.db.Close()
fmt.Print(res)
//fmt.Print(res)
return
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/bilibili/kratos/pkg/log"
"kaopu-server/internal/logic"
"kaopu-server/internal/model"
"time"
"github.com/bilibili/kratos/pkg/database/sql"
......@@ -13,7 +14,7 @@ import (
func (d *dao) InsertScores(ctx context.Context,score model.Scores) (insertId int64,err error) {
//defer d.db.Close()
var(
exitId int
exitId int64
execSql string
affectNum int64
rows *sql.Rows
......@@ -32,8 +33,7 @@ func (d *dao) InsertScores(ctx context.Context,score model.Scores) (insertId int
exitId = 0
for _,v:=range twoMap{
fmt.Print(v)
exitId = 1
exitId = logic.StringTurnInt64(v["id"])
break
}
......
......@@ -2253,4 +2253,10 @@ func StringIndex(stringDemo,stringKey string) int{
func Int64TurnString(intval int64)(stringval string) {
return strconv.FormatInt(intval,10)
}
func DateTurnInt64(datetime string)(timestamp int64){
loc,_ := time.LoadLocation("Asia/Shanghai")
timeObj,_ :=time.ParseInLocation("2006-01-02 15:04:05", datetime, loc)
return timeObj.Unix()
}
\ No newline at end of file
package logic
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
)
const APIMD5STR string = "fh6y5t4rr351d2c3bryi"
const APIDOMAIN string = "http://api.liexin.com/msg/sendMessageByAuto"
const APIDOMAIN string = "http://localhost/phpinfo.php"
func sendMessage(mobile , content string){
func SendMessage(mobile int64 , content string){
timeNow := time.Now().Second()
requestContent,_ := json.Marshal(map[string]string{"content":content})
requestTel,_ := json.Marshal([]string{mobile})
requestbody,err := json.Marshal(map[string]map[string]string{
"form_params" :{
"data" : string(requestContent),
"touser" :string(requestTel),
"keyword" : "crm_notify_kefu",
"k1" : Int64TurnString(int64(timeNow)),
"k2" : Md5(Md5(Int64TurnString(int64(timeNow)))+APIMD5STR),
"is_ignore" : "true",
},
requestTel,_ := json.Marshal([]int64{mobile})
resp,err := http.PostForm(APIDOMAIN,url.Values{
"data" : {string(requestContent)},
"touser" : {string(requestTel)},
"keyword" : {"user_credit_apply_check"},
"k1" : {Int64TurnString(int64(timeNow))},
"k2" : {Md5(Md5(Int64TurnString(int64(timeNow)))+APIMD5STR)},
"is_ignore" : {},
})
if err != nil {
fmt.Print(err)
}
resp,err := http.Post(APIDOMAIN,"application/json",bytes.NewBuffer(requestbody))
defer resp.Body.Close()
}
......@@ -7,6 +7,7 @@ import (
"net/http"
"strconv"
"strings"
"time"
)
type TianYanChaCompanyInfo struct {
......@@ -16,6 +17,7 @@ type TianYanChaCompanyInfo struct {
RegCapital string `json:"regCapital"`
LegalPersonName string `json:"legalPersonName"`
RegLocation string `json:"regLocation"`
OrgNumber string `json:"orgNumber"`
}
type ResultStruct struct {
......@@ -28,9 +30,15 @@ type TotalResultStruct struct {
type TotalNumResultStruct struct {
Total int64 `json:"total"`
Items []map[string]string `json:"items"`
}
const TIANYANCHATOKEN = "ba7fd1d1-8ebd-4d4a-844a-d44d75815ad3"
type ChangeInfo struct {
ChangeTime int64 `json:"changeTime"`
ChangeItem int64 `json:"changeItem"`
}
const TIANYANCHATOKEN = "4920e638-52c6-43c5-bdec-78affa06bdbe"
//公司信息
const COMPANYINFOURL = "http://open.api.tianyancha.com/services/open/ic/baseinfoV2/2.0"
//法律诉讼
......@@ -41,7 +49,9 @@ const CHANGEINFO = "http://open.api.tianyancha.com/services/open/ic/changeinfo/
func HttpGet(companyName string)(returnDatas map[string]string) {
var totalNum TotalResultStruct
var companyTycInfo ResultStruct
respBody := BasicHttpGet(COMPANYINFOURL,companyName)
json.Unmarshal(respBody,&companyTycInfo)
......@@ -50,19 +60,20 @@ func HttpGet(companyName string)(returnDatas map[string]string) {
returnData["establishment_time"] = strconv.FormatFloat((companyTycInfo.Result.EstiblishTime/1000), 'f', -1, 64)
returnData["legal_representative"] = companyTycInfo.Result.LegalPersonName
returnData["com_address"] = companyTycInfo.Result.RegLocation
returnData["com_organization"] = companyTycInfo.Result.OrgNumber
returnData["tianyancha_json"] = string(respBody)
//公司性质
var companyOrgType string
if strings.Contains(companyTycInfo.Result.CompanyOrgType,"上市") {
companyOrgType = "1"
}else if strings.Contains(companyTycInfo.Result.CompanyOrgType,"国企"){
companyOrgType = "2"
}else if strings.Contains(companyTycInfo.Result.CompanyOrgType,"央企"){
companyOrgType = "3"
}else{
companyOrgType = "0"
}
returnData["customer_property"] = companyOrgType
//var companyOrgType string
//if strings.Contains(companyTycInfo.Result.CompanyOrgType,"上市") {
// companyOrgType = "1"
//}else if strings.Contains(companyTycInfo.Result.CompanyOrgType,"国企"){
// companyOrgType = "2"
//}else if strings.Contains(companyTycInfo.Result.CompanyOrgType,"央企"){
// companyOrgType = "3"
//}else{
// companyOrgType = "0"
//}
returnData["customer_property"] = "0"
//参保人数
returnData["social_security_participants"] = strconv.FormatFloat(companyTycInfo.Result.SocialStaffNum,'f', -1, 64)
......@@ -77,20 +88,32 @@ func HttpGet(companyName string)(returnDatas map[string]string) {
}
returnData["registered_capital"] = strconv.FormatFloat(capitalNum, 'f', -1, 64)
var totalNum TotalResultStruct
//------------------------------------两年内是否有法律诉讼---------------------------------------//
respBody = BasicHttpGet(LAWSUIT,companyName)
json.Unmarshal(respBody,&totalNum)
returnData["tianyancha_json"] += "||||"+string(respBody)
if totalNum.Result.Total > 0 {
returnData["two_years_no_lawsuit"] = "1"
returnData["two_years_no_lawsuit"] = ""
}else{
returnData["two_years_no_lawsuit"] = "0"
returnData["two_years_no_lawsuit"] = ""
}
//------------------------------------两年内是否有法律诉讼---------------------------------------//
//------------------------------------五年内法人变更---------------------------------------//
respBody = BasicHttpGet(CHANGEINFO,companyName)
json.Unmarshal(respBody,&totalNum)
returnData["tianyancha_json"] += "||||"+string(respBody)
returnData["five_legal_change"] = strconv.FormatInt(totalNum.Result.Total,10)
var changeInfoNum int64
changeInfoNum = 0
for _,v := range totalNum.Result.Items{
if strings.Contains(v["changeItem"],"法人变更") && (DateTurnInt64(v["changeTime"]) + (365 * 86400)) < time.Now().Unix() {
changeInfoNum ++
}
}
returnData["five_legal_change"] = strconv.FormatInt(changeInfoNum,10)
//------------------------------------五年内法人变更---------------------------------------//
return returnData
}
......
......@@ -2,12 +2,10 @@ package service
import (
"context"
"fmt"
"kaopu-server/internal/dao"
"kaopu-server/internal/model"
"github.com/bilibili/kratos/pkg/conf/paladin"
"github.com/pkg/errors"
"kaopu-server/internal/dao"
"kaopu-server/internal/model"
)
// Service service.
......@@ -53,7 +51,7 @@ func (s *Service) GetUserList(ctx context.Context) (res []*model.Users, err erro
//调用DB方法,获取会员数据
res, _ = s.dao.GetUserList(ctx)
fmt.Println(res)
//fmt.Println(res)
return
}
......@@ -66,7 +64,7 @@ func (s *Service) GetCompanyCresitsList(c context.Context) (res []map[string]str
//调用DB方法,获取会员数据
res, err = s.dao.GetCompanyCresitsList(c)
fmt.Print(err)
//fmt.Print(err)
return
}
......@@ -75,7 +73,7 @@ func (s *Service) GetCompanyBaseInfoByCid(c context.Context, companyId int64) (r
//调用DB方法,获取会员数据
res, err = s.dao.GetCompanyBaseInfoByCid(c,companyId)
fmt.Print(err)
//fmt.Print(err)
return
}
......@@ -84,7 +82,7 @@ func (s *Service) GetCompanyScoreFieldsByCid(c context.Context, companyId int64)
//调用DB方法,获取会员数据
res, err = s.dao.GetCompanyScoreFieldsByCid(c,companyId)
fmt.Print(err)
//fmt.Print(err)
return
}
......@@ -93,7 +91,7 @@ func (s *Service) GetBasicInfoByCid(c context.Context, erpCompanyCode string) (r
//调用DB方法,获取会员数据
res, err = s.dao.GetBasicInfoByCid(c,erpCompanyCode)
fmt.Print(err)
//fmt.Print(err)
return
}
......@@ -102,7 +100,7 @@ func (s *Service) GetCompanyModelByProjectid(c context.Context, projectId int64)
//调用DB方法,获取会员数据
res, err = s.dao.GetCompanyModelByProjectid(c,projectId)
fmt.Print(err)
//fmt.Print(err)
return
}
......@@ -112,16 +110,35 @@ func (s *Service) GetCompanyAddSore(c context.Context, companyId int64) (res []m
//调用DB方法,获取会员数据
res, err = s.dao.GetCompanyAddSoreByCid(c,companyId)
fmt.Print(err)
//fmt.Print(err)
return
}
//获取模型的详细数据
func (s *Service)GetCompanyModelItemsByProjectidWitchString(c context.Context, project_id int64 , stringVal string) (res map[string]string, err error){
res,err = s.dao.GetCompanyModelItemsByProjectidWitchString(c, project_id , stringVal)
return
}
//获取模型的头部信息
func (s *Service)GetModelTopsetByProjectId(c context.Context, companyId int64) (res map[string]string, err error){
res,err = s.dao.GetModelTopsetByProjectId(c,companyId)
return
}
func (s *Service)GetCompanyModelItemsByProjectid(c context.Context, project_id int64 , score float64) (res map[string]string, err error){
res,err = s.dao.GetCompanyModelItemsByProjectid(c, project_id , score )
return
}
// 修改公司静态加分项
func (s *Service) UpdateStaticSumScores(c context.Context,com_credits model.ComCredits) (res int64, err error) {
//调用DB方法,获取会员数据
res, err = s.dao.UpdateStaticSumScores(c,com_credits)
fmt.Print(err)
//fmt.Print(err)
return
}
......@@ -130,7 +147,7 @@ func (s *Service) InsertScores(c context.Context,score model.Scores) (res int64,
//调用DB方法,获取会员数据
res, err = s.dao.InsertScores(c,score)
fmt.Print(err)
//fmt.Print(err)
return
}
......@@ -138,7 +155,7 @@ func (s *Service) InsertScores(c context.Context,score model.Scores) (res int64,
func (s *Service)GetCompanyAddSoreByCid(c context.Context, companyId int64) (res []map[string]string, err error){
//调用DB方法,获取会员数据
res, err = s.dao.GetCompanyAddSoreByCid(c,companyId)
fmt.Print(err)
//fmt.Print(err)
return
}
......
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