@@ -1,6 +1,6 @@ | |||
# 多重构建,减少镜像大小 | |||
# 构建:使用golang:1.15版本 | |||
FROM golang:1.15 as build | |||
# 构建:使用golang:1.18版本 | |||
FROM registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/golang:1.18.4 as build | |||
# 容器环境变量添加,会覆盖默认的变量值 | |||
ENV GO111MODULE=on | |||
@@ -16,7 +16,7 @@ ADD . . | |||
RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o zyos_mall_task cmd/task/main.go | |||
FROM ubuntu:xenial as prod | |||
LABEL maintainer="wuhanqin" | |||
LABEL maintainer="dengbiao" | |||
ENV TZ="Asia/Shanghai" | |||
COPY static/html static/html | |||
@@ -25,10 +25,10 @@ RUN rm -f /etc/localtime \ | |||
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | |||
&& echo "Asia/Shanghai" > /etc/timezone | |||
# 在build阶段复制可执行的go二进制文件app | |||
COPY --from=build /go/release/zyos_mall_task ./zyos_mall_task | |||
COPY --from=build /go/release/zyos ./zyos | |||
COPY --from=build /go/release/etc/task.yml /var/zyos/task.yml | |||
COPY --from=build /go/release/etc/cfg.yml /var/zyos/cfg.yml | |||
# 启动服务 | |||
CMD ["./zyos_mall_task","-c","/var/zyos/task.yml"] | |||
CMD ["./zyos","-c","/var/zyos/cfg.yml"] | |||
@@ -15,6 +15,7 @@ type Config struct { | |||
RabbitMqAddrTest string `yaml:"rabbitMq_addr_test"` | |||
DB DBCfg `yaml:"db"` | |||
MQ MQCfg `yaml:"mq"` | |||
ES ESCfg `yaml:"es"` | |||
Log LogCfg `yaml:"log"` | |||
ArkID ArkIDCfg `yaml:"arkid"` | |||
Admin AdminCfg `yaml:"admin"` | |||
@@ -73,6 +74,12 @@ type MQCfg struct { | |||
Pwd string `yaml:"pwd"` | |||
} | |||
type ESCfg struct { | |||
Url string `yaml:"url"` | |||
User string `yaml:"user"` | |||
Pwd string `yaml:"pwd"` | |||
} | |||
//日志配置结构体 | |||
type LogCfg struct { | |||
AppName string `yaml:"app_name" ` | |||
@@ -16,6 +16,7 @@ var ( | |||
RedisAddr string | |||
DB *DBCfg | |||
MQ *MQCfg | |||
ES *ESCfg | |||
Log *LogCfg | |||
ArkID *ArkIDCfg | |||
Admin *AdminCfg | |||
@@ -66,4 +67,5 @@ func InitCfg() { | |||
RabbitMqAddr = conf.RabbitMqAddr | |||
} | |||
MQ = &conf.MQ | |||
ES = &conf.ES | |||
} |
@@ -0,0 +1,12 @@ | |||
package cfg | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" | |||
"encoding/json" | |||
) | |||
func InitEs() { | |||
data, _ := json.Marshal(ES) | |||
filePutContents("init_rabbit_es", string(data)) | |||
es.Init(ES.Url, ES.User, ES.Pwd) | |||
} |
@@ -1,6 +1,7 @@ | |||
package db | |||
import ( | |||
"applet/app/utils/logx" | |||
"database/sql" | |||
"fmt" | |||
"os" | |||
@@ -11,7 +12,6 @@ import ( | |||
"xorm.io/xorm/log" | |||
"applet/app/cfg" | |||
"applet/app/utils/logx" | |||
) | |||
var Db *xorm.Engine | |||
@@ -70,6 +70,10 @@ func QueryNativeString(Db *xorm.Engine, sql string, args ...interface{}) ([]map[ | |||
results, err := Db.SQL(sql, args...).QueryString() | |||
return results, err | |||
} | |||
func QueryNativeStringWithSession(session *xorm.Session, sql string, args ...interface{}) ([]map[string]string, error) { | |||
results, err := session.SQL(sql, args...).QueryString() | |||
return results, err | |||
} | |||
// UpdateComm common update | |||
func UpdateComm(Db *xorm.Engine, id interface{}, model interface{}) (int64, error) { | |||
@@ -83,16 +87,6 @@ func InsertComm(Db *xorm.Engine, model interface{}) (int64, error) { | |||
return row, err | |||
} | |||
// ExecuteOriginalSql 执行原生sql | |||
func ExecuteOriginalSql(session *xorm.Session, sql string) (sql.Result, error) { | |||
result, err := session.Exec(sql) | |||
if err != nil { | |||
_ = logx.Warn(err) | |||
return nil, err | |||
} | |||
return result, nil | |||
} | |||
// GetComm | |||
// payload *model | |||
// return *model,has,err | |||
@@ -110,3 +104,13 @@ func InsertCommWithSession(session *xorm.Session, model interface{}) (int64, err | |||
row, err := session.InsertOne(model) | |||
return row, err | |||
} | |||
// ExecuteOriginalSql 执行原生sql | |||
func ExecuteOriginalSql(session *xorm.Session, sql string) (sql.Result, error) { | |||
result, err := session.Exec(sql) | |||
if err != nil { | |||
_ = logx.Warn(err) | |||
return nil, err | |||
} | |||
return result, nil | |||
} |
@@ -1,16 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
//UserProfileFindByArkID is get userprofile by arkid | |||
func CapitalPoolByIsUse(Db *xorm.Engine) (*model.CapitalPool, error) { | |||
var m model.CapitalPool | |||
if has, err := Db.Where("is_use = 1").Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} |
@@ -0,0 +1,92 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/md" | |||
"applet/app/utils/cache" | |||
"applet/app/utils/logx" | |||
) | |||
func CityGetAll() (*[]model.City, error) { | |||
var CityList []model.City | |||
if err := Db.Cols("id,name").Find(&CityList); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &CityList, nil | |||
} | |||
// 获取一条记录 | |||
func CityGetOne(key string) (*model.City, error) { | |||
var City model.City | |||
if has, err := Db.Where("`id`=?", key).Get(&City); err != nil || has == false { | |||
if has == false { | |||
return &City, nil | |||
} | |||
return nil, logx.Error(err) | |||
} | |||
return &City, nil | |||
} | |||
//单条记录获取DB | |||
func CityGetWithDb(HKey string) string { | |||
cacheKey := md.OfficialCityCacheKey | |||
get, err := cache.HGetString(cacheKey, HKey) | |||
if err != nil || get == "" { | |||
City, err := CityGetOne(HKey) | |||
if err != nil || City == nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
// key是否存在 | |||
cacheKeyExist := false | |||
if cache.Exists(cacheKey) { | |||
cacheKeyExist = true | |||
} | |||
// 设置缓存 | |||
_, err = cache.HSet(cacheKey, HKey, City.Name) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
if !cacheKeyExist { // 如果是首次设置 设置过期时间 | |||
_, err := cache.Expire(cacheKey, md.CfgCacheTime) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
} | |||
return City.Name | |||
} | |||
return get | |||
} | |||
func CityFindWithDb(keys ...string) map[string]string { | |||
res := map[string]string{} | |||
cacheKey := md.OfficialCityCacheKey | |||
err := cache.GetJson(cacheKey, &res) | |||
if err != nil || len(res) == 0 { | |||
CityList, _ := CityGetAll() | |||
if CityList == nil { | |||
return nil | |||
} | |||
for _, v := range *CityList { | |||
res[v.Id] = v.Name | |||
} | |||
cache.SetJson(cacheKey, res, md.CfgCacheTime) | |||
} | |||
if len(keys) == 0 { | |||
return res | |||
} | |||
tmp := map[string]string{} | |||
for _, v := range keys { | |||
if val, ok := res[v]; ok { | |||
tmp[v] = val | |||
} else { | |||
tmp[v] = "" | |||
} | |||
} | |||
return tmp | |||
} |
@@ -1,40 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"errors" | |||
"xorm.io/xorm" | |||
) | |||
// GetCloudBundleByVersion is 根据版本 获取打包记录 | |||
func GetCloudBundleByVersion(Db *xorm.Engine, appverison string, os int) (*model.CloudBundle, error) { | |||
m := new(model.CloudBundle) | |||
has, err := Db.Where("version = ? and os = ?", appverison, os).Get(m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !has { | |||
return nil, errors.New("not Found") | |||
} | |||
return m, nil | |||
} | |||
// GetCloudBundleByVersionPlatform is 根据版本\os 获取打包记录 | |||
func GetCloudBundleByVersionPlatform(Db *xorm.Engine, appverison string, platform string) (*model.CloudBundle, error) { | |||
m := new(model.CloudBundle) | |||
var tag int | |||
if platform == "ios" { | |||
tag = 2 | |||
} else { | |||
tag = 1 | |||
} | |||
has, err := Db.Where("version = ? and os=?", appverison, tag).Get(m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !has { | |||
return nil, errors.New("not Found") | |||
} | |||
return m, nil | |||
} |
@@ -0,0 +1,92 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/md" | |||
"applet/app/utils/cache" | |||
"applet/app/utils/logx" | |||
) | |||
func CountyGetAll() (*[]model.County, error) { | |||
var CountyList []model.County | |||
if err := Db.Cols("id,name").Find(&CountyList); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &CountyList, nil | |||
} | |||
// 获取一条记录 | |||
func CountyGetOne(key string) (*model.County, error) { | |||
var County model.County | |||
if has, err := Db.Where("`id`=?", key).Get(&County); err != nil || has == false { | |||
if has == false { | |||
return &County, nil | |||
} | |||
return nil, logx.Error(err) | |||
} | |||
return &County, nil | |||
} | |||
//单条记录获取DB | |||
func CountyGetWithDb(HKey string) string { | |||
cacheKey := md.OfficialCountyCacheKey | |||
get, err := cache.HGetString(cacheKey, HKey) | |||
if err != nil || get == "" { | |||
County, err := CountyGetOne(HKey) | |||
if err != nil || County == nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
// key是否存在 | |||
cacheKeyExist := false | |||
if cache.Exists(cacheKey) { | |||
cacheKeyExist = true | |||
} | |||
// 设置缓存 | |||
_, err = cache.HSet(cacheKey, HKey, County.Name) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
if !cacheKeyExist { // 如果是首次设置 设置过期时间 | |||
_, err := cache.Expire(cacheKey, md.CfgCacheTime) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
} | |||
return County.Name | |||
} | |||
return get | |||
} | |||
func CountyFindWithDb(keys ...string) map[string]string { | |||
res := map[string]string{} | |||
cacheKey := md.OfficialCountyCacheKey | |||
err := cache.GetJson(cacheKey, &res) | |||
if err != nil || len(res) == 0 { | |||
CountyList, _ := CountyGetAll() | |||
if CountyList == nil { | |||
return nil | |||
} | |||
for _, v := range *CountyList { | |||
res[v.Id] = v.Name | |||
} | |||
cache.SetJson(cacheKey, res, md.CfgCacheTime) | |||
} | |||
if len(keys) == 0 { | |||
return res | |||
} | |||
tmp := map[string]string{} | |||
for _, v := range keys { | |||
if val, ok := res[v]; ok { | |||
tmp[v] = val | |||
} else { | |||
tmp[v] = "" | |||
} | |||
} | |||
return tmp | |||
} |
@@ -1,33 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
// 通过文件名目录与文件名查找文件 | |||
func FileGetByPFidAndName(Db *xorm.Engine, dirId, fname string) (*model.SysFile, error) { | |||
var f model.SysFile | |||
if has, err := Db.Where("parent_fid = ? AND show_name = ?", dirId, fname).Get(&f); !has || err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &f, nil | |||
} | |||
// 插入文件信息 | |||
func FileInsert(Db *xorm.Engine, f *model.SysFile) error { | |||
if _, err := Db.InsertOne(f); err != nil { | |||
return logx.Warn(err) | |||
} | |||
return nil | |||
} | |||
// 文件信息更新 | |||
func FileUpdate(Db *xorm.Engine, f *model.SysFile) error { | |||
if _, err := Db.Where("`fid` = ?", f.Fid).Update(f); err != nil { | |||
return logx.Warn(err) | |||
} | |||
return nil | |||
} |
@@ -0,0 +1,92 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/md" | |||
"applet/app/utils/cache" | |||
"applet/app/utils/logx" | |||
) | |||
func ProvinceGetAll() (*[]model.Province, error) { | |||
var provinceList []model.Province | |||
if err := Db.Cols("id,name").Find(&provinceList); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &provinceList, nil | |||
} | |||
// 获取一条记录 | |||
func ProvinceGetOne(key string) (*model.Province, error) { | |||
var province model.Province | |||
if has, err := Db.Where("`id`=?", key).Get(&province); err != nil || has == false { | |||
if has == false { | |||
return &province, nil | |||
} | |||
return nil, logx.Error(err) | |||
} | |||
return &province, nil | |||
} | |||
//单条记录获取DB | |||
func ProvinceGetWithDb(HKey string) string { | |||
cacheKey := md.OfficialProvinceCacheKey | |||
get, err := cache.HGetString(cacheKey, HKey) | |||
if err != nil || get == "" { | |||
province, err := ProvinceGetOne(HKey) | |||
if err != nil || province == nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
// key是否存在 | |||
cacheKeyExist := false | |||
if cache.Exists(cacheKey) { | |||
cacheKeyExist = true | |||
} | |||
// 设置缓存 | |||
_, err = cache.HSet(cacheKey, HKey, province.Name) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
if !cacheKeyExist { // 如果是首次设置 设置过期时间 | |||
_, err := cache.Expire(cacheKey, md.CfgCacheTime) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
} | |||
return province.Name | |||
} | |||
return get | |||
} | |||
func ProvinceFindWithDb(keys ...string) map[string]string { | |||
res := map[string]string{} | |||
cacheKey := md.OfficialProvinceCacheKey | |||
err := cache.GetJson(cacheKey, &res) | |||
if err != nil || len(res) == 0 { | |||
provinceList, _ := ProvinceGetAll() | |||
if provinceList == nil { | |||
return nil | |||
} | |||
for _, v := range *provinceList { | |||
res[v.Id] = v.Name | |||
} | |||
cache.SetJson(cacheKey, res, md.CfgCacheTime) | |||
} | |||
if len(keys) == 0 { | |||
return res | |||
} | |||
tmp := map[string]string{} | |||
for _, v := range keys { | |||
if val, ok := res[v]; ok { | |||
tmp[v] = val | |||
} else { | |||
tmp[v] = "" | |||
} | |||
} | |||
return tmp | |||
} |
@@ -1,43 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
type AgentBase struct { | |||
Session *xorm.Session | |||
AgentBase *model.RegionalAgentBase | |||
} | |||
func NewAgentBase(session *xorm.Session, agentBase *model.RegionalAgentBase) *AgentBase { | |||
return &AgentBase{ | |||
Session: session, | |||
AgentBase: agentBase, | |||
} | |||
} | |||
func (a AgentBase) GetAgentBaseInfo() bool { | |||
isHas, err := a.Session.Get(a.AgentBase) | |||
if err != nil { | |||
return false | |||
} | |||
if !isHas { | |||
return false | |||
} | |||
return true | |||
} | |||
// GetCountByRegionalAgentBase 通过传入的参数查询数据(单条) | |||
func GetCountByRegionalAgentBase(Db *xorm.Engine) (*model.RegionalAgentBase, error) { | |||
var m model.RegionalAgentBase | |||
get, err := Db.Get(&m) | |||
if err != nil { | |||
return &m, err | |||
} | |||
if !get { | |||
return &m, logx.Warn("Not found") | |||
} | |||
return &m, nil | |||
} |
@@ -0,0 +1,192 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"errors" | |||
"fmt" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
// BatchSelectRegionalAgentRegions 批量查询数据 TODO::和下面的方法重复了,建议采用下面的 `RegionalAgentRegionFindByParams` 方法 | |||
func BatchSelectRegionalAgentRegions(Db *xorm.Engine, params map[string]interface{}) (*[]model.RegionalAgentRegion, error) { | |||
var regionalAgentRegionData []model.RegionalAgentRegion | |||
if err := Db.In(utils.AnyToString(params["key"]), params["value"]). | |||
Find(®ionalAgentRegionData); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return ®ionalAgentRegionData, nil | |||
} | |||
// RegionalAgentRegionInsert 插入单条数据 | |||
func RegionalAgentRegionInsert(Db *xorm.Engine, regionalAgentRegion *model.RegionalAgentRegion) (int64, error) { | |||
_, err := Db.InsertOne(regionalAgentRegion) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return regionalAgentRegion.Id, nil | |||
} | |||
// BatchAddRegionalAgentRegions 批量新增数据 | |||
func BatchAddRegionalAgentRegions(Db *xorm.Engine, regionalAgentRegionData []*model.RegionalAgentRegion) (int64, error) { | |||
affected, err := Db.Insert(regionalAgentRegionData) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func GetRegionalAgentRegionCount(Db *xorm.Engine) int { | |||
var regionalAgentRegion model.RegionalAgentRegion | |||
session := Db.Where("") | |||
count, err := session.Count(®ionalAgentRegion) | |||
if err != nil { | |||
return 0 | |||
} | |||
return int(count) | |||
} | |||
// RegionalAgentRegionDelete 删除记录 | |||
func RegionalAgentRegionDelete(Db *xorm.Engine, id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.RegionalAgentRegion{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.RegionalAgentRegion{}) | |||
} | |||
} | |||
// RegionalAgentRegionUpdate 更新记录 | |||
func RegionalAgentRegionUpdate(Db *xorm.Engine, id interface{}, regionalAgentRegion *model.RegionalAgentRegion, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = Db.Where("id=?", id).Cols(forceColums...).Update(regionalAgentRegion) | |||
} else { | |||
affected, err = Db.Where("id=?", id).Update(regionalAgentRegion) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
// RegionalAgentRegionGetOneByParams 通过传入的参数查询数据(单条) | |||
func RegionalAgentRegionGetOneByParams(Db *xorm.Engine, params map[string]interface{}) (*model.RegionalAgentRegion, error) { | |||
var m model.RegionalAgentRegion | |||
var query = fmt.Sprintf("%s =?", params["key"]) | |||
if has, err := Db.Where(query, params["value"]).Get(&m); err != nil || has == false { | |||
return nil, logx.Error(err) | |||
} | |||
return &m, nil | |||
} | |||
// RegionalAgentRegionFindByParams 通过传入的参数查询数据(多条) | |||
func RegionalAgentRegionFindByParams(Db *xorm.Engine, params map[string]interface{}) (*[]model.RegionalAgentRegion, error) { | |||
var m []model.RegionalAgentRegion | |||
if params["value"] == nil { | |||
return nil, errors.New("参数有误") | |||
} | |||
if params["key"] == nil { | |||
//查询全部数据 | |||
err := Db.Find(&m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &m, nil | |||
} else { | |||
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice { | |||
//指定In查询 | |||
if err := Db.In(utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} else { | |||
var query = fmt.Sprintf("%s =?", params["key"]) | |||
err := Db.Where(query, params["value"]).Find(&m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &m, nil | |||
} | |||
} | |||
} | |||
// RegionalAgentRegionFindByLevel 查询等级数据(多条) | |||
//func RegionalAgentRegionFindByLevel(level int) (*[]model.RegionalAgentRegion, error) { | |||
// var m []model.RegionalAgentRegion | |||
// | |||
//} | |||
// 根据经纬度获取网点 | |||
// lng float64 经度 | |||
// lat float64 维度 | |||
func GetSelectedSiteWithLatLng(engine *xorm.Engine, lng, lat float64, page, pageSize string, scopeOfBranches int) (*[]model.RegionalAgentRegion, error) { | |||
var regions []model.RegionalAgentRegion | |||
where := `sqrt( ( (( %f - longitude)*PI()*12656*cos((( %f +latitude)/2)*PI()/180)/180) * (( %f - longitude)*PI()*12656*cos (((%f+latitude)/2)*PI()/180)/180) ) + ( ((%f-latitude)*PI()*12656/180) * ((%f-latitude)*PI()*12656/180) ) ) < ` + utils.IntToStr(scopeOfBranches) | |||
where = fmt.Sprintf(where, lng, lat, lng, lat, lat, lat) | |||
if page == "" && pageSize == "" { | |||
err := engine.Where(where).Find(®ions) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return ®ions, nil | |||
} | |||
p := utils.StrToInt(page) // 页码 | |||
ps := utils.StrToInt(pageSize) // 每页记录数 | |||
err := engine.Where(where).Limit(ps, (p-1)*ps).Find(®ions) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return ®ions, nil | |||
} | |||
// 根据经纬度获取最近的网点 | |||
// lng float64 经度 | |||
// lat float64 维度 | |||
func GetSelectedSiteWithLatLngNearClose(engine *xorm.Engine, lng, lat float64, scopeOfBranches int) (*model.RegionalAgentRegion, error) { | |||
var region model.RegionalAgentRegion | |||
where := `sqrt( ( (( %f - longitude)*PI()*12656*cos((( %f +latitude)/2)*PI()/180)/180) * (( %f - longitude)*PI()*12656*cos (((%f+latitude)/2)*PI()/180)/180) ) + ( ((%f-latitude)*PI()*12656/180) * ((%f-latitude)*PI()*12656/180) ) ) < ` + utils.IntToStr(scopeOfBranches) | |||
where = fmt.Sprintf(where, lng, lat, lng, lat, lat, lat) | |||
sel := `regional_agent_region.*, sqrt( ( (( %f - longitude)*PI()*12656*cos((( %f +latitude)/2)*PI()/180)/180) * (( %f - longitude)*PI()*12656*cos (((%f+latitude)/2)*PI()/180)/180) ) + ( ((%f-latitude)*PI()*12656/180) * ((%f-latitude)*PI()*12656/180) ) ) AS km` | |||
sel = fmt.Sprintf(sel, lng, lat, lng, lat, lat, lat) | |||
isHas, err := engine.Select(sel). | |||
Table("regional_agent_region").Where(where).Get(®ion) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !isHas { | |||
return nil, nil | |||
} | |||
return ®ion, nil | |||
} | |||
// 根据总后台的区id获取代理网点 | |||
func GetSiteListWithWebSiteRegionId(session *xorm.Session, websiteRegionId string) (*model.RegionalAgentRegion, error) { | |||
var regionD *model.RegionalAgentRegion | |||
isExist, err := session.Table("regional_agent_region"). | |||
Where("website_region_id = ?", websiteRegionId). | |||
Get(®ionD) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !isExist { | |||
return nil, nil | |||
} | |||
var regionSite *model.RegionalAgentRegion | |||
isExist, err = session.Table("regional_agent_region"). | |||
Where("district_id = ?", regionD.Id).Get(®ionSite) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !isExist { | |||
return regionD, nil | |||
} | |||
return regionSite, nil | |||
} |
@@ -0,0 +1,117 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"errors" | |||
"fmt" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
// BatchSelectRegionalAgentUserBelongs 批量查询数据 TODO::和下面的方法重复了,建议采用下面的 `RegionalAgentUserBelongFindByParams` 方法 | |||
func BatchSelectRegionalAgentUserBelongs(Db *xorm.Engine, params map[string]interface{}) (*[]model.RegionalAgentUserBelong, error) { | |||
var RegionalAgentUserBelongData []model.RegionalAgentUserBelong | |||
if err := Db.In(utils.AnyToString(params["key"]), params["value"]). | |||
Find(&RegionalAgentUserBelongData); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &RegionalAgentUserBelongData, nil | |||
} | |||
// RegionalAgentUserBelongInsert 插入单条数据 | |||
func RegionalAgentUserBelongInsert(Db *xorm.Engine, RegionalAgentUserBelong *model.RegionalAgentUserBelong) (int64, error) { | |||
_, err := Db.InsertOne(RegionalAgentUserBelong) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return RegionalAgentUserBelong.Id, nil | |||
} | |||
// BatchAddRegionalAgentUserBelongs 批量新增数据 | |||
func BatchAddRegionalAgentUserBelongs(Db *xorm.Engine, RegionalAgentUserBelongData []*model.RegionalAgentUserBelong) (int64, error) { | |||
affected, err := Db.Insert(RegionalAgentUserBelongData) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func GetRegionalAgentUserBelongCount(Db *xorm.Engine) int { | |||
var RegionalAgentUserBelong model.RegionalAgentUserBelong | |||
session := Db.Where("") | |||
count, err := session.Count(&RegionalAgentUserBelong) | |||
if err != nil { | |||
return 0 | |||
} | |||
return int(count) | |||
} | |||
// RegionalAgentUserBelongDelete 删除记录 | |||
func RegionalAgentUserBelongDelete(Db *xorm.Engine, id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.RegionalAgentUserBelong{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.RegionalAgentUserBelong{}) | |||
} | |||
} | |||
// RegionalAgentUserBelongUpdate 更新记录 | |||
func RegionalAgentUserBelongUpdate(Db *xorm.Engine, id interface{}, RegionalAgentUserBelong *model.RegionalAgentUserBelong, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = Db.Where("id=?", id).Cols(forceColums...).Update(RegionalAgentUserBelong) | |||
} else { | |||
affected, err = Db.Where("id=?", id).Update(RegionalAgentUserBelong) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
// RegionalAgentUserBelongGetOneByParams 通过传入的参数查询数据(单条) | |||
func RegionalAgentUserBelongGetOneByParams(Db *xorm.Engine, params map[string]interface{}) (*model.RegionalAgentUserBelong, error) { | |||
var m model.RegionalAgentUserBelong | |||
var query = fmt.Sprintf("%s =?", params["key"]) | |||
if has, err := Db.Where(query, params["value"]).Get(&m); err != nil || has == false { | |||
return nil, logx.Error(err) | |||
} | |||
return &m, nil | |||
} | |||
// RegionalAgentUserBelongFindByParams 通过传入的参数查询数据(多条) | |||
func RegionalAgentUserBelongFindByParams(Db *xorm.Engine, params map[string]interface{}) (*[]model.RegionalAgentUserBelong, error) { | |||
var m []model.RegionalAgentUserBelong | |||
if params["value"] == nil { | |||
return nil, errors.New("参数有误") | |||
} | |||
if params["key"] == nil { | |||
//查询全部数据 | |||
err := Db.Find(&m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &m, nil | |||
} else { | |||
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice { | |||
//指定In查询 | |||
if err := Db.In(utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} else { | |||
var query = fmt.Sprintf("%s =?", params["key"]) | |||
err := Db.Where(query, params["value"]).Find(&m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &m, nil | |||
} | |||
} | |||
} |
@@ -2,7 +2,10 @@ package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/md" | |||
"applet/app/utils/cache" | |||
"applet/app/utils/logx" | |||
"fmt" | |||
"xorm.io/xorm" | |||
) | |||
@@ -24,6 +27,70 @@ func SysCfgGetOne(Db *xorm.Engine, key string) (*model.SysCfg, error) { | |||
return &cfgList, nil | |||
} | |||
//单条记录获取DB | |||
func SysCfgGetWithDb(eg *xorm.Engine, masterId string, HKey string) string { | |||
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, masterId, HKey[0:1]) | |||
get, err := cache.HGetString(cacheKey, HKey) | |||
if err != nil || get == "" { | |||
cfg, err := SysCfgGetOne(eg, HKey) | |||
if err != nil || cfg == nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
// key是否存在 | |||
cacheKeyExist := false | |||
if cache.Exists(cacheKey) { | |||
cacheKeyExist = true | |||
} | |||
// 设置缓存 | |||
_, err = cache.HSet(cacheKey, HKey, cfg.Val) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
if !cacheKeyExist { // 如果是首次设置 设置过期时间 | |||
_, err := cache.Expire(cacheKey, md.CfgCacheTime) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
} | |||
return cfg.Val | |||
} | |||
return get | |||
} | |||
// 多条记录获取DB | |||
func SysCfgFindWithDb(eg *xorm.Engine, masterId string, keys ...string) map[string]string { | |||
res := map[string]string{} | |||
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, masterId) | |||
err := cache.GetJson(cacheKey, &res) | |||
if err != nil || len(res) == 0 { | |||
cfgList, _ := SysCfgGetAll(eg) | |||
if cfgList == nil { | |||
return nil | |||
} | |||
for _, v := range *cfgList { | |||
res[v.Key] = v.Val | |||
} | |||
cache.SetJson(cacheKey, res, md.CfgCacheTime) | |||
} | |||
if len(keys) == 0 { | |||
return res | |||
} | |||
tmp := map[string]string{} | |||
for _, v := range keys { | |||
if val, ok := res[v]; ok { | |||
tmp[v] = val | |||
} else { | |||
tmp[v] = "" | |||
} | |||
} | |||
return tmp | |||
} | |||
// 返回最后插入id | |||
func SysCfgInsert(Db *xorm.Engine, key, val, memo string) bool { | |||
cfg := model.SysCfg{Key: key, Val: val, Memo: memo} | |||
@@ -1,476 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"errors" | |||
"strconv" | |||
"strings" | |||
"github.com/gin-gonic/gin" | |||
"github.com/tidwall/gjson" | |||
"xorm.io/xorm" | |||
) | |||
// 返回所有, 不管是否显示 | |||
func SysModFindAll(Db *xorm.Engine) (*[]model.SysModule, error) { | |||
var m []model.SysModule | |||
if err := Db.Find(&m); err != nil { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
// 查找主模块数据 | |||
func SysModFindMain(Db *xorm.Engine) (*[]model.SysModule, error) { | |||
var m []model.SysModule | |||
if err := Db.Where("mod_pid = 0 AND state = 1 AND position = 'base'"). | |||
Asc("sort"). | |||
Find(&m); err != nil { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
// 用父ID查找子模块数据 | |||
func SysModFindByPId(c *gin.Context, Db *xorm.Engine, id int) (*[]model.SysModule, error) { | |||
var m []model.SysModule | |||
if err := Db.Where("state = 1").Where("mod_pid = ?", id). | |||
Asc("sort"). | |||
Find(&m); err != nil { | |||
return nil, err | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
var ms []model.SysModule | |||
modname_list := []string{"product", "search_result_taobao_item", "hot_rank_tab_view"} | |||
for _, item := range *mm.(*[]model.SysModule) { | |||
if strings.Contains(item.Data, "tmall") == false && item.ModName == "product_detail_title" { | |||
item.Data = strings.Replace(item.Data, "\"platform_css\":[", "\"platform_css\":[{\"name\":\"天猫\",\"type\":\"tmall\",\"text_color\":\"#FFFFFF\",\"bg_color\":\"#FF4242\"},", 1) | |||
} | |||
if strings.Contains(item.Data, "tmall") == false && utils.InArr(item.ModName, modname_list) { | |||
item.Data = strings.Replace(item.Data, "{\"index\":\"6\",\"type\":\"kaola\",\"platform_name\":\"考拉\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", "{\"index\":\"6\",\"type\":\"kaola\",\"platform_name\":\"考拉\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"},{\"index\":\"7\",\"type\":\"tmall\",\"platform_name\":\"天猫\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", 1) | |||
item.Data = strings.Replace(item.Data, "{\"type\":\"kaola\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", "{\"type\":\"kaola\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"},{\"type\":\"tmall\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", 1) | |||
} | |||
if strings.Contains(item.Data, "优惠卷") { | |||
item.Data = strings.Replace(item.Data, "优惠卷", "优惠券", -1) | |||
} | |||
ms = append(ms, item) | |||
} | |||
return &ms, nil | |||
} | |||
// 用父ID查找子模块数据 | |||
func SysModFindByPIds(c *gin.Context, Db *xorm.Engine, ids ...int) (*[]model.SysModule, error) { | |||
var m []model.SysModule | |||
if err := Db.In("mod_pid", ids).Where("state = 1"). | |||
Asc("sort"). | |||
Find(&m); err != nil { | |||
return nil, err | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
var ms []model.SysModule | |||
for _, item := range *mm.(*[]model.SysModule) { | |||
//数据里面 | |||
if strings.Contains(item.Data, "tmall") == false && item.ModName == "product" { | |||
item.Data = strings.Replace(item.Data, "{\"index\":\"6\",\"type\":\"kaola\",\"platform_name\":\"考拉\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", "{\"index\":\"6\",\"type\":\"kaola\",\"platform_name\":\"考拉\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"},{\"index\":\"7\",\"type\":\"tmall\",\"platform_name\":\"天猫\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", 1) | |||
} | |||
item = SysModDataByReplace(c, item) | |||
ms = append(ms, item) | |||
} | |||
return &ms, nil | |||
} | |||
// 用IDS找对应模块数据 | |||
func SysModFindByIds(Db *xorm.Engine, ids ...int) (*[]model.SysModule, error) { | |||
var m []model.SysModule | |||
if err := Db.In("mod_id", ids).Where("state = 1"). | |||
Cols("mod_id,mod_pid,mod_name,position,skip_identifier,title,subtitle,url,margin,aspect_ratio,icon,img,font_color,bg_img,bg_color,bg_color_t,badge,path,data,sort"). | |||
Asc("sort").Find(&m); err != nil { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
// ID查找对应模块 | |||
func SysModFindById(c *gin.Context, Db *xorm.Engine, id string) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND mod_id = ?", id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
} | |||
// SysModFindByTmpId is 根据模板 | |||
func SysModFindByTmpId(c *gin.Context, Db *xorm.Engine, id string) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND template_id = ?", id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
} | |||
// Name查找对应模块 | |||
func SysModFindByName(c *gin.Context, Db *xorm.Engine, name string) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND mod_name = ?", name). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
} | |||
// SysModFindByName is Name查找对应模块 | |||
func SysModFindByNames(names ...string) (*[]model.SysModule, error) { | |||
var m []model.SysModule | |||
if err := Db.In("mod_name", names).Where("state = 1"). | |||
Cols("mod_id,mod_pid,mod_name,position,skip_identifier,title,subtitle,url,margin,aspect_ratio,icon,img,font_color,bg_img,bg_color,bg_color_t,badge,path,data,sort"). | |||
Find(&m); err != nil { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
// SysModFindByPosition is 根据位置查找对应模块 | |||
func SysModFindByPosition(Db *xorm.Engine, positions ...string) (*[]model.SysModule, error) { | |||
var m []model.SysModule | |||
if err := Db.In("position", positions).Where("state = 1").Find(&m); err != nil { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
// 根据跳转标识 查找对应模块 | |||
func SysModFindBySkipIdentifier(c *gin.Context, Db *xorm.Engine, name string) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND skip_identifier = ?", name). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
} | |||
// 根据跳转标识和位置 查找对应模块list | |||
func SysModFindBySkipIdentifierAndPosition(c *gin.Context, Db *xorm.Engine, name string, position string) (*[]model.SysModule, error) { | |||
var m []model.SysModule | |||
if err := Db.Where("state = 1 AND skip_identifier = ? AND position = ?", name, position). | |||
Cols("mod_id,mod_pid,mod_name,position,skip_identifier,title,subtitle,url,margin,aspect_ratio,icon,img,font_color,bg_img,bg_color,bg_color_t,badge,path,data,sort"). | |||
Asc("sort").Find(&m); err != nil { | |||
return nil, err | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*[]model.SysModule), nil | |||
} | |||
// SysModFindByTemplateIDAndSkip is 根据模板id 查找对应模块 | |||
func SysModFindByTemplateIDAndSkip(Db *xorm.Engine, id interface{}, skip string) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND skip_identifier = ?", id, skip). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// SysModFindByTemplateIDAndPID is 根据模板id 和pid =0 查找父模块 | |||
func SysModFindByTemplateIDAndPID(Db *xorm.Engine, id interface{}, pid interface{}) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND mod_pid = ?", id, pid). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// SysModFindByTemplateIDAndModName is 根据模板id 和mod name 查找模块 | |||
func SysModFindByTemplateIDAndModName(Db *xorm.Engine, id interface{}, modName string) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND mod_name = ?", id, modName). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// SysModFindNavIsUsed 查找正在使用的底部导航栏模板 | |||
func SysModFindNavIsUsedByPlatform(c *gin.Context, Db *xorm.Engine, platform string) (*model.SysModule, error) { | |||
var ( | |||
tm model.SysTemplate | |||
m model.SysModule | |||
) | |||
switch platform { | |||
case "ios": | |||
if has, err := Db.Where("is_use = 1 AND type = 'bottom' AND platform = 2 "). | |||
Cols("id,uid,name,is_use,is_system"). | |||
Get(&tm); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
appvserison := SysCfgGet(c, "ios_audit_version") | |||
if c.GetHeader("app_version_name") == appvserison && c.GetHeader("app_version_name") != "" { | |||
m, err := GetCloudBundleByVersion(Db, appvserison, 2) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
tm.Id = int(gjson.Get(m.TemplateDuringAudit, "bottom").Int()) | |||
} | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND mod_name = 'bottom_nav'", tm.Id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
case "android": | |||
has, err := Db.Where("is_use = 1 AND type = 'bottom' AND platform = 2 ").Cols("id,uid,name,is_use,is_system").Get(&tm) | |||
if err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
appvserison := SysCfgGet(c, "android_audit_version") | |||
if appvserison != "" && c.GetHeader("app_version_name") == appvserison { | |||
m, err := GetCloudBundleByVersion(Db, appvserison, 1) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
tm.Id = int(gjson.Get(m.TemplateDuringAudit, "bottom").Int()) | |||
} | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND mod_name = 'bottom_nav'", tm.Id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
case "wx_applet", "wap": | |||
if has, err := Db.Where("is_use = 1 AND type = 'bottom' AND platform = 4 "). | |||
Cols("id,uid,name,is_use,is_system"). | |||
Get(&tm); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
appvserison := SysCfgGet(c, "mp_audit_version") | |||
// fmt.Println("header:", c.Request.Header) | |||
if c.GetHeader("AppVersionName") == appvserison && c.GetHeader("AppVersionName") != "" { | |||
m, err := SysCfgGetOne(Db, "mp_audit_template") | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
tm.Id = int(gjson.Get(m.Val, "bottom").Int()) | |||
} | |||
// fmt.Println("template_id", tm.Id) | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND mod_name = 'bottom_nav'", tm.Id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
case "baidu_applet": | |||
if has, err := Db.Where("is_use = 1 AND type = 'bottom' AND platform = 4 "). | |||
Cols("id,uid,name,is_use,is_system"). | |||
Get(&tm); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
appvserison := SysCfgGet(c, "baidu_audit_version") | |||
if appvserison != "" && c.GetHeader("app_version_name") == appvserison { | |||
m, err := SysCfgGetOne(Db, "baidu_audit_template") | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
tm.Id = int(gjson.Get(m.Val, "bottom").Int()) | |||
} | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND mod_name = 'bottom_nav'", tm.Id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
case "toutiao_applet": | |||
if has, err := Db.Where("is_use = 1 AND type = 'bottom' AND platform = 4 "). | |||
Cols("id,uid,name,is_use,is_system"). | |||
Get(&tm); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
appvserison := SysCfgGet(c, "tt_audit_version") | |||
if appvserison != "" && c.GetHeader("app_version_name") == appvserison { | |||
m, err := SysCfgGetOne(Db, "tt_audit_template") | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
tm.Id = int(gjson.Get(m.Val, "bottom").Int()) | |||
} | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND mod_name = 'bottom_nav'", tm.Id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
case "alipay_applet": | |||
if has, err := Db.Where("is_use = 1 AND type = 'bottom' AND platform = 4 "). | |||
Cols("id,uid,name,is_use,is_system"). | |||
Get(&tm); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
appvserison := SysCfgGet(c, "zfb_audit_version") | |||
if appvserison != "" && c.GetHeader("app_version_name") == appvserison { | |||
m, err := SysCfgGetOne(Db, "zfb_audit_template") | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
tm.Id = int(gjson.Get(m.Val, "bottom").Int()) | |||
} | |||
if has, err := Db.Where("state = 1 AND template_id = ? AND mod_name = 'bottom_nav'", tm.Id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
default: | |||
return &m, errors.New("Platform not support") | |||
} | |||
} | |||
// SysModFindBySkipIdentifierAndModName is 根据mod_name和位置 查找对应模块 | |||
func SysModFindBySkipIdentifierAndModName(c *gin.Context, Db *xorm.Engine, name string, modName string) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND skip_identifier = ? AND mod_name = ?", name, modName).Get(&m); err != nil || !has { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
} | |||
// SysModFindByModName is 根据mod_name和位置 查找对应模块 | |||
func SysModFindByModName(c *gin.Context, Db *xorm.Engine, modName string) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND mod_name = ?", modName).Get(&m); err != nil || !has { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
} | |||
// 根据跳转标识和平台类型查找 | |||
func SysModFindBySkipIdentifierAndPlatform(c *gin.Context, Db *xorm.Engine, name string, platform int) (*model.SysModule, error) { | |||
var m model.SysModule | |||
if has, err := Db.Where("state = 1 AND skip_identifier = ? AND platform = ?", name, platform).Get(&m); err != nil || !has { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysModule), nil | |||
} | |||
//公共处理modData的链接 | |||
func SysModDataByReplace(c *gin.Context, mod model.SysModule) model.SysModule { | |||
//替换链接的一些参数 | |||
if strings.Contains(mod.Data, "[replace_APP_URL]") { | |||
mod.Data = strings.Replace(mod.Data, "[replace_APP_URL]", c.GetString("domain_wap_base"), -1) | |||
} | |||
if strings.Contains(mod.Data, "[replace_masterId]") { | |||
mod.Data = strings.Replace(mod.Data, "[replace_masterId]", c.GetString("mid"), -1) | |||
} | |||
if strings.Contains(mod.Data, "优惠卷") { | |||
mod.Data = strings.Replace(mod.Data, "优惠卷", "优惠券", -1) | |||
} | |||
if strings.Contains(mod.Data, "[replace_uid]") { | |||
token := c.GetHeader("Authorization") | |||
// 按空格分割 | |||
parts := strings.SplitN(token, " ", 2) | |||
if len(parts) == 2 && parts[0] == "Bearer" { | |||
// parts[1]是获取到的tokenString,我们使用之前定义好的解析JWT的函数来解析它 | |||
mc, _ := utils.ParseToken(parts[1]) | |||
mod.Data = strings.Replace(mod.Data, "[replace_uid]", strconv.Itoa(mc.UID), -1) | |||
} | |||
} | |||
//if strings.Contains(mod.Data, "\"child_category_id") && strings.Contains(mod.Data, "\"category_id") { | |||
// //如果存在这两个字段,要换一下 | |||
// mod.Data = strings.ReplaceAll(mod.Data, "\"category_id", "\"null_category_id") | |||
// mod.Data = strings.ReplaceAll(mod.Data, "\"child_category_id", "\"category_id") | |||
//} | |||
return mod | |||
} | |||
//公共处理modData的链接 | |||
func SysModDataByReplaceSecond(c *gin.Context, mod *model.SysModule) *model.SysModule { | |||
//替换链接的一些参数 | |||
if strings.Contains(mod.Data, "[replace_APP_URL]") { | |||
mod.Data = strings.Replace(mod.Data, "[replace_APP_URL]", c.GetString("domain_wap_base"), -1) | |||
} | |||
if strings.Contains(mod.Data, "[replace_masterId]") { | |||
mod.Data = strings.Replace(mod.Data, "[replace_masterId]", c.GetString("mid"), -1) | |||
} | |||
if strings.Contains(mod.Data, "优惠卷") { | |||
mod.Data = strings.Replace(mod.Data, "优惠卷", "优惠券", -1) | |||
} | |||
if strings.Contains(mod.Data, "[replace_uid]") { | |||
token := c.GetHeader("Authorization") | |||
// 按空格分割 | |||
parts := strings.SplitN(token, " ", 2) | |||
if len(parts) == 2 && parts[0] == "Bearer" { | |||
// parts[1]是获取到的tokenString,我们使用之前定义好的解析JWT的函数来解析它 | |||
mc, _ := utils.ParseToken(parts[1]) | |||
mod.Data = strings.Replace(mod.Data, "[replace_uid]", strconv.Itoa(mc.UID), -1) | |||
} | |||
} | |||
//if strings.Contains(mod.Data, "\"child_category_id") && strings.Contains(mod.Data, "\"category_id") { | |||
// //如果存在这两个字段,要换一下 | |||
// mod.Data = strings.ReplaceAll(mod.Data, "\"category_id", "\"null_category_id") | |||
// mod.Data = strings.ReplaceAll(mod.Data, "\"child_category_id", "\"category_id") | |||
//} | |||
return mod | |||
} |
@@ -1,493 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/md" | |||
"applet/app/utils" | |||
"applet/app/utils/cache" | |||
"applet/app/utils/logx" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/syyongx/php2go" | |||
"github.com/tidwall/gjson" | |||
"regexp" | |||
"strings" | |||
"xorm.io/xorm" | |||
"github.com/gin-gonic/gin" | |||
) | |||
//处理多眼导航数据 激励广告过滤 | |||
func MultiNavFormat(c *gin.Context, mod model.SysModule) model.SysModule { | |||
var data = mod.Data | |||
var listStyle = gjson.Get(data, "list_style").String() | |||
var multiNav []md.MultiNav | |||
if err := json.Unmarshal([]byte(listStyle), &multiNav); err != nil { | |||
return mod | |||
} | |||
userLevelWeight := c.GetString("user_level_weight") | |||
var list []md.MultiNav | |||
for _, v := range multiNav { | |||
if v.SkipIdentifier == "pub.flutter.incentive_ad" && v.Data.Conditions == "1" { | |||
var levelWeight = 0 | |||
if v.Data.LevelWeight != "" && v.Data.LevelWeight != "0" { | |||
levelWeight = utils.StrToInt(v.Data.LevelWeight) | |||
} | |||
//如果用户等级大于等于设置等级 就显示 | |||
if utils.StrToInt(userLevelWeight) >= levelWeight && c.GetString("user_login") == "1" { | |||
list = append(list, v) | |||
} | |||
} else { | |||
list = append(list, v) | |||
} | |||
} | |||
b, err := json.Marshal(list) | |||
if err != nil { | |||
return mod | |||
} | |||
if b != nil { | |||
mod.Data = strings.Replace(mod.Data, listStyle, string(b), -1) | |||
} | |||
return mod | |||
} | |||
func sysModFormat(c *gin.Context, m interface{}) (interface{}, error) { | |||
var mods []model.SysModule | |||
protocol := SysCfgGet(c, "file_bucket_scheme") | |||
domain := SysCfgGet(c, "file_bucket_host") | |||
//fmt.Println(protocol, domain) | |||
if protocol == "" || domain == "" { | |||
return nil, errors.New("System configuration error, object storage protocol and domain name not found") | |||
} | |||
modname_list := []string{"product", "search_result_taobao_item", "hot_rank_tab_view"} | |||
switch m.(type) { | |||
case *[]model.SysModule: | |||
ms := m.(*[]model.SysModule) | |||
for _, item := range *ms { | |||
replaceList := reformatPng(item.Data) | |||
l := removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
newVal := fmt.Sprintf("%s://%s/%s", protocol, domain, php2go.Rawurlencode(s)) | |||
item.Data = strings.ReplaceAll(item.Data, ss, `"`+newVal+`"`) | |||
} | |||
replaceList = reformatJPG(item.Data) | |||
l = removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
newVal := fmt.Sprintf("%s://%s/%s", protocol, domain, php2go.Rawurlencode(s)) | |||
item.Data = strings.Replace(item.Data, ss, `"`+newVal+`"`, -1) | |||
} | |||
replaceList = reformatGIF(item.Data) | |||
l = removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
newVal := fmt.Sprintf("%s://%s/%s", protocol, domain, php2go.Rawurlencode(s)) | |||
item.Data = strings.Replace(item.Data, ss, `"`+newVal+`"`, -1) | |||
} | |||
if strings.Contains(item.Data, "tmall") == false && item.ModName == "product_detail_title" { | |||
item.Data = strings.Replace(item.Data, "\"platform_css\":[", "\"platform_css\":[{\"name\":\"天猫\",\"type\":\"tmall\",\"text_color\":\"#FFFFFF\",\"bg_color\":\"#FF4242\"},", 1) | |||
} | |||
if strings.Contains(item.Data, "tmall") == false && utils.InArr(item.ModName, modname_list) { | |||
item.Data = strings.Replace(item.Data, "{\"index\":\"6\",\"type\":\"kaola\",\"platform_name\":\"考拉\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", "{\"index\":\"6\",\"type\":\"kaola\",\"platform_name\":\"考拉\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"},{\"index\":\"7\",\"type\":\"tmall\",\"platform_name\":\"天猫\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", 1) | |||
item.Data = strings.Replace(item.Data, "{\"type\":\"kaola\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", "{\"type\":\"kaola\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"},{\"type\":\"tmall\",\"provider_name_color\":\"#FFFFFF\",\"provider_bg_color\":\"#FF4242\"}", 1) | |||
} | |||
item = SysModDataByReplace(c, item) | |||
if item.ModName == "multi_nav" { | |||
item = MultiNavFormat(c, item) | |||
} | |||
mods = append(mods, item) | |||
} | |||
return &mods, nil | |||
case *model.SysModule: | |||
m := m.(*model.SysModule) | |||
repalceList := reformatPng(m.Data) | |||
l := removeDuplicateElement(repalceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
if skipHTTPPng(s) { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
new := fmt.Sprintf(`%s://%s/%s`, protocol, domain, php2go.Rawurlencode(s)) | |||
m.Data = strings.Replace(m.Data, ss, `"`+new+`"`, -1) | |||
} | |||
repalceList = reformatJPG(m.Data) | |||
l = removeDuplicateElement(repalceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
new := fmt.Sprintf("%s://%s/%s", protocol, domain, php2go.Rawurlencode(s)) | |||
m.Data = strings.Replace(m.Data, ss, `"`+new+`"`, -1) | |||
} | |||
repalceList = reformatGIF(m.Data) | |||
l = removeDuplicateElement(repalceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
new := fmt.Sprintf("%s://%s/%s", protocol, domain, php2go.Rawurlencode(s)) | |||
m.Data = strings.Replace(m.Data, ss, `"`+new+`"`, -1) | |||
} | |||
m = SysModDataByReplaceSecond(c, m) | |||
return m, nil | |||
case []*model.UserLevel: | |||
ms := m.([]*model.UserLevel) | |||
for _, item := range ms { | |||
replaceList := reformatPng(item.CssSet) | |||
l := removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
// png | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
newVal := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
item.CssSet = strings.Replace(item.CssSet, ss, `"`+newVal+`"`, -1) | |||
// jpg | |||
replaceList = reformatJPG(item.CssSet) | |||
l = removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
newVal := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
item.CssSet = strings.Replace(item.CssSet, ss, `"`+newVal+`"`, -1) | |||
} | |||
} | |||
} | |||
return ms, nil | |||
case []*model.SysPushUser: | |||
ms := m.([]*model.SysPushUser) | |||
for _, item := range ms { | |||
replaceList := reformatPng(item.SendData) | |||
l := removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
// png | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
newVal := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
item.SendData = strings.Replace(item.SendData, ss, `"`+newVal+`"`, -1) | |||
// jpg | |||
replaceList = reformatJPG(item.SendData) | |||
l = removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
newVal := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
item.SendData = strings.Replace(item.SendData, ss, `"`+newVal+`"`, -1) | |||
} | |||
} | |||
} | |||
return ms, nil | |||
case *model.SysPushUser: | |||
m := m.(*model.SysPushUser) | |||
repalceList := reformatPng(m.SendData) | |||
l := removeDuplicateElement(repalceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
new := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
m.SendData = strings.Replace(m.SendData, ss, `"`+new+`"`, -1) | |||
} | |||
repalceList = reformatJPG(m.SendData) | |||
l = removeDuplicateElement(repalceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
new := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
m.SendData = strings.Replace(m.SendData, ss, `"`+new+`"`, -1) | |||
} | |||
repalceList = reformatGIF(m.SendData) | |||
l = removeDuplicateElement(repalceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
new := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
m.SendData = strings.Replace(m.SendData, ss, `"`+new+`"`, -1) | |||
} | |||
return m, nil | |||
default: | |||
return nil, nil | |||
} | |||
} | |||
func ReformatStr(str string, c *gin.Context) string { | |||
protocol := SysCfgGet(c, "file_bucket_scheme") | |||
domain := SysCfgGet(c, "file_bucket_host") | |||
// PNG | |||
replaceList := reformatPng(str) | |||
l := removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
new := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
if skipHTTPPng(new) { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
str = strings.Replace(str, ss, `"`+new+`"`, -1) | |||
} | |||
// JPG | |||
replaceList = reformatJPG(str) | |||
l = removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
new := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
if skipHTTPPng(new) { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
str = strings.Replace(str, ss, `"`+new+`"`, -1) | |||
} | |||
// GIF | |||
replaceList = reformatGIF(str) | |||
l = removeDuplicateElement(replaceList) | |||
for _, s := range l { | |||
if strings.Contains(s, "http") { | |||
continue | |||
} | |||
s = strings.ReplaceAll(s, `\`, "") | |||
s = php2go.Rawurlencode(s) | |||
new := fmt.Sprintf("%s://%s/%s", protocol, domain, s) | |||
if skipHTTPPng(new) { | |||
continue | |||
} | |||
ss := s | |||
s = strings.ReplaceAll(s, `"`, "") | |||
str = strings.Replace(str, ss, `"`+new+`"`, -1) | |||
} | |||
return str | |||
} | |||
// 正则匹配 | |||
func reformatPng(data string) []string { | |||
re, _ := regexp.Compile(`"([^\"]*.png")`) | |||
list := re.FindAllString(data, -1) | |||
return list | |||
} | |||
// | |||
func skipHTTPPng(data string) bool { | |||
re, _ := regexp.Compile(`(http|https):\/\/([^\"]*.png)`) | |||
return re.MatchString(data) | |||
} | |||
// 正则匹配 | |||
func reformatJPG(data string) []string { | |||
re, _ := regexp.Compile(`"([^\"]*.jpg")`) | |||
list := re.FindAllString(data, -1) | |||
return list | |||
} | |||
// 正则匹配 | |||
func reformatGIF(data string) []string { | |||
re, _ := regexp.Compile(`"([^\"]*.gif")`) | |||
list := re.FindAllString(data, -1) | |||
return list | |||
} | |||
func removeDuplicateElement(addrs []string) []string { | |||
result := make([]string, 0, len(addrs)) | |||
temp := map[string]int{} | |||
i := 1 | |||
for _, item := range addrs { | |||
if _, ok := temp[item]; !ok { | |||
temp[item] = i | |||
result = append(result, item) | |||
continue | |||
} | |||
temp[item] = temp[item] + 1 | |||
} | |||
// fmt.Println(temp) | |||
return result | |||
} | |||
//单条记录获取 | |||
func SysCfgGet(c *gin.Context, key string) string { | |||
res := SysCfgFind(c, key) | |||
//fmt.Println(res) | |||
if _, ok := res[key]; !ok { | |||
return "" | |||
} | |||
return res[key] | |||
} | |||
//单条记录获取DB | |||
func SysCfgGetWithDb(eg *xorm.Engine, masterId string, HKey string) string { | |||
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, masterId, HKey[0:1]) | |||
get, err := cache.HGetString(cacheKey, HKey) | |||
if err != nil || get == "" { | |||
cfg, err := SysCfgGetOne(eg, HKey) | |||
if err != nil || cfg == nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
// key是否存在 | |||
cacheKeyExist := false | |||
if cache.Exists(cacheKey) { | |||
cacheKeyExist = true | |||
} | |||
// 设置缓存 | |||
_, err = cache.HSet(cacheKey, HKey, cfg.Val) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
if !cacheKeyExist { // 如果是首次设置 设置过期时间 | |||
_, err := cache.Expire(cacheKey, md.CfgCacheTime) | |||
if err != nil { | |||
_ = logx.Error(err) | |||
return "" | |||
} | |||
} | |||
return cfg.Val | |||
} | |||
return get | |||
} | |||
// 多条记录获取 | |||
func SysCfgFind(c *gin.Context, keys ...string) map[string]string { | |||
res := map[string]string{} | |||
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, c.GetString("mid")) | |||
err := cache.GetJson(cacheKey, &res) | |||
if err != nil || len(res) == 0 { | |||
cfgList, _ := SysCfgGetAll(DBs[c.GetString("mid")]) | |||
if cfgList == nil { | |||
return nil | |||
} | |||
for _, v := range *cfgList { | |||
res[v.Key] = v.Val | |||
} | |||
cache.SetJson(cacheKey, res, md.CfgCacheTime) | |||
} | |||
if len(keys) == 0 { | |||
return res | |||
} | |||
tmp := map[string]string{} | |||
for _, v := range keys { | |||
if val, ok := res[v]; ok { | |||
tmp[v] = val | |||
} else { | |||
tmp[v] = "" | |||
} | |||
} | |||
return tmp | |||
} | |||
// 多条记录获取DB | |||
func SysCfgFindWithDb(eg *xorm.Engine, masterId string, keys ...string) map[string]string { | |||
res := map[string]string{} | |||
cacheKey := fmt.Sprintf(md.AppCfgCacheKey, masterId) | |||
err := cache.GetJson(cacheKey, &res) | |||
if err != nil || len(res) == 0 { | |||
cfgList, _ := SysCfgGetAll(eg) | |||
if cfgList == nil { | |||
return nil | |||
} | |||
for _, v := range *cfgList { | |||
res[v.Key] = v.Val | |||
} | |||
cache.SetJson(cacheKey, res, md.CfgCacheTime) | |||
} | |||
if len(keys) == 0 { | |||
return res | |||
} | |||
tmp := map[string]string{} | |||
for _, v := range keys { | |||
if val, ok := res[v]; ok { | |||
tmp[v] = val | |||
} else { | |||
tmp[v] = "" | |||
} | |||
} | |||
return tmp | |||
} |
@@ -1,39 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"errors" | |||
"xorm.io/xorm" | |||
) | |||
// InertSysPushAppOne is 插入一条记录在 表sys_push_app | |||
func InertSysPushAppOne(Db *xorm.Engine, m *model.SysPushApp) (int64, error) { | |||
affect, err := Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affect, nil | |||
} | |||
//UpdateSysPushApp is 更新某条记录 | |||
func UpdateSysPushApp(Db *xorm.Engine, m *model.SysPushApp) (int64, error) { | |||
affect, err := Db.ID(m.Id).Update(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affect, nil | |||
} | |||
//SysPushAppByID is 根据id 获取对应的推送信息 | |||
func SysPushAppByID(Db *xorm.Engine, id interface{}) (*model.SysPushApp, error) { | |||
m := new(model.SysPushApp) | |||
has, err := Db.ID(id).Get(m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !has { | |||
return nil, errors.New("Not Found") | |||
} | |||
return m, nil | |||
} |
@@ -1,21 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"errors" | |||
"xorm.io/xorm" | |||
) | |||
//SysPushTemplateByType is 根据类型 | |||
func SysPushTemplateByType(Db *xorm.Engine, t string) (*model.SysPushTemplate, error) { | |||
m := new(model.SysPushTemplate) | |||
has, err := Db.Where("type = ?", t).Get(m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !has { | |||
return nil, errors.New("Not Found") | |||
} | |||
return m, nil | |||
} |
@@ -1,94 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"github.com/gin-gonic/gin" | |||
"xorm.io/xorm" | |||
) | |||
// SysPushUserByUIDByTypeIn is 根据uid和类型获取对应的通知 | |||
func SysPushUserByUIDByTypeIn(c *gin.Context, Db *xorm.Engine, uid interface{}, limit int, start int, t ...interface{}) ([]*model.SysPushUser, error) { | |||
var m []*model.SysPushUser | |||
if limit == 0 && start == 0 { | |||
if err := Db.Where("uid = ?", uid).In("type", t...).Desc("time").Find(&m); err != nil { | |||
return nil, err | |||
} | |||
mm, err := sysModFormat(c, m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.([]*model.SysPushUser), nil | |||
} | |||
if err := Db.Where("uid = ?", uid).In("type", t...).Limit(limit, start).Desc("time").Find(&m); err != nil { | |||
return nil, err | |||
} | |||
mm, err := sysModFormat(c, m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.([]*model.SysPushUser), nil | |||
} | |||
//SysPushUserInTypeGET is In 查询 一个 | |||
func SysPushUserInTypeGET(c *gin.Context, Db *xorm.Engine, uid interface{}, ts ...interface{}) (*model.SysPushUser, error) { | |||
m := new(model.SysPushUser) | |||
has, err := Db.Where("uid = ?", uid).In("type", ts...).Desc("time").Get(m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !has { | |||
return nil, nil | |||
} | |||
mm, err := sysModFormat(c, m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.(*model.SysPushUser), nil | |||
} | |||
//SysPushUserInType is In 查询 | |||
func SysPushUserInType(c *gin.Context, Db *xorm.Engine, uid interface{}, ts ...interface{}) ([]*model.SysPushUser, error) { | |||
var m []*model.SysPushUser | |||
if err := Db.Where("uid = ?", uid).In("type", ts...).Desc("time").Find(&m); err != nil { | |||
return nil, err | |||
} | |||
mm, err := sysModFormat(c, &m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.([]*model.SysPushUser), nil | |||
} | |||
//SysPushUserInTypeCount is In 查询 | |||
func SysPushUserInTypeCount(Db *xorm.Engine, uid interface{}, ts ...interface{}) (int64, error) { | |||
m := new(model.SysPushUser) | |||
count, err := Db.Where("uid = ? AND is_read = 0", uid).In("type", ts...).Count(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return count, nil | |||
} | |||
//SysPushUserInsertOne is 插入一条记录 | |||
func SysPushUserInsertOne(Db *xorm.Engine, m *model.SysPushUser) (int64, error) { | |||
affected, err := Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
//BatchUpdateSysPushUserRead is 批量更新某种类型的通知 | |||
func BatchUpdateSysPushUserRead(Db *xorm.Engine, uid, t interface{}) error { | |||
sql := "update sys_push_user set is_read = ? where uid = ? and type = ?" | |||
_, err := Db.Exec(sql, 1, uid, t) | |||
if err != nil { | |||
return logx.Warn(err) | |||
} | |||
return nil | |||
} |
@@ -1,26 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
//SysTmpFindByIsUseByType is find tmp by issystem | |||
func SysTmpFindByIsUseByType(Db *xorm.Engine, use, t, platform string) (*model.SysTemplate, error) { | |||
var m model.SysTemplate | |||
if has, err := Db.Where("is_use = ? AND type = ? AND platform = ?", use, t, platform). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
func SysTmpFindByID(Db *xorm.Engine, id int) (*model.SysTemplate, error) { | |||
var m model.SysTemplate | |||
if has, err := Db.Where("id = ?", id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} |
@@ -2,16 +2,18 @@ package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"fmt" | |||
"xorm.io/xorm" | |||
) | |||
// UserisExistByUsernameAndPassword is usernameAndPassword exist | |||
func UserisExistByUsernameAndPassword(Db *xorm.Engine, username string, password string) (bool, error) { | |||
has, err := Db.Where("username = ? AND password = ?", username, utils.Md5(password)).Exist(&model.User{}) | |||
func UserisExistByUsernameAndPassword(Db *xorm.Engine, username, password, zone string) (bool, error) { | |||
sess := Db.Where("(username = ? or phone=?) AND password = ?", username, username, password) | |||
if zone != "" && zone != "86" { | |||
sess = sess.And("zone=?", zone) | |||
} | |||
has, err := sess.Exist(&model.User{}) | |||
if err != nil { | |||
return false, err | |||
@@ -21,7 +23,7 @@ func UserisExistByUsernameAndPassword(Db *xorm.Engine, username string, password | |||
// UserisExistByMobile is exist | |||
func UserisExistByMobile(Db *xorm.Engine, n string) (bool, error) { | |||
has, err := Db.Where("phone = ?", n).Exist(&model.User{}) | |||
has, err := Db.Where("phone = ? and phone<>''", n).Exist(&model.User{}) | |||
if err != nil { | |||
return false, err | |||
@@ -71,9 +73,13 @@ func UserFindByMobileAll(Db *xorm.Engine, mobile string) (*model.User, error) { | |||
} | |||
// UserGetByMobileIgnoreDelete search user by mobile ignore delete | |||
func UserGetByMobileIgnoreDelete(Db *xorm.Engine, mobile string) (*model.User, bool, error) { | |||
func UserGetByMobileIgnoreDelete(Db *xorm.Engine, mobile, zone string) (*model.User, bool, error) { | |||
m := new(model.User) | |||
has, err := Db.Where("phone = ?", mobile).Get(m) | |||
sess := Db.Where("phone = ?", mobile) | |||
if zone != "" && zone != "86" { | |||
sess = sess.And("zone=?", zone) | |||
} | |||
has, err := sess.Get(m) | |||
if err != nil { | |||
return nil, false, logx.Warn(err) | |||
} | |||
@@ -181,7 +187,15 @@ func UserFindByArkidUserName(Db *xorm.Engine, name string) (*model.User, error) | |||
// UserFindByID is find user byid | |||
func UserFindByID(Db *xorm.Engine, id interface{}) (*model.User, error) { | |||
var m model.User | |||
if has, err := Db.Where("uid = ?", id). | |||
if _, err := Db.Where("uid = ?", id). | |||
Get(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
func UserFindByIDWithSession(sess *xorm.Session, id interface{}) (*model.User, error) { | |||
var m model.User | |||
if has, err := sess.Where("uid = ?", id). | |||
Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
@@ -292,7 +306,15 @@ func UserUpdateWithSession(Db *xorm.Session, uid interface{}, user *model.User, | |||
return affected, nil | |||
} | |||
func UpdateUserFinValid() { | |||
} | |||
// UserDelete is delete user | |||
func UserDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
return Db.Where("uid = ?", uid).Delete(model.User{}) | |||
} | |||
func UserDeleteWithSess(sess *xorm.Session, uid interface{}) (int64, error) { | |||
return sess.Where("uid = ?", uid).Delete(model.User{}) | |||
} |
@@ -1,85 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
// GetUserFav is 获取商品收藏 | |||
func GetUserFav(Db *xorm.Engine, uid, itemid interface{}) (*model.UserFavorite, error) { | |||
var m model.UserFavorite | |||
if has, err := Db.Where("uid = ? AND item_id = ?", uid, itemid).Get(&m); err != nil || !has { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//InsertUserFavOne is 插入一条收藏记录 | |||
func InsertUserFavOne(Db *xorm.Engine, m *model.UserFavorite) (int64, error) { | |||
affected, err := Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
//UserFavFindByProvider 根据提供商来筛选收藏的 | |||
func UserFavFindByProvider(Db *xorm.Engine, uid interface{}, provider string, limit, start int) ([]*model.UserFavorite, error) { | |||
var m []*model.UserFavorite | |||
var err error | |||
if provider == "all" { | |||
if limit == 0 && start == 0 { | |||
err = Db.Where("uid = ?", uid).Desc("create_at").Find(&m) | |||
} else { | |||
err = Db.Where("uid = ?", uid).Desc("create_at").Limit(limit, start).Find(&m) | |||
} | |||
} else { | |||
if limit == 0 && start == 0 { | |||
err = Db.Where("uid = ? AND provider = ?", uid, provider).Desc("create_at").Find(&m) | |||
} else { | |||
err = Db.Where("uid = ? AND provider = ?", uid, provider).Desc("create_at").Limit(limit, start).Find(&m) | |||
} | |||
} | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
//UserFavFindSearchByTitle is 我的收藏搜索 | |||
func UserFavFindSearchByTitle(Db *xorm.Engine, uid interface{}, title string, limit, start int) ([]*model.UserFavorite, error) { | |||
var m []*model.UserFavorite | |||
var err error | |||
if limit == 0 && start == 0 { | |||
err = Db.Where("item_title like ?", "%"+title+"%").Desc("create_at").Find(&m) | |||
} else { | |||
err = Db.Where("item_title like ?", "%"+title+"%").Desc("create_at").Limit(limit, start).Find(&m) | |||
} | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
// UserFavDelete is 删除收藏夹 | |||
func UserFavDelete(Db *xorm.Engine, uid interface{}, itemIds []interface{}) (int64, error) { | |||
var m model.UserFavorite | |||
affect, err := Db.Where("uid = ?", uid).In("item_id", itemIds).Delete(&m) | |||
if err != nil { | |||
return 0, logx.Warn(err) | |||
} | |||
return affect, nil | |||
} | |||
// UserFavDeleteByUserDelete is 删除用户时删除对应的收藏夹 | |||
func UserFavDeleteByUserDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
var m model.UserFavorite | |||
affect, err := Db.Where("uid = ?", uid).Delete(&m) | |||
if err != nil { | |||
return 0, logx.Warn(err) | |||
} | |||
return affect, nil | |||
} |
@@ -1,71 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
// GetFinUserFlowByID is 用户流水记录 | |||
func GetFinUserFlowByID(Db *xorm.Engine, id interface{}) (*model.FinUserFlow, error) { | |||
var m model.FinUserFlow | |||
if has, err := Db.Where("id = ?", id).Get(&m); err != nil || !has { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// GetFinUserFlowByID is 用户流水记录 | |||
func GetFinUserFlowByUIDANDOID(Db *xorm.Engine, types, uid, ordId string) (*model.FinUserFlow, error) { | |||
var m model.FinUserFlow | |||
if has, err := Db.Where("uid = ? and ord_id = ? and type = ?", uid, ordId, types).Get(&m); err != nil || !has { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//FinUserFlowInsertOne is 插入一条流水记录 | |||
func FinUserFlowInsertOne(Db *xorm.Engine, m *model.FinUserFlow) error { | |||
_, err := Db.InsertOne(m) | |||
if err != nil { | |||
return err | |||
} | |||
return nil | |||
} | |||
// FinUserFlowByUID is 用户流水 | |||
func FinUserFlowInputByUID(Db *xorm.Engine, uid interface{}, time string, limit, start int) ([]*model.FinUserFlow, error) { | |||
var m []*model.FinUserFlow | |||
if err := Db.Where("uid = ? AND create_at like ?", uid, time+"%").In("type", "0").Desc("create_at").Limit(limit, start).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
// FinUserFlowByUIDByOrderAction is 用户流水 by OrderAction | |||
func FinUserFlowInputByUIDByOrderActionByTime(Db *xorm.Engine, uid, oa interface{}, time string, limit, start int) ([]*model.FinUserFlow, error) { | |||
var m []*model.FinUserFlow | |||
if err := Db.Where("uid = ? AND ord_action = ? AND create_at like ?", uid, oa, time+"%").Desc("create_at").Limit(limit, start).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
// FinUserFlowByUIDByOrderAction is 用户流水 by OrderAction | |||
func FinUserFlowInputByUIDByTypeByTime(Db *xorm.Engine, uid int, time string, limit, start int) ([]*model.FinUserFlow, error) { | |||
var m []*model.FinUserFlow | |||
if err := Db.Where("uid = ? AND type = 1 AND create_at like ?", uid, time+"%").Desc("create_at").Limit(limit, start).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
// 在事务中使用,插入一条流水记录 | |||
func FinUserFlowInsertOneWithSession(session *xorm.Session, m *model.FinUserFlow) error { | |||
_, err := session.InsertOne(m) | |||
if err != nil { | |||
return err | |||
} | |||
return nil | |||
} |
@@ -1,91 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
// GetUserFootMark is 获取商品足迹 | |||
func GetUserFootMark(Db *xorm.Engine, uid, itemid interface{}) (*model.UserFootMark, error) { | |||
var m model.UserFootMark | |||
if has, err := Db.Where("uid = ? AND item_id = ?", uid, itemid).Get(&m); err != nil || !has { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//InsertUserFavOne is 插入一条足迹记录 | |||
func InsertUserFootMarkOne(Db *xorm.Engine, m *model.UserFootMark) (int64, error) { | |||
affected, err := Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
// UpdateUserFootMarkOne is 更新一条足迹记录 | |||
func UpdateUserFootMarkOne(Db *xorm.Engine, m *model.UserFootMark) (int64, error) { | |||
row, err := Db.ID(m.Id).AllCols().Update(m) | |||
return row, err | |||
} | |||
//UserFootMarkFindByProvider 根据提供商来筛选足迹的 | |||
func UserFootMarkFindByProvider(Db *xorm.Engine, uid interface{}, provider string, limit, start int) ([]*model.UserFootMark, error) { | |||
var m []*model.UserFootMark | |||
var err error | |||
if provider == "all" { | |||
if limit == 0 && start == 0 { | |||
err = Db.Where("uid = ?", uid).Desc("create_at").Find(&m) | |||
} else { | |||
err = Db.Where("uid = ?", uid).Desc("create_at").Limit(limit, start).Find(&m) | |||
} | |||
} else { | |||
if limit == 0 && start == 0 { | |||
err = Db.Where("uid = ? AND provider = ?", uid, provider).Desc("create_at").Find(&m) | |||
} else { | |||
err = Db.Where("uid = ? AND provider = ?", uid, provider).Desc("create_at").Limit(limit, start).Find(&m) | |||
} | |||
} | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
//UserFootMarkFindSearchByTitle is 我的足迹搜索 | |||
func UserFootMarkFindSearchByTitle(Db *xorm.Engine, uid interface{}, title string, limit, start int) ([]*model.UserFootMark, error) { | |||
var m []*model.UserFootMark | |||
var err error | |||
if limit == 0 && start == 0 { | |||
err = Db.Where("item_title like ?", "%"+title+"%").Desc("create_at").Find(&m) | |||
} else { | |||
err = Db.Where("item_title like ?", "%"+title+"%").Desc("create_at").Limit(limit, start).Find(&m) | |||
} | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
// UserFootMarkDelete is 删除足迹夹 | |||
func UserFootMarkDelete(Db *xorm.Engine, uid interface{}, itemIds []interface{}) (int64, error) { | |||
var m model.UserFootMark | |||
affect, err := Db.Where("uid = ?", uid).In("item_id", itemIds).Delete(&m) | |||
if err != nil { | |||
return 0, logx.Warn(err) | |||
} | |||
return affect, nil | |||
} | |||
// UserFootMarkDeleteByUserDelete is 删除用户时删除对应的足迹夹 | |||
func UserFootMarkDeleteByUserDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
var m model.UserFootMark | |||
affect, err := Db.Where("uid = ?", uid).Delete(&m) | |||
if err != nil { | |||
return 0, logx.Warn(err) | |||
} | |||
return affect, nil | |||
} |
@@ -1,123 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"github.com/gin-gonic/gin" | |||
"xorm.io/xorm" | |||
) | |||
//UserLevelByID is 根据用户id 获取对应的等级信息 | |||
func UserLevelByID(Db *xorm.Engine, id interface{}) (*model.UserLevel, error) { | |||
m := new(model.UserLevel) | |||
has, err := Db.Where("id = ?", id).Get(m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
if !has { | |||
return nil, logx.Error("Not found") | |||
} | |||
return m, nil | |||
} | |||
//UserLevelTop is 查询最高的等级 | |||
func UserLevelTop(Db *xorm.Engine) (*model.UserLevel, error) { | |||
m := new(model.UserLevel) | |||
has, err := Db.OrderBy("level_weight DESC").Get(m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
if !has { | |||
return nil, logx.Error("Not found") | |||
} | |||
return m, nil | |||
} | |||
//UserLevelNext is 查询下一等级 | |||
func UserLevelNext(Db *xorm.Engine, curLevelWeight int) (*model.UserLevel, error) { | |||
m := new(model.UserLevel) | |||
has, err := Db.Where("level_weight > ?", curLevelWeight).OrderBy("level_weight ASC").Get(m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
if !has { | |||
return nil, logx.Error("Not found") | |||
} | |||
return m, nil | |||
} | |||
// UserLevelByWeight is 根据权重获取对应的等级 | |||
func UserLevelByWeight(Db *xorm.Engine, w interface{}) (*model.UserLevel, error) { | |||
m := new(model.UserLevel) | |||
has, err := Db.Where("level_weight = ?", w).Get(m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
if !has { | |||
return nil, logx.Warn("Not found") | |||
} | |||
return m, nil | |||
} | |||
//UserLevelInIDescByWeight is In 查询获取 权重最低 对应等级 | |||
func UserLevelInIDescByWeightLow(Db *xorm.Engine) ([]*model.UserLevel, error) { | |||
var ms []*model.UserLevel | |||
if err := Db.Asc("level_weight").Limit(1).Find(&ms); err != nil { | |||
return nil, err | |||
} | |||
return ms, nil | |||
} | |||
//UserLevelInIDescByWeight is In 查询获取对应等级 根据权重排序 | |||
func UserLevelInIDescByWeight(Db *xorm.Engine, ids []int) ([]*model.UserLevel, error) { | |||
var ms []*model.UserLevel | |||
if err := Db.In("id", ids).Desc("level_weight").Find(&ms); err != nil { | |||
return nil, err | |||
} | |||
return ms, nil | |||
} | |||
// UserLevlAll is 获取所有开启等级并且升序返回 | |||
func UserLevlAll(c *gin.Context, Db *xorm.Engine) ([]*model.UserLevel, error) { | |||
var m []*model.UserLevel | |||
err := Db.Where("is_use = ?", 1).Asc("level_weight").Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.([]*model.UserLevel), nil | |||
} | |||
// UserLevlEgAll is 获取所有开启等级并且升序返回 | |||
func UserLevlEgAll(Db *xorm.Engine) ([]*model.UserLevel, error) { | |||
var m []*model.UserLevel | |||
err := Db.Where("is_use = ?", 1).Asc("level_weight").Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
// UserLevlAllByWeight is 获取所有等级并且权重升序返回 | |||
func UserLevlAllByWeight(c *gin.Context, Db *xorm.Engine) ([]*model.UserLevel, error) { | |||
var m []*model.UserLevel | |||
err := Db.Asc("level_weight").Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
mm, err := sysModFormat(c, m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return mm.([]*model.UserLevel), nil | |||
} |
@@ -1,72 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
// 用户当前等级正在审核中的记录 | |||
func UserLevelAuditingFindByUidAndLevel(Db *xorm.Engine, uid int, levelId int) (*model.UserLevelAudit, error) { | |||
var m model.UserLevelAudit | |||
has, err := Db.Where("uid=? AND state=? AND current_level_id=?", uid, 1, levelId).Get(&m) | |||
if err != nil || !has { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// 用户正在审核中的记录 | |||
func UserLevelAuditingFindByUid(Db *xorm.Engine, uid int) (*model.UserLevelAudit, error) { | |||
var m model.UserLevelAudit | |||
has, err := Db.Where("uid=? AND state=?", uid, 1).Get(&m) | |||
if err != nil || !has { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
// 插入一条记录 | |||
func UserLevelAuditInsertWithSession(Db *xorm.Session, data *model.UserLevelAudit) (int64, error) { | |||
affect, err := Db.Insert(data) | |||
if err != nil || affect != 1 { | |||
return 0, err | |||
} | |||
return affect, nil | |||
} | |||
func UserLevelAuditFindById(Db *xorm.Engine, id int) (*model.UserLevelAudit, error) { | |||
var m model.UserLevelAudit | |||
has, err := Db.Where("id=?", id).Get(&m) | |||
if err != nil || !has { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
func UserLevelAuditFindByIdAndUid(Db *xorm.Engine, id int, uid int) (*model.UserLevelAudit, error) { | |||
var m model.UserLevelAudit | |||
has, err := Db.Where("next_level_id=? AND uid=? AND state<>2", id, uid).Get(&m) | |||
if err != nil || !has { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
// 更新审核记录 | |||
func UserLevelAuditUpdateByIdWithSession(session *xorm.Session, id int, audit *model.UserLevelAudit, forceColumns ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColumns != nil { | |||
affected, err = session.Where("id=?", id).Cols(forceColumns...).Update(audit) | |||
} else { | |||
affected, err = session.Where("id=?", id).Update(audit) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} |
@@ -1,145 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"time" | |||
"xorm.io/xorm" | |||
) | |||
// 获取对应等级未过期的付费订单 | |||
func UserLevelOrderListByUIDByLevelTypeByExpire(Db *xorm.Engine, uid, levelID interface{}) ([]*model.UserLevelOrd, error) { | |||
var m []*model.UserLevelOrd | |||
err := Db.Where("uid = ? AND level_id = ? AND state = ? ", uid, levelID, 1).Desc("expire_at").Find(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
// OrderListByPvdAndNoSettledWithPage is 查询未结算订单 | |||
func UserLevelOrderListByUIDByNoSettledWithPage(Db *xorm.Engine, page int) ([]*model.UserLevelOrd, error) { | |||
perPage := 100 | |||
startPlace := (page - 1) * perPage | |||
var o []*model.UserLevelOrd | |||
err := Db.Where("settle_at=?", 0).In("state", 1).Limit(perPage, startPlace).Find(&o) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return o, nil | |||
} | |||
// 获取一个订单 | |||
func UserLevelOrderById(Db *xorm.Engine, id string) (*model.UserLevelOrd, error) { | |||
var m *model.UserLevelOrd | |||
has, err := Db.Where("id = ? ", id).Get(&m) | |||
if err != nil || has == false { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
//UserLevelOrderListByUIDByLevelByDateTypeByExpire is 获取某用户某等级的订单,按照过期时间降序排序 | |||
func UserLevelOrderListByUIDByLevelByDateTypeByExpire(Db *xorm.Engine, uid, levelID, t interface{}) ([]*model.UserLevelOrd, error) { | |||
var m []*model.UserLevelOrd | |||
err := Db.Where("uid = ? AND level_id = ? AND date_type = ? AND state = ? ", uid, levelID, t, 1).Desc("expire_at").Find(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
//UserLevelOrderOneByUIDByLevelByDateTypeByExpire is 获取某用户某等级的订单,按照过期时间降序排序 | |||
func UserLevelOrderOneByUIDByLevelByDateTypeByExpire(Db *xorm.Engine, uid, levelID interface{}) ([]*model.UserLevelOrd, error) { | |||
var m []*model.UserLevelOrd | |||
err := Db.Where("uid = ? AND level_id = ? and state = 1", uid, levelID).Desc("expire_at").Find(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
//UserLevelOrdInsertOne is 插入一个 等级付费升级的订单 | |||
func UserLevelOrdInsertOne(Db *xorm.Engine, order *model.UserLevelOrd) (int64, error) { | |||
affect, err := Db.InsertOne(order) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affect, nil | |||
} | |||
//UserLevelOrdUpdateOne is 更新付费升级订单 | |||
func UserLevelOrdUpdateOne(Db *xorm.Engine, order *model.UserLevelOrd) (int64, error) { | |||
affect, err := Db.ID(order.Id).Update(order) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affect, nil | |||
} | |||
func UserLevelOrdUpdateOneWithSession(Db *xorm.Session, order *model.UserLevelOrd) (int64, error) { | |||
affect, err := Db.ID(order.Id).Update(order) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affect, nil | |||
} | |||
func UserLevelOrdFindOneByOid(Db *xorm.Engine, id int64) (*model.UserLevelOrd, error) { | |||
var m model.UserLevelOrd | |||
has, err := Db.Where("id=? AND state=?", id, 1).Get(&m) | |||
if err != nil || !has { | |||
return nil, err | |||
} | |||
return &m, nil | |||
} | |||
func UserLevelOrdFindByUidStateLevelAndNotExpire(Db *xorm.Engine, uid int, state int, level string) (*model.UserLevelOrd, error) { | |||
var m model.UserLevelOrd | |||
//过期时间还没到 或者是永久的订单 | |||
if has, err := Db.Where("uid = ? AND level_id = ? AND state = ? AND (expire_at>= ? OR date_type=4)", uid, level, state, time.Now().Unix()).Get(&m); !has || err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// 查询订单状态 | |||
func UserLevelOrdFindByID(Db *xorm.Engine, id int) (*model.UserLevelOrd, error) { | |||
var m model.UserLevelOrd | |||
if has, err := Db.Where("id = ?", id).Get(&m); !has || err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// 获取对应id订单 | |||
func UserLevelOrdFindByIDs(Db *xorm.Engine, ids []int) ([]*model.UserLevelOrd, error) { | |||
var m []*model.UserLevelOrd | |||
err := Db.In("id", ids).Find(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
//session事务修改订单 | |||
func UserLvUpOrderUpdateWithSession(session *xorm.Session, ordId int64, order *model.UserLevelOrd, forceCols ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceCols != nil { | |||
affected, err = session.Where("id=?", ordId).Cols(forceCols...).Update(order) | |||
} else { | |||
affected, err = session.Where("id=?", ordId).Update(order) | |||
} | |||
if err != nil { | |||
return 0, logx.Warn(err) | |||
} | |||
return affected, nil | |||
} |
@@ -1,39 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"errors" | |||
"xorm.io/xorm" | |||
) | |||
//UserLevelTaskInIDS is 根据ids 获取等级任务 | |||
func UserLevelTaskInIDS(Db *xorm.Engine, ids []int) ([]*model.UserLevelTask, error) { | |||
var m []*model.UserLevelTask | |||
if err := Db.In("level_id", ids).Asc("level_id").Find(&m); err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
//UserLevelTaskByID is 根据id 获取等级任务列表 | |||
func UserLevelTaskByID(Db *xorm.Engine, id interface{}) ([]*model.UserLevelTask, error) { | |||
var m []*model.UserLevelTask | |||
if err := Db.Where("level_id = ?", id).Find(&m); err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
//UserLevelTaskOneByID is 根据id 获取等级任务 | |||
func UserLevelTaskOneByID(Db *xorm.Engine, id interface{}) (*model.UserLevelTask, error) { | |||
m := new(model.UserLevelTask) | |||
has, err := Db.Where("id = ?", id).Get(m) | |||
//fmt.Println(m) | |||
if !has { | |||
return nil, errors.New("Not found") | |||
} | |||
if err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} |
@@ -1,188 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
//UserNoticeByReceiverByTime is 获取改接收者的 | |||
func UserNoticeByReceiverByTime(Db *xorm.Engine, uid interface{}, sort string) (*[]model.UserNotice, error) { | |||
switch sort { | |||
case "desc": | |||
// 降序 | |||
var m []model.UserNotice | |||
err := Db.Where("receiver = ?", uid).Desc("create_at").Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
case "asc": | |||
//升序 | |||
var m []model.UserNotice | |||
err := Db.Where("receiver = ?", uid).Asc("create_at").Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
default: | |||
//默认 | |||
var m []model.UserNotice | |||
err := Db.Where("receiver = ?", uid).Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
} | |||
//UserNoticeByReceiverByTimeByType is 获取改接收者的By Type | |||
func UserNoticeByReceiverByTimeByType(Db *xorm.Engine, uid, t interface{}, sort string, limit, start int) (*[]model.UserNotice, error) { | |||
switch sort { | |||
case "desc": | |||
// 降序 | |||
var m []model.UserNotice | |||
if limit == 0 && start == 0 { | |||
err := Db.Where("receiver = ? AND type = ?", uid, t).Desc("create_at").Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
err := Db.Where("receiver = ? AND type = ?", uid, t).Desc("create_at").Limit(limit, start).Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
case "asc": | |||
//升序 | |||
var m []model.UserNotice | |||
if limit == 0 && start == 0 { | |||
err := Db.Where("receiver = ? AND type = ?", uid, t).Asc("create_at").Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
err := Db.Where("receiver = ? AND type = ?", uid, t).Asc("create_at").Limit(limit, start).Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
default: | |||
//默认 | |||
var m []model.UserNotice | |||
if limit == 0 && start == 0 { | |||
err := Db.Where("receiver = ? AND type = ?", uid).Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
err := Db.Where("receiver = ? AND type = ?", uid, t).Limit(limit, start).Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
} | |||
//GetUserNoticeByReceiverByTimeByType is 获取改接收者的By Type | |||
func GetUserNoticeByReceiverByTimeByType(Db *xorm.Engine, uid, t interface{}, sort string) (*model.UserNotice, error) { | |||
var ( | |||
has bool | |||
err error | |||
) | |||
switch sort { | |||
case "desc": | |||
// 降序 | |||
var m model.UserNotice | |||
if t == 0 || t == 1 { | |||
// fmt.Println(t) | |||
has, err = Db.Where("receiver = '0' AND type = ?", t).Desc("create_at").Get(&m) | |||
} else { | |||
has, err = Db.Where("receiver = ? AND type = ?", uid, t).Desc("create_at").Get(&m) | |||
} | |||
if !has { | |||
return &m, logx.Warn("Not found") | |||
} | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
case "asc": | |||
//升序 | |||
var m model.UserNotice | |||
if t == 0 || t == 1 { | |||
has, err = Db.Where("receiver = '0' AND type = ?", t).Asc("create_at").Get(&m) | |||
} else { | |||
has, err = Db.Where("receiver = ? AND type = ?", uid, t).Asc("create_at").Get(&m) | |||
} | |||
if !has { | |||
return &m, logx.Warn("Not found") | |||
} | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
default: | |||
//默认 | |||
var m model.UserNotice | |||
if t == 0 || t == 1 { | |||
// fmt.Println(t) | |||
has, err = Db.Where("receiver = '0' AND type = ?", t).Get(&m) | |||
} else { | |||
has, err = Db.Where("receiver = ? AND type = ?", uid, t).Get(&m) | |||
} | |||
if !has { | |||
return &m, logx.Warn("Not found") | |||
} | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
} | |||
//GetUserUnReadCountByType is 获取 | |||
func GetUserUnReadCountByType(Db *xorm.Engine, id, t interface{}) (int64, error) { | |||
var ( | |||
count int64 | |||
err error | |||
) | |||
n := new(model.UserNotice) | |||
if t == 0 || t == 1 { | |||
count, err = Db.Where("receiver = '0' AND type = ? AND status = '0'", t).Count(n) | |||
} else { | |||
count, err = Db.Where("receiver = ? AND type = ? AND status = '0'", id, t).Count(n) | |||
} | |||
if err != nil { | |||
return 0, nil | |||
} | |||
return count, nil | |||
} | |||
//BatchUpdateUserNoticeRead is 批量更新某种类型的通知 | |||
func BatchUpdateUserNoticeRead(Db *xorm.Engine, uid, t interface{}) error { | |||
sql := "update user_notice set status = ? where receiver = ? and type = ?" | |||
_, err := Db.Exec(sql, 1, uid, t) | |||
if err != nil { | |||
return logx.Warn(err) | |||
} | |||
return nil | |||
} | |||
//UserNoticeInsertOne 插入一条通知数据 | |||
func UserNoticeInsertOne(Db *xorm.Engine, m *model.UserNotice) error { | |||
_, err := Db.InsertOne(m) | |||
if err != nil { | |||
return logx.Warn(err) | |||
} | |||
return nil | |||
} | |||
//UserNoticeDeleteByUserDelete is 删除用户通知 | |||
func UserNoticeDeleteByUserDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
return Db.Where("receiver = ? OR sender = ?", uid, uid).Delete(model.UserNotice{}) | |||
} |
@@ -1,438 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/md" | |||
"applet/app/utils/logx" | |||
"errors" | |||
"xorm.io/xorm" | |||
) | |||
//UserProfileFindByArkID is get userprofile by arkid | |||
func UserProfileFindByArkID(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("arkid_uid = ?", id).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserProfileFindByInviteCode is get userprofile by InviteCode | |||
func UserProfileFindByInviteCode(Db *xorm.Engine, code string) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("invite_code = ?", code).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserProfileFindByInviteCode is get userprofile by InviteCode | |||
func UserProfileFindByCustomInviteCode(Db *xorm.Engine, code string) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("custom_invite_code = ?", code).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserProfileFindByInviteCodes is get userprofile by InviteCode | |||
func UserProfileFindByInviteCodes(Db *xorm.Engine, codes ...string) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if err := Db.In("invite_code", codes).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserProfileFindByCustomInviteCodes is get userprofile by CustomInviteCode | |||
func UserProfileFindByCustomInviteCodes(Db *xorm.Engine, codes ...string) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if err := Db.In("custom_invite_code", codes).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileFindByID search user_profile by userid | |||
func UserProfileFindByID(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("uid = ?", id).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileOrderByNew 找最新的记录 | |||
func UserProfileOrderByNew(Db *xorm.Engine) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("invite_code != ''").OrderBy("uid desc").Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileFindByTaobaoOpenID search user_profile ByTaobaoOpenID | |||
func UserProfileFindByTaobaoOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("third_party_taobao_oid = ?", openid).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileFindByQQOpenID search user_profile ByTaobaoOpenID | |||
func UserProfileFindByQQOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("third_party_qq_openid = ?", openid).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileFindByAppleToken search user_profile AppleToken | |||
func UserProfileFindByAppleToken(Db *xorm.Engine, token interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("third_party_apple_token = ?", token).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileFindByWeChatOpenID search user_profile By 微信openid | |||
func UserProfileFindByWeChatOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("third_party_wechat_openid = ?", openid).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileFindByWeChatMiniOpenID search user_profile By 小程序openid | |||
func UserProfileFindByWeChatMiniOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("third_party_wechat_mini_openid = ?", openid).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileFindByWeChatUnionID search user_profile By 微信唯一id | |||
func UserProfileFindByWeChatUnionID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("third_party_wechat_unionid = ?", openid).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileisExistByTaobaoOpenID is exist by Taobao | |||
func UserProfileisExistByTaobaoOpenID(Db *xorm.Engine, openid string) (bool, error) { | |||
has, err := Db.Where("third_party_taobao_oid = ?", openid).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileisExistByQQOpenID is exist by QQ openid | |||
func UserProfileisExistByQQOpenID(Db *xorm.Engine, openid string) (bool, error) { | |||
has, err := Db.Where("third_party_qq_openid = ?", openid).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileisExistByAppleToken is exist by apple token | |||
func UserProfileisExistByAppleToken(Db *xorm.Engine, token string) (bool, error) { | |||
has, err := Db.Where("third_party_apple_token = ?", token).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileisExistByWeChatOpenID is exist by Wecaht openid | |||
func UserProfileisExistByWeChatOpenID(Db *xorm.Engine, openid string) (bool, error) { | |||
has, err := Db.Where("third_party_wechat_openid = ?", openid).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileisExistByWeChatMiniOpenID is exist by Wecaht openid | |||
func UserProfileisExistByWeChatMiniOpenID(Db *xorm.Engine, openid string) (bool, error) { | |||
has, err := Db.Where("third_party_wechat_mini_openid = ?", openid).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileisExistByWeChatUnionID is exist by Wecaht openid | |||
func UserProfileisExistByWeChatUnionID(Db *xorm.Engine, openid string) (bool, error) { | |||
has, err := Db.Where("third_party_wechat_unionid = ?", openid).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileisExistByRelationIDAndSpecialID is exist by RelationIdAndSpecialId | |||
func UserProfileisExistByRelationIDAndSpecialID(Db *xorm.Engine, SpecialID, RelationID int64) (bool, error) { | |||
has, err := Db.Where("acc_taobao_self_id = ? AND acc_taobao_share_id = ?", SpecialID, RelationID).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileisExistBySpecialID is exist by SpecialId | |||
func UserProfileisExistBySpecialID(Db *xorm.Engine, SpecialID string) (bool, error) { | |||
has, err := Db.Where("acc_taobao_self_id = ? ", SpecialID).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileCountByRelationID 统计relationID数量 | |||
func UserProfileCountByRelationID(Db *xorm.Engine) (total int64, err error) { | |||
relate := new(model.UserProfile) | |||
total, err = Db.Where("acc_taobao_share_id > 0").Count(relate) | |||
return | |||
} | |||
// UserProfileCountByPUID 统计直推下级数量 | |||
func UserProfileCountByPUID(Db *xorm.Engine, puid int) (total int64, err error) { | |||
relate := new(model.UserProfile) | |||
total, err = Db.Where("parent_uid = ?", puid).Count(relate) | |||
return | |||
} | |||
// UserProfileisExistByRelationID is exist by RelationID | |||
func UserProfileisExistByRelationID(Db *xorm.Engine, RelationID string) (bool, error) { | |||
has, err := Db.Where("acc_taobao_share_id = ? ", RelationID).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileFindByIDs is in sql by ids | |||
func UserProfileFindByIDs(Db *xorm.Engine, uids ...int) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if err := Db.In("uid", uids).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileByPuid search user_profile by parent_uid | |||
func UserProfileByPuid(Db *xorm.Engine, puid interface{}) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if err := Db.Where("parent_uid = ?", puid).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UsersProfileInByIds is profiles by ids | |||
func UsersProfileInByIds(Db *xorm.Engine, ids []int, limit, start int) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if limit == 0 && start == 0 { | |||
if err := Db.In("uid", ids).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
if err := Db.In("uid", ids).Limit(limit, start).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UsersProfileInByUIDByisVerify is In查询 以及是否是有效用户 | |||
func UsersProfileInByUIDByisVerify(Db *xorm.Engine, ids []int, isVerify interface{}) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if err := Db.In("uid", ids).Where("is_verify = ?", isVerify). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UsersProfileInByIdsByDesc is 根据某列 降序 | |||
func UsersProfileInByIdsByDesc(Db *xorm.Engine, ids []int, limit, start int, c string) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if limit == 0 && start == 0 { | |||
if err := Db.In("uid", ids).Desc(c).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
if err := Db.In("uid", ids).Desc(c).Limit(limit, start).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UsersProfileInByIdsByAsc is 根据某列 升序 | |||
func UsersProfileInByIdsByAsc(Db *xorm.Engine, ids []int, limit, start int, c string) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if limit == 0 && start == 0 { | |||
if err := Db.In("uid", ids).Asc(c).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
if err := Db.In("uid", ids).Asc(c).Limit(limit, start).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UsersProfileByAll is 查询所有分享id大于0的数据 | |||
func UsersProfileByTaobaoShateIdNotNull(Db *xorm.Engine, limit, start int) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if err := Db.Where("acc_taobao_share_id > 0").Limit(limit, start).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserProfileIsExistByUserID is mobile exist | |||
func UserProfileIsExistByUserID(Db *xorm.Engine, id int) (bool, error) { | |||
has, err := Db.Where("uid = ?", id).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileIsExistByInviteCode is exist ? | |||
func UserProfileIsExistByInviteCode(Db *xorm.Engine, code string) (bool, error) { | |||
has, err := Db.Where("invite_code = ?", code).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
// UserProfileIsExistByCustomInviteCode is exist ? | |||
func UserProfileIsExistByCustomInviteCode(Db *xorm.Engine, code string) (bool, error) { | |||
has, err := Db.Where("custom_invite_code = ?", code).Exist(&model.UserProfile{}) | |||
if err != nil { | |||
return false, err | |||
} | |||
return has, nil | |||
} | |||
//UserProfileInsert is insert user | |||
func UserProfileInsert(Db *xorm.Engine, userProfile *model.UserProfile) (int64, error) { | |||
affected, err := Db.Insert(userProfile) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
//UserProfileUpdate is update userprofile | |||
func UserProfileUpdate(Db *xorm.Engine, uid interface{}, userProfile *model.UserProfile, forceCols ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceCols != nil { | |||
affected, err = Db.Where("uid=?", uid).Cols(forceCols...).Update(userProfile) | |||
} else { | |||
affected, err = Db.Where("uid=?", uid).Update(userProfile) | |||
} | |||
if err != nil { | |||
return 0, logx.Warn(err) | |||
} | |||
return affected, nil | |||
} | |||
//UserProfileUpdateByArkID is update userprofile | |||
func UserProfileUpdateByArkID(Db *xorm.Engine, arkid interface{}, userProfile *model.UserProfile, forceCols ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceCols != nil { | |||
affected, err = Db.Where("arkid_uid=?", arkid).Cols(forceCols...).Update(userProfile) | |||
} else { | |||
affected, err = Db.Where("arkid_uid=?", arkid).Update(userProfile) | |||
} | |||
if err != nil { | |||
return 0, logx.Warn(err) | |||
} | |||
return affected, nil | |||
} | |||
// UserProfileDelete is delete user profile | |||
func UserProfileDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
return Db.Where("uid = ?", uid).Delete(model.UserProfile{}) | |||
} | |||
func UserProfileFindByIdWithSession(session *xorm.Session, uid int) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := session.Where("uid = ?", uid).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// 在事务中更新用户信息 | |||
func UserProfileUpdateWithSession(session *xorm.Session, uid interface{}, userProfile *model.UserProfile, forceCols ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceCols != nil { | |||
affected, err = session.Where("uid=?", uid).Cols(forceCols...).Update(userProfile) | |||
} else { | |||
affected, err = session.Where("uid=?", uid).Update(userProfile) | |||
} | |||
if err != nil { | |||
return 0, logx.Warn(err) | |||
} | |||
return affected, nil | |||
} | |||
// 根据uid获取md.user | |||
func UserAllInfoByUid(Db *xorm.Engine, uid interface{}) (*md.User, error) { | |||
u, err := UserFindByID(Db, uid) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if u == nil { | |||
return nil, errors.New("user is nil") | |||
} | |||
up, err := UserProfileFindByID(Db, uid) | |||
if err != nil { | |||
return nil, err | |||
} | |||
// 获取user 等级 | |||
ul, err := UserLevelByID(Db, u.Level) | |||
if err != nil { | |||
return nil, err | |||
} | |||
user := &md.User{ | |||
Info: u, | |||
Profile: up, | |||
Level: ul, | |||
} | |||
return user, nil | |||
} |
@@ -1,213 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
// UserRelateInsert is 插入一条数据到用户关系表 | |||
func UserRelateInsert(Db *xorm.Engine, userRelate *model.UserRelate) (int64, error) { | |||
affected, err := Db.Insert(userRelate) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
//UserRelateByPuid is 获取用户关系列表 by puid | |||
func UserRelatesByPuid(Db *xorm.Engine, puid interface{}, limit, start int) (*[]model.UserRelate, error) { | |||
var m []model.UserRelate | |||
if limit == 0 && start == 0 { | |||
if err := Db.Where("parent_uid = ?", puid). | |||
Cols(`id,parent_uid,uid,level,invite_time`). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
if err := Db.Where("parent_uid = ?", puid). | |||
Cols(`id,parent_uid,uid,level,invite_time`).Limit(limit, start). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserRelatesByPuidByLv is 获取用户关系列表 by puid 和lv | |||
func UserRelatesByPuidByLv(Db *xorm.Engine, puid, lv interface{}, limit, start int) (*[]model.UserRelate, error) { | |||
var m []model.UserRelate | |||
if limit == 0 && start == 0 { | |||
if err := Db.Where("parent_uid = ? AND level = ?", puid, lv). | |||
Cols(`id,parent_uid,uid,level,invite_time`). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
if err := Db.Where("parent_uid = ? AND level = ?", puid, lv). | |||
Cols(`id,parent_uid,uid,level,invite_time`).Limit(limit, start). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserRelatesByPuidByLvByTime is 获取直属 level =1用户关系列表 by puid 和lv by time | |||
func UserRelatesByPuidByLvByTime(Db *xorm.Engine, puid, lv, stime, etime interface{}, limit, start int) (*[]model.UserRelate, error) { | |||
var m []model.UserRelate | |||
if limit == 0 && start == 0 { | |||
if err := Db.Where("parent_uid = ? AND level = ? AND invite_time > ? AND invite_time < ?", puid, lv, stime, etime). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
if err := Db.Where("parent_uid = ? AND level = ? AND invite_time > ? AND invite_time < ?", puid, lv, stime, etime). | |||
Limit(limit, start). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserRelatesByPuidByTime is 获取户关系列表 by puid 和lv by time | |||
func UserRelatesByPuidByTime(Db *xorm.Engine, puid, stime, etime interface{}, limit, start int) (*[]model.UserRelate, error) { | |||
var m []model.UserRelate | |||
if limit == 0 && start == 0 { | |||
if err := Db.Where("parent_uid = ? AND invite_time > ? AND invite_time < ?", puid, stime, etime). | |||
Cols(`id,parent_uid,uid,level,invite_time`). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
if err := Db.Where("parent_uid = ? AND invite_time > ? AND invite_time < ?", puid, stime, etime). | |||
Cols(`id,parent_uid,uid,level,invite_time`).Limit(limit, start). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserRelatesByPuidExceptLv is 获取用户关系列表 by puid 和非 lv | |||
func UserRelatesByPuidExceptLv(Db *xorm.Engine, puid, lv interface{}, limit, start int) (*[]model.UserRelate, error) { | |||
var m []model.UserRelate | |||
if limit == 0 && start == 0 { | |||
if err := Db.Where("parent_uid = ? AND level != ?", puid, lv). | |||
Cols(`id,parent_uid,uid,level,invite_time`). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
if err := Db.Where("parent_uid = ? AND level != ?", puid, lv). | |||
Cols(`id,parent_uid,uid,level,invite_time`).Limit(limit, start). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserRelateByUID is 获取用户关系表 by uid | |||
func UserRelateByUID(Db *xorm.Engine, uid interface{}) (*model.UserRelate, bool, error) { | |||
r := new(model.UserRelate) | |||
has, err := Db.Where("uid=?", uid).Get(r) | |||
if err != nil { | |||
return nil, false, err | |||
} | |||
return r, has, nil | |||
} | |||
//UserRelateByUIDByLv is 获取用户关系表 by uid | |||
func UserRelateByUIDByLv(Db *xorm.Engine, uid, lv interface{}) (*model.UserRelate, bool, error) { | |||
r := new(model.UserRelate) | |||
has, err := Db.Where("uid=? AND level=?", uid, lv).Get(r) | |||
if err != nil { | |||
return nil, false, err | |||
} | |||
return r, has, nil | |||
} | |||
//UserRelateByUIDAndPUID 根据 Puid 和uid 查找 ,用于确认关联 | |||
func UserRelateByUIDAndPUID(Db *xorm.Engine, uid, puid interface{}) (*model.UserRelate, bool, error) { | |||
r := new(model.UserRelate) | |||
has, err := Db.Where("uid=? AND parent_uid=?", uid, puid).Get(r) | |||
if err != nil { | |||
return nil, false, err | |||
} | |||
return r, has, nil | |||
} | |||
//UserRelatesByPuIDAndLv is 查询用户关系表 获取指定等级和puid的关系 | |||
func UserRelatesByPuIDAndLv(Db *xorm.Engine, puid, lv interface{}) (*[]model.UserRelate, error) { | |||
var m []model.UserRelate | |||
if err := Db.Where("parent_uid = ? AND level = ?", puid, lv). | |||
Cols(`id,parent_uid,uid,level,invite_time`). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserRelateInByUID is In查询 | |||
func UserRelateInByUID(Db *xorm.Engine, ids []int) (*[]model.UserRelate, error) { | |||
var m []model.UserRelate | |||
if err := Db.In("uid", ids). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
// UserRelatesByUIDDescLv is Where 查询 根据level 降序 | |||
func UserRelatesByUIDDescLv(Db *xorm.Engine, id interface{}) (*[]model.UserRelate, error) { | |||
var m []model.UserRelate | |||
if err := Db.Where("uid = ?", id).Desc("level"). | |||
Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
//UserRelateCountByPUID is 根据puid 计数 | |||
func UserRelateCountByPUID(Db *xorm.Engine, pid interface{}) (int64, error) { | |||
count, err := Db.Where("parent_uid = ?", pid).Count(model.UserRelate{}) | |||
if err != nil { | |||
return 0, nil | |||
} | |||
return count, nil | |||
} | |||
//UserRelateDelete is 删除关联他上级的关系记录,以及删除他下级的关联记录 | |||
func UserRelateDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
// 删除与之上级的记录 | |||
_, err := Db.Where("uid = ?", uid).Delete(model.UserRelate{}) | |||
if err != nil { | |||
return 0, err | |||
} | |||
// 删除与之下级的记录 | |||
_, err = Db.Where("parent_uid = ?", uid).Delete(model.UserRelate{}) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return 1, nil | |||
} | |||
//UserRelateDelete is 删除关联他上级的关系记录 | |||
func UserRelateExtendDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
// 删除与之上级的记录 | |||
_, err := Db.Where("uid = ?", uid).Delete(model.UserRelate{}) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return 1, nil | |||
} |
@@ -1,25 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
//UserTagDeleteByUserDelete is 删除用户时删除用户标签 | |||
func UserTagDeleteByUserDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
return Db.Where("uid = ?", uid).Delete(model.UserTag{}) | |||
} | |||
func UserTagsByUid(Db *xorm.Engine, uid interface{}) ([]string, error) { | |||
var tagList []*model.UserTag | |||
if err := Db.Where("uid=?", uid).Cols("tag_name").Find(&tagList); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
var tags []string | |||
for _, item := range tagList { | |||
tags = append(tags, item.TagName) | |||
} | |||
return tags, nil | |||
} |
@@ -1,35 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"xorm.io/xorm" | |||
) | |||
func GetUserVirtualAmountOne(session *xorm.Session, uid int, coinId int) (*model.UserVirtualAmount, error) { | |||
var m model.UserVirtualAmount | |||
isExist, err := session.Table("user_virtual_amount").Where("uid = ? AND coin_id = ?", uid, coinId).Get(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !isExist { | |||
return nil, nil | |||
} | |||
return &m, nil | |||
} | |||
func GetUserVirtualAmountSum(eg *xorm.Engine, uid int, coinId int) (string, error) { | |||
//TODO 后面针对单个虚拟币 | |||
var m model.UserVirtualAmount | |||
sum, err := eg.Table("user_virtual_amount").Where("uid = ? ", uid).Sum(&m, "amount") | |||
if err != nil { | |||
return "0", err | |||
} | |||
return utils.Float64ToStr(sum), nil | |||
} | |||
/*func UserVirtualAmountUpdateWithSession(session *xorm.Session, m *model.UserVirtualAmount) bool { | |||
}*/ |
@@ -1,63 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/md" | |||
"applet/app/utils/cache" | |||
"errors" | |||
"fmt" | |||
"xorm.io/xorm" | |||
) | |||
func GetVirtualCoinList(eg *xorm.Engine, masterId string) ([]*model.VirtualCoin, error) { | |||
var m []*model.VirtualCoin | |||
cacheKey := fmt.Sprintf(md.VirtualCoinCfgCacheKey, masterId) | |||
err := cache.GetJson(cacheKey, &m) | |||
if err != nil || len(m) == 0 { | |||
err := eg.Where("is_use=1").Find(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
cache.SetJson(cacheKey, m, md.CfgCacheTime) | |||
} | |||
return m, nil | |||
} | |||
// InsertUserVirtualFlow 插入一条虚拟币流水 | |||
func InsertUserVirtualFlow(eg *xorm.Engine, m model.UserVirtualCoinFlow) error { | |||
insert, err := eg.Insert(m) | |||
if err != nil { | |||
return err | |||
} | |||
if insert == 0 { | |||
return errors.New("插入虚拟币流水错误") | |||
} | |||
return nil | |||
} | |||
func InsertUserVirtualFlowWithSess(sess *xorm.Session, m model.UserVirtualCoinFlow) error { | |||
insert, err := sess.Insert(m) | |||
if err != nil { | |||
return err | |||
} | |||
if insert == 0 { | |||
return errors.New("插入虚拟币流水错误") | |||
} | |||
return nil | |||
} | |||
func GetBlockCoin(eg *xorm.Engine) (*model.VirtualCoin, error) { | |||
var m model.VirtualCoin | |||
get, err := eg.Where("is_block = 1").Get(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if get { | |||
return &m, nil | |||
} | |||
return nil, errors.New("查询有误!") | |||
} |
@@ -1,16 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"xorm.io/xorm" | |||
) | |||
// 根据订单id查出相关的数据 | |||
func GetVirtualCoinRelateListWithOrdId(engine *xorm.Engine, ordId int64) ([]*model.VirtualCoinRelate, error) { | |||
var list []*model.VirtualCoinRelate | |||
err := engine.Table("virtual_coin_relate").Where("oid = ?", ordId).Find(&list) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return list, nil | |||
} |
@@ -1,6 +1,8 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"fmt" | |||
"os" | |||
"time" | |||
@@ -9,8 +11,6 @@ import ( | |||
"xorm.io/xorm/log" | |||
"applet/app/cfg" | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
) | |||
var DBs map[string]*xorm.Engine | |||
@@ -1,38 +0,0 @@ | |||
package db | |||
import ( | |||
"xorm.io/xorm" | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
) | |||
// 批量获取信息 | |||
func DbsDealOrderUseFindByIds(eg *xorm.Engine, types string, ids []string) (*[]model.DealOrderUser, error) { | |||
var ord []model.DealOrderUser | |||
if err := eg.In("id", ids). | |||
Where("type = ?", types). | |||
Find(&ord); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if len(ord) == 0 { | |||
return nil, nil | |||
} | |||
return &ord, nil | |||
} | |||
func DbsDealOrderUserUpdate(eg *xorm.Engine, id int, ord *model.DealOrderUser) error { | |||
if _, err := eg.Where(" `id` = ?", id).AllCols().Update(ord); err != nil { | |||
return logx.Warn(err) | |||
} | |||
return nil | |||
} | |||
func DbsDealOrderUserInsert(eg *xorm.Engine, ord *model.DealOrderUser) bool { | |||
_, err := eg.InsertOne(ord) | |||
if err != nil { | |||
logx.Warn(err) | |||
return false | |||
} | |||
return true | |||
} |
@@ -1,30 +0,0 @@ | |||
package db | |||
import ( | |||
"xorm.io/xorm" | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
) | |||
func DbsPlanCommissionById(eg *xorm.Engine, id int) (*model.PlanCommission, error) { | |||
var m model.PlanCommission | |||
if isGet, err := eg.Where("id = ?", id).Get(&m); err != nil || !isGet { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
func DbsPlanCommissionByIds(eg *xorm.Engine, ids ...int) []*model.PlanCommission { | |||
var m []*model.PlanCommission | |||
var err error | |||
if len(ids) > 0 { | |||
err = eg.In("id", ids).Find(&m) | |||
} else { | |||
err = eg.Find(&m) | |||
} | |||
if err != nil { | |||
return nil | |||
} | |||
return m | |||
} |
@@ -1,51 +0,0 @@ | |||
package db | |||
import ( | |||
"xorm.io/xorm" | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
) | |||
func DbsPlanRewardByPvd(eg *xorm.Engine, pvd string) (*model.PlanReward, error) { | |||
m := &model.PlanReward{} | |||
if isGet, err := eg.Where("pvd = ?", pvd).Get(m); err != nil || !isGet { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
func DbsPlanRewardByPvds(eg *xorm.Engine, pvds ...string) ([]*model.PlanReward, error) { | |||
var m []*model.PlanReward | |||
var err error | |||
if len(pvds) > 0 { | |||
err = eg.In("pvd", pvds).Find(&m) | |||
} else { | |||
err = eg.Find(&m) | |||
} | |||
if err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
// 查询使用自动结算的平台 | |||
func DbsPlanRewardIsAutoSettle(eg *xorm.Engine) ([]*model.PlanReward, error) { | |||
var m []*model.PlanReward | |||
var err error | |||
if err = eg.In("pvd", "mall_goods", "mall_group_buy", "mall_goods_user_lv").Where(" settle_mode=? AND plan_settle_id<>?", 1, 0).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} | |||
// 查出开启的渠道 | |||
func DbsPlanRewardIsOpen(eg *xorm.Engine) ([]*model.PlanReward, error) { | |||
var m []*model.PlanReward | |||
var err error | |||
if err = eg.Where(" state=?", 1).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} |
@@ -1,17 +0,0 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"xorm.io/xorm" | |||
) | |||
func PlanSettleListByIds(eg *xorm.Engine, ids []int) ([]*model.PlanSettle, error) { | |||
var m []*model.PlanSettle | |||
var err error | |||
err = eg.In("id", ids).Find(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} |
@@ -1,55 +0,0 @@ | |||
package db | |||
import ( | |||
"xorm.io/xorm" | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
) | |||
// 系统配置get | |||
func DbsSysCfgGetAll(eg *xorm.Engine) (*[]model.SysCfg, error) { | |||
var cfgList []model.SysCfg | |||
if err := eg.Cols("`key`,`val`").Find(&cfgList); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &cfgList, nil | |||
} | |||
// 获取一条记录 | |||
func DbsSysCfgGet(eg *xorm.Engine, key string) (*model.SysCfg, error) { | |||
var cfgList model.SysCfg | |||
if has, err := eg.Where("`key`=?", key).Get(&cfgList); err != nil || has == false { | |||
return nil, logx.Error(err) | |||
} | |||
return &cfgList, nil | |||
} | |||
func DbsSysCfgInsert(eg *xorm.Engine, key, val string) bool { | |||
cfg := model.SysCfg{Key: key, Val: val} | |||
_, err := eg.Where("`key`=?", key).Cols("val,memo").Update(&cfg) | |||
if err != nil { | |||
logx.Error(err) | |||
return false | |||
} | |||
return true | |||
} | |||
func DbsSysCfgInserts(eg *xorm.Engine, key, val string) bool { | |||
cfg := model.SysCfg{Key: key, Val: val} | |||
_, err := eg.InsertOne(&cfg) | |||
if err != nil { | |||
logx.Error(err) | |||
return false | |||
} | |||
return true | |||
} | |||
func DbsSysCfgUpdate(eg *xorm.Engine, key, val string) bool { | |||
cfg := model.SysCfg{Key: key, Val: val} | |||
_, err := eg.Where("`key`=?", key).Cols("val").Update(&cfg) | |||
if err != nil { | |||
logx.Error(err) | |||
return false | |||
} | |||
return true | |||
} |
@@ -1,41 +0,0 @@ | |||
package db | |||
import ( | |||
"xorm.io/xorm" | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
) | |||
func DbsUser(eg *xorm.Engine, uid int) (*[]model.UserRelate, error) { | |||
var userRelate []model.UserRelate | |||
if err := eg.Where("uid = ?", uid).Asc("level").Find(&userRelate); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if len(userRelate) == 0 { | |||
return nil, nil | |||
} | |||
return &userRelate, nil | |||
} | |||
func DbsUserFindByIds(eg *xorm.Engine, uid []int) (*[]model.User, error) { | |||
var users []model.User | |||
if err := eg.In("uid", uid).Asc("level").Find(&users); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if len(users) == 0 { | |||
return nil, nil | |||
} | |||
return &users, nil | |||
} | |||
func DbsUserRelate(eg *xorm.Engine, uid int) (*[]model.UserRelate, error) { | |||
var userRelate []model.UserRelate | |||
if err := eg.Where("uid = ?", uid).Asc("level").Find(&userRelate); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if len(userRelate) == 0 { | |||
return nil, nil | |||
} | |||
return &userRelate, nil | |||
} |
@@ -1,44 +0,0 @@ | |||
package db | |||
import ( | |||
"xorm.io/xorm" | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
) | |||
// UserProfileFindByIDs is in sql by ids | |||
func DbsUserProfileFindByIDs(eg *xorm.Engine, uids ...int) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
if err := eg.In("uid", uids).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} | |||
func DbsUserProfileFindByIDsList(eg *xorm.Engine, uids []int) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
col := "uid" | |||
if err := eg.In(col, uids).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
if len(m) == 0 { | |||
return nil, nil | |||
} | |||
return &m, nil | |||
} | |||
func DbsUserProfileFindByTbPids(eg *xorm.Engine, pids []int64, isShare bool) (*[]model.UserProfile, error) { | |||
var m []model.UserProfile | |||
col := "acc_taobao_self_id" | |||
col_where := "acc_taobao_self_id>0" | |||
if isShare { | |||
col = "acc_taobao_share_id" | |||
col_where = "acc_taobao_share_id>0" | |||
} | |||
if err := eg.Where(col_where).In(col, pids).Find(&m); err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
if len(m) == 0 { | |||
return nil, nil | |||
} | |||
return &m, nil | |||
} |
@@ -1,22 +0,0 @@ | |||
package model | |||
type TKBrand struct { | |||
BrandId int `json:"brandId" xorm:"not null pk autoincr comment('品牌id') INT(10)"` //品牌ID | |||
BrandName string `json:"brandName" xorm:"not null default '' comment('品牌名称') VARCHAR(64)"` //品牌名称 | |||
BrandLogo string `json:"brandLogo" xorm:"not null default '' comment('品牌logo') VARCHAR(255)"` //品牌logo | |||
BrandEnglish string `json:"brandEnglish" xorm:"not null default '' comment('品牌英文名称') VARCHAR(255)"` //品牌英文名称 | |||
Name string `json:"name" xorm:"not null default '' comment('官方旗舰店旗舰店铺名称') VARCHAR(255)"` //官方旗舰店旗舰店铺名称 | |||
SellerId string `json:"sellerId" xorm:"not null default '' comment('店铺ID') VARCHAR(255)"` //店铺ID | |||
BrandScore int `json:"brandScore" xorm:"not null default '' comment('店铺评分') INT(10)"` //店铺评分 | |||
Location string `json:"location" xorm:"not null default '' comment('发源地') VARCHAR(255)"` //发源地 | |||
EstablishTime string `json:"establishTime" xorm:"not null default '' comment('创立时间') VARCHAR(255)"` //创立时间 | |||
BelongTo string `json:"belongTo" xorm:"not null default '' comment('所属公司') VARCHAR(255)"` //所属公司 | |||
Position string `json:"position" xorm:"not null default '' comment('品牌定位:1. 奢侈 2.轻奢 3.大众') VARCHAR(255)"` //品牌定位:1. 奢侈 2.轻奢 3.大众 | |||
Consumer string `json:"consumer" xorm:"not null default '' comment('品牌定位:1. 奢侈 2.轻奢 3.大众') VARCHAR(255)"` //消费群体 | |||
Label string `json:"Label" xorm:"not null default '' comment('标签') VARCHAR(255)"` //标签 | |||
SimpleLabel string `json:"simpleLabel" xorm:"not null default '' comment('一句话评价') VARCHAR(255)"` //一句话评价 | |||
Cids string `json:"cids" xorm:"not null default '' comment('主营类目(可能有多个主营类目,用逗号隔开)') VARCHAR(255)"` //主营类目(可能有多个主营类目,用逗号隔开) | |||
BrandDesc string `json:"brandDesc" xorm:"not null default '' comment('品牌介绍') VARCHAR(255)"` //品牌介绍 (2020.10.30更新字段) | |||
FansNum int `json:"fansNum" xorm:"not null default '' comment('粉丝数') INT(10)"` //粉丝数 (2020.10.30更新字段) | |||
Sales2h int `json:"sales2h" xorm:"not null default '' comment('近期销量') INT(10)"` //近期销量 (2020.10.30更新字段) | |||
} |
@@ -1,15 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type AcquisitionLog struct { | |||
Id int64 `json:"id" xorm:"pk autoincr comment('主键') BIGINT(10)"` | |||
ParentUid int `json:"parent_uid" xorm:"not null default 0 comment('上级会员ID') unique(idx_union_u_p_id) INT(20)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('关联UserID') unique(idx_union_u_p_id) INT(20)"` | |||
Level int `json:"level" xorm:"not null default 1 comment('推广等级(1直属,大于1非直属)') INT(10)"` | |||
InviteTime time.Time `json:"invite_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('邀请时间') TIMESTAMP"` | |||
State int `json:"state" xorm:"not null default 0 comment('0为未完成,1为已完成') TINYINT(1)"` | |||
CompleteCon string `json:"complete_con" xorm:"not null default '' VARCHAR(16)"` | |||
} |
@@ -1,21 +0,0 @@ | |||
package model | |||
type AcquisitionRewardLog struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
Uid int `json:"uid" xorm:"not null default 0 INT(11)"` | |||
ToUid int `json:"to_uid" xorm:"not null default 0 comment('被邀请人uid') INT(11)"` | |||
Title string `json:"title" xorm:"not null comment('标题') VARCHAR(255)"` | |||
Source int `json:"source" xorm:"not null default 0 comment('1为直推奖励 | |||
2为间推奖励 | |||
3为额外奖励 | |||
4为榜单奖励 | |||
来源标识') TINYINT(4)"` | |||
SourceText string `json:"source_text" xorm:"not null default '' comment('来源text') VARCHAR(255)"` | |||
JobsTag int `json:"jobs_tag" xorm:"comment('任务标识,只有额外奖励有') TINYINT(1)"` | |||
Money string `json:"money" xorm:"not null default 0.00 comment('奖励金额') DECIMAL(10,2)"` | |||
CreatedAt int `json:"created_at" xorm:"not null comment('创建时间') INT(10)"` | |||
GivenAt int `json:"given_at" xorm:"comment('奖励发放时间') INT(10)"` | |||
State int `json:"state" xorm:"not null default 1 comment('发放状态 0未发放 1已发放') TINYINT(1)"` | |||
IsFrozen int `json:"is_frozen" xorm:"not null default 0 comment('冻结状态 0未冻结 1已冻结') TINYINT(1)"` | |||
UpdatedAt int `json:"updated_at" xorm:"comment('更新时间') INT(10)"` | |||
} |
@@ -1,19 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type AdmList struct { | |||
AdmId int `json:"adm_id" xorm:"not null pk autoincr INT(10)"` | |||
AdmName string `json:"adm_name" xorm:"not null default '' comment('管理员名称') VARCHAR(64)"` | |||
AdmPsw string `json:"adm_psw" xorm:"not null default '' comment('密码') CHAR(32)"` | |||
Phone string `json:"phone" xorm:"not null default '' comment('手机号') VARCHAR(16)"` | |||
RoleId int `json:"role_id" xorm:"not null default 0 comment('0为超管,其它请参照角色表') TINYINT(3)"` | |||
State int `json:"state" xorm:"not null default 1 comment('0关闭,1启用') TINYINT(1)"` | |||
Ip string `json:"ip" xorm:"not null default '' comment('最后登陆IP,如果与当前IP不一致,请强退') VARCHAR(15)"` | |||
Token string `json:"token" xorm:"not null default '' comment('最后登陆token') unique CHAR(40)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(200)"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') TIMESTAMP"` | |||
LatestLoginAt int `json:"latest_login_at" xorm:"not null default 0 comment('最新登陆时间,时间戳') INT(10)"` | |||
} |
@@ -1,12 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type AdmLog struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
AdmId int `json:"adm_id" xorm:"not null default 0 comment('管理员ID') INT(11)"` | |||
Ip string `json:"ip" xorm:"not null default '' comment('IP') VARCHAR(15)"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('登陆时间') TIMESTAMP"` | |||
} |
@@ -1,16 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type AdmOpLog struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
AdmId int `json:"adm_id" xorm:"not null pk default 0 comment('管理员ID') INT(11)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('被操作人UID,如非操作用户信息,默认为0') INT(11)"` | |||
Perm string `json:"perm" xorm:"not null default '' comment('操作权限,敏感模块权限') VARCHAR(128)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('操作描述') VARCHAR(512)"` | |||
Ip string `json:"ip" xorm:"not null default '' comment('操作IP') VARCHAR(15)"` | |||
State int `json:"state" xorm:"not null default 1 comment('操作结果1成功,0失败') TINYINT(1)"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') TIMESTAMP"` | |||
} |
@@ -1,16 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type AdmRole struct { | |||
RoleId int `json:"role_id" xorm:"not null pk comment('角色ID') INT(10)"` | |||
RoleName string `json:"role_name" xorm:"not null default '' comment('角色名称') VARCHAR(64)"` | |||
Perms string `json:"perms" xorm:"comment('权限列表') TEXT"` | |||
IsSuper int `json:"is_super" xorm:"not null default 0 comment('是否超管') TINYINT(1)"` | |||
State int `json:"state" xorm:"not null default 1 comment('0禁用,1启用') TINYINT(1)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(500)"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') TIMESTAMP"` | |||
UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"` | |||
} |
@@ -1,10 +0,0 @@ | |||
package model | |||
type AdmRolePerms struct { | |||
Id int `json:"id" xorm:"not null pk autoincr comment('ID') INT(10)"` | |||
Pid int `json:"pid" xorm:"not null comment('父ID') INT(10)"` | |||
Perm string `json:"perm" xorm:"not null default '' comment('权限匹配名') VARCHAR(128)"` | |||
PermName string `json:"perm_name" xorm:"not null default '' comment('后台显示名称') VARCHAR(64)"` | |||
Sort int `json:"sort" xorm:"not null default 0 comment('显示排序,越大越前') INT(11)"` | |||
State int `json:"state" xorm:"not null default 1 comment('是否开启') TINYINT(1)"` | |||
} |
@@ -1,14 +0,0 @@ | |||
package model | |||
type AppRelease struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
Version string `json:"version" xorm:"not null default '' VARCHAR(255)"` | |||
Os int `json:"os" xorm:"comment('系统:1.Android;2.ios') TINYINT(1)"` | |||
Memo string `json:"memo" xorm:"TEXT"` | |||
Src string `json:"src" xorm:"VARCHAR(255)"` | |||
CreatedAt int `json:"created_at" xorm:"INT(11)"` | |||
State int `json:"state" xorm:"not null default 1 comment('版本状态:0关 1开') TINYINT(1)"` | |||
UpdateNotice int `json:"update_notice" xorm:"not null default 1 comment('更新提醒:0关 1开') TINYINT(1)"` | |||
YybUrl string `json:"yyb_url" xorm:"comment('应用宝url') VARCHAR(255)"` | |||
ForceUpdate int `json:"force_update" xorm:"comment('强制更新(安卓)') TINYINT(1)"` | |||
} |
@@ -1,22 +0,0 @@ | |||
package model | |||
type Article struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Pid int `json:"pid" xorm:"not null default 0 comment('一级分类,对应article_cate表parent_id=0的记录') INT(11)"` | |||
CateId int `json:"cate_id" xorm:"not null default 0 comment('分类ID') index INT(11)"` | |||
TypeId int `json:"type_id" xorm:"not null default 0 comment('类型,对应article_cate表pid=0的记录') index INT(11)"` | |||
Title string `json:"title" xorm:"not null default '' comment('标题') VARCHAR(255)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示:0不显示;1显示') TINYINT(1)"` | |||
CreatedAt int `json:"created_at" xorm:"comment('创建时间') INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"comment('更新时间') INT(11)"` | |||
Cover string `json:"cover" xorm:"comment('封面') VARCHAR(255)"` | |||
Tags string `json:"tags" xorm:"comment('标签') VARCHAR(2048)"` | |||
Content string `json:"content" xorm:"comment('内容') LONGTEXT"` | |||
Info string `json:"info" xorm:"comment('描述') LONGTEXT"` | |||
IsSelected int `json:"is_selected" xorm:"not null default 0 comment('是否精选') TINYINT(1)"` | |||
IsRecommend int `json:"is_recommend" xorm:"not null default 0 comment('是否推荐') TINYINT(1)"` | |||
Sort int `json:"sort" xorm:"not null default 0 comment('排序') INT(11)"` | |||
WatchCount int `json:"watch_count" xorm:"not null default 0 comment('观看人数') INT(11)"` | |||
LikeCount int `json:"like_count" xorm:"not null default 0 comment('喜爱人数') INT(11)"` | |||
ForwardCount int `json:"forward_count" xorm:"not null default 0 comment('转发人数') INT(11)"` | |||
} |
@@ -1,10 +0,0 @@ | |||
package model | |||
type ArticleCate struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Pid int `json:"pid" xorm:"default 0 comment('上级,0表示文章类型') INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' VARCHAR(255)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示') TINYINT(1)"` | |||
CreatedAt int `json:"created_at" xorm:"INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"INT(11)"` | |||
} |
@@ -1,13 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type ArticleLikeLog struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
ArticleId int64 `json:"article_id" xorm:"not null default 0 comment('文章ID') unique(IDX_LOG) BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') unique(IDX_LOG) INT(10)"` | |||
//CreatedAt time.Time `json:"created_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"` | |||
CreatedAt time.Time `json:"created_at" xorm:"created"` | |||
} |
@@ -1,12 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type ArticleWatchLog struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
ArticleId int64 `json:"article_id" xorm:"not null default 0 comment('文章ID') unique(IDX_LOG) BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') unique(IDX_LOG) INT(10)"` | |||
CreatedAt time.Time `json:"created_at" xorm:"created"` | |||
} |
@@ -1,15 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type BusinessCollegeOrd struct { | |||
Id int64 `json:"id" xorm:"pk comment('订单id') BIGINT(22)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('uid') INT(10)"` | |||
ModId int `json:"mod_id" xorm:"not null default 0 comment('模块ID') INT(10)"` | |||
PayAmount string `json:"pay_amount" xorm:"not null default 0 comment('付费金额') DECIMAL(2)"` | |||
PayChannel int `json:"pay_channel" xorm:"not null default 0 comment('1:支付宝,2:微信,3:余额') TINYINT(1)"` | |||
State int `json:"state" xorm:"not null default 0 comment('支付状态:0未支付1已支付') TINYINT(1)"` | |||
CreateAt time.Time `json:"create_at" xorm:"created"` | |||
} |
@@ -1,18 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type CapitalPool struct { | |||
Id int `json:"id" xorm:"not null pk autoincr comment('主键id') INT(11)"` | |||
IsUse int `json:"is_use" xorm:"not null comment('是否开启(否:0;是:1)') TINYINT(1)"` | |||
IsAuto int `json:"is_auto" xorm:"not null default 0 comment('是否自动分红(否:0;是:1)') TINYINT(1)"` | |||
BonusType string `json:"bonus_type" xorm:"not null default '0' comment('分红类型(1佣金,2积分,3区块币)多个以逗号隔开') VARCHAR(255)"` | |||
BonusDateType int `json:"bonus_date_type" xorm:"not null default 0 comment('日期类型(1每天,2固定时间)') TINYINT(1)"` | |||
BonusTime string `json:"bonus_time" xorm:"default '0' comment('分红日期(1,15,30)多个日期已逗号分隔开;ps 只有日期类型是2才是有数据') VARCHAR(255)"` | |||
BonusLevelType int `json:"bonus_level_type" xorm:"not null default 0 comment('用户等级分红类型(1,指定等级,2大于或等于指定等级)') TINYINT(1)"` | |||
UserLevelGroup string `json:"user_level_group" xorm:"not null comment('指定用户等级组json') TEXT"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"` | |||
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"` | |||
} |
@@ -1,15 +0,0 @@ | |||
package model | |||
type ChannelActivity struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Img string `json:"img" xorm:"default '' comment('图片') VARCHAR(255)"` | |||
Sort int `json:"sort" xorm:"default 0 comment('排序') INT(5)"` | |||
IsUse int `json:"is_use" xorm:"default 0 comment('是否使用') INT(1)"` | |||
Source string `json:"source" xorm:"default '' comment('来源 淘宝=>tb 京东=>jd 拼多多=>pdd 唯品会=>wph 苏宁易购=>snyg 考拉=>kaola') VARCHAR(50)"` | |||
IsRecommend int `json:"is_recommend" xorm:"default 0 comment('是否官方推荐') INT(1)"` | |||
StartTime int `json:"start_time" xorm:"default 0 comment('开始时间') INT(11)"` | |||
EndTime int `json:"end_time" xorm:"default 0 comment('结束时间') INT(11)"` | |||
ActivityId string `json:"activity_id" xorm:"default '' comment('活动id') VARCHAR(100)"` | |||
Url string `json:"url" xorm:"comment('活动链接') TEXT"` | |||
Name string `json:"name" xorm:"default '' comment('名称') VARCHAR(255)"` | |||
} |
@@ -1,17 +0,0 @@ | |||
package model | |||
type CloudBundle struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
Os int `json:"os" xorm:"not null default 1 comment('系统类型:1.Android; 2.IOS') TINYINT(1)"` | |||
Version string `json:"version" xorm:"not null default '' comment('版本号') VARCHAR(255)"` | |||
Modules string `json:"modules" xorm:"not null default '' comment('包含的模块') VARCHAR(255)"` | |||
ApplyAt int `json:"apply_at" xorm:"comment('申请时间') INT(11)"` | |||
FinishAt int `json:"finish_at" xorm:"comment('完成时间') INT(11)"` | |||
State int `json:"state" xorm:"not null default 1 comment('状态:正在排队0,正在同步代码1,正在更新配置2,正在混淆3,正在打包4,正在上传5,打包成功999,异常-1') SMALLINT(5)"` | |||
Memo string `json:"memo" xorm:"comment('备注') TEXT"` | |||
ErrorMsg string `json:"error_msg" xorm:"comment('错误信息') TEXT"` | |||
Src string `json:"src" xorm:"comment('包源地址') VARCHAR(255)"` | |||
BuildId string `json:"build_id" xorm:"comment('build版本ID') VARCHAR(255)"` | |||
BuildNumber string `json:"build_number" xorm:"default '' VARCHAR(255)"` | |||
TemplateDuringAudit string `json:"template_during_audit" xorm:"not null default '' VARCHAR(255)"` | |||
} |
@@ -1,11 +0,0 @@ | |||
package model | |||
type DealOrderUser struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Type string `json:"type" xorm:"default '' comment('类型 activity_order活动订单 oil_order加油订单') index VARCHAR(100)"` | |||
Uid int `json:"uid" xorm:"default 0 comment('用户id') index INT(11)"` | |||
Time int `json:"time" xorm:"default 0 comment('写入时间') index INT(11)"` | |||
EndTime int `json:"end_time" xorm:"default 0 comment('结束时间') index INT(11)"` | |||
RelationId int64 `json:"relation_id" xorm:"default 0 comment('渠道id') index BIGINT(12)"` | |||
Data string `json:"data" xorm:"comment('拓展用') TEXT"` | |||
} |
@@ -1,22 +0,0 @@ | |||
package model | |||
type DuomaiMallBrand struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
ThirdId int `json:"third_id" xorm:"not null default 0 comment('三方平台ID') INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('品牌名称') VARCHAR(255)"` | |||
SubName string `json:"sub_name" xorm:"not null default '' comment('品牌副标题') VARCHAR(255)"` | |||
Logo string `json:"logo" xorm:"not null default '' comment('品牌logo') VARCHAR(255)"` | |||
Url string `json:"url" xorm:"not null default '' comment('商城地址') VARCHAR(255)"` | |||
CommRate string `json:"comm_rate" xorm:"not null default '' comment('返利比例') VARCHAR(255)"` | |||
CateId int `json:"cate_id" xorm:"not null default 0 comment('分类ID') INT(11)"` | |||
Desc string `json:"desc" xorm:"not null comment('商城简介') TEXT"` | |||
Detail string `json:"detail" xorm:"not null comment('商城详情') TEXT"` | |||
Data string `json:"data" xorm:"not null comment('商城详情') TEXT"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示') TINYINT(1)"` | |||
Sort int `json:"sort" xorm:"not null default 0 comment('排序') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 INT(11)"` | |||
Tags string `json:"tags" xorm:"not null comment('标签,“,”号分割') TEXT"` | |||
CommList string `json:"comm_list" xorm:"comment('分佣列表') TEXT"` | |||
} |
@@ -1,11 +0,0 @@ | |||
package model | |||
type DuomaiMallBrandCate struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('分类名称') VARCHAR(255)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示') TINYINT(1)"` | |||
Sort int `json:"sort" xorm:"default 0 comment('排序') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 INT(11)"` | |||
} |
@@ -1,10 +0,0 @@ | |||
package model | |||
type FinSysLog struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
FromUid int `json:"from_uid" xorm:"not null default 0 comment('来自于用户') INT(11)"` | |||
FromSource int `json:"from_source" xorm:"not null default 0 comment('来源') TINYINT(4)"` | |||
Amount float32 `json:"amount" xorm:"not null default 0.0000 comment('金额') FLOAT(12,4)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(50)"` | |||
CreateAt int `json:"create_at" xorm:"not null default 0 comment('创建时间') INT(11)"` | |||
} |
@@ -1,9 +0,0 @@ | |||
package model | |||
type FinUserCommissionLog struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null INT(10)"` | |||
Oid string `json:"oid" xorm:"not null default '' comment('订单ID') VARCHAR(50)"` | |||
OrderType int `json:"order_type" xorm:"not null default 0 comment('0自购,1分享') TINYINT(1)"` | |||
OrderProvider string `json:"order_provider" xorm:"not null default '' comment('订单供应商') VARCHAR(32)"` | |||
} |
@@ -1,29 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type FinUserFlow struct { | |||
Id int64 `json:"id" xorm:"pk autoincr comment('流水编号') BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` | |||
Type int `json:"type" xorm:"not null default 0 comment('0收入,1支出') TINYINT(1)"` | |||
Amount string `json:"amount" xorm:"not null default 0.0000 comment('变动金额') DECIMAL(11,4)"` | |||
BeforeAmount string `json:"before_amount" xorm:"not null default 0.0000 comment('变动前金额') DECIMAL(11,4)"` | |||
AfterAmount string `json:"after_amount" xorm:"not null default 0.0000 comment('变动后金额') DECIMAL(11,4)"` | |||
SysFee string `json:"sys_fee" xorm:"not null default 0.0000 comment('手续费') DECIMAL(11,4)"` | |||
PaymentType int `json:"payment_type" xorm:"not null default 1 comment('1支付宝,2微信.3手动转账') TINYINT(1)"` | |||
OrdType string `json:"ord_type" xorm:"not null default '' comment('订单类型taobao,jd,pdd,vip,suning,kaola,own自营,withdraw提现') VARCHAR(20)"` | |||
OrdId string `json:"ord_id" xorm:"not null default '' comment('对应订单编号') VARCHAR(50)"` | |||
OrdTitle string `json:"ord_title" xorm:"not null default '' comment('订单标题') VARCHAR(50)"` | |||
OrdAction int `json:"ord_action" xorm:"not null default 0 comment('10自购,11推广,12团队,20提现,21消费') TINYINT(2)"` | |||
OrdTime int `json:"ord_time" xorm:"not null default 0 comment('下单时间or提现时间') INT(11)"` | |||
OrdDetail string `json:"ord_detail" xorm:"not null default '' comment('记录商品ID或提现账号') VARCHAR(50)"` | |||
ExpectedTime string `json:"expected_time" xorm:"not null default '0' comment('预期到账时间,字符串用于直接显示,结算后清除内容') VARCHAR(30)"` | |||
State int `json:"state" xorm:"not null default 1 comment('1未到账,2已到账') TINYINT(1)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(2000)"` | |||
OtherId int64 `json:"other_id" xorm:"not null default 0 comment('其他关联订单,具体根据订单类型判断') BIGINT(20)"` | |||
AliOrdId string `json:"ali_ord_id" xorm:"default '' comment('支付宝订单号') VARCHAR(128)"` | |||
CreateAt time.Time `json:"create_at" xorm:"created not null default CURRENT_TIMESTAMP comment('创建时间') TIMESTAMP"` | |||
UpdateAt time.Time `json:"update_at" xorm:"updated not null default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"` | |||
} |
@@ -1,19 +0,0 @@ | |||
package model | |||
type FinUserLog struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null comment('用户ID') INT(10)"` | |||
Type int `json:"type" xorm:"not null default 0 comment('0余额,1积分') TINYINT(1)"` | |||
FromType int `json:"from_type" xorm:"not null default 0 comment('来源类型:1,导购订单结算;2,拉新奖励;3,管理调整') TINYINT(3)"` | |||
ValidBefore float32 `json:"valid_before" xorm:"not null default 0.0000 comment('之前可用余额') FLOAT(10,4)"` | |||
ValidAfter float32 `json:"valid_after" xorm:"not null default 0.0000 comment('之后可用余额') FLOAT(10,4)"` | |||
ValidAlter float32 `json:"valid_alter" xorm:"not null default 0.0000 comment('变更金额') FLOAT(10,4)"` | |||
InvalidBefore float32 `json:"invalid_before" xorm:"not null default 0.0000 comment('之前冻结余额') FLOAT(10,4)"` | |||
InvalidAfter float32 `json:"invalid_after" xorm:"not null default 0.0000 comment('之后冻结余额') FLOAT(10,4)"` | |||
InvalidAlter float32 `json:"invalid_alter" xorm:"not null default 0.0000 comment('变更金额') FLOAT(10,4)"` | |||
SysCommission float32 `json:"sys_commission" xorm:"not null default 0.000000 comment('平台抽取手续费') FLOAT(12,6)"` | |||
Oid string `json:"oid" xorm:"not null default '' comment('关联订单ID') VARCHAR(50)"` | |||
Action string `json:"action" xorm:"not null default '' comment('操作行为,如:withdraw提现') VARCHAR(20)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(80)"` | |||
CreateAt int `json:"create_at" xorm:"not null default 0 comment('创建时间') INT(10)"` | |||
} |
@@ -1,20 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type FinWithdrawApply struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') index INT(10)"` | |||
AdmId int `json:"adm_id" xorm:"not null default 0 comment('审核人ID,0为系统自动') INT(10)"` | |||
Amount string `json:"amount" xorm:"not null default 0.00 comment('提现金额') DECIMAL(10,2)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注,失败请备注原因') VARCHAR(500)"` | |||
Type int `json:"type" xorm:"not null default 1 comment('提现类型;1:手动;2:自动') TINYINT(1)"` | |||
WithdrawAccount string `json:"withdraw_account" xorm:"not null default '' comment('提现账号') VARCHAR(64)"` | |||
WithdrawName string `json:"withdraw_name" xorm:"not null default '' comment('提现人姓名') VARCHAR(12)"` | |||
Reason int `json:"reason" xorm:"not null default 0 comment('审核失败(驳回理由);1:当前账号不满足提现规则;2:账号异常;3:资金异常') TINYINT(1)"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('申请时间') TIMESTAMP"` | |||
UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP comment('处理时间') TIMESTAMP"` | |||
State int `json:"state" xorm:"not null default 0 comment('0申请中,1通过,2完成,3失败') TINYINT(1)"` | |||
} |
@@ -1,67 +0,0 @@ | |||
package model | |||
import "time" | |||
//产品发布表 | |||
type GuideGoods struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
GoodsUrl string `json:"goodsUrl" xorm:"not null comment('传进来的商品链接') VARCHAR(50)"` | |||
ItemUrl string `json:"itemUrl" xorm:"not null default 0 comment('搜索出来的商品链接') VARCHAR(50)"` | |||
GoodsId string `json:"goodsId" xorm:"not null default 0 comment('商品id') VARCHAR(50)"` | |||
Provider string `json:"provider" xorm:"not null default 0 comment('渠道key') VARCHAR(50)"` | |||
ProviderName string `json:"providerName" xorm:"not null default 0.0000 comment('渠道') VARCHAR(50)"` | |||
ProviderImg string `json:"providerImg" xorm:"not null default 0 comment('渠道图片') VARCHAR(50)"` | |||
ProviderImgUrl string `json:"providerImgUrl" xorm:"not null default 0 comment('渠道图片Url') VARCHAR(50)"` | |||
GoodsTitle string `json:"goodsTitle" xorm:"not null default 0.0000 comment('商品标题') VARCHAR(50)"` | |||
GoodsPrice string `json:"goodsPrice" xorm:"not null default 1 comment('商品原价') VARCHAR(50)"` | |||
WlGoodsPrice string `json:"wlGoodsPrice" xorm:"not null default 1 comment('商品卷后价') VARCHAR(50)"` | |||
CouponPrice string `json:"couponPrice" xorm:"not null default 1 comment('优惠劵金额') VARCHAR(50)"` | |||
CouponUrl string `json:"couponUrl" xorm:"not null default 1 comment('优惠劵Url') VARCHAR(50)"` | |||
Category string `json:"category" xorm:"not null default 1 comment('分类') VARCHAR(50)"` | |||
CategoryName string `json:"categoryName" xorm:"not null default 1 comment('分类名') VARCHAR(50)"` | |||
InOrderCount string `json:"inOrderCount" xorm:"not null default 1 comment('销量') VARCHAR(50)"` | |||
GoodsDesc string `json:"goodsDesc" xorm:"not null default 0.0000 comment('商品描述') VARCHAR(50)"` | |||
GoodsContent string `json:"goodsContent" xorm:"not null default 0.0000 comment('商品文案(以json存)') VARCHAR(50)"` | |||
GoodsImg string `json:"goodsImg" xorm:"not null default 0.0000 comment('商品主图') VARCHAR(50)"` | |||
GoodsImgUrl string `json:"goodsImgUrl" xorm:"not null default 0.0000 comment('商品主图URL') VARCHAR(50)"` | |||
GoodsImgList string `json:"goodsImgList" xorm:"not null default 0.0000 comment('商品图片组(以json存)') VARCHAR(50)"` | |||
VideoUrl string `json:"videoUrl" xorm:"not null default 0.0000 comment('商品视频URL') VARCHAR(50)"` | |||
IsPutOn string `json:"isPutOn" xorm:"not null default 0 comment('是否上架;0:否;1:是') VARCHAR(50)"` | |||
PutOnAt time.Time `json:"putOnAt"xorm:"not null default 0 comment('创建时间') datetime"` | |||
PutDownAt time.Time `json:"putDownAt"xorm:"not null default 0 comment('创建时间') datetime"` | |||
CreateAt time.Time `xorm:"not null default 0 comment('创建时间') datetime"` | |||
UpdateAt time.Time `xorm:"not null default 0 comment('更新时间') datetime"` | |||
} | |||
//产品发布app端数据 | |||
type GuideGoodsApp struct { | |||
Id string `json:"id"` | |||
GoodsUrl string `json:"goods_url"` | |||
ItemURL string `json:"item_url"` | |||
GoodsId string `json:"goods_id"` | |||
Provider string `json:"provider"` | |||
ProviderName string `json:"provider_name"` | |||
ProviderImg string `json:"provider_img"` | |||
ProviderImgUrl string `json:"provider_img_url"` | |||
GoodsTitle string `json:"goods_title"` | |||
GoodsPrice string `json:"goods_price"` | |||
WlGoodsPrice string `json:"wl_goods_price"` | |||
CouponPrice string `json:"coupon_price"` | |||
CouponURL string `json:"coupon_url"` | |||
Category string `json:"category"` | |||
CategoryName string `json:"category_name"` | |||
InOrderCount string `json:"in_order_count"` | |||
GoodsDesc string `json:"goods_desc"` | |||
GoodsContent string `json:"goods_content"` | |||
GoodsImg string `json:"goods_img"` | |||
GoodsImgUrl string `json:"goods_img_url"` | |||
GoodsImgList string `json:"goods_img_list"` | |||
VideoUrl string `json:"video_url"` | |||
StateInfo string `json:"state_info"` | |||
IsPutOn string `json:"is_put_on"` | |||
PutOnAt string `json:"put_on_at"` | |||
PutDownAt string `json:"put_down_at"` | |||
Commission string `json:"commission"` //反的价钱 | |||
ShareValue string `json:"share_value"` //分享赚 | |||
SlefBuy string `json:"slef_buy"` //自购赚 | |||
} |
@@ -1,23 +0,0 @@ | |||
package model | |||
import "time" | |||
//激励广告表 | |||
type IncentiveAd struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
AdName string `json:"ad_name" xorm:"not null comment('广告名称(唯一)') VARCHAR(50)"` | |||
SdkType string `json:"sdk_type" xorm:"not null default 0 comment('平台:1,优量汇;2,快手联盟;3,穿山甲') VARCHAR(50)"` | |||
AndroidMediaId string `json:"android_media_id" xorm:"not null default 0 comment('安卓媒体id') VARCHAR(50)"` | |||
IosMediaId string `json:"ios_media_id" xorm:"not null default 0.0000 comment('ios媒体id') VARCHAR(50)"` | |||
AndroidAdId string `json:"android_ad_id" xorm:"not null default 0.0000 comment('安卓广告id') VARCHAR(50)"` | |||
IosAdId string `json:"ios_ad_id" xorm:"not null default 0.0000 comment('ios广告id') VARCHAR(50)"` | |||
Conditions int `json:"conditions" xorm:"not null default 1 comment('是否开启条件限制(0否,1是)') TINYINT(1)"` | |||
Autoplay int `json:"autoplay" xorm:"not null default 1 comment('是否自动播放(0否,1是)') TINYINT(1)"` | |||
AutoClickAd int `json:"auto_click_ad" xorm:"not null default 1 comment('是否自动点击广告(0否,1是)') TINYINT(1)"` | |||
LevelLimitId int `json:"level_limit_id" xorm:"comment('等级id') INT(11)"` | |||
LevelLimitName string `json:"level_limit_name" xorm:"comment('等级名称') VARCHAR(50)"` | |||
LevelWeight int `json:"level_weight" xorm:" comment('等级权重') INT(11)"` | |||
CreateAt time.Time `xorm:"not null default 0 comment('创建时间') datetime"` | |||
UpdateAt time.Time `xorm:"not null default 0 comment('更新时间') datetime"` | |||
VisitCount int `json:"visit_count" xorm:" default 0 comment('可观看次数') INT(11)"` | |||
} |
@@ -1,9 +0,0 @@ | |||
package model | |||
type IncentiveAdTotal struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
AdId int `json:"ad_id" xorm:"default 0 comment('广告id') INT(11)"` | |||
Count int `json:"count" xorm:"default 0 comment('观看数量') INT(11)"` | |||
Time int `json:"time" xorm:"default 0 comment('时间') INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 comment('用户id') INT(11)"` | |||
} |
@@ -1,6 +0,0 @@ | |||
package model | |||
type LogisticCompany struct { | |||
Name string `json:"name" xorm:"comment('快递公司名称') VARCHAR(255)"` | |||
Code string `json:"code" xorm:"comment('快递公司代号') VARCHAR(255)"` | |||
} |
@@ -1,52 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type MallOrd struct { | |||
OrdId int64 `json:"ord_id" xorm:"not null pk BIGINT(20)"` | |||
MainOrdId int64 `json:"main_ord_id" xorm:"not null comment('主订单号') index BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"comment('用户id') index INT(11)"` | |||
BuyerName string `json:"buyer_name" xorm:"comment('购买人') VARCHAR(255)"` | |||
BuyerPhone string `json:"buyer_phone" xorm:"comment('购买人手机号') VARCHAR(255)"` | |||
CostPrice string `json:"cost_price" xorm:"comment('价格') DECIMAL(12,2)"` | |||
CostVirtualCoin string `json:"cost_virtual_coin" xorm:"comment('消耗的虚拟币') DECIMAL(12,2)"` | |||
VirtualCoinId int `json:"virtual_coin_id" xorm:"comment('使用的虚拟币id') INT(11)"` | |||
State int `json:"state" xorm:"comment('订单状态:0未支付 1已支付 2已发货 3已完成 4售后中 5部分售后中 6关闭') TINYINT(1)"` | |||
PayTime time.Time `json:"pay_time" xorm:"comment('支付时间') DATETIME"` | |||
PayChannel int `json:"pay_channel" xorm:"not null comment('支付方式:1balance 2alipay 3wx_pay') TINYINT(1)"` | |||
ShippingTime time.Time `json:"shipping_time" xorm:"comment('发货时间') DATETIME"` | |||
LogisticCompany string `json:"logistic_company" xorm:"not null default '' comment('物流公司') VARCHAR(255)"` | |||
LogisticNum string `json:"logistic_num" xorm:"not null default '' comment('物流单号') VARCHAR(255)"` | |||
ReceiverPhone string `json:"receiver_phone" xorm:"not null default '' comment('收货人手机号') VARCHAR(20)"` | |||
ReceiverName string `json:"receiver_name" xorm:"not null default '' comment('收货人名字') VARCHAR(255)"` | |||
ReceiverAddressDetail string `json:"receiver_address_detail" xorm:"not null default '' comment('收货人地址') VARCHAR(255)"` | |||
ShippingType int `json:"shipping_type" xorm:"not null default 1 comment('运送方式:1快递送货') TINYINT(1)"` | |||
CouponDiscount string `json:"coupon_discount" xorm:"not null default 0.00 comment('优惠券折扣额') DECIMAL(12,2)"` | |||
DiscountPrice string `json:"discount_price" xorm:"not null default 0.00 comment('立减') DECIMAL(12,2)"` | |||
UserCouponId int64 `json:"user_coupon_id" xorm:"comment('使用的优惠券id') BIGINT(20)"` | |||
ReturnInsuranceFee string `json:"return_insurance_fee" xorm:"not null default 0.00 comment('退货无忧费用') DECIMAL(12,2)"` | |||
IsReceipt int `json:"is_receipt" xorm:"not null default 0 comment('是否开具发票 0否 1是') TINYINT(255)"` | |||
ShippingFee string `json:"shipping_fee" xorm:"not null default 0.00 comment('运费') DECIMAL(12,2)"` | |||
Comment string `json:"comment" xorm:"not null comment('备注') VARCHAR(2048)"` | |||
ProvinceName string `json:"province_name" xorm:"not null default '' comment('收货省份') VARCHAR(255)"` | |||
CityName string `json:"city_name" xorm:"not null default '' comment('收货城市') VARCHAR(255)"` | |||
CountyName string `json:"county_name" xorm:"not null default '' comment('收货区域') VARCHAR(255)"` | |||
PayNum string `json:"pay_num" xorm:"not null default '' comment('交易流水') VARCHAR(255)"` | |||
ConfirmTime time.Time `json:"confirm_time" xorm:"comment('确认时间') DATETIME"` | |||
EstimateIntegral string `json:"estimate_integral" xorm:"not null default 0.0000 comment('预计积分') DECIMAL(12,4)"` | |||
EstimateCommission string `json:"estimate_commission" xorm:"not null default 0.0000 comment('预计佣金') DECIMAL(12,4)"` | |||
CreateTime time.Time `json:"create_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` | |||
UpdateTime time.Time `json:"update_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` | |||
DeletedTime time.Time `json:"deleted_time" xorm:"comment('删除时间') DATETIME"` | |||
FinishTime time.Time `json:"finish_time" xorm:"comment('完成时间') DATETIME"` | |||
OrderType int `json:"order_type" xorm:"not null default 1 comment('订单类型:1普通订单 2拼团订单') TINYINT(3)"` | |||
Data string `json:"data" xorm:"comment('订单相关的数据') TEXT"` | |||
GroupBuyCommission string `json:"group_buy_commission" xorm:"default 0.0000 comment('团购未中奖佣金') DECIMAL(12,4)"` | |||
GroupBuySettleTime time.Time `json:"group_buy_settle_time" xorm:"comment('拼团结算时间') DATETIME"` | |||
SettleTime time.Time `json:"settle_time" xorm:"comment('结算时间') DATETIME"` | |||
GroupBuyCommissionTime time.Time `json:"group_buy_commission_time" xorm:"comment('拼团分佣时间') DATETIME"` | |||
CommissionTime time.Time `json:"commission_time" xorm:"comment('分佣时间') DATETIME"` | |||
ShareUid int `json:"share_uid" xorm:"comment('分享人') INT(11)"` | |||
} |
@@ -1,14 +0,0 @@ | |||
package model | |||
type MomentsCate struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Pid int `json:"pid" xorm:"not null default 0 comment('上级,0表示一级分类') INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('分类名称') VARCHAR(255)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示') TINYINT(1)"` | |||
TypeId int `json:"type_id" xorm:"not null default 0 comment('类型') TINYINT(10)"` | |||
Data string `json:"data" xorm:"not null default '' comment('保存不同类型定义的设置数据') VARCHAR(255)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 INT(11)"` | |||
Child *[]MomentsCate `json:"child"` | |||
} |
@@ -1,13 +0,0 @@ | |||
package model | |||
type MomentsMaterial struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Pid int `json:"pid" xorm:"not null default 0 comment('分类ID') INT(11)"` | |||
CateId int `json:"cate_id" xorm:"not null default 0 comment('子分类') INT(11)"` | |||
TypeId int `json:"type_id" xorm:"not null default 0 comment('类型ID') INT(11)"` | |||
Data string `json:"data" xorm:"not null comment('素材详情json') TEXT"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示:0不显示;1显示') TINYINT(1)"` | |||
CreatedAt int `json:"created_at" xorm:"comment('创建时间') INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"comment('更新时间') INT(11)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 INT(11)"` | |||
} |
@@ -1,15 +0,0 @@ | |||
package model | |||
type NewcomersFreePriceType struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
PriceName string `json:"price_name" xorm:"not null comment('价格类型') VARCHAR(255)"` | |||
NeedQuan int `json:"need_quan" xorm:"not null default 0 comment('需要的福利券') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否开启') TINYINT(1)"` | |||
IsDel int `json:"is_del" xorm:"not null default 0 INT(11)"` | |||
NeedUseQuan int `json:"need_use_quan" xorm:"not null default 1 INT(1)"` | |||
NeedLimitBuy int `json:"need_limit_buy" xorm:"not null default 0 INT(1)"` | |||
Auth string `json:"auth" xorm:"not null comment('权限') TEXT"` | |||
LimitBuyCondition string `json:"limit_buy_condition" xorm:"not null comment('限购条件') TEXT"` | |||
} |
@@ -1,31 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type NewcomersFreeProduct struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
GoodId string `json:"good_id" xorm:"not null default '' comment('平台商品ID') VARCHAR(255)"` | |||
Source string `json:"source" xorm:"not null default 'taobao' comment('来源平台') VARCHAR(255)"` | |||
SourceUrl string `json:"source_url" xorm:"not null default '' comment('用户输入地址') VARCHAR(255)"` | |||
PriceType int `json:"price_type" xorm:"not null default 0 comment('所属价格类型') TINYINT(1)"` | |||
OriginalPrice string `json:"original_price" xorm:"not null default 0.00 comment('原价') DECIMAL(10,2)"` | |||
CouponPrice string `json:"coupon_price" xorm:"not null default 0.00 comment('券后价格') DECIMAL(10,2)"` | |||
ReturnMoney string `json:"return_money" xorm:"not null default 0.00 comment('返还的钱') DECIMAL(10,2)"` | |||
Money string `json:"money" xorm:"not null default 0 comment('实付金额') DECIMAL(10)"` | |||
Stock int `json:"stock" xorm:"not null default 0 comment('库存数量') INT(11)"` | |||
Sale int `json:"sale" xorm:"not null default 0 comment('卖掉的数量') INT(11)"` | |||
EndTime time.Time `json:"end_time" xorm:"not null comment('结束时间') DATETIME"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否上架') TINYINT(1)"` | |||
IsDel int `json:"is_del" xorm:"not null default 0 comment('是否删除') TINYINT(1)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
Title string `json:"title" xorm:"not null default '' comment('标题') VARCHAR(255)"` | |||
StartTime time.Time `json:"start_time" xorm:"not null comment('开始时间') DATETIME"` | |||
Pictures string `json:"pictures" xorm:"not null default '' comment('图片地址') VARCHAR(255)"` | |||
CouponUrl string `json:"coupon_url" xorm:"not null default '' comment('优惠券链接') VARCHAR(255)"` | |||
Amount int `json:"amount" xorm:"default 0 comment('总数') INT(11)"` | |||
ReturnType int `json:"return_type" xorm:"default 0 comment('0平台补贴 1 淘礼金补贴') INT(1)"` | |||
OwnbuyReturnType int `json:"ownbuy_return_type" xorm:"default 0 comment('自购补贴:1开启、0关闭') INT(1)"` | |||
} |
@@ -1,8 +0,0 @@ | |||
package model | |||
type NewcomersInviteRecord struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
FromUid int `json:"from_uid" xorm:"not null default 0 comment('邀请人uid') INT(11)"` | |||
ToUid int `json:"to_uid" xorm:"not null default 0 comment('被邀请人uid') INT(11)"` | |||
QualificationRecord int `json:"qualification_record" xorm:"not null default 0 comment('获得资格记录表ID') INT(11)"` | |||
} |
@@ -1,10 +0,0 @@ | |||
package model | |||
type NewcomersQualification struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') INT(10)"` | |||
RemainTimes int `json:"remain_times" xorm:"not null default 0 comment('剩余次数') INT(11)"` | |||
CumulativeTimes int `json:"cumulative_times" xorm:"not null default 0 comment('累计次数') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
} |
@@ -1,21 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type NewcomersQualificationRecord struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
Uid int `json:"uid" xorm:"not null default 0 INT(11)"` | |||
Source int `json:"source" xorm:"not null default 0 comment('1为注册获得 | |||
2为分享获得 | |||
3为消费扣除 | |||
4为后台修改 | |||
来源标识') TINYINT(4)"` | |||
SourceText string `json:"source_text" xorm:"not null default '' comment('来源') VARCHAR(255)"` | |||
ChangeNum int `json:"change_num" xorm:"not null default 0 comment('变更值') INT(11)"` | |||
AfterChangeNum int `json:"after_change_num" xorm:"not null default 0 comment('变更后值') INT(11)"` | |||
OrderId int64 `json:"order_id" xorm:"not null default 0 comment('新人免单订单ID(与order_list主键对应)') BIGINT(20)"` | |||
CreatedAt time.Time `json:"created_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') TIMESTAMP"` | |||
UpdatedAt time.Time `json:"updated_at" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"` | |||
} |
@@ -1,10 +0,0 @@ | |||
package model | |||
type OrdItemInfo struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
ItemId string `json:"item_id" xorm:"not null default '' comment('商品id') index VARCHAR(100)"` | |||
Pvd string `json:"pvd" xorm:"not null default '' comment('供应商') VARCHAR(32)"` | |||
Thumbnail string `json:"thumbnail" xorm:"not null default '' comment('缩略图URL') VARCHAR(2000)"` | |||
ItemTitle string `json:"item_title" xorm:"not null default '' comment('标题') VARCHAR(256)"` | |||
ItemLink string `json:"item_link" xorm:"not null default '' comment('商品链接') VARCHAR(2000)"` | |||
} |
@@ -1,42 +0,0 @@ | |||
package model | |||
type OrdList struct { | |||
OrdId int64 `xorm:"pk autoincr BIGINT(20)" json:"ord_id"` | |||
Uid int `xorm:"not null index INT(10)" json:"uid"` | |||
PvdOid string `xorm:"not null index(IDX_PVD) VARCHAR(50)" json:"pvd_oid"` | |||
ParentOrdId int64 `xorm:" BIGINT(20)" json:"parent_ord_id"` | |||
Pvd string `xorm:"not null default '' index(IDX_PVD) index(IDX_PVD_ITEM) VARCHAR(8)" json:"pvd"` | |||
ItemId string `xorm:"not null default '' index(IDX_PVD_ITEM) VARCHAR(50)" json:"item_id"` | |||
ItemNum int `xorm:"not null default 1 TINYINT(3)" json:"item_num"` | |||
ItemPrice float64 `xorm:"not null default 0.00 FLOAT(10,2)" json:"item_price"` | |||
ItemCommissionRate float64 `xorm:"not null default 0.00 FLOAT(6,4)" json:"item_commission_rate"` | |||
PaidPrice float64 `xorm:"not null default 0.00 FLOAT(10,2)" json:"paid_price"` | |||
OrderType int `xorm:"not null default 0 TINYINT(1)" json:"order_type"` | |||
PriceType int `xorm:"not null default 0 INT(1)" json:"price_type"` | |||
OrderCompare int `xorm:"not null default 0 TINYINT(1)" json:"order_compare"` | |||
SubsidyFee float64 `xorm:"not null default 0.00 FLOAT(8,2)" json:"subsidy_fee"` | |||
SubsidyRate float64 `xorm:"not null default 0.0000 FLOAT(10,4)" json:"subsidy_rate"` | |||
UserCommission float64 `xorm:"not null default 0.000 FLOAT(8,3)" json:"user_commission"` | |||
UserCommissionRate float64 `xorm:"not null default 0.0000 FLOAT(6,4)" json:"user_commission_rate"` | |||
PvdCommission float64 `xorm:"not null default 0.0000 FLOAT(8,4)" json:"pvd_commission"` | |||
PvdCommissionRate float64 `xorm:"not null default 0.0000 FLOAT(6,4)" json:"pvd_commission_rate"` | |||
SysCommission float64 `xorm:"not null default 0.0000 FLOAT(8,4)" json:"sys_commission"` | |||
SysCommissionRate float64 `xorm:"not null default 0.0000 FLOAT(6,4)" json:"sys_commission_rate"` | |||
PlanCommissionId int `xorm:"not null default 0 INT(10)" json:"plan_commission_id"` | |||
PlanCommissionState int `xorm:"not null default 0 TINYINT(1)" json:"plan_commission_state"` | |||
Reason string `xorm:"not null default '' VARCHAR(32)" json:"reason"` | |||
State int `xorm:"not null default 0 TINYINT(1)" json:"state"` | |||
LockState int `xorm:"not null default 0 TINYINT(1)" json:"lock_state"` | |||
CreateAt int `xorm:"not null default 0 INT(10)" json:"create_at"` | |||
UpdateAt int `xorm:"not null default 0 INT(11)" json:"update_at"` | |||
ConfirmAt int `xorm:"not null default 0 INT(10)" json:"confirm_at"` | |||
PvdSettleAt int `xorm:"not null default 0 INT(10)" json:"pvd_settle_at"` | |||
SettleAt int `xorm:"not null default 0 INT(10)" json:"settle_at"` | |||
SubsidyAt int `xorm:"not null default 0 INT(10)" json:"subsidy_at"` | |||
BenefitList string `xorm:"not null default '' index VARCHAR(200)" json:"benefit_list"` | |||
BenefitAll float64 `xorm:"not null default 0.00 FLOAT(8,2)" json:"benefit_all"` | |||
Data string `xorm:"not null default '' VARCHAR(2000)" json:"data"` | |||
UpdateFrom int `xorm:"not null default 0 TINYINT(1)" json:"update_from"` | |||
CreateFrom int `xorm:"not null default 0 TINYINT(1)" json:"create_from"` | |||
PvdPid string `xorm:"not null default '' index VARCHAR(100)" json:"pvd_pid"` | |||
} |
@@ -1,29 +0,0 @@ | |||
package model | |||
type OrdListHis struct { | |||
OrdId int64 `json:"ord_id" xorm:"not null pk autoincr comment('本系统订单ID') BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null comment('用户id') index INT(11)"` | |||
ProviderOid string `json:"provider_oid" xorm:"not null comment('供应商订单订单号') VARCHAR(50)"` | |||
SkuId string `json:"sku_id" xorm:"not null default '' comment('商品SKU') VARCHAR(50)"` | |||
ItemId string `json:"item_id" xorm:"not null comment('商品ID') VARCHAR(50)"` | |||
ItemPrice string `json:"item_price" xorm:"not null default 0.00 comment('商品单价') DECIMAL(10,2)"` | |||
Provider string `json:"provider" xorm:"not null default '' comment('供应商taobao,jd,pdd,vip,suning,kaola') VARCHAR(16)"` | |||
PaidPrice string `json:"paid_price" xorm:"not null default 0.00 comment('付款金额') DECIMAL(10,2)"` | |||
OrderType int `json:"order_type" xorm:"not null default 0 comment('0自购,1分享订单,粉丝订单') TINYINT(1)"` | |||
BuyerId int `json:"buyer_id" xorm:"not null default 0 comment('0分享订单,其它自购或粉丝') INT(11)"` | |||
UpdateFrom int `json:"update_from" xorm:"not null default 0 comment('订单更新来源,0.API,1.导入,2.后台操作') TINYINT(1)"` | |||
UserCommission string `json:"user_commission" xorm:"not null default 0.000 comment('用户佣金') DECIMAL(10,3)"` | |||
UserCommissionRate string `json:"user_commission_rate" xorm:"not null default 0.0000 comment('用户佣金比例,如10.05%就是0.1005') DECIMAL(6,4)"` | |||
ProviderAllCommission string `json:"provider_all_commission" xorm:"not null default 0.000 comment('联盟返佣总额') DECIMAL(10,3)"` | |||
ProviderAllCommissionRate string `json:"provider_all_commission_rate" xorm:"not null default 0.0000 comment('联盟返佣比例') DECIMAL(6,4)"` | |||
PlanCommissionId int `json:"plan_commission_id" xorm:"not null default 0 comment('分佣方案') INT(10)"` | |||
PlanSettleId int `json:"plan_settle_id" xorm:"not null default 0 comment('结算方案') INT(10)"` | |||
SettleState int `json:"settle_state" xorm:"not null default 0 comment('用户结算状态,0未结算,1已结算') TINYINT(1)"` | |||
Reason string `json:"reason" xorm:"not null default '' comment('失效原因') VARCHAR(32)"` | |||
State int `json:"state" xorm:"not null default 0 comment('0已付款,1已收货,2成功,3失效') TINYINT(1)"` | |||
CreateAt int `json:"create_at" xorm:"not null default 0 comment('创建时间') INT(10)"` | |||
UpdateAt int `json:"update_at" xorm:"not null default 0 comment('更新时间') INT(10)"` | |||
ConfirmAt int `json:"confirm_at" xorm:"not null default 0 comment('确认收货时间') INT(10)"` | |||
ProviderSettleAt int `json:"provider_settle_at" xorm:"not null default 0 comment('供应商结算时间') INT(10)"` | |||
SettleAt int `json:"settle_at" xorm:"not null default 0 comment('用户分佣结算时间') INT(10)"` | |||
} |
@@ -1,11 +0,0 @@ | |||
package model | |||
type OrdListRelate struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
Oid int64 `json:"oid" xorm:"not null default 0 comment('订单号') index unique(IDX_ORD) BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') unique(IDX_ORD) index INT(10)"` | |||
Amount float64 `json:"amount" xorm:"not null default 0.00 comment('金额') FLOAT(10,2)"` | |||
Pvd string `json:"pvd" xorm:"not null default '' comment('供应商taobao,jd,pdd,vip,suning,kaola') index VARCHAR(8)"` | |||
CreateAt int `json:"create_at" xorm:"not null default 0 comment('订单创建时间') index INT(10)"` | |||
Level int `json:"level" xorm:"not null default 0 comment('0自购 1直推 大于1:间推') INT(10)"` | |||
} |
@@ -1,12 +0,0 @@ | |||
package model | |||
import "time" | |||
type PlanCommission struct { | |||
Id int `json:"id" xorm:"not null pk autoincr comment('分佣方案ID,现在只允许1,2') INT(10)"` | |||
PlanName string `json:"plan_name" xorm:"not null default '' comment('方案名称') VARCHAR(64)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(256)"` | |||
Mode string `json:"mode" xorm:"not null default '' comment('模式,lv_all级差按总佣金,lv_self级差按自购') VARCHAR(16)"` | |||
Data string `json:"data" xorm:"not null default '' comment('里面包含等级分配方案数据') VARCHAR(3000)"` | |||
UpdateAt time.Time `json:"update_at" xorm:"default CURRENT_TIMESTAMP TIMESTAMP"` | |||
} |
@@ -1,15 +0,0 @@ | |||
package model | |||
type PlanReward struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
Pvd string `json:"pvd" xorm:"not null comment('供应商') VARCHAR(16)"` | |||
PvdRate float32 `json:"pvd_rate" xorm:"not null default 0.0000 comment('供应商抽成比例') FLOAT(6,4)"` | |||
SysRate float32 `json:"sys_rate" xorm:"not null default 0.0000 comment('平台抽成比例') FLOAT(6,4)"` | |||
SettleMode int `json:"settle_mode" xorm:"not null default 1 comment('0.手动方案,1.自动方案') TINYINT(1)"` | |||
PlanCommissionId int `json:"plan_commission_id" xorm:"not null default 0 comment('佣金方案0未设置,>0对应方案') TINYINT(3)"` | |||
PlanSettleId int `json:"plan_settle_id" xorm:"not null default 0 comment('结算方案0未设置,>0对应方案') TINYINT(3)"` | |||
State int `json:"state" xorm:"not null default 1 comment('0关闭,1开启') TINYINT(1)"` | |||
Source int `json:"source" xorm:"not null default 1 comment('佣金来源:1联盟佣金 2补贴金额') TINYINT(1)"` | |||
RegionRate float32 `json:"region_rate" xorm:"not null default 0.0000 comment('区域代理抽成比例') FLOAT(6,4)"` | |||
GlobalRate float32 `json:"global_rate" xorm:"not null default 0.0000 comment('全球分红抽成比例') FLOAT(6,4)"` | |||
} |
@@ -1,14 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type PlanSettle struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
PlanName string `json:"plan_name" xorm:"not null default '' comment('方案名称') VARCHAR(128)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(512)"` | |||
SettleMode int `json:"settle_mode" xorm:"not null default 0 comment('0组合条件,1固定条件') TINYINT(1)"` | |||
SettleCondition string `json:"settle_condition" xorm:"comment('当组合时候存json,固定存数字(组合条件时settleTime为0时是立即结算)') TEXT"` | |||
UpdateTime time.Time `json:"update_time" xorm:"default CURRENT_TIMESTAMP TIMESTAMP"` | |||
} |
@@ -1,8 +0,0 @@ | |||
package model | |||
type PlanWithdraw struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(10)"` | |||
PlanName string `json:"plan_name" xorm:"not null default '' comment('方案名称') VARCHAR(64)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('方案描述') VARCHAR(512)"` | |||
State int `json:"state" xorm:"not null default 1 comment('0关闭,1开启') TINYINT(1)"` | |||
} |
@@ -1,21 +0,0 @@ | |||
package model | |||
type PrivilegeCardBrand struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
ZhimengId int `json:"zhimeng_id" xorm:"not null default 0 comment('智盟ID') INT(11)"` | |||
ThirdId int `json:"third_id" xorm:"not null default 0 comment('三方平台ID') INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('品牌名称') VARCHAR(255)"` | |||
SubName string `json:"sub_name" xorm:"not null default '' comment('品牌副标题') VARCHAR(255)"` | |||
Logo string `json:"logo" xorm:"not null default '' comment('品牌logo') VARCHAR(255)"` | |||
CateId int `json:"cate_id" xorm:"not null default 0 comment('分类ID') INT(11)"` | |||
Type string `json:"type" xorm:"not null default '' comment('类型') VARCHAR(255)"` | |||
TypeId string `json:"type_id" xorm:"not null default '' comment('类型id') VARCHAR(255)"` | |||
AccountType string `json:"account_type" xorm:"comment('账号类型') VARCHAR(255)"` | |||
Remark string `json:"remark" xorm:"not null comment('温馨提示') TEXT"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示') TINYINT(1)"` | |||
Sort int `json:"sort" xorm:"default 0 comment('排序') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 INT(11)"` | |||
Skip string `json:"skip" xorm:"comment('跳转信息') TEXT"` | |||
} |
@@ -1,12 +0,0 @@ | |||
package model | |||
type PrivilegeCardBrandCate struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('分类名称') VARCHAR(255)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示') TINYINT(1)"` | |||
Sort int `json:"sort" xorm:"default 0 comment('排序') INT(11)"` | |||
Amount int `json:"amount" xorm:"default 0 comment('品牌数量') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 INT(11)"` | |||
} |
@@ -1,24 +0,0 @@ | |||
package model | |||
type PrivilegeCardGoods struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
ZhimengId int `json:"zhimeng_id" xorm:"not null default 0 comment('智盟ID') INT(11)"` | |||
ThirdId int `json:"third_id" xorm:"not null default 0 comment('三方平台ID') INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('商品名称') VARCHAR(255)"` | |||
GoodsImg string `json:"goods_img" xorm:"not null default '' comment('商品图片') VARCHAR(255)"` | |||
BrandId int `json:"brand_id" xorm:"not null default 0 comment('品牌ID') INT(11)"` | |||
Times string `json:"times" xorm:"not null default '' comment('时长') VARCHAR(255)"` | |||
CateId int `json:"cate_id" xorm:"not null default 0 comment('商品分类ID') INT(11)"` | |||
MarkupMode int `json:"markup_mode" xorm:"not null default 0 comment('加价模式 0为利润空间1为进货价') TINYINT(1)"` | |||
MarkupRate int `json:"markup_rate" xorm:"not null default 0 comment('加价比例') INT(3)"` | |||
OfficialPrice string `json:"official_price" xorm:"not null default 0.00 comment('原价') DECIMAL(10,2)"` | |||
PlatformPrice string `json:"platform_price" xorm:"not null default 0.00 comment('进货价') DECIMAL(10,2)"` | |||
FinalPrice string `json:"final_price" xorm:"not null default 0.00 comment('销售价') DECIMAL(10,2)"` | |||
Type string `json:"type" xorm:"not null default '' comment('类型') VARCHAR(255)"` | |||
TypeId string `json:"type_id" xorm:"not null default '' comment('类型id') VARCHAR(255)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示') TINYINT(1)"` | |||
Sort int `json:"sort" xorm:"default 0 comment('排序') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 INT(11)"` | |||
} |
@@ -1,13 +0,0 @@ | |||
package model | |||
type PrivilegeCardGoodsCate struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('商品分类名称') VARCHAR(255)"` | |||
IsShow int `json:"is_show" xorm:"not null default 1 comment('是否显示') TINYINT(1)"` | |||
Sort int `json:"sort" xorm:"default 0 comment('排序') INT(11)"` | |||
BrandId int `json:"brand_id" xorm:"not null default 0 comment('从属品牌ID') INT(11)"` | |||
Amount int `json:"amount" xorm:"default 0 comment('商品数量') INT(11)"` | |||
CreatedAt int `json:"created_at" xorm:"not null default 0 INT(11)"` | |||
UpdatedAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 INT(11)"` | |||
} |
@@ -1,24 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type PrivilegeCardNum struct { | |||
Id int64 `json:"id" xorm:"pk autoincr comment('主键') BIGINT(11)"` | |||
CardNum string `json:"card_num" xorm:"not null default '' comment('卡号') index VARCHAR(255)"` | |||
CardKey string `json:"card_key" xorm:"not null default '' comment('激活码') index VARCHAR(255)"` | |||
Uid int `json:"uid" xorm:"comment('绑定用户') index INT(11)"` | |||
Phone string `json:"phone" xorm:"not null default '' comment('用户手机号') VARCHAR(255)"` | |||
ParentUid int `json:"parent_uid" xorm:"not null default 0 comment('推荐人') index INT(11)"` | |||
CardType int `json:"card_type" xorm:"not null default 1 comment('1实体卡 2虚拟卡') TINYINT(1)"` | |||
Theme string `json:"theme" xorm:"not null default '' comment('主题描述') VARCHAR(255)"` | |||
FromType int `json:"from_type" xorm:"not null default 0 comment('来源:0用户购买 1后台操作 2 导入') TINYINT(1)"` | |||
Status int `json:"status" xorm:"not null default 0 comment('状态:0未激活 1激活') TINYINT(1)"` | |||
GivenData string `json:"given_data" xorm:"comment('赠送权益数据') TEXT"` | |||
ValidDateType int `json:"valid_date_type" xorm:"not null default 0 comment('1月度 2季度 3年度 4永久 5自定义(天数)') TINYINT(1)"` | |||
CustomDay int `json:"custom_day" xorm:"not null default 0 comment('自定义天数') INT(11)"` | |||
ExpireTime time.Time `json:"expire_time" xorm:"not null default '0000-00-00 00:00:00' comment('过期时间 2099-12-31 23:59:59表示永久') DATETIME"` | |||
CreateTime time.Time `json:"create_time" xorm:"created not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` | |||
UpdateTime time.Time `json:"update_time" xorm:"updated not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` | |||
} |
@@ -1,21 +0,0 @@ | |||
package model | |||
type PrivilegeCardOrd struct { | |||
Id int64 `json:"id" xorm:"pk autoincr comment('订单ID') BIGINT(20)"` | |||
OrdId int64 `json:"ord_id" xorm:"not null comment('订单号') index BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null comment('用户id') index INT(10)"` | |||
GoodsId int `json:"goods_id" xorm:"not null default 0 comment('商品ID') INT(11)"` | |||
GoodsNum int `json:"goods_num" xorm:"not null default 1 comment('商品数量') INT(11)"` | |||
GoodsPrice string `json:"goods_price" xorm:"not null default 0.00 comment('商品单价') DECIMAL(10,2)"` | |||
PaidPrice string `json:"paid_price" xorm:"not null default 0.00 comment('付款金额') DECIMAL(10,2)"` | |||
Profit string `json:"profit" xorm:"not null default 0.00 comment('利润') DECIMAL(10,2)"` | |||
PayMethod int `json:"pay_method" xorm:"not null default 1 comment('1余额2支付宝3微信') TINYINT(1)"` | |||
State int `json:"state" xorm:"not null default 0 comment('0未支付,1已支付,2已退款,3失效') TINYINT(1)"` | |||
Account string `json:"account" xorm:"not null default '' comment('充值账号--直冲') VARCHAR(255)"` | |||
KeySecret string `json:"key_secret" xorm:"not null comment('兑换用json--卡券') TEXT"` | |||
CreatedAt int `json:"created_at" xorm:"created not null default 0 comment('创建时间') INT(10)"` | |||
UpdatedAt int `json:"updated_at" xorm:"updated not null default 0 comment('更新时间') INT(10)"` | |||
DeletedAt int `json:"deleted_at" xorm:"not null default 0 comment('删除时间') INT(10)"` | |||
ExpiredAt int `json:"expired_at" xorm:"not null default 0 comment('到期时间') INT(10)"` | |||
SettleAt int `json:"settle_at" xorm:"not null default 0 comment('结算时间') INT(10)"` | |||
} |
@@ -1,28 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type PrivilegeOpenCardOrd struct { | |||
OrdId int64 `json:"ord_id" xorm:"not null pk comment('系统订单号') BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"not null comment('购买人id') INT(11)"` | |||
DateType int `json:"date_type" xorm:"not null default 1 comment('日期类型: 1月 2季 3年 4永久') TINYINT(1)"` | |||
CardType int `json:"card_type" xorm:"not null default 1 comment('权益卡类型:1实体卡 2虚拟卡') TINYINT(1)"` | |||
Address string `json:"address" xorm:"comment('收货地址') TEXT"` | |||
Receiver string `json:"receiver" xorm:"comment('收货人') VARCHAR(255)"` | |||
Phone string `json:"phone" xorm:"comment('收货人手机号') VARCHAR(20)"` | |||
CostPrice string `json:"cost_price" xorm:"not null default 0.0000 comment('支付金额') DECIMAL(10,4)"` | |||
LogisticNum string `json:"logistic_num" xorm:"comment('物流单号') VARCHAR(255)"` | |||
State int `json:"state" xorm:"not null default 0 comment('0未支付 1已支付 2印刷中 3已发货 4已完成 5售后中 6关闭') TINYINT(1)"` | |||
LogisticCompany string `json:"logistic_company" xorm:"comment('物流公司') VARCHAR(255)"` | |||
CardNum string `json:"card_num" xorm:"comment('卡号') VARCHAR(255)"` | |||
CardKey string `json:"card_key" xorm:"comment('卡密') VARCHAR(255)"` | |||
AfterSaleId int64 `json:"after_sale_id" xorm:"comment('售后单号') BIGINT(20)"` | |||
PayTime time.Time `json:"pay_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('支付时间') DATETIME"` | |||
CreateTime time.Time `json:"create_time" xorm:"created not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` | |||
UpdateTime time.Time `json:"update_time" xorm:"updated not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` | |||
GivenData string `json:"given_data" xorm:"comment('赠送设置') TEXT"` | |||
PayChannel int `json:"pay_channel" xorm:"not null comment('支付方式:1balance 2alipay 3wx_pay') TINYINT(1)"` | |||
SettleAt int `json:"settle_at" xorm:"default 0 comment('返现时间') INT(11)"` | |||
} |
@@ -1,16 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type Product struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"not null default 0 INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('产品库名称') VARCHAR(64)"` | |||
Pvd string `json:"pvd" xorm:"not null default '' comment('平台') VARCHAR(12)"` | |||
Source string `json:"source" xorm:"not null default '' comment('来源;official:官方') VARCHAR(32)"` | |||
Data string `json:"data" xorm:"not null comment('设置数据源,json') TEXT"` | |||
CreateAt time.Time `json:"create_at" xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` | |||
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` | |||
} |
@@ -1,25 +0,0 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type ProductCategory struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Pid int `json:"pid" xorm:"not null default 0 comment('分类父ID') INT(11)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('操作人') INT(11)"` | |||
Pvd string `json:"pvd" xorm:"not null default '' comment('供应商名,,taobao,jd,pdd,vip,suning,kaola') VARCHAR(16)"` | |||
Name string `json:"name" xorm:"not null default '' comment('分类名称') VARCHAR(32)"` | |||
Img string `json:"img" xorm:"not null default '' comment('分类图片') VARCHAR(64)"` | |||
Sort int `json:"sort" xorm:"default 0 comment('序号') INT(5)"` | |||
IsUse int `json:"is_use" xorm:"not null default 1 comment('是否开启;1:开启;0:关闭') TINYINT(1)"` | |||
CreateAt time.Time `json:"create_at" xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` | |||
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` | |||
} | |||
type ProductCategoryApp struct { | |||
Id string `json:"id"` | |||
Pid string `json:"pid"` | |||
Pvd string `json:"pvd"` | |||
Name string `json:"name"` | |||
} |
@@ -1,7 +0,0 @@ | |||
package model | |||
type ProductGoods struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
SourceId int `json:"source_id" xorm:"not null comment('product表id') INT(11)"` | |||
GoodsId int `json:"goods_id" xorm:"not null comment('guide_goods表id') INT(11)"` | |||
} |
@@ -1,16 +0,0 @@ | |||
package model | |||
type RedirectInfo struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Host string `json:"host" xorm:"not null default '' VARCHAR(255)"` | |||
PreHost string `json:"pre_host" xorm:"not null default '' VARCHAR(255)"` | |||
InviteCode string `json:"invite_code" xorm:"not null default '' VARCHAR(255)"` | |||
Appid string `json:"appid" xorm:"not null default '' VARCHAR(255)"` | |||
Unionid string `json:"unionid" xorm:"not null default '' VARCHAR(255)"` | |||
Openid string `json:"openid" xorm:"not null default '' VARCHAR(255)"` | |||
Headimgurl string `json:"headimgurl" xorm:"not null default '' VARCHAR(255)"` | |||
Nickname string `json:"nickname" xorm:"not null default '' VARCHAR(2550)"` | |||
CreateAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
UpdateAt int `json:"updated_at" xorm:"not null default 0 INT(11)"` | |||
Sex int `json:"sex" xorm:"not null default 0 INT(1)"` | |||
} |