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

This commit is contained in:
laodaming 2023-09-26 13:06:59 +08:00
commit 1543e60301
6 changed files with 62 additions and 21 deletions

View File

@ -68,7 +68,7 @@ func (a *FsAddressModel) CreateOne(ctx context.Context, address *FsAddress) (res
return result, nil return result, nil
} }
func (a *FsAddressModel) UpdateAddAddress(ctx context.Context, address *FsAddress) (err error) { func (a *FsAddressModel) UpdateAddress(ctx context.Context, address *FsAddress) (err error) {
err = a.db.WithContext(ctx).Model(&FsAddress{}).Transaction(func(tx *gorm.DB) error { err = a.db.WithContext(ctx).Model(&FsAddress{}).Transaction(func(tx *gorm.DB) error {
err = tx. err = tx.
Where("user_id = ? and address_id = ? and status = 1 ", address.UserId, address.AddressId). Where("user_id = ? and address_id = ? and status = 1 ", address.UserId, address.AddressId).

View File

@ -95,22 +95,23 @@ 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 *FsShoppingCart `json:"shopping_cart_snapshot"` // 购物车快照
ProductCover string `json:"product_cover"` // 商品封面 ShoppingCartSnapshotInfo map[string]interface{} `json:"shopping_cart_snapshot_info"` // 商品封面
ProductCoverMetadata map[string]interface{} `json:"product_cover_metadata"` // 商品封面 ProductCover string `json:"product_cover"` // 商品封面
ProductSn string `json:"product_sn"` // 商品编码 ProductCoverMetadata map[string]interface{} `json:"product_cover_metadata"` // 商品封面
DiyInformation *UserDiyInformation `json:"diy_information"` ProductSn string `json:"product_sn"` // 商品编码
SizeInfo *OrderProductSizeInfo `json:"size_info"` DiyInformation *UserDiyInformation `json:"diy_information"`
FittingInfo *OrderProductFittingInfo `json:"fitting_info"` SizeInfo *OrderProductSizeInfo `json:"size_info"`
StepNum []int `json:"step_num"` // 阶梯数量 FittingInfo *OrderProductFittingInfo `json:"fitting_info"`
IsHighlyCustomized int64 `json:"is_highly_customized"` StepNum []int `json:"step_num"` // 阶梯数量
IsHighlyCustomized int64 `json:"is_highly_customized"`
} }
type PurchaseQuantity struct { type PurchaseQuantity struct {
Current interface{} `json:"current"` Current interface{} `json:"current"`

View File

@ -88,7 +88,7 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
} }
// 插入数据库 更新地址 // 插入数据库 更新地址
err := m.UpdateAddAddress(l.ctx, address) err := m.UpdateAddress(l.ctx, address)
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
return resp.SetStatus(basic.CodeDbUpdateErr) return resp.SetStatus(basic.CodeDbUpdateErr)

View File

@ -42,6 +42,10 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo *
now := time.Now().UTC() now := time.Now().UTC()
if req.AddressId == 0 {
return resp.SetStatusWithMessage(basic.CodeApiErr, "address_id must setting")
}
address := gmodel.FsAddress{ address := gmodel.FsAddress{
AddressId: req.AddressId, AddressId: req.AddressId,
UserId: &userinfo.UserId, UserId: &userinfo.UserId,
@ -56,10 +60,9 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo *
City: &req.City, City: &req.City,
State: &req.State, State: &req.State,
Utime: &now, Utime: &now,
Ltime: &now,
} }
err := l.svcCtx.AllModels.FsAddress.UpdateAddAddress(l.ctx, &address) err := l.svcCtx.AllModels.FsAddress.UpdateAddress(l.ctx, &address)
if err != nil { if err != nil {
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error()) return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
} }

View File

@ -20,7 +20,7 @@ service info {
post /api/info/address/add(AddressRequest) returns (response); post /api/info/address/add(AddressRequest) returns (response);
@handler AddressUpdateHandler @handler AddressUpdateHandler
post /api/info/address/update(AddressObjectRequest) returns (response); post /api/info/address/update(AddressRequest) returns (response);
@handler AddressDeleteHandler @handler AddressDeleteHandler
post /api/info/address/delete(AddressIdRequest) returns (response); post /api/info/address/delete(AddressIdRequest) returns (response);

View File

@ -1076,6 +1076,43 @@ 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{}
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].ShoppingCartSnapshot.Snapshot = nil
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)