aa
This commit is contained in:
@@ -397,7 +397,7 @@ type GetStoreManageStateResult struct {
|
||||
StoreName string `json:"storeName"`
|
||||
CoverArea float64 `json:"coverArea"`
|
||||
MarketScale int `json:"marketScale"` //市场规模
|
||||
OpenTime int `json:"openTime"` //营业时长
|
||||
OpenTime float64 `json:"openTime"` //营业时长
|
||||
SkuCount int `json:"skuCount"` //商品数
|
||||
HighSkuCount int `json:"highSkuCount"` //虚高商品数
|
||||
ActAmple int `json:"actAmple"` //活动丰富的
|
||||
@@ -408,7 +408,9 @@ type GetStoreManageStateResult struct {
|
||||
|
||||
func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, fromTime, toTime string) (getStoreManageStateResult []*GetStoreManageStateResult, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
db = dao.GetDB()
|
||||
fromTimeT, toTimeT = utils.Str2Time(fromTime), utils.Str2Time(toTime)
|
||||
dayCount = int(fromTimeT.Sub(toTimeT).Hours())/24 + 1 //查的几天
|
||||
)
|
||||
//权限
|
||||
if permission.IsRoled(ctx) {
|
||||
@@ -437,6 +439,7 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
|
||||
MarketScale: storeDetail.MarketScale,
|
||||
CoverArea: storeDetail.CoverArea,
|
||||
}
|
||||
//覆盖范围
|
||||
if result.CoverArea == 0 {
|
||||
handler := partner.GetPurchasePlatformFromVendorID(vendorID)
|
||||
store, _ := handler.ReadStore(ctx, storeDetail.VendorOrgCode, storeDetail.VendorStoreID)
|
||||
@@ -446,12 +449,37 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
|
||||
result.CoverArea = storeMaps[0].CoverArea
|
||||
}
|
||||
}
|
||||
//营业时长
|
||||
optime := jxutils.JxOperationTime2TimeByDate(storeDetail.CloseTime1, time.Now()).Sub(jxutils.JxOperationTime2TimeByDate(storeDetail.OpenTime1, time.Now())).Hours()
|
||||
if storeDetail.CloseTime2 != 0 && storeDetail.OpenTime2 != 0 {
|
||||
optime += jxutils.JxOperationTime2TimeByDate(storeDetail.CloseTime2, time.Now()).Sub(jxutils.JxOperationTime2TimeByDate(storeDetail.OpenTime2, time.Now())).Hours()
|
||||
}
|
||||
result.OpenTime = optime * float64(dayCount)
|
||||
//商品数
|
||||
skuCount, highSkuCount := 0, 0
|
||||
storeSkus, _ := dao.GetStoresSkusInfo(db, []int{v}, nil)
|
||||
for _, v := range storeSkus {
|
||||
if v.Status == model.StoreSkuBindStatusNormal && v.Stock > 0 {
|
||||
skuCount++
|
||||
}
|
||||
if priceRefer, err := dao.GetPriceReferPrice(db, 0, v.SkuID, utils.Time2Date(time.Now().AddDate(0, 0, -1))); err == nil && priceRefer != nil {
|
||||
if v.UnitPrice > priceRefer.MidUnitPrice {
|
||||
highSkuCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
result.SkuCount = skuCount
|
||||
result.HighSkuCount = highSkuCount
|
||||
//活动丰富度
|
||||
|
||||
getStoreManageStateResult = append(getStoreManageStateResult, result)
|
||||
}
|
||||
return getStoreManageStateResult, err
|
||||
}
|
||||
|
||||
func CalculateCoverArea(coordinate []string, vendorID int) (area float64) {
|
||||
//我先把地理坐标转成了平面坐标(百度的方法)
|
||||
//然后按多个坐标求面积公式求的面积(百度的方法)
|
||||
if len(coordinate) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user