From 7a706a316e3d10b9f0b1d39a2ba7e4c01cfd06b8 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Mon, 30 Aug 2021 17:10:46 +0800 Subject: [PATCH 01/18] a --- business/jxstore/report/report.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 29c0b354d..06007b28a 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -796,11 +796,9 @@ func OrderNotifyReport(ctx *jxcontext.Context, storeIDs, brandIDs []int, vendorI LEFT JOIN store b ON IF(a.store_id = 0 ,a.jx_store_id, a.store_id) = b.id LEFT JOIN user c ON c.mobile = b.market_man_phone LEFT JOIN user d ON d.mobile = b.operator_phone - WHERE a.status = ? AND a.notify_type <> ? + WHERE a.notify_type <> ? ` - sqlParams := []interface{}{ - model.OrderStatusFinished, 0, - } + sqlParams := []interface{}{0} if len(storeIDs) > 0 { sql += ` AND IF(a.jx_store_id != 0, a.jx_store_id, a.store_id) IN(` + dao.GenQuestionMarks(len(storeIDs)) + `)` sqlParams = append(sqlParams, storeIDs) From 11ebe15aaa68ae7b055243452f5bd1a4cdf644a5 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Tue, 31 Aug 2021 17:05:57 +0800 Subject: [PATCH 02/18] aa --- business/partner/purchase/ebai/store.go | 47 +++++++++++++------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index 9211588b6..8215b7222 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -362,29 +362,32 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask // todo 此函数只考虑了在饿了么侧开店的情况 func EbaiDeliveryType2Jx(deliveryType string) int8 { spIndex := strings.Index(deliveryType, "|") - elmDeliveryType := utils.Str2Int64(deliveryType[:spIndex]) - switch elmDeliveryType { - case ebaiapi.DeliveryTypeElmFengNiaoZS, - ebaiapi.DeliveryTypeElmFengNiaoZSKA, - ebaiapi.DeliveryTypeElmFengNiaoKS, - ebaiapi.DeliveryTypeElmNewRetail, - ebaiapi.DeliveryTypeElmEPeiSong, - ebaiapi.DeliveryTypeElmFengNiaoHybrid, - ebaiapi.DeliveryTypeElmFengNiaoNiubee: - return scheduler.StoreDeliveryTypeByPlatform - case ebaiapi.DeliveryTypeElmXingHuoZBTrial, - ebaiapi.DeliveryTypeElmXingHuoZB, - ebaiapi.DeliveryTypeElmXingHuoZBKA: - return scheduler.StoreDeliveryTypeCrowdSourcing - case ebaiapi.DeliveryTypeElmNone, - ebaiapi.DeliveryTypeElmXingHuoTrial, - ebaiapi.DeliveryTypeElmXingHuo, - ebaiapi.DeliveryTypeElmEBase, - ebaiapi.DeliveryTypeElmXingHuoKA: - return scheduler.StoreDeliveryTypeByStore - default: - return scheduler.StoreDeliveryTypeCrowdSourcing + if deliveryType != "" { + elmDeliveryType := utils.Str2Int64(deliveryType[:spIndex]) + switch elmDeliveryType { + case ebaiapi.DeliveryTypeElmFengNiaoZS, + ebaiapi.DeliveryTypeElmFengNiaoZSKA, + ebaiapi.DeliveryTypeElmFengNiaoKS, + ebaiapi.DeliveryTypeElmNewRetail, + ebaiapi.DeliveryTypeElmEPeiSong, + ebaiapi.DeliveryTypeElmFengNiaoHybrid, + ebaiapi.DeliveryTypeElmFengNiaoNiubee: + return scheduler.StoreDeliveryTypeByPlatform + case ebaiapi.DeliveryTypeElmXingHuoZBTrial, + ebaiapi.DeliveryTypeElmXingHuoZB, + ebaiapi.DeliveryTypeElmXingHuoZBKA: + return scheduler.StoreDeliveryTypeCrowdSourcing + case ebaiapi.DeliveryTypeElmNone, + ebaiapi.DeliveryTypeElmXingHuoTrial, + ebaiapi.DeliveryTypeElmXingHuo, + ebaiapi.DeliveryTypeElmEBase, + ebaiapi.DeliveryTypeElmXingHuoKA: + return scheduler.StoreDeliveryTypeByStore + default: + return scheduler.StoreDeliveryTypeCrowdSourcing + } } + return scheduler.StoreDeliveryTypeCrowdSourcing } func EbaiDeliveryRegion2Jx(deliveryRegion interface{}) string { From 7b4617ce90352b3b050547b97a1302d56187042d Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Tue, 31 Aug 2021 17:52:58 +0800 Subject: [PATCH 03/18] aa' --- business/partner/purchase/ebai/store.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index 8215b7222..1324062f4 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -391,6 +391,9 @@ func EbaiDeliveryType2Jx(deliveryType string) int8 { } func EbaiDeliveryRegion2Jx(deliveryRegion interface{}) string { + if deliveryRegion == nil { + return "" + } realDeliveryRegion := deliveryRegion.([]interface{}) if len(realDeliveryRegion) > 0 { region := deliveryRegion.([]interface{})[0].(map[string]interface{})["region"].([]interface{})[0].([]interface{}) From 261391b3cac405c176fc8aa4e6b83c97cc2ed349 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Tue, 31 Aug 2021 18:15:57 +0800 Subject: [PATCH 04/18] aa --- business/partner/purchase/jdshop/store.go | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/business/partner/purchase/jdshop/store.go b/business/partner/purchase/jdshop/store.go index 6b27e8930..2f47c0abf 100644 --- a/business/partner/purchase/jdshop/store.go +++ b/business/partner/purchase/jdshop/store.go @@ -22,19 +22,21 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo // result, err := api.JdShopAPI.NewInfoList(utils.Str2Int64(vendorStoreID)) // storeDetail.VendorStoreID = vendorStoreID // storeDetail.Status = JdsStatus2jxStatus(result.StoreStatus) - result2, err := api.JdShopAPI.QueryEntityStore(utils.Str2Int64(vendorStoreID)) - if result2 == nil { - return storeDetail, fmt.Errorf("未查询到该平台门店,平台门店ID:[%v]", vendorStoreID) + if vendorStoreID != "" { + result2, _ := api.JdShopAPI.QueryEntityStore(utils.Str2Int64(vendorStoreID)) + if result2 == nil { + return storeDetail, fmt.Errorf("未查询到该平台门店,平台门店ID:[%v]", vendorStoreID) + } + storeDetail = &dao.StoreDetail{} + storeDetail.ID = utils.Str2Int(result2.ExStoreID) + storeDetail.Name = result2.StoreName + storeDetail.Address = result2.Address + storeDetail.Tel1 = result2.Phone + storeDetail.DistrictCode = result2.AddrCode + zbs := strings.Split(result2.Coordinate, ",") + storeDetail.Lat = jxutils.StandardCoordinate2Int(utils.Str2Float64(zbs[0])) + storeDetail.Lng = jxutils.StandardCoordinate2Int(utils.Str2Float64(zbs[1])) } - storeDetail = &dao.StoreDetail{} - storeDetail.ID = utils.Str2Int(result2.ExStoreID) - storeDetail.Name = result2.StoreName - storeDetail.Address = result2.Address - storeDetail.Tel1 = result2.Phone - storeDetail.DistrictCode = result2.AddrCode - zbs := strings.Split(result2.Coordinate, ",") - storeDetail.Lat = jxutils.StandardCoordinate2Int(utils.Str2Float64(zbs[0])) - storeDetail.Lng = jxutils.StandardCoordinate2Int(utils.Str2Float64(zbs[1])) return storeDetail, err } From 11513a7415a559be7162af3b8fdc7d7b1e20c57d Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 09:08:36 +0800 Subject: [PATCH 05/18] aa --- business/jxstore/cms/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 2eef60f80..79e91addf 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -400,7 +400,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte if params["earningType"] != nil { if params["earningType"].(int) != 0 { if params["earningType"].(int) == 1 { - sqlWhere += " AND t1.pay_percentage = 100" + sqlWhere += " AND t1.pay_percentage >= 50" } else { sqlWhere += " AND t1.pay_percentage < 50" } From 3eda219ba9abc0041469606aff1325130e833535 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 09:43:17 +0800 Subject: [PATCH 06/18] aa --- business/jxstore/cms/store.go | 56 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 79e91addf..c1e5e0b48 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -438,6 +438,14 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte } } + if params["mapLongitude"] != nil && params["mapLatitude"] != nil && params["mapRadius"] != nil { + mapLongitude := utils.Str2Float64(params["mapLongitude"].(string)) + mapLatitude := utils.Str2Float64(params["mapLatitude"].(string)) + mapRadius := params["mapRadius"].(int) + sqlWhere += " AND getDistance(?, ?, CAST(t1.lng AS DECIMAL(15,6))/1000000, CAST(t1.lat AS DECIMAL(15,6))/1000000) * 1000 <= ?" + sqlWhereParams = append(sqlWhereParams, mapLongitude, mapLatitude, mapRadius) + } + sql = sqlFrom + sqlWhere sqlParams = append(sqlParams, sqlFromParams...) sqlParams = append(sqlParams, sqlWhereParams...) @@ -512,8 +520,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa sql = ` SELECT DISTINCT t1.*, - CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng, - CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat, + -- CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng, + -- CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat, IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, bank.value payee_bank_name, IF(om.name <> '', om.name, om.user_id2) operator_name, @@ -536,33 +544,33 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa var storeList []*StoreExt offset = jxutils.FormalizePageOffset(offset) pageSize = jxutils.FormalizePageSize(pageSize) - mapLimit := false + //mapLimit := false // globals.SugarLogger.Debug(sql) // globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil { // 地图区域限制过滤 - if mapLongitude2, ok := params["mapLongitude"].(string); ok { - var ( - mapLatitude, mapLongitude float64 - mapRadius int - ) - mapLimit = true - mapLongitude = utils.Str2Float64(mapLongitude2) - mapLatitude = utils.Str2Float64(params["mapLatitude"].(string)) - mapRadius = params["mapRadius"].(int) - for _, v := range storeList { - valid := !mapLimit - if mapLimit { - valid = jxutils.EarthDistance(mapLongitude, mapLatitude, v.FloatLng, v.FloatLat)*1000 <= float64(mapRadius) - } - if valid { - retVal.Stores = append(retVal.Stores, v) - } - } - } else { - retVal.Stores = storeList - } + //if mapLongitude2, ok := params["mapLongitude"].(string); ok { + // var ( + // mapLatitude, mapLongitude float64 + // mapRadius int + // ) + // mapLimit = true + // mapLongitude = utils.Str2Float64(mapLongitude2) + // mapLatitude = utils.Str2Float64(params["mapLatitude"].(string)) + // mapRadius = params["mapRadius"].(int) + // for _, v := range storeList { + // valid := !mapLimit + // if mapLimit { + // valid = jxutils.EarthDistance(mapLongitude, mapLatitude, v.FloatLng, v.FloatLat)*1000 <= float64(mapRadius) + // } + // if valid { + // retVal.Stores = append(retVal.Stores, v) + // } + // } + //} else { + // retVal.Stores = storeList + //} //权限 if permission.IsRoled(ctx) { if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil { From 9304dd11660fe3591e65772724bd19f80376c6b0 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 09:45:16 +0800 Subject: [PATCH 07/18] aa --- business/jxstore/cms/store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index c1e5e0b48..c14522dcb 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -545,8 +545,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa offset = jxutils.FormalizePageOffset(offset) pageSize = jxutils.FormalizePageSize(pageSize) //mapLimit := false - // globals.SugarLogger.Debug(sql) - // globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) + globals.SugarLogger.Debug(sql) + globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil { // 地图区域限制过滤 From 3ab0b3bf6cc51adafe9accb5aae9fb03971645a2 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 10:04:07 +0800 Subject: [PATCH 08/18] aa --- business/jxstore/cms/store.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index c14522dcb..eedcf80b6 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -545,10 +545,11 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa offset = jxutils.FormalizePageOffset(offset) pageSize = jxutils.FormalizePageSize(pageSize) //mapLimit := false - globals.SugarLogger.Debug(sql) - globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) + //globals.SugarLogger.Debug(sql) + //globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil { + fmt.Println("111111111111111111111111111111", utils.Format4Output(storeList, true)) // 地图区域限制过滤 //if mapLongitude2, ok := params["mapLongitude"].(string); ok { // var ( From 2edb3d15e539b2caa27fcc3b545e92ba2fdfff6a Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 10:09:50 +0800 Subject: [PATCH 09/18] aa --- business/jxstore/cms/store.go | 73 ++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index eedcf80b6..a9527ab2e 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -512,6 +512,37 @@ func setStoreMapInfo(ctx *jxcontext.Context, db *dao.DaoDB, storesInfo *StoresIn // todo 门店绑定信息可以考虑以数组形式返回,而不是现在这样 func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interface{}, offset, pageSize int, orderTimeFrom, orderTimeTo time.Time, orderCountFrom, orderCountTo int) (retVal *StoresInfo, err error) { briefLevel := int(utils.ForceInterface2Int64(params["briefLevel"])) + //权限 + //权限 + if permission.IsRoled(ctx) { + if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil { + var storeIDs2 []int + if params["storeIDs"] != nil { + var storeIDs []int + if err = utils.UnmarshalUseNumber([]byte(params["storeIDs"].(string)), &storeIDs); err == nil { + for _, v := range storeIDs { + if storeIDsMap[v] != 0 { + storeIDs2 = append(storeIDs2, v) + } + } + } + if len(storeIDs2) == 0 { + storeIDs2 = append(storeIDs2, -1) + } + } else { + if len(storeIDsMap) > 0 { + for k, _ := range storeIDsMap { + storeIDs2 = append(storeIDs2, k) + } + } else { + storeIDs2 = append(storeIDs2, -1) + } + } + if data, err := json.Marshal(storeIDs2); err == nil { + params["storeIDs"] = string(data) + } + } + } sql, sqlParams, _, _, err := getStoresSql(ctx, keyword, params, orderTimeFrom, orderTimeTo) if err != nil { @@ -536,6 +567,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa (SELECT COUNT(*) FROM store t11 WHERE t11.link_store_id = t1.id) link_store_count ` + sql + ` ORDER BY t1.id DESC + LIMIT ? OFFSET ? ` db := dao.GetDB() retVal = &StoresInfo{} @@ -544,12 +576,12 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa var storeList []*StoreExt offset = jxutils.FormalizePageOffset(offset) pageSize = jxutils.FormalizePageSize(pageSize) + sqlParams = append(sqlParams, pageSize, offset) //mapLimit := false //globals.SugarLogger.Debug(sql) //globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil { - fmt.Println("111111111111111111111111111111", utils.Format4Output(storeList, true)) // 地图区域限制过滤 //if mapLongitude2, ok := params["mapLongitude"].(string); ok { // var ( @@ -572,35 +604,22 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa //} else { // retVal.Stores = storeList //} - //权限 - if permission.IsRoled(ctx) { - if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil { - var storeList2 []*StoreExt - for _, v := range retVal.Stores { - if storeIDsMap[v.ID] != 0 { - storeList2 = append(storeList2, v) - } - } - retVal.Stores = nil - retVal.Stores = storeList2 - } - } // 订单情况过滤 - storeList, err = filterStoreByOrderInfo(db, retVal.Stores, orderTimeFrom, orderTimeTo, orderCountFrom, orderCountTo) - if err != nil { - return nil, err - } + //storeList, err = filterStoreByOrderInfo(db, retVal.Stores, orderTimeFrom, orderTimeTo, orderCountFrom, orderCountTo) + //if err != nil { + // return nil, err + //} // 分页 - retVal.TotalCount = len(storeList) - retVal.Stores = nil - for i := offset; i < offset+pageSize && i < len(storeList); i++ { - storeIDs = append(storeIDs, storeList[i].ID) - retVal.Stores = append(retVal.Stores, storeList[i]) - } - if len(storeIDs) == 0 { - return retVal, nil - } + //retVal.TotalCount = len(storeList) + //retVal.Stores = nil + //for i := offset; i < offset+pageSize && i < len(storeList); i++ { + // storeIDs = append(storeIDs, storeList[i].ID) + // retVal.Stores = append(retVal.Stores, storeList[i]) + //} + //if len(storeIDs) == 0 { + // return retVal, nil + //} // 导出门店地图标信息时,可能会需要转换门店坐标 needConver2Baidu := int(utils.Interface2Int64WithDefault(params["coordinateType"], 0)) == model.CoordinateTypeBaiDu From dd0992a5456c8d2820ce00bbe3af346eb9a4596c Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 10:37:03 +0800 Subject: [PATCH 10/18] aa --- business/jxstore/cms/store.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index a9527ab2e..c5996c7ba 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -513,7 +513,6 @@ func setStoreMapInfo(ctx *jxcontext.Context, db *dao.DaoDB, storesInfo *StoresIn func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interface{}, offset, pageSize int, orderTimeFrom, orderTimeTo time.Time, orderCountFrom, orderCountTo int) (retVal *StoresInfo, err error) { briefLevel := int(utils.ForceInterface2Int64(params["briefLevel"])) //权限 - //权限 if permission.IsRoled(ctx) { if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil { var storeIDs2 []int @@ -544,12 +543,12 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa } } sql, sqlParams, _, _, err := getStoresSql(ctx, keyword, params, orderTimeFrom, orderTimeTo) - if err != nil { return nil, err } sql = ` SELECT + SQL_CALC_FOUND_ROWS DISTINCT t1.*, -- CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng, -- CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat, @@ -580,8 +579,10 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa //mapLimit := false //globals.SugarLogger.Debug(sql) //globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) - - if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil { + txDB , _ := dao.Begin(db) + if err = dao.GetRowsTx(txDB, &storeList, sql, sqlParams...); err == nil { + retVal.Stores = storeList + retVal.TotalCount = dao.GetLastTotalRowCount2(db, txDB) // 地图区域限制过滤 //if mapLongitude2, ok := params["mapLongitude"].(string); ok { // var ( @@ -648,10 +649,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa task.Run() task.GetResult(0) } - } else { - return nil, err } - + dao.Commit(db, txDB) if len(retVal.Stores) > 0 { setStoreMapInfo(ctx, db, retVal, storeIDs, briefLevel, params["isBussinessStatus"]) retVal.MapCenterLng, retVal.MapCenterLat = getMapCenter(retVal.Stores) From 433a14e9359fd008656c90bbd3c82b04b4b8918c Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 10:40:33 +0800 Subject: [PATCH 11/18] aa --- business/jxstore/cms/store.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index c5996c7ba..e9c565aa6 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -550,8 +550,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa SELECT SQL_CALC_FOUND_ROWS DISTINCT t1.*, - -- CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng, - -- CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat, + CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng, + CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat, IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, bank.value payee_bank_name, IF(om.name <> '', om.name, om.user_id2) operator_name, @@ -579,10 +579,10 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa //mapLimit := false //globals.SugarLogger.Debug(sql) //globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) - txDB , _ := dao.Begin(db) + txDB, _ := dao.Begin(db) if err = dao.GetRowsTx(txDB, &storeList, sql, sqlParams...); err == nil { retVal.Stores = storeList - retVal.TotalCount = dao.GetLastTotalRowCount2(db, txDB) + retVal.TotalCount = dao.GetLastTotalRowCount2(db, txDB) // 地图区域限制过滤 //if mapLongitude2, ok := params["mapLongitude"].(string); ok { // var ( From 947833a28fe81e5a7b940018a3eb68bbf44294bf Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 10:53:17 +0800 Subject: [PATCH 12/18] aa --- business/model/store.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/business/model/store.go b/business/model/store.go index ee41b49ef..a9787cac8 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -427,13 +427,13 @@ type StoreMap struct { VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` Status int `json:"status"` // 取值同Store.Status + IsOnline int `json:"isOnline"` //上下线状态, 0是下线,1是上线 StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字,由平台到京西 VendorStoreName string `orm:"size(255)" json:"vendorStoreName"` //平台门店名,由京西到平台 VendorPayPercentage int `json:"vendorPayPercentage"` //平台结算比例 - PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格 - PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` // - + PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格 + PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` // FreightDeductionPack string `orm:"size(32)" json:"freightDeductionPack"` // AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货 From 5acc9f31f6dd48714fd6b910827366892bb2de26 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 11:21:09 +0800 Subject: [PATCH 13/18] aa --- business/jxstore/cms/store.go | 86 +++++++++++++++++++++++------------ business/jxstore/misc/misc.go | 2 + business/model/store.go | 2 +- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index e9c565aa6..c5f6f5ad8 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -461,12 +461,12 @@ func setStoreMapInfo(ctx *jxcontext.Context, db *dao.DaoDB, storesInfo *StoresIn if err != nil { return err } - isStoreVendorStatus := false - if isBussinessStatus != nil { - if isBussinessStatus.(bool) { - isStoreVendorStatus = true - } - } + //isStoreVendorStatus := false + //if isBussinessStatus != nil { + // if isBussinessStatus.(bool) { + // isStoreVendorStatus = true + // } + //} storeMapMap := dao.StoreMapList2Map(storeMapList) storeCourierMap := dao.StoreCourierList2Map(storeCourierList) @@ -486,26 +486,26 @@ func setStoreMapInfo(ctx *jxcontext.Context, db *dao.DaoDB, storesInfo *StoresIn v.CourierMaps = append(v.CourierMaps, v2) } } - task := tasksch.NewParallelTask("上下线状态", tasksch.NewParallelConfig().SetParallelCount(4), ctx, - func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { - store := batchItemList[0].(*StoreExt) - for _, v2 := range store.StoreMaps { - if isStoreVendorStatus { - if handler := CurVendorSync.GetStoreHandler(v2.VendorID); handler != nil { - if store, err := handler.ReadStore(ctx, v2.VendorOrgCode, v2.VendorStoreID); err == nil && store != nil { - if store.Status != model.StoreStatusDisabled { - v2.BussinessStatus = 1 - } else { - v2.BussinessStatus = -1 - } - } - } - } - } - return retVal, err - }, storesInfo.Stores) - task.Run() - task.GetResult(0) + //task := tasksch.NewParallelTask("上下线状态", tasksch.NewParallelConfig().SetParallelCount(4), ctx, + // func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + // store := batchItemList[0].(*StoreExt) + // for _, v2 := range store.StoreMaps { + // if isStoreVendorStatus { + // if handler := CurVendorSync.GetStoreHandler(v2.VendorID); handler != nil { + // if store, err := handler.ReadStore(ctx, v2.VendorOrgCode, v2.VendorStoreID); err == nil && store != nil { + // if store.Status != model.StoreStatusDisabled { + // v2.BussinessStatus = 1 + // } else { + // v2.BussinessStatus = -1 + // } + // } + // } + // } + // } + // return retVal, err + // }, storesInfo.Stores) + //task.Run() + //task.GetResult(0) return nil } @@ -4287,7 +4287,7 @@ func RefreshStoreBind(ctx *jxcontext.Context) (err error) { if store.OperatorPhone3 != "" { mobileList = append(mobileList, store.OperatorPhone3) } - mobileList = append(mobileList, "18160030913", "15520595380", "18980410281", "18048531223", "18080188338", "13012345678") + mobileList = append(mobileList, "18160030913", "15520595380", "18048531223", "18080188338", "13012345678") for _, v := range mobileList { if user, err := dao.GetUserByID(db, "mobile", v); err == nil && user != nil { userIDmap1[user.UserID] = user.UserID @@ -4323,7 +4323,13 @@ func UpdateVendorStoreBussinessStatus(ctx *jxcontext.Context, storeID, vendorID, return err } handler := partner.GetPurchasePlatformFromVendorID(vendorID) - err = handler.UpdateStoreLineStatus(ctx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, status) + if err = handler.UpdateStoreLineStatus(ctx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, status); err == nil { + if storeMaps, _ := dao.GetStoresMapList(db, []int{vendorID}, []int{storeID}, nil, model.StoreStatusAll, + model.StoreIsSyncAll, "", "", ""); len(storeMaps) > 0 { + storeMaps[0].IsOnline = status + dao.UpdateEntity(db, storeMaps[0], "IsOnline") + } + } return err } @@ -5146,3 +5152,27 @@ func UpdateBrandUser(ctx *jxcontext.Context, brandID int, userID string, isDel b } return err } + +func RefreshStoreIsOnline(ctx *jxcontext.Context) (err error) { + var ( + db = dao.GetDB() + ) + stores, _ := dao.GetStoresMapList(db, []int{model.VendorIDMTWM, model.VendorIDJD, model.VendorIDEBAI}, nil, nil, model.StoreStatusAll, model.StoreStatusAll, "", "", "") + task := tasksch.NewParallelTask("RefreshStoreBind", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, + func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + storeMap := batchItemList[0].(*model.StoreMap) + if handler := CurVendorSync.GetStoreHandler(storeMap.VendorID); handler != nil { + if store, err := handler.ReadStore(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID); err == nil && store != nil { + if store.Status != model.StoreStatusDisabled { + storeMap.IsOnline = 1 + } else { + storeMap.IsOnline = -1 + } + } + } + return retVal, err + }, stores) + tasksch.HandleTask(task, nil, true).Run() + task.GetID() + return err +} diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index beff203e4..39554cf64 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -324,6 +324,8 @@ func Init() { RefreshAfsOrderStatusAccess(jxcontext.AdminCtx) //刷新门店分组管理 cms.RefreshStoreBind(jxcontext.AdminCtx) + //更新所有门店的上下线状态 + cms.RefreshStoreIsOnline(jxcontext.AdminCtx) }, dailyWorkTimeList) ScheduleTimerFunc("RrefreshMtwmVendorAct", func() { //刷新美团平台活动 diff --git a/business/model/store.go b/business/model/store.go index a9787cac8..f828ff368 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -427,7 +427,7 @@ type StoreMap struct { VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` Status int `json:"status"` // 取值同Store.Status - IsOnline int `json:"isOnline"` //上下线状态, 0是下线,1是上线 + IsOnline int `json:"isOnline"` //上下线状态, -1是下线,1是上线 StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字,由平台到京西 VendorStoreName string `orm:"size(255)" json:"vendorStoreName"` //平台门店名,由京西到平台 VendorPayPercentage int `json:"vendorPayPercentage"` //平台结算比例 From ed39a2c052b6deb92534e756f52bcde673f46838 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 15:24:47 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E7=89=A9=E7=AB=9E=E5=A4=A9=E6=8B=A9?= =?UTF-8?q?=E5=94=AE=E5=90=8E=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 11 +++++--- business/jxcallback/orderman/orderman_ext.go | 27 +++++++++++++++++--- business/jxstore/misc/misc.go | 11 +++++--- business/jxstore/tempop/tempop.go | 15 ++--------- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 1366b6581..f64427b61 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -2154,12 +2154,15 @@ func RefreshJdAfsOrderTotalShopMoney() { sqlParams := []interface{}{time.Now().AddDate(0, 0, -3), model.VendorIDJD, model.AfsOrderStatusFinished} dao.GetRows(db, &afsOrders, sql, sqlParams) for _, v := range afsOrders { - if handler := partner.GetPurchaseOrderHandlerFromVendorID(v.VendorID); handler != nil { - if orderAfsInfo, err := handler.GetOrderAfsInfo(nil, v.VendorOrderID, v.AfsOrderID); err == nil && orderAfsInfo.AfsTotalShopMoney != 0 { - v.AfsTotalShopMoney = orderAfsInfo.AfsTotalShopMoney + //排除物竞天择的 + if order, _ := partner.CurOrderManager.LoadOrder(v.VendorOrderID, v.VendorID); !strings.Contains(order.BuyerComment, "JD") { + if handler := partner.GetPurchaseOrderHandlerFromVendorID(v.VendorID); handler != nil { + if orderAfsInfo, err := handler.GetOrderAfsInfo(nil, v.VendorOrderID, v.AfsOrderID); err == nil && orderAfsInfo.AfsTotalShopMoney != 0 { + v.AfsTotalShopMoney = orderAfsInfo.AfsTotalShopMoney + } } + dao.UpdateEntity(db, v, "AfsTotalShopMoney") } - dao.UpdateEntity(db, v, "AfsTotalShopMoney") } } diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 617b32ca3..bfd96d50c 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -1563,12 +1563,20 @@ func RefreshJdShopOrdersEarningPrice(ctx *jxcontext.Context, orderStartTime, ord if err != nil { return err } + var afsOrderList []map[*model.AfsOrder]float64 if results != nil { for _, v := range results.BillList.Result { if v.DueAmount != 0 { - order, err := partner.CurOrderManager.LoadOrder(utils.Int64ToStr(v.OrderID), model.VendorIDJD) - if order == nil || err != nil { - continue + order, _ := partner.CurOrderManager.LoadOrder(utils.Int64ToStr(v.OrderID), model.VendorIDJD) + //可能是物竞天择的售后单 + if order == nil { + if afsOrder, _ := partner.CurOrderManager.LoadAfsOrder(utils.Int64ToStr(v.OrderID), model.VendorIDJD); afsOrder != nil { + var afsOrderMap = make(map[*model.AfsOrder]float64) + afsOrderMap[afsOrder] = v.DueAmount + afsOrderList = append(afsOrderList, afsOrderMap) + } else { + continue + } } store, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode) // stores, _ := dao.GetStoreList(db, []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, nil, nil, nil, "") @@ -1584,6 +1592,19 @@ func RefreshJdShopOrdersEarningPrice(ctx *jxcontext.Context, orderStartTime, ord } } } + if len(afsOrderList) > 0 { + for i := len(afsOrderList) - 1; i < 0; i-- { + afsOrderMap := afsOrderList[i] + for k, v := range afsOrderMap { + if order2, _ := partner.CurOrderManager.LoadOrder(k.VendorOrderID, model.VendorIDJD); order2 != nil { + if k.AfsTotalShopMoney == 0 && order2.TotalShopMoney != 0 { + k.AfsTotalShopMoney = order2.TotalShopMoney - utils.Float64TwoInt64(v*100) + dao.UpdateEntity(db, k, "AfsTotalShopMoney") + } + } + } + } + } return err } diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 39554cf64..e817555c3 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -186,12 +186,19 @@ func Init() { orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-30*time.Minute), time.Now()) }, 5*time.Second, 10*time.Minute) + //刷新京东物竞天择订单结算价 ScheduleTimerFunc("RefreshJdShopOrdersEarningPrice", func() { orderman.RefreshJdShopOrdersEarningPrice(jxcontext.AdminCtx, utils.Time2Str(time.Now().AddDate(0, 0, -2)), utils.Time2Str(time.Now().AddDate(0, 0, -2))) orderman.RefreshJdShopOrdersEarningPrice(jxcontext.AdminCtx, utils.Time2Str(time.Now().AddDate(0, 0, -1)), utils.Time2Str(time.Now().AddDate(0, 0, -1))) }, []string{ "05:00:00", }) + //刷新京东售后单结算价 + ScheduleTimerFunc("RefreshJdAfsOrderTotalShopMoney", func() { + orderman.RefreshJdAfsOrderTotalShopMoney() + }, []string{ + "05:30:00", + }) ScheduleTimerFunc("auto enable remote store", func() { cms.EnableHaveRestStores(jxcontext.AdminCtx, false, true) @@ -276,10 +283,6 @@ func Init() { ScheduleTimerFunc("SendQywxPeopleCount", func() { cms.SendQywxPeopleCount(jxcontext.AdminCtx) }, dailyHeartbeat) - //刷新京东售后单结算价 - ScheduleTimerFunc("RefreshJdAfsOrderTotalShopMoney", func() { - orderman.RefreshJdAfsOrderTotalShopMoney() - }, openRemoteStoreTimeList) ScheduleTimerFunc("doDailyWork1", func() { //同步商品额外前缀和水印图(打标记) cms.SyncSkuExperfixAndWatermark(jxcontext.AdminCtx) diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index 330445599..9c6412124 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -4,8 +4,6 @@ import ( "bytes" "context" "fmt" - dyvmsapiclient "github.com/alibabacloud-go/dyvmsapi-20170525-2.0.2/client" - "github.com/alibabacloud-go/tea/tea" "net" "regexp" "strconv" @@ -1987,17 +1985,8 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { // } // go connHandler(conn, "1e000f02000151323032313036313530303030313"+utils.Int2Str(i)+"00000033") //} - mobileNum := "18160030913" - templateParam := map[string]interface{}{ - "tel": "111111", - } - request := &dyvmsapiclient.SingleCallByTtsRequest{ - CalledNumber: tea.String(mobileNum), - TtsCode: tea.String(globals.SMSVoicePickOrderTemplate), - TtsParam: tea.String(string(utils.MustMarshal(templateParam))), - } - _, _err := api.VoiceClient.SingleCallByTts(request) - return _err + cms.RefreshStoreIsOnline(jxcontext.AdminCtx) + return err } func Hextob(str string) []byte { From edc1eadec952c448d0befb03df46ca11eec88302 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 15:28:19 +0800 Subject: [PATCH 15/18] aa --- business/jxstore/cms/store.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index c5f6f5ad8..2af99d890 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -5168,6 +5168,7 @@ func RefreshStoreIsOnline(ctx *jxcontext.Context) (err error) { } else { storeMap.IsOnline = -1 } + dao.UpdateEntity(db, storeMap, "IsOnline") } } return retVal, err From 0f265afa77ff56b42a212156b3468d0cc5b11be7 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 15:32:10 +0800 Subject: [PATCH 16/18] aa --- business/jxstore/cms/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 2af99d890..58af721e8 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -5157,7 +5157,7 @@ func RefreshStoreIsOnline(ctx *jxcontext.Context) (err error) { var ( db = dao.GetDB() ) - stores, _ := dao.GetStoresMapList(db, []int{model.VendorIDMTWM, model.VendorIDJD, model.VendorIDEBAI}, nil, nil, model.StoreStatusAll, model.StoreStatusAll, "", "", "") + stores, _ := dao.GetStoresMapList(db, []int{model.VendorIDMTWM, model.VendorIDJD, model.VendorIDEBAI}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "") task := tasksch.NewParallelTask("RefreshStoreBind", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeMap := batchItemList[0].(*model.StoreMap) From aa1561e6b1f51ae2e6e286bdc24565f919f889c0 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 15:57:43 +0800 Subject: [PATCH 17/18] aa --- business/jxstore/cms/store.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 58af721e8..6834b22f6 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -529,12 +529,18 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa storeIDs2 = append(storeIDs2, -1) } } else { - if len(storeIDsMap) > 0 { - for k, _ := range storeIDsMap { - storeIDs2 = append(storeIDs2, k) + if params["storeID"] != nil { + if storeIDsMap[int(utils.Interface2Int64WithDefault(params["storeID"], 0))] == 0 { + params["storeID"] = nil } } else { - storeIDs2 = append(storeIDs2, -1) + if len(storeIDsMap) > 0 { + for k, _ := range storeIDsMap { + storeIDs2 = append(storeIDs2, k) + } + } else { + storeIDs2 = append(storeIDs2, -1) + } } } if data, err := json.Marshal(storeIDs2); err == nil { From de9590fb1b78001f08032324c23ac8842bb08d34 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 16:18:25 +0800 Subject: [PATCH 18/18] aa --- business/jxstore/cms/sku.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index dfdcac1c0..541dd772b 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -107,16 +107,16 @@ func GetCategories(ctx *jxcontext.Context, parentID int, isExd bool) (catList [] for _, v := range cats { ids = append(ids, v.ID) } - thingMapMap, err2 := dao.GetThingMapMap(db, model.ThingTypeCategory, nil, ids) + //thingMapMap, err2 := dao.GetThingMapMap(db, model.ThingTypeCategory, nil, ids) // globals.SugarLogger.Debug(utils.Format4Output(thingMapMap, false)) - if err = err2; err == nil { - for _, v := range cats { - catList = append(catList, &dao.SkuCategoryWithVendor{ - SkuCategory: v, - MapList: thingMapMap[int64(v.ID)], - }) - } + //if err = err2; err == nil { + for _, v := range cats { + catList = append(catList, &dao.SkuCategoryWithVendor{ + SkuCategory: v, + //MapList: thingMapMap[int64(v.ID)], + }) } + //} } return catList, err }