fix:购物车下单

This commit is contained in:
momo
2023-09-20 15:07:12 +08:00
parent 8768588a8f
commit ed5dce9ff0
18 changed files with 572 additions and 51 deletions

View File

@@ -32,6 +32,7 @@ type (
}
Order interface {
// 下单
Create(ctx context.Context, in *CreateReq) (res *CreateRes, err error)
// 预支付
// 列表
// 详情
@@ -45,7 +46,7 @@ type (
/* 下单 */
CreateReq struct {
ExpectedDeliveryTime string `json:"expected_delivery_time"` // 预计到货时间
ExpectedDeliveryTime time.Time `json:"expected_delivery_time"` // 预计到货时间
ExchangeRate int64 `json:"exchange_rate"` // 换算汇率(厘)
CurrentCurrency string `json:"current_currency"` // 当前货币
OriginalCurrency string `json:"original_currency"` // 原始货币
@@ -250,24 +251,14 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
orderProductTotal = orderProductTotal + productTotalPrice
// 订单商品
var productLogoResource *gmodel.Resource
if shoppingCart.ShoppingCartProduct.CoverResource != nil {
var coverResourceMetadata map[string]interface{}
if shoppingCart.ShoppingCartProduct.CoverResource.Metadata != nil {
json.Unmarshal(*shoppingCart.ShoppingCartProduct.CoverResource.Metadata, &coverResourceMetadata)
}
productLogoResource = &gmodel.Resource{
Metadata: coverResourceMetadata,
ResourceID: shoppingCart.ShoppingCartProduct.CoverResource.ResourceId,
ResourceType: *shoppingCart.ShoppingCartProduct.CoverResource.ResourceType,
ResourceURL: *shoppingCart.ShoppingCartProduct.CoverResource.ResourceUrl,
}
}
var productSnapshot = make(map[string]interface{}, 1)
productSnapshot["product_snapshot"] = shoppingCart.ShoppingCartProduct
var productCoverMetadata map[string]interface{}
if shoppingCart.ShoppingCartProduct.CoverResource != nil && shoppingCart.ShoppingCartProduct.CoverResource.Metadata != nil {
json.Unmarshal(*shoppingCart.ShoppingCartProduct.CoverResource.Metadata, &productCoverMetadata)
}
orderProductList = append(orderProductList, gmodel.OrderProduct{
Amount: order.GetAmountInfo(order.GetAmountInfoReq{
TotalPrice: order.GetAmountInfo(order.GetAmountInfoReq{
ExchangeRate: in.ExchangeRate,
Initiate: productTotalPrice,
Current: productTotalPrice,
@@ -275,12 +266,12 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
OriginalCurrency: in.OriginalCurrency,
}),
ExpectedDeliveryTime: in.ExpectedDeliveryTime,
Number: *shoppingCart.PurchaseQuantity,
PurchaseQuantity: *shoppingCart.PurchaseQuantity,
ProductID: *shoppingCart.ProductId,
ProductLogo: *shoppingCart.ShoppingCartProduct.Cover,
ProductLogoResource: productLogoResource,
ProductCover: *shoppingCart.ShoppingCartProduct.Cover,
ProductCoverMetadata: productCoverMetadata,
ProductName: *shoppingCart.ShoppingCartProduct.Title,
ProductPrice: order.GetAmountInfo(order.GetAmountInfoReq{
ItemPrice: order.GetAmountInfo(order.GetAmountInfoReq{
ExchangeRate: in.ExchangeRate,
Initiate: productPrice,
Current: productPrice,
@@ -289,6 +280,23 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
}),
ProductSnapshot: productSnapshot,
ShoppingCartSnapshot: &shoppingCart.FsShoppingCart,
ProductSn: *shoppingCart.ShoppingCartProduct.Sn,
DiyInformation: &gmodel.DiyInformation{
Address: shoppingCartSnapshot.UserDiyInformation.Address,
Phone: shoppingCartSnapshot.UserDiyInformation.Phone,
Qrcode: shoppingCartSnapshot.UserDiyInformation.Qrcode,
Slogan: shoppingCartSnapshot.UserDiyInformation.Slogan,
Website: shoppingCartSnapshot.UserDiyInformation.Website,
},
FittingInfo: &gmodel.FittingInfo{
FittingID: *shoppingCart.FittingId,
FittingName: shoppingCartSnapshot.FittingInfo.FittingName,
},
SizeInfo: &gmodel.SizeInfo{
SizeID: *shoppingCart.SizeId,
Capacity: shoppingCartSnapshot.SizeInfo.Capacity,
},
StepNum: stepNum,
})
}
@@ -357,7 +365,7 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
StatusTitle: constants.OrderStatusMessage[constants.ORDERSTATUSUNPAIDDEPOSIT],
}
// 订单状态--链路
var statusLink = order.GenerateOrderStatusLink(in.DeliveryMethod, nowTime)
var statusLink = order.GenerateOrderStatusLink(in.DeliveryMethod, nowTime, in.ExpectedDeliveryTime)
var orderInfo = gmodel.OrderInfo{
Ctime: nowTime,
DeliveryMethod: in.DeliveryMethod,