瀏覽代碼

更新

master
huangjiajun 2 月之前
父節點
當前提交
11d24bad47
共有 7 個文件被更改,包括 211 次插入33 次删除
  1. +6
    -0
      app/db/db_guide_order.go
  2. +33
    -31
      app/task/init.go
  3. +1
    -0
      app/task/md/cron_key.go
  4. +42
    -1
      app/task/svc/svc_tik_tok_chanxuan.go
  5. +107
    -0
      app/task/svc/svc_tik_tok_local_life_order_settle.go
  6. +21
    -0
      app/task/task_chan_xuan_order_settle.go
  7. +1
    -1
      go.mod

+ 6
- 0
app/db/db_guide_order.go 查看文件

@@ -52,6 +52,12 @@ func GetGuideOrderList(args map[string]string) []model.GuideOrder {
if args["to_settle_time"] != "" {
sess = sess.And("platform_settle_time<?", args["to_settle_time"])
}
if args["is_not_in"] != "" {
sess = sess.And("three_type!=?", args["is_not_in"])
}
if args["is_in"] != "" {
sess = sess.And("three_type=?", args["is_in"])
}
sort := "update_time desc,id desc"
if args["sort"] != "" {
sort = args["sort"]


+ 33
- 31
app/task/init.go 查看文件

@@ -83,7 +83,9 @@ func doTask(fnName string) func() {

// 增加自动任务队列
func initTasks() {
jobs[taskMd.ZhimengCronPLayletBihaiOrder] = taskPlayletBihaiOrder //
jobs[taskMd.ZhimengCronTikTokLocalLifeOrderSettle] = taskTikTokLocalLifeOrderSettle //c
jobs[taskMd.ZhimengCronChanxuanOrderSettle] = taskChanxuanOrderSettle //c
jobs[taskMd.ZhimengCronPLayletBihaiOrder] = taskPlayletBihaiOrder //

jobs[taskMd.ZhimengCronCinema5bmsOrder] = taskCinema5bmsOrder //
jobs[taskMd.ZhimengCronCinema5bmsYesterOrder] = taskCinema5bmsYesterOrder //
@@ -93,36 +95,36 @@ func initTasks() {
jobs[taskMd.ZhimengCronTikTokCsjpLive] = taskTikTokCsjpLive //
jobs[taskMd.ZhimengCronTikTokChanxuan] = taskTikTokCsjpChanxuan //

jobs[taskMd.ZhimengCronTikTokTask] = taskTikTokTask //
jobs[taskMd.ZhimengCronTikTokTaskRelate] = taskTikTokTaskRelate //
jobs[taskMd.ZhimengCronTikTokTaskMoney] = taskTikTokTaskMoney //
jobs[taskMd.ZhimengCronTikTokTaskMoneyByYestday] = taskTikTokTaskMoneyByYestday //
jobs[taskMd.ZhimengCronDianzhongKuaishouMoney] = taskDianzhongKuaishouMoney //
jobs[taskMd.ZhimengCronPlayletOrderSettle] = taskPlayletOrderSettle //
jobs[taskMd.ZhimengCronHwOrderSettle] = taskHwOrderSettle //
jobs[taskMd.ZhimengCronMasterMonthSettle] = taskMasterMonthSettle //
jobs[taskMd.ZhimengCronHwStarbucksOrder] = taskHwStarbucksOrder //
jobs[taskMd.ZhimengCronHwMovieOrder] = taskHwMovieOrder //
jobs[taskMd.ZhimengCronHwMcdonaldOrder] = taskHwMcdonaldOrder //
jobs[taskMd.ZhimengCronHwNayukiOrder] = taskHwNayukiOrder //
jobs[taskMd.ZhimengCronHwLuckinOrder] = taskHwLuckinOrder //
jobs[taskMd.ZhimengCronHwPizzaOrder] = taskHwPizzaOrder //
jobs[taskMd.ZhimengCronHwPagodaOrder] = taskHwPagodaOrder //
jobs[taskMd.ZhimengCronHwBurgerKingOrder] = taskHwBurgerKingOrder //
jobs[taskMd.ZhimengCronHwHeyteaOrder] = taskHwHeyteaOrder //
jobs[taskMd.ZhimengCronHwToKfcOrder] = taskHwToKfcOrder //
jobs[taskMd.ZhimengCronHwWallaceOrder] = taskHwWallaceOrder //
jobs[taskMd.ZhimengCronHwFlowerCakeOrder] = taskHwFlowerCakeOrder //
jobs[taskMd.ZhimengCronHwDeliveryOrder] = taskHwDeliveryOrder //
jobs[taskMd.ZhimengCronHwTourismOrder] = taskHwTourismOrder //
jobs[taskMd.ZhimengCronTikTokLocalLifeOrder] = taskTikTokLocalLifeOrder //
jobs[taskMd.ZhimengCronCsjpLocalLifeOrder] = taskCsjpLocalLifeOrder //
jobs[taskMd.ZhimengCronTikTokLocalLifeOrderSettle] = taskTikTokLocalLifeOrderSettle //
jobs[taskMd.ZhimengCronKuaishouOrder] = taskKuaishouOrder //
jobs[taskMd.ZhimengCronKuaishouAuth] = taskKuaishouAuth //
jobs[taskMd.ZhimengCronMeituanOrder] = taskMeituanOrder //
jobs[taskMd.ZhimengCronMeituanStoreOrder] = taskMeituanStoreOrder //
jobs[taskMd.ZhimengCronLifeOrderSettle] = taskLifeOrderSettle //
jobs[taskMd.ZhimengCronTikTokTask] = taskTikTokTask //
jobs[taskMd.ZhimengCronTikTokTaskRelate] = taskTikTokTaskRelate //
jobs[taskMd.ZhimengCronTikTokTaskMoney] = taskTikTokTaskMoney //
jobs[taskMd.ZhimengCronTikTokTaskMoneyByYestday] = taskTikTokTaskMoneyByYestday //
jobs[taskMd.ZhimengCronDianzhongKuaishouMoney] = taskDianzhongKuaishouMoney //
jobs[taskMd.ZhimengCronPlayletOrderSettle] = taskPlayletOrderSettle //
jobs[taskMd.ZhimengCronHwOrderSettle] = taskHwOrderSettle //
jobs[taskMd.ZhimengCronMasterMonthSettle] = taskMasterMonthSettle //
jobs[taskMd.ZhimengCronHwStarbucksOrder] = taskHwStarbucksOrder //
jobs[taskMd.ZhimengCronHwMovieOrder] = taskHwMovieOrder //
jobs[taskMd.ZhimengCronHwMcdonaldOrder] = taskHwMcdonaldOrder //
jobs[taskMd.ZhimengCronHwNayukiOrder] = taskHwNayukiOrder //
jobs[taskMd.ZhimengCronHwLuckinOrder] = taskHwLuckinOrder //
jobs[taskMd.ZhimengCronHwPizzaOrder] = taskHwPizzaOrder //
jobs[taskMd.ZhimengCronHwPagodaOrder] = taskHwPagodaOrder //
jobs[taskMd.ZhimengCronHwBurgerKingOrder] = taskHwBurgerKingOrder //
jobs[taskMd.ZhimengCronHwHeyteaOrder] = taskHwHeyteaOrder //
jobs[taskMd.ZhimengCronHwToKfcOrder] = taskHwToKfcOrder //
jobs[taskMd.ZhimengCronHwWallaceOrder] = taskHwWallaceOrder //
jobs[taskMd.ZhimengCronHwFlowerCakeOrder] = taskHwFlowerCakeOrder //
jobs[taskMd.ZhimengCronHwDeliveryOrder] = taskHwDeliveryOrder //
jobs[taskMd.ZhimengCronHwTourismOrder] = taskHwTourismOrder //
jobs[taskMd.ZhimengCronTikTokLocalLifeOrder] = taskTikTokLocalLifeOrder //
jobs[taskMd.ZhimengCronCsjpLocalLifeOrder] = taskCsjpLocalLifeOrder //
jobs[taskMd.ZhimengCronKuaishouOrder] = taskKuaishouOrder //
jobs[taskMd.ZhimengCronKuaishouAuth] = taskKuaishouAuth //
jobs[taskMd.ZhimengCronMeituanOrder] = taskMeituanOrder //
jobs[taskMd.ZhimengCronMeituanStoreOrder] = taskMeituanStoreOrder //
jobs[taskMd.ZhimengCronLifeOrderSettle] = taskLifeOrderSettle //

jobs[taskMd.ZhimengCronElmOrder] = taskElmOrder //
jobs[taskMd.ZhimengCronDidiOrder] = taskDidiOrder //


+ 1
- 0
app/task/md/cron_key.go 查看文件

@@ -50,6 +50,7 @@ const (
ZhimengCronTikTokLocalLifeOrder = "zhimeng_cron_tik_tok_local_life_order"
ZhimengCronCsjpLocalLifeOrder = "zhimeng_cron_csjp_local_life_order"
ZhimengCronTikTokLocalLifeOrderSettle = "zhimeng_cron_tik_tok_local_life_order_settle"
ZhimengCronChanxuanOrderSettle = "zhimeng_cron_chan_xuan_order_settle"
ZhimengCronLifeOrderSettle = "zhimeng_cron_life_order_settle"
ZhimengCronSuccessLifeOrderSettle = "zhimeng_cron_success_life_order_settle"
ZhimengCronPayLifeOrderSettle = "zhimeng_cron_pay_life_order_settle"


+ 42
- 1
app/task/svc/svc_tik_tok_chanxuan.go 查看文件

@@ -30,6 +30,7 @@ func TikTokChanxuan(ordType int) {
if len(strs) == 3 {
timeStr = strs[0] + ":" + strs[1] + ":00"
}
timeStr = "2024-10-22 20:29:07"
fmt.Println(timeStr)
past := utils.TimeParseStd(timeStr).Unix()
// 如果上次记录超过30天或者 过去时间大于当前时间戳, 把时间设置为此前20分钟
@@ -158,6 +159,9 @@ func OrdersTikTokChanxuanGet(page, pageSize int, sTime, eTime int64, userId stri
if v.RealCommission > 0 {
ord.RealCommission = utils.Float64ToStr(float64(v.RealCommission) / 100)
}
if utils.AnyToInt64(v.AfterSalesStatus) == 2 {
ord.Status = "结算后退款"
}
one := db.GetGuideOrderByOne(ord.PvdOid, utils.IntToStr(ord.Uid), ord.Pvd)
if one == nil {
insertOne, err := db.ZhimengDb.InsertOne(ord)
@@ -169,7 +173,44 @@ func OrdersTikTokChanxuanGet(page, pageSize int, sTime, eTime int64, userId stri
ord.PlatformSettleTime = one.PlatformSettleTime
}
if one.Status == "违规订单" {
one.Status = "违规订单"
ord.Status = "违规订单"
}
if one.Status == "结算后退款" {
ord.Status = "结算后退款"
}
if ord.SettleTime > 0 && ord.Status == "结算后退款" {
ord.SettleTime = 0
masterDb := db.MasterDb{}
masterDb.Set()
master := masterDb.GetMaster(utils.IntToStr(ord.Uid))
if master != nil {
masterAmountDb := db.MasterAmountDb{}
masterAmountDb.Set()
amount := masterAmountDb.GetMasterAmountByExtendUid(utils.IntToStr(master.Id), utils.IntToStr(ord.ExtendUid), "playlet")
if amount != nil {
oldAmount := amount.Amount
amount.Amount = utils.Float64ToStr(utils.StrToFloat64(amount.Amount) - utils.StrToFloat64(ord.RealCommission))
update := masterAmountDb.MasterAmountUpdate(amount.Id, amount)
if update {
var tmp = model.MasterAmountFlow{
Uid: utils.IntToStr(ord.Uid),
Time: time.Now(),
BeforeAmount: oldAmount,
Amount: ord.RealCommission,
AfterAmount: amount.Amount,
Platform: "playlet",
Oid: utils.Int64ToStr(ord.Oid),
Title: "订单退款扣除",
FlowType: "order_refund_deduct",
IncomeType: 0,
ExtendUid: utils.IntToStr(ord.ExtendUid),
}
masterAmountFlowDb := db.MasterAmountFlowDb{}
masterAmountFlowDb.Set()
masterAmountFlowDb.MasterAmountFlowInsert(&tmp)
}
}
}
}
db.ZhimengDb.Where("id=?", one.Id).AllCols().Update(ord)
}


+ 107
- 0
app/task/svc/svc_tik_tok_local_life_order_settle.go 查看文件

@@ -20,6 +20,113 @@ func TikTokLocalLifeOrderSettle() {
"status": "订单结算",
"sort": "id desc",
"is_to_settle": "1",
"is_not_in": "chan_xuan",
"is_commission": "1",
"to_settle_time": utils.Int64ToStr(month["start"]),
"p": "1",
"size": "100",
}
order := db.GetGuideOrderList(arg)
if len(order) == 0 {
return
}
fmt.Println(utils.SerializeStr(order))
platformMap := map[string]string{
"tikTok_life": "抖音本地生活",
"csjp": "穿山甲抖音",
"csjp_live": "穿山甲抖音直播商品",
"kuaishou": "快手",
"kuaishou_live": "快手直播商品",
"meituan": "美团",
"own_ele": "饿了么",
}
for _, v := range order {
fmt.Println("=================00")
// 加锁 防止并发提取
mutexKey := fmt.Sprintf("guide_order_settle3:%d", v.Id)
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 == 0 {
fmt.Println("=================3")

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

continue
}
masterAmountDb := db.MasterAmountDb{}
masterAmountDb.Set()
amount := masterAmountDb.GetMasterAmountByExtendUid(utils.IntToStr(master.Id), utils.IntToStr(v.ExtendUid), "playlet")
if amount == nil {
fmt.Println("=================5")
continue
}
if utils.StrToFloat64(v.RealCommission) <= 0 {
v.SettleTime = int(time.Now().Unix())
db.ZhimengDb.Where("id=?", v.Id).Update(&v)
continue
}
oldAmount := amount.LastMonthAmount
amount.LastMonthAmount = utils.Float64ToStr(utils.StrToFloat64(amount.LastMonthAmount) + utils.StrToFloat64(v.RealCommission))
update := masterAmountDb.MasterAmountUpdate(amount.Id, amount)
if update == false {
fmt.Println("=================7")

continue
}
var tmp = model.MasterLastMonthAmountFlow{
Uid: utils.IntToStr(master.Id),
Time: time.Now(),
BeforeAmount: oldAmount,
Amount: v.RealCommission,
AfterAmount: amount.LastMonthAmount,
Platform: v.Pvd,
Oid: utils.Int64ToStr(v.Oid),
Title: platformMap[v.Pvd] + "结算",
FlowType: v.Pvd + "_settle",
ExtendUid: utils.IntToStr(v.ExtendUid),
}
masterLastMonthAmountFlowDb := db.MasterLastMonthAmountFlowDb{}
masterLastMonthAmountFlowDb.Set()
masterLastMonthAmountFlowDb.MasterLastMonthAmountFlowInsert(&tmp)
v.SettleTime = int(time.Now().Unix())
db.ZhimengDb.Where("id=?", v.Id).Update(&v)
}
return
}
func ChanxuanOrderSettle() {
day := time.Now().Day()
if day < 28 {
return
}
month := utils.GetTimeRange("current_month")
fmt.Println(month)
arg := map[string]string{
"status": "订单结算",
"sort": "id desc",
"is_to_settle": "1",
"is_in": "chan_xuan",
"is_commission": "1",
"to_settle_time": utils.Int64ToStr(month["start"]),
"p": "1",


+ 21
- 0
app/task/task_chan_xuan_order_settle.go 查看文件

@@ -0,0 +1,21 @@
package task

import (
"applet/app/task/svc"
"math/rand"
"time"
)

func taskChanxuanOrderSettle() {
for {
if len(ch) > workerNum {
time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000)))
} else {
goto START
}
}
START:
ch <- 1
svc.ChanxuanOrderSettle()
<-ch
}

+ 1
- 1
go.mod 查看文件

@@ -4,7 +4,7 @@ go 1.15

require (
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20230707081910-52e70aa52998
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20241022083957-0babff5f367b
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20241023030432-34a00dfd6f1a
github.com/360EntSecGroup-Skylar/excelize v1.4.1
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/boombuler/barcode v1.0.1


Loading…
取消
儲存