京东商城创建门店
This commit is contained in:
@@ -233,13 +233,14 @@ func (v *VendorSync) SyncStore2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs
|
|||||||
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
var resultList []interface{}
|
var resultList []interface{}
|
||||||
|
var vendorStoreID string
|
||||||
storeMap := batchItemList[0].(*model.StoreMap)
|
storeMap := batchItemList[0].(*model.StoreMap)
|
||||||
db2 := db
|
db2 := db
|
||||||
if len(loopMapInfo.StoreMapList) > 1 {
|
if len(loopMapInfo.StoreMapList) > 1 {
|
||||||
db2 = dao.GetDB()
|
db2 = dao.GetDB()
|
||||||
}
|
}
|
||||||
if model.IsSyncStatusNew(storeMap.SyncStatus) {
|
if model.IsSyncStatusNew(storeMap.SyncStatus) {
|
||||||
if err = handler.CreateStore2(db2, storeMap.StoreID, userName); err == nil {
|
if vendorStoreID, err = handler.CreateStore2(db2, storeMap.StoreID, userName); err == nil {
|
||||||
resultList = append(resultList, 1)
|
resultList = append(resultList, 1)
|
||||||
} else {
|
} else {
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeMap.StoreID, model.VendorChineseNames[storeMap.VendorID], "创建门店")
|
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeMap.StoreID, model.VendorChineseNames[storeMap.VendorID], "创建门店")
|
||||||
@@ -258,9 +259,15 @@ func (v *VendorSync) SyncStore2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if model.IsSyncStatusNew(storeMap.SyncStatus) {
|
||||||
|
storeMap.VendorStoreID = vendorStoreID
|
||||||
|
storeMap.SyncStatus = 0
|
||||||
|
_, err = dao.UpdateEntity(db, storeMap, "VendorStoreID", model.FieldSyncStatus)
|
||||||
|
} else {
|
||||||
storeMap.SyncStatus = 0
|
storeMap.SyncStatus = 0
|
||||||
_, err = dao.UpdateEntity(db, storeMap, model.FieldSyncStatus)
|
_, err = dao.UpdateEntity(db, storeMap, model.FieldSyncStatus)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return resultList, err
|
return resultList, err
|
||||||
}, loopMapInfo.StoreMapList)
|
}, loopMapInfo.StoreMapList)
|
||||||
t.AddChild(loopStoreTask).Run()
|
t.AddChild(loopStoreTask).Run()
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ type StoreDetail struct {
|
|||||||
|
|
||||||
DistrictName string `json:"districtName"`
|
DistrictName string `json:"districtName"`
|
||||||
CityName string `json:"cityName"`
|
CityName string `json:"cityName"`
|
||||||
|
ProvinceName string `json:"provinceName"` //省名
|
||||||
|
JdsCode int `json:"jdsCode"` //京东商城地址代码
|
||||||
|
|
||||||
IsAutoOrder int8 `json:"isAutoOrder"` // 平台是否自动接单,-1:否,0:未知,1:是
|
IsAutoOrder int8 `json:"isAutoOrder"` // 平台是否自动接单,-1:否,0:未知,1:是
|
||||||
MarketManName string `json:"marketManName"` //市场负责人
|
MarketManName string `json:"marketManName"` //市场负责人
|
||||||
@@ -96,7 +98,9 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
|||||||
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name, t2.is_order, t2.yb_app_id, t2.yb_app_key, t2.yb_store_prefix,
|
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name, t2.is_order, t2.yb_app_id, t2.yb_app_key, t2.yb_store_prefix,
|
||||||
t3.value price_percentage_pack_str,
|
t3.value price_percentage_pack_str,
|
||||||
t4.value freight_deduction_pack_str,
|
t4.value freight_deduction_pack_str,
|
||||||
|
province.name province_name,
|
||||||
district.name district_name,
|
district.name district_name,
|
||||||
|
district.jds_code jds_code,
|
||||||
city.name city_name,
|
city.name city_name,
|
||||||
IF(mm.name <> '', mm.name, mm.user_id2) market_man_name,
|
IF(mm.name <> '', mm.name, mm.user_id2) market_man_name,
|
||||||
IF(om.name <> '', om.name, om.user_id2) operator_name,
|
IF(om.name <> '', om.name, om.user_id2) operator_name,
|
||||||
@@ -106,6 +110,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
|||||||
LEFT JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
LEFT JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
||||||
LEFT JOIN place city ON city.code = t1.city_code
|
LEFT JOIN place city ON city.code = t1.city_code
|
||||||
LEFT JOIN place district ON district.code = t1.district_code
|
LEFT JOIN place district ON district.code = t1.district_code
|
||||||
|
LEFT JOIN place province ON city.parent_code = province.code
|
||||||
LEFT JOIN new_config t3 ON t3.key = t2.price_percentage_pack AND t3.type = ? AND t3.deleted_at = ?
|
LEFT JOIN new_config t3 ON t3.key = t2.price_percentage_pack AND t3.type = ? AND t3.deleted_at = ?
|
||||||
LEFT JOIN new_config t4 ON t4.key = t2.freight_deduction_pack AND t4.type = ? AND t4.deleted_at = ?
|
LEFT JOIN new_config t4 ON t4.key = t2.freight_deduction_pack AND t4.type = ? AND t4.deleted_at = ?
|
||||||
LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = t1.market_man_phone
|
LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = t1.market_man_phone
|
||||||
|
|||||||
@@ -20,5 +20,5 @@ type Place struct {
|
|||||||
EbaiCode int `orm:"index" json:"ebaiCode"`
|
EbaiCode int `orm:"index" json:"ebaiCode"`
|
||||||
Enabled int8 `json:"enabled"` // 是否启用
|
Enabled int8 `json:"enabled"` // 是否启用
|
||||||
MtpsPrice int `json:"mtpsPrice"` // 分为单位
|
MtpsPrice int `json:"mtpsPrice"` // 分为单位
|
||||||
JdsCode int `orm:"index" json:"jdsCode"` //京东商城代码
|
JdsCode int `json:"jdsCode"` //京东商城代码
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ type IPurchasePlatformHandler interface {
|
|||||||
// Store
|
// Store
|
||||||
ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (store *dao.StoreDetail, err error)
|
ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (store *dao.StoreDetail, err error)
|
||||||
UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error)
|
UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error)
|
||||||
CreateStore2(db *dao.DaoDB, storeID int, userName string) (err error)
|
CreateStore2(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error)
|
||||||
DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error)
|
DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error)
|
||||||
GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error)
|
GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error)
|
||||||
UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error)
|
UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error)
|
||||||
|
|||||||
@@ -535,8 +535,8 @@ func (c *PurchaseHandler) GetShopIDsByPage() (vendorStoreIDs []string, err error
|
|||||||
return vendorStoreIDs, err
|
return vendorStoreIDs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
||||||
return err
|
return vendorStoreID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||||
|
|||||||
@@ -499,8 +499,8 @@ func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgC
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
||||||
return err
|
return vendorStoreID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package jdshop
|
package jdshop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -18,16 +23,31 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
||||||
store, err := dao.GetStoreDetail(db, storeID, model.VendorIDJDShop)
|
store, err := dao.GetStoreDetail(db, storeID, model.VendorIDJDShop)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return vendorStoreID, err
|
||||||
}
|
}
|
||||||
|
data, _, err := jxutils.DownloadFileByURL(jdshopapi.JdsStoreImg)
|
||||||
|
timeMap := map[string]string{
|
||||||
|
"businessBeginTime": int2TimeStr(int(store.OpenTime1)),
|
||||||
|
"businessEndTime": int2TimeStr(int(store.CloseTime1)),
|
||||||
|
}
|
||||||
|
timeJSON, _ := json.Marshal(timeMap)
|
||||||
createEntityStoreParam := &jdshopapi.CreateEntityStoreParam{
|
createEntityStoreParam := &jdshopapi.CreateEntityStoreParam{
|
||||||
Name: store.Name,
|
Name: store.Name,
|
||||||
|
AddCode: store.JdsCode,
|
||||||
|
AddCodeName: store.DistrictName,
|
||||||
|
AddName: store.ProvinceName + store.CityName + store.DistrictName + "@!" + store.Address,
|
||||||
|
Coordinate: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)) + utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)),
|
||||||
|
Phone: store.Tel1,
|
||||||
|
ExtendJSON: string(timeJSON),
|
||||||
|
ImageFile: base64.StdEncoding.EncodeToString(data),
|
||||||
|
CategoryName: jdshopapi.JdsStoreCategoryName,
|
||||||
|
CustomerID: utils.Int2Str(store.ID),
|
||||||
}
|
}
|
||||||
err = api.JdShopAPI.CreateEntityStore(createEntityStoreParam)
|
vendorStoreID, err = api.JdShopAPI.CreateEntityStore(createEntityStoreParam)
|
||||||
return err
|
return vendorStoreID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||||
@@ -61,3 +81,12 @@ func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrg
|
|||||||
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error) {
|
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string, storeID int64) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func int2TimeStr(time int) (str string) {
|
||||||
|
str += utils.Int2Str(time / 1000)
|
||||||
|
str += utils.Int2Str(time % 1000 / 100)
|
||||||
|
str += ":"
|
||||||
|
str += utils.Int2Str(time % 100 / 10)
|
||||||
|
str += utils.Int2Str(time % 10)
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
return p.UpdateStore(db, storeID, userName)
|
return p.UpdateStore(db, storeID, userName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
||||||
return err
|
return vendorStoreID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
||||||
return err
|
return vendorStoreID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user