fix调整
This commit is contained in:
parent
8870b389be
commit
2261421ba5
@ -1,15 +1,14 @@
|
|||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fs_address 用户地址表
|
// fs_address 用户地址表
|
||||||
type FsAddress struct {
|
type FsAddress struct {
|
||||||
AddressId int64 `gorm:"primary_key;default:0;auto_increment;" json:"address_id"` //
|
AddressId int64 `gorm:"primary_key;default:0;auto_increment;" json:"address_id"` //
|
||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户ID
|
||||||
FirstName *string `gorm:"default:'';" json:"first_name"` // FirstName
|
FirstName *string `gorm:"default:'';" json:"first_name"` // FirstName
|
||||||
LastName *string `gorm:"default:'';" json:"last_name"` // LastName
|
LastName *string `gorm:"default:'';" json:"last_name"` // LastName
|
||||||
Mobile *string `gorm:"default:'';" json:"mobile"` // 手机号码
|
Mobile *string `gorm:"default:'';" json:"mobile"` // 手机号码
|
||||||
@ -21,8 +20,8 @@ type FsAddress struct {
|
|||||||
ZipCode *string `gorm:"default:'';" json:"zip_code"` //
|
ZipCode *string `gorm:"default:'';" json:"zip_code"` //
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常
|
Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常
|
||||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` // 创建时间
|
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"` // 更新时间
|
Utime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"utime"` // 更新时间
|
||||||
Ltime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"ltime"` // 上次被使用的时间
|
Ltime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ltime"` // 上次被使用的时间
|
||||||
}
|
}
|
||||||
type FsAddressModel struct {
|
type FsAddressModel struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -73,14 +73,14 @@ type PayStatus struct {
|
|||||||
|
|
||||||
// 订单信息
|
// 订单信息
|
||||||
type OrderInfo struct {
|
type OrderInfo struct {
|
||||||
UserId int64 `json:"user_id"` // 物流类型
|
UserId int64 `json:"user_id"` // 物流类型
|
||||||
Ctime *time.Time `json:"ctime"` // 创建日期
|
Ctime *time.Time `json:"ctime"` // 创建日期
|
||||||
DeliveryMethod int64 `json:"delivery_method"` // 物流类型
|
DeliveryMethod int64 `json:"delivery_method"` // 物流类型
|
||||||
Metadata map[string]interface{} `json:"metadata"` // 额外参数
|
Metadata OrderMetadata `json:"metadata"` // 额外参数
|
||||||
OrderSn string `json:"order_sn"` // 订单编号
|
OrderSn string `json:"order_sn"` // 订单编号
|
||||||
Status OrderStatus `json:"status"` // 当前状态
|
Status OrderStatus `json:"status"` // 当前状态
|
||||||
StatusLink []OrderStatus `json:"status_link"` // 状态链路
|
StatusLink []OrderStatus `json:"status_link"` // 状态链路
|
||||||
Utime *time.Time `json:"utime"` // 更新时间
|
Utime *time.Time `json:"utime"` // 更新时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订单状态--用户
|
// 订单状态--用户
|
||||||
@ -112,6 +112,7 @@ type OrderProduct struct {
|
|||||||
SizeInfo *OrderProductSizeInfo `json:"size_info"`
|
SizeInfo *OrderProductSizeInfo `json:"size_info"`
|
||||||
FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
|
FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
|
||||||
IsHighlyCustomized int64 `json:"is_highly_customized"`
|
IsHighlyCustomized int64 `json:"is_highly_customized"`
|
||||||
|
RenderImage string `json:"render_image"`
|
||||||
}
|
}
|
||||||
type PurchaseQuantity struct {
|
type PurchaseQuantity struct {
|
||||||
Current interface{} `json:"current"`
|
Current interface{} `json:"current"`
|
||||||
@ -140,9 +141,9 @@ type ExpectedDelivery struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type OrderProductInter struct {
|
type OrderProductInter struct {
|
||||||
|
CartId int64 `json:"cart_id"` // 购物车ID
|
||||||
TotalPrice AmountInfo `json:"total_price"` // 商品总价
|
TotalPrice AmountInfo `json:"total_price"` // 商品总价
|
||||||
ItemPrice AmountInfo `json:"item_price"` // 商品单价
|
ItemPrice AmountInfo `json:"item_price"` // 商品单价
|
||||||
ExpectedDelivery *ExpectedDelivery `json:"expected_delivery"` // 预计到货
|
|
||||||
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"` // 商品名称
|
||||||
@ -153,4 +154,8 @@ type OrderProductInter struct {
|
|||||||
SizeInfo *OrderProductSizeInfo `json:"size_info"`
|
SizeInfo *OrderProductSizeInfo `json:"size_info"`
|
||||||
FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
|
FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
|
||||||
IsHighlyCustomized int64 `json:"is_highly_customized"`
|
IsHighlyCustomized int64 `json:"is_highly_customized"`
|
||||||
|
RenderImage string `json:"render_image"`
|
||||||
|
}
|
||||||
|
type OrderMetadata struct {
|
||||||
|
ExpectedDeliveryTime ExpectedDelivery `json:"expected_delivery_time"` // 预计到货时间
|
||||||
}
|
}
|
||||||
|
@ -807,7 +807,7 @@ func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *Create
|
|||||||
func (d *defaultOrder) List(ctx context.Context, in *ListReq) (res *ListRes, err error) {
|
func (d *defaultOrder) List(ctx context.Context, in *ListReq) (res *ListRes, err error) {
|
||||||
var orderList []gmodel.FsOrder
|
var orderList []gmodel.FsOrder
|
||||||
model := d.MysqlConn.Model(&gmodel.FsOrder{}).Where("is_del = ?", 0)
|
model := d.MysqlConn.Model(&gmodel.FsOrder{}).Where("is_del = ?", 0)
|
||||||
model.Where("pay_status > ?", 0)
|
// model.Where("pay_status > ?", 0)
|
||||||
if in.UserId != 0 {
|
if in.UserId != 0 {
|
||||||
model.Where("user_id = ?", in.UserId)
|
model.Where("user_id = ?", in.UserId)
|
||||||
}
|
}
|
||||||
@ -1054,10 +1054,6 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||||||
CurrentCurrency: in.CurrentCurrency,
|
CurrentCurrency: in.CurrentCurrency,
|
||||||
OriginalCurrency: in.OriginalCurrency,
|
OriginalCurrency: in.OriginalCurrency,
|
||||||
}),
|
}),
|
||||||
ExpectedDelivery: &gmodel.ExpectedDelivery{
|
|
||||||
Current: in.ExpectedDeliveryTime,
|
|
||||||
Initiate: in.ExpectedDeliveryTime,
|
|
||||||
},
|
|
||||||
PurchaseQuantity: &gmodel.PurchaseQuantity{
|
PurchaseQuantity: &gmodel.PurchaseQuantity{
|
||||||
Current: *shoppingCart.PurchaseQuantity,
|
Current: *shoppingCart.PurchaseQuantity,
|
||||||
Initiate: *shoppingCart.PurchaseQuantity,
|
Initiate: *shoppingCart.PurchaseQuantity,
|
||||||
@ -1082,6 +1078,8 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
IsHighlyCustomized: *shoppingCart.IsHighlyCustomized,
|
IsHighlyCustomized: *shoppingCart.IsHighlyCustomized,
|
||||||
|
RenderImage: shoppingCartSnapshot.RenderImage,
|
||||||
|
CartId: shoppingCart.Id,
|
||||||
}
|
}
|
||||||
orderProductList = append(orderProductList, &productInter)
|
orderProductList = append(orderProductList, &productInter)
|
||||||
shoppingProductSnapshotList = append(shoppingProductSnapshotList, shoppingCart.ShoppingCartProduct)
|
shoppingProductSnapshotList = append(shoppingProductSnapshotList, shoppingCart.ShoppingCartProduct)
|
||||||
@ -1160,6 +1158,12 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||||||
byteShoppingCartSnapshot, _ := json.Marshal(shoppingCartSnapshotList)
|
byteShoppingCartSnapshot, _ := json.Marshal(shoppingCartSnapshotList)
|
||||||
byteShoppingProductSnapshot, _ := json.Marshal(shoppingProductSnapshotList)
|
byteShoppingProductSnapshot, _ := json.Marshal(shoppingProductSnapshotList)
|
||||||
byteStatusLink, _ := json.Marshal(statusLink)
|
byteStatusLink, _ := json.Marshal(statusLink)
|
||||||
|
byteOrderMetadata, _ := json.Marshal(gmodel.OrderMetadata{
|
||||||
|
ExpectedDeliveryTime: gmodel.ExpectedDelivery{
|
||||||
|
Current: in.ExpectedDeliveryTime,
|
||||||
|
Initiate: in.ExpectedDeliveryTime,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
// 创建订单
|
// 创建订单
|
||||||
resultCreate := tx.Create(&gmodel.FsOrder{
|
resultCreate := tx.Create(&gmodel.FsOrder{
|
||||||
@ -1175,6 +1179,7 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||||||
Status: (*int64)(&status),
|
Status: (*int64)(&status),
|
||||||
PayStatus: (*int64)(&payStatus),
|
PayStatus: (*int64)(&payStatus),
|
||||||
Ctime: &nowTime,
|
Ctime: &nowTime,
|
||||||
|
Metadata: &byteOrderMetadata,
|
||||||
})
|
})
|
||||||
|
|
||||||
if resultCreate.Error != nil {
|
if resultCreate.Error != nil {
|
||||||
@ -1341,12 +1346,19 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var status = order.GetOrderStatusCurrent(statusLink, constants.OrderStatusCode(*orderInfo.Status))
|
|
||||||
var orderDetail gmodel.OrderDetail
|
var orderMetadata gmodel.OrderMetadata
|
||||||
var orderMetadata map[string]interface{}
|
|
||||||
if orderInfo.Metadata != nil {
|
if orderInfo.Metadata != nil {
|
||||||
json.Unmarshal(*orderInfo.Metadata, &orderMetadata)
|
json.Unmarshal(*orderInfo.Metadata, &orderMetadata)
|
||||||
}
|
}
|
||||||
|
// 预计到货时间
|
||||||
|
var expectedTime = orderMetadata.ExpectedDeliveryTime.Current
|
||||||
|
|
||||||
|
var status = order.GetOrderStatusCurrent(statusLink, constants.OrderStatusCode(*orderInfo.Status))
|
||||||
|
status.ExpectedTime = &expectedTime
|
||||||
|
|
||||||
|
var orderDetail gmodel.OrderDetail
|
||||||
|
|
||||||
if original == 1 {
|
if original == 1 {
|
||||||
orderDetail.DeliveryAddress = orderAddress
|
orderDetail.DeliveryAddress = orderAddress
|
||||||
orderDetail.OrderAmount = orderAmount
|
orderDetail.OrderAmount = orderAmount
|
||||||
@ -1371,32 +1383,35 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel
|
|||||||
for _, productValue := range orderProduct {
|
for _, productValue := range orderProduct {
|
||||||
var shoppingCartSnapshotData gmodel.FsShoppingCartData
|
var shoppingCartSnapshotData gmodel.FsShoppingCartData
|
||||||
for _, shoppingCartSnapshotValue := range shoppingCartSnapshot {
|
for _, shoppingCartSnapshotValue := range shoppingCartSnapshot {
|
||||||
snapshot, err := d.OrderShoppingCartSnapshotHandler(ctx, shoppingCartSnapshotValue.Snapshot)
|
if productValue.CartId == shoppingCartSnapshotValue.Id {
|
||||||
if err != nil {
|
|
||||||
logc.Errorf(ctx, "OrderDetailHandler OrderShoppingCartSnapshotHandler failed, err: %v", err)
|
snapshot, err := d.OrderShoppingCartSnapshotHandler(ctx, shoppingCartSnapshotValue.Snapshot)
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
logc.Errorf(ctx, "OrderDetailHandler OrderShoppingCartSnapshotHandler failed, err: %v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
shoppingCartSnapshotData.Id = shoppingCartSnapshotValue.Id
|
||||||
|
shoppingCartSnapshotData.UserId = shoppingCartSnapshotValue.UserId
|
||||||
|
shoppingCartSnapshotData.ProductId = shoppingCartSnapshotValue.ProductId
|
||||||
|
shoppingCartSnapshotData.TemplateId = shoppingCartSnapshotValue.TemplateId
|
||||||
|
shoppingCartSnapshotData.ModelId = shoppingCartSnapshotValue.ModelId
|
||||||
|
shoppingCartSnapshotData.SizeId = shoppingCartSnapshotValue.SizeId
|
||||||
|
shoppingCartSnapshotData.LightId = shoppingCartSnapshotValue.LightId
|
||||||
|
shoppingCartSnapshotData.FittingId = shoppingCartSnapshotValue.FittingId
|
||||||
|
shoppingCartSnapshotData.PurchaseQuantity = shoppingCartSnapshotValue.PurchaseQuantity
|
||||||
|
shoppingCartSnapshotData.IsSelected = shoppingCartSnapshotValue.IsSelected
|
||||||
|
shoppingCartSnapshotData.IsSelected = shoppingCartSnapshotValue.IsSelected
|
||||||
|
shoppingCartSnapshotData.IsHighlyCustomized = shoppingCartSnapshotValue.IsHighlyCustomized
|
||||||
|
shoppingCartSnapshotData.Ctime = shoppingCartSnapshotValue.Ctime
|
||||||
|
shoppingCartSnapshotData.Utime = shoppingCartSnapshotValue.Utime
|
||||||
|
shoppingCartSnapshotData.Snapshot = &snapshot
|
||||||
}
|
}
|
||||||
shoppingCartSnapshotData.Id = shoppingCartSnapshotValue.Id
|
|
||||||
shoppingCartSnapshotData.UserId = shoppingCartSnapshotValue.UserId
|
|
||||||
shoppingCartSnapshotData.ProductId = shoppingCartSnapshotValue.ProductId
|
|
||||||
shoppingCartSnapshotData.TemplateId = shoppingCartSnapshotValue.TemplateId
|
|
||||||
shoppingCartSnapshotData.ModelId = shoppingCartSnapshotValue.ModelId
|
|
||||||
shoppingCartSnapshotData.SizeId = shoppingCartSnapshotValue.SizeId
|
|
||||||
shoppingCartSnapshotData.LightId = shoppingCartSnapshotValue.LightId
|
|
||||||
shoppingCartSnapshotData.FittingId = shoppingCartSnapshotValue.FittingId
|
|
||||||
shoppingCartSnapshotData.PurchaseQuantity = shoppingCartSnapshotValue.PurchaseQuantity
|
|
||||||
shoppingCartSnapshotData.IsSelected = shoppingCartSnapshotValue.IsSelected
|
|
||||||
shoppingCartSnapshotData.IsSelected = shoppingCartSnapshotValue.IsSelected
|
|
||||||
shoppingCartSnapshotData.IsHighlyCustomized = shoppingCartSnapshotValue.IsHighlyCustomized
|
|
||||||
shoppingCartSnapshotData.Ctime = shoppingCartSnapshotValue.Ctime
|
|
||||||
shoppingCartSnapshotData.Utime = shoppingCartSnapshotValue.Utime
|
|
||||||
shoppingCartSnapshotData.Snapshot = &snapshot
|
|
||||||
}
|
}
|
||||||
|
|
||||||
orderProductItem := gmodel.OrderProduct{
|
orderProductItem := gmodel.OrderProduct{
|
||||||
TotalPrice: order.GetAmountInfoFormat(&productValue.TotalPrice),
|
TotalPrice: order.GetAmountInfoFormat(&productValue.TotalPrice),
|
||||||
ItemPrice: order.GetAmountInfoFormat(&productValue.ItemPrice),
|
ItemPrice: order.GetAmountInfoFormat(&productValue.ItemPrice),
|
||||||
ExpectedDeliveryTime: &productValue.ExpectedDelivery.Current,
|
ExpectedDeliveryTime: &expectedTime,
|
||||||
PurchaseQuantity: *productValue.PurchaseQuantity,
|
PurchaseQuantity: *productValue.PurchaseQuantity,
|
||||||
ProductId: productValue.ProductId,
|
ProductId: productValue.ProductId,
|
||||||
ProductSn: productValue.ProductSn,
|
ProductSn: productValue.ProductSn,
|
||||||
@ -1409,6 +1424,7 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel
|
|||||||
SizeInfo: productValue.SizeInfo,
|
SizeInfo: productValue.SizeInfo,
|
||||||
FittingInfo: productValue.FittingInfo,
|
FittingInfo: productValue.FittingInfo,
|
||||||
IsHighlyCustomized: productValue.IsHighlyCustomized,
|
IsHighlyCustomized: productValue.IsHighlyCustomized,
|
||||||
|
RenderImage: productValue.RenderImage,
|
||||||
}
|
}
|
||||||
|
|
||||||
orderProductList = append(orderProductList, orderProductItem)
|
orderProductList = append(orderProductList, orderProductItem)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user