tt
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
|||||||
"github.com/qiniu/api.v7/storage"
|
"github.com/qiniu/api.v7/storage"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/baseapi/utils/errlist"
|
"git.rosy.net.cn/baseapi/utils/errlist"
|
||||||
@@ -1593,125 +1592,127 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
|
|||||||
// }, []int{0})
|
// }, []int{0})
|
||||||
// tasksch.HandleTask(task, nil, true).Run()
|
// tasksch.HandleTask(task, nil, true).Run()
|
||||||
// _, err = task.GetResult(0)
|
// _, err = task.GetResult(0)
|
||||||
var (
|
//建店
|
||||||
storeMaps []*model.StoreMap
|
// var (
|
||||||
db = dao.GetDB()
|
// storeMaps []*model.StoreMap
|
||||||
)
|
// db = dao.GetDB()
|
||||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil {
|
// )
|
||||||
api.JdShop2API.SetCookieWithStr(configs[0].Value)
|
// if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil {
|
||||||
}
|
// api.JdShop2API.SetCookieWithStr(configs[0].Value)
|
||||||
sql := `
|
// }
|
||||||
SELECT * from store_map where vendor_id = 5 and deleted_at = '1970-01-01 00:00:00' and vendor_org_code = 2 and store_id <> 667281
|
// sql := `
|
||||||
AND store_id <> 100000
|
// SELECT * from store_map where vendor_id = 5 and deleted_at = '1970-01-01 00:00:00' and vendor_org_code = 2 and store_id <> 667281
|
||||||
AND store_id <> 102919
|
// AND store_id <> 100000
|
||||||
AND LENGTH(vendor_store_id) < 9
|
// AND store_id <> 102919
|
||||||
`
|
// AND LENGTH(vendor_store_id) < 9
|
||||||
err = dao.GetRows(db, &storeMaps, sql, nil)
|
// `
|
||||||
for _, v := range storeMaps {
|
// err = dao.GetRows(db, &storeMaps, sql, nil)
|
||||||
store, _ := dao.GetStoreDetail(db, v.StoreID, model.VendorIDJDShop, "2")
|
// for _, v := range storeMaps {
|
||||||
err = api.JdShop2API.DeleteStoresByID(utils.Str2Int64(store.VendorStoreID))
|
// store, _ := dao.GetStoreDetail(db, v.StoreID, model.VendorIDJDShop, "2")
|
||||||
time.Sleep(time.Second)
|
// err = api.JdShop2API.DeleteStoresByID(utils.Str2Int64(store.VendorStoreID))
|
||||||
data, _, _ := jxutils.DownloadFileByURL(jdshopapi.JdsStoreImg)
|
// time.Sleep(time.Second)
|
||||||
url, _ := api.JdShop2API.UploadImageNew(data, "2659335b16e3880e367759b8fc675933.tem.png")
|
// data, _, _ := jxutils.DownloadFileByURL(jdshopapi.JdsStoreImg)
|
||||||
ex := store.LicenceExpire
|
// url, _ := api.JdShop2API.UploadImageNew(data, "2659335b16e3880e367759b8fc675933.tem.png")
|
||||||
if ex == "" {
|
// ex := store.LicenceExpire
|
||||||
ex = utils.Time2Str(utils.Str2Time(store.LicenceValid).AddDate(0, 6, 0))
|
// if ex == "" {
|
||||||
}
|
// ex = utils.Time2Str(utils.Str2Time(store.LicenceValid).AddDate(0, 6, 0))
|
||||||
if !strings.Contains(ex, "00:00:00") {
|
// }
|
||||||
ex += " 00:00:00"
|
// if !strings.Contains(ex, "00:00:00") {
|
||||||
}
|
// ex += " 00:00:00"
|
||||||
var url2 string
|
// }
|
||||||
if store.Licence != "" {
|
// var url2 string
|
||||||
data2, _, _ := jxutils.DownloadFileByURL(store.Licence)
|
// if store.Licence != "" {
|
||||||
fileName := store.Licence[strings.LastIndex(store.Licence, "/")+1 : len(store.Licence)]
|
// data2, _, _ := jxutils.DownloadFileByURL(store.Licence)
|
||||||
url2, _ = api.JdShop2API.UploadImageNew(data2, fileName)
|
// fileName := store.Licence[strings.LastIndex(store.Licence, "/")+1 : len(store.Licence)]
|
||||||
}
|
// url2, _ = api.JdShop2API.UploadImageNew(data2, fileName)
|
||||||
storeName := store.Name
|
// }
|
||||||
if strings.Contains(storeName, "(") {
|
// storeName := store.Name
|
||||||
storeName = storeName[0:strings.Index(storeName, "(")] + storeName[strings.Index(storeName, ")")+3:len(storeName)]
|
// if strings.Contains(storeName, "(") {
|
||||||
}
|
// storeName = storeName[0:strings.Index(storeName, "(")] + storeName[strings.Index(storeName, ")")+3:len(storeName)]
|
||||||
if strings.Contains(storeName, "(") {
|
// }
|
||||||
storeName = storeName[0:strings.Index(storeName, "(")] + storeName[strings.Index(storeName, ")")+3:len(storeName)]
|
// if strings.Contains(storeName, "(") {
|
||||||
}
|
// storeName = storeName[0:strings.Index(storeName, "(")] + storeName[strings.Index(storeName, ")")+3:len(storeName)]
|
||||||
if strings.Contains(storeName, ".") {
|
// }
|
||||||
storeName = strings.ReplaceAll(storeName, ".", "")
|
// if strings.Contains(storeName, ".") {
|
||||||
}
|
// storeName = strings.ReplaceAll(storeName, ".", "")
|
||||||
if strings.Contains(storeName, "-") {
|
// }
|
||||||
storeName = strings.ReplaceAll(storeName, "-", "")
|
// if strings.Contains(storeName, "-") {
|
||||||
}
|
// storeName = strings.ReplaceAll(storeName, "-", "")
|
||||||
if strings.Contains(storeName, " ") {
|
// }
|
||||||
storeName = strings.ReplaceAll(storeName, " ", "")
|
// if strings.Contains(storeName, " ") {
|
||||||
}
|
// storeName = strings.ReplaceAll(storeName, " ", "")
|
||||||
storeName = "京西菜市" + strings.ReplaceAll(storeName, "店", "") + "生鲜店"
|
// }
|
||||||
if len(storeName) > 30 {
|
// storeName = "京西菜市" + strings.ReplaceAll(storeName, "店", "") + "生鲜店"
|
||||||
storeName = utils.LimitUTF8StringLen2(storeName, 30)
|
// if len(storeName) > 30 {
|
||||||
}
|
// storeName = utils.LimitUTF8StringLen2(storeName, 30)
|
||||||
param := &jdshopapi.UpdateBasicParam{
|
// }
|
||||||
StoreName: storeName,
|
// param := &jdshopapi.UpdateBasicParam{
|
||||||
CategoryID2: 4,
|
// StoreName: storeName,
|
||||||
Coordinate: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)) + "," + utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)),
|
// CategoryID2: 4,
|
||||||
BussinessBeginTime: int2TimeStr(int(store.OpenTime1)),
|
// Coordinate: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)) + "," + utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)),
|
||||||
BussinessEndTime: int2TimeStr(int(store.CloseTime1)),
|
// BussinessBeginTime: int2TimeStr(int(store.OpenTime1)),
|
||||||
ImgURL: url,
|
// BussinessEndTime: int2TimeStr(int(store.CloseTime1)),
|
||||||
StorePhone: store.Tel1,
|
// ImgURL: url,
|
||||||
AddName: store.Address,
|
// StorePhone: store.Tel1,
|
||||||
AddCode3: store.JdsCode,
|
// AddName: store.Address,
|
||||||
CategoryID1: 3,
|
// AddCode3: store.JdsCode,
|
||||||
}
|
// CategoryID1: 3,
|
||||||
if url2 != "" {
|
// }
|
||||||
param.CategoryID1 = 34
|
// if url2 != "" {
|
||||||
param.CategoryID2 = 62
|
// param.CategoryID1 = 34
|
||||||
param.QualificationRequests = []*jdshopapi.QualificationRequests{
|
// param.CategoryID2 = 62
|
||||||
&jdshopapi.QualificationRequests{
|
// param.QualificationRequests = []*jdshopapi.QualificationRequests{
|
||||||
QualificationID: 41,
|
// &jdshopapi.QualificationRequests{
|
||||||
QualificationName: "营业执照",
|
// QualificationID: 41,
|
||||||
QualificationNo: store.LicenceCode,
|
// QualificationName: "营业执照",
|
||||||
QualificationURL: url2,
|
// QualificationNo: store.LicenceCode,
|
||||||
StartTime: utils.Time2Str(utils.Str2Time(store.LicenceValid)),
|
// QualificationURL: url2,
|
||||||
EndingTime: ex,
|
// StartTime: utils.Time2Str(utils.Str2Time(store.LicenceValid)),
|
||||||
Time: []string{utils.Time2Str(utils.Str2Time(store.LicenceValid)), ex},
|
// EndingTime: ex,
|
||||||
},
|
// Time: []string{utils.Time2Str(utils.Str2Time(store.LicenceValid)), ex},
|
||||||
}
|
// },
|
||||||
}
|
// }
|
||||||
if store.JdsStreetCode != 0 {
|
// }
|
||||||
param.AddCode3 = store.JdsStreetCode
|
// if store.JdsStreetCode != 0 {
|
||||||
}
|
// param.AddCode3 = store.JdsStreetCode
|
||||||
if param.AddCode3 == 0 {
|
// }
|
||||||
param.AddCode3 = store.JdCode
|
// if param.AddCode3 == 0 {
|
||||||
}
|
// param.AddCode3 = store.JdCode
|
||||||
//证明这个店可能隶属直辖市或者东莞
|
// }
|
||||||
if model.ZXCityCodeMap[store.CityCode] != "" {
|
// //证明这个店可能隶属直辖市或者东莞
|
||||||
result, _ := api.AutonaviAPI.GetCoordinateAreaInfo(jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat))
|
// if model.ZXCityCodeMap[store.CityCode] != "" {
|
||||||
if result["regeocode"] != nil {
|
// result, _ := api.AutonaviAPI.GetCoordinateAreaInfo(jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat))
|
||||||
street := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})["township"].(string)
|
// if result["regeocode"] != nil {
|
||||||
if street != "" {
|
// street := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})["township"].(string)
|
||||||
result1, _ := api.JdShopAPI.GetProvince()
|
// if street != "" {
|
||||||
for _, v := range result1 {
|
// result1, _ := api.JdShopAPI.GetProvince()
|
||||||
if strings.Contains(store.CityName, v.AreaName) {
|
// for _, v := range result1 {
|
||||||
result2, _ := api.JdShopAPI.GetCity(v.AreaID)
|
// if strings.Contains(store.CityName, v.AreaName) {
|
||||||
for _, vv := range result2 {
|
// result2, _ := api.JdShopAPI.GetCity(v.AreaID)
|
||||||
if strings.Contains(store.DistrictName, vv.AreaName) {
|
// for _, vv := range result2 {
|
||||||
result3, _ := api.JdShopAPI.GetCounty(vv.AreaID)
|
// if strings.Contains(store.DistrictName, vv.AreaName) {
|
||||||
for _, vvv := range result3 {
|
// result3, _ := api.JdShopAPI.GetCounty(vv.AreaID)
|
||||||
if street == vvv.AreaName {
|
// for _, vvv := range result3 {
|
||||||
param.AddCode3 = vvv.AreaID
|
// if street == vvv.AreaName {
|
||||||
break
|
// param.AddCode3 = vvv.AreaID
|
||||||
}
|
// break
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if vendorStroeID, err := api.JdShop2API.SubmitBasic(param); err == nil {
|
// }
|
||||||
v.VendorStoreID = utils.Int64ToStr(vendorStroeID)
|
// if vendorStroeID, err := api.JdShop2API.SubmitBasic(param); err == nil {
|
||||||
dao.UpdateEntity(db, v, "VendorStoreID")
|
// v.VendorStoreID = utils.Int64ToStr(vendorStroeID)
|
||||||
time.Sleep(time.Second)
|
// dao.UpdateEntity(db, v, "VendorStoreID")
|
||||||
err = api.JdShop2API.UpdateExpand(int(vendorStroeID))
|
// time.Sleep(time.Second)
|
||||||
}
|
// err = api.JdShop2API.UpdateExpand(int(vendorStroeID))
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//分类
|
||||||
// var (
|
// var (
|
||||||
// db = dao.GetDB()
|
// db = dao.GetDB()
|
||||||
// )
|
// )
|
||||||
@@ -1744,33 +1745,57 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// var (
|
//门店建商品
|
||||||
// db = dao.GetDB()
|
var (
|
||||||
// )
|
db = dao.GetDB()
|
||||||
// storeSkus, _ := dao.GetStoresSkusInfo(db, []int{model.JdShopMainStoreID2}, nil)
|
storeMaps []*model.StoreMap
|
||||||
// for _, v := range storeSkus {
|
)
|
||||||
// if v.JdsID != 0 {
|
sql := `
|
||||||
// if err = api.JdShop2API.StoreSkuBindStore(false, []string{utils.Int64ToStr(v.JdsID)}, []string{"1000063128"}); err == nil {
|
SELECT *
|
||||||
// storeSkus2, _ := dao.GetStoresSkusInfo(db, []int{667281}, []int{v.SkuID})
|
FROM store_map
|
||||||
// if len(storeSkus2) > 0 {
|
WHERE vendor_id = 5
|
||||||
// status := storeSkus2[0].Status
|
AND deleted_at = '1970-01-01 00:00:00'
|
||||||
// stock := storeSkus2[0].Stock
|
AND vendor_org_code = 2
|
||||||
// price := storeSkus2[0].Price
|
AND store_id <> 667281
|
||||||
// if status == model.StoreSkuBindStatusNormal {
|
AND store_id <> 100000
|
||||||
// api.JdShop2API.StoreWareDoUpdate(status, v.JdsID, "1000063128")
|
AND store_id <> 102919
|
||||||
// }
|
AND store_id = 103075
|
||||||
// if stock != 0 {
|
`
|
||||||
// api.JdShop2API.StoreUpdateStock(stock, v.JdsID, "1000063128")
|
err = dao.GetRows(db, &storeMaps, sql, nil)
|
||||||
// }
|
storeSkus, _ := dao.GetStoresSkusInfo(db, []int{model.JdShopMainStoreID2}, nil)
|
||||||
// api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), v.JdsID, "1000063128")
|
task := tasksch.NewParallelTask("京东商城门店建商品1", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||||
// } else {
|
func(task2 *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
// continue
|
v := batchItemList[0].(*model.StoreSkuBind)
|
||||||
// }
|
if v.JdsID != 0 {
|
||||||
// }
|
task := tasksch.NewParallelTask("京东商城门店建商品2", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||||
// } else {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
// continue
|
storeMap := batchItemList[0].(*model.StoreMap)
|
||||||
// }
|
if err = api.JdShop2API.StoreSkuBindStore(false, []string{utils.Int64ToStr(v.JdsID)}, []string{storeMap.VendorStoreID}); err == nil {
|
||||||
// }
|
storeSkus2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{v.SkuID})
|
||||||
|
if len(storeSkus2) > 0 {
|
||||||
|
status := storeSkus2[0].Status
|
||||||
|
stock := storeSkus2[0].Stock
|
||||||
|
price := storeSkus2[0].Price
|
||||||
|
if status == model.StoreSkuBindStatusNormal {
|
||||||
|
api.JdShop2API.StoreWareDoUpdate(status, v.JdsID, storeMap.VendorStoreID)
|
||||||
|
}
|
||||||
|
if stock != 0 {
|
||||||
|
api.JdShop2API.StoreUpdateStock(stock, v.JdsID, storeMap.VendorStoreID)
|
||||||
|
}
|
||||||
|
api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), v.JdsID, storeMap.VendorStoreID)
|
||||||
|
} else {
|
||||||
|
return retVal, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal, err
|
||||||
|
}, storeMaps)
|
||||||
|
tasksch.HandleTask(task, task2, true).Run()
|
||||||
|
_, err = task.GetResult(0)
|
||||||
|
}
|
||||||
|
return retVal, err
|
||||||
|
}, storeSkus)
|
||||||
|
tasksch.HandleTask(task, nil, true).Run()
|
||||||
|
_, err = task.GetResult(0)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user