100 lines
2.7 KiB
Go
100 lines
2.7 KiB
Go
package mtwm
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
"git.rosy.net.cn/jx-callback/business/partner"
|
|
)
|
|
|
|
var (
|
|
curPurchaseHandler *PurchaseHandler
|
|
)
|
|
|
|
type PurchaseHandler struct {
|
|
partner.BasePurchasePlatform
|
|
}
|
|
|
|
func init() {
|
|
curPurchaseHandler = new(PurchaseHandler)
|
|
// partner.RegisterPurchasePlatform(curPurchaseHandler)
|
|
}
|
|
|
|
func (c *PurchaseHandler) GetVendorID() int {
|
|
return model.VendorIDMTWM
|
|
}
|
|
|
|
func rangeMtwm2JX(areaStr string) string {
|
|
var area []interface{}
|
|
if err := utils.UnmarshalUseNumber([]byte(areaStr), &area); err == nil {
|
|
if len(area) > 0 {
|
|
coordList := make([]string, len(area))
|
|
for k, v := range area {
|
|
vv := v.(map[string]interface{})
|
|
coordList[k] = fmt.Sprintf("%.6f,%.6f", jxutils.IntCoordinate2Standard(int(utils.MustInterface2Int64(vv["x"]))), jxutils.IntCoordinate2Standard(int(utils.MustInterface2Int64(vv["y"]))))
|
|
}
|
|
return strings.Join(coordList, ";")
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func rangeJX2Mtwm(coords string) string {
|
|
pairs := strings.Split(strings.Trim(coords, ";"), ";")
|
|
if len(pairs) > 0 {
|
|
coordList := make([]map[string]interface{}, len(pairs))
|
|
for k, v := range pairs {
|
|
pair := strings.Split(v, ",")
|
|
coordList[k] = map[string]interface{}{
|
|
"x": jxutils.StandardCoordinate2Int(utils.Str2Float64(pair[0])),
|
|
"y": jxutils.StandardCoordinate2Int(utils.Str2Float64(pair[1])),
|
|
}
|
|
}
|
|
return string(utils.MustMarshal(coordList))
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func openTimeMtwm2JX(vendorOpenTime string) [][2]int16 {
|
|
timePairs := strings.Split(vendorOpenTime, ",")
|
|
jxOpenTimers := make([][2]int16, len(timePairs))
|
|
for k, v := range timePairs {
|
|
times := strings.Split(v, "-")
|
|
jxOpenTimers[k][0] = jxutils.StrTime2JxOperationTime(times[0], 700)
|
|
jxOpenTimers[k][1] = jxutils.StrTime2JxOperationTime(times[1], 2000)
|
|
}
|
|
return jxOpenTimers
|
|
}
|
|
|
|
func openTimeJX2Mtwm(times [][2]int16) string {
|
|
strPairs := make([]string, len(times))
|
|
for k, v := range times {
|
|
strPairs[k] = jxutils.JxOperationTime2StrTime(v[0]) + "-" + jxutils.JxOperationTime2StrTime(v[1])
|
|
}
|
|
return strings.Join(strPairs, ",")
|
|
}
|
|
|
|
func bizStatusMtwm2JX(openLevel, online int) int {
|
|
if online == mtwmapi.PoiOffline {
|
|
return model.StoreStatusDisabled
|
|
} else {
|
|
if openLevel == mtwmapi.PoiOpenLevelHaveRest {
|
|
return model.StoreStatusClosed
|
|
}
|
|
}
|
|
return model.StoreStatusOpened
|
|
}
|
|
|
|
func bizStatusJX2Mtwm(status int) (openLevel, online int) {
|
|
if status == model.StoreStatusDisabled {
|
|
return mtwmapi.PoiOpenLevelHaveRest, mtwmapi.PoiOffline
|
|
} else if status == model.StoreStatusClosed {
|
|
return mtwmapi.PoiOpenLevelHaveRest, mtwmapi.PoiOnline
|
|
}
|
|
return mtwmapi.PoiOpenLevelNormal, mtwmapi.PoiOnline
|
|
}
|