fix:支付
This commit is contained in:
parent
e2508cc347
commit
9e6f919fa8
|
@ -12,9 +12,9 @@ func (m *FsShoppingCartModel) TableName() string {
|
|||
// 关联查询
|
||||
type RelaFsShoppingCart struct {
|
||||
FsShoppingCart
|
||||
ShoppingCartProduct *RelaFsProduct `json:"shopping_cart_product" gorm:"foreignkey:product_id;references: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"`
|
||||
ShoppingCartProduct *RelaFsProduct `json:"shopping_cart_product" gorm:"foreignkey:product_id;references:id"`
|
||||
ShoppingCartProductModel3d *FsProductModel3d `json:"shopping_cart_product_model3d_list" gorm:"foreignkey:model_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
|
||||
|
|
|
@ -746,7 +746,7 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
Preload("ShoppingCartProduct", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(gmodel.NewFsProductModel(tx).TableName()).Preload("CoverResource")
|
||||
}).
|
||||
Preload("ShoppingCartProductModel3dList").
|
||||
Preload("ShoppingCartProductModel3d").
|
||||
Preload("ShoppingCartProductModel3dFitting").
|
||||
Where("id IN ?", in.CartIds).
|
||||
Where("user_id = ?", in.UserId).
|
||||
|
@ -807,9 +807,6 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
for _, shoppingCart := range shoppingCartList {
|
||||
// 购物车快照
|
||||
var shoppingCartSnapshot gmodel.CartSnapshot
|
||||
|
||||
// 购物车商品模型
|
||||
var shoppingCartProductModel3d *gmodel.FsProductModel3d
|
||||
if shoppingCart.Snapshot != nil {
|
||||
json.Unmarshal([]byte(*shoppingCart.Snapshot), &shoppingCartSnapshot)
|
||||
}
|
||||
|
@ -820,31 +817,9 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
return errors.New(errorCode.Message)
|
||||
}
|
||||
|
||||
// 商品模型异常
|
||||
if len(shoppingCart.ShoppingCartProductModel3dList) == 0 {
|
||||
errorCode = *basic.CodeErrOrderCreatProductAccessoryAbsent
|
||||
errorCode.Message = "create order failed, accessoryof product '" + shoppingCartSnapshot.ProductInfo.ProductName + "'is absent"
|
||||
return errors.New(errorCode.Message)
|
||||
} else {
|
||||
var isProductModel bool
|
||||
for _, shoppingCartProductModel3dInfo := range shoppingCart.ShoppingCartProductModel3dList {
|
||||
if *shoppingCart.SizeId == *shoppingCartProductModel3dInfo.SizeId {
|
||||
shoppingCartProductModel3d = shoppingCartProductModel3dInfo
|
||||
isProductModel = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isProductModel {
|
||||
errorCode = *basic.CodeErrOrderCreatProductAccessoryAbsent
|
||||
errorCode.Message = "create order failed, accessory of product '" + shoppingCartSnapshot.ProductInfo.ProductName + "'is absent"
|
||||
return errors.New(errorCode.Message)
|
||||
}
|
||||
shoppingCart.ShoppingCartProductModel3dList = []*gmodel.FsProductModel3d{shoppingCartProductModel3d}
|
||||
}
|
||||
|
||||
var stepPriceJson gmodel.StepPriceJsonStruct
|
||||
if shoppingCartProductModel3d.StepPrice != nil && len(*shoppingCartProductModel3d.StepPrice) != 0 {
|
||||
err = json.Unmarshal(*shoppingCartProductModel3d.StepPrice, &shoppingCartProductModel3d.StepPrice)
|
||||
if shoppingCart.ShoppingCartProductModel3d.StepPrice != nil {
|
||||
err = json.Unmarshal(*shoppingCart.ShoppingCartProductModel3d.StepPrice, &stepPriceJson)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user