Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-09-26 15:28:27 +08:00
commit fae365d59e
3 changed files with 127 additions and 62 deletions

View File

@ -95,23 +95,22 @@ type OrderStatus struct {
// 订单商品 // 订单商品
type OrderProduct struct { type OrderProduct struct {
TotalPrice AmountInfo `json:"amount"` // 商品总价 TotalPrice AmountInfo `json:"amount"` // 商品总价
ExpectedDeliveryTime *time.Time `json:"expected_delivery_time"` // 预计到货时间 ExpectedDeliveryTime *time.Time `json:"expected_delivery_time"` // 预计到货时间
PurchaseQuantity PurchaseQuantity `json:"purchase_quantity"` // 购买数量 PurchaseQuantity PurchaseQuantity `json:"purchase_quantity"` // 购买数量
ProductID int64 `json:"product_id"` // 商品ID ProductID int64 `json:"product_id"` // 商品ID
ProductName string `json:"product_name"` // 商品名称 ProductName string `json:"product_name"` // 商品名称
ItemPrice AmountInfo `json:"product_price"` // 商品单价 ItemPrice AmountInfo `json:"product_price"` // 商品单价
ProductSnapshot interface{} `json:"product_snapshot"` // 商品快照 ProductSnapshot interface{} `json:"product_snapshot"` // 商品快照
ShoppingCartSnapshot *FsShoppingCart `json:"shopping_cart_snapshot"` // 购物车快照 ShoppingCartSnapshot *FsShoppingCartData `json:"shopping_cart_snapshot"` // 购物车快照
ShoppingCartSnapshotInfo map[string]interface{} `json:"shopping_cart_snapshot_info"` // 商品封面 ProductCover string `json:"product_cover"` // 商品封面
ProductCover string `json:"product_cover"` // 商品封面 ProductCoverMetadata map[string]interface{} `json:"product_cover_metadata"` // 商品封面
ProductCoverMetadata map[string]interface{} `json:"product_cover_metadata"` // 商品封面 ProductSn string `json:"product_sn"` // 商品编码
ProductSn string `json:"product_sn"` // 商品编码 DiyInformation *UserDiyInformation `json:"diy_information"`
DiyInformation *UserDiyInformation `json:"diy_information"` SizeInfo *OrderProductSizeInfo `json:"size_info"`
SizeInfo *OrderProductSizeInfo `json:"size_info"` FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
FittingInfo *OrderProductFittingInfo `json:"fitting_info"` StepNum []int `json:"step_num"` // 阶梯数量
StepNum []int `json:"step_num"` // 阶梯数量 IsHighlyCustomized int64 `json:"is_highly_customized"`
IsHighlyCustomized int64 `json:"is_highly_customized"`
} }
type PurchaseQuantity struct { type PurchaseQuantity struct {
Current interface{} `json:"current"` Current interface{} `json:"current"`

View File

@ -2,6 +2,7 @@ package gmodel
import ( import (
"context" "context"
"time"
) )
func (m *FsShoppingCartModel) TableName() string { func (m *FsShoppingCartModel) TableName() string {
@ -16,6 +17,23 @@ type RelaFsShoppingCart struct {
ShoppingCartProductModel3dList []*FsProductModel3d `json:"shopping_cart_product_model3d_list" gorm:"foreignkey:product_id;references:product_id"` ShoppingCartProductModel3dList []*FsProductModel3d `json:"shopping_cart_product_model3d_list" gorm:"foreignkey:product_id;references:product_id"`
ShoppingCartProductModel3dFitting *FsProductModel3d `json:"shopping_cart_product_model3d_list_fitting" gorm:"foreignkey:fitting_id;references:id"` ShoppingCartProductModel3dFitting *FsProductModel3d `json:"shopping_cart_product_model3d_list_fitting" gorm:"foreignkey:fitting_id;references:id"`
} }
type FsShoppingCartData struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户id
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id
TemplateId *int64 `gorm:"default:0;" json:"template_id"` // 模板id
ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型id
SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id
LightId *int64 `gorm:"default:0;" json:"light_id"` // 灯光id
FittingId *int64 `gorm:"default:0;" json:"fitting_id"` // 配件id
PurchaseQuantity *int64 `gorm:"default:0;" json:"purchase_quantity"` // 购买数量
Snapshot *map[string]interface{} `gorm:"default:'';" json:"snapshot"` //
SnapshotData *string `gorm:"default:'';" json:"snapshot_data"` //
IsSelected *int64 `gorm:"default:0;" json:"is_selected"` // 是否被选中 0非 1是
IsHighlyCustomized *int64 `gorm:"default:0;" json:"is_highly_customized"` // 是否高度定制 0非 1是针对客人高度定制只能后台增加如购物车
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
}
// 快照json数据结构 // 快照json数据结构
// 购物车快照数据结构 // 购物车快照数据结构

View File

@ -268,6 +268,7 @@ func (d *defaultOrder) PaymentSuccessful(ctx context.Context, in *PaymentSuccess
StatusTitle: constants.OrderStatusMessage[statusCode], StatusTitle: constants.OrderStatusMessage[statusCode],
} }
statusLink = order.UpdateOrderStatusLink(ress.OrderDetailOriginal.OrderInfo.StatusLink, gmodel.OrderStatus{ statusLink = order.UpdateOrderStatusLink(ress.OrderDetailOriginal.OrderInfo.StatusLink, gmodel.OrderStatus{
Ctime: &ntime,
Utime: &ntime, Utime: &ntime,
StatusCode: statusCode, StatusCode: statusCode,
StatusTitle: constants.OrderStatusMessage[statusCode], StatusTitle: constants.OrderStatusMessage[statusCode],
@ -343,8 +344,7 @@ func (d *defaultOrder) PaymentSuccessful(ctx context.Context, in *PaymentSuccess
PayTitle: &payTitle, PayTitle: &payTitle,
}) })
// 更新订单信息 // 更新订单信息
var sql string = fmt.Sprintf(", `utime` = '%s'", ntime) var sql string = fmt.Sprintf(", `utime` = '%s', `pay_status` = %d", ntime, orderPayStatusCode)
uOrderDetail["pay_status"] = orderPayStatusCode
uOrderDetail["order_info"] = struct { uOrderDetail["order_info"] = struct {
Utime *time.Time `json:"utime"` Utime *time.Time `json:"utime"`
Status gmodel.OrderStatus `json:"status"` Status gmodel.OrderStatus `json:"status"`
@ -892,7 +892,32 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
if shoppingCart.ShoppingCartProduct.CoverResource != nil && shoppingCart.ShoppingCartProduct.CoverResource.Metadata != nil { if shoppingCart.ShoppingCartProduct.CoverResource != nil && shoppingCart.ShoppingCartProduct.CoverResource.Metadata != nil {
json.Unmarshal(*shoppingCart.ShoppingCartProduct.CoverResource.Metadata, &productCoverMetadata) json.Unmarshal(*shoppingCart.ShoppingCartProduct.CoverResource.Metadata, &productCoverMetadata)
} }
orderProductList = append(orderProductList, gmodel.OrderProduct{ snapshot, err := d.OrderDetailSnapshotHandler(ctx, shoppingCart.FsShoppingCart.Snapshot)
if err != nil {
return err
}
var shoppingCartSnapshotInter = &gmodel.FsShoppingCartData{
Id: shoppingCart.FsShoppingCart.Id,
UserId: shoppingCart.FsShoppingCart.UserId,
ProductId: shoppingCart.FsShoppingCart.ProductId,
TemplateId: shoppingCart.FsShoppingCart.TemplateId,
ModelId: shoppingCart.FsShoppingCart.ModelId,
SizeId: shoppingCart.FsShoppingCart.SizeId,
LightId: shoppingCart.FsShoppingCart.LightId,
FittingId: shoppingCart.FsShoppingCart.FittingId,
PurchaseQuantity: shoppingCart.FsShoppingCart.PurchaseQuantity,
Snapshot: &snapshot,
SnapshotData: shoppingCart.FsShoppingCart.Snapshot,
IsSelected: shoppingCart.FsShoppingCart.IsSelected,
IsHighlyCustomized: shoppingCart.FsShoppingCart.IsHighlyCustomized,
Ctime: shoppingCart.FsShoppingCart.Ctime,
Utime: shoppingCart.FsShoppingCart.Utime,
}
var purchaseQuantityInter = gmodel.PurchaseQuantity{
Current: *shoppingCart.PurchaseQuantity,
Initiate: *shoppingCart.PurchaseQuantity,
}
productInter := gmodel.OrderProduct{
TotalPrice: order.GetAmountInfo(order.GetAmountInfoReq{ TotalPrice: order.GetAmountInfo(order.GetAmountInfoReq{
ExchangeRate: in.ExchangeRate, ExchangeRate: in.ExchangeRate,
Initiate: productTotalPrice, Initiate: productTotalPrice,
@ -901,10 +926,7 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
OriginalCurrency: in.OriginalCurrency, OriginalCurrency: in.OriginalCurrency,
}), }),
ExpectedDeliveryTime: &in.ExpectedDeliveryTime, ExpectedDeliveryTime: &in.ExpectedDeliveryTime,
PurchaseQuantity: gmodel.PurchaseQuantity{ PurchaseQuantity: purchaseQuantityInter,
Current: *shoppingCart.PurchaseQuantity,
Initiate: *shoppingCart.PurchaseQuantity,
},
ProductID: *shoppingCart.ProductId, ProductID: *shoppingCart.ProductId,
ProductCover: *shoppingCart.ShoppingCartProduct.Cover, ProductCover: *shoppingCart.ShoppingCartProduct.Cover,
ProductCoverMetadata: productCoverMetadata, ProductCoverMetadata: productCoverMetadata,
@ -917,7 +939,7 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
OriginalCurrency: in.OriginalCurrency, OriginalCurrency: in.OriginalCurrency,
}), }),
ProductSnapshot: shoppingCart.ShoppingCartProduct, ProductSnapshot: shoppingCart.ShoppingCartProduct,
ShoppingCartSnapshot: &shoppingCart.FsShoppingCart, ShoppingCartSnapshot: shoppingCartSnapshotInter,
ProductSn: *shoppingCart.ShoppingCartProduct.Sn, ProductSn: *shoppingCart.ShoppingCartProduct.Sn,
DiyInformation: &shoppingCartSnapshot.UserDiyInformation, DiyInformation: &shoppingCartSnapshot.UserDiyInformation,
FittingInfo: &gmodel.OrderProductFittingInfo{ FittingInfo: &gmodel.OrderProductFittingInfo{
@ -934,7 +956,8 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
}, },
StepNum: stepNum, StepNum: stepNum,
IsHighlyCustomized: *shoppingCart.IsHighlyCustomized, IsHighlyCustomized: *shoppingCart.IsHighlyCustomized,
}) }
orderProductList = append(orderProductList, productInter)
} }
subtotal = order.GetAmountInfo(order.GetAmountInfoReq{ subtotal = order.GetAmountInfo(order.GetAmountInfoReq{
@ -1060,6 +1083,66 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
}, nil }, nil
} }
// 处理订单购物车快照
func (d *defaultOrder) OrderDetailSnapshotHandler(ctx context.Context, req *string) (res map[string]interface{}, err error) {
var snapshot map[string]interface{}
json.Unmarshal([]byte(*req), &snapshot)
snapshotFittingInfoData, snapshotFittingInfoEx := snapshot["fitting_info"]
var fittingInfoMap map[string]interface{}
if snapshotFittingInfoEx {
var snapshotFittingInfoJson map[string]interface{}
var fittingName string
snapshotFittingInfo := snapshotFittingInfoData.(map[string]interface{})
snapshotFittingInfoJsonData, snapshotFittingInfoJsonEx := snapshotFittingInfo["fitting_json"]
if snapshotFittingInfoJsonEx {
json.Unmarshal([]byte(snapshotFittingInfoJsonData.(string)), &snapshotFittingInfoJson)
}
fittingNameData, fittingNameEx := snapshotFittingInfo["fitting_name"]
if fittingNameEx {
fittingName = fittingNameData.(string)
}
fittingInfoMap = make(map[string]interface{}, 2)
fittingInfoMap["fitting_json"] = snapshotFittingInfoJson
fittingInfoMap["fitting_name"] = fittingName
}
snapshot["fitting_info"] = fittingInfoMap
snapshotModelInfoData, snapshotModelInfoEx := snapshot["model_info"]
var modelInfoMap map[string]interface{}
if snapshotModelInfoEx {
var snapshotModelInfoJson map[string]interface{}
snapshotModelInfo := snapshotModelInfoData.(map[string]interface{})
snapshotModelInfoJsonData, snapshotModelInfoJsonEx := snapshotModelInfo["model_json"]
if snapshotModelInfoJsonEx {
json.Unmarshal([]byte(snapshotModelInfoJsonData.(string)), &snapshotModelInfoJson)
}
modelInfoMap = make(map[string]interface{}, 1)
modelInfoMap["model_json"] = snapshotModelInfoJson
}
snapshot["model_info"] = modelInfoMap
snapshotTemplateInfoData, snapshotTemplateInfoEx := snapshot["template_info"]
var templateInfoMap map[string]interface{}
if snapshotTemplateInfoEx {
var snapshotTemplateInfoJson map[string]interface{}
var templateTag string
snapshotTemplateInfo := snapshotTemplateInfoData.(map[string]interface{})
snapshotTemplateInfoJsonData, snapshotTemplateInfoJsonEx := snapshotTemplateInfo["template_json"]
if snapshotTemplateInfoJsonEx {
json.Unmarshal([]byte(snapshotTemplateInfoJsonData.(string)), &snapshotTemplateInfoJson)
}
templateTagData, templateTagEx := snapshotTemplateInfo["template_tag"]
if templateTagEx {
templateTag = templateTagData.(string)
}
templateInfoMap = make(map[string]interface{}, 2)
templateInfoMap["template_json"] = snapshotTemplateInfoJson
templateInfoMap["template_tag"] = templateTag
}
snapshot["template_info"] = templateInfoMap
return snapshot, nil
}
// 详情处理 // 详情处理
func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel.FsOrder, original int64) (res *DetailRes, err error) { func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel.FsOrder, original int64) (res *DetailRes, err error) {
var orderDetail gmodel.OrderDetail var orderDetail gmodel.OrderDetail
@ -1076,42 +1159,7 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel
orderDetail.OrderProduct[orderProductKey].TotalPrice = order.GetAmountInfoFormat(&orderProduct.TotalPrice) orderDetail.OrderProduct[orderProductKey].TotalPrice = order.GetAmountInfoFormat(&orderProduct.TotalPrice)
orderDetail.OrderProduct[orderProductKey].PurchaseQuantity = order.GetPurchaseQuantity(&orderProduct.PurchaseQuantity) orderDetail.OrderProduct[orderProductKey].PurchaseQuantity = order.GetPurchaseQuantity(&orderProduct.PurchaseQuantity)
orderDetail.OrderProduct[orderProductKey].ProductSnapshot = nil orderDetail.OrderProduct[orderProductKey].ProductSnapshot = nil
var snapshot map[string]interface{} orderDetail.OrderProduct[orderProductKey].ShoppingCartSnapshot.SnapshotData = nil
if orderDetail.OrderProduct[orderProductKey].ShoppingCartSnapshot.Snapshot != nil {
json.Unmarshal([]byte(*orderDetail.OrderProduct[orderProductKey].ShoppingCartSnapshot.Snapshot), &snapshot)
}
snapshotfittingInfoData, snapshotfittingInfoEx := snapshot["fitting_info"]
var snapshotfittingInfoJson map[string]interface{}
if snapshotfittingInfoEx {
snapshotfittingInfo := snapshotfittingInfoData.(map[string]interface{})
snapshotfittingInfoJsonData, snapshotfittingInfoJsonEx := snapshotfittingInfo["fitting_json"]
if snapshotfittingInfoJsonEx {
var snapshotfittingInfoJson map[string]interface{}
json.Unmarshal([]byte(snapshotfittingInfoJsonData.(string)), &snapshotfittingInfoJson)
}
}
snapshot["fitting_info"] = snapshotfittingInfoJson
snapshotModelInfoData, snapshotModelInfoEx := snapshot["model_info"]
var snapshotModelInfoJson map[string]interface{}
if snapshotModelInfoEx {
snapshotModelInfo := snapshotModelInfoData.(map[string]interface{})
snapshotModelInfoJsonData, snapshotModelInfoJsonEx := snapshotModelInfo["model_json"]
if snapshotModelInfoJsonEx {
json.Unmarshal([]byte(snapshotModelInfoJsonData.(string)), &snapshotModelInfoJson)
}
}
snapshot["model_info"] = snapshotModelInfoJson
snapshotTemplateInfoData, snapshotTemplateInfoEx := snapshot["template_info"]
var snapshotTemplateInfoJson map[string]interface{}
if snapshotTemplateInfoEx {
snapshotTemplateInfo := snapshotTemplateInfoData.(map[string]interface{})
snapshotTemplateInfoJsonData, snapshotTemplateInfoJsonEx := snapshotTemplateInfo["template_json"]
if snapshotTemplateInfoJsonEx {
json.Unmarshal([]byte(snapshotTemplateInfoJsonData.(string)), &snapshotTemplateInfoJson)
}
}
snapshot["template_info"] = snapshotTemplateInfoJson
orderDetail.OrderProduct[orderProductKey].ShoppingCartSnapshotInfo = snapshot
} }
orderDetail.OrderInfo.StatusLink = order.GetOrderStatusLinkUser(orderDetail.OrderInfo.DeliveryMethod, orderDetail.OrderInfo.StatusLink) orderDetail.OrderInfo.StatusLink = order.GetOrderStatusLinkUser(orderDetail.OrderInfo.DeliveryMethod, orderDetail.OrderInfo.StatusLink)
orderDetail.OrderAmount.Deposit.PayAmount = order.GetAmountInfoFormat(&orderDetail.OrderAmount.Deposit.PayAmount) orderDetail.OrderAmount.Deposit.PayAmount = order.GetAmountInfoFormat(&orderDetail.OrderAmount.Deposit.PayAmount)