From 235d841744c08e010d7e2c179a469f8c819bb93a Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 21 Mar 2025 09:41:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db/model/hc_card_cate.go | 13 ++ app/db/model/hc_card_list.go | 16 +++ app/db/model/hc_cardorder.go | 32 +++++ app/task/init.go | 3 + app/task/md/cron_key.go | 3 + app/task/svc/svc_hc_recharge_goods.go | 168 ++++++++++++++++++++++++ app/task/svc/svc_meituan_local_order.go | 91 +++++++++++++ app/task/task_hc_recharge_goods.go | 21 +++ app/task/task_hc_ticket_goods.go | 21 +++ app/task/task_meituan_local_order.go | 21 +++ go.mod | 2 +- 11 files changed, 390 insertions(+), 1 deletion(-) create mode 100644 app/db/model/hc_card_cate.go create mode 100644 app/db/model/hc_card_list.go create mode 100644 app/db/model/hc_cardorder.go create mode 100644 app/task/svc/svc_hc_recharge_goods.go create mode 100644 app/task/svc/svc_meituan_local_order.go create mode 100644 app/task/task_hc_recharge_goods.go create mode 100644 app/task/task_hc_ticket_goods.go create mode 100644 app/task/task_meituan_local_order.go diff --git a/app/db/model/hc_card_cate.go b/app/db/model/hc_card_cate.go new file mode 100644 index 0000000..2cf8268 --- /dev/null +++ b/app/db/model/hc_card_cate.go @@ -0,0 +1,13 @@ +package model + +type HcCardCate struct { + Id int `json:"id" xorm:"not null pk autoincr index INT(11)"` + AccountType string `json:"account_type" xorm:"default '' comment('账号类型') VARCHAR(100)"` + GId int `json:"g_id" xorm:"default 0 comment('商品id') index index(g_id_2) INT(11)"` + GoodsLogo string `json:"goods_logo" xorm:"VARCHAR(255)"` + GName string `json:"g_name" xorm:"index(g_id_2) index VARCHAR(255)"` + UpdateTime int `json:"update_time" xorm:"default 0 INT(11)"` + Type string `json:"type" xorm:"default '' comment('直充 卡券') index(g_id_2) index VARCHAR(255)"` + Xuzhi string `json:"xuzhi" xorm:"LONGTEXT"` + IsDelete int `json:"is_delete" xorm:"default 0 INT(11)"` +} diff --git a/app/db/model/hc_card_list.go b/app/db/model/hc_card_list.go new file mode 100644 index 0000000..a4fb47e --- /dev/null +++ b/app/db/model/hc_card_list.go @@ -0,0 +1,16 @@ +package model + +type HcCardList struct { + Id int `json:"id" xorm:"not null pk autoincr index INT(11)"` + GId int `json:"g_id" xorm:"default 0 index index(g_id_2) INT(11)"` + Title string `json:"title" xorm:"default '' VARCHAR(255)"` + OfficialPrice float64 `json:"official_price" xorm:"default 0.00 comment('官方价') DOUBLE(30,2)"` + PlatPrice float64 `json:"plat_price" xorm:"default 0.00 DOUBLE(30,2)"` + Times string `json:"times" xorm:"default '' VARCHAR(100)"` + SpecId int `json:"spec_id" xorm:"default 0 index(g_id_2) index INT(11)"` + SpecImg string `json:"spec_img" xorm:"default '' VARCHAR(255)"` + UpdateTime int `json:"update_time" xorm:"default 0 INT(11)"` + LId int `json:"l_id" xorm:"default 0 INT(11)"` + Type string `json:"type" xorm:"default '' VARCHAR(255)"` + IsDelete int `json:"is_delete" xorm:"default 0 INT(11)"` +} diff --git a/app/db/model/hc_cardorder.go b/app/db/model/hc_cardorder.go new file mode 100644 index 0000000..2f826c6 --- /dev/null +++ b/app/db/model/hc_cardorder.go @@ -0,0 +1,32 @@ +package model + +type HcCardorder struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Orderid string `json:"orderId" xorm:"default '' VARCHAR(255)"` + CreateTime int `json:"create_time" xorm:"default 0 INT(11)"` + Uid int `json:"uid" xorm:"default 0 comment('站长id') INT(11)"` + Zuid int `json:"zuid" xorm:"default 0 comment('站长平台的用户') INT(11)"` + Statut string `json:"statut" xorm:"default '' comment('状态') VARCHAR(100)"` + Account string `json:"account" xorm:"default '' comment('充值账号') VARCHAR(100)"` + BuyNum int `json:"buy_num" xorm:"default 0 comment('购买数量') INT(11)"` + GId int `json:"g_id" xorm:"default 0 comment('商品id') INT(11)"` + SpecId int `json:"spec_id" xorm:"default 0 comment('套餐id') INT(11)"` + Type string `json:"type" xorm:"default '' comment('类型') VARCHAR(100)"` + Payment float64 `json:"payment" xorm:"default 0.00 DOUBLE(11,2)"` + Msg string `json:"msg" xorm:"default '' VARCHAR(100)"` + PayTime int `json:"pay_time" xorm:"default 0 INT(11)"` + LId int `json:"l_id" xorm:"default 0 INT(11)"` + SysOrderid string `json:"sys_orderId" xorm:"default '' VARCHAR(255)"` + Status string `json:"status" xorm:"default '' VARCHAR(255)"` + IsToreturn int `json:"is_toreturn" xorm:"default 0 INT(11)"` + CardMsg string `json:"card_msg" xorm:"TEXT"` + IsFh int `json:"is_fh" xorm:"default 0 INT(11)"` + Oid string `json:"oid" xorm:"default '' VARCHAR(255)"` + RechargeStatus int `json:"recharge_status" xorm:"default 0 comment('0无 1充值中 2充值成功 3充值失败') INT(11)"` + NextUpdateTime int `json:"next_update_time" xorm:"default 0 INT(11)"` + UpdateTime int `json:"update_time" xorm:"default 0 INT(11)"` + CreateMsg string `json:"create_msg" xorm:"TEXT"` + ShowMsg string `json:"show_msg" xorm:"TEXT"` + Amount float64 `json:"amount" xorm:"default 0.00 DOUBLE(11,2)"` + Idcard string `json:"idcard" xorm:"default '' VARCHAR(255)"` +} diff --git a/app/task/init.go b/app/task/init.go index 18bd332..ab00ab0 100644 --- a/app/task/init.go +++ b/app/task/init.go @@ -128,6 +128,7 @@ func initTasks() { jobs[taskMd.ZhimengCronLifeOrderSettle] = taskLifeOrderSettle // jobs[taskMd.ZhimengCronElmOrder] = taskElmOrder // + jobs[taskMd.ZhimengCronMeituanLocalOrder] = taskMeituanLocalOrder // jobs[taskMd.ZhimengCronDidiOrder] = taskDidiOrder // jobs[taskMd.ZhimengCronT3Order] = taskT3Order // jobs[taskMd.ZhimengCronOilAddEs] = taskOilAddEs //加油站点加入es @@ -136,5 +137,7 @@ func initTasks() { jobs[taskMd.ZhimengCronHwRechargeOrder] = taskHwRechargeOrder //加油订单 jobs[taskMd.ZhimengCronMovieOrder] = taskMovieOrder //加油订单 jobs[taskMd.ZhimengCronKfcOrder] = taskKfcOrder //加油订单 + jobs[taskMd.ZhimengCronHcRechargeGoods] = taskHcRechargeGoods //加油订单 + jobs[taskMd.ZhimengCronHcTicketGoods] = taskHcTicketGoods //加油订单 } diff --git a/app/task/md/cron_key.go b/app/task/md/cron_key.go index be8cbfb..b37af2d 100644 --- a/app/task/md/cron_key.go +++ b/app/task/md/cron_key.go @@ -43,6 +43,7 @@ const ( ZhimengCronHwTourismOrder = "zhimeng_cron_hw_tourism_order" ZhimengCronKuaishouOrder = "zhimeng_cron_kuaishou_order" ZhimengCronMeituanOrder = "zhimeng_cron_meituan_order" + ZhimengCronMeituanLocalOrder = "zhimeng_cron_meituan_local_order" ZhimengCronMeituanStoreOrder = "zhimeng_cron_meituan_store_order" ZhimengCronElmOrder = "zhimeng_cron_elm_order" ZhimengCronT3Order = "zhimeng_cron_t3_order" @@ -60,4 +61,6 @@ const ( ZhimengCronMovieOrder = "zhimeng_cron_movie_order" ZhimengCronKfcOrder = "zhimeng_cron_kfc_order" ZhimengCronHwRechargeOrder = "zhimeng_cron_hw_recharge_order" + ZhimengCronHcRechargeGoods = "zhimeng_cron_hc_recharge_goods" + ZhimengCronHcTicketGoods = "zhimeng_cron_hc_ticket_goods" ) diff --git a/app/task/svc/svc_hc_recharge_goods.go b/app/task/svc/svc_hc_recharge_goods.go new file mode 100644 index 0000000..847c5f6 --- /dev/null +++ b/app/task/svc/svc_hc_recharge_goods.go @@ -0,0 +1,168 @@ +package svc + +import ( + "applet/app/db" + "applet/app/db/model" + "applet/app/utils" + "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/hc_card" + "time" +) + +func HcRechargeGoods() { + param := map[string]string{} + list := hc_card.HcRechargeList(param) + for _, v := range list { + if v.Xuzhi == "" { + param1 := map[string]string{ + "g_id": utils.IntToStr(v.GId), + } + detail := hc_card.HcRechargeDetail(param1) + v.Xuzhi = detail.Xuzhi + } + tmp := model.HcCardCate{ + AccountType: v.AccountType, + GId: v.GId, + GoodsLogo: v.GoodsLogo, + GName: v.GName, + UpdateTime: int(time.Now().Unix()), + Type: "直充", + Xuzhi: v.Xuzhi, + IsDelete: 0, + } + var data model.HcCardCate + db.ZhimengDb.Where("g_id=? and type=?", tmp.GId, tmp.Type).Get(&data) + id := 0 + if data.Id > 0 { + id = data.Id + data.UpdateTime = int(time.Now().Unix()) + data.Xuzhi = v.Xuzhi + data.GName = v.GName + data.GoodsLogo = v.GoodsLogo + data.GId = v.GId + data.AccountType = v.AccountType + data.IsDelete = 0 + db.ZhimengDb.Where("id=?", data.Id).Update(&data) + } else { + db.ZhimengDb.InsertOne(&tmp) + id = tmp.Id + } + ids := []int{-1} + for _, v1 := range v.Spec { + specTmp := model.HcCardList{ + GId: v.GId, + Title: v1.Title, + OfficialPrice: utils.StrToFloat64(v1.OfficialPrice), + PlatPrice: utils.StrToFloat64(v1.PlatPrice), + Times: v1.Times, + SpecId: v1.SpecId, + SpecImg: v1.SpecImg, + UpdateTime: int(time.Now().Unix()), + LId: id, + Type: "直充", + IsDelete: 0, + } + var specData model.HcCardList + db.ZhimengDb.Where("l_id=? and spec_id=?", id, v1.SpecId).Get(&specData) + if specData.Id > 0 { + specData.UpdateTime = int(time.Now().Unix()) + specData.GId = v.GId + specData.Title = v1.Title + specData.OfficialPrice = utils.StrToFloat64(v1.OfficialPrice) + specData.PlatPrice = utils.StrToFloat64(v1.PlatPrice) + specData.Times = v1.Times + specData.SpecId = v1.SpecId + specData.SpecImg = v1.SpecImg + specData.IsDelete = 0 + db.ZhimengDb.Where("id=?", data.Id).Update(&specData) + } else { + db.ZhimengDb.InsertOne(&specTmp) + } + ids = append(ids, v1.SpecId) + + } + if len(ids) > 0 { + db.ZhimengDb.NotIn("spec_id", ids).And("l_id=?", id).Cols("is_delete").Update(&model.HcCardList{IsDelete: 1}) + } + } + if len(list) > 0 { + db.ZhimengDb.Where("type=? and update_time 0 { + id = data.Id + data.UpdateTime = int(time.Now().Unix()) + data.Xuzhi = v.Xuzhi + data.GName = v.GName + data.GoodsLogo = v.GoodsLogo + data.GId = v.GId + data.IsDelete = 0 + db.ZhimengDb.Where("id=?", data.Id).Update(&data) + } else { + db.ZhimengDb.InsertOne(&tmp) + id = tmp.Id + } + ids := []int{-1} + for _, v1 := range v.Spec { + specTmp := model.HcCardList{ + GId: v.GId, + Title: v1.Title, + OfficialPrice: utils.StrToFloat64(v1.OfficialPrice), + PlatPrice: utils.StrToFloat64(v1.PlatPrice), + SpecId: v1.SpecId, + SpecImg: v1.SpecImg, + UpdateTime: int(time.Now().Unix()), + LId: id, + Type: "卡券", + IsDelete: 0, + } + var specData model.HcCardList + db.ZhimengDb.Where("l_id=? and spec_id=?", id, v1.SpecId).Get(&specData) + if specData.Id > 0 { + specData.UpdateTime = int(time.Now().Unix()) + specData.GId = v.GId + specData.Title = v1.Title + specData.OfficialPrice = utils.StrToFloat64(v1.OfficialPrice) + specData.PlatPrice = utils.StrToFloat64(v1.PlatPrice) + specData.SpecId = v1.SpecId + specData.SpecImg = v1.SpecImg + specData.IsDelete = 0 + db.ZhimengDb.Where("id=?", data.Id).Update(&specData) + } else { + db.ZhimengDb.InsertOne(&specTmp) + } + ids = append(ids, v1.SpecId) + + } + if len(ids) > 0 { + db.ZhimengDb.NotIn("spec_id", ids).And("l_id=?", id).Cols("is_delete").Update(&model.HcCardList{IsDelete: 1}) + } + } + if len(list) > 0 { + db.ZhimengDb.Where("type=? and update_time 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 + } + + for { + count := 0 + var positionIndex = "" + if pageNo == 1 { + nextPositionIndex = "" + } + count, positionIndex = OrdersMeituanGet(nextPositionIndex, pageSize, beginTime, endTime, "update", 2) + 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 + } +} diff --git a/app/task/task_hc_recharge_goods.go b/app/task/task_hc_recharge_goods.go new file mode 100644 index 0000000..44b0b58 --- /dev/null +++ b/app/task/task_hc_recharge_goods.go @@ -0,0 +1,21 @@ +package task + +import ( + "applet/app/task/svc" + "math/rand" + "time" +) + +func taskHcRechargeGoods() { + for { + if len(ch) > workerNum { + time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) + } else { + goto START + } + } +START: + ch <- 1 + svc.HcRechargeGoods() + <-ch +} diff --git a/app/task/task_hc_ticket_goods.go b/app/task/task_hc_ticket_goods.go new file mode 100644 index 0000000..f3652e8 --- /dev/null +++ b/app/task/task_hc_ticket_goods.go @@ -0,0 +1,21 @@ +package task + +import ( + "applet/app/task/svc" + "math/rand" + "time" +) + +func taskHcTicketGoods() { + for { + if len(ch) > workerNum { + time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) + } else { + goto START + } + } +START: + ch <- 1 + svc.HcTicketGoods() + <-ch +} diff --git a/app/task/task_meituan_local_order.go b/app/task/task_meituan_local_order.go new file mode 100644 index 0000000..f46f86a --- /dev/null +++ b/app/task/task_meituan_local_order.go @@ -0,0 +1,21 @@ +package task + +import ( + "applet/app/task/svc" + "math/rand" + "time" +) + +func taskMeituanLocalOrder() { + for { + if len(ch) > workerNum { + time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) + } else { + goto START + } + } +START: + ch <- 1 + svc.MeituanLocalOrder() + <-ch +} diff --git a/go.mod b/go.mod index dd41561..1b83070 100644 --- a/go.mod +++ b/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.20250311032855-92b94363b2d1 + code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20250313085525-11c4483541e5 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