feat:新增api
This commit is contained in:
@@ -2,11 +2,10 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"fusenapi/server/product/internal/svc"
|
||||
@@ -47,64 +46,64 @@ func (l *GetLastProductDesignLogic) GetLastProductDesign(req *types.Request, use
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:IsOpenRender switch is closed")
|
||||
}
|
||||
//查询用户最近下单成功的数据
|
||||
orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, user.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of order is found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get your last order")
|
||||
}
|
||||
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, user.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of order is found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get your last order")
|
||||
// }
|
||||
//获取该订单相关设计信息
|
||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail is not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get order detail")
|
||||
}
|
||||
//获取设计模板详情,便于获得design_id
|
||||
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail template is not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get order detail template")
|
||||
}
|
||||
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail is not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get order detail")
|
||||
// }
|
||||
// //获取设计模板详情,便于获得design_id
|
||||
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail template is not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get order detail template")
|
||||
// }
|
||||
//最后一次设计不存在,则不返回该设计相关数据
|
||||
if *orderDetailTemplate.DesignId <= 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:last design id is not set")
|
||||
}
|
||||
// if *orderDetailTemplate.DesignId <= 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeOK, "success:last design id is not set")
|
||||
// }
|
||||
//获取设计数据
|
||||
productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, user.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product design is not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product design")
|
||||
}
|
||||
var info interface{}
|
||||
if productDesign.Info != nil && *productDesign.Info != "" {
|
||||
if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
var logoColor interface{}
|
||||
if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||
if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, user.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product design is not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product design")
|
||||
// }
|
||||
// var info interface{}
|
||||
// if productDesign.Info != nil && *productDesign.Info != "" {
|
||||
// if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
// var logoColor interface{}
|
||||
// if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||
// if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetLastProductDesignRsp{
|
||||
Id: productDesign.Id,
|
||||
OptionalId: *productDesign.OptionalId,
|
||||
SizeId: *productDesign.SizeId,
|
||||
LogoColor: logoColor,
|
||||
Info: info,
|
||||
Id: 1,
|
||||
OptionalId: 1,
|
||||
SizeId: 1,
|
||||
LogoColor: 1,
|
||||
Info: nil,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ import (
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/step_price"
|
||||
"gorm.io/gorm"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/product/internal/svc"
|
||||
|
||||
@@ -14,10 +14,11 @@ import (
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/image"
|
||||
"fusenapi/utils/step_price"
|
||||
"gorm.io/gorm"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"fusenapi/server/product/internal/svc"
|
||||
"fusenapi/server/product/internal/types"
|
||||
|
||||
@@ -460,66 +461,66 @@ func (l *GetProductInfoLogic) getRenderDesign(clientNo string) interface{} {
|
||||
// 获取用户最新设计
|
||||
func (l *GetProductInfoLogic) getLastDesign(userInfo gmodel.FsUser) interface{} {
|
||||
//查询用户最近下单成功的数据
|
||||
orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userInfo.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userInfo.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
//获取该订单相关设计信息
|
||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
//获取设计模板详情,便于获得design_id
|
||||
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// //获取设计模板详情,便于获得design_id
|
||||
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
//若没打开了个性化渲染按钮或者最后一次设计不存在,则不返回该设计相关数据
|
||||
if *userInfo.IsOpenRender != 1 || *orderDetailTemplate.DesignId <= 0 {
|
||||
return nil
|
||||
}
|
||||
//获取设计数据
|
||||
productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, userInfo.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
var info interface{}
|
||||
if productDesign.Info != nil && *productDesign.Info != "" {
|
||||
if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
var logoColor interface{}
|
||||
if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||
if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// if *userInfo.IsOpenRender != 1 || *orderDetailTemplate.DesignId <= 0 {
|
||||
// return nil
|
||||
// }
|
||||
// //获取设计数据
|
||||
// productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, userInfo.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// var info interface{}
|
||||
// if productDesign.Info != nil && *productDesign.Info != "" {
|
||||
// if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
// var logoColor interface{}
|
||||
// if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||
// if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
return map[string]interface{}{
|
||||
"id": productDesign.Id,
|
||||
"info": info,
|
||||
"logo_color": logoColor,
|
||||
"material_id": *productDesign.MaterialId,
|
||||
"optional_id": *productDesign.OptionalId,
|
||||
"size_id": *productDesign.SizeId,
|
||||
"id": 1,
|
||||
"info": 1,
|
||||
"logo_color": 1,
|
||||
"material_id": 1,
|
||||
"optional_id": 1,
|
||||
"size_id": 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/color_list"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/product/internal/svc"
|
||||
@@ -126,28 +126,28 @@ func (l *GetRenderSettingByPidLogic) checkRenderDesign(clientNo string) (bool, e
|
||||
// 查询是否存在最新设计
|
||||
func (l *GetRenderSettingByPidLogic) checkLastDesignExists(userId int64) (bool, error) {
|
||||
//查询用户最近下单成功的数据
|
||||
orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userId, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userId, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return false, nil
|
||||
// }
|
||||
// return false, err
|
||||
// }
|
||||
//获取该订单相关设计信息
|
||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
//获取设计模板详情,便于获得design_id
|
||||
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
return *orderDetailTemplate.DesignId > 0, nil
|
||||
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return false, nil
|
||||
// }
|
||||
// return false, err
|
||||
// }
|
||||
// //获取设计模板详情,便于获得design_id
|
||||
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return false, nil
|
||||
// }
|
||||
// return false, err
|
||||
// }
|
||||
return false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user