Browse Source

test

master
huangjiajun 1 year ago
parent
commit
33d0eddc13
2 changed files with 23 additions and 2 deletions
  1. +5
    -1
      app/db/db_master_amount.go
  2. +18
    -1
      app/task/svc/svc_playlet_order_settle.go

+ 5
- 1
app/db/db_master_amount.go View File

@@ -3,6 +3,7 @@ package db
import ( import (
"applet/app/db/model" "applet/app/db/model"
"applet/app/utils" "applet/app/utils"
"fmt"
"time" "time"
"xorm.io/xorm" "xorm.io/xorm"
) )
@@ -41,8 +42,11 @@ func (masterAmountDb *MasterAmountDb) GetMasterAmountByListId(id string) *model.
return &data return &data
} }
func (masterAmountDb *MasterAmountDb) MasterAmountUpdate(id int, data *model.MasterAmount) bool { func (masterAmountDb *MasterAmountDb) MasterAmountUpdate(id int, data *model.MasterAmount) bool {
get, err := masterAmountDb.Db.Where("id=?", id).Update(data)
data.UpdateTime = time.Now()
get, err := masterAmountDb.Db.Where("id=?", id).AllCols().Update(data)
if get == 0 || err != nil { if get == 0 || err != nil {
fmt.Println(get)
fmt.Println(err)
return false return false
} }
return true return true


+ 18
- 1
app/task/svc/svc_playlet_order_settle.go View File

@@ -34,44 +34,61 @@ func PlayletOrderSettle() {
fmt.Println(utils.SerializeStr(order)) fmt.Println(utils.SerializeStr(order))


for _, v := range 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") withdrawAvailable, err := cache.Do("SET", mutexKey, 1, "EX", 1800, "NX")
if err != nil { if err != nil {
fmt.Println("=================0")

fmt.Println(err) fmt.Println(err)
continue continue
} }
if withdrawAvailable != "OK" { if withdrawAvailable != "OK" {
fmt.Println("=================1")

continue continue
} }
if v.SettleTime > 0 { if v.SettleTime > 0 {
fmt.Println("=================2")

continue continue
} }
//加到上月结算 //加到上月结算
if v.Uid == "" || v.Uid == "0" { if v.Uid == "" || v.Uid == "0" {
fmt.Println("=================3")

continue continue
} }
masterDb := db.MasterDb{} masterDb := db.MasterDb{}
masterDb.Set() masterDb.Set()
master := masterDb.GetMaster(v.Uid) master := masterDb.GetMaster(v.Uid)
if master == nil { if master == nil {
fmt.Println("=================4")

continue continue
} }
masterAmountDb := db.MasterAmountDb{} masterAmountDb := db.MasterAmountDb{}
masterAmountDb.Set() masterAmountDb.Set()
amount := masterAmountDb.GetMasterAmount(utils.IntToStr(master.Id), "playlet") amount := masterAmountDb.GetMasterAmount(utils.IntToStr(master.Id), "playlet")
if amount == nil { if amount == nil {
fmt.Println("=================5")

continue continue
} }
if utils.StrToFloat64(v.Commission) <= 0 { if utils.StrToFloat64(v.Commission) <= 0 {
v.SettleTime = int(time.Now().Unix()) v.SettleTime = int(time.Now().Unix())
playletSaleOrderDb.PlayletVideoOrderUpdate(v.Id, &v) playletSaleOrderDb.PlayletVideoOrderUpdate(v.Id, &v)
fmt.Println("=================6")

continue continue
} }
oldAmount := amount.LastMonthAmount oldAmount := amount.LastMonthAmount
amount.LastMonthAmount = utils.Float64ToStr(utils.StrToFloat64(amount.LastMonthAmount) + utils.StrToFloat64(v.Commission)) amount.LastMonthAmount = utils.Float64ToStr(utils.StrToFloat64(amount.LastMonthAmount) + utils.StrToFloat64(v.Commission))
update := masterAmountDb.MasterAmountUpdate(master.Id, amount) update := masterAmountDb.MasterAmountUpdate(master.Id, amount)
if update == false { if update == false {
fmt.Println("=================7")

continue continue
} }
var tmp = model.MasterLastMonthAmountFlow{ var tmp = model.MasterLastMonthAmountFlow{


Loading…
Cancel
Save