fix:支付
This commit is contained in:
parent
4cd2e1ce65
commit
c7a2cf7d1c
|
@ -95,23 +95,22 @@ type OrderStatus struct {
|
|||
|
||||
// 订单商品
|
||||
type OrderProduct struct {
|
||||
TotalPrice AmountInfo `json:"amount"` // 商品总价
|
||||
ExpectedDeliveryTime *time.Time `json:"expected_delivery_time"` // 预计到货时间
|
||||
PurchaseQuantity PurchaseQuantity `json:"purchase_quantity"` // 购买数量
|
||||
ProductID int64 `json:"product_id"` // 商品ID
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
ItemPrice AmountInfo `json:"product_price"` // 商品单价
|
||||
ProductSnapshot interface{} `json:"product_snapshot"` // 商品快照
|
||||
ShoppingCartSnapshot *FsShoppingCart `json:"shopping_cart_snapshot"` // 购物车快照
|
||||
ShoppingCartSnapshotInfo map[string]interface{} `json:"shopping_cart_snapshot_info"` // 商品封面
|
||||
ProductCover string `json:"product_cover"` // 商品封面
|
||||
ProductCoverMetadata map[string]interface{} `json:"product_cover_metadata"` // 商品封面
|
||||
ProductSn string `json:"product_sn"` // 商品编码
|
||||
DiyInformation *UserDiyInformation `json:"diy_information"`
|
||||
SizeInfo *OrderProductSizeInfo `json:"size_info"`
|
||||
FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
|
||||
StepNum []int `json:"step_num"` // 阶梯数量
|
||||
IsHighlyCustomized int64 `json:"is_highly_customized"`
|
||||
TotalPrice AmountInfo `json:"amount"` // 商品总价
|
||||
ExpectedDeliveryTime *time.Time `json:"expected_delivery_time"` // 预计到货时间
|
||||
PurchaseQuantity PurchaseQuantity `json:"purchase_quantity"` // 购买数量
|
||||
ProductID int64 `json:"product_id"` // 商品ID
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
ItemPrice AmountInfo `json:"product_price"` // 商品单价
|
||||
ProductSnapshot interface{} `json:"product_snapshot"` // 商品快照
|
||||
ShoppingCartSnapshot *FsShoppingCartData `json:"shopping_cart_snapshot"` // 购物车快照
|
||||
ProductCover string `json:"product_cover"` // 商品封面
|
||||
ProductCoverMetadata map[string]interface{} `json:"product_cover_metadata"` // 商品封面
|
||||
ProductSn string `json:"product_sn"` // 商品编码
|
||||
DiyInformation *UserDiyInformation `json:"diy_information"`
|
||||
SizeInfo *OrderProductSizeInfo `json:"size_info"`
|
||||
FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
|
||||
StepNum []int `json:"step_num"` // 阶梯数量
|
||||
IsHighlyCustomized int64 `json:"is_highly_customized"`
|
||||
}
|
||||
type PurchaseQuantity struct {
|
||||
Current interface{} `json:"current"`
|
||||
|
|
|
@ -2,6 +2,7 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
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"`
|
||||
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数据结构
|
||||
// 购物车快照数据结构
|
||||
|
|
|
@ -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 {
|
||||
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{
|
||||
ExchangeRate: in.ExchangeRate,
|
||||
Initiate: productTotalPrice,
|
||||
|
@ -901,10 +926,7 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
OriginalCurrency: in.OriginalCurrency,
|
||||
}),
|
||||
ExpectedDeliveryTime: &in.ExpectedDeliveryTime,
|
||||
PurchaseQuantity: gmodel.PurchaseQuantity{
|
||||
Current: *shoppingCart.PurchaseQuantity,
|
||||
Initiate: *shoppingCart.PurchaseQuantity,
|
||||
},
|
||||
PurchaseQuantity: purchaseQuantityInter,
|
||||
ProductID: *shoppingCart.ProductId,
|
||||
ProductCover: *shoppingCart.ShoppingCartProduct.Cover,
|
||||
ProductCoverMetadata: productCoverMetadata,
|
||||
|
@ -917,7 +939,7 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
OriginalCurrency: in.OriginalCurrency,
|
||||
}),
|
||||
ProductSnapshot: shoppingCart.ShoppingCartProduct,
|
||||
ShoppingCartSnapshot: &shoppingCart.FsShoppingCart,
|
||||
ShoppingCartSnapshot: shoppingCartSnapshotInter,
|
||||
ProductSn: *shoppingCart.ShoppingCartProduct.Sn,
|
||||
DiyInformation: &shoppingCartSnapshot.UserDiyInformation,
|
||||
FittingInfo: &gmodel.OrderProductFittingInfo{
|
||||
|
@ -934,7 +956,8 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
},
|
||||
StepNum: stepNum,
|
||||
IsHighlyCustomized: *shoppingCart.IsHighlyCustomized,
|
||||
})
|
||||
}
|
||||
orderProductList = append(orderProductList, productInter)
|
||||
}
|
||||
|
||||
subtotal = order.GetAmountInfo(order.GetAmountInfoReq{
|
||||
|
@ -1060,6 +1083,66 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
}, 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) {
|
||||
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].PurchaseQuantity = order.GetPurchaseQuantity(&orderProduct.PurchaseQuantity)
|
||||
orderDetail.OrderProduct[orderProductKey].ProductSnapshot = nil
|
||||
var snapshot map[string]interface{}
|
||||
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.OrderProduct[orderProductKey].ShoppingCartSnapshot.SnapshotData = nil
|
||||
}
|
||||
orderDetail.OrderInfo.StatusLink = order.GetOrderStatusLinkUser(orderDetail.OrderInfo.DeliveryMethod, orderDetail.OrderInfo.StatusLink)
|
||||
orderDetail.OrderAmount.Deposit.PayAmount = order.GetAmountInfoFormat(&orderDetail.OrderAmount.Deposit.PayAmount)
|
||||
|
|
Loading…
Reference in New Issue
Block a user