Initial commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package withdrawUserOrdermod
|
||||
|
||||
import (
|
||||
"stat/common/mongos"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// 表名
|
||||
const CollUserWithDrawOrder = "withdraw_user_order"
|
||||
|
||||
var db *mongos.MongoTool
|
||||
|
||||
// UserWithdrawOrder 用户提现订单
|
||||
type UserWithdrawOrder struct {
|
||||
ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` //流水id
|
||||
PlatformId string `json:"platformId" bson:"platformId"` //原始平台流水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:是直推用户
|
||||
IsFormalUser bool `json:"isFormalUser" bson:"isFormalUser"` // 是否正式用户
|
||||
DistrictCode string `json:"districtCode" bson:"districtCode"` //渠道码
|
||||
PromCode string `json:"promCode,omitempty" bson:"promCode"` //用户推广序列
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package withdrawUserOrdermod
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"stat/common/log"
|
||||
"stat/common/mongos"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
// 初始化model
|
||||
func Init() {
|
||||
// 获取数据库表
|
||||
db = mongos.New(mongos.MgoManager, CollUserWithDrawOrder)
|
||||
|
||||
indexes := []mongo.IndexModel{
|
||||
{
|
||||
Keys: bson.D{{Key: "appId", Value: 1}, {Key: "uid", Value: 1}},
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := db.CreateIndex(context.Background(), indexes); err != nil {
|
||||
panic(fmt.Sprintf("Model %s InitIndex error %+v", CollUserWithDrawOrder, err))
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户详情(集团)
|
||||
func GetBlocUserWithdrawOrderList(ctx context.Context, appId *int32, start, end *time.Time, skip, limit int64) (count int64, data []UserWithdrawOrder, err error) {
|
||||
filter := bson.M{"blocDeduction": false}
|
||||
|
||||
if appId != nil {
|
||||
filter["appId"] = appId
|
||||
}
|
||||
if start != nil && end != nil {
|
||||
filter["successAt"] = bson.M{"$gte": start, "$lt": end}
|
||||
} else if start != nil {
|
||||
filter["successAt"] = bson.M{"$gte": start}
|
||||
} else if end != nil {
|
||||
filter["successAt"] = bson.M{"$lt": end}
|
||||
}
|
||||
|
||||
sort := bson.D{{Key: "successAt", Value: -1}}
|
||||
|
||||
opts := options.Find().SetSort(sort).SetSkip(skip).SetLimit(limit)
|
||||
|
||||
if err = db.Find(ctx, &data, filter, opts); err != nil {
|
||||
log.Error("register GetBlocUserWithdrawOrderList Find err", log.E(err))
|
||||
return
|
||||
}
|
||||
|
||||
if count, err = db.Count(ctx, filter); err != nil {
|
||||
log.Error("register GetBlocUserWithdrawOrderList Count err", log.E(err))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AddWithdrawOrder 添加提现请求
|
||||
func AddWithdrawOrder(ctx context.Context, doc *UserWithdrawOrder) (id string, err error) {
|
||||
ret, err := db.InsertOne(ctx, doc)
|
||||
if err != nil {
|
||||
log.Error("withdraw AddWithdraw InsertOne err", log.E(err))
|
||||
return
|
||||
}
|
||||
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// 获取用户详情(集团)
|
||||
func GetBlocUserWithdrawOrder(ctx context.Context, appId int32, start, end time.Time) (data []UserWithdrawOrder, err error) {
|
||||
filter := bson.M{"blocDeduction": false, "appId": appId, "successAt": bson.M{"$gte": start, "$lt": end}}
|
||||
|
||||
sort := bson.D{{Key: "successAt", Value: -1}}
|
||||
|
||||
opts := options.Find().SetSort(sort)
|
||||
|
||||
if err = db.Find(ctx, &data, filter, opts); err != nil {
|
||||
log.Error("register GetBlocUserWithdrawOrderList Find err", log.E(err))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user