forked from all_user/stat_center
Initial commit
This commit is contained in:
Executable
+60
@@ -0,0 +1,60 @@
|
||||
package syncwithdraw
|
||||
|
||||
type TagSyncWithdraw struct {
|
||||
Act string
|
||||
ActName string
|
||||
AppId string
|
||||
BlocDeduction string
|
||||
CreatedAt string
|
||||
DevID string
|
||||
DeviceType string
|
||||
DistrictCode string
|
||||
ID string
|
||||
IsDirect string
|
||||
Money string
|
||||
Name string
|
||||
OID string
|
||||
PayMoney string
|
||||
PayType string
|
||||
PlatformId string
|
||||
PromCode string
|
||||
RegisterTime string
|
||||
Status string
|
||||
SuccessAt string
|
||||
UID string
|
||||
UpdatedAt string
|
||||
}
|
||||
|
||||
var FN struct {
|
||||
SyncWithdraw TagSyncWithdraw
|
||||
}
|
||||
|
||||
var TN struct {
|
||||
SyncWithdraw string
|
||||
}
|
||||
|
||||
func init() {
|
||||
FN.SyncWithdraw.Act = "act"
|
||||
FN.SyncWithdraw.ActName = "actName"
|
||||
FN.SyncWithdraw.AppId = "appId"
|
||||
FN.SyncWithdraw.BlocDeduction = "blocDeduction"
|
||||
FN.SyncWithdraw.CreatedAt = "createdAt"
|
||||
FN.SyncWithdraw.DevID = "devID"
|
||||
FN.SyncWithdraw.DeviceType = "deviceType"
|
||||
FN.SyncWithdraw.DistrictCode = "districtCode"
|
||||
FN.SyncWithdraw.ID = "_id"
|
||||
FN.SyncWithdraw.IsDirect = "isDirect"
|
||||
FN.SyncWithdraw.Money = "money"
|
||||
FN.SyncWithdraw.Name = "name"
|
||||
FN.SyncWithdraw.OID = "oid"
|
||||
FN.SyncWithdraw.PayMoney = "payMoney"
|
||||
FN.SyncWithdraw.PayType = "payType"
|
||||
FN.SyncWithdraw.PlatformId = "platformId"
|
||||
FN.SyncWithdraw.PromCode = "promCode"
|
||||
FN.SyncWithdraw.RegisterTime = "registerTime"
|
||||
FN.SyncWithdraw.Status = "status"
|
||||
FN.SyncWithdraw.SuccessAt = "successAt"
|
||||
FN.SyncWithdraw.UID = "uid"
|
||||
FN.SyncWithdraw.UpdatedAt = "updatedAt"
|
||||
TN.SyncWithdraw = "sync_withdraw"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package syncwithdraw
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// 帖子模型,数据库中的
|
||||
// @table:sync_withdraw
|
||||
type SyncWithdraw struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` // ID
|
||||
AppId int32 `json:"appId" bson:"appId"` //appID
|
||||
UID uint64 `json:"uid" bson:"uid"` //用户id
|
||||
PlatformId string `json:"platformId" bson:"platformId"` //原始平台流水Id
|
||||
Name string `json:"name" bson:"name"` //用户名
|
||||
OID string `json:"oid" bson:"oid"` //第三方支付平台id
|
||||
Money int64 `json:"money" bson:"money"` //提现金额
|
||||
PayMoney int64 `json:"payMoney" bson:"payMoney"` //实际到账
|
||||
PayType string `json:"payType" bson:"payType"` //提现方式,alipay,bankcard
|
||||
ActName string `json:"actName" bson:"actName"` //交易账户持有人
|
||||
Act string `json:"act" bson:"act"` //交易账户
|
||||
DeviceType string `json:"deviceType" bson:"deviceType"` //设备类型
|
||||
DevID string `json:"devID" bson:"devID"` //设备id
|
||||
Status int `json:"status" bson:"status"` //5提现成功
|
||||
SuccessAt time.Time `json:"successAt" bson:"successAt"` //回调成功时间
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` //刷新时间
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` //提现申请时间
|
||||
BlocDeduction bool `json:"blocDeduction" bson:"blocDeduction"` // 集团扣量(特定渠道扣量)
|
||||
RegisterTime time.Time `json:"registerTime,omitempty" bson:"registerTime"` // 操作时间
|
||||
IsDirect bool `json:"isDirect" bson:"isDirect"` //true:是直推用户
|
||||
IsFormalUser bool `json:"isFormalUser" bson:"isFormalUser"` // 是否正式用户
|
||||
DistrictCode string `json:"districtCode" bson:"districtCode"` //渠道码
|
||||
PromCode string `json:"promCode,omitempty" bson:"promCode"` //用户推广序列
|
||||
}
|
||||
type SyncWithdrawList []*SyncWithdraw
|
||||
@@ -0,0 +1,128 @@
|
||||
package syncwithdraw
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
var db *mongos.MongoTool
|
||||
|
||||
func Init(ctx context.Context) {
|
||||
// 获取数据库表
|
||||
db = mongos.New(mongos.MgoManager, TN.SyncWithdraw)
|
||||
// 初始化索引
|
||||
indexes := []mongo.IndexModel{
|
||||
{
|
||||
Keys: bson.D{
|
||||
{Key: FN.SyncWithdraw.UID, Value: 1},
|
||||
{Key: FN.SyncWithdraw.AppId, Value: 1},
|
||||
},
|
||||
},
|
||||
}
|
||||
if _, err := db.CreateIndex(ctx, indexes); err != nil {
|
||||
panic(fmt.Sprintf("(SyncWithdraw:initSyncWithdrawIndex) Create SyncWithdraw Index failed! err:%+v:", err))
|
||||
}
|
||||
}
|
||||
|
||||
//InsertOneSyncWithdraw 插入一个VIP购买记录
|
||||
func InsertOneSyncWithdraw(ctx context.Context, SyncWithdraw *SyncWithdraw) error {
|
||||
if _, err := db.InsertOne(ctx, SyncWithdraw); err != nil {
|
||||
log.Warn("SyncWithdraw:InsertOneSyncWithdraw db.InsertOne failed", log.E(err))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//FindOneSyncWithdraw 查找一个VIP购买记录
|
||||
func FindOneSyncWithdraw(ctx context.Context, filter bson.M) (
|
||||
*SyncWithdraw, error) {
|
||||
var SyncWithdraw SyncWithdraw
|
||||
if err := db.FindOne(ctx, &SyncWithdraw, filter); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SyncWithdraw, nil
|
||||
}
|
||||
|
||||
//DelOneSyncWithdraw 删除一个VIP购买记录
|
||||
func DelOneSyncWithdraw(ctx context.Context, filter bson.M) (
|
||||
int64, error) {
|
||||
count, err := db.DeleteOne(ctx, filter)
|
||||
if err != nil {
|
||||
log.Warn("SyncWithdraw:DelOneSyncWithdraw db.DeleteOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return 0, err
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
//UpdateOneSyncWithdraw 更新一个VIP购买记录
|
||||
func UpdateOneSyncWithdraw(ctx context.Context, filter bson.M, update bson.M) error {
|
||||
_, err := db.UpdateOne(ctx, filter, update)
|
||||
if err != nil {
|
||||
log.Warn("user:UpdateOneSyncWithdraw db.UpdateOne failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//CountSyncWithdraws 统计VIP购买记录数量
|
||||
func CountSyncWithdraws(ctx context.Context, filter bson.M) (
|
||||
int64, error) {
|
||||
count, err := db.Count(ctx, filter)
|
||||
if err != nil {
|
||||
log.Warn("SyncWithdraw:CountSyncWithdraws db.Count failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return 0, err
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
//UpdateManySyncWithdraw 更新满足条件的VIP购买记录
|
||||
func UpdateManySyncWithdraw(ctx context.Context, filter bson.M, update bson.M) error {
|
||||
_, err := db.UpdateMany(ctx, filter, update)
|
||||
if err != nil {
|
||||
log.Warn("user:UpdateManySyncWithdraw db.UpdateMany failed",
|
||||
log.E(err), log.Any("filter", filter))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//FindManySyncWithdraw 查找一批VIP购买记录数据
|
||||
func FindManySyncWithdraw(ctx context.Context, filter bson.M,
|
||||
opts ...*options.FindOptions) (SyncWithdrawList, error) {
|
||||
data := make(SyncWithdrawList, 0)
|
||||
if err := db.Find(ctx, &data, filter, opts...); err != nil {
|
||||
log.Warn("SyncWithdraw:FindManySyncWithdraw db.Find failed", log.E(err), log.Any("filter", filter))
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
//FindManySyncWithdrawWithBind 用自己定义结构查找一批VIP购买记录数据
|
||||
func FindManySyncWithdrawWithBind(ctx context.Context, bind interface{}, filter bson.M,
|
||||
opts ...*options.FindOptions) error {
|
||||
if err := db.Find(ctx, bind, filter, opts...); err != nil {
|
||||
log.Warn("SyncWithdraw:FindManySyncWithdrawWithBind db.Find failed", log.E(err), log.Any("filter", filter))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//AggregateSyncWithdraws 聚合查找一批VIP购买记录信息
|
||||
func AggregateSyncWithdraws(ctx context.Context,
|
||||
bind interface{}, pipeline []bson.M) error {
|
||||
if err := db.Aggregate(ctx, bind, pipeline); err != nil {
|
||||
log.Warn("feedback:AggregateSyncWithdraws db.Aggregate failed",
|
||||
log.E(err), log.Any("pipeline", pipeline))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user