Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/debug-token

This commit is contained in:
eson
2023-10-18 10:23:12 +08:00
43 changed files with 1564 additions and 131 deletions

View File

@@ -11,7 +11,7 @@ type FsAdminRole struct {
RolePid *int64 `gorm:"default:0;" json:"role_pid"` // 上级角色
RoleName *string `gorm:"unique_key;default:'';" json:"role_name"` //
DataAuthType *int64 `gorm:"default:1;" json:"data_auth_type"` // 数据权限类型
DataAuth *string `gorm:"default:'';" json:"data_auth"` //
DataAuth *[]byte `gorm:"default:'';" json:"data_auth"` //
Status *int64 `gorm:"default:2;" json:"status"` // 状态:1=启用,2=停用
Remark *string `gorm:"default:'';" json:"remark"` //
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序权重

View File

@@ -11,6 +11,7 @@ type FsDepartment struct {
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1正常0停用
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
ParentId *int64 `gorm:"default:0;" json:"parent_id"` // 父级id
Manager *int64 `gorm:"default:0;" json:"manager"` // 负责人
}
type FsDepartmentModel struct {
db *gorm.DB

View File

@@ -7,9 +7,9 @@ import (
// fs_font 字体配置
type FsFont struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
Title *string `gorm:"default:'';" json:"title"` // 字体名字
Title *string `gorm:"default:'';" json:"title"` //
LinuxFontname *string `gorm:"default:'';" json:"linux_fontname"` // linux对应字体名
FilePath *string `gorm:"default:'';" json:"file_path"` // 字体文件路径
FilePath *string `gorm:"default:'';" json:"file_path"` //
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
}
type FsFontModel struct {

View File

@@ -25,6 +25,9 @@ type FsOrder struct {
PayStatusLink *[]byte `gorm:"default:'';" json:"pay_status_link"` //
ShoppingCartSnapshot *[]byte `gorm:"default:'';" json:"shopping_cart_snapshot"` //
ShoppingProductSnapshot *[]byte `gorm:"default:'';" json:"shopping_product_snapshot"` //
SaleGerentId *int64 `gorm:"default:0;" json:"sale_gerent_id"` // 销售负责人
DesignGerentId *int64 `gorm:"default:0;" json:"design_gerent_id"` // 设计负责人
Scm *[]byte `gorm:"default:'';" json:"scm"` //
}
type FsOrderModel struct {
db *gorm.DB

View File

@@ -19,9 +19,14 @@ type OrderDetail struct {
// 收货地址
type OrderAddress struct {
Address string `json:"address"` // 详细地址
Mobile string `json:"mobile"` // 手机
Name string `json:"name"` // 姓
Street string `json:"street"` // 详细地址
City string `json:"city"` // 城市
FirstName string `json:"first_name"` // 姓
LastName string `json:"last_name"` // 名
Mobile string `json:"mobile"` // 手机
State string `json:"state"` // 州
Suite string `json:"suite"` // 房号
ZipCode string `json:"zip_code"` // 邮编号码
}
// 订单金额

View File

@@ -25,6 +25,7 @@ type FsOrderTrade struct {
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
PayTitle *string `gorm:"default:'';" json:"pay_title"` //
ReceiptSn *string `gorm:"default:'';" json:"receipt_sn"` //
}
type FsOrderTradeModel struct {
db *gorm.DB

View File

@@ -37,6 +37,7 @@ type FsProduct struct {
SceneIds *string `gorm:"default:'';" json:"scene_ids"` //
IsCustomization *int64 `gorm:"default:0;" json:"is_customization"` // 是否可定制
Unit *string `gorm:"default:'';" json:"unit"` //
SupplyChainManager *int64 `gorm:"default:0;" json:"supply_chain_manager"` // 供应链负责人
}
type FsProductModel struct {
db *gorm.DB

View File

@@ -173,12 +173,7 @@ func (d *FsProductModel3dModel) GetAllByProductIdsTags(ctx context.Context, prod
}
// 获取每个产品最低价格
func (d *FsProductModel3dModel) GetProductMinPrice(ctx context.Context, productIds []int64, mapProductMinPrice map[int64]int64) error {
//获取产品模型价格列表
modelList, err := d.GetAllByProductIdsTags(ctx, productIds, []int{constants.TAG_MODEL, constants.TAG_PARTS}, "id,product_id,price,tag,part_id,step_price")
if err != nil {
return errors.New("failed to get model list")
}
func (d *FsProductModel3dModel) GetProductMinPrice(modelList []FsProductModel3d, mapProductMinPrice map[int64]int64) error {
mapModelMinPrice := make(map[int64]int64)
//每个模型/配件存储最小价格
for _, modelInfo := range modelList {
@@ -189,7 +184,7 @@ func (d *FsProductModel3dModel) GetProductMinPrice(ctx context.Context, productI
continue
}
var stepPrice StepPriceJsonStruct
if err = json.Unmarshal(*modelInfo.StepPrice, &stepPrice); err != nil {
if err := json.Unmarshal(*modelInfo.StepPrice, &stepPrice); err != nil {
return errors.New(fmt.Sprintf("failed to parse model step price:%d", modelInfo.Id))
}
lenRange := len(stepPrice.PriceRange)
@@ -226,3 +221,11 @@ func (d *FsProductModel3dModel) GetProductMinPrice(ctx context.Context, productI
}
return nil
}
func (d *FsProductModel3dModel) GetAllByProductIdTags(ctx context.Context, productId int64, tags []int64, fields ...string) (resp []FsProductModel3d, err error) {
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`product_id`= ? and `tag` in(?) and `status` = ?", productId, tags, 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Find(&resp).Error
return resp, err
}

View File

@@ -18,15 +18,16 @@ func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, prod
err = db.Find(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindAllByIds(ctx context.Context, ids []int64) (resp []FsProductTemplateV2, err error) {
func (t *FsProductTemplateV2Model) FindAllByIds(ctx context.Context, ids []int64, fields ...string) (resp []FsProductTemplateV2, err error) {
if len(ids) == 0 {
return
}
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", ids, 0, 1).Find(&resp).Error
if err != nil {
return nil, err
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` in (?) and `is_del` = ? and `status` = ?", ids, 0, 1)
if len(fields) != 0 {
db = db.Select(fields[0])
}
return
err = db.Find(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindAllByIdsWithoutStatus(ctx context.Context, ids []int64, fields ...string) (resp []FsProductTemplateV2, err error) {
if len(ids) == 0 {
@@ -179,3 +180,11 @@ func (t *FsProductTemplateV2Model) FindAllByProductIdsTemplateTag(ctx context.Co
err = db.Find(&resp).Error
return resp, err
}
func (t *FsProductTemplateV2Model) FindAllByFittingIds(ctx context.Context, fittingIds []int64, fields ...string) (resp []FsProductTemplateV2, err error) {
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in(?) and `status` = ? and `is_del` = ? ", fittingIds, 1, 0)
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Find(&resp).Error
return resp, err
}

View File

@@ -79,9 +79,9 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in
}
return info, nil
}
func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int64) (resp *FsUserInfo, err error) {
func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int64, module string) (resp *FsUserInfo, err error) {
if userId > 0 {
err = m.db.WithContext(ctx).Model(&FsUserInfo{}).Where("user_id = ?", userId).Take(&resp).Error
err = m.db.WithContext(ctx).Model(&FsUserInfo{}).Where("user_id = ? and module = ?", userId, module).Take(&resp).Error
} else {
err = m.db.WithContext(ctx).Model(&FsUserInfo{}).Where("user_id = ? and guest_id = ?", userId, guestId).Take(&resp).Error
}