Commit 34402165 by Joneq

优化程序的分类

parent bc4969ae
......@@ -17,7 +17,7 @@ func AddScore() {
sumScore = sumScore / joinNum
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
insertScoreMsg.Weight = 50
insertScoreMsg.Weight = 1
setInsertScoreChanFooter(1,0,5)
}
......
......@@ -2,7 +2,8 @@ package main
var(
currentScore float64
totalScore [7]float64
totalScore [20]float64
weight float64
)
......@@ -10,6 +11,9 @@ var(
//公司信息计算
func CompanyInfo() {
modelInfo := getModelByProjectId(1)
weight = stringTurnFloat64(modelInfo["weight"])
EstablishmentTime()
CompanyNature()
ChangeslegalInFiveYears()
......@@ -17,25 +21,10 @@ func CompanyInfo() {
AnnualTaxRate()
lawsuitsInPastTwoYars()
NumberOfSocial()
var(
sumScore float64 = 0
joinNum float64 = 0
)
//查找出所有不是0的分值
for i :=0;i < len(totalScore) ; i++ {
if totalScore[i] != 0 {
joinNum += 1
sumScore += totalScore[i] * 0.5
}
}
//经过权重计算之后的总分值
sumScore = sumScore / joinNum
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
insertScoreMsg.Weight = 50
setProjectScore(totalScore,weight,stringTurnFloat64(modelInfo["full_score"]))
setInsertScoreChanFooter(1,0,1)
}
......@@ -55,9 +44,7 @@ func EstablishmentTime() {
totalScore[0]= currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setScore(currentScore,weight)
setInsertScoreChanFooter(1,1,8)
}
......@@ -75,11 +62,7 @@ func CompanyNature() {
totalScore[1]= currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setScore(currentScore,weight)
setInsertScoreChanFooter(1,1,9)
}
......@@ -97,7 +80,7 @@ func ChangeslegalInFiveYears() {
totalScore[2]= currentScore
setScore(currentScore,weight)
setInsertScoreChanFooter(1,1,10)
}
......@@ -116,6 +99,7 @@ func RegisteredCapital() {
totalScore[3]= currentScore
setScore(currentScore,weight)
setInsertScoreChanFooter(1,1,11)
}
......@@ -133,6 +117,7 @@ func AnnualTaxRate() {
totalScore[4]= currentScore
setScore(currentScore,weight)
setInsertScoreChanFooter(1,1,12)
}
......@@ -148,6 +133,7 @@ func lawsuitsInPastTwoYars() {
totalScore[5]= currentScore
setScore(currentScore,weight)
setInsertScoreChanFooter(1,1,13)
}
......@@ -164,6 +150,7 @@ func NumberOfSocial() {
totalScore[6]= currentScore
setScore(currentScore,weight)
setInsertScoreChanFooter(1,1,14)
}
......
......@@ -2,34 +2,22 @@ package main
var(
e_currentScore float64
e_totalScore [2]float64
e_totalScore [20]float64
e_weight float64
)
//企业征信(10分)
func EnterPriseCredit() {
var(
sumScore float64 = 0
joinNum float64 = 0
)
modelInfo := getModelByProjectId(2)
e_weight = stringTurnFloat64(modelInfo["weight"])
IsEnterpriseOverdueWhether()
IsHistoryOverdue()
//查找出所有不是0的分值
for i :=0;i < len(e_totalScore) ; i++ {
if e_totalScore[i] != 0 {
joinNum += 1
sumScore += e_totalScore[i] * 0.5
}
}
//经过权重计算之后的总分值
sumScore = sumScore / joinNum
setProjectScore(e_totalScore,e_weight,stringTurnFloat64(modelInfo["full_score"]))
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,0,2)
}
......@@ -45,9 +33,8 @@ func IsEnterpriseOverdueWhether() {
}
e_totalScore[0]= e_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = e_currentScore,e_currentScore,e_currentScore
insertScoreMsg.Weight = 50
setScore(e_currentScore,e_weight)
setInsertScoreChanFooter(1,2,15)
}
......@@ -64,8 +51,7 @@ func IsHistoryOverdue() {
e_totalScore[1]= e_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = e_currentScore,e_currentScore,e_currentScore
insertScoreMsg.Weight = 50
setScore(e_currentScore,e_weight)
setInsertScoreChanFooter(1,2,16)
}
\ No newline at end of file
......@@ -2,11 +2,16 @@ package main
var(
h_currentScore float64
h_totalScore [6]float64
h_totalScore [20]float64
h_weight float64
)
//历史交易情况(50分)
func HistoryBussiness() {
modelInfo := getModelByProjectId(4)
h_weight = stringTurnFloat64(modelInfo["weight"])
CooperationTime()
AccumulatedAmountOfCooperation()
AccumulatedGrossProfit()
......@@ -14,24 +19,8 @@ func HistoryBussiness() {
AverageMoneyThreeMonths()
AverageMoneySixMonths()
var(
sumScore float64 = 0
joinNum float64 = 0
)
//查找出所有不是0的分值
for i :=0;i < len(totalScore) ; i++ {
if totalScore[i] != 0 {
joinNum += 1
sumScore += totalScore[i] * 0.5
}
}
//经过权重计算之后的总分值
sumScore = sumScore / joinNum
setProjectScore(h_totalScore,h_weight,stringTurnFloat64(modelInfo["full_score"]))
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,0,4)
}
......@@ -56,8 +45,8 @@ func CooperationTime() {
h_totalScore[0]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,29)
}
......@@ -85,8 +74,7 @@ func AccumulatedAmountOfCooperation() {
h_totalScore[1]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,30)
}
......@@ -114,8 +102,7 @@ func AccumulatedGrossProfit() {
h_totalScore[2]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,31)
}
......@@ -136,8 +123,8 @@ func HistoricalOverdueTimes() {
h_totalScore[3]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,32)
}
......@@ -165,8 +152,8 @@ func AverageMoneyThreeMonths() {
h_totalScore[4]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,33)
}
......@@ -194,7 +181,7 @@ func AverageMoneySixMonths() {
h_totalScore[5]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setScore(h_currentScore,h_weight)
setInsertScoreChanFooter(1,4,33)
}
......@@ -137,4 +137,50 @@ func stringTurnInt64(val string) (int64) {
func stringTurnFloat64(val string)(float64) {
floatval,_ := strconv.ParseFloat(val, 64)
return floatval
}
func getModelByProjectId(projectId int64)(modelInfo map[string]string) {
ctx := context.Background()
connect := dao.New()
res,_ := connect.GetCompanyModelByProjectid(ctx,1)
return res
}
//设置分数
func setScore(curretScoreRelace float64,weightReplace float64) {
insertScoreMsg.TotalScore = curretScoreRelace
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.CurrentScore = curretScoreRelace * weightReplace,curretScoreRelace * weightReplace
insertScoreMsg.Weight = weightReplace
}
//设置project总分
func setProjectScore(totalScoreReplace [20]float64, weightReplace float64, fullScore float64) {
var(
sumScore float64 = 0
joinNum float64 = 0
)
//查找出所有不是0的分值
for i :=0;i < len(totalScoreReplace) ; i++ {
if totalScoreReplace[i] > 0 {
joinNum += 1
sumScore += totalScoreReplace[i] * weightReplace
}
}
insertScoreMsg.CurrentScore = sumScore
//如果最后金额大于满分,则算为最满分
if sumScore > fullScore {
insertScoreMsg.TotalScore = fullScore
}else{
insertScoreMsg.TotalScore = sumScore
}
//经过权重计算之后的总分值
insertScoreMsg.FinalScore = sumScore / joinNum
insertScoreMsg.Weight = weightReplace
}
\ No newline at end of file
......@@ -3,11 +3,16 @@ package main
var(
p_currentScore float64
p_totalScore [11]float64
p_totalScore [20]float64
p_weight float64
)
//个人征信(30分)
func PersonalCredit() {
modelInfo := getModelByProjectId(3)
p_weight = stringTurnFloat64(modelInfo["weight"])
Age()
MaritalStatus()
DefaultAccountRatio()
......@@ -20,24 +25,8 @@ func PersonalCredit() {
TotalCreditCardLimit()
MaximumAmountOfSingleCreditCard()
var(
sumScore float64 = 0
joinNum float64 = 0
)
//查找出所有不是0的分值
for i :=0;i < len(totalScore) ; i++ {
if totalScore[i] != 0 {
joinNum += 1
sumScore += totalScore[i] * 0.5
}
}
//经过权重计算之后的总分值
sumScore = sumScore / joinNum
setProjectScore(p_totalScore,p_weight,stringTurnFloat64(modelInfo["full_score"]))
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,0,3)
}
......@@ -54,9 +43,8 @@ func Age() {
p_totalScore[0]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,17)
}
......@@ -74,8 +62,8 @@ func MaritalStatus() {
p_totalScore[1]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,18)
}
......@@ -93,8 +81,8 @@ func DefaultAccountRatio() {
p_totalScore[2]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,19)
}
......@@ -112,8 +100,8 @@ func ExternalGuarantee() {
p_totalScore[3]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,20)
}
......@@ -131,8 +119,8 @@ func SumBeOverdueMonthTwoYesar() {
p_totalScore[4]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,22)
}
......@@ -154,8 +142,8 @@ func MaxBeOverdueTwoYears() {
p_totalScore[5]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,23)
}
......@@ -175,8 +163,8 @@ func IsBeOverdue() {
p_totalScore[6]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,24)
}
......@@ -195,8 +183,8 @@ func IsMortgage() {
p_totalScore[7]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,25)
}
......@@ -222,8 +210,8 @@ func NumberOfCreditInquiryInThePastTwoMonths() {
p_totalScore[8]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,26)
}
......@@ -241,8 +229,8 @@ func TotalCreditCardLimit() {
p_totalScore[9]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,27)
}
......@@ -260,7 +248,7 @@ func MaximumAmountOfSingleCreditCard() {
p_totalScore[10]= p_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = p_currentScore,p_currentScore,p_currentScore
insertScoreMsg.Weight = 50
setScore(p_currentScore,p_weight)
setInsertScoreChanFooter(1,3,28)
}
......@@ -32,6 +32,7 @@ type (
GetCompanyScoreFieldsByCid(c context.Context, companyId int64) (r map[string]string, err error)
GetBasicInfoByCid(c context.Context, companyId int64) (r map[string]string, err error)
GetCompanyAddSoreByCid(c context.Context, companyId int64) (r []map[string]string, err error)
GetCompanyModelByProjectid(c context.Context, companyId int64) (r map[string]string, err error)
//---静态结束
CountYuqi(ctx context.Context,project_id int,erp_company_code string) (r []map[string]interface{},err error) //计算逾期
......
package dao
import (
"context"
"fmt"
"github.com/pkg/errors"
"github.com/bilibili/kratos/pkg/database/sql"
)
//通过projectId获取该项信息
func (d *dao) GetCompanyModelByProjectid(c context.Context, projectId int64) (res map[string]string, err error) {
var (
rows *sql.Rows
)
if rows, err = d.db.Query(c, "select "+ SqlField + " from lie_model where project_id = ?",projectId); err != nil {
err = errors.WithStack(err)
return
}
defer rows.Close()
if err != nil{
fmt.Println("select fail,err:",err)
return
}
twoMap,err := GetAllParam(rows)
for _,v:=range twoMap{
res = v
break
}
return
}
\ No newline at end of file
package model
/*
CREATE TABLE `lie_com_credits` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`apply_account` varchar(11) NOT NULL DEFAULT '' COMMENT '申请账号 手机号 法人电话',
`erp_company_code` varchar(20) NOT NULL DEFAULT '' COMMENT 'erp公司编码',
`company_name` varchar(60) NOT NULL DEFAULT '' COMMENT '公司名字',
`static_credit_score` decimal(6,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '静态信用分',
`dynamic_credit_score` decimal(6,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '动态信用分',
`total_credit_score` decimal(6,2) NOT NULL DEFAULT '0.00' COMMENT '总信用分',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '1已申请 5待评分 10已评分',
`blacklist_hit` varchar(50) NOT NULL DEFAULT '' COMMENT '黑名单命中',
`credit_invest_result` varchar(50) NOT NULL DEFAULT '' COMMENT '征信达标结果',
`ichunt_hunting_core` enum('H','G','F','E','D','C','B','A') NOT NULL COMMENT '猎芯网评分分级',
`recommended_amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '建议额度',
`recom_time_limit` varchar(30) NOT NULL DEFAULT '' COMMENT '建议区间',
`admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '评分人ID',
`admin_name` varchar(30) NOT NULL DEFAULT '' COMMENT '评分人',
`score_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '评分时间',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `company_code` (`erp_company_code`) USING BTREE,
UNIQUE KEY `company_name` (`company_name`) USING BTREE,
KEY `company_code_2` (`erp_company_code`,`status`,`create_time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='公司信用分管理';
*/
\ No newline at end of file
......@@ -97,6 +97,15 @@ func (s *Service) GetBasicInfoByCid(c context.Context, companyId int64) (res map
return
}
// 获取模型数据
func (s *Service) GetCompanyModelByProjectid(c context.Context, projectId int64) (res map[string]string, err error) {
//调用DB方法,获取会员数据
res, err = s.dao.GetCompanyModelByProjectid(c,projectId)
fmt.Print(err)
return
}
// 获取公司加分项
func (s *Service) GetCompanyAddSore(c context.Context, companyId int64) (res []map[string]string, err error) {
......
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