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

This commit is contained in:
eson
2023-06-20 19:37:08 +08:00
22 changed files with 406 additions and 485 deletions

View File

@@ -45,32 +45,6 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
logx.Error(err)
return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
}
address := types.Address{}
//直接邮寄才有地址信息
if *orderInfo.DeliveryMethod == int64(constants.DELIVERY_METHOD_ADDRESS) {
addressInfo, err := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn).GetOne(l.ctx, *orderInfo.AddressId, userinfo.UserId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
}
address.Id = addressInfo.Id
address.UserId = *addressInfo.UserId
address.Name = *addressInfo.Name
address.FirstName = *addressInfo.FirstName
address.LastName = *addressInfo.LastName
address.Mobile = *addressInfo.Mobile
address.Street = *addressInfo.Street
address.Suite = *addressInfo.Suite
address.City = *addressInfo.City
address.State = *addressInfo.State
address.Country = *addressInfo.Country
address.ZipCode = *addressInfo.ZipCode
address.Status = *addressInfo.Status
address.IsDefault = *addressInfo.IsDefault
}
//获取订单详情
orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
orderDetails, err := orderDetailModel.GetOrderDetailsByOrderId(l.ctx, orderInfo.Id)
@@ -149,7 +123,7 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
//处理订单状态
orderStatus := order.GetOrderStatus(constants.Order(*orderInfo.Status), constants.DeliveryMethod(*orderInfo.DeliveryMethod))
//组装
productListRsp := make([]types.Product, 0, len(orderDetails))
productListRsp := make([]*types.Product, 0, len(orderDetails))
for _, v := range orderDetails {
cover := *v.Cover
if req.Size >= 200 {
@@ -174,7 +148,7 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
if productIndex, ok := mapProduct[*v.ProductId]; ok {
Title = *productList[productIndex].Title
}
productListRsp = append(productListRsp, types.Product{
productListRsp = append(productListRsp, &types.Product{
Cover: cover,
Fitting: Fitting,
OptionPrice: *v.OptionPrice,
@@ -198,10 +172,36 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
Sn: *orderInfo.Sn,
Status: int64(orderStatus),
Ctime: time.Unix(*orderInfo.Ctime, 0).Format("2006-01-02 15:04:05"),
PayInfo: types.PayInfo{},
Address: address,
Address: nil,
ProductList: productListRsp,
}
//直接邮寄才有地址信息
if *orderInfo.DeliveryMethod == int64(constants.DELIVERY_METHOD_ADDRESS) {
addressInfo, err := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn).GetOne(l.ctx, *orderInfo.AddressId, userinfo.UserId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
}
data.Address = &types.Address{
Id: addressInfo.Id,
UserId: *addressInfo.UserId,
Name: *addressInfo.Name,
FirstName: *addressInfo.FirstName,
LastName: *addressInfo.LastName,
Mobile: *addressInfo.Mobile,
Street: *addressInfo.Street,
Suite: *addressInfo.Suite,
City: *addressInfo.City,
State: *addressInfo.State,
Country: *addressInfo.Country,
ZipCode: *addressInfo.ZipCode,
Status: *addressInfo.Status,
IsDefault: *addressInfo.IsDefault,
}
}
//首款
if payIndex, ok := mapPay[1]; ok {
data.PayInfo.Deposit = types.Deposit{

View File

@@ -21,18 +21,18 @@ type GetOrderDetailReq struct {
}
type GetOrderDetailRsp struct {
Id int64 `json:"id"`
TotalAmount int64 `json:"total_amount"`
Deposit int64 `json:"deposit"`
Remaining int64 `json:"remaining"`
IsPayCompleted int64 `json:"is_pay_completed"`
DeliveryMethod int64 `json:"delivery_method"`
Sn string `json:"sn"`
Status int64 `json:"status"`
Ctime string `json:"ctime"`
PayInfo PayInfo `json:"pay_info"`
Address Address `json:"address"`
ProductList []Product `json:"productList"`
Id int64 `json:"id"`
TotalAmount int64 `json:"total_amount"`
Deposit int64 `json:"deposit"`
Remaining int64 `json:"remaining"`
IsPayCompleted int64 `json:"is_pay_completed"`
DeliveryMethod int64 `json:"delivery_method"`
Sn string `json:"sn"`
Status int64 `json:"status"`
Ctime string `json:"ctime"`
PayInfo *PayInfo `json:"pay_info"`
Address *Address `json:"address"`
ProductList []*Product `json:"productList"`
}
type Product struct {