From cd430f4d1e890c918f82de6626b2c7a10f2caea0 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Thu, 17 Nov 2022 17:59:23 +0800 Subject: [PATCH 1/4] jxincomebegin --- business/jxcallback/orderman/orderman_ext.go | 2 +- business/jxstore/cms/store.go | 161 ++++++++---------- business/jxstore/misc/misc.go | 2 +- business/model/dao/dao_order.go | 4 + business/model/dao/store.go | 2 - .../partner/purchase/tiktok_store/store.go | 12 +- 6 files changed, 84 insertions(+), 99 deletions(-) diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 58fac16f1..c4322fe3e 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -339,7 +339,7 @@ func (c *OrderManager) GetOrders(ctx *jxcontext.Context, isIncludeFake bool, fro //if isJxIncomeArea { // begin = utils.MustInterface2Int64(params["jxIncomeBegin"]) // end = utils.MustInterface2Int64(params["jxIncomeEnd"]) - // pageSize = math.MaxInt32 + //pageSize = math.MaxInt32 //} orders, totalCount, err := dao.GetOrders(db, nil, false, isIncludeFake, fromDateStr, toDateStr, isDateFinish, skuIDs, isJxFirst, "", params, offset, pageSize) if err == nil { diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index e1ff3e4ca..17ffd8685 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -5897,93 +5897,79 @@ func UpdateStorePoiStatus(ctx *jxcontext.Context) error { } //抖音定时任务 -//func UpdateStoreRelInformation(ctx *jxcontext.Context) error { -// var ( -// storeIDs []string -// temp map[int64]string -// db = dao.GetDB() -// errList = errlist.New() -// tempIDs map[string][]string -// FreightTemplate = &model.FreightTemplate{} -// ) -// vendorOrgCodes, _ := dao.GetVendorOrgCode(db, model.VendorIDDD, "", "platform") -// for _, v := range vendorOrgCodes { -// if temp, err = tiktok_store.GetAllVendorStoreMap(ctx, v.VendorOrgCode); err != nil { -// return nil, err -// } -// //tempIDs[v.VendorOrgCode] = temp -// } -// -// if handler, ok := partner.GetPurchasePlatformFromVendorID(model.VendorIDDD).(partner.IStoreHandler); ok { -// rootTask := tasksch.NewParallelTask("UpdateStoreRelInformation 根据平台门店ID同步本地相关信息", tasksch.NewParallelConfig().SetParallelCount(1), ctx, -// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { -// vendorOrgCodes, _ := dao.GetVendorOrgCode(db, model.VendorIDDD, "", "platform") -// for _, v := range vendorOrgCodes { -// if temp, err = tiktok_store.GetAllVendorStoreMap(ctx, v.VendorOrgCode); err != nil { -// return nil, err -// } -// //tempIDs[v.VendorOrgCode] = temp -// } -// -// subTask := tasksch.NewSeqTask("UpdateStoreRelInformation 根据平台门店ID同步本地相关信息", ctx, -// func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { -// switch step { -// case 0: -// for i, j := range tempIDs { -// for _, v := range j { -// //(1)仓库以及电子围栏 -// if bindWarehouse, err := tiktok_store.GetWarehouseByStore(i, utils.Str2Int64(v)); err != nil { -// errList.AddErr(fmt.Errorf("同步任务: 获取门店(%s)绑定的仓库以及电子围栏失败:%v", v, err)) -// } else if len(bindWarehouse[utils.Str2Int64(i)][0].OutFenceIds) > 0 { -// tempStr := "" -// for k, v := range bindWarehouse[utils.Str2Int64(i)][0].OutFenceIds { -// tempStr += v -// if k != len(bindWarehouse[utils.Str2Int64(i)][0].OutFenceIds) { -// tempStr += "," -// } -// } -// FreightTemplate.FenceID = tempStr -// FreightTemplate.WarehouseID = bindWarehouse[utils.Str2Int64(i)][0].WarehouseId -// } -// //(2)运费模板 -// if bindFreightIDs, err := tiktok_store.GetStoreFreight(i, utils.Str2Int64(v)); err != nil { -// globals.SugarLogger.Debugf("同步任务: 获取门店(%s) 绑定运费模板出错:%v", v, err) -// errList.AddErr(fmt.Errorf("同步任务: 获取门店(%s) 绑定运费模板出错:%v", v, err)) -// } else { -// FreightTemplate.TemplateID = bindFreightIDs -// } -// //(3)限售模板 -// if bindTradeLimitID, err := tiktok_store.GetStoreSaleLimit(i, utils.Str2Int64(v)); err != nil { -// globals.SugarLogger.Debugf("同步任务: 获取门店(%s) 限售模板出错:%v", v, err) -// errList.AddErr(fmt.Errorf("同步任务: 获取门店(%s) 限售模板出错:%v", v, err)) -// } else { -// FreightTemplate.TradeLimitID = bindTradeLimitID -// } -// } -// } -// -// if _, err := dao.UpdateEntity(db, FreightTemplate, "TemplateID", "WarehouseID", "FenceID", "TradeLimitID "); err != nil { -// if err1 := dao.CreateEntity(db, FreightTemplate); err != nil { -// errList.AddErr(fmt.Errorf("同步进数据库错误信息:%v", err1)) -// } else { -// errList.AddErr(fmt.Errorf("同步进数据库错误信息:%v", err)) -// } -// } -// dao.WrapAddIDCULDEntity(FreightTemplate, "同步任务操作") -// } -// return nil, err -// }, 4) -// return retVal, err -// }, storeIDs) -// } -// -// //task := tasksch.NewSeqTask(fmt.Sprintf("平台:抖店小时达 UpdateStoreRelInformation"), ctx, -// // func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { -// // -// // }, 3) -// //tasksch.ManageTask(task).Run() -// return nil -//} +func UpdateStoreRelInformation(ctx *jxcontext.Context) error { + var ( + tempRelIDs map[int64]string + db = dao.GetDB() + errList = errlist.New() + tempIDs map[string]map[int64]string + FreightTemplate = &model.FreightTemplate{} + ) + if vendorOrgCodes, err := dao.GetVendorOrgCode(db, model.VendorIDDD, "", "platform"); err != nil { + return fmt.Errorf("获取vendorOrgCodes失败: %v", err) + } else { + for _, v := range vendorOrgCodes { + tempRelIDs, err = tiktok_store.GetAllVendorStoreMap(ctx, v.VendorOrgCode) //平台与京西门店映射关系 + if err != nil { + return err + } + tempIDs[v.VendorOrgCode] = tempRelIDs + } + for i, j := range tempIDs { + for m, n := range j { //m-vendorStoreID n-storeID + subTask := tasksch.NewSeqTask(fmt.Sprintf("UpdateStoreRelInformation 平台门店(%d) 本地门店(%s):同步本地相关信息", m, n), ctx, func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { + switch step { + case 0: //(1)仓库以及电子围栏 + if bindWarehouse, err := tiktok_store.GetWarehouseByStore(i, m); err != nil { + errList.AddErr(fmt.Errorf("同步任务: 获取门店(%s)绑定的仓库以及电子围栏失败:%v", n, err)) + } else if len(bindWarehouse[utils.Str2Int64(i)][0].OutFenceIds) > 0 { + for _, s := range bindWarehouse[utils.Str2Int64(i)][0].OutFenceIds { + if s == n { + FreightTemplate.FenceID = s + } + } + } else { + FreightTemplate.WarehouseID = bindWarehouse[utils.Str2Int64(i)][0].WarehouseId + } + case 1: //(2)运费模板 + if bindFreightIDs, err := tiktok_store.GetStoreFreight(i, m); err != nil { + globals.SugarLogger.Debugf("同步任务: 获取门店(%s) 绑定运费模板出错:%v", n, err) + errList.AddErr(fmt.Errorf("同步任务: 获取门店(%s) 绑定运费模板出错:%v", n, err)) + } else { + FreightTemplate.TemplateID = bindFreightIDs + } + case 2: //(3)限售模板 + if bindTradeLimitID, err := tiktok_store.GetStoreSaleLimit(i, m); err != nil { + globals.SugarLogger.Debugf("同步任务: 获取门店(%s) 限售模板出错:%v", n, err) + errList.AddErr(fmt.Errorf("同步任务: 获取门店(%s) 限售模板出错:%v", n, err)) + } else { + FreightTemplate.TradeLimitID = bindTradeLimitID + } + } + + return nil, nil + }, 4) + tasksch.ManageTask(subTask).Run() + //time.Sleep(2 * time.Second) + FreightTemplate.VendorStoreID = utils.Int64ToStr(m) + FreightTemplate.StoreID = utils.Str2Int(n) + if _, err := dao.UpdateEntity(db, FreightTemplate, "VendorStoreID", "StoreID", "TemplateID", "WarehouseID", "FenceID", "TradeLimitID"); err != nil { + if err1 := dao.CreateEntity(db, FreightTemplate); err1 != nil { + errList.AddErr(fmt.Errorf("创建操作,同步进数据库错误信息:%v", err1)) + } else { + errList.AddErr(fmt.Errorf("更新操作,同步进数据库错误信息:%v", err)) + } + } + } + } + } + lastErr := errList.GetErrListAsOne() + if lastErr != nil { + globals.SugarLogger.Debugf("定时任务同步抖店门店信息到本地 相关提示:%s", lastErr) + //return lastErr + } + return nil +} //获取抖店门店建议范围 (即电子围栏) func GetDDScope(ctx *jxcontext.Context, storeID int, vendorStoreID string) (warehouse_getFences_response.FencesItem, error) { @@ -5994,7 +5980,6 @@ func GetDDScope(ctx *jxcontext.Context, storeID int, vendorStoreID string) (ware return data, errors.New("storeID,vendorStoreID 必填") } storeMap, err := GetVendorOrgCode(ctx, dao.GetDB(), storeID, model.VendorIDDD, vendorStoreID) - globals.SugarLogger.Debug("len(storeMap)=================%d", len(storeMap)) if err != nil { return data, errors.New(fmt.Sprintf("获取vendorOrgCode失败,请检查数据或重试:%v", err)) } diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 5f1d01029..e55f7ea9e 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -187,7 +187,7 @@ func Init() { }) //每天晚上23:00获取门店 电子围栏、仓库、限售模板、运费模板ID同步进数据库 ScheduleTimerFunc("UpdateStoreRelInformation", func() { - //cms.UpdateStoreRelInformation(jxcontext.AdminCtx) + cms.UpdateStoreRelInformation(jxcontext.AdminCtx) }, []string{ "22:00:00", }) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index d855e62bd..06ffa1e96 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -2,6 +2,8 @@ package dao import ( "fmt" + "git.rosy.net.cn/jx-callback/globals" + "reflect" "regexp" "strconv" "time" @@ -1057,12 +1059,14 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat } sql += ` ) a WHERE 1 = 1` + globals.SugarLogger.Debugf("params 的type= %s,data======%d", reflect.TypeOf(params["jxIncomeBegin"]), utils.MustInterface2Int64(params["jxIncomeBegin"])) if params["jxIncomeBegin"] != nil { //if utils.MustInterface2Int64(params["jxIncomeBegin"]) != 0 { sql += " AND a.jx_income >= ?" sqlParams = append(sqlParams, utils.MustInterface2Int64(params["jxIncomeBegin"])) //} } + utils.MustInterface2Int64(params["jxIncomeBegin"]) if params["jxIncomeEnd"] != nil { //if utils.MustInterface2Int64(params["jxIncomeEnd"]) != 0 { sql += " AND a.jx_income <= ?" diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 1f4e01368..774dd18a1 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -3,7 +3,6 @@ package dao import ( "errors" "fmt" - "git.rosy.net.cn/jx-callback/globals" "sort" "strings" "time" @@ -1635,6 +1634,5 @@ func InsertIntoFreightTemplate(storeID int, vendorStoreID string, templateID, wa //只获取美团平台的京西storeID func GetCodeAndIDByMeiTuan(vendorStoreID string) (storeID int, err error) { err = GetRow(GetDB(), &storeID, "SELECT s.store_id FROM store_map s WHERE s.vendor_store_id = ? AND s.vendor_id = ? ", vendorStoreID, model.VendorIDMTWM) - globals.SugarLogger.Debugf("GetCodeAndIDByMeiTuan storeID===========%d", storeID) return storeID, err } diff --git a/business/partner/purchase/tiktok_store/store.go b/business/partner/purchase/tiktok_store/store.go index 381e15067..104ac2e82 100644 --- a/business/partner/purchase/tiktok_store/store.go +++ b/business/partner/purchase/tiktok_store/store.go @@ -262,11 +262,10 @@ func CreateOrUpdateAll(vendorOrgCode string, storeID, vendorStoreID, deliveryFee VendorStoreID: utils.Int64ToStr(vendorStoreID), } if err := dao.CreateEntity(db, FreightTemplate); err != nil { - _, err1 := dao.UpdateEntity(db, FreightTemplate, "TemplateID", "WarehouseID", "FenceID", "TradeLimitID") - if err1 != nil { - errList.AddErr(fmt.Errorf("同步进数据库错误信息:%v", err1)) + if _, err1 := dao.UpdateEntity(db, FreightTemplate, "TemplateID", "WarehouseID", "FenceID", "TradeLimitID"); err1 != nil { + errList.AddErr(fmt.Errorf("更新操作,同步进数据库错误信息:%v", err1)) } else { - errList.AddErr(fmt.Errorf("同步进数据库错误信息:%v", err)) + errList.AddErr(fmt.Errorf("创建操作,同步进数据库错误信息:%v", err)) } } endErr := errList.GetErrListAsOne() @@ -493,10 +492,9 @@ func (P *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin if err = dao.CreateEntity(db, FreightTemplate); err != nil { if _, err1 := dao.UpdateEntity(db, FreightTemplate, "FenceID"); err1 != nil { globals.SugarLogger.Debugf("db update storeID,vendorStoreID defeat on :%v", err1) - errList.AddErr(fmt.Errorf("同步Step1进数据库错误信息:%v", err1)) + errList.AddErr(fmt.Errorf("更新操作,同步进数据库错误信息:%v", err1)) } else { - globals.SugarLogger.Debugf("检测数据打印 err===========%v", err) - errList.AddErr(fmt.Errorf("同步Step2进数据库错误信息:%v", err)) + errList.AddErr(fmt.Errorf("创建操作,同步进数据库错误信息:%v", err)) } } } From 448199d4db141f8ef3ae51e6f4a9b1e8c646973e Mon Sep 17 00:00:00 2001 From: richboo111 Date: Thu, 17 Nov 2022 18:03:52 +0800 Subject: [PATCH 2/4] jxincomebegin --- business/model/dao/dao_order.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 06ffa1e96..2fbdae7a8 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -2,8 +2,6 @@ package dao import ( "fmt" - "git.rosy.net.cn/jx-callback/globals" - "reflect" "regexp" "strconv" "time" @@ -1059,7 +1057,7 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat } sql += ` ) a WHERE 1 = 1` - globals.SugarLogger.Debugf("params 的type= %s,data======%d", reflect.TypeOf(params["jxIncomeBegin"]), utils.MustInterface2Int64(params["jxIncomeBegin"])) + if params["jxIncomeBegin"] != nil { //if utils.MustInterface2Int64(params["jxIncomeBegin"]) != 0 { sql += " AND a.jx_income >= ?" From 710a248f1ff30042ceedfa789980c60a5c37aeb5 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Thu, 17 Nov 2022 18:05:56 +0800 Subject: [PATCH 3/4] jxincomebegin --- business/model/dao/dao_order.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 2fbdae7a8..0ec4d4e07 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1057,14 +1057,13 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat } sql += ` ) a WHERE 1 = 1` - + globals.SugarLogger.Debugf("params 的type= %s,data======%d", reflect.TypeOf(params["jxIncomeBegin"]), utils.MustInterface2Int64(params["jxIncomeBegin"])) if params["jxIncomeBegin"] != nil { //if utils.MustInterface2Int64(params["jxIncomeBegin"]) != 0 { sql += " AND a.jx_income >= ?" sqlParams = append(sqlParams, utils.MustInterface2Int64(params["jxIncomeBegin"])) //} } - utils.MustInterface2Int64(params["jxIncomeBegin"]) if params["jxIncomeEnd"] != nil { //if utils.MustInterface2Int64(params["jxIncomeEnd"]) != 0 { sql += " AND a.jx_income <= ?" From 147a61deaf48bddd1fcb0241a9643947db2864bb Mon Sep 17 00:00:00 2001 From: richboo111 Date: Thu, 17 Nov 2022 18:06:57 +0800 Subject: [PATCH 4/4] jxincomebegin --- business/model/dao/dao_order.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 0ec4d4e07..c4b687d19 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -2,6 +2,7 @@ package dao import ( "fmt" + "git.rosy.net.cn/jx-callback/globals" "regexp" "strconv" "time" @@ -1057,7 +1058,7 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat } sql += ` ) a WHERE 1 = 1` - globals.SugarLogger.Debugf("params 的type= %s,data======%d", reflect.TypeOf(params["jxIncomeBegin"]), utils.MustInterface2Int64(params["jxIncomeBegin"])) + globals.SugarLogger.Debugf("params 的type= %T,data======%d", params["jxIncomeBegin"], utils.MustInterface2Int64(params["jxIncomeBegin"])) if params["jxIncomeBegin"] != nil { //if utils.MustInterface2Int64(params["jxIncomeBegin"]) != 0 { sql += " AND a.jx_income >= ?"