摸大红支持购物车多选一起结账

下单支持多商品行快照与一次支付;支付后整单复制文案,前台提供购物车加购与结账。
This commit is contained in:
yml2213
2026-07-16 20:58:39 +08:00
parent e241607535
commit 183351a297
17 changed files with 1159 additions and 117 deletions
+39 -4
View File
@@ -2,6 +2,7 @@ package mohong
import (
"encoding/json"
"fmt"
"strings"
"hfb_sys/backend/internal/model"
@@ -42,7 +43,40 @@ func toProductDTOWithCategory(row model.MohongProduct, categoryName string, incl
return dto
}
func toOrderDTO(row model.MohongOrder, snap productSnapshot, buyerNickname, buyerPhone string, includeAdmin bool) OrderDTO {
func toOrderDTO(row model.MohongOrder, snap productSnapshot, items []orderItemSnapshot, buyerNickname, buyerPhone string, includeAdmin bool) OrderDTO {
if len(items) == 0 {
items = decodeOrderItems(row)
}
title := snap.Title
cover := snap.CoverURL
unit := snap.Unit
if title == "" && len(items) > 0 {
title = items[0].Title
}
if cover == "" && len(items) > 0 {
cover = items[0].CoverURL
}
if unit == "" && len(items) > 0 {
unit = items[0].Unit
}
if len(items) > 1 && title != "" {
title = fmt.Sprintf("%s 等%d种", title, len(items))
}
itemDTOs := make([]OrderItemDTO, 0, len(items))
for _, item := range items {
lineAmount := item.PriceCent * int64(item.Quantity)
itemDTOs = append(itemDTOs, OrderItemDTO{
ProductID: item.ID,
Title: item.Title,
CoverURL: item.CoverURL,
Unit: item.Unit,
Quantity: item.Quantity,
UnitPriceCent: item.PriceCent,
UnitPrice: money.Format(item.PriceCent),
AmountCent: lineAmount,
Amount: money.Format(lineAmount),
})
}
dto := OrderDTO{
ID: row.ID,
OrderNo: row.OrderNo,
@@ -54,9 +88,10 @@ func toOrderDTO(row model.MohongOrder, snap productSnapshot, buyerNickname, buye
AmountCent: row.AmountCent,
Amount: money.Format(row.AmountCent),
Status: row.Status,
ProductTitle: snap.Title,
ProductCoverURL: snap.CoverURL,
ProductUnit: snap.Unit,
ProductTitle: title,
ProductCoverURL: cover,
ProductUnit: unit,
Items: itemDTOs,
QrcodeURLSnapshot: row.QrcodeURLSnapshot,
CopyText: row.CopyText,
CancelReason: row.CancelReason,