90 lines
3.8 KiB
Go
90 lines
3.8 KiB
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"stat/common/log"
|
|
"stat/common/mongos"
|
|
"time"
|
|
|
|
"github.com/shopspring/decimal"
|
|
"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 decimal.Decimal `bson:"balance"` //余额 单位:分
|
|
Remark string `bson:"remark"` //备注
|
|
CreatedAt time.Time `bson:"createdAt"` //文档创建时间
|
|
UpdatedAt time.Time `bson:"updatedAt"` //文档更新时间
|
|
}
|
|
|
|
// YhDistrictCodeInfo 渠道码信息
|
|
type YhDistrictCodeInfo struct {
|
|
DiscCode string `bson:"discCode"` //商圈码
|
|
PromSeq string `bson:"promSeq"` //推广序列
|
|
Remark string `bson:"remark"` //备注
|
|
PromCode string `bson:"promCode"` //备注
|
|
CreatedAt time.Time `bson:"createdAt"`
|
|
DeletedAt time.Time `bson:"deletedAt,omitempty"` //删除时间
|
|
}
|
|
|
|
const CollDistrict = "district"
|
|
const CollDistrictCode = "disc_prom_seqe"
|
|
|
|
var dbDistrict *mongos.MongoTool
|
|
var dbDistrictcode *mongos.MongoTool
|
|
|
|
func DistrictInit() {
|
|
dbDistrict = mongos.New(ManagerYh, CollDistrict)
|
|
dbDistrictcode = mongos.New(ManagerYh, CollDistrictCode)
|
|
}
|
|
|
|
// FindYhDistrictInfo 查询所有渠道
|
|
func FindSQDistrictInfo(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 FindYhDistrictInfo Find error", CollDistrict), log.E(err))
|
|
return list, err
|
|
}
|
|
|
|
return list, nil
|
|
}
|
|
|
|
// FindSQDistrictCodeInfo 查询渠道的渠道码
|
|
func FindSQDistrictCodeInfo(ctx context.Context, discCode string) ([]YhDistrictCodeInfo, error) {
|
|
list := make([]YhDistrictCodeInfo, 0)
|
|
query := bson.M{"discCode": discCode}
|
|
|
|
if err := dbDistrictcode.Find(ctx, &list, query); err != nil {
|
|
log.Error(fmt.Sprintf("model %s FindYhDistrictInfo Find error", CollDistrict), log.E(err))
|
|
return list, err
|
|
}
|
|
|
|
return list, nil
|
|
}
|