ziwen hai 1 ano
pai
achega
797a8844ea
Modificáronse 2 ficheiros con 23 adicións e 9 borrados
  1. 17 6
      controller/census/invoice_payment.go
  2. 6 3
      models/fms/invoice_payment_summary.go

+ 17 - 6
controller/census/invoice_payment.go

@@ -1568,8 +1568,8 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 	}
 	if req.SellerIds != "" {
 		sellerIds := strings.Split(req.SellerIds, ",")
-		cond += ` AND (c.seller_id in ?)`
-		pars = append(pars, sellerIds)
+		cond += ` AND (b.seller_id in ? OR b.rai_seller_id in ?)`
+		pars = append(pars, sellerIds, sellerIds)
 		noSummaryCond += ` AND (b.seller_id in ? OR b.rai_seller_id in ?)`
 		noSummaryPars = append(noSummaryPars, sellerIds, sellerIds)
 	}
@@ -1941,6 +1941,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 				resp.FailMsg("获取失败", "获取商品到款统计列表总数失败, Err: "+e.Error(), c)
 				return
 			}
+			contractIdSumMap := make(map[int]int)
 
 			for _, v := range registerList {
 				if v.InvoicedAmountCount >= v.PaymentAmountCount {
@@ -1952,7 +1953,10 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 				if rate == 0.0 {
 					rate = 1.0
 				}
-				contractAmount += v.ContractAmount / v.RMBRate
+				if _,ok := contractIdSumMap[v.ContractRegisterId]; !ok{
+					contractIdSumMap[v.ContractRegisterId] = 1
+					contractAmount += v.ContractAmount / v.RMBRate
+				}
 			}
 
 		}()
@@ -2004,14 +2008,18 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 
 			invoiceSumMap := make(map[string]float64)
 			contractSumMap := make(map[string]float64)
+			contractIdSumMap := make(map[int]int)
 
 			for _, v := range registerList {
-				if v.InvoicedAmount >= v.PaymentAmount {
+				if v.InvoiceOrigin >= v.PaymentOrigin {
 					invoiceSumMap[v.CurrencyUnit] += v.InvoicedAmount
-				} else if v.InvoicedAmount == 0 {
+				} else {
 					invoiceSumMap[v.CurrencyUnit] += v.PaymentAmount
 				}
-				contractSumMap[v.CurrencyUnit] += v.ContractAmount
+				if _,ok := contractIdSumMap[v.ContractRegisterId]; !ok{
+					contractIdSumMap[v.ContractRegisterId] = 1
+					contractSumMap[v.CurrencyUnit] += v.ContractAmount
+				}
 			}
 
 			for _, v := range contractAmountCurrencyTotals {
@@ -2572,9 +2580,12 @@ func ExportNotInvoiceCensusList(c *gin.Context, results *fms.NotInvoicePaymentCe
 				}
 
 			} else {
+
 				dataRow.AddCell().SetString(fmt.Sprintf("%.2f", item.NotInvoicedAmountTotal)) // 未开票金额
+
 				dataRow.AddCell().SetString(serviceProductIdMap[item.ServiceProductId])       // 套餐类型
 
+
 				if item.SellerId > 0 && item.RaiSellerId > 0 {
 					if item.ServiceProductId == 1 {
 						item.SellerGroupName = sellerMap[item.SellerId].GroupName

+ 6 - 3
models/fms/invoice_payment_summary.go

@@ -103,7 +103,7 @@ type InvoicePaymentSummaryItem struct {
 func GetInvoicePaymentCensusSummaryData(condition string, pars []interface{}) (results []*InvoicePaymentSummaryItem, err error) {
 	fields := []string{"a.id AS summary_id", "a.register_id", "a.invoice_id", "a.payment_id", "a.service_product_id", "b.company_name", "b.start_date", "b.end_date",
 		"c.origin_amount AS invoice_amount", "c.invoice_time AS invoice_date", "IF(c.seller_id > 0, c.seller_id, d.seller_id) AS seller_id", "IF(c.seller_name = '' OR c.seller_name IS NULL, d.seller_name, c.seller_name) AS seller_name", "IF(c.seller_group_id > 0,c.seller_group_id,d.seller_group_id) AS seller_group_id",
-		"IF(c.seller_group_name = '' OR c.seller_group_name IS NULL, d.seller_group_name, c.seller_group_name) AS seller_group_name", "d.origin_amount AS payment_amount", "d.invoice_time AS payment_date", "d.pay_type","b.currency_unit",
+		"IF(c.seller_group_name = '' OR c.seller_group_name IS NULL, d.seller_group_name, c.seller_group_name) AS seller_group_name", "d.origin_amount AS payment_amount", "d.invoice_time AS payment_date", "d.pay_type", "b.currency_unit",
 	}
 	query := global.DEFAULT_MYSQL.Table("invoice_payment_summary AS a").
 		Select(strings.Join(fields, ",")).
@@ -218,6 +218,9 @@ type InvoiceSummary struct {
 	SummaryId           int     `json:"summary_id" description:"汇总ID"`
 	PaymentAmountCount  float64 `gorm:"column:payment_amount_count" json:"payment_amount_count" description:"到款金额"`
 	InvoicedAmountCount float64 `gorm:"column:invoiced_amount_count" json:"invoiced_amount_count" description:"开票金额"`
+	InvoiceOrigin       float64 `gorm:"column:invoice_origin" json:"invoice_origin" description:"开票原始金额"`
+	PaymentOrigin       float64 `gorm:"column:payment_origin" json:"payment_origin" description:"到款原始金额"`
+	ServiceProductId    int     `json:"service_product_id" description:"套餐类型:1ficc套餐,2权益套餐"`
 	ContractRegister
 }
 
@@ -348,11 +351,11 @@ func GetNoInvoicePaymentCensusData(condition string, pars []interface{}) (result
 // GetInvoiceCensusList 获取未开票统计列表
 func GetInvoiceCensusList(condition string, pars []interface{}) (results []*InvoiceSummary, err error) {
 	query := global.DEFAULT_MYSQL.Table("contract_register AS b").
-		Select("b.*, a.id as summary_id, IF(a.invoice_id >0, 1,0) as sort_invoice_id, IF(a.payment_id >0, 1,0) as sort_payment_id, COALESCE(SUM( c.amount ),0) AS invoiced_amount_count,COALESCE(SUM( d.amount ),0) AS payment_amount_count ").
+		Select("b.*, a.id as summary_id, IF(a.invoice_id >0, 1,0) as sort_invoice_id, IF(a.payment_id >0, 1,0) as sort_payment_id, COALESCE(SUM( c.amount ),0) AS invoiced_amount_count,COALESCE(SUM( d.amount ),0) AS payment_amount_count,a.service_product_id,c.origin_amount AS invoice_origin,d.origin_amount AS payment_origin ").
 		Joins("left JOIN invoice_payment_summary AS a ON a.register_id = b.contract_register_id AND b.is_deleted = 0").
 		Joins("LEFT JOIN contract_invoice AS c ON a.invoice_id = c.contract_invoice_id AND c.is_deleted = 0").
 		Joins("LEFT JOIN contract_invoice AS d ON a.payment_id = d.contract_invoice_id AND d.is_deleted = 0").
-		Where(condition, pars...).Group("contract_register_id")
+		Where(condition, pars...).Group("contract_register_id,service_product_id")
 
 	nq := global.DEFAULT_MYSQL.Table("(?) AS e", query).
 		Select("*").Where(" e.invoiced_amount_count <>  e.contract_amount ")