|
@@ -6,6 +6,7 @@ import (
|
|
|
"hongze/hz_crm_api/controllers"
|
|
|
"hongze/hz_crm_api/models"
|
|
|
"hongze/hz_crm_api/models/company"
|
|
|
+ "hongze/hz_crm_api/models/fms"
|
|
|
"hongze/hz_crm_api/models/statistic_report"
|
|
|
"hongze/hz_crm_api/models/system"
|
|
|
cygxService "hongze/hz_crm_api/services/cygx"
|
|
@@ -126,17 +127,21 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
mapNoRenewedcompanyContractIds[v.CompanyContractId] = true
|
|
|
}
|
|
|
|
|
|
- mapAddTrialNum := make(map[string]float64) // 新增试用-(数据)
|
|
|
- mapNewContractMoney := make(map[string]float64) // 新签合同(金额)
|
|
|
- mapNewContractNum := make(map[string]int) // 新签合同(数量)
|
|
|
- mapExpiredContractMoney := make(map[string]float64) // 到期合同(金额)
|
|
|
- mapExpiredContractNum := make(map[string]int) // 到期合同(数量)
|
|
|
- mapRenewedContractMoney := make(map[string]float64) // 续约合同(金额)
|
|
|
- mapRenewedContractNum := make(map[string]int) // 续约合同(数量)
|
|
|
- confirmedNoRenewalContractMoney := make(map[string]float64) // 确认不续约合同(金额)
|
|
|
- confirmedNoRenewalContractNum := make(map[string]int) // 确认不续约合同(数量)
|
|
|
- mapSignedClientNum := make(map[string]int) // 签约客户(数量)
|
|
|
- mapSignedClientMoney := make(map[string]float64) // 签约客户(金额)
|
|
|
+ mapAddTrialNum := make(map[string]float64) // 新增试用-(数据)
|
|
|
+ mapNewContractMoney := make(map[string]float64) // 新签合同(金额)
|
|
|
+ mapNewContractNum := make(map[string]int) // 新签合同(数量)
|
|
|
+ mapExpiredContractMoney := make(map[string]float64) // 到期合同(金额)
|
|
|
+ mapExpiredContractNum := make(map[string]int) // 到期合同(数量)
|
|
|
+ mapRenewedContractMoney := make(map[string]float64) // 续约合同(金额)
|
|
|
+ mapRenewedContractNum := make(map[string]int) // 续约合同(数量)
|
|
|
+ confirmedNoRenewalContractMoney := make(map[string]float64) // 确认不续约合同(金额)
|
|
|
+ confirmedNoRenewalContractNum := make(map[string]int) // 确认不续约合同(数量)
|
|
|
+ mapSignedClientNum := make(map[string]int) // 签约客户(数量)
|
|
|
+ mapSignedClientMoney := make(map[string]float64) // 签约客户(金额)
|
|
|
+ mapInvoiceAmountMoney := make(map[string]float64) // 财务系统开票金额(金额)
|
|
|
+ mapPaymentAmountMoney := make(map[string]float64) // 财务系统到款金额(金额)
|
|
|
+ mapNewCustomerInvoicingMoney := make(map[string]float64) // 财务系统新客开票金额(金额)
|
|
|
+ mapNewCustomerPaymentsReceivedMoney := make(map[string]float64) // 财务系统新客到款金额(金额)
|
|
|
|
|
|
for _, v := range listRaiData {
|
|
|
startDateTime := utils.StrDateToDate(v.StartDate)
|
|
@@ -179,11 +184,49 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
confirmedNoRenewalContractMoney[keyMap] += v.Money
|
|
|
confirmedNoRenewalContractNum[keyMap]++
|
|
|
}
|
|
|
-
|
|
|
mapSignedClientMoney[keyMap] += v.Money
|
|
|
mapSignedClientNum[keyMap]++
|
|
|
}
|
|
|
|
|
|
+ listFmsData, err := fms.GetContractRegisterListByStartDate(startDate)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据信息失败"
|
|
|
+ br.ErrMsg = "获取财务系统数据信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range listFmsData {
|
|
|
+ startDateTime := v.StartDate
|
|
|
+ monthNum := startDateTime.Month()
|
|
|
+ yearStr := strconv.Itoa(startDateTime.Year())
|
|
|
+ if dataType == "季度" {
|
|
|
+ if monthNum < 4 {
|
|
|
+ yearStr += "Q1"
|
|
|
+ } else if monthNum > 3 && monthNum < 7 {
|
|
|
+ yearStr += "Q2"
|
|
|
+ } else if monthNum > 6 && monthNum < 10 {
|
|
|
+ yearStr += "Q3"
|
|
|
+ } else if monthNum > 9 {
|
|
|
+ yearStr += "Q4"
|
|
|
+ }
|
|
|
+ } else if dataType == "半年度" {
|
|
|
+ if monthNum < 7 {
|
|
|
+ yearStr += "H1"
|
|
|
+ } else {
|
|
|
+ yearStr += "H2"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ keyMap := fmt.Sprint(yearStr, "_", v.RaiSellerId)
|
|
|
+ mapInvoiceAmountMoney[keyMap] += v.InvoicedAmount
|
|
|
+ mapPaymentAmountMoney[keyMap] += v.PaymentAmount
|
|
|
+
|
|
|
+ if v.ContractType == 1 {
|
|
|
+ mapNewCustomerInvoicingMoney[keyMap] += v.InvoicedAmount
|
|
|
+ mapNewCustomerPaymentsReceivedMoney[keyMap] += v.PaymentAmount
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
conditionTry := ` AND a.create_time >= ? AND a.create_time <= ? AND a.operation in ( "add","receive","apply_receive" ) AND a.sys_user_id IN ( SELECT admin_id FROM admin WHERE role_type_code IN ( 'rai_seller', 'rai_group' , 'rai_admin') ) `
|
|
|
var parsTry []interface{}
|
|
|
parsTry = append(parsTry, startDate, endDate)
|
|
@@ -290,13 +333,18 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
|
|
|
sellerItem.AverageRevenueCount = utils.SubFloatToString(mapSignedClientMoney[keyMap]/float64(mapSignedClientNum[keyMap]), 2) //客单价
|
|
|
}
|
|
|
|
|
|
- sellerItem.InvoiceAmountCount = "开票金额-(数据)"
|
|
|
- sellerItem.PaymentReceivedCount = "到款金额-(数据)"
|
|
|
- sellerItem.UnpaidRatioCount = "未到款比例-(数据)"
|
|
|
- sellerItem.NewCustomerInvoicingCount = "新客开票-(数据)"
|
|
|
- sellerItem.NewCustomerPaymentsReceivedCount = "新客到款-(数据)"
|
|
|
+ sellerItem.InvoiceAmountCount = utils.SubFloatToString(mapInvoiceAmountMoney[keyMap], 2) //"开票金额-(数据)"
|
|
|
+ sellerItem.PaymentReceivedCount = utils.SubFloatToString(mapPaymentAmountMoney[keyMap], 2) //"开票金额-(数据)"
|
|
|
+ if mapInvoiceAmountMoney[keyMap] == 0 || mapPaymentAmountMoney[keyMap] == 0 {
|
|
|
+ sellerItem.UnpaidRatioCount = "0%"
|
|
|
+ } else {
|
|
|
+ sellerItem.UnpaidRatioCount = utils.SubFloatToString((mapInvoiceAmountMoney[keyMap]-mapPaymentAmountMoney[keyMap])/mapInvoiceAmountMoney[keyMap]*100, 2) + "%" //"未到款比例-(数据)"
|
|
|
+ }
|
|
|
+ sellerItem.NewCustomerInvoicingCount = utils.SubFloatToString(mapNewCustomerInvoicingMoney[keyMap], 2) // "新客开票-(数据)"
|
|
|
+ sellerItem.NewCustomerPaymentsReceivedCount = utils.SubFloatToString(mapNewCustomerPaymentsReceivedMoney[keyMap], 2) // "新客到款-(数据)"
|
|
|
item.DataList = append(item.DataList, sellerItem)
|
|
|
}
|
|
|
+
|
|
|
if len(sellerDevelop) > 0 {
|
|
|
sellerItem := new(statistic_report.RaiDataSummaryDetail)
|
|
|
sellerItem.SellerName = "开拓组合计"
|