|
|
@@ -34,44 +34,61 @@ func PlayletOrderSettle() { |
|
|
|
fmt.Println(utils.SerializeStr(order)) |
|
|
|
|
|
|
|
for _, v := range order { |
|
|
|
fmt.Println("=================00") |
|
|
|
// 加锁 防止并发提取 |
|
|
|
mutexKey := fmt.Sprintf("playlet_order_settle1:%s", v.CustomOid) |
|
|
|
mutexKey := fmt.Sprintf("playlet_order_settle2:%s", v.CustomOid) |
|
|
|
withdrawAvailable, err := cache.Do("SET", mutexKey, 1, "EX", 1800, "NX") |
|
|
|
if err != nil { |
|
|
|
fmt.Println("=================0") |
|
|
|
|
|
|
|
fmt.Println(err) |
|
|
|
continue |
|
|
|
} |
|
|
|
if withdrawAvailable != "OK" { |
|
|
|
fmt.Println("=================1") |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
if v.SettleTime > 0 { |
|
|
|
fmt.Println("=================2") |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
//加到上月结算 |
|
|
|
if v.Uid == "" || v.Uid == "0" { |
|
|
|
fmt.Println("=================3") |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
masterDb := db.MasterDb{} |
|
|
|
masterDb.Set() |
|
|
|
master := masterDb.GetMaster(v.Uid) |
|
|
|
if master == nil { |
|
|
|
fmt.Println("=================4") |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
masterAmountDb := db.MasterAmountDb{} |
|
|
|
masterAmountDb.Set() |
|
|
|
amount := masterAmountDb.GetMasterAmount(utils.IntToStr(master.Id), "playlet") |
|
|
|
if amount == nil { |
|
|
|
fmt.Println("=================5") |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
if utils.StrToFloat64(v.Commission) <= 0 { |
|
|
|
v.SettleTime = int(time.Now().Unix()) |
|
|
|
playletSaleOrderDb.PlayletVideoOrderUpdate(v.Id, &v) |
|
|
|
fmt.Println("=================6") |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
oldAmount := amount.LastMonthAmount |
|
|
|
amount.LastMonthAmount = utils.Float64ToStr(utils.StrToFloat64(amount.LastMonthAmount) + utils.StrToFloat64(v.Commission)) |
|
|
|
update := masterAmountDb.MasterAmountUpdate(master.Id, amount) |
|
|
|
if update == false { |
|
|
|
fmt.Println("=================7") |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
var tmp = model.MasterLastMonthAmountFlow{ |
|
|
|