Compare commits
2 Commits
60caecc1b9
...
c1978c9ee7
Author | SHA1 | Date | |
---|---|---|---|
c1978c9ee7 | |||
73f269f847 |
@ -32,7 +32,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")
|
||||
|
@ -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})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user