导出文件 上传 oss
This commit is contained in:
parent
69a771a0cb
commit
73f269f847
4
go.mod
4
go.mod
@ -17,9 +17,9 @@ go 1.18
|
|||||||
//github.com/fonchain_enterprise/utils/ipAddrQuery => ../utils/ipAddrQuery
|
//github.com/fonchain_enterprise/utils/ipAddrQuery => ../utils/ipAddrQuery
|
||||||
//github.com/fonchain_enterprise/utils/jwt => ../utils/jwt
|
//github.com/fonchain_enterprise/utils/jwt => ../utils/jwt
|
||||||
//github.com/fonchain_enterprise/utils/logger => ../utils/logger
|
//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 (
|
require (
|
||||||
dubbo.apache.org/dubbo-go/v3 v3.0.2
|
dubbo.apache.org/dubbo-go/v3 v3.0.2
|
||||||
|
@ -25,7 +25,7 @@ func BundleOrderRouter(r *gin.RouterGroup) {
|
|||||||
bundleOrderWebRoute := bundleOrderRoute.Group("web")
|
bundleOrderWebRoute := bundleOrderRoute.Group("web")
|
||||||
{
|
{
|
||||||
bundleOrderWebRoute.POST("financial-confirm", bundle.UpdateFinancialConfirmationStatus)
|
bundleOrderWebRoute.POST("financial-confirm", bundle.UpdateFinancialConfirmationStatus)
|
||||||
bundleOrderWebRoute.POST("order-export", bundle.ExportOrderInfo)
|
bundleOrderWebRoute.POST("order-export", bundle.ExportOrderInfoOss)
|
||||||
}
|
}
|
||||||
|
|
||||||
bundleOrderAppRoute := bundleOrderRoute.Group("app")
|
bundleOrderAppRoute := bundleOrderRoute.Group("app")
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"fonchain-fiee/pkg/service/bundle/common"
|
"fonchain-fiee/pkg/service/bundle/common"
|
||||||
"fonchain-fiee/pkg/service/bundle/logic"
|
"fonchain-fiee/pkg/service/bundle/logic"
|
||||||
bundleModel "fonchain-fiee/pkg/service/bundle/model"
|
bundleModel "fonchain-fiee/pkg/service/bundle/model"
|
||||||
|
"fonchain-fiee/pkg/service/upload"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"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)
|
//var exportUrl = fmt.Sprintf("%s%s/%s", httpType, c.Request.Host, dirPath + path)
|
||||||
fmt.Println("exportUrl : ", exportUrl)
|
fmt.Println("exportUrl : ", exportUrl)
|
||||||
service.Success(c, &bundleModel.ExportResponse{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})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user