89 lines
3.1 KiB
Go
89 lines
3.1 KiB
Go
package withdrawser
|
||
|
||
import (
|
||
"time"
|
||
|
||
"91porn-server/common/log"
|
||
"91porn-server/common/maths"
|
||
"91porn-server/common/pageopt"
|
||
"91porn-server/models/v/wdordmod"
|
||
|
||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||
)
|
||
|
||
type HumanRefundQuery struct {
|
||
ID *primitive.ObjectID `json:"id" form:"id"`
|
||
DistrictCode *string `json:"districtCode" form:"districtCode"`
|
||
UID *uint64 `json:"uid" form:"uid"`
|
||
}
|
||
|
||
type HumanRefundRecord struct {
|
||
ID primitive.ObjectID `json:"id"` //流水id
|
||
UID uint64 `json:"uid"` //用户id
|
||
Name string `json:"name"` //用户名
|
||
Money float64 `json:"money"` //税前金额
|
||
PayMoney float64 `json:"payMoney"` //提现金额
|
||
PayType string `json:"payType"` //提现方式,alipay,bankcard
|
||
WithdrawType wdordmod.WithdrawTypes `json:"withdrawType"` //提现类型,0:代理提现 1:金币提现 2:商区提现
|
||
ActName string `json:"actName"` //账户持有人
|
||
Act string `json:"act"` //交易账户
|
||
Status int `json:"status"` //1:未审核 2:转账中 3:已拒绝 4:未知错误 5:提现成功 6:提现失败
|
||
StatusDesc string `json:"statusDesc"` //状态说明
|
||
DistrictCode string `json:"districtCode"` //商区码
|
||
CreatedAt time.Time `json:"createdAt"` //提现申请时间
|
||
}
|
||
|
||
type humanRefundPage struct {
|
||
Total int64 `json:"total"`
|
||
List []HumanRefundRecord `json:"list"`
|
||
}
|
||
|
||
var unknownStatus = wdordmod.UNKNOWN
|
||
|
||
func HumanRefundPage(skip, limit int64, query HumanRefundQuery) humanRefundPage {
|
||
mats := []pageopt.Matcher{
|
||
(&wdordmod.IDMatch{ID: query.ID}).New(),
|
||
(&wdordmod.UIDMatch{UID: query.UID}).New(),
|
||
(&wdordmod.DistrictCodeMatch{DistrictCode: query.DistrictCode}).New(),
|
||
(&wdordmod.StatusMatch{Status: &unknownStatus}).New(),
|
||
}
|
||
list, _ := wdordmod.List(wdordmod.Sort_CreatedAt_n1, &skip, &limit, mats...)
|
||
records := make([]HumanRefundRecord, len(list))
|
||
for i, v := range list {
|
||
records[i] = HumanRefundRecord{
|
||
ID: v.ID,
|
||
UID: v.UID,
|
||
Name: v.Name,
|
||
Money: maths.ToFloat64_b2(float64(v.Money)),
|
||
PayMoney: maths.ToFloat64_b2(float64(v.PayMoney)),
|
||
PayType: v.PayType,
|
||
WithdrawType: v.WithdrawType,
|
||
ActName: v.ActName,
|
||
Act: v.Act,
|
||
Status: v.Status,
|
||
StatusDesc: v.StatusDesc,
|
||
DistrictCode: v.DistrictCode,
|
||
CreatedAt: v.CreatedAt,
|
||
}
|
||
}
|
||
count, _ := wdordmod.Count(mats...)
|
||
return humanRefundPage{count, records}
|
||
}
|
||
|
||
func DealWithUnkownOrder(id string, remark string) error {
|
||
w, err := wdordmod.FindWithdrawOrderByIDAndStatus(id, wdordmod.UNKNOWN) //防重入
|
||
if err != nil {
|
||
return err
|
||
}
|
||
now := time.Now()
|
||
set := wdordmod.EditSelector{
|
||
Status: wdordmod.FAILURE,
|
||
StatusDesc: "[人工退款]" + remark,
|
||
CheckedAt: &now,
|
||
}
|
||
if err = refusedWirhdraw(w, set, "提现被平台拒绝"); err != nil {
|
||
log.Error("提现订单人工退款失败", log.E(err))
|
||
}
|
||
return err
|
||
}
|