zwxi преди 11 месеца
родител
ревизия
160d098ba5
променени са 2 файла, в които са добавени 43 реда и са изтрити 32 реда
  1. 42 31
      controller/census/invoice_payment.go
  2. 1 1
      controller/contract/pre_register.go

+ 42 - 31
controller/census/invoice_payment.go

@@ -811,29 +811,6 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 		historyCond += ` AND new_company = 0 `
 	}
 
-	// 套餐筛选
-	if req.ServiceTypes != "" {
-		serviceTypes := strings.Split(req.ServiceTypes, ",")
-		registerIds, e := fms.GetContractRegisterIdsByTempId(serviceTypes)
-		if e != nil {
-			err = fmt.Errorf("获取合同登记IDs失败, Err: %s", e.Error())
-			return
-		}
-		if len(registerIds) > 0 {
-			cond += ` AND b.contract_register_id IN ?`
-			pars = append(pars, registerIds)
-		} else {
-			cond += ` AND 1 = 2`
-		}
-		// 勾选套餐筛选时忽略导入的历史数据
-		if req.StartDate == "" {
-			req.StartDate = "2023-04"
-			req.EndDate = "3023-04"
-		} else {
-			req.StartDate = "2023-04"
-		}
-	}
-
 	var latestTime time.Time
 
 	invoiceItem, err := fms.GetLatestIncome(cond, pars)
@@ -865,6 +842,32 @@ func getCensusIncomeListV2(ch chan models.CensusIncomeChartResp, req fms.IncomeL
 	var reqStartDate, reqEndDate time.Time
 	historyTime, _ := time.Parse(utils.FormatDate, "2023-04-01")
 
+	// 套餐筛选
+	if req.ServiceTypes != "" {
+		serviceTypes := strings.Split(req.ServiceTypes, ",")
+		registerIds, e := fms.GetContractRegisterIdsByTempId(serviceTypes)
+		if e != nil {
+			err = fmt.Errorf("获取合同登记IDs失败, Err: %s", e.Error())
+			return
+		}
+		if len(registerIds) > 0 {
+			cond += ` AND b.contract_register_id IN ?`
+			pars = append(pars, registerIds)
+		} else {
+			cond += ` AND 1 = 2`
+		}
+		// 勾选套餐筛选时忽略导入的历史数据
+		if req.StartDate == "" {
+			req.StartDate = "2023-04"
+			req.EndDate = "3023-04"
+		} else {
+			startDateTime, _ := time.Parse(utils.FormatMonth, req.StartDate)
+			if startDateTime.Before(historyTime) {
+				req.StartDate = "2023-04"
+			}
+		}
+	}
+
 	if req.StartDate != "" && req.EndDate != "" {
 		st := fmt.Sprint(req.StartDate, "-01 00:00:00")
 		ed := fmt.Sprint(req.EndDate, "-01 23:59:59")
@@ -1604,6 +1607,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 							item.SellerName = v.SellerName
 							item.RaiSellerId = v.RaiSellerId
 							item.RaiSellerName = v.RaiSellerName
+							item.RMBRate = v.RMBRate
 
 							NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item)
 						}
@@ -1617,6 +1621,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 							item.SellerName = v.SellerName
 							item.RaiSellerId = v.RaiSellerId
 							item.RaiSellerName = v.RaiSellerName
+							item.RMBRate = v.RMBRate
 
 							NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item)
 						}
@@ -1633,6 +1638,8 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 						item1.SellerName = v.SellerName
 						item1.RaiSellerId = v.RaiSellerId
 						item1.RaiSellerName = v.RaiSellerName
+						item1.RMBRate = v.RMBRate
+
 						NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item1)
 
 						item2 := fms.NotInvoicePaymentSummaryItem{
@@ -1643,6 +1650,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 						item2.SellerName = v.SellerName
 						item2.RaiSellerId = v.RaiSellerId
 						item2.RaiSellerName = v.RaiSellerName
+						item2.RMBRate = v.RMBRate
 
 						NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item2)
 					}
@@ -1657,6 +1665,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 						item1.SellerName = v.SellerName
 						item1.RaiSellerId = v.RaiSellerId
 						item1.RaiSellerName = v.RaiSellerName
+						item1.RMBRate = v.RMBRate
 
 						NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item1)
 					}
@@ -1671,6 +1680,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 						item2.SellerName = v.SellerName
 						item2.RaiSellerId = v.RaiSellerId
 						item2.RaiSellerName = v.RaiSellerName
+						item2.RMBRate = v.RMBRate
 
 						NotInvoiceSummaryMap[v.ContractRegisterId] = append(NotInvoiceSummaryMap[v.ContractRegisterId], &item2)
 					}
@@ -1703,7 +1713,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 			}
 
 			for registerId, list := range NotInvoiceSummaryMap {
-				for _, v := range list {
+				for i, v := range list {
 					// fmt.Println("v.ContractRegisterId", v.ContractRegisterId)
 					// fmt.Println("v.ServiceProductId:", v.ServiceProductId)
 					// fmt.Println("v.NotInvoicedAmountTotal:", v.NotInvoicedAmountTotal)
@@ -1713,26 +1723,27 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
 							// 有合规登记或补录合同过的,有serviceAmountMap信息
 							if _, ok := serviceAmountMap[registerId]; ok {
 								if _, ok2 := serviceAmountMap[registerId][v.ServiceProductId]; ok2 {
-									v.NotInvoicedAmountOriginTotal = serviceAmountMap[registerId][v.ServiceProductId].ServiceAmount - v.InvoiceAmountTotal
+									list[i].NotInvoicedAmountOriginTotal = serviceAmountMap[registerId][v.ServiceProductId].ServiceAmount - v.InvoiceAmountTotal
 								}
 							} else {
 								// 预登记没有合同套餐金额信息
-								v.NotInvoicedAmountOriginTotal = v.InvoiceAmountTotal - v.PaymentAmountTotal
+								list[i].NotInvoicedAmountOriginTotal = v.InvoiceAmountTotal - v.PaymentAmountTotal
 							}
 						} else {
 							if _, ok := serviceAmountMap[registerId]; ok {
 								// 有合规登记或补录合同过的,有serviceAmountMap信息
 								if _, ok2 := serviceAmountMap[registerId][v.ServiceProductId]; ok2 {
-									v.NotInvoicedAmountOriginTotal = serviceAmountMap[registerId][v.ServiceProductId].ServiceAmount - v.PaymentAmountTotal
+									list[i].NotInvoicedAmountOriginTotal = serviceAmountMap[registerId][v.ServiceProductId].ServiceAmount - v.PaymentAmountTotal
 								}
 							} else {
 								// 预登记没有合同套餐金额信息
-								v.NotInvoicedAmountOriginTotal = v.PaymentAmountTotal - v.InvoiceAmountTotal
+								list[i].NotInvoicedAmountOriginTotal = v.PaymentAmountTotal - v.InvoiceAmountTotal
 							}
 						}
-						v.NotInvoicedAmountTotal = v.NotInvoicedAmountOriginTotal / v.RMBRate
-						v.NotInvoicedAmountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.NotInvoicedAmountTotal), 64)
 					}
+					list[i].NotInvoicedAmountTotal = v.NotInvoicedAmountOriginTotal / v.RMBRate
+					list[i].NotInvoicedAmountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.NotInvoicedAmountTotal), 64)
+
 					// 补充销售信息
 					if v.SellerId > 0 && v.RaiSellerId > 0 {
 						if v.ServiceProductId == 1 {
@@ -2439,7 +2450,7 @@ func ExportNotInvoiceCensusList(c *gin.Context, results *fms.NotInvoicePaymentCe
 			} else {
 
 				dataRow.AddCell().SetString(fmt.Sprintf("%.2f", item.NotInvoicedAmountOriginTotal)) // 未开票金额
-				dataRow.AddCell().SetString(fmt.Sprintf("%.2f", item.NotInvoicedAmountTotal)) // 未开票换算金额
+				dataRow.AddCell().SetString(fmt.Sprintf("%.2f", item.NotInvoicedAmountTotal))       // 未开票换算金额
 
 				dataRow.AddCell().SetString(serviceProductIdMap[item.ServiceProductId]) // 套餐类型
 

+ 1 - 1
controller/contract/pre_register.go

@@ -1177,7 +1177,7 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
 		if v.ContractInvoiceId != 0 {
 			//更新
 			invoiceHandleType = 1
-			invoiceUpdateCols = append(invoiceUpdateCols, "OriginAmount", "CurrencyUnit",
+			invoiceUpdateCols = append(invoiceUpdateCols, "Amount","OriginAmount", "CurrencyUnit",
 				"InvoiceDate", "Remark", "ServiceProductId", "StartDate", "EndDate", "ModifyTime")
 		} else {
 			//新增