From a9cad070fd73fff76c4f2fc331789a25e49043af Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 11 Mar 2025 15:14:33 +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/hdl/zhimeng_platform/hdl_hw_order_list.go | 2 +- app/md/settle_pvd.go | 2 + app/svc/platform/svc_hw_order_list.go | 4 +- app/task/init.go | 10 +- app/task/md/cron_key.go | 3 + app/task/md/oil.go | 29 +++ app/task/md/xiaoju.go | 128 +++++++++++++ app/task/svc/svc_hw_order_settle.go | 2 +- app/task/svc/svc_hw_recharge_order.go | 68 +++++++ app/task/svc/svc_life_order_settle.go | 8 +- app/task/svc/svc_oil_add_es.go | 77 ++++++++ app/task/svc/svc_oil_order.go | 168 ++++++++++++++++++ app/task/svc/svc_xiaoju.go | 38 ++++ app/task/task_hw_recharge_order.go | 21 +++ app/task/task_oil_add_es.go | 21 +++ app/task/task_oil_order.go | 21 +++ app/task/task_pay_life_order_settle.go | 2 +- go.mod | 9 +- 18 files changed, 596 insertions(+), 17 deletions(-) create mode 100644 app/task/md/oil.go create mode 100644 app/task/md/xiaoju.go create mode 100644 app/task/svc/svc_hw_recharge_order.go create mode 100644 app/task/svc/svc_oil_add_es.go create mode 100644 app/task/svc/svc_oil_order.go create mode 100644 app/task/svc/svc_xiaoju.go create mode 100644 app/task/task_hw_recharge_order.go create mode 100644 app/task/task_oil_add_es.go create mode 100644 app/task/task_oil_order.go diff --git a/app/hdl/zhimeng_platform/hdl_hw_order_list.go b/app/hdl/zhimeng_platform/hdl_hw_order_list.go index 7ac46d0..0f2f183 100644 --- a/app/hdl/zhimeng_platform/hdl_hw_order_list.go +++ b/app/hdl/zhimeng_platform/hdl_hw_order_list.go @@ -14,7 +14,7 @@ func HwOrderList(c *gin.Context) { return } platformMap := map[string]string{ - "starbucks": "星巴克", "movie": "电影", "mcdonald": "麦当劳", "nayuki": "奈雪", "luckin": "瑞幸咖啡", "pizza": "必胜客", + "recharge": "视频会员直充", "starbucks": "星巴克", "movie": "电影", "mcdonald": "麦当劳", "nayuki": "奈雪", "luckin": "瑞幸咖啡", "pizza": "必胜客", "pagoda": "百果园", "burger_king": "汉堡王", "heytea": "喜茶", "to_kfc": "肯德基", "wallace": "华莱士", "flowerCake": "鲜花", "delivery": "比价寄", "tourism": "出游", } diff --git a/app/md/settle_pvd.go b/app/md/settle_pvd.go index eba107a..7a5db71 100644 --- a/app/md/settle_pvd.go +++ b/app/md/settle_pvd.go @@ -14,6 +14,7 @@ var SettlePvd = map[string]string{ "own_didi_chauffeur": "滴滴代驾", "own_oilstation": "加油", "own_king_flower": "花小猪打车", + "xiaoju": "加油", } var LifeSettlePvd = map[string]string{ "meituan": "美团", @@ -22,6 +23,7 @@ var LifeSettlePvd = map[string]string{ "own_didi_online_car": "滴滴打车", "own_didi_freight": "滴滴货运", "own_didi_chauffeur": "滴滴代驾", + "xiaoju": "加油", "own_oilstation": "加油", "own_king_flower": "花小猪打车", } diff --git a/app/svc/platform/svc_hw_order_list.go b/app/svc/platform/svc_hw_order_list.go index 9fe0eba..2605b04 100644 --- a/app/svc/platform/svc_hw_order_list.go +++ b/app/svc/platform/svc_hw_order_list.go @@ -13,7 +13,7 @@ func HwOrderList(c *gin.Context, args map[string]string) ([]map[string]string, i list, total := db.GetHwOrderListTotal(args) var data = make([]map[string]string, 0) platformMap := map[string]string{ - "starbucks": "星巴克", "movie": "电影", "mcdonald": "麦当劳", "nayuki": "奈雪", "luckin": "瑞幸咖啡", "pizza": "必胜客", + "recharge": "视频会员直充", "starbucks": "星巴克", "movie": "电影", "mcdonald": "麦当劳", "nayuki": "奈雪", "luckin": "瑞幸咖啡", "pizza": "必胜客", "pagoda": "百果园", "burger_king": "汉堡王", "heytea": "喜茶", "to_kfc": "肯德基", "wallace": "华莱士", "flowerCake": "鲜花", "delivery": "比价寄", "tourism": "出游", } if len(list) > 0 { @@ -66,7 +66,7 @@ func HwOrderOutput(c *gin.Context, args map[string]string) (string, map[string]s "H1": "佣金", } platformMap := map[string]string{ - "starbucks": "星巴克", "movie": "电影", "mcdonald": "麦当劳", "nayuki": "奈雪", "luckin": "瑞幸咖啡", "pizza": "必胜客", + "recharge": "视频会员直充", "starbucks": "星巴克", "movie": "电影", "mcdonald": "麦当劳", "nayuki": "奈雪", "luckin": "瑞幸咖啡", "pizza": "必胜客", "pagoda": "百果园", "burger_king": "汉堡王", "heytea": "喜茶", "to_kfc": "肯德基", "wallace": "华莱士", "flowerCake": "鲜花", "delivery": "比价寄", "tourism": "出游", } diff --git a/app/task/init.go b/app/task/init.go index e5ed70b..b3c9322 100644 --- a/app/task/init.go +++ b/app/task/init.go @@ -127,8 +127,12 @@ func initTasks() { jobs[taskMd.ZhimengCronMeituanStoreOrder] = taskMeituanStoreOrder // jobs[taskMd.ZhimengCronLifeOrderSettle] = taskLifeOrderSettle // - jobs[taskMd.ZhimengCronElmOrder] = taskElmOrder // - jobs[taskMd.ZhimengCronDidiOrder] = taskDidiOrder // - jobs[taskMd.ZhimengCronT3Order] = taskT3Order // + jobs[taskMd.ZhimengCronElmOrder] = taskElmOrder // + jobs[taskMd.ZhimengCronDidiOrder] = taskDidiOrder // + jobs[taskMd.ZhimengCronT3Order] = taskT3Order // + jobs[taskMd.ZhimengCronOilAddEs] = taskOilAddEs //加油站点加入es + jobs[taskMd.ZhimengCronOilOrder] = taskOilOrder //加油订单 + jobs[taskMd.ZhimengCronPayLifeOrderSettle] = taskPayLifeOrderSettle // + jobs[taskMd.ZhimengCronHwRechargeOrder] = taskHwRechargeOrder //加油订单 } diff --git a/app/task/md/cron_key.go b/app/task/md/cron_key.go index 4b79632..f0e46e1 100644 --- a/app/task/md/cron_key.go +++ b/app/task/md/cron_key.go @@ -55,4 +55,7 @@ const ( ZhimengCronLifeOrderSettle = "zhimeng_cron_life_order_settle" ZhimengCronSuccessLifeOrderSettle = "zhimeng_cron_success_life_order_settle" ZhimengCronPayLifeOrderSettle = "zhimeng_cron_pay_life_order_settle" + ZhimengCronOilAddEs = "zhimeng_cron_oil_add_es" + ZhimengCronOilOrder = "zhimeng_cron_oil_order" + ZhimengCronHwRechargeOrder = "zhimeng_cron_hw_recharge_order" ) diff --git a/app/task/md/oil.go b/app/task/md/oil.go new file mode 100644 index 0000000..6d6f835 --- /dev/null +++ b/app/task/md/oil.go @@ -0,0 +1,29 @@ +package md + +type OilData struct { + OutUserId string `json:"outUserId"` + Cellphone string `json:"cellphone"` + OrderId string `json:"orderId"` + CityId string `json:"cityId"` + DdCityId string `json:"ddCityId"` + CityName string `json:"cityName"` + StoreId string `json:"storeId"` + StoreName string `json:"storeName"` + ItemName string `json:"itemName"` + GunNo string `json:"gunNo"` + Quantity float64 `json:"quantity"` + TotalMoney int `json:"totalMoney"` + RealMoney int `json:"realMoney"` + ServiceFee int `json:"serviceFee"` + PayStatus int `json:"payStatus"` + PayTime string `json:"payTime"` + RefundStatus int `json:"refundStatus"` + OrderStatus int `json:"orderStatus"` + OrderSourceStatus int `json:"orderSourceStatus"` + OrderTime string `json:"orderTime"` + PayType int `json:"payType"` + SourcePayType int `json:"sourcePayType"` + UnitPrice int `json:"unitPrice"` + OrderPayInfo string `json:"orderPayInfo"` + BillingType int `json:"billingType"` +} diff --git a/app/task/md/xiaoju.go b/app/task/md/xiaoju.go new file mode 100644 index 0000000..6a24bdd --- /dev/null +++ b/app/task/md/xiaoju.go @@ -0,0 +1,128 @@ +package md + +type XiaojuGoods struct { + StoreId string `json:"storeId"` + StoreName string `json:"storeName"` + StoreLogo string `json:"storeLogo"` + CityName string `json:"cityName"` + ProvinceName string `json:"provinceName"` + Address string `json:"address"` + Lon float64 `json:"lon"` + Lat float64 `json:"lat"` + BrandName string `json:"brandName"` + ItemInfoList []struct { + ItemName string `json:"itemName"` + CityPrice int `json:"cityPrice"` + StorePrice int `json:"storePrice"` + } `json:"itemInfoList"` + HuiLabels []string `json:"huiLabels"` +} +type OilStationVipPrice struct { + StoreId string `json:"storeId"` + ItemName string `json:"itemName"` + StorePrice int `json:"storePrice"` + VipPrice int `json:"vipPrice"` + CityPrice int `json:"cityPrice"` +} +type ScreenType struct { + Name string `json:"name"` + Type string `json:"type"` +} +type OilReq struct { + Page string `json:"page" example:"页码"` + ItemName string `json:"item_name" example:"油品 92#"` + BrandName string `json:"brand_name" example:"品牌"` + Sort string `json:"sort" example:"排序"` + Lat string `json:"lat" example:"纬度"` + Lng string `json:"lng" example:"经度"` + Keyword string `json:"keyword"` +} +type OilUrlReq struct { + IndexId string `json:"index_id" ` + Lat string `json:"lat" example:"纬度"` + Lng string `json:"lng" example:"经度"` +} +type XiaojuGoodsEs struct { + StoreId string `json:"storeId"` + StoreName string `json:"storeName"` + StoreLogo string `json:"storeLogo"` + CityName string `json:"cityName"` + ProvinceName string `json:"provinceName"` + Address string `json:"address"` + Lon float64 `json:"lon"` + Lat float64 `json:"lat"` + BrandName string `json:"brandName"` + ItemName string `json:"itemName"` + CityPrice float64 `json:"cityPrice"` + StorePrice float64 `json:"storePrice"` + HuiLabels string `json:"huiLabels"` + IndexId string `json:"index_id"` + Location struct { + Lat float64 `json:"lat"` + Lon float64 `json:"lon"` + } `json:"location"` +} + +const EggOilStation = "zhiying_oil_station" +const EggOilStationMap = ` +{ + "settings" : { + "number_of_shards" : 2, + "number_of_replicas" : 1 + }, + "mappings":{ + "properties":{ + "lat":{ + "type": "double" + }, + "lon":{ + "type": "double" + }, + "platform":{ + "type": "keyword" + }, + "storeId":{ + "type": "keyword" + }, + "storeName":{ + "type": "keyword" + }, + "storeLogo":{ + "type": "keyword" + }, + "address":{ + "type": "keyword" + }, + "brandName":{ + "type": "keyword" + }, + "huiLabels":{ + "type": "keyword" + }, + "provinceName":{ + "type": "keyword" + }, + "cityName":{ + "type": "keyword" + }, + "itemName":{ + "type": "keyword" + }, + "cityPrice":{ + "type": "double" + }, + "storePrice":{ + "type": "double" + }, + "vipPrice":{ + "type": "double" + }, + "index_id":{ + "type": "keyword" + }, + "location":{ + "type": "geo_point" + } + } + } +}` diff --git a/app/task/svc/svc_hw_order_settle.go b/app/task/svc/svc_hw_order_settle.go index c9f1b5d..b2ce46a 100644 --- a/app/task/svc/svc_hw_order_settle.go +++ b/app/task/svc/svc_hw_order_settle.go @@ -31,7 +31,7 @@ func HwOrderSettle() { } fmt.Println(utils.SerializeStr(order)) platformMap := map[string]string{ - "starbucks": "星巴克", "movie": "电影", "mcdonald": "麦当劳", "nayuki": "奈雪", "luckin": "瑞幸咖啡", "pizza": "必胜客", + "recharge": "视频会员直充", "starbucks": "星巴克", "movie": "电影", "mcdonald": "麦当劳", "nayuki": "奈雪", "luckin": "瑞幸咖啡", "pizza": "必胜客", "pagoda": "百果园", "burger_king": "汉堡王", "heytea": "喜茶", "to_kfc": "肯德基", "wallace": "华莱士", "flowerCake": "鲜花", "delivery": "比价寄", "tourism": "出游", } for _, v := range order { diff --git a/app/task/svc/svc_hw_recharge_order.go b/app/task/svc/svc_hw_recharge_order.go new file mode 100644 index 0000000..83688f4 --- /dev/null +++ b/app/task/svc/svc_hw_recharge_order.go @@ -0,0 +1,68 @@ +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/hw" + "encoding/json" + "fmt" + "github.com/tidwall/gjson" + "strings" + "time" +) + +func HwRechargeOrder() { + data := hw.HwRechargeSendOrder(offical.SysCfgByKeyStr("hw_recharge_secret"), "recharge", "RECHARGE") + order := gjson.Get(data, "data").String() + if order != "" && order != "[]" { + var list = make([]map[string]interface{}, 0) + json.Unmarshal([]byte(order), &list) + for _, v := range list { + AddRechargeOrder("recharge", v) + } + } + return +} + +func AddRechargeOrder(method string, order map[string]interface{}) { + statusArr := map[string]string{"SOLD": "订单成功", "SUCCESS": "订单成功", "REFUNDED": "订单退款", "AFTER_SALE": "订单付款"} + userId := order["openid"] + if strings.Contains(utils.AnyToString(userId), "own") == false { + return + } + isShare := 0 + if strings.Contains(utils.AnyToString(userId), "share") { + isShare = 1 + } + split := strings.Split(utils.AnyToString(userId), "_") + mid := split[2] + uid := split[3] + var ord = &model.HwOrder{ + Oid: utils.AnyToString(order["sell_order_no"]), + Info: utils.AnyToString(order["commodity_name"]), + Commission: utils.AnyToFloat64(order["agent_rebate"]), + Type: method, + Uid: utils.StrToInt(mid), + Payment: utils.AnyToFloat64(order["amount"]), + Status: statusArr[utils.AnyToString(order["order_status"])], + CreateTime: int(utils.TimeStdParseUnix(utils.AnyToString(order["create_time"]))), + Data: utils.SerializeStr(order), + UpdateTime: int(time.Now().Unix()), + Zuid: uid, + UserId: utils.AnyToString(order["openid"]), + IsShare: isShare, + ExtendUid: "0", + } + one := db.GetHwOrderByOne(ord.Oid, utils.IntToStr(ord.Uid), ord.Type) + if one == nil { + insertOne, err := db.ZhimengDb.InsertOne(ord) + fmt.Println(insertOne) + fmt.Println(err) + } else { + ord.SettleTime = one.SettleTime + db.ZhimengDb.Where("id=?", one.Id).AllCols().Update(ord) + } + return +} diff --git a/app/task/svc/svc_life_order_settle.go b/app/task/svc/svc_life_order_settle.go index cad7dd1..d48ee36 100644 --- a/app/task/svc/svc_life_order_settle.go +++ b/app/task/svc/svc_life_order_settle.go @@ -11,10 +11,10 @@ import ( ) func LifeOrderSettle(arg map[string]string) { - day := time.Now().Day() - if day < 20 { - return - } + //day := time.Now().Day() + //if day < 20 { + // return + //} order := db.GetLifeOrderList(arg) if len(order) == 0 { diff --git a/app/task/svc/svc_oil_add_es.go b/app/task/svc/svc_oil_add_es.go new file mode 100644 index 0000000..8dd8751 --- /dev/null +++ b/app/task/svc/svc_oil_add_es.go @@ -0,0 +1,77 @@ +package svc + +import ( + offical "applet/app/db/official" + "applet/app/task/md" + "applet/app/utils" + "applet/app/utils/cache" + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/xiaoju" + "encoding/json" + "fmt" + "github.com/jinzhu/copier" + "github.com/tidwall/gjson" + "time" +) + +func OilAddEs() { + oilAddEsTime := offical.SysCfgByKeyStr("oil_add_es_time") + today := utils.GetTimeRange("today") + if utils.TimeStdParseUnix(oilAddEsTime) > today["start"] { + return + } + PessimismLockValue := "zhiyingOilAddEsTime" + key := fmt.Sprintf("zhiyingOilAddEsTime") + //TODO::增加“悲观锁”防止串行 + getString, _ := cache.GetString(key) + if getString == PessimismLockValue { + fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次未执行完") + return + } + cache.SetEx(key, PessimismLockValue, 3600*15) //8小时 + offical.DbsSysCfgUpdate("oil_add_es_time", time.Now().Format("2006-01-02 15:04:05")) + CommOilAddEs(1) + cache.Del(key) +} +func CommOilAddEs(p int) { + platformKey := XiaojuKey() + token := GetXiaojuToken(platformKey) + data := map[string]interface{}{ + "pageIndex": p, + "pageSize": 100, + } + list, _ := xiaoju.XiaojuStation(platformKey, token, data) + //处理数据 + storeInfoList := gjson.Get(list, "storeInfoList").String() + var store = make([]md.XiaojuGoods, 0) + json.Unmarshal([]byte(storeInfoList), &store) + count := len(store) + for _, v := range store { + var tmp md.XiaojuGoodsEs + copier.Copy(&tmp, &v) + tmp.HuiLabels = utils.SerializeStr(v.HuiLabels) + for _, v1 := range v.ItemInfoList { + var tmp2 = tmp + tmp2.ItemName = v1.ItemName + tmp2.IndexId = tmp2.StoreId + tmp2.ItemName + tmp2.CityPrice = float64(v1.CityPrice) / 100 + tmp2.StorePrice = float64(v1.StorePrice) / 100 + tmp2.Location.Lon = tmp2.Lon + tmp2.Location.Lat = tmp2.Lat + doc, _ := es.FirstDoc(md.EggOilStation, tmp2.IndexId) + if doc == nil { + createDocRet, _ := es.CreateDoc(md.EggOilStation, tmp2.IndexId, tmp2) + fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet) + } else { + createDocRet, _ := es.UpdateDoc(md.EggOilStation, tmp2.IndexId, tmp2) + fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet) + } + } + } + if count == 100 { + p++ + CommOilAddEs(p) + return + } + return +} diff --git a/app/task/svc/svc_oil_order.go b/app/task/svc/svc_oil_order.go new file mode 100644 index 0000000..bffe0e7 --- /dev/null +++ b/app/task/svc/svc_oil_order.go @@ -0,0 +1,168 @@ +package svc + +import ( + "applet/app/cfg" + "applet/app/db" + "applet/app/db/model" + offical "applet/app/db/official" + "applet/app/task/md" + "applet/app/utils" + "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/xiaoju" + "encoding/json" + "fmt" + "github.com/tidwall/gjson" + "strings" + "time" +) + +func OilOrder() { + pvdTimeKey := "oil_time" + + // 获得最后时间 + timeStrData := offical.SysCfgByKey(pvdTimeKey) + timeStr := "" + if timeStrData == nil { + offical.DbsSysCfgInserts(pvdTimeKey, time.Now().Format("2006-01-02")) + timeStr = offical.SysCfgByKeyStr(pvdTimeKey) + } else { + timeStr = timeStrData.V + } + // 所有时间都是在操作秒数 + now := time.Now().Unix() + strs := strings.Split(timeStr, ":") + 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 + ) + + //怕时间不是走最新的 + leave := now - past + if leave > 500 { + leave = 0 + } + past = past + leave + beginTime = past - 85000 + endTime = past + + if endTime > now { + endTime = now + } + for { + count := 0 + count, _ = OrdersOilGet(pageNo, pageSize, beginTime, endTime) + if count == 0 { + goto ChkArg + } + // 判断是否分页已经全部取完了 + if count <= pageSize { + pageNo++ + fmt.Println("========下一页========" + utils.IntToStr(pageNo)) + count = 0 + continue + } + ChkArg: + // 查询完后重置时间, 最后查询时间 + 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 + } + offical.DbsSysCfgUpdate(pvdTimeKey, utils.TimeToStr(endTime)) + +} + +func OrdersOilGet(p int, pageSize int, sTime, eTime int64) (int, string) { + platformKey := XiaojuKey() + args := map[string]interface{}{ + "queryEndTime": time.Unix(eTime, 0).Format("2006-01-02 15:04:05"), + "queryStartTime": time.Unix(sTime, 0).Format("2006-01-02 15:04:05"), + "pageIndex": p, + "pageSize": pageSize, + } + token := GetXiaojuToken(platformKey) + datas, err := xiaoju.XiaojuStationOrder(platformKey, token, args) + if err != nil { + return 0, "" + } + var order = make([]md.OilData, 0) + json.Unmarshal([]byte(gjson.Get(datas, "orderInfoList").String()), &order) + if len(order) == 0 { + return 0, "" + } + count := len(order) + + for _, v := range order { + commXiaoju(v) + } + return count, "" +} +func commXiaoju(data md.OilData) error { + if data.PayStatus == 0 { + return nil + } + state := "订单付款" + if data.RefundStatus == 1 { + state = "订单退款" + } + ex := strings.Split(data.OutUserId, "_") + if strings.Contains(utils.AnyToString(data.OutUserId), "zhiying") == false { + return nil + } + if strings.Contains(utils.AnyToString(data.OutUserId), "dev") && cfg.Prd { + return nil + } + if strings.Contains(utils.AnyToString(data.OutUserId), "prd") && cfg.Prd == false { + return nil + } + var res = model.LifeOrder{ + PvdParentOid: data.OrderId, + Pvd: "xiaoju", + Status: state, + CreateTime: int(utils.TimeStdParseUnix(data.PayTime)), + } + res.Uid = utils.StrToInt(ex[3]) + res.StationUid = utils.StrToInt(ex[2]) + res.Oid = utils.StrToInt64(utils.OrderUUID(utils.StrToInt(ex[2]))) + res.PvdOid = data.OrderId + res.UpdateTime = int(time.Now().Unix()) + res.Title = data.StoreName + res.Gid = res.PvdOid + res.Payment = utils.Float64ToStr(float64(data.RealMoney) / 100) + var commission = float64(data.RealMoney) / 100 * (0.2 / 100) + res.Commission = utils.Float64ToStr(commission) + res.RealCommission = utils.Float64ToStr(commission) + one := db.GetLifeOrderByOne(res.PvdOid, utils.IntToStr(res.Uid), res.Pvd) + if one == nil { + insertOne, err := db.ZhimengDb.InsertOne(&res) + fmt.Println(insertOne) + fmt.Println(err) + } else { + res.SettleTime = one.SettleTime + res.CreateTime = one.CreateTime + if one.PlatformSettleTime > 0 { + res.PlatformSettleTime = one.PlatformSettleTime + } + db.ZhimengDb.Where("id=?", one.Id).AllCols().Update(&res) + } + return nil +} diff --git a/app/task/svc/svc_xiaoju.go b/app/task/svc/svc_xiaoju.go new file mode 100644 index 0000000..8f1d700 --- /dev/null +++ b/app/task/svc/svc_xiaoju.go @@ -0,0 +1,38 @@ +package svc + +import ( + "applet/app/cfg" + offical "applet/app/db/official" + "applet/app/utils/cache" + "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/xiaoju" + "github.com/tidwall/gjson" +) + +// 小桔基本配置 +func XiaojuKey() map[string]string { + param := map[string]string{ + "key": offical.SysCfgByKeyStr("xiaoju_key"), + "sign_secret": offical.SysCfgByKeyStr("xiaoju_sign_secret"), + "data_secret": offical.SysCfgByKeyStr("xiaoju_data_secret"), + "secret": offical.SysCfgByKeyStr("xiaoju_secret"), + "url": "https://gw.am.xiaojukeji.com/online/energy/v1/", + } + return param +} +func GetXiaojuToken(platformKey map[string]string) string { + key := "zhiying_xiaoju_token" + token, err := cache.GetString(key) + if cfg.Prd == false { + return token + } + if err != nil || token == "" { + token1, _ := xiaoju.GetXiaojuToken(platformKey) + token = gjson.Get(token1, "accessToken").String() + if token != "" { + availableTime := gjson.Get(token1, "availableTime").Int() + cache.SetEx(key, token, int(availableTime-20)) + } + } + return token + +} diff --git a/app/task/task_hw_recharge_order.go b/app/task/task_hw_recharge_order.go new file mode 100644 index 0000000..8908b01 --- /dev/null +++ b/app/task/task_hw_recharge_order.go @@ -0,0 +1,21 @@ +package task + +import ( + "applet/app/task/svc" + "math/rand" + "time" +) + +func taskHwRechargeOrder() { + for { + if len(ch) > workerNum { + time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) + } else { + goto START + } + } +START: + ch <- 1 + svc.HwRechargeOrder() + <-ch +} diff --git a/app/task/task_oil_add_es.go b/app/task/task_oil_add_es.go new file mode 100644 index 0000000..bc24dfc --- /dev/null +++ b/app/task/task_oil_add_es.go @@ -0,0 +1,21 @@ +package task + +import ( + "applet/app/task/svc" + "math/rand" + "time" +) + +func taskOilAddEs() { + for { + if len(ch) > workerNum { + time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) + } else { + goto START + } + } +START: + ch <- 1 + svc.OilAddEs() + <-ch +} diff --git a/app/task/task_oil_order.go b/app/task/task_oil_order.go new file mode 100644 index 0000000..26c4dd6 --- /dev/null +++ b/app/task/task_oil_order.go @@ -0,0 +1,21 @@ +package task + +import ( + "applet/app/task/svc" + "math/rand" + "time" +) + +func taskOilOrder() { + for { + if len(ch) > workerNum { + time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) + } else { + goto START + } + } +START: + ch <- 1 + svc.OilOrder() + <-ch +} diff --git a/app/task/task_pay_life_order_settle.go b/app/task/task_pay_life_order_settle.go index 35ca8b8..79fa7cd 100644 --- a/app/task/task_pay_life_order_settle.go +++ b/app/task/task_pay_life_order_settle.go @@ -28,7 +28,7 @@ START: "to_settle_time": utils.Int64ToStr(month["start"]), "p": "1", "size": "100", - "pvd": "own_didi_online_car,own_didi_freight,own_didi_chauffeur,own_oilstation,own_king_flower", + "pvd": "xiaoju", } svc.LifeOrderSettle(arg) <-ch diff --git a/go.mod b/go.mod index 9c397a9..8aa9616 100644 --- a/go.mod +++ b/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.20241023080942-721e3ee3148e + code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20250311032855-92b94363b2d1 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 @@ -17,7 +17,7 @@ require ( github.com/go-playground/universal-translator v0.18.0 github.com/go-playground/validator/v10 v10.10.0 github.com/go-redis/redis v6.15.9+incompatible - github.com/go-sql-driver/mysql v1.6.0 + github.com/go-sql-driver/mysql v1.8.1 github.com/gomodule/redigo v2.0.0+incompatible github.com/jinzhu/copier v0.3.5 github.com/makiuchi-d/gozxing v0.1.1 @@ -25,13 +25,12 @@ require ( github.com/qiniu/api.v7/v7 v7.8.2 github.com/robfig/cron/v3 v3.0.1 github.com/sony/sonyflake v1.1.0 - github.com/stretchr/testify v1.8.0 // indirect - github.com/syyongx/php2go v0.9.7 + github.com/syyongx/php2go v0.9.8 github.com/tidwall/gjson v1.14.1 go.uber.org/zap v1.16.0 golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect golang.org/x/net v0.14.0 // indirect - gopkg.in/natefinch/lumberjack.v2 v2.0.0 + gopkg.in/natefinch/lumberjack.v2 v2.2.1 gopkg.in/yaml.v2 v2.4.0 xorm.io/xorm v1.3.2