支付成功通知
This commit is contained in:
@@ -87,3 +87,10 @@ func (c *FsCartModel) GetUserCartsByIds(ctx context.Context, userId int64, ids [
|
||||
err = c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` in (?) and `user_id` = ?", ids, userId).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *FsCartModel) DeleteCartsByIds(ctx context.Context, ids []int64) ( err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
return c.db.WithContext(ctx).Model(&FsCart{}).Where("`id` in (?)", ids).Delete(&FsCart{}).Error
|
||||
}
|
||||
|
||||
@@ -136,6 +136,21 @@ func (m *FsOrderModel) FindCount(ctx context.Context, countBuilder *gorm.DB, fil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) FindOneByQuery(ctx context.Context, rowBuilder *gorm.DB, filterMap map[string]string) (*FsOrderRel, error) {
|
||||
var resp FsOrderRel
|
||||
|
||||
if filterMap != nil {
|
||||
rowBuilder = rowBuilder.Scopes(handler.FilterData(filterMap))
|
||||
}
|
||||
|
||||
result := rowBuilder.WithContext(ctx).Limit(1).Find(&resp)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
} else {
|
||||
return &resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 事务
|
||||
func (m *FsOrderModel) Trans(ctx context.Context, fn func(ctx context.Context, connGorm *gorm.DB) error) error {
|
||||
tx := m.db.Table(m.name).WithContext(ctx).Begin()
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package gmodel
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
"fusenapi/utils/handler"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (p *FsPayModel) GetListByOrderNumber(ctx context.Context, sn string) (resp []FsPay, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsPay{}).Where("`order_number` = ? ", sn).Find(&resp).Error
|
||||
@@ -33,6 +38,69 @@ func (p *FsPayModel) CreateOrUpdate(ctx context.Context, req *FsPay) (resp *FsPa
|
||||
return req, err
|
||||
}
|
||||
|
||||
func (m *FsPayModel) RowSelectBuilder(selectData []string) *gorm.DB {
|
||||
var rowBuilder = m.db.Table(m.name)
|
||||
|
||||
if selectData != nil {
|
||||
rowBuilder = rowBuilder.Select(selectData)
|
||||
} else {
|
||||
rowBuilder = rowBuilder.Select("*")
|
||||
}
|
||||
return rowBuilder
|
||||
}
|
||||
|
||||
func (m *FsPayModel) FindCount(ctx context.Context, countBuilder *gorm.DB, filterMap map[string]string) (int64, error) {
|
||||
var count int64
|
||||
|
||||
// 过滤
|
||||
if filterMap != nil {
|
||||
countBuilder = countBuilder.Scopes(handler.FilterData(filterMap))
|
||||
}
|
||||
|
||||
result := countBuilder.WithContext(ctx).Limit(1).Count(&count)
|
||||
if result.Error != nil {
|
||||
return 0, result.Error
|
||||
} else {
|
||||
return count, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *FsPayModel) FindOneByQuery(ctx context.Context, rowBuilder *gorm.DB, filterMap map[string]string) (*FsPay, error) {
|
||||
var resp FsPay
|
||||
|
||||
if filterMap != nil {
|
||||
rowBuilder = rowBuilder.Scopes(handler.FilterData(filterMap))
|
||||
}
|
||||
|
||||
result := rowBuilder.WithContext(ctx).Limit(1).Find(&resp)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
} else {
|
||||
return &resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 事务
|
||||
func (m *FsPayModel) Trans(ctx context.Context, fn func(ctx context.Context, connGorm *gorm.DB) error) error {
|
||||
tx := m.db.Table(m.name).WithContext(ctx).Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := tx.Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := fn(ctx, tx); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.Commit().Error
|
||||
}
|
||||
|
||||
func (m *FsPayModel) TableName() string {
|
||||
return m.name
|
||||
}
|
||||
|
||||
@@ -35,6 +35,10 @@ func (d *FsProductDesignModel) UpdateBySn(ctx context.Context, sn string, data *
|
||||
return d.db.WithContext(ctx).Model(&FsProductDesign{}).Where("`sn` = ?", sn).Updates(&data).Error
|
||||
}
|
||||
|
||||
func (d *FsProductDesignModel) UpdateByIds(ctx context.Context, ids []int64, data *FsProductDesign) error {
|
||||
return d.db.Table(d.name).WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in ?", ids).Updates(&data).Error
|
||||
}
|
||||
|
||||
func (m *FsProductDesignModel) TableName() string {
|
||||
return m.name
|
||||
}
|
||||
|
||||
26
model/gmodel/fs_resources_gen.go
Normal file
26
model/gmodel/fs_resources_gen.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_resources 资源表
|
||||
type FsResources struct {
|
||||
ResourceId string `gorm:"primary_key;default:'';" json:"resource_id"` // 资源 ID
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户 ID
|
||||
GuestId *int64 `gorm:"index;default:0;" json:"guest_id"` // 访客 ID
|
||||
ResourceType *string `gorm:"index;default:'';" json:"resource_type"` // 资源类型
|
||||
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL
|
||||
UploadedAt *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"uploaded_at"` // 上传时间
|
||||
Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率
|
||||
MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加
|
||||
}
|
||||
type FsResourcesModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsResourcesModel(db *gorm.DB) *FsResourcesModel {
|
||||
return &FsResourcesModel{db: db, name: "fs_resources"}
|
||||
}
|
||||
2
model/gmodel/fs_resources_logic.go
Normal file
2
model/gmodel/fs_resources_logic.go
Normal file
@@ -0,0 +1,2 @@
|
||||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
||||
@@ -30,7 +30,7 @@ type FsUser struct {
|
||||
IsPhoneAdvertisement *int64 `gorm:"default:0;" json:"is_phone_advertisement"` // 是否接收短信广告
|
||||
IsOpenRender *int64 `gorm:"default:0;" json:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭)
|
||||
IsThousandFace *int64 `gorm:"default:0;" json:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在)
|
||||
IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` //
|
||||
IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` // 是否开启低渲染模型渲染
|
||||
IsRemoveBg *int64 `gorm:"default:1;" json:"is_remove_bg"` // 用户上传logo是否去除背景
|
||||
}
|
||||
type FsUserModel struct {
|
||||
|
||||
@@ -79,6 +79,7 @@ type AllModelsGen struct {
|
||||
FsQuotationRemarkTemplate *FsQuotationRemarkTemplateModel // fs_quotation_remark_template 报价单备注模板
|
||||
FsQuotationSaler *FsQuotationSalerModel // fs_quotation_saler 报价单业务员表
|
||||
FsRefundReason *FsRefundReasonModel // fs_refund_reason
|
||||
FsResources *FsResourcesModel // fs_resources 资源表
|
||||
FsStandardLogo *FsStandardLogoModel // fs_standard_logo 标准logo
|
||||
FsTags *FsTagsModel // fs_tags 产品分类表
|
||||
FsToolLogs *FsToolLogsModel // fs_tool_logs 3d设计工具日志表
|
||||
@@ -169,6 +170,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
||||
FsQuotationRemarkTemplate: NewFsQuotationRemarkTemplateModel(gdb),
|
||||
FsQuotationSaler: NewFsQuotationSalerModel(gdb),
|
||||
FsRefundReason: NewFsRefundReasonModel(gdb),
|
||||
FsResources: NewFsResourcesModel(gdb),
|
||||
FsStandardLogo: NewFsStandardLogoModel(gdb),
|
||||
FsTags: NewFsTagsModel(gdb),
|
||||
FsToolLogs: NewFsToolLogsModel(gdb),
|
||||
|
||||
Reference in New Issue
Block a user