Commit 4d408cc2 by huangchengyi

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

parents 768f0197 b1160282
......@@ -9,7 +9,7 @@ func AddScore()(finalScore float64) {
)
for _,v :=range companyAddScore{
sumScore += stringTurnFloat64(v["final_score"])
sumScore += StringTurnFloat64(v["final_score"])
joinNum += 1
}
......@@ -18,7 +18,7 @@ func AddScore()(finalScore float64) {
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
insertScoreMsg.Weight = 1
setInsertScoreChanFooter(1,0,5)
SetInsertScoreChanFooter(1,0,5)
finalScore = insertScoreMsg.FinalScore
return finalScore
}
......
......@@ -12,7 +12,7 @@ var(
func CompanyInfo()(finalScore float64) {
modelInfo := getModelByProjectId(1)
weight = stringTurnFloat64(modelInfo["weight"])
weight = StringTurnFloat64(modelInfo["weight"])
EstablishmentTime()
CompanyNature()
......@@ -22,8 +22,8 @@ func CompanyInfo()(finalScore float64) {
lawsuitsInPastTwoYars()
NumberOfSocial()
finalScore = setProjectScore(c_totalScore,weight,stringTurnFloat64(modelInfo["full_score"]))
setInsertScoreChanFooter(1,0,1)
finalScore = SetProjectScore(c_totalScore,weight,StringTurnFloat64(modelInfo["full_score"]))
SetInsertScoreChanFooter(1,0,1)
return finalScore
}
......@@ -31,8 +31,8 @@ func CompanyInfo()(finalScore float64) {
//成立时间(1分) 大于五年1分,小于零分
func EstablishmentTime() {
establishment_time := stringTurnInt64(companyBasicInfo["establishment_time"])
diffTime := getTimeStamp() - establishment_time
establishment_time := StringTurnInt64(companyBasicInfo["establishment_time"])
diffTime := GetTimeStamp() - establishment_time
//五年以上有分
if diffTime > (3600 * 24 * 365 * 5) {
......@@ -44,14 +44,14 @@ func EstablishmentTime() {
c_totalScore[0]= c_currentScore
setScore(c_currentScore,weight)
setInsertScoreChanFooter(1,1,8)
SetInsertScoreChanFooter(1,1,8)
}
//公司性质(1分)上,国,央,一分,其它零分
func CompanyNature() {
customer_property := stringTurnInt64(companyBasicInfo["customer_property"])
customer_property := StringTurnInt64(companyBasicInfo["customer_property"])
if customer_property == 0 {
c_currentScore = 0
......@@ -62,13 +62,13 @@ func CompanyNature() {
c_totalScore[1]= c_currentScore
setScore(c_currentScore,weight)
setInsertScoreChanFooter(1,1,9)
SetInsertScoreChanFooter(1,1,9)
}
//5年内法人变更次数(1分)
func ChangeslegalInFiveYears() {
five_legal_change := stringTurnInt64(companyBasicInfo["five_legal_change"])
five_legal_change := StringTurnInt64(companyBasicInfo["five_legal_change"])
//两次以上0分,以下一分
if five_legal_change < 2 {
......@@ -80,13 +80,13 @@ func ChangeslegalInFiveYears() {
c_totalScore[2]= c_currentScore
setScore(c_currentScore,weight)
setInsertScoreChanFooter(1,1,10)
SetInsertScoreChanFooter(1,1,10)
}
//注册资本(2分)
func RegisteredCapital() {
registered_capital := stringTurnInt64(companyBasicInfo["registered_capital"])
registered_capital := StringTurnInt64(companyBasicInfo["registered_capital"])
if registered_capital < 500000 {
c_currentScore = 0
......@@ -99,12 +99,12 @@ func RegisteredCapital() {
c_totalScore[3]= c_currentScore
setScore(c_currentScore,weight)
setInsertScoreChanFooter(1,1,11)
SetInsertScoreChanFooter(1,1,11)
}
//年纳税额(2分)
func AnnualTaxRate() {
year_tax_payable := stringTurnFloat64(companyBasicInfo["year_tax_payable"])
year_tax_payable := StringTurnFloat64(companyBasicInfo["year_tax_payable"])
if year_tax_payable < 20000 {
c_currentScore = 0
......@@ -117,12 +117,12 @@ func AnnualTaxRate() {
c_totalScore[4]= c_currentScore
setScore(c_currentScore,weight)
setInsertScoreChanFooter(1,1,12)
SetInsertScoreChanFooter(1,1,12)
}
//近两年内有无诉讼(2分)
func lawsuitsInPastTwoYars() {
two_years_no_lawsuit := stringTurnInt64(companyBasicInfo["two_years_no_lawsuit"])
two_years_no_lawsuit := StringTurnInt64(companyBasicInfo["two_years_no_lawsuit"])
if two_years_no_lawsuit == 1 {
c_currentScore = 0
......@@ -133,13 +133,13 @@ func lawsuitsInPastTwoYars() {
c_totalScore[5]= c_currentScore
setScore(c_currentScore,weight)
setInsertScoreChanFooter(1,1,13)
SetInsertScoreChanFooter(1,1,13)
}
//社保参保人数(1分)
func NumberOfSocial() {
social_security_participants := stringTurnInt64(companyBasicInfo["social_security_participants"])
social_security_participants := StringTurnInt64(companyBasicInfo["social_security_participants"])
if social_security_participants > 5 {
c_currentScore = 1
......@@ -150,7 +150,7 @@ func NumberOfSocial() {
c_totalScore[6]= c_currentScore
setScore(c_currentScore,weight)
setInsertScoreChanFooter(1,1,14)
SetInsertScoreChanFooter(1,1,14)
}
......
......@@ -11,20 +11,20 @@ var(
func EnterPriseCredit()(finalScore float64) {
modelInfo := getModelByProjectId(2)
e_weight = stringTurnFloat64(modelInfo["weight"])
e_weight = StringTurnFloat64(modelInfo["weight"])
IsEnterpriseOverdueWhether()
IsHistoryOverdue()
finalScore = setProjectScore(e_totalScore,e_weight,stringTurnFloat64(modelInfo["full_score"]))
setInsertScoreChanFooter(1,0,2)
finalScore = SetProjectScore(e_totalScore,e_weight,StringTurnFloat64(modelInfo["full_score"]))
SetInsertScoreChanFooter(1,0,2)
return finalScore
}
//企业有无负债(5分)
func IsEnterpriseOverdueWhether() {
company_has_liabilities := stringTurnInt64(companySoreFields["company_has_liabilities"])
company_has_liabilities := StringTurnInt64(companySoreFields["company_has_liabilities"])
if company_has_liabilities == 1 {
e_currentScore = 0
......@@ -35,13 +35,13 @@ func IsEnterpriseOverdueWhether() {
e_totalScore[0]= e_currentScore
setScore(e_currentScore,e_weight)
setInsertScoreChanFooter(1,2,15)
SetInsertScoreChanFooter(1,2,15)
}
//历史有无逾期(5分)
func IsHistoryOverdue() {
history_overdue := stringTurnInt64(companySoreFields["history_overdue"])
history_overdue := StringTurnInt64(companySoreFields["history_overdue"])
if history_overdue == 1 {
e_currentScore = 0
......@@ -53,5 +53,5 @@ func IsHistoryOverdue() {
setScore(e_currentScore,e_weight)
setInsertScoreChanFooter(1,2,16)
SetInsertScoreChanFooter(1,2,16)
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ var(
func HistoryBussiness()(finalScore float64) {
modelInfo := getModelByProjectId(4)
h_weight = stringTurnFloat64(modelInfo["weight"])
h_weight = StringTurnFloat64(modelInfo["weight"])
CooperationTime()
AccumulatedAmountOfCooperation()
......@@ -19,16 +19,16 @@ func HistoryBussiness()(finalScore float64) {
AverageMoneyThreeMonths()
AverageMoneySixMonths()
finalScore = setProjectScore(h_totalScore,h_weight,stringTurnFloat64(modelInfo["full_score"]))
setInsertScoreChanFooter(1,0,4)
finalScore = SetProjectScore(h_totalScore,h_weight,StringTurnFloat64(modelInfo["full_score"]))
SetInsertScoreChanFooter(1,0,4)
return finalScore
}
//合作时间(5分)
func CooperationTime() {
first_order_time := stringTurnInt64(basicInfo["first_order_time"])
diffTime := getTimeStamp() - first_order_time
first_order_time := StringTurnInt64(basicInfo["first_order_time"])
diffTime := GetTimeStamp() - first_order_time
if diffTime < (3600 * 12 * 365 ) {
h_currentScore = 0
......@@ -47,13 +47,13 @@ func CooperationTime() {
//设置分数
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,29)
SetInsertScoreChanFooter(1,4,29)
}
//合作累计金额(10分)
func AccumulatedAmountOfCooperation() {
total_order_amount := stringTurnFloat64(basicInfo["total_order_amount"])
total_order_amount := StringTurnFloat64(basicInfo["total_order_amount"])
if total_order_amount < 1000000 {
h_currentScore = 0
......@@ -75,13 +75,13 @@ func AccumulatedAmountOfCooperation() {
//设置分数
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,30)
SetInsertScoreChanFooter(1,4,30)
}
//累计毛利(10分)
func AccumulatedGrossProfit() {
total_gross_profit := stringTurnFloat64(basicInfo["total_gross_profit"])
total_gross_profit := StringTurnFloat64(basicInfo["total_gross_profit"])
if total_gross_profit < 30000 {
h_currentScore = 0
......@@ -103,12 +103,12 @@ func AccumulatedGrossProfit() {
//设置分数
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,31)
SetInsertScoreChanFooter(1,4,31)
}
//历史逾期次数(5分)
func HistoricalOverdueTimes() {
total_delay_times := stringTurnInt64(basicInfo["total_delay_times"])
total_delay_times := StringTurnInt64(basicInfo["total_delay_times"])
if total_delay_times > 5 {
h_currentScore = 0
......@@ -125,13 +125,13 @@ func HistoricalOverdueTimes() {
//设置分数
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,32)
SetInsertScoreChanFooter(1,4,32)
}
//近3个月的平均交易额(10分)
func AverageMoneyThreeMonths() {
recently_three_average_amount := stringTurnFloat64(basicInfo["recently_three_average_amount"])
recently_three_average_amount := StringTurnFloat64(basicInfo["recently_three_average_amount"])
if recently_three_average_amount < 1 * 100000 {
h_currentScore = 0
......@@ -154,13 +154,13 @@ func AverageMoneyThreeMonths() {
//设置分数
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,33)
SetInsertScoreChanFooter(1,4,33)
}
//近6个月的平均交易额(10分)
func AverageMoneySixMonths() {
recently_six_max_amount := stringTurnFloat64(basicInfo["recently_six_max_amount"])
recently_six_max_amount := StringTurnFloat64(basicInfo["recently_six_max_amount"])
if recently_six_max_amount < 1 * 100000 {
h_currentScore = 0
......@@ -183,5 +183,5 @@ func AverageMoneySixMonths() {
//设置分数
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,33)
SetInsertScoreChanFooter(1,4,33)
}
......@@ -49,20 +49,19 @@ func main() {
flag.StringVar(&runtype, "runtype", "one", "default config path")
go insertRecord()
c := context.Background()
go InsertRecord(c)
if runtype == "one" {
//调用服务获取公司信息,然后进行全局赋值
svc := service.New()
c := context.Background()
companyData,_ = svc.GetCompanyCresitsList(c)
for _,v :=range companyData{
c := context.Background()
insertScoreMsg.ComCreditsId = stringTurnInt64(v["id"])
getCompanyRunInfo(c)
setSumScore()
insertScoreMsg.ComCreditsId = StringTurnInt64(v["id"])
GetCompanyRunInfo(c)
SetSumScore(c)
}
}else{
fmt.Print("待补充rabbitmq")
......@@ -79,28 +78,25 @@ func main() {
//计算单一项总的静态分
func setSumScore() {
func SetSumScore(c context.Context) {
com_credits.Id = insertScoreMsg.ComCreditsId
com_credits.StaticCreditScore = CompanyInfo() + AddScore() + HistoryBussiness() + EnterPriseCredit() + PersonalCredit()
c := context.Background()
connect := dao.New()
connect.UpdateStaticSumScores(c,com_credits)
}
//协程增加分值记录
func insertRecord() {
func InsertRecord(c context.Context) {
for insertScoreMsgRecord := range socreRecordChan{
//声明service层
connect := dao.New()
ctx := context.Background()
svc := service.New()
//CurrentScore64 := float64(insertScoreMsgRecord.CurrentScore)
//插入数据
//if !math.IsNaN(CurrentScore64) && CurrentScore64 != 0 {
//}
insertId,err := connect.InsertScores(ctx,insertScoreMsgRecord)
insertId,err := svc.InsertScores(c,insertScoreMsgRecord)
fmt.Print(err)
fmt.Print(insertId)
}
......@@ -108,13 +104,13 @@ func insertRecord() {
}
//设置插入的分数头
func setInsertScoreChanFooter(_typy,project_pid,project_id int8) {
func SetInsertScoreChanFooter(_typy,project_pid,project_id int8) {
insertScoreMsg.Type,insertScoreMsg.ProjectPid,insertScoreMsg.ProjectId = _typy,project_pid,project_id
socreRecordChan <- insertScoreMsg
}
//获取详细的计算基本数据
func getCompanyRunInfo(c context.Context) {
func GetCompanyRunInfo(c context.Context) {
//声明service层
connect := dao.New()
companyBasicInfo,_ = connect.GetCompanyBaseInfoByCid(c,insertScoreMsg.ComCreditsId)
......@@ -123,16 +119,16 @@ func getCompanyRunInfo(c context.Context) {
basicInfo,_ = connect.GetBasicInfoByCid(c,insertScoreMsg.ComCreditsId)
}
func getTimeStamp()(timestamp int64) {
func GetTimeStamp()(timestamp int64) {
return time.Now().Unix()
}
func stringTurnInt64(val string) (int64) {
func StringTurnInt64(val string) (int64) {
intval,_ := strconv.ParseInt(val, 10, 64)
return intval
}
func stringTurnFloat64(val string)(float64) {
func StringTurnFloat64(val string)(float64) {
floatval,_ := strconv.ParseFloat(val, 64)
return floatval
}
......@@ -154,7 +150,7 @@ func setScore(curretScoreRelace float64,weightReplace float64) {
}
//设置project总分
func setProjectScore(totalScoreReplace [20]float64, weightReplace float64, fullScore float64)(finalScore float64) {
func SetProjectScore(totalScoreReplace [20]float64, weightReplace float64, fullScore float64)(finalScore float64) {
var(
sumScore float64 = 0
joinNum float64 = 0
......
......@@ -11,7 +11,7 @@ var(
func PersonalCredit()(finalScore float64) {
modelInfo := getModelByProjectId(3)
p_weight = stringTurnFloat64(modelInfo["weight"])
p_weight = StringTurnFloat64(modelInfo["weight"])
Age()
MaritalStatus()
......@@ -25,14 +25,14 @@ func PersonalCredit()(finalScore float64) {
TotalCreditCardLimit()
MaximumAmountOfSingleCreditCard()
finalScore = setProjectScore(p_totalScore,p_weight,stringTurnFloat64(modelInfo["full_score"]))
setInsertScoreChanFooter(1,0,3)
finalScore = SetProjectScore(p_totalScore,p_weight,StringTurnFloat64(modelInfo["full_score"]))
SetInsertScoreChanFooter(1,0,3)
return finalScore
}
//年龄(1分)
func Age() {
age := stringTurnInt64(companySoreFields["age"])
age := StringTurnInt64(companySoreFields["age"])
if age > 30 && age <50 {
......@@ -45,13 +45,13 @@ func Age() {
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,17)
SetInsertScoreChanFooter(1,3,17)
}
//婚姻状况(1分)
func MaritalStatus() {
marital_status := stringTurnInt64(companySoreFields["marital_status"])
marital_status := StringTurnInt64(companySoreFields["marital_status"])
if marital_status == 1 {
p_currentScore = 1
......@@ -64,13 +64,13 @@ func MaritalStatus() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,18)
SetInsertScoreChanFooter(1,3,18)
}
//违约账户比(2分)
func DefaultAccountRatio() {
account_ratio := stringTurnFloat64(companySoreFields["account_ratio"])
account_ratio := StringTurnFloat64(companySoreFields["account_ratio"])
if account_ratio < 20 {
p_currentScore = 2
......@@ -83,13 +83,13 @@ func DefaultAccountRatio() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,19)
SetInsertScoreChanFooter(1,3,19)
}
//对外担保(5分)
func ExternalGuarantee() {
guaranty := stringTurnInt64(companySoreFields["guaranty"])
guaranty := StringTurnInt64(companySoreFields["guaranty"])
if guaranty == 1 {
p_currentScore = 0
......@@ -102,13 +102,13 @@ func ExternalGuarantee() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,20)
SetInsertScoreChanFooter(1,3,20)
}
//近2年内30天内逾期次数(3分)
func SumBeOverdueMonthTwoYesar() {
two_years_th_days_overdue_times := stringTurnInt64(companySoreFields["two_years_th_days_overdue_times"])
two_years_th_days_overdue_times := StringTurnInt64(companySoreFields["two_years_th_days_overdue_times"])
if two_years_th_days_overdue_times < 1 {
p_currentScore = 3
......@@ -121,13 +121,13 @@ func SumBeOverdueMonthTwoYesar() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,22)
SetInsertScoreChanFooter(1,3,22)
}
//近2年内最大逾期金额(3分)two_years_max_overdue_amount
func MaxBeOverdueTwoYears() {
two_years_max_overdue_amount := stringTurnFloat64(companySoreFields["two_years_max_overdue_amount"])
two_years_max_overdue_amount := StringTurnFloat64(companySoreFields["two_years_max_overdue_amount"])
if two_years_max_overdue_amount >= 10000 {
p_currentScore = 0
......@@ -144,14 +144,14 @@ func MaxBeOverdueTwoYears() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,23)
SetInsertScoreChanFooter(1,3,23)
}
//是否存在当前逾期(3分)
func IsBeOverdue() {
is_exist_now_overdue := stringTurnInt64(companySoreFields["is_exist_now_overdue"])
is_exist_now_overdue := StringTurnInt64(companySoreFields["is_exist_now_overdue"])
if is_exist_now_overdue == 1 {
p_currentScore = 0
......@@ -165,14 +165,14 @@ func IsBeOverdue() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,24)
SetInsertScoreChanFooter(1,3,24)
}
//有无房贷(1分)
func IsMortgage() {
presence_of_mortgage := stringTurnInt64(companySoreFields["presence_of_mortgage"])
presence_of_mortgage := StringTurnInt64(companySoreFields["presence_of_mortgage"])
if presence_of_mortgage == 1 {
p_currentScore = 0
......@@ -185,13 +185,13 @@ func IsMortgage() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,25)
SetInsertScoreChanFooter(1,3,25)
}
//近两个月征信查询次数(5分)
func NumberOfCreditInquiryInThePastTwoMonths() {
two_months_credit_view_nums := stringTurnInt64(companySoreFields["two_months_credit_view_nums"])
two_months_credit_view_nums := StringTurnInt64(companySoreFields["two_months_credit_view_nums"])
if two_months_credit_view_nums == 0 {
p_currentScore = 5
......@@ -212,13 +212,13 @@ func NumberOfCreditInquiryInThePastTwoMonths() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,26)
SetInsertScoreChanFooter(1,3,26)
}
//信用卡总额度(3分)
func TotalCreditCardLimit() {
credit_card_total := stringTurnInt64(companySoreFields["credit_card_total"])
credit_card_total := StringTurnInt64(companySoreFields["credit_card_total"])
if credit_card_total >= 200000 {
p_currentScore = 3
......@@ -231,13 +231,13 @@ func TotalCreditCardLimit() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,27)
SetInsertScoreChanFooter(1,3,27)
}
//单张信用卡最高额度(3分)
func MaximumAmountOfSingleCreditCard() {
maximum_credit_card_limit := stringTurnInt64(companySoreFields["maximum_credit_card_limit"])
maximum_credit_card_limit := StringTurnInt64(companySoreFields["maximum_credit_card_limit"])
if maximum_credit_card_limit >= 100000 {
p_currentScore = 3
......@@ -250,5 +250,5 @@ func MaximumAmountOfSingleCreditCard() {
//设置分数
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,28)
SetInsertScoreChanFooter(1,3,28)
}
......@@ -37,6 +37,7 @@ github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d/go.mod h1:URriBxXwVq5ijiJ1
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537/go.mod h1:AHHPPPXTw0h6pVabbcbyGRK1DckRn7r/STdZEeIDzZc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
......@@ -74,8 +75,6 @@ github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE=
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 h1:wqckanyE9qc/XnvnybC6SHOb8Nyd62QXAZOzA8twFig=
github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9/go.mod h1:64ikIrMv84B+raz7akXOqbF7cK3/OQQ/6cClY10oy7A=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
......@@ -103,6 +102,7 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ichunt2019/go-msgserver v0.0.0-20191203074423-ea6520d9a4ea h1:GLlx6jezFXZGHhCcdECTC5MAAYPgzB91D5synlgzR+Q=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/influxdb1-client v0.0.0-20190809212627-fc22c7df067e/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
......@@ -120,8 +120,10 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8=
......@@ -155,6 +157,7 @@ github.com/openconfig/reference v0.0.0-20190727015836-8dfd928c9696/go.mod h1:ym2
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/otokaze/mock v0.0.0-20190125081256-8282b7a7c7c3/go.mod h1:pLR8n2aimFxvvDJ6n8JuQWthMGezCYMjuhlaTjPTZf0=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/philchia/agollo v0.0.0-20190728085453-a95533fccea3 h1:e/WwwXpp+h9CtbiwSdDxrgq6ymvrvLH/P+kS+8qq4v8=
github.com/philchia/agollo v0.0.0-20190728085453-a95533fccea3/go.mod h1:EXNdWdQkS+QBi0nb/Xm+sBBuQ1PM7/NIPr1JDzOlt8A=
github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
......@@ -162,6 +165,7 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
......@@ -211,6 +215,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU=
github.com/templexxx/xor v0.0.0-20181023030647-4e92f724b73b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4=
......@@ -314,10 +319,12 @@ google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRn
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/bsm/ratelimit.v1 v1.0.0-20160220154919-db14e161995a/go.mod h1:KF9sEfUPAXdG8Oev9e99iLGnl2uJMjc5B+4y3O7x610=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc=
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
......
......@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/bilibili/kratos/pkg/database/sql"
"github.com/pkg/errors"
"kaopu-server/internal/logic"
"kaopu-server/internal/model"
"github.com/bilibili/kratos/pkg/log"
)
......@@ -39,9 +40,11 @@ func (d *dao) UpdateStaticSumScores(ctx context.Context,com_credits model.ComCre
execSql = "update `lie_com_credits` set `static_credit_score` = ? where id = ? "
row,err := d.db.Exec(ctx,execSql,com_credits.DynamicCreditScore,com_credits.Id)
if err != nil {
log.Error("db.DemoExec.Exec(%s) error(%v)", execSql, err)
log.Error("UpdateStaticSumScoresdb.DemoExec.Exec(%s) error(%v)", execSql, err)
}
d.UpdateComCredits(ctx,com_credits)
row.RowsAffected()
defer d.db.Close()
......@@ -59,7 +62,7 @@ func (d *dao) UpdateMoveSumScores(ctx context.Context,com_credits model.ComCredi
execSql = "update `lie_com_credits` set `dynamic_credit_score` = ? where id = ? "
row,err := d.db.Exec(ctx,execSql,com_credits.DynamicCreditScore,com_credits.Id)
if err != nil {
log.Error("db.DemoExec.Exec(%s) error(%v)", execSql, err)
log.Error("UpdateMoveSumScoresdb.DemoExec.Exec(%s) error(%v)", execSql, err)
}
row.RowsAffected()
......@@ -69,7 +72,70 @@ func (d *dao) UpdateMoveSumScores(ctx context.Context,com_credits model.ComCredi
return
}
func (d *dao)UpdateComCredits(ctx context.Context,com_credits model.ComCredits)(Id int64,err error) {
var (
rows *sql.Rows
res map[string]string
)
//获取当前条的数据
if rows, err = d.db.Query(ctx, "select "+ SqlField + " from lie_com_credits where id = ?",com_credits.Id); err != nil {
err = errors.WithStack(err)
return
}
if err != nil{
fmt.Println("select fail,err:",err)
return
}
twoMap,err := GetAllParam(rows)
for _,v:=range twoMap{
res = v
break
}
//修改相应的参数
total_credit_score := logic.StringTurnFloat64(res["static_credit_score"]) + logic.StringTurnFloat64(res["dynamic_credit_score"])
grade,_ := d.GetGrade(ctx,total_credit_score)
execSql := "update `lie_com_credits` set `total_credit_score` = ? , `ichunt_hunting_core` = ? , `recom_time_limit` = ? ,`recommended_amount` = ? where id = ? "
row,err := d.db.Exec(ctx,execSql,total_credit_score,grade["grade"],grade["recommended_limit"],logic.StringTurnFloat64(grade["recommended_amount"]),com_credits.Id)
if err != nil {
log.Error("UpdateComCreditsdb.DemoExec.Exec(%s) error(%v)", execSql, err)
}
row.RowsAffected()
return
}
func (d *dao)GetGrade(ctx context.Context,sumScore float64)(res map[string]string,err error) {
var (
rows *sql.Rows
)
//获取当前条的数据
if rows, err = d.db.Query(ctx, "select "+ SqlField + " from lie_grade where status = 1 and min_score >= ? and max_score < ?",sumScore,sumScore); err != nil {
err = errors.WithStack(err)
return
}
if err != nil{
fmt.Println("select fail,err:",err)
return
}
twoMap,err := GetAllParam(rows)
for _,v:=range twoMap{
res = v
break
}
return
}
......
......@@ -26,7 +26,7 @@ func (d *dao) InsertScores(ctx context.Context,score model.Scores) (insertId int
execSql = "INSERT INTO `lie_scores` (`type`, `project_pid`, `project_id`, `total_score`, `current_score`, `weight`, `final_score`, `com_credits_id`, `create_time`)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
row,err := d.db.Exec(ctx,execSql,score.Type,score.ProjectPid,score.ProjectId,score.TotalScore,score.CurrentScore,score.Weight,score.FinalScore,score.ComCreditsId,time.Now().Unix())
if err != nil {
log.Error("db.DemoExec.Exec(%s) error(%v)", execSql, err)
log.Error("InsertScoresdb.DemoExec.Exec(%s) error(%v)", execSql, err)
}else{
affectNum,_ = row.LastInsertId()
}
......@@ -35,7 +35,7 @@ func (d *dao) InsertScores(ctx context.Context,score model.Scores) (insertId int
execSql = "update `lie_scores` set `type` = ?, `project_pid` = ?, `project_id` = ?, `total_score` = ?, `current_score` = ?, `weight` = ?, `final_score` = ?, `com_credits_id` = ?, `update_time` = ? where `type` = ? and project_pid = ? and project_id = ? and com_credits_id = ?"
row,err := d.db.Exec(ctx,execSql,score.Type,score.ProjectPid,score.ProjectId,score.TotalScore,score.CurrentScore,score.Weight,score.FinalScore,score.ComCreditsId,time.Now().Unix(),score.Type,score.ProjectPid,score.ProjectId,score.ComCreditsId)
if err != nil {
log.Error("db.DemoExec.Exec(%s) error(%v)", execSql, err)
log.Error("updateScoresdb.DemoExec.Exec(%s) error(%v)", execSql, err)
}else{
affectNum,_ = row.RowsAffected()
}
......
......@@ -2247,12 +2247,22 @@ func GetConfig() {
panic(err)
}
//初始化日志目录
setLog("kaopuserver start",0)
SetLog("kaopuserver start",0)
}
func setLog(k string,v interface{}){
func SetLog(k string,v interface{}){
//初始化日志目录
log.Init(&log.Config{Dir: "logs"})
defer log.Close()
log.Info(k,v)
}
func StringTurnInt64(val string) (int64) {
intval,_ := strconv.ParseInt(val, 10, 64)
return intval
}
func StringTurnFloat64(val string)(float64) {
floatval,_ := strconv.ParseFloat(val, 64)
return floatval
}
\ No newline at end of file
package model
type Grade struct {
Id int64 `json:"id"`
Grade int64 `json:"grade"`
MinScore float64 `json:"min_score"`
MaxScore float64 `json:"max_score"`
RecommendedAmount float64 `json:"recommended_amount"`
RecommendedLimit string `json:"recommended_limit"`
Status int64 `json:"status"`
Creator string `json:"creator"`
CreateTime int64 `json:"create_time"`
UpdateTime int64 `json:"update_time"`
}
/*CREATE TABLE `lie_grade` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '信用等级ID',
`grade` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '等级,1-A,2-B, 3-C, 4-D, 5-E, 6-F',
`min_score` decimal(6,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '最小分值',
`max_score` decimal(6,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '最大分值',
`recommended_amount` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '建议额度',
`recommended_limit` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '建议期限',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态,1-启用,-1-禁用',
`creator` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '创建人',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `grade` (`grade`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='信用等级表';*/
\ No newline at end of file
......@@ -125,5 +125,14 @@ func (s *Service) UpdateStaticSumScores(c context.Context,com_credits model.ComC
return
}
// 修改公司静态加分项
func (s *Service) InsertScores(c context.Context,score model.Scores) (res int64, err error) {
//调用DB方法,获取会员数据
res, err = s.dao.InsertScores(c,score)
defer s.dao.Close()
fmt.Print(err)
return
}
//----------静态结束
\ No newline at end of file
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