animeic 1 year ago
parent
commit
a453f9418c
2 changed files with 22 additions and 9 deletions
  1. 2 2
      boxcost/api/bill.go
  2. 20 7
      boxcost/api/report-excel.go

+ 2 - 2
boxcost/api/bill.go

@@ -45,6 +45,7 @@ func Bill(r *GinRouter) {
 type BillRecordReq struct {
 	BillType string             `json:"billType"`
 	Id       primitive.ObjectID `json:"id"`
+	Record   *bool              `json:"record"`
 }
 
 // 对账单据
@@ -67,8 +68,7 @@ func BillRecord(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	} else {
 		return nil, errors.New("订单类型错误!")
 	}
-	record := true
-	update := bson.M{"isRecord": &record}
+	update := bson.M{"isRecord": req.Record}
 	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), collection, req.Id.Hex(), &update)
 
 }

+ 20 - 7
boxcost/api/report-excel.go

@@ -110,6 +110,7 @@ func (b *ReportExcel) drawTableTitle() error {
 	drawCol("G", "单价")
 	drawCol("H", "金额")
 	drawCol("I", "产品名称")
+	drawCol("J", "对账状态")
 	// b.Excel.SetRowHeight(b.SheetName, b.Row, 35)
 
 	return nil
@@ -118,7 +119,7 @@ func (b *ReportExcel) drawTableTitle() error {
 func (b *ReportExcel) drawTableContent() error {
 	b.Row += 2
 	var DrawRow = func(rowIndex int, values ...string) {
-		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I"}
+		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}
 
 		for i, c := range charas {
 			v := ""
@@ -149,7 +150,11 @@ func (b *ReportExcel) drawTableContent() error {
 				err = json.Unmarshal(data, &purchase)
 				if err != nil {
 					log.Error(err)
-					continue
+					panic(err)
+				}
+				record := "否"
+				if *purchase.IsRecord {
+					record = "是"
 				}
 				for _, paper := range purchase.Paper {
 					index++
@@ -161,7 +166,7 @@ func (b *ReportExcel) drawTableContent() error {
 					// 实际金额
 					realPrice := fmt.Sprintf("%.3f", paper.OrderPrice*float64(paper.ConfirmCount))
 					b.FormatToEmpty(&realPrice)
-					DrawRow(b.Row, fmt.Sprintf("%d", index), completeTime, paper.Name, paper.Norm, fmt.Sprintf("%s*%s", paper.Height, paper.Width), fmt.Sprintf("%d", paper.ConfirmCount), fmt.Sprintf("%.3f", paper.OrderPrice), realPrice, purchase.ProductName)
+					DrawRow(b.Row, fmt.Sprintf("%d", index), completeTime, paper.Name, paper.Norm, fmt.Sprintf("%s*%s", paper.Height, paper.Width), fmt.Sprintf("%d", paper.ConfirmCount), fmt.Sprintf("%.3f", paper.OrderPrice), realPrice, purchase.ProductName, record)
 					totalPrice += paper.OrderPrice * float64(paper.ConfirmCount)
 					totalCount += paper.ConfirmCount
 					b.Row++
@@ -172,7 +177,11 @@ func (b *ReportExcel) drawTableContent() error {
 				err = json.Unmarshal(data, &produce)
 				if err != nil {
 					log.Error(err)
-					continue
+					panic(err)
+				}
+				record := "否"
+				if *produce.IsRecord {
+					record = "是"
 				}
 				for _, pproduce := range produce.Produces {
 					index++
@@ -184,7 +193,7 @@ func (b *ReportExcel) drawTableContent() error {
 					// 实际金额
 					realPrice := fmt.Sprintf("%.3f", pproduce.OrderPrice*float64(pproduce.ConfirmCount))
 					b.FormatToEmpty(&realPrice)
-					DrawRow(b.Row, fmt.Sprintf("%d", index), completeTime, pproduce.Name, pproduce.Norm, pproduce.PrintSize, fmt.Sprintf("%d", pproduce.ConfirmCount), fmt.Sprintf("%.3f", pproduce.OrderPrice), realPrice, produce.ProductName)
+					DrawRow(b.Row, fmt.Sprintf("%d", index), completeTime, pproduce.Name, pproduce.Norm, pproduce.PrintSize, fmt.Sprintf("%d", pproduce.ConfirmCount), fmt.Sprintf("%.3f", pproduce.OrderPrice), realPrice, produce.ProductName, record)
 					totalPrice += pproduce.OrderPrice * float64(pproduce.ConfirmCount)
 					totalCount += pproduce.ConfirmCount
 					b.Row++
@@ -195,7 +204,11 @@ func (b *ReportExcel) drawTableContent() error {
 				err = json.Unmarshal(data, &product)
 				if err != nil {
 					log.Error(err)
-					continue
+					panic(err)
+				}
+				record := "否"
+				if *product.IsRecord {
+					record = "是"
 				}
 				for _, pproduct := range product.Products {
 					index++
@@ -207,7 +220,7 @@ func (b *ReportExcel) drawTableContent() error {
 					// 实际金额
 					realPrice := fmt.Sprintf("%.3f", pproduct.OrderPrice*float64(pproduct.ConfirmCount))
 					b.FormatToEmpty(&realPrice)
-					DrawRow(b.Row, fmt.Sprintf("%d", index), completeTime, pproduct.Name, pproduct.Norm, "-", fmt.Sprintf("%d", pproduct.ConfirmCount), fmt.Sprintf("%.3f", pproduct.OrderPrice), realPrice, product.ProductName)
+					DrawRow(b.Row, fmt.Sprintf("%d", index), completeTime, pproduct.Name, pproduct.Norm, "-", fmt.Sprintf("%d", pproduct.ConfirmCount), fmt.Sprintf("%.3f", pproduct.OrderPrice), realPrice, product.ProductName, record)
 					totalPrice += pproduct.OrderPrice * float64(pproduct.ConfirmCount)
 					totalCount += pproduct.ConfirmCount
 					b.Row++