From 73f269f847c86b934b008494a8fc7be30ffc0c30 Mon Sep 17 00:00:00 2001 From: jhc Date: Tue, 27 May 2025 10:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=20oss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 +- pkg/router/bundleOrder.go | 2 +- pkg/service/bundle/bundleOrder.go | 88 ++++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 66edb91..03356ab 100644 --- a/go.mod +++ b/go.mod @@ -17,9 +17,9 @@ go 1.18 //github.com/fonchain_enterprise/utils/ipAddrQuery => ../utils/ipAddrQuery //github.com/fonchain_enterprise/utils/jwt => ../utils/jwt //github.com/fonchain_enterprise/utils/logger => ../utils/logger -//replace github.com/fonchain_enterprise/utils/objstorage => ../../tyfon-新/utils/objstorage +replace github.com/fonchain_enterprise/utils/objstorage => ../../tyfon-新/utils/objstorage -replace github.com/fonchain_enterprise/utils/objstorage => ../utils/objstorage +//replace github.com/fonchain_enterprise/utils/objstorage => ../utils/objstorage // require ( dubbo.apache.org/dubbo-go/v3 v3.0.2 diff --git a/pkg/router/bundleOrder.go b/pkg/router/bundleOrder.go index b26fb5f..7f542f3 100644 --- a/pkg/router/bundleOrder.go +++ b/pkg/router/bundleOrder.go @@ -25,7 +25,7 @@ func BundleOrderRouter(r *gin.RouterGroup) { bundleOrderWebRoute := bundleOrderRoute.Group("web") { bundleOrderWebRoute.POST("financial-confirm", bundle.UpdateFinancialConfirmationStatus) - bundleOrderWebRoute.POST("order-export", bundle.ExportOrderInfo) + bundleOrderWebRoute.POST("order-export", bundle.ExportOrderInfoOss) } bundleOrderAppRoute := bundleOrderRoute.Group("app") diff --git a/pkg/service/bundle/bundleOrder.go b/pkg/service/bundle/bundleOrder.go index 6ddde62..b8f382a 100644 --- a/pkg/service/bundle/bundleOrder.go +++ b/pkg/service/bundle/bundleOrder.go @@ -12,6 +12,7 @@ import ( "fonchain-fiee/pkg/service/bundle/common" "fonchain-fiee/pkg/service/bundle/logic" bundleModel "fonchain-fiee/pkg/service/bundle/model" + "fonchain-fiee/pkg/service/upload" "math/big" "strconv" "strings" @@ -426,8 +427,93 @@ func ExportOrderInfo(c *gin.Context) { } } - var exportUrl = strings.Replace(strings.Replace(filePath, ".", fmt.Sprintf("%s://%s", httpType, c.Request.Host), 1), "runtime", "api/static", 1) + var exportUrl = strings.Replace(strings.Replace(filePath, ".", fmt.Sprintf("%s://%s", httpType, c.Request.Host), 1), "runtime", "api/fiee/static", 1) //var exportUrl = fmt.Sprintf("%s%s/%s", httpType, c.Request.Host, dirPath + path) fmt.Println("exportUrl : ", exportUrl) service.Success(c, &bundleModel.ExportResponse{ExportUrl: exportUrl}) } + +func ExportOrderInfoOss(c *gin.Context) { + var req bundle.OrderRecordsRequest + + if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil { + service.Error(c, err) + return + } + + res, err := service.BundleProvider.OrderRecordsList(context.Background(), &req) + if err != nil { + service.Error(c, err) + return + } + + rows := make([][]interface{}, 0) + + for _, orderRecord := range res.OrderRecords { + if orderRecord.CustomerID != "" { + var userID uint64 + userID, err = strconv.ParseUint(orderRecord.CustomerID, 10, 64) + if err != nil { + err = nil + continue + } + + userInfo, _ := service.AccountProvider.Info(context.Background(), &account.InfoRequest{ + Domain: "app", + ID: userID, + }) + if userInfo != nil { + orderRecord.Sex = userInfo.Sex + orderRecord.Nationality = userInfo.Nationality + orderRecord.TelNum = userInfo.TelNum + } + } + + status := "" + if orderRecord.Status == bundleModel.OrderSigned { + status = "未支付" + } else if orderRecord.Status == bundleModel.OrderPaid { + status = "已支付" + } + financialConfirmation := "" + if orderRecord.FinancialConfirmation == bundleModel.UnConfirm { + financialConfirmation = "未确认" + } else if orderRecord.FinancialConfirmation == bundleModel.Confirmed { + financialConfirmation = "已确认" + } + + rows = append(rows, []interface{}{ + orderRecord.OrderNo, + orderRecord.CustomerNum, + orderRecord.CustomerName, + orderRecord.Sex, + orderRecord.TelNum, + orderRecord.Nationality, + orderRecord.BundleName, + orderRecord.SignedTime, + orderRecord.Amount, + orderRecord.Num, + orderRecord.ValueAddBundleAmount, + orderRecord.TotalAmount, + status, + orderRecord.PayTime, + financialConfirmation, + }) + } + + dirPath := "./runtime" + + filePath, err := logic.WriteToExcel(dirPath, rows) + if err != nil { + service.Error(c, err) + return + } + + exportUrl, err := upload.PutBos(filePath, "excel", true) + if err != nil { + service.Error(c, err) + return + } + + service.Success(c, &bundleModel.ExportResponse{ExportUrl: exportUrl}) +}