|
@@ -3,6 +3,7 @@ package service
|
|
|
import (
|
|
|
"context"
|
|
|
"errors"
|
|
|
+ "log"
|
|
|
"math"
|
|
|
"time"
|
|
|
|
|
@@ -185,7 +186,7 @@ func (s *Synthesis) WithdrawalStatus(req *entity.UserWithdrawalStatus) error {
|
|
|
// 更新内容
|
|
|
updateContent := bson.M{"$set": bson.M{"status": req.Status}}
|
|
|
// 设置更新选项
|
|
|
- updateOptions := options.Update().SetUpsert(true) // 设置 upsert 选项
|
|
|
+ updateOptions := options.Update() // 设置 upsert 选项
|
|
|
// 执行更新操作
|
|
|
_, err := collection.UpdateOne(context.TODO(), updateCondition, updateContent, updateOptions)
|
|
|
if err != nil {
|
|
@@ -201,18 +202,32 @@ func (s *Synthesis) WithdrawalStatusBatch(req *entity.UserWithdrawalStatusBatch)
|
|
|
return errors.New("id 不能为空")
|
|
|
}
|
|
|
for _, id := range req.ID {
|
|
|
+
|
|
|
objID := primitive.ObjectID{}
|
|
|
objID, _ = primitive.ObjectIDFromHex(id)
|
|
|
updateCondition := bson.M{"_id": objID}
|
|
|
updateContent := bson.M{}
|
|
|
+ withdrawal := models.CashOutRecord{}
|
|
|
+ err := collection.FindOne(context.TODO(), updateCondition).Decode(&withdrawal)
|
|
|
+ if err != nil {
|
|
|
+ log.Printf("查询提现记录失败: %v", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
if req.Withdrawal != 0 {
|
|
|
- updateContent = bson.M{"$set": bson.M{"withdrawal": req.Withdrawal}}
|
|
|
+ if withdrawal.Status == 1 {
|
|
|
+ updateContent = bson.M{"$set": bson.M{"withdrawal": req.Withdrawal}}
|
|
|
+ } else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
}
|
|
|
if req.Status > 0 {
|
|
|
+ if withdrawal.Status != 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
updateContent = bson.M{"$set": bson.M{"status": req.Status}}
|
|
|
}
|
|
|
updateOptions := options.Update().SetUpsert(true)
|
|
|
- _, err := collection.UpdateOne(context.TODO(), updateCondition, updateContent, updateOptions)
|
|
|
+ _, err = collection.UpdateOne(context.TODO(), updateCondition, updateContent, updateOptions)
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|