소스 검색

更新

master
huangjiajun 3 달 전
부모
커밋
e122aaee75
11개의 변경된 파일418개의 추가작업 그리고 13개의 파일을 삭제
  1. +10
    -0
      app/db/db_guide_order.go
  2. +1
    -0
      app/md/settle_pvd.go
  3. +12
    -8
      app/svc/platform/svc_guide_order_list.go
  4. +6
    -4
      app/svc/platform/svc_life_order_list.go
  5. +3
    -0
      app/task/init.go
  6. +2
    -0
      app/task/md/cron_key.go
  7. +212
    -0
      app/task/svc/svc_wph_order.go
  8. +129
    -0
      app/task/svc/svc_wph_refund_order.go
  9. +21
    -0
      app/task/task_wph_order.go
  10. +21
    -0
      app/task/task_wph_refund_order.go
  11. +1
    -1
      go.mod

+ 10
- 0
app/db/db_guide_order.go 파일 보기

@@ -15,6 +15,16 @@ func GetGuideOrderByOne(oid, mid, types string) *model.GuideOrder {
}
return &data
}

func GetGuideOrderByOid(oid, types string) *model.GuideOrder {
var data model.GuideOrder
get, err := ZhimengDb.Where(" pvd_oid=? and pvd=?", oid, types).Get(&data)
if get == false || err != nil {
fmt.Println(err)
return nil
}
return &data
}
func GetGuideOrderList(args map[string]string) []model.GuideOrder {
/***
p 页数


+ 1
- 0
app/md/settle_pvd.go 파일 보기

@@ -5,6 +5,7 @@ var SettlePvd = map[string]string{
"csjp": "穿山甲抖音",
"csjp_live": "穿山甲抖音直播商品",
"kuaishou": "快手",
"vip": "唯品会",
"kuaishou_live": "快手直播商品",
"meituan": "美团",
"own_ele": "饿了么",


+ 12
- 8
app/svc/platform/svc_guide_order_list.go 파일 보기

@@ -13,10 +13,12 @@ func GuideOrderList(c *gin.Context, args map[string]string) ([]map[string]string
list, total := db.GetGuideOrderListTotal(args)
var data = make([]map[string]string, 0)
platformMap := map[string]string{
"tikTok_life": "抖音本地生活",
"csjp": "穿山甲抖音",
"csjp_live": "穿山甲抖音直播商品",
"kuaishou": "快手",
"tikTok_life": "抖音本地生活",
"csjp": "穿山甲抖音",
"csjp_live": "穿山甲抖音直播商品",
"kuaishou": "快手",
"vip": "唯品会",

"kuaishou_live": "快手直播商品",
"meituan": "美团",
"own_ele": "饿了么",
@@ -76,10 +78,12 @@ func GuideOrderOutput(c *gin.Context, args map[string]string) (string, map[strin
"I1": "实际佣金",
}
platformMap := map[string]string{
"tikTok_life": "抖音本地生活",
"csjp": "穿山甲抖音",
"csjp_live": "穿山甲抖音直播商品",
"kuaishou": "快手",
"tikTok_life": "抖音本地生活",
"csjp": "穿山甲抖音",
"csjp_live": "穿山甲抖音直播商品",
"kuaishou": "快手",
"vip": "唯品会",

"kuaishou_live": "快手直播商品",
"meituan": "美团",
"own_ele": "饿了么",


+ 6
- 4
app/svc/platform/svc_life_order_list.go 파일 보기

@@ -69,10 +69,12 @@ func LifeOrderOutput(c *gin.Context, args map[string]string) (string, map[string
"I1": "实际佣金",
}
platformMap := map[string]string{
"tikTok_life": "抖音本地生活",
"csjp": "穿山甲抖音",
"csjp_live": "穿山甲抖音直播商品",
"kuaishou": "快手",
"tikTok_life": "抖音本地生活",
"csjp": "穿山甲抖音",
"csjp_live": "穿山甲抖音直播商品",
"kuaishou": "快手",
"vip": "唯品会",

"kuaishou_live": "快手直播商品",
"meituan": "美团",
"own_ele": "饿了么",


+ 3
- 0
app/task/init.go 파일 보기

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

// 增加自动任务队列
func initTasks() {
jobs[taskMd.ZhimengCronWphOrder] = taskWphOrder //
jobs[taskMd.ZhimengCronWphRefundOrder] = taskWphRefundOrder //

jobs[taskMd.ZhimengCronTikTokLocalLifeOrderSettle] = taskTikTokLocalLifeOrderSettle //c
jobs[taskMd.ZhimengCronChanxuanOrderSettle] = taskChanxuanOrderSettle //c
jobs[taskMd.ZhimengCronPLayletBihaiOrder] = taskPlayletBihaiOrder //


+ 2
- 0
app/task/md/cron_key.go 파일 보기

@@ -42,6 +42,8 @@ const (
ZhimengCronHwDeliveryOrder = "zhimeng_cron_hw_delivery_order"
ZhimengCronHwTourismOrder = "zhimeng_cron_hw_tourism_order"
ZhimengCronKuaishouOrder = "zhimeng_cron_kuaishou_order"
ZhimengCronWphOrder = "zhimeng_cron_wph_order"
ZhimengCronWphRefundOrder = "zhimeng_cron_wph_refund_order"
ZhimengCronMeituanOrder = "zhimeng_cron_meituan_order"
ZhimengCronMeituanLocalOrder = "zhimeng_cron_meituan_local_order"
ZhimengCronMeituanStoreOrder = "zhimeng_cron_meituan_store_order"


+ 212
- 0
app/task/svc/svc_wph_order.go 파일 보기

@@ -0,0 +1,212 @@
package svc

import (
"applet/app/db"
"applet/app/db/model"
offical "applet/app/db/official"
"applet/app/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/thirdParty/wph"
"fmt"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"strings"
"time"
)

func WphComm() map[string]string {
wphData := offical.SysCfgByKeyStr("wph_data")
serviceParam := map[string]string{
"token": "",
"uuid": "353543142",
"key": "8f8c427e",
"secret": "DB9C5A92480618101A15835DD9E8AF69",
"pid": "",
}
serviceParam["token"] = gjson.Get(wphData, "token").String()
serviceParam["pid"] = gjson.Get(wphData, "pid").String()
return serviceParam
}
func WphOrder() {
pvdTimeKey := "wph_time"

// 获得最后时间
latest := offical.SysCfgByKey(pvdTimeKey)
if latest == nil {
offical.DbsSysCfgInserts(pvdTimeKey, time.Now().String())
latest = offical.SysCfgByKey(pvdTimeKey)
}
// 所有时间都是在操作秒数
now := time.Now().Unix()
strs := strings.Split(latest.V, ":")
timeStr := latest.V
if len(strs) == 3 {
timeStr = strs[0] + ":" + strs[1] + ":00"
}
fmt.Println(timeStr)
past := utils.TimeParseStd(timeStr).Unix()
// 如果上次记录超过30天或者 过去时间大于当前时间戳, 把时间设置为此前20分钟
if past < now-180*86400 || past > now {
past = now
}
var (
beginTime int64 = 0
endTime int64 = 0
pageNo int = 1
pageSize int = 50
nextPositionIndex string = ""
)

//怕时间不是走最新的
leave := now - past
if leave > 500 {
leave = 0
}
past = past + leave
beginTime = past - 300
endTime = past

if endTime > now {
endTime = now
}
wphData := WphComm()
for {
count := 0
var positionIndex = ""
if pageNo == 1 {
nextPositionIndex = "0"
}
if nextPositionIndex != "" {
positionIndex, count, _ = OrdersWphGet(pageNo, pageSize, beginTime, endTime, "update", 1, nextPositionIndex, wphData)
}
if count == 0 {
nextPositionIndex = ""
goto ChkArg
}
// 判断是否分页已经全部取完了
if count <= pageSize {
nextPositionIndex = positionIndex
pageNo++
fmt.Println("========下一页========" + utils.IntToStr(pageNo))
count = 0
continue
}
ChkArg:
nextPositionIndex = ""

// 查询完后重置时间, 最后查询时间
if endTime < now {
pageNo = 1
offical.DbsSysCfgUpdate(pvdTimeKey, utils.TimeToStr(endTime))
beginTime = endTime
endTime = endTime + 300
if endTime > now {
endTime = now
}
count = 0
continue
}
count = 0
break
}
}
func OrdersWphGet(p int, pageSize int, sTime, eTime int64, timeType string, pvd int, nextPositionIndex string, wphData map[string]string) (string, int, string) {

queryModel := map[string]string{
"pageSize": utils.IntToStr(pageSize),
"page": utils.IntToStr(p),
"updateTimeStart": utils.Int64ToStr(sTime * 1000),
"updateTimeEnd": utils.Int64ToStr(eTime * 1000),
"requestId": wphData["uuid"] + utils.Int64ToStr(time.Now().Unix()) + utils.IntToStr(php2go.Rand(1000, 9999)),
}
paramData := map[string]interface{}{
"queryModel": queryModel,
}
param := utils.SerializeStr(paramData)

order := wph.GetOrder(wphData, param)
if order == nil {
return "", 0, ""
}
orderCount := len(order)
var kuaishouState = map[string]string{
"已下单": "创建订单",
"已付款": "订单付款",
"已签收": "订单完成",
"待结算": "订单完成",
"已结算": "订单结算",
"已失效": "订单失效",
}
for _, v := range order {
//if v["status"] == "已下单" {
// continue
//}
if v["channelTag"] != wphData["pid"] {
continue
}
userId := v["open_id"]
ex := strings.Split(userId, "_")
if strings.Contains(utils.AnyToString(userId), "off") == false {
continue
}
buyType := ex[1]
if v["statParam"] != "" {
buyType = v["statParam"]
}
if buyType == "" {
buyType = "self"
}
var orderType int

if buyType == "share" {
orderType = 1
}
if buyType == "cloud" {
orderType = 10
}
if buyType == "free" {
orderType = 2
}
taskType := ""
if utils.InArr(buyType, []string{"happy_orchard"}) {
orderType = 1
taskType = buyType
}
var resNew = model.GuideOrder{
PvdParentOid: v["oid"],
Pvd: "vip",
Status: kuaishouState[v["status"]],
CreateTime: utils.StrToInt(v["create_time"]),
}
resNew.TaskType = taskType
resNew.IsShare = orderType
resNew.Oid = utils.StrToInt64(utils.OrderUUID(utils.StrToInt(ex[1])))
resNew.PvdOid = v["oid"]
resNew.Uid = utils.StrToInt(ex[2])
resNew.StationUid = utils.StrToInt(ex[1])
resNew.UpdateTime = int(time.Now().Unix())
resNew.Commission = v["commission"]
resNew.RealCommission = v["commission"]
resNew.Title = v["title"]
resNew.Img = v["img"]
resNew.Gid = v["gid"]
resNew.IsShare = orderType
resNew.Payment = v["payment"]
if utils.StrToInt64(v["js_time"]) > 0 {
resNew.PlatformSettleTime = utils.StrToInt(v["js_time"])
}
one := db.GetGuideOrderByOne(resNew.PvdOid, utils.IntToStr(resNew.Uid), resNew.Pvd)
if one == nil {
insertOne, err := db.ZhimengDb.InsertOne(&resNew)
fmt.Println(insertOne)
fmt.Println(err)
} else {
resNew.SettleTime = one.SettleTime
if one.PlatformSettleTime > 0 {
resNew.PlatformSettleTime = one.PlatformSettleTime
}
db.ZhimengDb.Where("id=?", one.Id).AllCols().Update(&resNew)
}
}
return "", orderCount, ""

}

+ 129
- 0
app/task/svc/svc_wph_refund_order.go 파일 보기

@@ -0,0 +1,129 @@
package svc

import (
"applet/app/db"
offical "applet/app/db/official"
"applet/app/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/thirdParty/wph"
"fmt"
"github.com/syyongx/php2go"
"strings"
"time"
)

func WphRefundOrder() {
pvdTimeKey := "wph_refund_time"

// 获得最后时间
latest := offical.SysCfgByKey(pvdTimeKey)
if latest == nil {
offical.DbsSysCfgInserts(pvdTimeKey, time.Now().String())
latest = offical.SysCfgByKey(pvdTimeKey)
}
// 所有时间都是在操作秒数
now := time.Now().Unix()
strs := strings.Split(latest.V, ":")
timeStr := latest.V
if len(strs) == 3 {
timeStr = strs[0] + ":" + strs[1] + ":00"
}
fmt.Println(timeStr)
past := utils.TimeParseStd(timeStr).Unix()
// 如果上次记录超过30天或者 过去时间大于当前时间戳, 把时间设置为此前20分钟
if past < now-180*86400 || past > now {
past = now
}
var (
beginTime int64 = 0
endTime int64 = 0
pageNo int = 1
pageSize int = 50
nextPositionIndex string = ""
)

//怕时间不是走最新的
leave := now - past
if leave > 500 {
leave = 0
}
past = past + leave
beginTime = past - 300
endTime = past

if endTime > now {
endTime = now
}
wphData := WphComm()
for {
count := 0
var positionIndex = ""
if pageNo == 1 {
nextPositionIndex = "0"
}
if nextPositionIndex != "" {
positionIndex, count, _ = OrdersWphRefundGet(pageNo, pageSize, beginTime, endTime, "update", 1, nextPositionIndex, wphData)
}
if count == 0 {
nextPositionIndex = ""
goto ChkArg
}
// 判断是否分页已经全部取完了
if count <= pageSize {
nextPositionIndex = positionIndex
pageNo++
fmt.Println("========下一页========" + utils.IntToStr(pageNo))
count = 0
continue
}
ChkArg:
nextPositionIndex = ""

// 查询完后重置时间, 最后查询时间
if endTime < now {
pageNo = 1
offical.DbsSysCfgUpdate(pvdTimeKey, utils.TimeToStr(endTime))
beginTime = endTime
endTime = endTime + 300
if endTime > now {
endTime = now
}
count = 0
continue
}
count = 0
break
}
}
func OrdersWphRefundGet(p int, pageSize int, sTime, eTime int64, timeType string, pvd int, nextPositionIndex string, wphData map[string]string) (string, int, string) {

queryModel := map[string]string{
"pageSize": utils.IntToStr(pageSize),
"page": utils.IntToStr(p),
"searchType": "1",
"searchTimeStart": utils.Int64ToStr(sTime * 1000),
"searchTimeEnd": utils.Int64ToStr(eTime * 1000),
"requestId": wphData["uuid"] + utils.Int64ToStr(time.Now().Unix()) + utils.IntToStr(php2go.Rand(1000, 9999)),
}
paramData := map[string]interface{}{
"request": queryModel,
}
param := utils.SerializeStr(paramData)

order := wph.GetRefundOrder(wphData, param)
if order == nil {
return "", 0, ""
}
orderCount := len(order)
for _, v := range order {
one := db.GetGuideOrderByOid(v["oid"], "vip")
if one != nil {
if v["state"] == "-1" {
one.Status = "订单失效"
} else if v["commission"] != "" {
one.Commission = v["commission"]
}
db.ZhimengDb.Where("id=?", one.Id).AllCols().Update(one)
}
}
return "", orderCount, ""
}

+ 21
- 0
app/task/task_wph_order.go 파일 보기

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

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

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

+ 21
- 0
app/task/task_wph_refund_order.go 파일 보기

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

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

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

+ 1
- 1
go.mod 파일 보기

@@ -4,7 +4,7 @@ go 1.19

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.20250313085525-11c4483541e5
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20250326054223-876fcaf55033
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


불러오는 중...
취소
저장