- 整理partner.ReadStore
This commit is contained in:
@@ -477,10 +477,10 @@ func getMapCenter(storeList []*StoreExt) (lng, lat float64) {
|
|||||||
|
|
||||||
func GetVendorStore(ctx *jxcontext.Context, vendorStoreID string, vendorID int) (retVal *StoreExt, err error) {
|
func GetVendorStore(ctx *jxcontext.Context, vendorStoreID string, vendorID int) (retVal *StoreExt, err error) {
|
||||||
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
||||||
result, err2 := handler.ReadStore(vendorStoreID)
|
result, err2 := handler.ReadStore(ctx, vendorStoreID)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
retVal = &StoreExt{
|
retVal = &StoreExt{
|
||||||
Store: *result,
|
Store: result.Store,
|
||||||
FloatLng: jxutils.IntCoordinate2Standard(result.Lng),
|
FloatLng: jxutils.IntCoordinate2Standard(result.Lng),
|
||||||
FloatLat: jxutils.IntCoordinate2Standard(result.Lat),
|
FloatLat: jxutils.IntCoordinate2Standard(result.Lat),
|
||||||
}
|
}
|
||||||
@@ -727,7 +727,7 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
|
|||||||
}
|
}
|
||||||
userName := ctx.GetUserName()
|
userName := ctx.GetUserName()
|
||||||
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
||||||
store, err2 := handler.ReadStore(storeMap.VendorStoreID)
|
store, err2 := handler.ReadStore(ctx, storeMap.VendorStoreID)
|
||||||
if err = err2; err == nil || storeMap.IsSync == 0 {
|
if err = err2; err == nil || storeMap.IsSync == 0 {
|
||||||
dao.WrapAddIDCULDEntity(storeMap, userName)
|
dao.WrapAddIDCULDEntity(storeMap, userName)
|
||||||
storeMap.StoreID = storeID
|
storeMap.StoreID = storeID
|
||||||
@@ -813,7 +813,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if vendorStoreID := utils.Interface2String(valid["vendorStoreID"]); vendorStoreID != "" {
|
if vendorStoreID := utils.Interface2String(valid["vendorStoreID"]); vendorStoreID != "" {
|
||||||
vendorStoreInfo, err2 := storeHandler.ReadStore(vendorStoreID)
|
vendorStoreInfo, err2 := storeHandler.ReadStore(ctx, vendorStoreID)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
valid["deliveryType"] = vendorStoreInfo.DeliveryType
|
valid["deliveryType"] = vendorStoreInfo.DeliveryType
|
||||||
}
|
}
|
||||||
@@ -1243,7 +1243,7 @@ func GetStoresVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, v
|
|||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
storeMap := batchItemList[0].(*model.StoreMap)
|
storeMap := batchItemList[0].(*model.StoreMap)
|
||||||
if handler := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID); handler != nil {
|
if handler := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID); handler != nil {
|
||||||
store, err2 := handler.ReadStore(storeMap.VendorStoreID)
|
store, err2 := handler.ReadStore(ctx, storeMap.VendorStoreID)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
retVal = []interface{}{&model.VendorStoreSnapshot{
|
retVal = []interface{}{&model.VendorStoreSnapshot{
|
||||||
StoreID: storeMap.StoreID,
|
StoreID: storeMap.StoreID,
|
||||||
|
|||||||
@@ -25,10 +25,8 @@ type StoreDetail struct {
|
|||||||
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
|
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
|
||||||
IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步
|
IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步
|
||||||
|
|
||||||
model.Place // district info
|
DistrictName string `json:"districtName"`
|
||||||
DistrictName string `json:"-"`
|
CityName string `json:"cityName"`
|
||||||
|
|
||||||
CityName string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoreDetail2 struct {
|
type StoreDetail2 struct {
|
||||||
@@ -48,8 +46,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
|||||||
SELECT t1.*,
|
SELECT t1.*,
|
||||||
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status,
|
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status,
|
||||||
t2.price_percentage, t3.value price_percentage_pack_str, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
|
t2.price_percentage, t3.value price_percentage_pack_str, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
|
||||||
district.code, district.name district_name, district.parent_code, district.level, district.tel_code,
|
district.name district_name,
|
||||||
district.jd_code, district.ebai_code, district.enabled, district.mtps_price,
|
|
||||||
city.name city_name
|
city.name city_name
|
||||||
FROM store t1
|
FROM store t1
|
||||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
||||||
@@ -75,7 +72,6 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
|||||||
}
|
}
|
||||||
storeDetail = &StoreDetail{}
|
storeDetail = &StoreDetail{}
|
||||||
if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil {
|
if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil {
|
||||||
storeDetail.Place.Name = storeDetail.DistrictName
|
|
||||||
storeDetail.PricePercentagePackObj = PricePercentagePack2Obj(storeDetail.PricePercentagePackStr)
|
storeDetail.PricePercentagePackObj = PricePercentagePack2Obj(storeDetail.PricePercentagePackStr)
|
||||||
return storeDetail, nil
|
return storeDetail, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,8 +244,6 @@ type Store struct {
|
|||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
||||||
|
|
||||||
DeliveryType int8 `orm:"-" json:"deliveryType"` // 仅用于传值
|
|
||||||
|
|
||||||
PrinterDisabled int8 `orm:"default(0)" json:"printerDisabled"` // 是否禁用网络打印机
|
PrinterDisabled int8 `orm:"default(0)" json:"printerDisabled"` // 是否禁用网络打印机
|
||||||
PrinterVendorID int `orm:"column(printer_vendor_id);" json:"printerVendorID"`
|
PrinterVendorID int `orm:"column(printer_vendor_id);" json:"printerVendorID"`
|
||||||
PrinterSN string `orm:"size(32);column(printer_sn);index" json:"printerSN"`
|
PrinterSN string `orm:"size(32);column(printer_sn);index" json:"printerSN"`
|
||||||
@@ -300,6 +298,23 @@ func (s *Store) IsPrinterDisabled() bool {
|
|||||||
return s.PrinterDisabled != 0
|
return s.PrinterDisabled != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Store) GetOpTimeList() (opTimeList []int16) {
|
||||||
|
opTimeList = []int16{s.OpenTime1, s.CloseTime1}
|
||||||
|
if s.OpenTime2 != 0 {
|
||||||
|
opTimeList = append(opTimeList, s.OpenTime2, s.CloseTime2)
|
||||||
|
}
|
||||||
|
return opTimeList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Store) SetOpTime(opTimeList []int16) {
|
||||||
|
if len(opTimeList) >= 2 {
|
||||||
|
s.OpenTime1, s.CloseTime1 = opTimeList[0], opTimeList[1]
|
||||||
|
if len(opTimeList) >= 4 {
|
||||||
|
s.OpenTime2, s.CloseTime2 = opTimeList[2], opTimeList[3]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type StoreSub struct {
|
type StoreSub struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ type IPurchasePlatformHandler interface {
|
|||||||
|
|
||||||
////////
|
////////
|
||||||
// Store
|
// Store
|
||||||
ReadStore(vendorStoreID string) (store *model.Store, err error)
|
ReadStore(ctx *jxcontext.Context, 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)
|
||||||
GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error)
|
GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error)
|
||||||
// EnableAutoAcceptOrder(vendorStoreID string, isEnabled bool) error
|
// EnableAutoAcceptOrder(vendorStoreID string, isEnabled bool) error
|
||||||
|
|||||||
@@ -71,33 +71,22 @@ func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error) {
|
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) {
|
||||||
baiduShopID := utils.Str2Int64(vendorStoreID)
|
baiduShopID := utils.Str2Int64(vendorStoreID)
|
||||||
result, err := api.EbaiAPI.ShopGet("", baiduShopID)
|
result, err := api.EbaiAPI.ShopGet("", baiduShopID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// globals.SugarLogger.Debug(utils.Format4Output(result, false))
|
globals.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||||
retVal := &model.Store{
|
retVal := &dao.StoreDetail{
|
||||||
Address: utils.Interface2String(result["address"]),
|
Store: model.Store{
|
||||||
Tel1: utils.Interface2String(result["phone"]),
|
Address: utils.Interface2String(result["address"]),
|
||||||
|
Tel1: utils.Interface2String(result["phone"]),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
retVal.OriginalName = utils.Interface2String(result["name"])
|
retVal.OriginalName = utils.Interface2String(result["name"])
|
||||||
_, retVal.Name = jxutils.SplitStoreName(retVal.OriginalName, partner.StoreNameSeparator, VendorStorePrefix)
|
_, retVal.Name = jxutils.SplitStoreName(retVal.OriginalName, partner.StoreNameSeparator, VendorStorePrefix)
|
||||||
retVal.DeliveryType = EbaiDeliveryType2Jx(utils.Interface2String(result["delivery_type"]))
|
retVal.DeliveryType = EbaiDeliveryType2Jx(utils.Interface2String(result["delivery_type"]))
|
||||||
|
|
||||||
if result["business_time"] != nil {
|
retVal.SetOpTime(ebaiOpTime2Jx(result["business_time"]))
|
||||||
businessTime := result["business_time"].([]interface{})
|
|
||||||
if len(businessTime) > 0 {
|
|
||||||
btime := businessTime[0].(map[string]interface{})
|
|
||||||
retVal.OpenTime1 = jxutils.StrTime2JxOperationTime(utils.Interface2String(btime["start"].(string)), 700)
|
|
||||||
retVal.CloseTime1 = jxutils.StrTime2JxOperationTime(utils.Interface2String(btime["end"].(string)), 2000)
|
|
||||||
if len(businessTime) > 1 {
|
|
||||||
btime = businessTime[1].(map[string]interface{})
|
|
||||||
retVal.OpenTime2 = jxutils.StrTime2JxOperationTime(utils.Interface2String(btime["start"].(string)), 700)
|
|
||||||
retVal.CloseTime2 = jxutils.StrTime2JxOperationTime(utils.Interface2String(btime["end"].(string)), 2000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ebaiStatus, err2 := api.EbaiAPI.ShopBusStatusGet("", baiduShopID, ebaiapi.PlatformFlagElm); err2 == nil {
|
if ebaiStatus, err2 := api.EbaiAPI.ShopBusStatusGet("", baiduShopID, ebaiapi.PlatformFlagElm); err2 == nil {
|
||||||
retVal.Status = EbaiBusStatus2JxStatus(ebaiStatus)
|
retVal.Status = EbaiBusStatus2JxStatus(ebaiStatus)
|
||||||
}
|
}
|
||||||
@@ -165,7 +154,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
||||||
shopID = store.ID
|
shopID = store.ID
|
||||||
}
|
}
|
||||||
store2, err2 := p.ReadStore(store.VendorStoreID)
|
store2, err2 := p.ReadStore(jxcontext.AdminCtx, store.VendorStoreID)
|
||||||
// globals.SugarLogger.Debugf("ebai UpdateStore2 store2:%s, err2:%v", utils.Format4Output(store2, true), err2)
|
// globals.SugarLogger.Debugf("ebai UpdateStore2 store2:%s, err2:%v", utils.Format4Output(store2, true), err2)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
if store2.ID == store.ID {
|
if store2.ID == store.ID {
|
||||||
@@ -359,8 +348,18 @@ func fillOpTimeParams(params map[string]interface{}, opTimeList []int16) map[str
|
|||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ebaiOpTime2Jx(businessTime interface{}) (opTimeList []int16) {
|
||||||
|
businessTimeList, _ := businessTime.([]interface{})
|
||||||
|
for _, v := range businessTimeList {
|
||||||
|
vMap := v.(map[string]interface{})
|
||||||
|
opTimeList = append(opTimeList, jxutils.StrTime2JxOperationTime(utils.Interface2String(vMap["start"])+":00", 700),
|
||||||
|
jxutils.StrTime2JxOperationTime(utils.Interface2String(vMap["end"])+":00", 2000))
|
||||||
|
}
|
||||||
|
return opTimeList
|
||||||
|
}
|
||||||
|
|
||||||
func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
||||||
params := fillOpTimeParams(nil, []int16{store.OpenTime1, store.CloseTime1, store.OpenTime2, store.CloseTime2})
|
params := fillOpTimeParams(nil, store.GetOpTimeList())
|
||||||
// if store.Tel2 != "" {
|
// if store.Tel2 != "" {
|
||||||
// params["ivr_phone"] = store.Tel2
|
// params["ivr_phone"] = store.Tel2
|
||||||
// }
|
// }
|
||||||
@@ -431,7 +430,7 @@ func (c *PurchaseHandler) GetShopHealthInfo(vendorShopID string) (shopHealthInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
|
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
|
||||||
store, err := c.ReadStore(vendorStoreID)
|
store, err := c.ReadStore(ctx, vendorStoreID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package ebai
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReadStore(t *testing.T) {
|
func TestReadStore(t *testing.T) {
|
||||||
result, err := new(PurchaseHandler).ReadStore(testShopBaiduID)
|
result, err := CurPurchaseHandler.ReadStore(jxcontext.AdminCtx, testShopBaiduID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
@@ -17,7 +19,7 @@ func TestReadStore(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdateStore(t *testing.T) {
|
func TestUpdateStore(t *testing.T) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
err := new(PurchaseHandler).UpdateStore(db, testShopID, "autotest")
|
err := CurPurchaseHandler.UpdateStore(db, testShopID, "autotest")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
@@ -25,7 +27,7 @@ func TestUpdateStore(t *testing.T) {
|
|||||||
|
|
||||||
func TestCreateStore(t *testing.T) {
|
func TestCreateStore(t *testing.T) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
_, err := new(PurchaseHandler).CreateStore(db, 1, "autotest")
|
_, err := CurPurchaseHandler.CreateStore(db, 1, "autotest")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,10 @@ import (
|
|||||||
|
|
||||||
"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/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error) {
|
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) {
|
||||||
return nil, errors.New("饿了么还没实现")
|
return nil, errors.New("饿了么还没实现")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,17 +32,19 @@ type tJdStoreInfo struct {
|
|||||||
SyncStatus int
|
SyncStatus int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error) {
|
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) {
|
||||||
result, err := api.JdAPI.GetStoreInfoByStationNo(vendorStoreID)
|
result, err := api.JdAPI.GetStoreInfoByStationNo(vendorStoreID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
retVal := &model.Store{
|
retVal := &dao.StoreDetail{
|
||||||
Address: utils.Interface2String(result["stationAddress"]),
|
Store: model.Store{
|
||||||
OpenTime1: JdOperationTime2JxOperationTime(result["serviceTimeStart1"]),
|
Address: utils.Interface2String(result["stationAddress"]),
|
||||||
CloseTime1: JdOperationTime2JxOperationTime(result["serviceTimeEnd1"]),
|
OpenTime1: JdOperationTime2JxOperationTime(result["serviceTimeStart1"]),
|
||||||
OpenTime2: JdOperationTime2JxOperationTime(result["serviceTimeStart2"]),
|
CloseTime1: JdOperationTime2JxOperationTime(result["serviceTimeEnd1"]),
|
||||||
CloseTime2: JdOperationTime2JxOperationTime(result["serviceTimeEnd2"]),
|
OpenTime2: JdOperationTime2JxOperationTime(result["serviceTimeStart2"]),
|
||||||
Status: JdStoreStatus2JxStatus(result["yn"], result["closeStatus"]),
|
CloseTime2: JdOperationTime2JxOperationTime(result["serviceTimeEnd2"]),
|
||||||
Tel1: utils.Interface2String(result["phone"]),
|
Status: JdStoreStatus2JxStatus(result["yn"], result["closeStatus"]),
|
||||||
|
Tel1: utils.Interface2String(result["phone"]),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
retVal.OriginalName = utils.Interface2String(result["stationName"])
|
retVal.OriginalName = utils.Interface2String(result["stationName"])
|
||||||
_, retVal.Name = jxutils.SplitStoreName(retVal.OriginalName, partner.StoreNameSeparator, VendorStorePrefix)
|
_, retVal.Name = jxutils.SplitStoreName(retVal.OriginalName, partner.StoreNameSeparator, VendorStorePrefix)
|
||||||
@@ -118,7 +120,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
"phone": store.Tel1,
|
"phone": store.Tel1,
|
||||||
"mobile": store.Tel2,
|
"mobile": store.Tel2,
|
||||||
}
|
}
|
||||||
fillOpTimeParams(params, []int16{store.OpenTime1, store.CloseTime1, store.OpenTime2, store.CloseTime2})
|
fillOpTimeParams(params, store.GetOpTimeList())
|
||||||
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
|
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
|
||||||
params["stationName"] = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
|
params["stationName"] = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
|
||||||
}
|
}
|
||||||
@@ -192,9 +194,9 @@ func (p *PurchaseHandler) GetAllStoresFromRemote() ([]*model.Store, error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
retVal := make([]*model.Store, len(ids))
|
retVal := make([]*model.Store, len(ids))
|
||||||
for index, id := range ids {
|
for index, id := range ids {
|
||||||
store, err2 := p.ReadStore(id)
|
store, err2 := p.ReadStore(jxcontext.AdminCtx, id)
|
||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
retVal[index] = store
|
retVal[index] = &store.Store
|
||||||
} else {
|
} else {
|
||||||
return nil, err2
|
return nil, err2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
@@ -14,7 +16,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestReadStore(t *testing.T) {
|
func TestReadStore(t *testing.T) {
|
||||||
result, err := new(PurchaseHandler).ReadStore(TestJdStoreNo)
|
result, err := new(PurchaseHandler).ReadStore(jxcontext.AdminCtx, TestJdStoreNo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
@@ -23,7 +25,7 @@ func TestReadStore(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdateStore(t *testing.T) {
|
func TestUpdateStore(t *testing.T) {
|
||||||
handler := new(PurchaseHandler)
|
handler := new(PurchaseHandler)
|
||||||
result, err := handler.ReadStore(TestJdStoreNo)
|
result, err := handler.ReadStore(jxcontext.AdminCtx, TestJdStoreNo)
|
||||||
|
|
||||||
// result := &model.Store{}
|
// result := &model.Store{}
|
||||||
// result.ID = 100164
|
// result.ID = 100164
|
||||||
@@ -40,7 +42,7 @@ func TestUpdateStore(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// same
|
// same
|
||||||
result, err = handler.ReadStore(TestJdStoreNo)
|
result, err = handler.ReadStore(jxcontext.AdminCtx, TestJdStoreNo)
|
||||||
if result.Name != newName {
|
if result.Name != newName {
|
||||||
t.Fatalf("result is not same, desired newName:%s, newName:%s", newName, result.Name)
|
t.Fatalf("result is not same, desired newName:%s, newName:%s", newName, result.Name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,23 +113,21 @@ func rangeJX2Mtwm(coords string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func openTimeMtwm2JX(vendorOpenTime string) [][2]int16 {
|
func openTimeMtwm2JX(vendorOpenTime string) (opTimeList []int16) {
|
||||||
timePairs := strings.Split(vendorOpenTime, ",")
|
timePairs := strings.Split(vendorOpenTime, ",")
|
||||||
jxOpenTimers := make([][2]int16, len(timePairs))
|
for _, v := range timePairs {
|
||||||
for k, v := range timePairs {
|
|
||||||
times := strings.Split(v, "-")
|
times := strings.Split(v, "-")
|
||||||
jxOpenTimers[k][0] = jxutils.StrTime2JxOperationTime(times[0], 700)
|
opTimeList = append(opTimeList, jxutils.StrTime2JxOperationTime(times[0]+":00", 700), jxutils.StrTime2JxOperationTime(times[1]+":00", 2000))
|
||||||
jxOpenTimers[k][1] = jxutils.StrTime2JxOperationTime(times[1], 2000)
|
|
||||||
}
|
}
|
||||||
return jxOpenTimers
|
return opTimeList
|
||||||
}
|
}
|
||||||
|
|
||||||
func openTimeJX2Mtwm(times []int16) string {
|
func openTimeJX2Mtwm(opTimeList []int16) string {
|
||||||
timesLen := len(times) / 2 * 2
|
timesLen := len(opTimeList) / 2 * 2
|
||||||
var strPairs []string
|
var strPairs []string
|
||||||
for i := 0; i < timesLen; i += 2 {
|
for i := 0; i < timesLen; i += 2 {
|
||||||
if times[i] != 0 {
|
if opTimeList[i] != 0 {
|
||||||
strPairs = append(strPairs, jxutils.JxOperationTime2StrTime(times[i])+"-"+jxutils.JxOperationTime2StrTime(times[i+1]))
|
strPairs = append(strPairs, jxutils.JxOperationTime2StrTime(opTimeList[i])+"-"+jxutils.JxOperationTime2StrTime(opTimeList[i+1]))
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,26 +33,20 @@ type tEbaiStoreInfo struct {
|
|||||||
DistrictID int `orm:"column(district_id)"`
|
DistrictID int `orm:"column(district_id)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (retVal *model.Store, err error) {
|
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (retVal *dao.StoreDetail, err error) {
|
||||||
result, err := api.MtwmAPI.PoiGet(vendorStoreID)
|
result, err := api.MtwmAPI.PoiGet(vendorStoreID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// globals.SugarLogger.Debug(utils.Format4Output(result, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||||
retVal = &model.Store{
|
retVal = &dao.StoreDetail{
|
||||||
Address: result.Address,
|
Store: model.Store{
|
||||||
Tel1: result.Phone,
|
Address: result.Address,
|
||||||
|
Tel1: result.Phone,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
retVal.OriginalName = result.Name
|
retVal.OriginalName = result.Name
|
||||||
_, retVal.Name = jxutils.SplitStoreName(retVal.OriginalName, partner.StoreNameSeparator, VendorStorePrefix)
|
_, retVal.Name = jxutils.SplitStoreName(retVal.OriginalName, partner.StoreNameSeparator, VendorStorePrefix)
|
||||||
|
|
||||||
openTimes := openTimeMtwm2JX(result.ShippingTime)
|
retVal.SetOpTime(openTimeMtwm2JX(result.ShippingTime))
|
||||||
if len(openTimes) > 0 {
|
|
||||||
retVal.OpenTime1 = openTimes[0][0]
|
|
||||||
retVal.CloseTime1 = openTimes[0][1]
|
|
||||||
if len(openTimes) > 1 {
|
|
||||||
retVal.OpenTime2 = openTimes[1][0]
|
|
||||||
retVal.CloseTime2 = openTimes[1][1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
retVal.Status = bizStatusMtwm2JX(result.OpenLevel, result.IsOnline)
|
retVal.Status = bizStatusMtwm2JX(result.OpenLevel, result.IsOnline)
|
||||||
|
|
||||||
tel2 := result.StandbyTel
|
tel2 := result.StandbyTel
|
||||||
@@ -128,7 +122,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
// err = api.MtwmAPI.PoiSave(storeDetail.VendorStoreID, params)
|
// err = api.MtwmAPI.PoiSave(storeDetail.VendorStoreID, params)
|
||||||
// }
|
// }
|
||||||
errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus)))
|
errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus)))
|
||||||
errList.AddErr(p.UpdateStoreOpTime(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, []int16{storeDetail.OpenTime1, storeDetail.CloseTime1, storeDetail.OpenTime2, storeDetail.CloseTime2}))
|
errList.AddErr(p.UpdateStoreOpTime(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, storeDetail.GetOpTimeList()))
|
||||||
return errList.GetErrListAsOne()
|
return errList.GetErrListAsOne()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package mtwm
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
// _ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
// _ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReadStore(t *testing.T) {
|
func TestReadStore(t *testing.T) {
|
||||||
store, err := new(PurchaseHandler).ReadStore("4351018")
|
store, err := new(PurchaseHandler).ReadStore(jxcontext.AdminCtx, "4351018")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,10 @@ import (
|
|||||||
|
|
||||||
"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/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error) {
|
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) {
|
||||||
return nil, errors.New("微盟微商城还没实现")
|
return nil, errors.New("微盟微商城还没实现")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user