aa
This commit is contained in:
@@ -5,8 +5,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/permission"
|
"git.rosy.net.cn/jx-callback/business/jxstore/permission"
|
||||||
@@ -388,17 +391,17 @@ func GetManageState(ctx *jxcontext.Context, cityCodes []int, vendorID int) (getM
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetStoreManageStateResult struct {
|
type GetStoreManageStateResult struct {
|
||||||
StoreID int `json:"storeID"`
|
StoreID int `json:"storeID"`
|
||||||
StoreName string `json:"storeName"`
|
StoreName string `json:"storeName"`
|
||||||
CoverArea int `json:"coverArea"`
|
CoverArea float64 `json:"coverArea"`
|
||||||
MarketScale int `json:"marketScale"` //市场规模
|
MarketScale int `json:"marketScale"` //市场规模
|
||||||
OpenTime int `json:"openTime"` //营业时长
|
OpenTime int `json:"openTime"` //营业时长
|
||||||
SkuCount int `json:"skuCount"` //商品数
|
SkuCount int `json:"skuCount"` //商品数
|
||||||
HighSkuCount int `json:"highSkuCount"` //虚高商品数
|
HighSkuCount int `json:"highSkuCount"` //虚高商品数
|
||||||
ActAmple int `json:"actAmple"` //活动丰富的
|
ActAmple int `json:"actAmple"` //活动丰富的
|
||||||
NullOrderCount int `json:"nullOrderCount"` //无效订单数
|
NullOrderCount int `json:"nullOrderCount"` //无效订单数
|
||||||
RefuseOrderCount int `json:"refuseOrderCount"` //拒绝订单数
|
RefuseOrderCount int `json:"refuseOrderCount"` //拒绝订单数
|
||||||
RepurchaseRate int `json:"repurchaseRate"` //复购率(转化率)
|
RepurchaseRate int `json:"repurchaseRate"` //复购率(转化率)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, fromTime, toTime string) (getStoreManageStateResult []*GetStoreManageStateResult, err error) {
|
func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, fromTime, toTime string) (getStoreManageStateResult []*GetStoreManageStateResult, err error) {
|
||||||
@@ -427,13 +430,42 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
|
|||||||
for _, v := range storeIDs {
|
for _, v := range storeIDs {
|
||||||
storeDetail, _ := dao.GetStoreDetail(db, v, vendorID, "")
|
storeDetail, _ := dao.GetStoreDetail(db, v, vendorID, "")
|
||||||
result := &GetStoreManageStateResult{
|
result := &GetStoreManageStateResult{
|
||||||
StoreID: v,
|
StoreID: v,
|
||||||
StoreName: storeDetail.Name,
|
StoreName: storeDetail.Name,
|
||||||
|
MarketScale: storeDetail.MarketScale,
|
||||||
|
CoverArea: storeDetail.CoverArea,
|
||||||
|
}
|
||||||
|
if result.CoverArea == 0 {
|
||||||
|
handler := partner.GetPurchasePlatformFromVendorID(vendorID)
|
||||||
|
store, _ := handler.ReadStore(ctx, storeDetail.VendorOrgCode, storeDetail.VendorStoreID)
|
||||||
|
if storeMaps, err := dao.GetStoresMapList(db, []int{vendorID}, []int{v}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", ""); len(storeMaps) > 0 && err == nil {
|
||||||
|
storeMaps[0].CoverArea = CalculateCoverArea(strings.Split(store.DeliveryRange, ";"))
|
||||||
|
dao.UpdateEntity(db, storeMaps[0], "CoverArea")
|
||||||
|
result.CoverArea = storeMaps[0].CoverArea
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handler := partner.GetPurchasePlatformFromVendorID(vendorID)
|
|
||||||
store, _ := handler.ReadStore(ctx, storeDetail.VendorOrgCode, storeDetail.VendorStoreID)
|
|
||||||
fmt.Println("testdddd", store.DeliveryRange)
|
|
||||||
getStoreManageStateResult = append(getStoreManageStateResult, result)
|
getStoreManageStateResult = append(getStoreManageStateResult, result)
|
||||||
}
|
}
|
||||||
return getStoreManageStateResult, err
|
return getStoreManageStateResult, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CalculateCoverArea(coordinate []string) (area float64) {
|
||||||
|
if len(coordinate) == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var xyList [][2]float64
|
||||||
|
for _, v := range coordinate {
|
||||||
|
cell := strings.Split(v, ",")
|
||||||
|
lat := utils.Str2Float64WithDefault(cell[0], 0)
|
||||||
|
lng := utils.Str2Float64WithDefault(cell[1], 0)
|
||||||
|
xys := jxutils.MillierConvertion(lat, lng)
|
||||||
|
xyList = append(xyList, xys)
|
||||||
|
}
|
||||||
|
var sum float64
|
||||||
|
for i := 0; i < len(xyList)-1; i++ {
|
||||||
|
sum += (xyList[i+1][0] - xyList[i][0]) * (xyList[i+1][1] + xyList[i+1][1])
|
||||||
|
}
|
||||||
|
sum += (xyList[0][0] - xyList[len(xyList)-1][0]) * (xyList[0][1] + xyList[len(xyList)-1][1])
|
||||||
|
sum /= 2
|
||||||
|
return math.Round(sum)
|
||||||
|
}
|
||||||
|
|||||||
@@ -267,6 +267,24 @@ func WalkingDistance(lng1, lat1, lng2, lat2 float64) (distance float64) {
|
|||||||
return distance
|
return distance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//经纬度坐标转换到平面坐标
|
||||||
|
func MillierConvertion(lat float64, lon float64) [2]float64 {
|
||||||
|
var L, H, W, temp, mill, x, y float64
|
||||||
|
L = 6381372 * math.Pi * 2 //地球周长
|
||||||
|
W = L // 平面展开后,x轴等于周长
|
||||||
|
H = L / 2 // y轴约等于周长一半
|
||||||
|
mill = 2.3 // 米勒投影中的一个常数,范围大约在正负2.3之间
|
||||||
|
temp = math.Pi
|
||||||
|
x = lon * temp / 180 // 将经度从度数转换为弧度
|
||||||
|
y = lat * temp / 180 // 将纬度从度数转换为弧度
|
||||||
|
y = 1.25 * math.Log(math.Tan(0.25*temp+0.4*y)) // 米勒投影的转换
|
||||||
|
// 弧度转为实际距离
|
||||||
|
x = (W / 2) + (W/(2*math.Pi))*x
|
||||||
|
y = (H / 2) - (H/(2*mill))*y
|
||||||
|
var result = [2]float64{x, y}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func StandardCoordinate2Int(value float64) int {
|
func StandardCoordinate2Int(value float64) int {
|
||||||
return int(math.Round(value * 1000000))
|
return int(math.Round(value * 1000000))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ type StoreDetail struct {
|
|||||||
BrandLogo string `json:"brandLogo"`
|
BrandLogo string `json:"brandLogo"`
|
||||||
BrandIsOpen int `json:"brandIsOpen"`
|
BrandIsOpen int `json:"brandIsOpen"`
|
||||||
BrandIsPrint int `json:"brandIsPrint"`
|
BrandIsPrint int `json:"brandIsPrint"`
|
||||||
|
|
||||||
|
CoverArea int `json:"coverArea"`
|
||||||
|
MarketScale float64 `json:"marketScale"` //市场规模
|
||||||
}
|
}
|
||||||
|
|
||||||
// 带快递门店信息的
|
// 带快递门店信息的
|
||||||
@@ -112,6 +115,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID, vendorOrgCo
|
|||||||
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee_deduction_sill, t2.delivery_fee_deduction_fee, t2.sync_status, t2.vendor_org_code,
|
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee_deduction_sill, t2.delivery_fee_deduction_fee, t2.sync_status, t2.vendor_org_code,
|
||||||
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,
|
||||||
t2.jds_street_code, t2.jds_street_name, t2.is_supply_goods, t2.vendor_pay_percentage, t2.mtwm_token, t2.ebai_supplier_id, t2.create_delivery_type,
|
t2.jds_street_code, t2.jds_street_name, t2.is_supply_goods, t2.vendor_pay_percentage, t2.mtwm_token, t2.ebai_supplier_id, t2.create_delivery_type,
|
||||||
|
t2.market_scale, t2.cover_area,
|
||||||
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,
|
province.name province_name,
|
||||||
|
|||||||
@@ -456,10 +456,11 @@ type StoreMap struct {
|
|||||||
YbAppKey string `orm:"size(255)" json:"ybAppKey"`
|
YbAppKey string `orm:"size(255)" json:"ybAppKey"`
|
||||||
YbStorePrefix string `orm:"size(255)" json:"ybStorePrefix"`
|
YbStorePrefix string `orm:"size(255)" json:"ybStorePrefix"`
|
||||||
|
|
||||||
MtwmToken string `orm:"size(255)" json:"mtwmToken"` //美团外卖商超token,有效期30天,每20天刷一次
|
MtwmToken string `orm:"size(255)" json:"mtwmToken"` //美团外卖商超token,有效期30天,每20天刷一次
|
||||||
MtwmRefreshToken string `orm:"size(255)" json:"mtwmRefreshToken"` //美团外卖商超refreshToken
|
MtwmRefreshToken string `orm:"size(255)" json:"mtwmRefreshToken"` //美团外卖商超refreshToken
|
||||||
EbaiSupplierID string `orm:"column(ebai_supplier_id)" json:"ebaiSupplierID"` //饿百供应商ID
|
EbaiSupplierID string `orm:"column(ebai_supplier_id)" json:"ebaiSupplierID"` //饿百供应商ID
|
||||||
MarketScale int `json:"marketScale"` //市场规模
|
MarketScale int `json:"marketScale"` //市场规模
|
||||||
|
CoverArea float64 `json:"coverArea"` //覆盖范围
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*StoreMap) TableUnique() [][]string {
|
func (*StoreMap) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -232,7 +232,9 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
|||||||
retVal.DeliveryRangeType = model.DeliveryRangeTypePolygon
|
retVal.DeliveryRangeType = model.DeliveryRangeTypePolygon
|
||||||
retVal.DeliveryRange = EbaiDeliveryRegion2Jx(result["delivery_region"])
|
retVal.DeliveryRange = EbaiDeliveryRegion2Jx(result["delivery_region"])
|
||||||
if retVal.DeliveryRange == "" {
|
if retVal.DeliveryRange == "" {
|
||||||
api.EbaiAPI.ShopDeliveryinfoGet("", utils.Str2Int64(vendorStoreID))
|
if list, err := api.EbaiAPI.ShopDeliveryinfoGet("", utils.Str2Int64(vendorStoreID)); err == nil {
|
||||||
|
retVal.DeliveryRange = EbaiDeliveryRegion2Jx2(list[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return retVal, nil
|
return retVal, nil
|
||||||
}
|
}
|
||||||
@@ -399,6 +401,19 @@ func EbaiDeliveryRegion2Jx(deliveryRegion interface{}) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EbaiDeliveryRegion2Jx2(deliveryRegion map[string]interface{}) string {
|
||||||
|
if len(deliveryRegion) > 0 {
|
||||||
|
region := deliveryRegion["delivery_areas"].([]interface{})[0].(map[string]interface{})["coordinates"].([]interface{})
|
||||||
|
coords := make([]string, len(region))
|
||||||
|
for k, v := range region {
|
||||||
|
mapV := v.(map[string]interface{})
|
||||||
|
coords[k] = fmt.Sprintf("%.6f,%.6f", utils.MustInterface2Float64(mapV["longitude"]), utils.MustInterface2Float64(mapV["latitude"]))
|
||||||
|
}
|
||||||
|
return strings.Join(coords, ";")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func JxDeliveryRegion2Ebai(store *model.Store) (deliveryRegion interface{}) {
|
func JxDeliveryRegion2Ebai(store *model.Store) (deliveryRegion interface{}) {
|
||||||
rangeStr := strings.Trim(store.DeliveryRange, ";")
|
rangeStr := strings.Trim(store.DeliveryRange, ";")
|
||||||
if store.DeliveryRangeType == model.DeliveryRangeTypeRadius {
|
if store.DeliveryRangeType == model.DeliveryRangeTypeRadius {
|
||||||
|
|||||||
Reference in New Issue
Block a user