JdStoreInfo1125
This commit is contained in:
@@ -8,11 +8,13 @@ import (
|
||||
"image/png"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/delivery"
|
||||
"github.com/360EntSecGroup-Skylar/excelize"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
@@ -1302,3 +1304,58 @@ func FixMtwmCategory(ctx *jxcontext.Context, mtwmStoreIDs []int, isAsync, isCont
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func JdStoreInfo1125() (hint string, err error) {
|
||||
fileName := "/Users/xujianhua/Downloads/老格恢复拓店进度.xlsx"
|
||||
db := dao.GetDB()
|
||||
storeList, err := dao.GetStoresMapList(db, []int{model.VendorIDJD}, nil, model.StoreStatusAll, model.StoreIsSyncYes, "")
|
||||
if err == nil {
|
||||
var validStoreList []*dao.StoreDetail
|
||||
for _, v := range storeList {
|
||||
if v.Status != model.StoreStatusDisabled && v.CreatedAt.Sub(utils.Str2Time("2019-10-01")) > 0 {
|
||||
storeInfo, err := api.JdAPI.GetStoreInfoByStationNo2(v.VendorStoreID)
|
||||
if err == nil && storeInfo.CreateTime.GoTime().Sub(utils.Str2Time("2019-10-25")) > 0 {
|
||||
if storeDetail, err := dao.GetStoreDetail(db, v.StoreID, v.VendorID); err == nil {
|
||||
validStoreList = append(validStoreList, storeDetail)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
getStoreList := func(lng, lat, lng2, lat2 int) (vendorStoreIDs []string) {
|
||||
for _, v := range validStoreList {
|
||||
if v.Lng >= lng && v.Lng <= lng2 && v.Lat >= lat && v.Lat <= lat2 {
|
||||
vendorStoreIDs = append(vendorStoreIDs, v.VendorStoreID)
|
||||
}
|
||||
}
|
||||
return vendorStoreIDs
|
||||
}
|
||||
sheetName := "老格明细"
|
||||
file, err2 := excelize.OpenFile(fileName)
|
||||
if err = err2; err == nil {
|
||||
// globals.SugarLogger.Debug(err, file)
|
||||
rows, err2 := file.GetRows(sheetName)
|
||||
if err = err2; err == nil {
|
||||
str2Coords := func(str string) (lng, lat int) {
|
||||
list := strings.Split(str, ",")
|
||||
if len(list) >= 2 {
|
||||
lng, lat = jxutils.StandardCoordinate2Int(utils.Str2Float64WithDefault(list[1], 0)), jxutils.StandardCoordinate2Int(utils.Str2Float64WithDefault(list[0], 0))
|
||||
}
|
||||
return lng, lat
|
||||
}
|
||||
for i := 1; i < len(rows); i++ {
|
||||
lng, lat := str2Coords(rows[i][8])
|
||||
lng2, lat2 := str2Coords(rows[i][7])
|
||||
vendorStoreIDs := getStoreList(lng, lat, lng2, lat2)
|
||||
// fmt.Printf("%d,%v", i, vendorStoreIDs)
|
||||
countInfo := fmt.Sprintf("京西已拓%d", len(vendorStoreIDs))
|
||||
axis, _ := excelize.CoordinatesToCellName(5, i+1)
|
||||
file.SetCellStr(sheetName, axis, countInfo)
|
||||
axis2, _ := excelize.CoordinatesToCellName(6, i+1)
|
||||
file.SetCellStr(sheetName, axis2, strings.Join(vendorStoreIDs, ","))
|
||||
}
|
||||
file.SaveAs("ffff.xlsx")
|
||||
}
|
||||
}
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
26
business/jxstore/tempop/tempop_test.go
Normal file
26
business/jxstore/tempop/tempop_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package tempop
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/elm"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/weimob/wsc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
api2.Init()
|
||||
}
|
||||
|
||||
func TestJdStoreInfo1125(t *testing.T) {
|
||||
_, err := JdStoreInfo1125()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user