|
@@ -945,8 +945,8 @@ func (ct *InvoicePaymentController) List(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -957,7 +957,7 @@ func (ct *InvoicePaymentController) List(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -975,11 +975,11 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
|
|
|
cond := `1 = 1`
|
|
|
pars := make([]interface{}, 0)
|
|
|
-
|
|
|
+
|
|
|
if req.Keyword != "" {
|
|
|
kw := "%" + req.Keyword + "%"
|
|
|
- cond += ` AND b.company_name LIKE ?`
|
|
|
- pars = append(pars, kw)
|
|
|
+ cond += ` AND (b.company_name LIKE ? OR b.contract_code LIKE ?)`
|
|
|
+ pars = append(pars, kw, kw)
|
|
|
}
|
|
|
if req.SellerIds != "" {
|
|
|
sellerIds := strings.Split(req.SellerIds, ",")
|
|
@@ -1060,18 +1060,18 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
if req.SortParam == "" {
|
|
|
- page.AddOrderItem(base.OrderItem{Column: "b.start_date", Asc: false})
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "e.start_date", Asc: false})
|
|
|
}else if req.SortParam == "start_date" {
|
|
|
if req.SortType == "asc" {
|
|
|
- page.AddOrderItem(base.OrderItem{Column: "b.start_date", Asc: true})
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "e.start_date", Asc: true})
|
|
|
}else{
|
|
|
- page.AddOrderItem(base.OrderItem{Column: "b.start_date", Asc: false})
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "e.start_date", Asc: false})
|
|
|
}
|
|
|
}else if req.SortParam == "end_date" {
|
|
|
if req.SortType == "asc" {
|
|
|
- page.AddOrderItem(base.OrderItem{Column: "b.end_date", Asc: true})
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "e.end_date", Asc: true})
|
|
|
}else{
|
|
|
- page.AddOrderItem(base.OrderItem{Column: "b.end_date", Asc: false})
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "e.end_date", Asc: false})
|
|
|
}
|
|
|
}else{
|
|
|
resp.Fail("排序字段不正确", c)
|
|
@@ -1095,7 +1095,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- results := new(fms.InvoicePaymentCensusResp)
|
|
|
+ results := new(fms.NotInvoicePaymentCensusResp)
|
|
|
if len(queryRegisterIds) > 0 {
|
|
|
|
|
|
summaryIdsCond := cond
|
|
@@ -1231,6 +1231,20 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
summaryMap[summaryList[i].SummaryId] = append(summaryMap[summaryList[i].SummaryId], v)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ currencyOB := new(fms.CurrencyUnit)
|
|
|
+ currencyCond := `enable = 1`
|
|
|
+ currencyPars := make([]interface{}, 0)
|
|
|
+ currencyList, e := currencyOB.List(currencyCond, currencyPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取失败", "获取货币列表失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ unitMap := make(map[string]string)
|
|
|
+ for i := range currencyList {
|
|
|
+ unitMap[currencyList[i].Code] = currencyList[i].UnitName
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
for i := range registerList {
|
|
|
v := new(fms.InvoicePaymentCensusItem)
|
|
@@ -1243,12 +1257,17 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
v.ServicesName = servicesNameMap[registerList[i].ContractRegisterId]
|
|
|
v.InvoicePaymentList = summaryMap[registerList[i].SummaryId]
|
|
|
v.ContractType = registerList[i].ContractType
|
|
|
+ v.ContractCode = registerList[i].ContractCode
|
|
|
+ v.ContractAmount = registerList[i].ContractAmount
|
|
|
+ v.UnitName = unitMap[registerList[i].CurrencyUnit]
|
|
|
+ v.ProductIds = registerList[i].ProductIds
|
|
|
+ v.NotInvoiceTotal = registerList[i].ContractAmount - registerList[i].InvoicedAmount
|
|
|
respList = append(respList, v)
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
|
|
|
- var invoiceTotal, paymentTotal float64
|
|
|
+ var invoiceTotal, paymentTotal, contractAmount float64
|
|
|
wg.Add(1)
|
|
|
go func() {
|
|
|
defer wg.Done()
|
|
@@ -1276,6 +1295,7 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
|
|
|
invoiceCurrencyTotals := make([]*fms.InvoiceListCurrencyTotal, 0)
|
|
|
paymentCurrencyTotals := make([]*fms.InvoiceListCurrencyTotal, 0)
|
|
|
+ contractAmountCurrencyTotals := make([]*fms.InvoiceListCurrencyTotal, 0)
|
|
|
wg.Add(1)
|
|
|
go func() {
|
|
|
defer wg.Done()
|
|
@@ -1303,6 +1323,12 @@ func (ct *InvoicePaymentController) NotInvoiceList(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 {
|
|
@@ -1323,6 +1349,8 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
}
|
|
|
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
|
|
@@ -1339,6 +1367,24 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
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
|
|
|
+ }
|
|
|
+ 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()
|
|
@@ -1355,17 +1401,18 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
resp.FailMsg("获取失败", totalGroupErr.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
results.DataList = respList
|
|
|
results.InvoiceTotal = invoiceTotal
|
|
|
results.PaymentTotal = paymentTotal
|
|
|
+ results.NotInvoiceTotal = contractAmount-invoiceTotal
|
|
|
results.InvoiceCurrencyTotal = invoiceCurrencyTotals
|
|
|
results.PaymentCurrencyTotal = paymentCurrencyTotals
|
|
|
+ results.NotInvoiceCurrencyTotal = contractAmountCurrencyTotals
|
|
|
}
|
|
|
|
|
|
|
|
|
if req.IsExport == 1 {
|
|
|
- ExportInvoicePaymentCensusList(c, results)
|
|
|
+ ExportNotInvoiceCensusList(c, results)
|
|
|
return
|
|
|
}
|
|
|
page.SetTotal(total)
|
|
@@ -1376,8 +1423,8 @@ func (ct *InvoicePaymentController) NotInvoiceList(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -1409,8 +1456,8 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
|
|
|
if req.Keyword != "" {
|
|
|
kw := "%" + req.Keyword + "%"
|
|
|
- cond += ` AND b.company_name LIKE ?`
|
|
|
- pars = append(pars, kw)
|
|
|
+ cond += ` AND (b.company_name LIKE ? OR b.contract_code LIKE ?)`
|
|
|
+ pars = append(pars, kw, kw)
|
|
|
}
|
|
|
if req.SellerIds != "" {
|
|
|
sellerIds := strings.Split(req.SellerIds, ",")
|
|
@@ -1491,9 +1538,9 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
if req.SortType == "asc" {
|
|
|
- page.AddOrderItem(base.OrderItem{Column: "c.invoice_time", Asc: true})
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "e.invoice_time", Asc: true})
|
|
|
}else{
|
|
|
- page.AddOrderItem(base.OrderItem{Column: "c.invoice_time", Asc: false})
|
|
|
+ page.AddOrderItem(base.OrderItem{Column: "e.invoice_time", Asc: false})
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1513,7 +1560,7 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- results := new(fms.InvoicePaymentCensusResp)
|
|
|
+ results := new(fms.NotInvoicePaymentCensusResp)
|
|
|
if len(queryRegisterIds) > 0 {
|
|
|
|
|
|
summaryIdsCond := cond
|
|
@@ -1617,6 +1664,7 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
v.PaymentDate = utils.TimeTransferString(utils.FormatDate, summaryList[i].PaymentDate)
|
|
|
v.PaymentAmount = summaryList[i].PaymentAmount
|
|
|
v.PayType = summaryList[i].PayType
|
|
|
+
|
|
|
|
|
|
svaList := make([]*fms.ContractPaymentServiceAmountItem, 0)
|
|
|
amountList := serviceAmountMap[summaryList[i].PaymentId]
|
|
@@ -1649,6 +1697,20 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
summaryMap[summaryList[i].SummaryId] = append(summaryMap[summaryList[i].SummaryId], v)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ currencyOB := new(fms.CurrencyUnit)
|
|
|
+ currencyCond := `enable = 1`
|
|
|
+ currencyPars := make([]interface{}, 0)
|
|
|
+ currencyList, e := currencyOB.List(currencyCond, currencyPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取失败", "获取货币列表失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ unitMap := make(map[string]string)
|
|
|
+ for i := range currencyList {
|
|
|
+ unitMap[currencyList[i].Code] = currencyList[i].UnitName
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
for i := range registerList {
|
|
|
v := new(fms.InvoicePaymentCensusItem)
|
|
@@ -1661,12 +1723,17 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
v.ServicesName = servicesNameMap[registerList[i].ContractRegisterId]
|
|
|
v.InvoicePaymentList = summaryMap[registerList[i].SummaryId]
|
|
|
v.ContractType = registerList[i].ContractType
|
|
|
+ v.ContractCode = registerList[i].ContractCode
|
|
|
+ v.ContractAmount = registerList[i].ContractAmount
|
|
|
+ v.UnitName = unitMap[registerList[i].CurrencyUnit]
|
|
|
+ v.ProductIds = registerList[i].ProductIds
|
|
|
respList = append(respList, v)
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
|
|
|
- var invoiceTotal, paymentTotal float64
|
|
|
+
|
|
|
+ var invoiceTotal, paymentTotal, contractAmount float64
|
|
|
wg.Add(1)
|
|
|
go func() {
|
|
|
defer wg.Done()
|
|
@@ -1694,6 +1761,7 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
|
|
|
invoiceCurrencyTotals := make([]*fms.InvoiceListCurrencyTotal, 0)
|
|
|
paymentCurrencyTotals := make([]*fms.InvoiceListCurrencyTotal, 0)
|
|
|
+ contractAmountCurrencyTotals := make([]*fms.InvoiceListCurrencyTotal, 0)
|
|
|
wg.Add(1)
|
|
|
go func() {
|
|
|
defer wg.Done()
|
|
@@ -1721,6 +1789,12 @@ 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 {
|
|
@@ -1741,6 +1815,8 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
}
|
|
|
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
|
|
@@ -1757,6 +1833,24 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
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
|
|
|
+ }
|
|
|
+ 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()
|
|
@@ -1773,17 +1867,17 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
resp.FailMsg("获取失败", totalGroupErr.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
results.DataList = respList
|
|
|
results.InvoiceTotal = invoiceTotal
|
|
|
results.PaymentTotal = paymentTotal
|
|
|
+ results.NotInvoiceTotal = contractAmount - invoiceTotal
|
|
|
results.InvoiceCurrencyTotal = invoiceCurrencyTotals
|
|
|
results.PaymentCurrencyTotal = paymentCurrencyTotals
|
|
|
+ results.NotInvoiceCurrencyTotal = contractAmountCurrencyTotals
|
|
|
}
|
|
|
-
|
|
|
|
|
|
if req.IsExport == 1 {
|
|
|
- ExportInvoicePaymentCensusList(c, results)
|
|
|
+ ExportNotPaymentCensusList(c, results)
|
|
|
return
|
|
|
}
|
|
|
page.SetTotal(total)
|
|
@@ -1791,4 +1885,425 @@ func (ct *InvoicePaymentController) NotPaymentList(c *gin.Context) {
|
|
|
baseData.SetPage(page)
|
|
|
baseData.SetList(results)
|
|
|
resp.OkData("获取成功", baseData, c)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func ExportNotInvoiceCensusList(c *gin.Context, results *fms.NotInvoicePaymentCensusResp) {
|
|
|
+ list := results.DataList
|
|
|
+ if len(list) == 0 {
|
|
|
+ resp.Fail("列表数据为空", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ xlsxFile := xlsx.NewFile()
|
|
|
+ style := xlsx.NewStyle()
|
|
|
+ alignment := xlsx.Alignment{
|
|
|
+ Horizontal: "center",
|
|
|
+ Vertical: "center",
|
|
|
+ WrapText: true,
|
|
|
+ }
|
|
|
+ style.Alignment = alignment
|
|
|
+ style.ApplyAlignment = true
|
|
|
+
|
|
|
+ sheet, err := xlsxFile.AddSheet("未开票统计")
|
|
|
+ if err != nil {
|
|
|
+ resp.FailData("新增Sheet失败", "Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ _ = sheet.SetColWidth(1, 1, 30)
|
|
|
+ _ = sheet.SetColWidth(3, 3, 30)
|
|
|
+
|
|
|
+
|
|
|
+ rowA := sheet.AddRow()
|
|
|
+ cellAA := rowA.AddCell()
|
|
|
+ cellAA.SetString(fmt.Sprintf("未开票合计金额(换算后):%.2f(元)", results.NotInvoiceTotal))
|
|
|
+ rowBData := "未开票金额:"
|
|
|
+ for _, v := range results.NotInvoiceCurrencyTotal {
|
|
|
+ rowBData += fmt.Sprintf("%s%.2f(%s) ", v.Name, v.Amount, v.UnitName)
|
|
|
+ }
|
|
|
+ rowB := sheet.AddRow()
|
|
|
+ rowB.AddCell().SetString(rowBData)
|
|
|
+ sheet.AddRow()
|
|
|
+
|
|
|
+
|
|
|
+ rowTitle := []string{"序号", "客户名称", "是否新客户", "合同有效期", "开票日", "开票金额", "到款日", "到款金额", "付款方式", "销售",
|
|
|
+ "销售组别", "销售类型"}
|
|
|
+ serviceTempCond := ``
|
|
|
+ serviceTempPars := make([]interface{}, 0)
|
|
|
+ serviceTempOB := new(fms.ContractServiceTemplate)
|
|
|
+ serviceTempList, e := serviceTempOB.List(serviceTempCond, serviceTempPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取套餐模板列表失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ serviceTempListMap := make(map[int]*fms.ContractServiceTemplate)
|
|
|
+ var serviceTempShow [] *fms.ContractServiceTemplate
|
|
|
+ for i := range serviceTempList {
|
|
|
+ serviceTempListMap[serviceTempList[i].ServiceTemplateId] = serviceTempList[i]
|
|
|
+ }
|
|
|
+ for i := range serviceTempList {
|
|
|
+ if serviceTempList[i].ProductId == 1 {
|
|
|
+ rowTitle = append(rowTitle, serviceTempList[i].Title)
|
|
|
+ serviceTempShow = append(serviceTempShow, serviceTempList[i])
|
|
|
+ }else if serviceTempList[i].ProductId == 2{
|
|
|
+ if serviceTempList[i].Title == "行业套餐" || serviceTempList[i].Title == "权益大套餐" || (serviceTempList[i].Title == "策略" && serviceTempListMap[serviceTempList[i].Pid].Pid==0){
|
|
|
+ }else if serviceTempList[i].Title == "医药" || serviceTempList[i].Title == "消费" || serviceTempList[i].Title == "科技" || serviceTempList[i].Title == "智造" {
|
|
|
+ }else {
|
|
|
+ serviceTempShow = append(serviceTempShow, serviceTempList[i])
|
|
|
+ }
|
|
|
+ if serviceTempList[i].Title == "行业套餐" || serviceTempList[i].Title == "45万" || serviceTempList[i].Title == "70万" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if serviceTempList[i].Pid > 0 && serviceTempListMap[serviceTempList[i].Pid].Pid > 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ rowTitle = append(rowTitle, serviceTempList[i].Title)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ hi := 0
|
|
|
+ insertHi := 0
|
|
|
+ titleRow := sheet.AddRow()
|
|
|
+ for i := range rowTitle {
|
|
|
+ v := titleRow.AddCell()
|
|
|
+ v.SetString(rowTitle[i])
|
|
|
+ v.SetStyle(style)
|
|
|
+ if rowTitle[i] != "权益大套餐" && rowTitle[i] != "医药" && rowTitle[i] != "消费" && rowTitle[i] != "科技" && rowTitle[i] != "智造" {
|
|
|
+ v.VMerge = 1
|
|
|
+ hi ++
|
|
|
+ }else{
|
|
|
+ if insertHi == 0 {
|
|
|
+ insertHi = hi
|
|
|
+ }
|
|
|
+ v.HMerge = 1
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ specialRow := sheet.AddRow()
|
|
|
+ for i:=0; i< hi; i++ {
|
|
|
+ if i == insertHi {
|
|
|
+ v1 := specialRow.AddCell()
|
|
|
+ v1.SetString("45万")
|
|
|
+ v1.SetStyle(style)
|
|
|
+ v1 = specialRow.AddCell()
|
|
|
+ v1.SetString("70万")
|
|
|
+ v1.SetStyle(style)
|
|
|
+ for j:=0; j<8;j++ {
|
|
|
+ if j%2 ==0 {
|
|
|
+ v1 = specialRow.AddCell()
|
|
|
+ v1.SetString("主观")
|
|
|
+ v1.SetStyle(style)
|
|
|
+ }else{
|
|
|
+ v1 = specialRow.AddCell()
|
|
|
+ v1.SetString("客观")
|
|
|
+ v1.SetStyle(style)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ v := specialRow.AddCell()
|
|
|
+ v.SetString("")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ newCompanyMap := map[int]string{0: "否", 1: "是"}
|
|
|
+ sellerTypeMap := map[int]string{1:"FICC销售", 2:"权益销售"}
|
|
|
+ for k, v := range list {
|
|
|
+ dataRow := sheet.AddRow()
|
|
|
+
|
|
|
+ l := len(v.InvoicePaymentList)
|
|
|
+ mergeRowNum := l - 1
|
|
|
+
|
|
|
+ sortNum := k + 1
|
|
|
+ colA := dataRow.AddCell()
|
|
|
+ colA.VMerge = mergeRowNum
|
|
|
+ colA.SetString(fmt.Sprint(sortNum))
|
|
|
+
|
|
|
+ colB := dataRow.AddCell()
|
|
|
+ colB.VMerge = mergeRowNum
|
|
|
+ colB.SetString(v.CompanyName)
|
|
|
+
|
|
|
+ colC := dataRow.AddCell()
|
|
|
+ colC.VMerge = mergeRowNum
|
|
|
+ colC.SetString(newCompanyMap[v.NewCompany])
|
|
|
+
|
|
|
+ colD := dataRow.AddCell()
|
|
|
+ colD.VMerge = mergeRowNum
|
|
|
+ colD.SetString(fmt.Sprint(v.StartDate, "至", v.EndDate))
|
|
|
+
|
|
|
+ for k2, v2 := range v.InvoicePaymentList {
|
|
|
+ rowData := []string{
|
|
|
+ v2.InvoiceDate,
|
|
|
+ fmt.Sprint(v2.InvoiceAmount),
|
|
|
+ v2.PaymentDate,
|
|
|
+ fmt.Sprint(v2.PaymentAmount),
|
|
|
+ fms.ContractPaymentPayTypeNameMap[v2.PayType],
|
|
|
+ v2.SellerName,
|
|
|
+ v2.SellerGroupName,
|
|
|
+ sellerTypeMap[v2.SellerType],
|
|
|
+ }
|
|
|
+
|
|
|
+ serviceTempShowAmount := make(map[int]string)
|
|
|
+ for i := range serviceTempShow {
|
|
|
+ for s2 := range v2.ServiceAmountList {
|
|
|
+ item := v2.ServiceAmountList[s2]
|
|
|
+ if item.ServiceTemplateId == serviceTempShow[i].ServiceTemplateId {
|
|
|
+ serviceTempShowAmount[serviceTempShow[i].ServiceTemplateId] = fmt.Sprint(item.Amount)
|
|
|
+ break
|
|
|
+ }else if serviceTempShow[i].Pid == item.ServiceTemplateId {
|
|
|
+ serviceTempShowAmount[serviceTempShow[i].ServiceTemplateId] = fmt.Sprint(item.Amount/2)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for i := range serviceTempShow {
|
|
|
+ sa := ""
|
|
|
+ if am, ok := serviceTempShowAmount[serviceTempShow[i].ServiceTemplateId]; ok {
|
|
|
+ sa = am
|
|
|
+ }
|
|
|
+ rowData = append(rowData, sa)
|
|
|
+ }
|
|
|
+
|
|
|
+ if k2 == 0 {
|
|
|
+ for i := range rowData {
|
|
|
+ dataRow.AddCell().SetString(rowData[i])
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRowExtra := sheet.AddRow()
|
|
|
+ for i := 0; i < 4; i++ {
|
|
|
+ dataRowExtra.AddCell()
|
|
|
+ }
|
|
|
+ for i := range rowData {
|
|
|
+ dataRowExtra.AddCell().SetString(rowData[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var buffer bytes.Buffer
|
|
|
+ _ = xlsxFile.Write(&buffer)
|
|
|
+ content := bytes.NewReader(buffer.Bytes())
|
|
|
+ randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
|
|
|
+ fileName := "商品到款统计_" + randStr + ".xlsx"
|
|
|
+
|
|
|
+ c.Writer.Header().Add("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, fileName))
|
|
|
+ c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
|
+ http.ServeContent(c.Writer, c.Request, fileName, time.Now(), content)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func ExportNotPaymentCensusList(c *gin.Context, results *fms.NotInvoicePaymentCensusResp) {
|
|
|
+ list := results.DataList
|
|
|
+ if len(list) == 0 {
|
|
|
+ resp.Fail("列表数据为空", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ xlsxFile := xlsx.NewFile()
|
|
|
+ style := xlsx.NewStyle()
|
|
|
+ alignment := xlsx.Alignment{
|
|
|
+ Horizontal: "center",
|
|
|
+ Vertical: "center",
|
|
|
+ WrapText: true,
|
|
|
+ }
|
|
|
+ style.Alignment = alignment
|
|
|
+ style.ApplyAlignment = true
|
|
|
+
|
|
|
+ sheet, err := xlsxFile.AddSheet("开票未到款统计")
|
|
|
+ if err != nil {
|
|
|
+ resp.FailData("新增Sheet失败", "Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ _ = sheet.SetColWidth(1, 1, 30)
|
|
|
+ _ = sheet.SetColWidth(3, 3, 30)
|
|
|
+
|
|
|
+
|
|
|
+ rowA := sheet.AddRow()
|
|
|
+ cellAA := rowA.AddCell()
|
|
|
+ cellAA.SetString(fmt.Sprintf("开票未到款合计金额(换算后):%.2f(元)", results.InvoiceTotal))
|
|
|
+ rowBData := "已开票金额:"
|
|
|
+ for _, v := range results.InvoiceCurrencyTotal {
|
|
|
+ rowBData += fmt.Sprintf("%s%.2f(%s) ", v.Name, v.Amount, v.UnitName)
|
|
|
+ }
|
|
|
+ rowB := sheet.AddRow()
|
|
|
+ rowB.AddCell().SetString(rowBData)
|
|
|
+ sheet.AddRow()
|
|
|
+
|
|
|
+
|
|
|
+ rowTitle := []string{"序号", "客户名称", "是否新客户", "合同有效期", "开票日", "开票金额", "到款日", "到款金额", "付款方式", "销售",
|
|
|
+ "销售组别", "销售类型"}
|
|
|
+ serviceTempCond := ``
|
|
|
+ serviceTempPars := make([]interface{}, 0)
|
|
|
+ serviceTempOB := new(fms.ContractServiceTemplate)
|
|
|
+ serviceTempList, e := serviceTempOB.List(serviceTempCond, serviceTempPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取套餐模板列表失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ serviceTempListMap := make(map[int]*fms.ContractServiceTemplate)
|
|
|
+ var serviceTempShow [] *fms.ContractServiceTemplate
|
|
|
+ for i := range serviceTempList {
|
|
|
+ serviceTempListMap[serviceTempList[i].ServiceTemplateId] = serviceTempList[i]
|
|
|
+ }
|
|
|
+ for i := range serviceTempList {
|
|
|
+ if serviceTempList[i].ProductId == 1 {
|
|
|
+ rowTitle = append(rowTitle, serviceTempList[i].Title)
|
|
|
+ serviceTempShow = append(serviceTempShow, serviceTempList[i])
|
|
|
+ }else if serviceTempList[i].ProductId == 2{
|
|
|
+ if serviceTempList[i].Title == "行业套餐" || serviceTempList[i].Title == "权益大套餐" || (serviceTempList[i].Title == "策略" && serviceTempListMap[serviceTempList[i].Pid].Pid==0){
|
|
|
+ }else if serviceTempList[i].Title == "医药" || serviceTempList[i].Title == "消费" || serviceTempList[i].Title == "科技" || serviceTempList[i].Title == "智造" {
|
|
|
+ }else {
|
|
|
+ serviceTempShow = append(serviceTempShow, serviceTempList[i])
|
|
|
+ }
|
|
|
+ if serviceTempList[i].Title == "行业套餐" || serviceTempList[i].Title == "45万" || serviceTempList[i].Title == "70万" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if serviceTempList[i].Pid > 0 && serviceTempListMap[serviceTempList[i].Pid].Pid > 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ rowTitle = append(rowTitle, serviceTempList[i].Title)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ hi := 0
|
|
|
+ insertHi := 0
|
|
|
+ titleRow := sheet.AddRow()
|
|
|
+ for i := range rowTitle {
|
|
|
+ v := titleRow.AddCell()
|
|
|
+ v.SetString(rowTitle[i])
|
|
|
+ v.SetStyle(style)
|
|
|
+ if rowTitle[i] != "权益大套餐" && rowTitle[i] != "医药" && rowTitle[i] != "消费" && rowTitle[i] != "科技" && rowTitle[i] != "智造" {
|
|
|
+ v.VMerge = 1
|
|
|
+ hi ++
|
|
|
+ }else{
|
|
|
+ if insertHi == 0 {
|
|
|
+ insertHi = hi
|
|
|
+ }
|
|
|
+ v.HMerge = 1
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ specialRow := sheet.AddRow()
|
|
|
+ for i:=0; i< hi; i++ {
|
|
|
+ if i == insertHi {
|
|
|
+ v1 := specialRow.AddCell()
|
|
|
+ v1.SetString("45万")
|
|
|
+ v1.SetStyle(style)
|
|
|
+ v1 = specialRow.AddCell()
|
|
|
+ v1.SetString("70万")
|
|
|
+ v1.SetStyle(style)
|
|
|
+ for j:=0; j<8;j++ {
|
|
|
+ if j%2 ==0 {
|
|
|
+ v1 = specialRow.AddCell()
|
|
|
+ v1.SetString("主观")
|
|
|
+ v1.SetStyle(style)
|
|
|
+ }else{
|
|
|
+ v1 = specialRow.AddCell()
|
|
|
+ v1.SetString("客观")
|
|
|
+ v1.SetStyle(style)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ v := specialRow.AddCell()
|
|
|
+ v.SetString("")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ newCompanyMap := map[int]string{0: "否", 1: "是"}
|
|
|
+ sellerTypeMap := map[int]string{1:"FICC销售", 2:"权益销售"}
|
|
|
+ for k, v := range list {
|
|
|
+ dataRow := sheet.AddRow()
|
|
|
+
|
|
|
+ l := len(v.InvoicePaymentList)
|
|
|
+ mergeRowNum := l - 1
|
|
|
+
|
|
|
+ sortNum := k + 1
|
|
|
+ colA := dataRow.AddCell()
|
|
|
+ colA.VMerge = mergeRowNum
|
|
|
+ colA.SetString(fmt.Sprint(sortNum))
|
|
|
+
|
|
|
+ colB := dataRow.AddCell()
|
|
|
+ colB.VMerge = mergeRowNum
|
|
|
+ colB.SetString(v.CompanyName)
|
|
|
+
|
|
|
+ colC := dataRow.AddCell()
|
|
|
+ colC.VMerge = mergeRowNum
|
|
|
+ colC.SetString(newCompanyMap[v.NewCompany])
|
|
|
+
|
|
|
+ colD := dataRow.AddCell()
|
|
|
+ colD.VMerge = mergeRowNum
|
|
|
+ colD.SetString(fmt.Sprint(v.StartDate, "至", v.EndDate))
|
|
|
+
|
|
|
+ for k2, v2 := range v.InvoicePaymentList {
|
|
|
+ rowData := []string{
|
|
|
+ v2.InvoiceDate,
|
|
|
+ fmt.Sprint(v2.InvoiceAmount),
|
|
|
+ v2.PaymentDate,
|
|
|
+ fmt.Sprint(v2.PaymentAmount),
|
|
|
+ fms.ContractPaymentPayTypeNameMap[v2.PayType],
|
|
|
+ v2.SellerName,
|
|
|
+ v2.SellerGroupName,
|
|
|
+ sellerTypeMap[v2.SellerType],
|
|
|
+ }
|
|
|
+
|
|
|
+ serviceTempShowAmount := make(map[int]string)
|
|
|
+ for i := range serviceTempShow {
|
|
|
+ for s2 := range v2.ServiceAmountList {
|
|
|
+ item := v2.ServiceAmountList[s2]
|
|
|
+ if item.ServiceTemplateId == serviceTempShow[i].ServiceTemplateId {
|
|
|
+ serviceTempShowAmount[serviceTempShow[i].ServiceTemplateId] = fmt.Sprint(item.Amount)
|
|
|
+ break
|
|
|
+ }else if serviceTempShow[i].Pid == item.ServiceTemplateId {
|
|
|
+ serviceTempShowAmount[serviceTempShow[i].ServiceTemplateId] = fmt.Sprint(item.Amount/2)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for i := range serviceTempShow {
|
|
|
+ sa := ""
|
|
|
+ if am, ok := serviceTempShowAmount[serviceTempShow[i].ServiceTemplateId]; ok {
|
|
|
+ sa = am
|
|
|
+ }
|
|
|
+ rowData = append(rowData, sa)
|
|
|
+ }
|
|
|
+
|
|
|
+ if k2 == 0 {
|
|
|
+ for i := range rowData {
|
|
|
+ dataRow.AddCell().SetString(rowData[i])
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRowExtra := sheet.AddRow()
|
|
|
+ for i := 0; i < 4; i++ {
|
|
|
+ dataRowExtra.AddCell()
|
|
|
+ }
|
|
|
+ for i := range rowData {
|
|
|
+ dataRowExtra.AddCell().SetString(rowData[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var buffer bytes.Buffer
|
|
|
+ _ = xlsxFile.Write(&buffer)
|
|
|
+ content := bytes.NewReader(buffer.Bytes())
|
|
|
+ randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
|
|
|
+ fileName := "商品到款统计_" + randStr + ".xlsx"
|
|
|
+
|
|
|
+ c.Writer.Header().Add("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, fileName))
|
|
|
+ c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
|
+ http.ServeContent(c.Writer, c.Request, fileName, time.Now(), content)
|
|
|
}
|