fix:购物车下单

This commit is contained in:
momo
2023-09-18 15:39:12 +08:00
parent 87347515d1
commit 8265140148
6 changed files with 194 additions and 99 deletions

View File

@@ -59,22 +59,20 @@ type PayInfo struct {
// 金额明细
type AmountInfo struct {
ExchangeRate string `json:"exchange_rate"` // 换算汇率
Change constants.AmountUnit `json:"change,omitempty"` // 变动金额
ChangeRemark string `json:"change_remark,omitempty"` // 变动备注状态编码
Currency string `json:"currency"` // 货币
Current constants.AmountUnit `json:"current"` // 当前金额
Initiate constants.AmountUnit `json:"initiate"` // 初始金额
Change AmountCurrency `json:"change,omitempty"` // 变动金额
ChangeRemark string `json:"change_remark,omitempty"` // 变动备注
Current AmountCurrency `json:"current"` // 当前金额
Initiate AmountCurrency `json:"initiate"` // 初始金额
Metadata map[string]interface{} `json:"metadata"` // 额外明细
}
// 金额货币
type AmountCurrency struct {
CurrentAmount constants.AmountUnit `json:"current_amount"` // 当前金额
CurrentCurrency string `json:"current_currency"` // 当前货币
ExchangeRate string `json:"exchange_rate"` // 换算汇率
OriginalAmount constants.AmountUnit `json:"original_amount"` // 原始金额
OriginalCurrency string `json:"original_currency"` // 原始货币
ExchangeRate constants.ExchangeRateUnit `json:"exchange_rate"` // 换算汇率
CurrentCurrency string `json:"current_currency"` // 当前货币
CurrentAmount constants.AmountUnit `json:"current_amount"` // 当前金额
OriginalCurrency string `json:"original_currency"` // 原始货币
OriginalAmount constants.AmountUnit `json:"original_amount"` // 原始金额
}
// 支付状态
@@ -108,16 +106,16 @@ type OrderStatus struct {
// 订单商品
type OrderProduct struct {
Amount AmountCurrency `json:"amount"` // 商品总价
Amount AmountInfo `json:"amount"` // 商品总价
ExpectedDeliveryTime string `json:"expected_delivery_time"` // 预计到货时间
Number int64 `json:"number"` // 商品数量
ProductID string `json:"product_id"` // 商品ID
ProductID int64 `json:"product_id"` // 商品ID
ProductLogo string `json:"product_logo"` // 商品logo
ProductLogoResource *Resource `json:"product_logo_resource"` // 商品封面--资源详情
ProductName string `json:"product_name"` // 商品名称
ProductPrice AmountCurrency `json:"product_price"` // 商品单价
ProductPrice AmountInfo `json:"product_price"` // 商品单价
ProductSnapshot map[string]interface{} `json:"product_snapshot"` // 商品快照
ShoppingCartSnapshot *ShoppingCartSnapshot `json:"shopping_cart_snapshot"` // 购物车快照
ShoppingCartSnapshot *FsShoppingCart `json:"shopping_cart_snapshot"` // 购物车快照
Unit string `json:"unit"` // 商品单位
}
@@ -128,62 +126,3 @@ type Resource struct {
ResourceType string `json:"resource_type"` // 资源类型
ResourceURL string `json:"resource_url"` // 资源地址
}
// 购物车
type ShoppingCartSnapshot struct {
Ctime string `json:"ctime"` // 创建时间
FittingID int64 `json:"fitting_id"` // 配件id
ID int64 `json:"id"` // 购物车ID
IsHighlyCustomized int64 `json:"is_highly_customized"` // 是否高度定制 0非 1是针对客人高度定制只能后台增加如购物车
ModelID int64 `json:"model_id"` // 模型id
ProductID int64 `json:"product_id"` // 产品id
PurchaseQuantity int64 `json:"purchase_quantity"` // 购买数量
SizeID int64 `json:"size_id"` // 尺寸id
Snapshot Snapshot `json:"snapshot"` // 购物车快照数据
TemplateID int64 `json:"template_id"` // 模板id
UserID int64 `json:"user_id"` // 用户id
Utime string `json:"utime"` // 更新时间
}
// 购物车快照
type Snapshot struct {
CombineImage string `json:"combine_image"` // 刀版图地址
FittingInfo FittingInfo `json:"fitting_info"`
Logo string `json:"logo"` // logo地址
ModelInfo ModelInfo `json:"model_info"`
RenderImage string `json:"render_image"` // 模板数据
SizeInfo SizeInfo `json:"size_info"`
TemplateInfo TemplateInfo `json:"template_info"`
UserDiyInformation UserDiyInformation `json:"user_diy_information"`
}
// 配件信息
type FittingInfo struct {
FittingJSON string `json:"fitting_json"`
}
// 模型数据
type ModelInfo struct {
ModelJSON string `json:"model_json"`
}
// 尺寸信息
type SizeInfo struct {
CM string `json:"cm"`
Inch string `json:"inch"`
}
// 模板数据
type TemplateInfo struct {
TemplateJSON string `json:"template_json"`
TemplateTag string `json:"template_tag"`
}
// DIY数据
type UserDiyInformation struct {
Address string `json:"address"` // 地址
Phone string `json:"phone"` // 电话
Qrcode string `json:"qrcode"` // 二维码
Slogan string `json:"slogan"` // slogan
Website string `json:"website"` // 网站
}

View File

@@ -2,6 +2,15 @@ package gmodel
import "context"
type RelaFsProduct struct {
FsProduct
CoverResource *FsResource `json:"cover_resource" gorm:"foreignkey:cover;references:resource_id"`
}
func (m *FsProductModel) TableName() string {
return m.name
}
func (p *FsProductModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsProduct, err error) {
db := p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` = ? ", id)
if len(fields) != 0 {

View File

@@ -6,7 +6,7 @@ import (
type RelaFsShoppingCart struct {
FsShoppingCart
ShoppingCartProduct *FsProduct `json:"shopping_cart_product" gorm:"foreignkey:product_id;references:id"`
ShoppingCartProduct *RelaFsProduct `json:"shopping_cart_product" gorm:"foreignkey:product_id;references:id"`
ShoppingCartProductPriceList []*FsProductPrice `json:"shopping_cart_product_price_list" gorm:"foreignkey:product_id;references:product_id"`
ShoppingCartProductModel3dList []*FsProductModel3d `json:"shopping_cart_product_model3d_list" gorm:"foreignkey:product_id;references:product_id"`
}