- remove JdRange2JxRange and JxRange2JdRange

This commit is contained in:
gazebo
2018-09-21 09:36:36 +08:00
parent b58530ecd2
commit 49a2d30f0e
2 changed files with 29 additions and 32 deletions

View File

@@ -1,9 +1,6 @@
package jd package jd
import ( import (
"fmt"
"strings"
"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/model/dao" "git.rosy.net.cn/jx-callback/business/model/dao"
@@ -67,7 +64,7 @@ func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error)
if err = err2; err == nil { if err = err2; err == nil {
retVal.DeliveryRangeType = int8(utils.MustInterface2Int64(result["deliveryRangeType"])) retVal.DeliveryRangeType = int8(utils.MustInterface2Int64(result["deliveryRangeType"]))
if retVal.DeliveryRangeType == model.DeliveryRangeTypePolygon { if retVal.DeliveryRangeType == model.DeliveryRangeTypePolygon {
retVal.DeliveryRange = JdRange2JxRange(utils.Interface2String(result["deliveryRange"])) retVal.DeliveryRange = utils.Interface2String(result["deliveryRange"])
} else { } else {
retVal.DeliveryRange = utils.Int64ToStr(utils.MustInterface2Int64(result["deliveryRangeRadius"])) retVal.DeliveryRange = utils.Int64ToStr(utils.MustInterface2Int64(result["deliveryRangeRadius"]))
} }
@@ -111,7 +108,7 @@ func (p *PurchaseHandler) UpdateStore(storeID int, userName string) (err error)
"county": store.JdDistrictCode, "county": store.JdDistrictCode,
} }
if store.DeliveryRangeType == model.DeliveryRangeTypePolygon { if store.DeliveryRangeType == model.DeliveryRangeTypePolygon {
params["coordinatePoints"] = JxRange2JdRange(store.DeliveryRange) params["coordinatePoints"] = store.DeliveryRange
} else { } else {
params["deliveryRangeRadius"] = utils.Str2Int64(store.DeliveryRange) params["deliveryRangeRadius"] = utils.Str2Int64(store.DeliveryRange)
} }
@@ -182,33 +179,33 @@ func (p *PurchaseHandler) GetAllStoresFromRemote() ([]*model.Store, error) {
return nil, err return nil, err
} }
func JdRange2JxRange(jdRanges string) (jxRanges string) { // func JdRange2JxRange(jdRanges string) (jxRanges string) {
coords := strings.Split(jdRanges, ";") // coords := strings.Split(jdRanges, ";")
intCoords := []string{} // intCoords := []string{}
for _, coord := range coords { // for _, coord := range coords {
items := strings.Split(coord, ",") // items := strings.Split(coord, ",")
if len(items) == 2 { // if len(items) == 2 {
lng := jxutils.StandardCoordinate2Int(utils.Str2Float64(items[0])) // lng := jxutils.StandardCoordinate2Int(utils.Str2Float64(items[0]))
lat := jxutils.StandardCoordinate2Int(utils.Str2Float64(items[1])) // lat := jxutils.StandardCoordinate2Int(utils.Str2Float64(items[1]))
intCoords = append(intCoords, fmt.Sprintf("%d,%d", lng, lat)) // intCoords = append(intCoords, fmt.Sprintf("%d,%d", lng, lat))
} // }
} // }
return strings.Join(intCoords, ";") // return strings.Join(intCoords, ";")
} // }
func JxRange2JdRange(jxRanges string) (jdRanges string) { // func JxRange2JdRange(jxRanges string) (jdRanges string) {
coords := strings.Split(jxRanges, ";") // coords := strings.Split(jxRanges, ";")
intCoords := []string{} // intCoords := []string{}
for _, coord := range coords { // for _, coord := range coords {
items := strings.Split(coord, ",") // items := strings.Split(coord, ",")
if len(items) == 2 { // if len(items) == 2 {
lng := jxutils.IntCoordinate2Standard(int(utils.Str2Int64(items[0]))) // lng := jxutils.IntCoordinate2Standard(int(utils.Str2Int64(items[0])))
lat := jxutils.IntCoordinate2Standard(int(utils.Str2Int64(items[1]))) // lat := jxutils.IntCoordinate2Standard(int(utils.Str2Int64(items[1])))
intCoords = append(intCoords, fmt.Sprintf("%f,%f", lng, lat)) // intCoords = append(intCoords, fmt.Sprintf("%f,%f", lng, lat))
} // }
} // }
return strings.Join(intCoords, ";") // return strings.Join(intCoords, ";")
} // }
func JdDeliveryType2Jx(deliveryType int) int8 { func JdDeliveryType2Jx(deliveryType int) int8 {
if deliveryType == 2938 { if deliveryType == 2938 {

View File

@@ -11,7 +11,7 @@ import (
) )
// 京东到家,以有库存表示关注(认领) // 京东到家,以有库存表示关注(认领)
func (p *PurchaseHandler) SyncStoreSku(storeID int, skuIDs []int, isForce bool, userName string) (err error) { func (p *PurchaseHandler) SyncStoreSkus(storeID int, skuIDs []int, isForce bool, userName string) (err error) {
db := dao.GetDB() db := dao.GetDB()
var storeSkus []*model.StoreSkuBind var storeSkus []*model.StoreSkuBind
sqlParams := []interface{}{ sqlParams := []interface{}{