|
@@ -1637,6 +1637,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
page.SetCurrent(1)
|
|
|
}
|
|
|
|
|
|
+ //先拿到在筛选范围内的合同列表
|
|
|
cond += ` AND b.contract_amount <> b.invoiced_amount AND b.is_deleted = 0 AND b.contract_amount <> b.payment_amount AND b.contract_status <> 4 `
|
|
|
registerList, total, e := fms.GetInvoiceCensusPageList(page, cond, pars)
|
|
|
if e != nil {
|
|
@@ -1675,6 +1676,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
defer wg.Done()
|
|
|
|
|
|
// 获取汇总数据
|
|
|
+ // 这里只能获取到有开票到款过的记录
|
|
|
summaryCond := cond
|
|
|
summaryCond += ` AND a.register_id IN ?`
|
|
|
summaryPars := pars
|
|
@@ -1685,11 +1687,24 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
resp.FailMsg("获取失败", "获取商品到款汇总列表失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+ fmt.Println("len(summaryData)", len(summaryData))
|
|
|
+
|
|
|
+ // 有过开票到款记录的合同ids,在后面的查询中去除
|
|
|
notQueryRegisterIds := make([]int, 0)
|
|
|
for _, v := range summaryData {
|
|
|
notQueryRegisterIds = append(notQueryRegisterIds, v.ContractRegisterId)
|
|
|
}
|
|
|
|
|
|
+ summaryList = summaryData
|
|
|
+
|
|
|
+ // 有开票到款过的记录map,用于在后面判断是否有过开票到款,然后补充数据
|
|
|
+ NotInvoiceSummaryMap := make(map[int][]*fms.NotInvoicePaymentSummaryItem, 0)
|
|
|
+ for _, v := range summaryList {
|
|
|
+ fmt.Println("v2.ContractRegisterId", v.ContractRegisterId)
|
|
|
+ NotInvoiceSummaryMap[v.RegisterId] = append(NotInvoiceSummaryMap[v.RegisterId], v)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取未进行过开票到款的合同数据,其实只用到了合同id和ProductIds用来补充不同的套餐信息
|
|
|
noSummaryCond += ` AND b.is_deleted = 0 AND b.contract_status <> 4 `
|
|
|
if len(notQueryRegisterIds) >0 {
|
|
|
noSummaryCond += ` AND b.contract_register_id IN ? AND b.contract_register_id NOT IN ?`
|
|
@@ -1698,26 +1713,19 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
noSummaryCond += ` AND b.contract_register_id IN ? `
|
|
|
noSummaryPars = append(noSummaryPars, queryRegisterIds)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
noSummaryData, e := fms.GetNoInvoicePaymentCensusData(noSummaryCond, noSummaryPars)
|
|
|
if e != nil {
|
|
|
resp.FailMsg("获取失败", "GetNoInvoicePaymentCensusData, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- fmt.Println("len(summaryData)", len(summaryData))
|
|
|
fmt.Println("len(noSummaryData)", len(noSummaryData))
|
|
|
- summaryList = summaryData
|
|
|
- NotInvoiceSummaryMap := make(map[int][]*fms.NotInvoicePaymentSummaryItem, 0)
|
|
|
- for _, v := range summaryList {
|
|
|
- fmt.Println("v2.ContractRegisterId", v.ContractRegisterId)
|
|
|
- NotInvoiceSummaryMap[v.RegisterId] = append(NotInvoiceSummaryMap[v.RegisterId], v)
|
|
|
- }
|
|
|
|
|
|
+ //补充为完整的list,包含有汇总记录的和没有汇总记录的
|
|
|
summaryList = append(summaryList, noSummaryData...)
|
|
|
|
|
|
//fmt.Println("len(NotInvoiceSummaryMap):", len(NotInvoiceSummaryMap))
|
|
|
|
|
|
+ //遍历列表,补充数据
|
|
|
for _, v := range summaryList {
|
|
|
//fmt.Println("ProductIds:", v.ProductIds)
|
|
|
//fmt.Println("ContractRegisterId:", v.ContractRegisterId)
|
|
@@ -1725,6 +1733,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
//fmt.Println("RegisterId:", v.RegisterId)
|
|
|
//fmt.Println("len(NotInvoiceSummaryMap[v.RegisterId]):", len(NotInvoiceSummaryMap[v.ContractRegisterId]))
|
|
|
if (v.ProductIds == "1,2" || v.ProductIds == "2,1") && len(NotInvoiceSummaryMap[v.ContractRegisterId]) == 1 {
|
|
|
+ // 套餐是ficc权益都有的,但是只有一个套餐有过开票到款,手动补充另一个套餐的信息
|
|
|
if v.ServiceProductId == 1 {
|
|
|
if serviceAmount, ok := serviceAmountMap[v.ContractRegisterId]; ok {
|
|
|
item := fms.NotInvoicePaymentSummaryItem{
|
|
@@ -1738,7 +1747,6 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
|
|
|
NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item)
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
if serviceAmount, ok := serviceAmountMap[v.ContractRegisterId]; ok {
|
|
|
item := fms.NotInvoicePaymentSummaryItem{
|
|
@@ -1755,6 +1763,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
|
|
|
}
|
|
|
} else if (v.ProductIds == "1,2" || v.ProductIds == "2,1") && len(NotInvoiceSummaryMap[v.ContractRegisterId]) == 0 {
|
|
|
+ // 套餐是ficc权益都有的,但是都没进行过开票到款,补充两个套餐的内容,直接用合同金额当作未开票金额即可
|
|
|
if serviceAmount, ok := serviceAmountMap[v.ContractRegisterId]; ok {
|
|
|
item1 := fms.NotInvoicePaymentSummaryItem{
|
|
|
NotInvoicedAmountTotal: serviceAmount[2].ServiceAmount,
|
|
@@ -1778,6 +1787,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item2)
|
|
|
}
|
|
|
} else if v.ProductIds == "1" && len(NotInvoiceSummaryMap[v.ContractRegisterId]) == 0 {
|
|
|
+ // 只有ficc套餐,但是未进行过开票到款,手动补充信息
|
|
|
if serviceAmount, ok := serviceAmountMap[v.ContractRegisterId]; ok {
|
|
|
item1 := fms.NotInvoicePaymentSummaryItem{
|
|
|
NotInvoicedAmountTotal: serviceAmount[1].ServiceAmount,
|
|
@@ -1791,6 +1801,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item1)
|
|
|
}
|
|
|
} else if v.ProductIds == "2" && len(NotInvoiceSummaryMap[v.ContractRegisterId]) == 0 {
|
|
|
+ // 只有权益套餐,但是未进行过开票到款,手动补充信息
|
|
|
if serviceAmount, ok := serviceAmountMap[v.ContractRegisterId]; ok {
|
|
|
item2 := fms.NotInvoicePaymentSummaryItem{
|
|
|
NotInvoicedAmountTotal: serviceAmount[2].ServiceAmount,
|
|
@@ -1831,6 +1842,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
unitMap[currencyList[i].Code] = currencyList[i].UnitName
|
|
|
}
|
|
|
|
|
|
+
|
|
|
for registerId, list := range NotInvoiceSummaryMap {
|
|
|
for _, v := range list {
|
|
|
fmt.Println("v.ContractRegisterId", v.ContractRegisterId)
|
|
@@ -1843,6 +1855,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
v.NotInvoicedAmountTotal = serviceAmountMap[registerId][v.ServiceProductId].ServiceAmount - v.PaymentAmountTotal
|
|
|
}
|
|
|
}
|
|
|
+ // 补充销售信息
|
|
|
if v.SellerId > 0 && v.RaiSellerId > 0 {
|
|
|
if v.ServiceProductId == 1 {
|
|
|
if seller, ok := sellerMap[v.SellerId]; ok {
|
|
@@ -2198,19 +2211,7 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
for i := range currencyList {
|
|
|
unitMap[currencyList[i].Code] = currencyList[i].UnitName
|
|
|
}
|
|
|
- //// 获取合同的套餐金额信息
|
|
|
- //serviceAmountList, e := fms.GetContractServiceAmountByContractRegisterIds(queryRegisterIds)
|
|
|
- //if e != nil {
|
|
|
- // resp.FailData("获取合同的套餐金额信息失败", "Err:"+e.Error(), c)
|
|
|
- // return
|
|
|
- //}
|
|
|
- //serviceAmountMap := make(map[int]map[int]*fms.ContractServiceAmount, 0)
|
|
|
- //for _, v := range serviceAmountList {
|
|
|
- // if _, ok := serviceAmountMap[v.ContractRegisterId]; !ok {
|
|
|
- // serviceAmountMap[v.ContractRegisterId] = make(map[int]*fms.ContractServiceAmount)
|
|
|
- // }
|
|
|
- // serviceAmountMap[v.ContractRegisterId][v.ProductId] = v
|
|
|
- //}
|
|
|
+
|
|
|
sellerList, e := crmService.GetSellerDepartmentListWithEnable()
|
|
|
if e != nil {
|
|
|
resp.FailData("获取销售失败", "Err:"+e.Error(), c)
|
|
@@ -2328,12 +2329,6 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
Code: currencyList[i].Code,
|
|
|
FlagImg: currencyList[i].FlagImg,
|
|
|
})
|
|
|
- //contractAmountCurrencyTotals = append(contractAmountCurrencyTotals, &fms.InvoiceListCurrencyTotal{
|
|
|
- // Name: currencyList[i].Name,
|
|
|
- // UnitName: currencyList[i].UnitName,
|
|
|
- // Code: currencyList[i].Code,
|
|
|
- // FlagImg: currencyList[i].FlagImg,
|
|
|
- //})
|
|
|
}
|
|
|
|
|
|
if len(summaryIds) == 0 {
|
|
@@ -2377,23 +2372,6 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
notpaymentCurrencyTotals[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
|
|
|
- // }
|
|
|
- // amount, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v.ContractAmount/v.RMBRate), 64)
|
|
|
- // contractAmount += amount
|
|
|
- // contractSumMap[v.CurrencyUnit] = v.ContractAmount
|
|
|
- //}
|
|
|
- //for _, v := range contractAmountCurrencyTotals {
|
|
|
- // v.Amount = contractSumMap[v.Code] - invoiceSumMap[v.Code]
|
|
|
- //}
|
|
|
-
|
|
|
}()
|
|
|
|
|
|
wg.Wait()
|