fix
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/order"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -37,23 +39,23 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
orderInfo, err := orderModel.FindOneBySn(l.ctx, userinfo.UserId, req.Sn)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
if orderInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
||||
}
|
||||
address := types.Address{}
|
||||
//直接邮寄才有地址信息
|
||||
if *orderInfo.DeliveryMethod == constants.DELIVERY_METHOD_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")
|
||||
}
|
||||
if addressInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not exists")
|
||||
}
|
||||
address.Id = addressInfo.Id
|
||||
address.UserId = *addressInfo.UserId
|
||||
address.Name = *addressInfo.Name
|
||||
@@ -145,7 +147,7 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
|
||||
mapPay[*v.PayStage] = k
|
||||
}
|
||||
//处理订单状态
|
||||
orderStatus := order.GetOrderStatus(*orderInfo.Status, *orderInfo.DeliveryMethod)
|
||||
orderStatus := order.GetOrderStatus(constants.Order(*orderInfo.Status), constants.DeliveryMethod(*orderInfo.DeliveryMethod))
|
||||
//组装
|
||||
productListRsp := make([]types.Product, 0, len(orderDetails))
|
||||
for _, v := range orderDetails {
|
||||
@@ -194,7 +196,7 @@ func (l *GetOrderDetailLogic) GetOrderDetail(req *types.GetOrderDetailReq, useri
|
||||
IsPayCompleted: *orderInfo.IsPayCompleted,
|
||||
DeliveryMethod: *orderInfo.DeliveryMethod,
|
||||
Sn: *orderInfo.Sn,
|
||||
Status: orderStatus,
|
||||
Status: int64(orderStatus),
|
||||
Ctime: time.Unix(*orderInfo.Ctime, 0).Format("2006-01-02 15:04:05"),
|
||||
PayInfo: types.PayInfo{},
|
||||
Address: address,
|
||||
|
||||
@@ -2,12 +2,14 @@ package logic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/pdf"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -54,12 +56,12 @@ func (l *GetOrderInvoiceLogic) GetOrderInvoice(req *types.GetOrderInvoiceReq, us
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
orderInfo, err := orderModel.FindOneBySn(l.ctx, userinfo.UserId, req.Sn)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
if orderInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order is not exists")
|
||||
}
|
||||
//地址数据
|
||||
var address gmodel.FsAddress
|
||||
if err = json.Unmarshal([]byte(*orderInfo.AddressInfo), &address); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user