|
@@ -1592,42 +1592,6 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
noSummaryCond += ` AND b.product_ids = '2' `
|
|
|
}
|
|
|
|
|
|
- // 开票到款日期
|
|
|
- //if req.TimeType != 0 {
|
|
|
- // if req.TimeType == 1 && req.StartDate != "" && req.EndDate != "" {
|
|
|
- // st := fmt.Sprint(req.StartDate, " 00:00:00")
|
|
|
- // ed := fmt.Sprint(req.EndDate, " 23:59:59")
|
|
|
- // cond += ` AND (c.invoice_time BETWEEN ? AND ?) `
|
|
|
- // pars = append(pars, st, ed)
|
|
|
- // }else if req.TimeType == 2 && req.StartDate != "" && req.EndDate != "" {
|
|
|
- // st := fmt.Sprint(req.StartDate, " 00:00:00")
|
|
|
- // ed := fmt.Sprint(req.EndDate, " 23:59:59")
|
|
|
- // cond += ` AND (d.invoice_time BETWEEN ? AND ?) `
|
|
|
- // pars = append(pars, st, ed)
|
|
|
- // }else if req.TimeType == 3 && req.StartDate != "" && req.EndDate != "" {
|
|
|
- // st := fmt.Sprint(req.StartDate, " 00:00:00")
|
|
|
- // ed := fmt.Sprint(req.EndDate, " 23:59:59")
|
|
|
- // cond += ` AND (c.invoice_time BETWEEN ? AND ?) AND (d.invoice_time BETWEEN ? AND ?) `
|
|
|
- // pars = append(pars, st, ed, st, ed)
|
|
|
- // }
|
|
|
- //} else if req.StartDate != "" && req.EndDate != "" {
|
|
|
- // st := fmt.Sprint(req.StartDate, " 00:00:00")
|
|
|
- // ed := fmt.Sprint(req.EndDate, " 23:59:59")
|
|
|
- // cond += ` AND ((c.invoice_time BETWEEN ? AND ?) or (d.invoice_time BETWEEN ? AND ?))`
|
|
|
- // pars = append(pars, st, ed, st, ed)
|
|
|
- //}
|
|
|
-
|
|
|
- //if req.HasInvoice == "1" {
|
|
|
- // cond += ` AND a.invoice_id > 0 `
|
|
|
- //}else if req.HasInvoice == "0" {
|
|
|
- // cond += ` AND a.invoice_id = 0 `
|
|
|
- //}
|
|
|
- //
|
|
|
- //if req.HasPayment == "1" {
|
|
|
- // cond += ` AND a.payment_id > 0 `
|
|
|
- //}else if req.HasPayment == "0" {
|
|
|
- // cond += ` AND a.payment_id = 0 `
|
|
|
- //}
|
|
|
|
|
|
page := new(base.Page)
|
|
|
page.SetPageSize(req.PageSize)
|
|
@@ -1693,21 +1657,21 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
// 获取汇总数据IDs, 用于查询合计数据
|
|
|
- summaryIdsCond := cond
|
|
|
- summaryIdsPars := pars
|
|
|
- if req.SellerIds != "" {
|
|
|
- sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
- summaryIdsCond += ` AND c.seller_id in ? AND (d.origin_amount > c.origin_amount OR c.origin_amount IS NULL) `
|
|
|
- summaryIdsPars = append(summaryIdsPars, sellerIds)
|
|
|
- } else {
|
|
|
- summaryIdsCond += ` AND (d.origin_amount > c.origin_amount OR c.origin_amount IS NULL) `
|
|
|
- summaryIdsPars = append(summaryIdsPars)
|
|
|
- }
|
|
|
- summaryIds, e := fms.GetInvoicePaymentCensusSummaryDataIds(summaryIdsCond, summaryIdsPars)
|
|
|
- if e != nil {
|
|
|
- resp.FailMsg("获取失败", "获取商品到款汇总IDs失败, Err: "+e.Error(), c)
|
|
|
- return
|
|
|
- }
|
|
|
+ //summaryIdsCond := cond
|
|
|
+ //summaryIdsPars := pars
|
|
|
+ //if req.SellerIds != "" {
|
|
|
+ // sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
+ // summaryIdsCond += ` AND c.seller_id in ? AND (d.origin_amount > c.origin_amount OR c.origin_amount IS NULL) `
|
|
|
+ // summaryIdsPars = append(summaryIdsPars, sellerIds)
|
|
|
+ //} else {
|
|
|
+ // summaryIdsCond += ` AND (d.origin_amount > c.origin_amount OR c.origin_amount IS NULL) `
|
|
|
+ // summaryIdsPars = append(summaryIdsPars)
|
|
|
+ //}
|
|
|
+ //summaryIds, e := fms.GetInvoicePaymentCensusSummaryDataIds(summaryIdsCond, summaryIdsPars)
|
|
|
+ //if e != nil {
|
|
|
+ // resp.FailMsg("获取失败", "获取商品到款汇总IDs失败, Err: "+e.Error(), c)
|
|
|
+ // return
|
|
|
+ //}
|
|
|
|
|
|
//fmt.Println("summaryIds:",summaryIds)
|
|
|
var listErr, totalErr, totalGroupErr error
|
|
@@ -1931,29 +1895,52 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
}()
|
|
|
|
|
|
// 开票到款金额合计(换算后)
|
|
|
- var invoiceTotal, paymentTotal, contractAmount float64
|
|
|
+ //var invoiceTotal, paymentTotal, contractAmount float64
|
|
|
+ //wg.Add(1)
|
|
|
+ //go func() {
|
|
|
+ // defer wg.Done()
|
|
|
+ //
|
|
|
+ // if len(summaryIds) == 0 {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // amountTotalCond := `a.id IN ?`
|
|
|
+ // amountTotalPars := make([]interface{}, 0)
|
|
|
+ // amountTotalPars = append(amountTotalPars, summaryIds)
|
|
|
+ // invoiceSum, e := fms.GetContractSummaryInvoicePaymentAmountTotal(amountTotalCond, amountTotalPars, 1)
|
|
|
+ // if e != nil {
|
|
|
+ // totalErr = fmt.Errorf("获取汇总开票金额合计失败, Err: %s", e.Error())
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // invoiceTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", invoiceSum), 64)
|
|
|
+ // paymentSum, e := fms.GetContractSummaryInvoicePaymentAmountTotal(amountTotalCond, amountTotalPars, 2)
|
|
|
+ // if e != nil {
|
|
|
+ // totalErr = fmt.Errorf("获取汇总到款金额合计失败, Err: %s", e.Error())
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // paymentTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", paymentSum), 64)
|
|
|
+ //}()
|
|
|
+
|
|
|
+ // 开票到款金额合计(换算后)V2
|
|
|
+ var invoiceTotal, contractAmount float64
|
|
|
wg.Add(1)
|
|
|
go func() {
|
|
|
defer wg.Done()
|
|
|
|
|
|
- if len(summaryIds) == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- amountTotalCond := `a.id IN ?`
|
|
|
- amountTotalPars := make([]interface{}, 0)
|
|
|
- amountTotalPars = append(amountTotalPars, summaryIds)
|
|
|
- invoiceSum, e := fms.GetContractSummaryInvoicePaymentAmountTotal(amountTotalCond, amountTotalPars, 1)
|
|
|
+ registerList, e := fms.GetInvoiceCensusList(cond, pars)
|
|
|
if e != nil {
|
|
|
- totalErr = fmt.Errorf("获取汇总开票金额合计失败, Err: %s", e.Error())
|
|
|
+ resp.FailMsg("获取失败", "获取商品到款统计列表总数失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- invoiceTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", invoiceSum), 64)
|
|
|
- paymentSum, e := fms.GetContractSummaryInvoicePaymentAmountTotal(amountTotalCond, amountTotalPars, 2)
|
|
|
- if e != nil {
|
|
|
- totalErr = fmt.Errorf("获取汇总到款金额合计失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
+
|
|
|
+ for _, v := range registerList {
|
|
|
+ if v.InvoicedAmountCount >= v.PaymentAmountCount {
|
|
|
+ invoiceTotal += v.InvoicedAmountCount
|
|
|
+ } else if v.InvoicedAmountCount == 0 {
|
|
|
+ invoiceTotal += v.PaymentAmountCount
|
|
|
+ }
|
|
|
+ contractAmount += v.ContractAmount
|
|
|
}
|
|
|
- paymentTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", paymentSum), 64)
|
|
|
+
|
|
|
}()
|
|
|
|
|
|
// 分币种金额统计
|
|
@@ -1995,56 +1982,25 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- if len(summaryIds) == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- totalGroupCond := `a.id IN ?`
|
|
|
- totalGroupPars := make([]interface{}, 0)
|
|
|
- totalGroupPars = append(totalGroupPars, summaryIds)
|
|
|
- invoiceSumGroup, e := fms.GetSummaryListCurrencySum(totalGroupCond, totalGroupPars, 1)
|
|
|
- if e != nil {
|
|
|
- totalGroupErr = fmt.Errorf("获取汇总货币合计开票金额失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- paymentSumGroup, e := fms.GetSummaryListCurrencySum(totalGroupCond, totalGroupPars, 2)
|
|
|
+ registerList, e := fms.GetInvoiceCensusList(cond, pars)
|
|
|
if e != nil {
|
|
|
- totalGroupErr = fmt.Errorf("获取汇总货币合计到款金额失败, Err: %s", e.Error())
|
|
|
+ resp.FailMsg("获取失败", "获取商品到款统计列表总数失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
invoiceSumMap := make(map[string]float64)
|
|
|
- paymentSumMap := make(map[string]float64)
|
|
|
contractSumMap := make(map[string]float64)
|
|
|
|
|
|
- for i := range invoiceSumGroup {
|
|
|
- invoiceSumMap[invoiceSumGroup[i].CurrencyUnit] = invoiceSumGroup[i].OriginAmountTotal
|
|
|
- continue
|
|
|
- }
|
|
|
- for i := range paymentSumGroup {
|
|
|
- paymentSumMap[paymentSumGroup[i].CurrencyUnit] = paymentSumGroup[i].OriginAmountTotal
|
|
|
- continue
|
|
|
- }
|
|
|
- for i := range invoiceCurrencyTotals {
|
|
|
- a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", invoiceSumMap[invoiceCurrencyTotals[i].Code]), 64)
|
|
|
- invoiceCurrencyTotals[i].Amount = a
|
|
|
- }
|
|
|
- for i := range paymentCurrencyTotals {
|
|
|
- a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", paymentSumMap[paymentCurrencyTotals[i].Code]), 64)
|
|
|
- paymentCurrencyTotals[i].Amount = a
|
|
|
- }
|
|
|
|
|
|
- contractRegisters, err := fms.GetContractInfoByRegisterIds(queryRegisterIds)
|
|
|
- if err != nil {
|
|
|
- resp.FailMsg("查询合同信息失败", "查询合同信息失败, Err: "+err.Error(), c)
|
|
|
- return
|
|
|
- }
|
|
|
- for _, v := range contractRegisters {
|
|
|
- if v.RMBRate == 0.0 {
|
|
|
- v.RMBRate = 1
|
|
|
+ for _, v := range registerList {
|
|
|
+ if v.InvoicedAmount >= v.PaymentAmount {
|
|
|
+ invoiceSumMap[v.CurrencyUnit] += v.InvoicedAmount
|
|
|
+ } else if v.InvoicedAmount == 0 {
|
|
|
+ invoiceSumMap[v.CurrencyUnit] += v.PaymentAmount
|
|
|
}
|
|
|
- amount, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v.ContractAmount/v.RMBRate), 64)
|
|
|
- contractAmount += amount
|
|
|
- contractSumMap[v.CurrencyUnit] = v.ContractAmount
|
|
|
+ contractSumMap[v.CurrencyUnit] += v.ContractAmount
|
|
|
}
|
|
|
+
|
|
|
for _, v := range contractAmountCurrencyTotals {
|
|
|
v.Amount = contractSumMap[v.Code] - invoiceSumMap[v.Code]
|
|
|
}
|
|
@@ -2067,7 +2023,6 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
}
|
|
|
results.DataList = respList
|
|
|
results.InvoiceTotal = invoiceTotal
|
|
|
- results.PaymentTotal = paymentTotal
|
|
|
results.NotInvoiceTotal = contractAmount - invoiceTotal
|
|
|
results.InvoiceCurrencyTotal = invoiceCurrencyTotals
|
|
|
results.PaymentCurrencyTotal = paymentCurrencyTotals
|