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
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
"stat/models"
|
||||
)
|
||||
|
||||
var (
|
||||
ManagerDsp *mongos.Manager
|
||||
ManagerStat *mongos.Manager
|
||||
)
|
||||
|
||||
// InitMongoDB 初始化同步数据库
|
||||
func InitMongoDB() error {
|
||||
// DspDB := mongos.NewManager("mongodb://yinse:7P1pwdsMLds6QOB092Xq@172.104.42.200:47018/video?direct=game&maxPoolSize=200&connectTimeout=30&authSource=video")
|
||||
// if err := DspDB.Connect(); err != nil {
|
||||
// log.Error("mgoDB connect err", log.E(err))
|
||||
// return err
|
||||
// }
|
||||
// ManagerDsp = DspDB
|
||||
|
||||
// // 初始化表链接
|
||||
// UserInit()
|
||||
// RechargeInit()
|
||||
// WithdrawInit()
|
||||
|
||||
statDB := mongos.NewManager("mongodb://stat:ebCJuLfJQAGKVDecdFH0@172.104.42.200:47017,139.162.18.46:47017,139.162.35.214:47017/statcentre?maxPoolSize=200&connectTimeout=30&authSource=statcentre")
|
||||
if err := statDB.Connect(); err != nil {
|
||||
log.Error("mgoDB connect err", log.E(err))
|
||||
return err
|
||||
}
|
||||
mongos.MgoManager = statDB
|
||||
|
||||
// 初始化数据库索引
|
||||
models.InitIndex()
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
"stat/common/utils"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
type DspRecharge struct {
|
||||
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` //流水id
|
||||
UID uint64 `json:"uid" bson:"uid"` //用户id
|
||||
DevType string `json:"devType" bson:"devType"` //设备系统类型 ios pc android
|
||||
Channel string `json:"channel" bson:"channel"` //渠道类型 鲨鱼 金鱼
|
||||
OID string `json:"oid" bson:"oid"` //支付平台订单号
|
||||
WithdrawType string `json:"WithdrawType" bson:"WithdrawType"` //充值类型
|
||||
Money int64 `json:"money" bson:"money"` //充值金额 订单金额 李秋山确认
|
||||
PayMoney int64 `json:"payMoney" bson:"payMoney"` //实际到账金额 用户实际支付金额 李秋山确认
|
||||
Status int `json:"status" bson:"status"` //1进行中 2付款失败 3付款成功 4已经退款
|
||||
SuccessAt time.Time `json:"successAt" bson:"successAt"` //回调成功时间
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` //创建时间
|
||||
IsDirect bool `json:"isDirect" bson:"isDirect"` //true:是直推用户
|
||||
DistrictCode string `json:"districtCode" bson:"districtCode"` //商区码
|
||||
}
|
||||
|
||||
const CollRecharge = "recharge_order"
|
||||
|
||||
var dbRecharge *mongos.MongoTool
|
||||
|
||||
func RechargeInit() {
|
||||
dbRecharge = mongos.New(ManagerDsp, CollRecharge)
|
||||
}
|
||||
|
||||
// FindDspRecharge 查询用户
|
||||
func FindDspRecharge(ctx context.Context, skip int64, limit int64) ([]DspRecharge, error) {
|
||||
list := make([]DspRecharge, 0)
|
||||
|
||||
beginTimeStr := "2020-07-01T00:00:00-08:00"
|
||||
|
||||
beginTime := utils.StrTimeToTime(beginTimeStr)
|
||||
query := bson.M{"successAt": bson.M{"$gt": beginTime}}
|
||||
|
||||
sort := bson.D{{Key: "successAt", Value: 1}}
|
||||
opts := options.Find().SetSkip(skip).SetLimit(limit).SetSort(sort)
|
||||
|
||||
if err := dbRecharge.Find(ctx, &list, query, opts); err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspRecharge Find error", CollDistrict), log.E(err))
|
||||
return list, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func FindDspRechargeCount(ctx context.Context) (count int64, err error) {
|
||||
|
||||
beginTimeStr := "2020-07-01T00:00:00-08:00"
|
||||
|
||||
beginTime := utils.StrTimeToTime(beginTimeStr)
|
||||
query := bson.M{"successAt": bson.M{"$gt": beginTime}}
|
||||
|
||||
count, err = dbRecharge.Count(ctx, query)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspRecharge Find error", CollDistrict), log.E(err))
|
||||
return count, err
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// FindDspDistrictRecharge
|
||||
func FindDspDistrictRecharge(ctx context.Context, district string) ([]DspRecharge, error) {
|
||||
list := make([]DspRecharge, 0)
|
||||
|
||||
beginTimeStr := "2020-10-01T00:00:00-08:00"
|
||||
|
||||
beginTime := utils.StrTimeToTime(beginTimeStr)
|
||||
query := bson.M{"successAt": bson.M{"$gt": beginTime}, "districtCode": district}
|
||||
|
||||
if err := dbRecharge.Find(ctx, &list, query); err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspDistrictRecharge Find error", CollDistrict), log.E(err))
|
||||
return list, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
//
|
||||
@@ -0,0 +1,69 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
type DspUser struct {
|
||||
UID uint64 `json:"uid" bson:"uid"` //用户id
|
||||
SysType string `json:"sysType" bson:"sysType"` //系统类型
|
||||
DevType string `json:"devType" bson:"devType"` //设备类型
|
||||
Mobile string `json:"mobile" bson:"mobile"` //手机号
|
||||
Name string `json:"name" bson:"name"` //名字
|
||||
DistrictCode string `json:"districtCode" bson:"districtCode"` //商区码
|
||||
PromCode string `json:"promotionCode" bson:"promotionCode"` //推广码
|
||||
IsDirect bool `json:"isDirect" bson:"isDirect"` //true:是直推用户
|
||||
CreatedAt time.Time `bson:"createdAt"` //文档创建时间
|
||||
}
|
||||
|
||||
const CollUser = "user"
|
||||
|
||||
var dbUser *mongos.MongoTool
|
||||
|
||||
func UserInit() {
|
||||
dbUser = mongos.New(ManagerDsp, CollUser)
|
||||
}
|
||||
|
||||
// FindDspUserInfo 查询用户
|
||||
func FindDspUserInfo(ctx context.Context, skip int64, limit int64) ([]DspUser, error) {
|
||||
list := make([]DspUser, 0)
|
||||
query := bson.M{}
|
||||
sort := bson.D{{Key: "_id", Value: 1}}
|
||||
opts := options.Find().SetSkip(skip).SetLimit(limit).SetSort(sort)
|
||||
|
||||
if err := dbUser.Find(ctx, &list, query, opts); err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspUserInfo Find error", CollDistrict), log.E(err))
|
||||
return list, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func FindOneUserInfo(ctx context.Context, uid uint64) (user DspUser, err error) {
|
||||
query := bson.M{"uid": uid}
|
||||
|
||||
if err := dbUser.FindOne(ctx, &user, query); err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspUserInfo Find error", CollDistrict), log.E(err))
|
||||
return user, err
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func FindManyUserInfo(ctx context.Context, uid []uint64) (user []DspUser, err error) {
|
||||
query := bson.M{"uid": bson.M{"$in": uid}}
|
||||
|
||||
if err := dbUser.Find(ctx, &user, query); err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspUserInfo Find error", CollDistrict), log.E(err))
|
||||
return user, err
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
"stat/common/utils"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
type DspWithdraw struct {
|
||||
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` //流水id
|
||||
AppId int32 `json:"appId" bson:"appId"` // appID
|
||||
UID uint64 `json:"uid" bson:"uid"` //用户id
|
||||
Name string `json:"name" bson:"name"` //用户名
|
||||
Amount int64 `json:"amount" bson:"amount"` //蝴蝶币数量
|
||||
OID string `json:"oid" bson:"oid"` //第三方支付平台id
|
||||
Money int64 `json:"money" bson:"money" binding:"required"` //提现金额
|
||||
PayMoney int64 `json:"payMoney" bson:"payMoney"` //实际到账
|
||||
PayType string `json:"payType" bson:"payType" binding:"required"` //提现方式,alipay,bankcard
|
||||
ActName string `json:"actName" bson:"actName"` //交易账户持有人
|
||||
Act string `json:"act" bson:"act"` //交易账户
|
||||
UserIP string `json:"userIp" bson:"userIp"` //用户ip
|
||||
DeviceType string `json:"deviceType" bson:"deviceType"` //设备类型
|
||||
DevID string `json:"devID" bson:"devID"` //设备id
|
||||
Status int `json:"status" bson:"status"` //1未审核 2审核通过,转账中 3已拒绝 4未知错误 5提现成功 6提现失败
|
||||
StatusDesc string `json:"statusDesc" bson:"statusDesc"` //状态说明
|
||||
CheckedAt time.Time `json:"checkedAt" bson:"checkedAt"` //审核时间
|
||||
ProgressAt time.Time `json:"progressAt" bson:"progressAt"` //第三方下单成功时间
|
||||
SuccessAt time.Time `json:"successAt" bson:"successAt"` //回调成功时间
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` //刷新时间
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` //提现申请时间
|
||||
ReceivedAt time.Time `json:"receivedAt" bson:"receivedAt"` //到账时间 李秋山确认 三方出款时间
|
||||
BlocDeduction bool `json:"blocDeduction" bson:"blocDeduction"` //集团扣量(特定渠道扣量)
|
||||
IsDirect bool `json:"isDirect" bson:"isDirect"` //true:是直推用户
|
||||
DistrictCode string `json:"districtCode" bson:"districtCode"` //渠道码
|
||||
PromCode string `json:"promCode,omitempty" bson:"promCode"` //用户推广序列
|
||||
}
|
||||
|
||||
const CollWithdraw = "withdraw_order"
|
||||
|
||||
var dbWithdraw *mongos.MongoTool
|
||||
|
||||
func WithdrawInit() {
|
||||
dbWithdraw = mongos.New(ManagerDsp, CollWithdraw)
|
||||
}
|
||||
|
||||
// FindDspWithdraw 查询用户
|
||||
func FindDspWithdraw(ctx context.Context, skip int64, limit int64) ([]DspWithdraw, error) {
|
||||
list := make([]DspWithdraw, 0)
|
||||
|
||||
beginTimeStr := "2020-07-01T00:00:00-08:00"
|
||||
|
||||
beginTime := utils.StrTimeToTime(beginTimeStr)
|
||||
query := bson.M{"successAt": bson.M{"$gt": beginTime}, "withdrawType": 1}
|
||||
|
||||
sort := bson.D{{Key: "successAt", Value: 1}}
|
||||
opts := options.Find().SetSkip(skip).SetLimit(limit).SetSort(sort)
|
||||
|
||||
if err := dbWithdraw.Find(ctx, &list, query, opts); err != nil {
|
||||
log.Error(fmt.Sprintf("model %s FindDspWithdraw Find error", CollDistrict), log.E(err))
|
||||
return list, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
Reference in New Issue
Block a user