Commit 388e74f8 by Joneq

完成公司历史数据计算

parent 2d3fd640
package main
//加分项30分)
func AddScore() {
var(
sumScore float32 = 0
joinNum float32 = 0
)
for _,v :=range companyAddScore{
sumScore += float32(stringTurnFloat64(v["final_score"]))
joinNum += 1
}
//经过权重计算之后的总分值
sumScore = sumScore / joinNum
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = sumScore,sumScore,sumScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,0,5)
}
//业界口碑(2分))
......
package main
var(
h_currentScore float32
h_totalScore [6]float32
)
//历史交易情况(50分)
func HistoryBussiness() {
CooperationTime()
......@@ -8,34 +13,188 @@ func HistoryBussiness() {
HistoricalOverdueTimes()
AverageMoneyThreeMonths()
AverageMoneySixMonths()
var(
sumScore float32 = 0
joinNum float32 = 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
setInsertScoreChanFooter(1,0,4)
}
//合作时间(5分)
func CooperationTime() {
first_order_time := stringTurnInt64(basicInfo["first_order_time"])
diffTime := getTimeStamp() - first_order_time
if diffTime < (3600 * 12 * 365 ) {
h_currentScore = 0
} else if diffTime < (3600 * 24 * 365 ) && diffTime >= (3600 * 12 * 365 ) {
h_currentScore = 1
}else if diffTime < (3600 * 24 * 365 * 2 ) && diffTime >= (3600 * 24 * 365 * 1) {
h_currentScore = 2
}else if diffTime >= (3600 * 24 * 365 *2){
h_currentScore = 5
}else{
h_currentScore = 0
}
h_totalScore[0]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,4,29)
}
//合作累计金额(10分)
func AccumulatedAmountOfCooperation() {
total_order_amount := stringTurnFloat64(basicInfo["total_order_amount"])
if total_order_amount < 1000000 {
h_currentScore = 0
} else if total_order_amount < 2000000 && total_order_amount >= 1000000 {
h_currentScore = 1
}else if total_order_amount < 3000000 && total_order_amount >= 2000000 {
h_currentScore = 2
}else if total_order_amount < 5000000 && total_order_amount >= 3000000{
h_currentScore = 3
}else if total_order_amount < 10000000 && total_order_amount >= 5000000{
h_currentScore = 5
}else if total_order_amount >= 10000000{
h_currentScore = 10
}else{
h_currentScore = 0
}
h_totalScore[1]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,4,30)
}
//累计毛利(10分)
func AccumulatedGrossProfit() {
total_gross_profit := stringTurnFloat64(basicInfo["total_gross_profit"])
if total_gross_profit < 30000 {
h_currentScore = 0
}else if total_gross_profit < 50000 && total_gross_profit >= 30000 {
h_currentScore = 1
}else if total_gross_profit < 50000 && total_gross_profit >= 100000 {
h_currentScore = 2
}else if total_gross_profit < 200000 && total_gross_profit >= 100000{
h_currentScore = 3
}else if total_gross_profit < 300000 && total_gross_profit >= 200000{
h_currentScore = 5
}else if total_gross_profit >= 300000{
h_currentScore = 10
}else{
h_currentScore = 0
}
h_totalScore[2]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,4,31)
}
//历史逾期次数(5分)
func HistoricalOverdueTimes() {
total_delay_times := stringTurnInt64(basicInfo["total_delay_times"])
if total_delay_times > 5 {
h_currentScore = 0
}else if total_delay_times <= 5 && total_delay_times >= 2{
h_currentScore = 3
}else if total_delay_times < 2{
h_currentScore = 5
}else{
h_currentScore = 0
}
h_totalScore[3]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,4,32)
}
//近3个月的平均交易额(10分)
func AverageMoneyThreeMonths() {
recently_three_average_amount := stringTurnFloat64(basicInfo["recently_three_average_amount"])
if recently_three_average_amount < 1 * 100000 {
h_currentScore = 0
}else if recently_three_average_amount < 2 * 100000 && recently_three_average_amount >= 1 * 100000 {
h_currentScore = 1
}else if recently_three_average_amount < 3 * 100000 && recently_three_average_amount >= 2 * 100000 {
h_currentScore = 2
}else if recently_three_average_amount < 5 * 100000 && recently_three_average_amount >= 3 * 100000{
h_currentScore = 3
}else if recently_three_average_amount < 10 * 100000 && recently_three_average_amount >= 5 * 100000{
h_currentScore = 5
}else if recently_three_average_amount >= 10 * 100000{
h_currentScore = 10
}else{
h_currentScore = 0
}
h_totalScore[4]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,4,33)
}
//近6个月的平均交易额(10分)
func AverageMoneySixMonths() {
recently_six_max_amount := stringTurnFloat64(basicInfo["recently_six_max_amount"])
if recently_six_max_amount < 1 * 100000 {
h_currentScore = 0
}else if recently_six_max_amount < 2 * 100000 && recently_six_max_amount >= 1 * 100000 {
h_currentScore = 1
}else if recently_six_max_amount < 3 * 100000 && recently_six_max_amount >= 2 * 100000 {
h_currentScore = 2
}else if recently_six_max_amount < 5 * 100000 && recently_six_max_amount >= 3 * 100000{
h_currentScore = 3
}else if recently_six_max_amount < 10 * 100000 && recently_six_max_amount >= 5 * 100000{
h_currentScore = 5
}else if recently_six_max_amount >= 10 * 100000{
h_currentScore = 10
}else{
h_currentScore = 0
}
h_totalScore[5]= h_currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setInsertScoreChanFooter(1,4,33)
}
......@@ -26,8 +26,10 @@ var (
companyBasicInfo map[string]string
//公司的逾期数据
companySoreFields map[string]string
//公司的历史数据
basicInfo map[string]string
//公司的逾期数据
companyAddSore []map[string]string
companyAddScore []map[string]string
//设置等待
wg sync.WaitGroup
)
......@@ -52,13 +54,13 @@ func main() {
setLog("companyData",companyData)
for _,v :=range companyData{
insertScoreMsg.ComCreditsId = stringTurnInt64(v["id"])
getCompanyRunInfo(c)
CompanyInfo()
EnterPriseCredit()
//AddScore()
//HistoryBussiness()
AddScore()
HistoryBussiness()
//PersonalCredit()
}
......@@ -96,7 +98,12 @@ func insertRecord() {
for insertScoreMsgRecord := range socreRecordChan{
//声明service层
connect := dao.New()
//CurrentScore64 := float64(insertScoreMsgRecord.CurrentScore)
//插入数据
//if !math.IsNaN(CurrentScore64) && CurrentScore64 != 0 {
//
//}
insertId,err := connect.InsertScores(ctx,insertScoreMsgRecord)
fmt.Print(err)
fmt.Print(insertId)
......@@ -116,7 +123,8 @@ func getCompanyRunInfo(c context.Context) {
connect := dao.New()
companyBasicInfo,_ = connect.GetCompanyBaseInfoByCid(c,insertScoreMsg.ComCreditsId)
companySoreFields,_ = connect.GetCompanyScoreFieldsByCid(c,insertScoreMsg.ComCreditsId)
companyAddSore,_ = connect.GetCompanyAddSoreByCid(c,insertScoreMsg.ComCreditsId)
companyAddScore,_ = connect.GetCompanyAddSoreByCid(c,insertScoreMsg.ComCreditsId)
basicInfo,_ = connect.GetBasicInfoByCid(c,insertScoreMsg.ComCreditsId)
}
func getTimeStamp()(timestamp int64) {
......
......@@ -13,7 +13,7 @@ func (d *dao) GetCompanyAddSoreByCid(c context.Context, companyId int64) (res []
var (
rows *sql.Rows
)
if rows, err = d.db.Query(c, "select "+ SqlField + " from lie_add_scores where com_credits_id = ?",companyId); err != nil {
if rows, err = d.db.Query(c, "select "+ SqlField + " from lie_add_score where com_credits_id = ?",companyId); err != nil {
err = errors.WithStack(err)
return
}
......
package dao
import (
"context"
"fmt"
"github.com/pkg/errors"
"github.com/bilibili/kratos/pkg/database/sql"
)
//通过UID获取用户信息
func (d *dao) GetBasicInfoByCid(c context.Context, companyId int64) (res map[string]string, err error) {
var (
rows *sql.Rows
)
if rows, err = d.db.Query(c, "select "+ SqlField + " from lie_basic_info where com_credits_id = ?",companyId); 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
......@@ -25,6 +25,7 @@ type (
InsertScores(ctx context.Context, score model.Scores) (insertId int64, err error)
GetCompanyBaseInfoByCid(c context.Context, companyId int64) (r map[string]string, err error)
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)
//---静态结束
......
package model
//
//CREATE TABLE `lie_basic_info` (
//`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '业务明细ID',
//`erp_company_code` varchar(20) NOT NULL DEFAULT '' COMMENT 'erp公司编码',
//`first_order_time` int(11) NOT NULL COMMENT '首次下单时间',
//`total_order_amount` decimal(10,2) NOT NULL COMMENT '历史交易总额(收款总额)',
//`total_gross_profit` decimal(10,2) NOT NULL COMMENT '历史累计毛利',
//`recently_average_amount` decimal(10,2) NOT NULL COMMENT '近6个月平均交易额',
//`recently_max_amount` decimal(10,2) NOT NULL COMMENT '近6个月最大交易额',
//`last_month_amount` decimal(10,2) NOT NULL COMMENT '上个月交易额',
//`reveive_period_aomunt` decimal(10,2) NOT NULL COMMENT '已获账期金额',
//`total_delay_times` int(11) NOT NULL COMMENT '历史逾期次数',
//`mianly_class` varchar(255) NOT NULL COMMENT '主要交易品类',
//`create_time` int(11) NOT NULL COMMENT '创建时间',
//`update_time` int(11) NOT NULL COMMENT '更新时间',
//`recently_three_average_amount` decimal(10,2) NOT NULL COMMENT '近3个月最大交易额',
//`recently_three_max_amount` decimal(10,2) NOT NULL COMMENT '近3个月最大交易额',
//PRIMARY KEY (`id`)
//) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='业务信息';
\ No newline at end of file
......@@ -88,6 +88,15 @@ func (s *Service) GetCompanyScoreFieldsByCid(c context.Context, companyId int64)
return
}
// 获取公司历史信息
func (s *Service) GetBasicInfoByCid(c context.Context, companyId int64) (res map[string]string, err error) {
//调用DB方法,获取会员数据
res, err = s.dao.GetBasicInfoByCid(c,companyId)
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