Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
d4d11db732
|
@ -2,17 +2,12 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (a *FsAddressModel) GetOne(ctx context.Context, id int64, userId int64) (resp FsAddress, err error) {
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`id` = ? and `user_id` = ? and `status` = ? ", id, userId, 1).Take(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsAddress{}, err
|
||||
}
|
||||
return resp, nil
|
||||
func (a *FsAddressModel) GetOne(ctx context.Context, id int64, userId int64) (resp *FsAddress, err error) {
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`id` = ? and `user_id` = ? and `status` = ? ", id, userId, 1).Take(resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []FsAddress, err error) {
|
||||
|
|
|
@ -2,9 +2,6 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// FsGetTypeCanteenType GetType返回前端的结构
|
||||
|
@ -22,10 +19,7 @@ func (c *FsCanteenTypeModel) FindAllGetType(ctx context.Context) (resp []*FsGetT
|
|||
}
|
||||
return resp, nil
|
||||
}
|
||||
func (c *FsCanteenTypeModel) FindOne(ctx context.Context, id int64) (resp FsCanteenType, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Where("`id` = ?", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
func (c *FsCanteenTypeModel) FindOne(ctx context.Context, id int64) (resp *FsCanteenType, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCanteenType{}).Where("`id` = ?", id).First(resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FindOneCartByParamsReq struct {
|
||||
|
@ -18,14 +16,11 @@ type FindOneCartByParamsReq struct {
|
|||
Status *int64
|
||||
}
|
||||
|
||||
func (c *FsCartModel) FindOne(ctx context.Context, id int64) (resp FsCart, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsCart{}, err
|
||||
}
|
||||
return resp, nil
|
||||
func (c *FsCartModel) FindOne(ctx context.Context, id int64) (resp *FsCart, err error) {
|
||||
err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` = ?", id).First(resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartByParamsReq) (resp FsCart, err error) {
|
||||
func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartByParamsReq) (resp *FsCart, err error) {
|
||||
db := c.db.WithContext(ctx).Model(&FsCart{})
|
||||
if req.UserId != nil {
|
||||
db = db.Where("`user_id` = ?", req.UserId)
|
||||
|
@ -48,10 +43,11 @@ func (c *FsCartModel) FindOneCartByParams(ctx context.Context, req FindOneCartBy
|
|||
if req.Status != nil {
|
||||
db = db.Where("`status` = ?", req.Status)
|
||||
}
|
||||
if err = db.First(&resp).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsCart{}, err
|
||||
err = db.First(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
return
|
||||
}
|
||||
func (c *FsCartModel) Create(ctx context.Context, data FsCart) error {
|
||||
return c.db.WithContext(ctx).Model(&FsCart{}).Create(&data).Error
|
||||
|
|
|
@ -2,22 +2,19 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).Take(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsOrder{}, err
|
||||
}
|
||||
return resp, nil
|
||||
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).Take(resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) FindOne(ctx context.Context, userId int64, OrderId int64) (order FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&order).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(&order).Error
|
||||
return order, err
|
||||
func (o *FsOrderModel) FindOne(ctx context.Context, userId int64, OrderId int64) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&order).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(order).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) Update(ctx context.Context, data *FsOrder) error {
|
||||
|
|
|
@ -2,17 +2,11 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string, userId int64) (resp FsProductDesign, err error) {
|
||||
func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string, userId int64) (resp *FsProductDesign, err error) {
|
||||
err = d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ? and `user_id` = ? and `status` = ?", sn, userId, 1).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductDesign{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
func (d *FsProductDesignModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductDesign, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
|
|
@ -2,18 +2,15 @@ package gmodel
|
|||
|
||||
import "context"
|
||||
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64) (resp FsProduct, err error) {
|
||||
err = p.db.Model(&FsProduct{}).Where("`id` = ? and `is_del` =? and `is_shelf` = ? and `status` =?", id, 0, 1, 1).First(&resp).Error
|
||||
if err != nil {
|
||||
return FsProduct{}, err
|
||||
}
|
||||
return resp, nil
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64) (resp *FsProduct, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` = ? and `is_del` =? and `is_shelf` = ? and `status` =?", id, 0, 1, 1).First(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
|
||||
if len(productIds) == 0 {
|
||||
return
|
||||
}
|
||||
db := p.db.Model(&FsProduct{}).
|
||||
db := p.db.Model(&FsProduct{}).WithContext(ctx).
|
||||
Where("`id` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productIds, 0, 1, 1)
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
|
|
|
@ -2,16 +2,11 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (d *FsProductModel3dModel) FindOne(ctx context.Context, id int64) (resp FsProductModel3d, err error) {
|
||||
func (d *FsProductModel3dModel) FindOne(ctx context.Context, id int64) (resp *FsProductModel3d, err error) {
|
||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` = ? ", id).Find(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductModel3d{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
|
|
@ -2,16 +2,11 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (s *FsProductSizeModel) FindOne(ctx context.Context, id int64) (resp FsProductSize, err error) {
|
||||
func (s *FsProductSizeModel) FindOne(ctx context.Context, id int64) (resp *FsProductSize, err error) {
|
||||
err = s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`id` = ? ", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductSize{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
func (s *FsProductSizeModel) GetAllByIds(ctx context.Context, ids []int64, sort string) (resp []FsProductSize, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
|
|
@ -2,8 +2,6 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64) (resp []FsProductTemplateV2, err error) {
|
||||
|
@ -26,11 +24,8 @@ func (t *FsProductTemplateV2Model) FindAllByIds(ctx context.Context, ids []int64
|
|||
}
|
||||
return
|
||||
}
|
||||
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp FsProductTemplateV2, err error) {
|
||||
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp *FsProductTemplateV2, err error) {
|
||||
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Find(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsProductTemplateV2{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err error) {
|
||||
|
@ -14,10 +11,7 @@ func (q *FsQrcodeSetModel) GetAll(ctx context.Context) (resp []FsQrcodeSet, err
|
|||
}
|
||||
return
|
||||
}
|
||||
func (q *FsQrcodeSetModel) FindOne(ctx context.Context, id int64) (resp FsQrcodeSet, err error) {
|
||||
func (q *FsQrcodeSetModel) FindOne(ctx context.Context, id int64) (resp *FsQrcodeSet, err error) {
|
||||
err = q.db.WithContext(ctx).Model(&FsQrcodeSet{}).Where("`id` = ?", id).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsQrcodeSet{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
|
|
|
@ -2,17 +2,11 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (t *FsTagsModel) FindOne(ctx context.Context, id int64) (resp FsTags, err error) {
|
||||
func (t *FsTagsModel) FindOne(ctx context.Context, id int64) (resp *FsTags, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsTags{}).Where("`id` = ? and `status` = ?", id, 1).First(&resp).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return FsTags{}, err
|
||||
}
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
func (t *FsTagsModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsTags, err error) {
|
||||
if len(ids) == 0 {
|
||||
|
|
|
@ -2,12 +2,14 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/canteen/internal/svc"
|
||||
"fusenapi/server/canteen/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -35,12 +37,12 @@ func (l *GetCanteenDetailLogic) GetCanteenDetail(req *types.GetCanteenDetailReq,
|
|||
canteenTypeModel := gmodel.NewFsCanteenTypeModel(l.svcCtx.MysqlConn)
|
||||
canteenTypeInfo, err := canteenTypeModel.FindOne(l.ctx, req.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "canteen type is not exists ")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get canteen type info ")
|
||||
}
|
||||
if canteenTypeInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "canteen type is not exists ")
|
||||
}
|
||||
//获取餐厅类型关联的所有产品
|
||||
canteenProductModel := gmodel.NewFsCanteenProductModel(l.svcCtx.MysqlConn)
|
||||
canteenProductList, err := canteenProductModel.GetAllByCanteenTypeId(l.ctx, req.Id)
|
||||
|
|
|
@ -2,6 +2,7 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/data-transfer/internal/svc"
|
||||
"fusenapi/server/data-transfer/internal/types"
|
||||
|
@ -9,6 +10,7 @@ import (
|
|||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/qrcode"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -41,12 +43,12 @@ func (l *UploadQrcodeLogic) UploadQrcode(req *types.UploadQrcodeReq, userinfo *a
|
|||
qrCodeModel := gmodel.NewFsQrcodeSetModel(l.svcCtx.MysqlConn)
|
||||
qrCodeSet, err := qrCodeModel.FindOne(l.ctx, req.QRcodeType)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "qrcode setting is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get qrcode setting")
|
||||
}
|
||||
if qrCodeSet.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "qrcode setting is not exists")
|
||||
}
|
||||
qrType := *qrCodeSet.SvgWebsite
|
||||
if strings.Contains(req.Url, "www.instagram.com") {
|
||||
qrType = *qrCodeSet.SvgInstagram
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -38,42 +40,42 @@ func (l *GetProductDesignLogic) GetProductDesign(req *types.GetProductDesignReq,
|
|||
productDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
designInfo, err := productDesignModel.FindOneBySn(l.ctx, req.Sn, userinfo.UserId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "design info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get design info")
|
||||
}
|
||||
if designInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "design info is not exists")
|
||||
}
|
||||
//获取产品尺寸信息
|
||||
productSizeModel := gmodel.NewFsProductSizeModel(l.svcCtx.MysqlConn)
|
||||
sizeInfo, err := productSizeModel.FindOne(l.ctx, *designInfo.SizeId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "product size info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product size info")
|
||||
}
|
||||
if sizeInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "product size info is not exists")
|
||||
}
|
||||
//获取模板信息
|
||||
productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
|
||||
productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, *designInfo.TemplateId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get template info")
|
||||
}
|
||||
if productTemplateV2Info.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info is not exists")
|
||||
}
|
||||
//获取产品模型信息
|
||||
productModel3dModel := gmodel.NewFsProductModel3dModel(l.svcCtx.MysqlConn)
|
||||
model3dInfo, err := productModel3dModel.FindOne(l.ctx, *designInfo.OptionalId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product 3D model info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product 3D model info")
|
||||
}
|
||||
if model3dInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product 3D model info is not exists")
|
||||
}
|
||||
optionalId := *designInfo.OptionalId
|
||||
if *model3dInfo.Status == 0 && *sizeInfo.Status == 1 && *productTemplateV2Info.Status == 1 && *productTemplateV2Info.IsDel == 0 {
|
||||
optionalId = 0
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"fusenapi/utils/image"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"gorm.io/gorm"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
@ -115,12 +116,12 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
|
|||
tagsModel := gmodel.NewFsTagsModel(l.svcCtx.MysqlConn)
|
||||
tagInfo, err := tagsModel.FindOne(l.ctx, req.Cid)
|
||||
if err != nil && !errors.Is(err, sqlc.ErrNotFound) {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "tag is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get tag err")
|
||||
}
|
||||
if tagInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "tag is not exists")
|
||||
}
|
||||
//获取产品尺寸数量
|
||||
productSizeModel := gmodel.NewFsProductSizeModel(l.svcCtx.MysqlConn)
|
||||
productSizeCount, err := productSizeModel.CountByStatus(l.ctx, 1)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -48,12 +50,12 @@ func (l *CartAddLogic) CartAdd(req *types.CartAddReq, userinfo *auth.UserInfo) (
|
|||
productDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
productDesignInfo, err := productDesignModel.FindOneBySn(l.ctx, req.DesignId, userinfo.UserId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "design info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product design info")
|
||||
}
|
||||
if productDesignInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "product design info is not exists")
|
||||
}
|
||||
//查找是否有此材质、产品、大小id的阶梯价格
|
||||
productPriceModel := gmodel.NewFsProductPriceModel(l.svcCtx.MysqlConn)
|
||||
priceStatus := int64(1)
|
||||
|
@ -94,7 +96,7 @@ func (l *CartAddLogic) CartAdd(req *types.CartAddReq, userinfo *auth.UserInfo) (
|
|||
Status: &cartStatus,
|
||||
}
|
||||
cartInfo, err := cartModel.FindOneCartByParams(l.ctx, cartReq)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get cart info")
|
||||
}
|
||||
|
@ -116,7 +118,7 @@ func (l *CartAddLogic) CartAdd(req *types.CartAddReq, userinfo *auth.UserInfo) (
|
|||
IsCheck: &req.IsCheck,
|
||||
TsTime: &nowTime,
|
||||
}
|
||||
if cartInfo.Id == 0 {
|
||||
if cartInfo == nil {
|
||||
err = cartModel.Create(l.ctx, data)
|
||||
} else {
|
||||
err = cartModel.Update(l.ctx, cartInfo.Id, data)
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -42,12 +44,12 @@ func (l *CartOrderDetailLogic) CartOrderDetail(req *types.CartOrderDetailReq, 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.CodeServiceErr, "the order is not exists")
|
||||
}
|
||||
//获取订单详细数据
|
||||
orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
orderDetailList, err := orderDetailModel.GetOrderDetailsByOrderId(l.ctx, orderInfo.Id)
|
||||
|
|
|
@ -2,9 +2,11 @@ package logic
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
|
||||
"context"
|
||||
|
@ -41,12 +43,12 @@ func (l *ChangeOrderMethodLogic) ChangeOrderMethod(req *types.ChangeOrderMethodR
|
|||
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.CodeServiceErr, "the order is not exists")
|
||||
}
|
||||
if *orderInfo.PayedAmount > 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeApiErr, "the order`s address cannot be changed for it is paid")
|
||||
}
|
||||
|
@ -56,12 +58,12 @@ func (l *ChangeOrderMethodLogic) ChangeOrderMethod(req *types.ChangeOrderMethodR
|
|||
addressModel := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
||||
addr, err := addressModel.GetOne(l.ctx, req.AddressId, userinfo.UserId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "address is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
|
||||
}
|
||||
if addr.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "address is not exists")
|
||||
}
|
||||
infoJsonByte, _ := json.Marshal(addr)
|
||||
strInfoJson := string(infoJsonByte)
|
||||
updData.AddressInfo = &strInfoJson
|
||||
|
|
Loading…
Reference in New Issue
Block a user