forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
// DistrictInfo 渠道原始信息
|
||||
type DistrictInfo struct {
|
||||
Code string `bson:"code"` //商区码
|
||||
Name string `bson:"name"` //账号
|
||||
Mobile string `bson:"mobile"` //手机号
|
||||
Parent string `bson:"parent"` //parent
|
||||
Password string `bson:"password"` //密码
|
||||
DiscType int `bson:"discType"` //商区类型/结算类型
|
||||
DividendRatio float64 `bson:"dividendRatio"` //分红比例 参与结算
|
||||
DisSettlement bool `bson:"disSettlement"` //禁止结算
|
||||
UserUnitCent float64 `bson:"userUnitCent"` //用户单价 单位:分
|
||||
NUDeductionRatio float64 `bson:"nuDeductionRatio"` //新增用户扣量比例
|
||||
NUDedLowerOutset int64 `bson:"nuDedLowerOutset"` //新增用户扣量起点
|
||||
NUDedAt time.Time `bson:"nuDedAt"` //新增用户扣量时间
|
||||
RechgDeductionRatio float64 `bson:"rechgDeductionRatio"` //充值扣量比例
|
||||
RechgDedLowerOutset int64 `bson:"rechgDedLowerOutset"` //充值扣量起点
|
||||
RechgDedAt time.Time `bson:"rechgDedAt"` //充值扣量时间
|
||||
ChildMax int `bson:"childMax"` //最大孩子数
|
||||
Disable bool `bson:"disable"` //禁用
|
||||
Lock bool `bson:"lock"` //禁止登陆
|
||||
DisTrans bool `bson:"disTrans"` //禁止交易
|
||||
DisAd bool `bson:"disAd"` //禁止广告
|
||||
DisMulDivi bool `bson:"disMulDivi"` //禁止多级分成(目前针对CPS)
|
||||
PayPassword string `bson:"payPassword"` //支付密码
|
||||
BalanceCent float64 `bson:"balance"` //余额 单位:分
|
||||
Remark string `bson:"remark"` //备注
|
||||
CreatedAt time.Time `bson:"createdAt"` //文档创建时间
|
||||
UpdatedAt time.Time `bson:"updatedAt"` //文档更新时间
|
||||
}
|
||||
|
||||
// DspDistrictCodeInfo 渠道码信息
|
||||
type DspDistrictCodeInfo struct {
|
||||
DiscCode string `bson:"discCode"` //商圈码
|
||||
PromSeq string `bson:"promSeq"` //推广序列
|
||||
Remark string `bson:"remark"` //备注
|
||||
CreatedAt time.Time `bson:"createdAt"`
|
||||
DeletedAt time.Time `bson:"deletedAt,omitempty"` //删除时间
|
||||
}
|
||||
|
||||
type BillLog struct {
|
||||
SumDate time.Time `bson:"sumDate"` //日期
|
||||
DiscType string `bson:"discType"` //商区类型
|
||||
DistrictCode string `bson:"districtCode"` //商圈码
|
||||
Name string `bson:"name"` //账号
|
||||
Cent float64 `bson:"cent"` //人民币分
|
||||
Desc string `bson:"desc"` //记录描述
|
||||
CreatedAt time.Time `bson:"createdAt"` //创建时间
|
||||
}
|
||||
|
||||
const CollDistrict = "district"
|
||||
const CollDistrictCode = "prom_seqe"
|
||||
|
||||
var dbDistrict *mongos.MongoTool
|
||||
var dbDistrictcode *mongos.MongoTool
|
||||
var dbDistrictLog *mongos.MongoTool
|
||||
|
||||
func DistrictInit() {
|
||||
dbDistrict = mongos.New(ManagerDsp, CollDistrict)
|
||||
dbDistrictcode = mongos.New(ManagerDsp, CollDistrictCode)
|
||||
}
|
||||
|
||||
// FindDspDistrictInfo 查询所有渠道
|
||||
func FindDspDistrictInfo(ctx context.Context) ([]DistrictInfo, error) {
|
||||
list := make([]DistrictInfo, 0)
|
||||
query := bson.M{}
|
||||
|
||||
if err := dbDistrict.Find(ctx, &list, query); err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspDistrictInfo Find error", CollDistrict), log.E(err))
|
||||
return list, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// FindDspDistrictCodeInfo 查询渠道的渠道码
|
||||
func FindDspDistrictCodeInfo(ctx context.Context, discCode string) ([]DspDistrictCodeInfo, error) {
|
||||
list := make([]DspDistrictCodeInfo, 0)
|
||||
query := bson.M{"discCode": discCode}
|
||||
|
||||
if err := dbDistrictcode.Find(ctx, &list, query); err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspDistrictInfo Find error", CollDistrict), log.E(err))
|
||||
return list, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
Reference in New Issue
Block a user