+ UpdateStoreOpTime
This commit is contained in:
@@ -5,5 +5,5 @@ import "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|||||||
type IStoreHandler interface {
|
type IStoreHandler interface {
|
||||||
UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error)
|
UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error)
|
||||||
// opTime格式为整数1130代表11:30
|
// opTime格式为整数1130代表11:30
|
||||||
// ChangeStoreOptime(ctx *jxcontext.Context, opTimeList []int) (err error)
|
UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int) (err error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,25 +335,32 @@ func JxDeliveryRegion2Ebai(store *model.Store) (deliveryRegion interface{}) {
|
|||||||
return deliveryRegion
|
return deliveryRegion
|
||||||
}
|
}
|
||||||
|
|
||||||
func JxBusinessTime2Ebai(store *model.Store) interface{} {
|
func fillOpTimeParams(params map[string]interface{}, opTimeList []int16) map[string]interface{} {
|
||||||
bTime := make([]map[string]interface{}, 1)
|
if params == nil {
|
||||||
bTime[0] = map[string]interface{}{
|
params = make(map[string]interface{})
|
||||||
"start": jxutils.JxOperationTime2StrTime(store.OpenTime1),
|
|
||||||
"end": jxutils.JxOperationTime2StrTime(store.CloseTime1),
|
|
||||||
}
|
}
|
||||||
if store.OpenTime2 != 0 {
|
var pairList []map[string]string
|
||||||
bTime = append(bTime, map[string]interface{}{
|
opTimeListLen := len(opTimeList)
|
||||||
"start": jxutils.JxOperationTime2StrTime(store.OpenTime2),
|
if opTimeListLen > 4 {
|
||||||
"end": jxutils.JxOperationTime2StrTime(store.CloseTime2),
|
opTimeListLen = 4
|
||||||
|
}
|
||||||
|
opTimeListLen = opTimeListLen / 2 * 2
|
||||||
|
for k := 0; k < len(opTimeList); k += 2 {
|
||||||
|
if opTimeList[k] != 0 {
|
||||||
|
pairList = append(pairList, map[string]string{
|
||||||
|
"start": jxutils.JxOperationTime2StrTime(opTimeList[k]),
|
||||||
|
"end": jxutils.JxOperationTime2StrTime(opTimeList[k+1]),
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
return bTime
|
}
|
||||||
|
params["business_time"] = pairList
|
||||||
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
||||||
params := map[string]interface{}{
|
params := fillOpTimeParams(nil, []int16{store.OpenTime1, store.CloseTime1, store.OpenTime2, store.CloseTime2})
|
||||||
"business_time": JxBusinessTime2Ebai(&store.Store),
|
|
||||||
}
|
|
||||||
// if store.Tel2 != "" {
|
// if store.Tel2 != "" {
|
||||||
// params["ivr_phone"] = store.Tel2
|
// params["ivr_phone"] = store.Tel2
|
||||||
// }
|
// }
|
||||||
@@ -447,3 +454,14 @@ func (c *PurchaseHandler) updateStoreStatus(userName string, storeID int, vendor
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
||||||
|
params := map[string]interface{}{
|
||||||
|
ebaiapi.KeyBaiduShopID: vendorStoreID,
|
||||||
|
}
|
||||||
|
fillOpTimeParams(params, opTimeList)
|
||||||
|
if globals.EnableEbaiStoreWrite {
|
||||||
|
api.EbaiAPI.ShopUpdate(params)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package jd
|
package jd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||||
@@ -114,11 +115,10 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
}
|
}
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
"outSystemId": outSystemID, // todo 直接修改这个字段可能会有问题
|
"outSystemId": outSystemID, // todo 直接修改这个字段可能会有问题
|
||||||
"serviceTimeStart1": JxOperationTime2JdOperationTime(store.OpenTime1),
|
|
||||||
"serviceTimeEnd1": JxOperationTime2JdOperationTime(store.CloseTime1),
|
|
||||||
"phone": store.Tel1,
|
"phone": store.Tel1,
|
||||||
"mobile": store.Tel2,
|
"mobile": store.Tel2,
|
||||||
}
|
}
|
||||||
|
fillOpTimeParams(params, []int16{store.OpenTime1, store.CloseTime1, store.OpenTime2, store.CloseTime2})
|
||||||
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)
|
||||||
}
|
}
|
||||||
@@ -140,11 +140,6 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
params["deliveryRangeRadius"] = utils.Str2Int64WithDefault(store.DeliveryRange, 0)
|
params["deliveryRangeRadius"] = utils.Str2Int64WithDefault(store.DeliveryRange, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
openTime2 := JxOperationTime2JdOperationTime(store.OpenTime2)
|
|
||||||
if openTime2 != 0 {
|
|
||||||
params["serviceTimeStart2"] = openTime2
|
|
||||||
params["serviceTimeEnd2"] = JxOperationTime2JdOperationTime(store.CloseTime2)
|
|
||||||
}
|
|
||||||
_, params["closeStatus"] = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus))
|
_, params["closeStatus"] = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus))
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(params, false))
|
globals.SugarLogger.Debug(utils.Format4Output(params, false))
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
@@ -328,3 +323,33 @@ func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int,
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fillOpTimeParams(params map[string]interface{}, opTimeList []int16) map[string]interface{} {
|
||||||
|
if params == nil {
|
||||||
|
params = make(map[string]interface{})
|
||||||
|
}
|
||||||
|
index := 1
|
||||||
|
opTimeListLen := len(opTimeList)
|
||||||
|
if opTimeListLen > 4 {
|
||||||
|
opTimeListLen = 4
|
||||||
|
}
|
||||||
|
opTimeListLen = opTimeListLen / 2 * 2
|
||||||
|
for k := 0; k < len(opTimeList); k += 2 {
|
||||||
|
if opTimeList[k] != 0 {
|
||||||
|
params[fmt.Sprintf("serviceTimeStart%d", index)] = JxOperationTime2JdOperationTime(int16(opTimeList[k]))
|
||||||
|
params[fmt.Sprintf("serviceTimeEnd%d", index)] = JxOperationTime2JdOperationTime(int16(opTimeList[k+1]))
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
||||||
|
params := fillOpTimeParams(nil, opTimeList)
|
||||||
|
if globals.EnableJdStoreWrite {
|
||||||
|
err = api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), params)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -124,10 +124,15 @@ func openTimeMtwm2JX(vendorOpenTime string) [][2]int16 {
|
|||||||
return jxOpenTimers
|
return jxOpenTimers
|
||||||
}
|
}
|
||||||
|
|
||||||
func openTimeJX2Mtwm(times [][2]int16) string {
|
func openTimeJX2Mtwm(times []int16) string {
|
||||||
strPairs := make([]string, len(times))
|
timesLen := len(times) / 2 * 2
|
||||||
for k, v := range times {
|
var strPairs []string
|
||||||
strPairs[k] = jxutils.JxOperationTime2StrTime(v[0]) + "-" + jxutils.JxOperationTime2StrTime(v[1])
|
for i := 0; i < timesLen; i += 2 {
|
||||||
|
if times[i] != 0 {
|
||||||
|
strPairs = append(strPairs, jxutils.JxOperationTime2StrTime(times[i])+"-"+jxutils.JxOperationTime2StrTime(times[i+1]))
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return strings.Join(strPairs, ",")
|
return strings.Join(strPairs, ",")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"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/jx-callback/business/jxcallback/scheduler"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"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"
|
||||||
@@ -103,10 +104,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
openTime := [][2]int16{[2]int16{storeDetail.OpenTime1, storeDetail.CloseTime1}}
|
errList := errlist.New()
|
||||||
if storeDetail.OpenTime2 > 0 {
|
|
||||||
openTime = append(openTime, [2]int16{storeDetail.OpenTime2, storeDetail.CloseTime2})
|
|
||||||
}
|
|
||||||
// remoteStoreInfo, err := api.MtwmAPI.PoiGet(storeDetail.VendorStoreID)
|
// remoteStoreInfo, err := api.MtwmAPI.PoiGet(storeDetail.VendorStoreID)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return err
|
// return err
|
||||||
@@ -129,12 +127,9 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
// if globals.EnableMtwmStoreWrite {
|
// if globals.EnableMtwmStoreWrite {
|
||||||
// err = api.MtwmAPI.PoiSave(storeDetail.VendorStoreID, params)
|
// err = api.MtwmAPI.PoiSave(storeDetail.VendorStoreID, params)
|
||||||
// }
|
// }
|
||||||
if err = p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus)); err == nil {
|
errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus)))
|
||||||
if globals.EnableMtwmStoreWrite {
|
errList.AddErr(p.UpdateStoreOpTime(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, []int16{storeDetail.OpenTime1, storeDetail.CloseTime1, storeDetail.OpenTime2, storeDetail.CloseTime2}))
|
||||||
err = api.MtwmAPI.PoiShipTimeUpdate(storeDetail.VendorStoreID, openTimeJX2Mtwm(openTime))
|
return errList.GetErrListAsOne()
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
|
func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
|
||||||
@@ -195,3 +190,11 @@ func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int,
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
||||||
|
shippingTime := openTimeJX2Mtwm(opTimeList)
|
||||||
|
if globals.EnableMtwmStoreWrite {
|
||||||
|
err = api.MtwmAPI.PoiShipTimeUpdate(vendorStoreID, shippingTime)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user