推荐商品
This commit is contained in:
@@ -37,27 +37,6 @@ const (
|
|||||||
CopyStoreSkuModeUpdatePrice = "updatePrice" // 增量复制价格
|
CopyStoreSkuModeUpdatePrice = "updatePrice" // 增量复制价格
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetStoreSkus用
|
|
||||||
type StoreSkuNameExt struct {
|
|
||||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
|
||||||
StoreName string `json:"storeName"`
|
|
||||||
|
|
||||||
model.SkuName
|
|
||||||
PayPercentage int `json:"-"`
|
|
||||||
UnitPrice int `json:"unitPrice"`
|
|
||||||
Skus []*dao.StoreSkuExt `orm:"-" json:"skus,omitempty"`
|
|
||||||
SkusStr string `json:"-"`
|
|
||||||
|
|
||||||
PendingOpType int8 `json:"pendingOpType"` // 取值同 StoreOpRequest.Type
|
|
||||||
PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetStoreSkus用
|
|
||||||
type StoreSkuNamesInfo struct {
|
|
||||||
TotalCount int `json:"totalCount"`
|
|
||||||
SkuNames []*StoreSkuNameExt `json:"skuNames"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateStoreSku用,API调用时
|
// UpdateStoreSku用,API调用时
|
||||||
type StoreSkuBindSkuInfo struct {
|
type StoreSkuBindSkuInfo struct {
|
||||||
SkuID int `json:"skuID"`
|
SkuID int `json:"skuID"`
|
||||||
@@ -169,7 +148,7 @@ var (
|
|||||||
dataLock DataLock
|
dataLock DataLock
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetStoreSkus(ctx *jxcontext.Context, storeID int, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
|
func GetStoreSkus(ctx *jxcontext.Context, storeID int, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||||
return GetStoresSkus(ctx, []int{storeID}, skuIDs, isFocus, keyword, isBySku, isAct, params, offset, pageSize)
|
return GetStoresSkus(ctx, []int{storeID}, skuIDs, isFocus, keyword, isBySku, isAct, params, offset, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,11 +332,11 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
|||||||
return sql, sqlParams, err
|
return sql, sqlParams, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoresSkus(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
|
func GetStoresSkus(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||||
return GetStoresSkusNew(ctx, storeIDs, skuIDs, isFocus, keyword, isBySku, isAct, params, offset, pageSize)
|
return GetStoresSkusNew(ctx, storeIDs, skuIDs, isFocus, keyword, isBySku, isAct, params, offset, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
|
func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||||
if !isFocus && !isBySku && (len(storeIDs) > 1 || len(storeIDs) == 0) {
|
if !isFocus && !isBySku && (len(storeIDs) > 1 || len(storeIDs) == 0) {
|
||||||
return nil, fmt.Errorf("未关注按SkuName只能查询单店")
|
return nil, fmt.Errorf("未关注按SkuName只能查询单店")
|
||||||
}
|
}
|
||||||
@@ -396,7 +375,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
|||||||
catOrderBy = "t2.seq, "
|
catOrderBy = "t2.seq, "
|
||||||
}
|
}
|
||||||
|
|
||||||
skuNamesInfo = &StoreSkuNamesInfo{}
|
skuNamesInfo = &dao.StoreSkuNamesInfo{}
|
||||||
if !isBySku && sqlPageSize != model.UnlimitedPageSize {
|
if !isBySku && sqlPageSize != model.UnlimitedPageSize {
|
||||||
sql2 := `
|
sql2 := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
SELECT SQL_CALC_FOUND_ROWS
|
||||||
@@ -456,12 +435,12 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
|||||||
}
|
}
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
globals.SugarLogger.Debugf("GetStoresSkusNew get result2:%v", time.Now().Sub(beginTime))
|
globals.SugarLogger.Debugf("GetStoresSkusNew get result2:%v", time.Now().Sub(beginTime))
|
||||||
storeNameMap := make(map[int64]*StoreSkuNameExt)
|
storeNameMap := make(map[int64]*dao.StoreSkuNameExt)
|
||||||
for _, v := range tmpList {
|
for _, v := range tmpList {
|
||||||
var storeName *StoreSkuNameExt
|
var storeName *dao.StoreSkuNameExt
|
||||||
index := jxutils.Combine2Int(v.StoreID, v.ID)
|
index := jxutils.Combine2Int(v.StoreID, v.ID)
|
||||||
if isBySku || storeNameMap[index] == nil {
|
if isBySku || storeNameMap[index] == nil {
|
||||||
storeName = &StoreSkuNameExt{
|
storeName = &dao.StoreSkuNameExt{
|
||||||
StoreID: v.StoreID,
|
StoreID: v.StoreID,
|
||||||
StoreName: v.StoreName,
|
StoreName: v.StoreName,
|
||||||
SkuName: v.SkuName,
|
SkuName: v.SkuName,
|
||||||
@@ -488,7 +467,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
|||||||
storeIDs, skuIDs = GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
storeIDs, skuIDs = GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
||||||
}
|
}
|
||||||
beginTime := time.Now()
|
beginTime := time.Now()
|
||||||
err = updateActPrice4StoreSkuNameNew(db, storeIDs, skuIDs, skuNamesInfo, actVendorID)
|
err = dao.UpdateActPrice4StoreSkuNameNew(db, storeIDs, skuIDs, skuNamesInfo, actVendorID)
|
||||||
globals.SugarLogger.Debugf("GetStoresSkusNew updateActPrice4StoreSkuName:%v", time.Now().Sub(beginTime))
|
globals.SugarLogger.Debugf("GetStoresSkusNew updateActPrice4StoreSkuName:%v", time.Now().Sub(beginTime))
|
||||||
if !isFocus {
|
if !isFocus {
|
||||||
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
||||||
@@ -499,7 +478,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
|||||||
return skuNamesInfo, err
|
return skuNamesInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoreAndSkuIDsFromInfo(skuNamesInfo *StoreSkuNamesInfo) (storeIDs, skuIDs []int) {
|
func GetStoreAndSkuIDsFromInfo(skuNamesInfo *dao.StoreSkuNamesInfo) (storeIDs, skuIDs []int) {
|
||||||
storeIDMap := make(map[int]int)
|
storeIDMap := make(map[int]int)
|
||||||
skuIDMap := make(map[int]int)
|
skuIDMap := make(map[int]int)
|
||||||
for _, skuName := range skuNamesInfo.SkuNames {
|
for _, skuName := range skuNamesInfo.SkuNames {
|
||||||
@@ -512,7 +491,7 @@ func GetStoreAndSkuIDsFromInfo(skuNamesInfo *StoreSkuNamesInfo) (storeIDs, skuID
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据已经部分关注的商品,得到已经存在的门店商品单价
|
// 根据已经部分关注的商品,得到已经存在的门店商品单价
|
||||||
func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *dao.StoreSkuNamesInfo) (err error) {
|
||||||
storeIDMap := make(map[int]int)
|
storeIDMap := make(map[int]int)
|
||||||
skuNameIDMap := make(map[int]int)
|
skuNameIDMap := make(map[int]int)
|
||||||
for _, skuName := range skuNamesInfo.SkuNames {
|
for _, skuName := range skuNamesInfo.SkuNames {
|
||||||
@@ -534,49 +513,7 @@ func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *StoreSkuNamesI
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// skuIDs为空,会导致性能极低,所以要skuIDs必须有值
|
func updateSaleInfo4StoreSkuName(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs, skuIDs []int, params map[string]interface{}, skuNamesInfo *dao.StoreSkuNamesInfo, offset, pageSize int) (err error) {
|
||||||
func updateActPrice4StoreSkuNameNew(db *dao.DaoDB, storeIDs, skuIDs []int, skuNamesInfo *StoreSkuNamesInfo, actVendorID int) (err error) {
|
|
||||||
if len(skuIDs) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var vendorIDs []int
|
|
||||||
if actVendorID >= 0 {
|
|
||||||
vendorIDs = []int{actVendorID}
|
|
||||||
}
|
|
||||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, storeIDs, skuIDs, time.Now(), time.Now())
|
|
||||||
if err != nil {
|
|
||||||
globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
actStoreSkuMap4Act := jxutils.NewActStoreSkuMap(actStoreSkuList, true)
|
|
||||||
actStoreSkuMap4EarningPrice := jxutils.NewActStoreSkuMap(actStoreSkuList, false)
|
|
||||||
|
|
||||||
for _, skuName := range skuNamesInfo.SkuNames {
|
|
||||||
if len(skuName.Skus) > 0 {
|
|
||||||
for _, v := range skuName.Skus {
|
|
||||||
if actStoreSku := actStoreSkuMap4Act.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
|
|
||||||
v.ActPrice = int(actStoreSku.ActualActPrice)
|
|
||||||
v.ActID = actStoreSku.ActID
|
|
||||||
v.ActType = actStoreSku.Type
|
|
||||||
}
|
|
||||||
if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
|
|
||||||
v.EarningPrice = int(actStoreSku.EarningPrice)
|
|
||||||
v.EarningActID = actStoreSku.ActID
|
|
||||||
}
|
|
||||||
|
|
||||||
v.RealEarningPrice = v.EarningPrice
|
|
||||||
if v.RealEarningPrice == 0 {
|
|
||||||
v.RealEarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
skuName.UnitPrice = skuName.Price
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func updateSaleInfo4StoreSkuName(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs, skuIDs []int, params map[string]interface{}, skuNamesInfo *StoreSkuNamesInfo, offset, pageSize int) (err error) {
|
|
||||||
var (
|
var (
|
||||||
saleInfoList []*SkuSaleInfo
|
saleInfoList []*SkuSaleInfo
|
||||||
timeList []time.Time
|
timeList []time.Time
|
||||||
@@ -605,7 +542,7 @@ func updateSaleInfo4StoreSkuName(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
for _, saleInfo := range saleInfoList {
|
for _, saleInfo := range saleInfoList {
|
||||||
saleInfoMap[jxutils.Combine2Int(saleInfo.StoreID, saleInfo.SkuID)] = saleInfo
|
saleInfoMap[jxutils.Combine2Int(saleInfo.StoreID, saleInfo.SkuID)] = saleInfo
|
||||||
}
|
}
|
||||||
var newSkuNames []*StoreSkuNameExt
|
var newSkuNames []*dao.StoreSkuNameExt
|
||||||
for _, skuName := range skuNamesInfo.SkuNames {
|
for _, skuName := range skuNamesInfo.SkuNames {
|
||||||
var newSkus []*dao.StoreSkuExt
|
var newSkus []*dao.StoreSkuExt
|
||||||
for _, sku := range skuName.Skus {
|
for _, sku := range skuName.Skus {
|
||||||
@@ -2141,16 +2078,16 @@ func ReCalculateJxPrice(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTopSkusByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (skuAndNameExt []*dao.SkuAndNameExt, err error) {
|
func GetTopSkusByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (storeSkuNameExt []*dao.StoreSkuNameExt, err error) {
|
||||||
if len(storeIDs) == 0 {
|
if len(storeIDs) == 0 {
|
||||||
return skuAndNameExt, err
|
return storeSkuNameExt, err
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
skuAndNameExt, err = dao.GetTopSkusByStoreIDs(db, storeIDs)
|
storeSkuNameExt, err = dao.GetTopSkusByStoreIDs(db, storeIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return skuAndNameExt, err
|
return storeSkuNameExt, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTopCategorysByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (skuCategory []*model.SkuCategory, err error) {
|
func GetTopCategorysByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (skuCategory []*model.SkuCategory, err error) {
|
||||||
|
|||||||
@@ -224,8 +224,8 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetFilterJxSkuInfoMap(jxSkuInfoList []*StoreSkuNameExt) map[int]*StoreSkuNameExt {
|
func GetFilterJxSkuInfoMap(jxSkuInfoList []*dao.StoreSkuNameExt) map[int]*dao.StoreSkuNameExt {
|
||||||
filterJxSkuInfoMap := make(map[int]*StoreSkuNameExt)
|
filterJxSkuInfoMap := make(map[int]*dao.StoreSkuNameExt)
|
||||||
for _, value := range jxSkuInfoList {
|
for _, value := range jxSkuInfoList {
|
||||||
for _, skuInfo := range value.Skus {
|
for _, skuInfo := range value.Skus {
|
||||||
filterJxSkuInfoMap[skuInfo.SkuID] = value
|
filterJxSkuInfoMap[skuInfo.SkuID] = value
|
||||||
@@ -322,7 +322,7 @@ func IsSkuCanSale(saleStatus int) bool {
|
|||||||
|
|
||||||
//京西平台和其他平台商品的对比
|
//京西平台和其他平台商品的对比
|
||||||
//storeIDStr 京西商家id ,vendorStoreID 平台商家id
|
//storeIDStr 京西商家id ,vendorStoreID 平台商家id
|
||||||
func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) {
|
func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*dao.StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) {
|
||||||
for skuID, jxSkuInfo := range filterJxSkuInfoMap {
|
for skuID, jxSkuInfo := range filterJxSkuInfoMap {
|
||||||
skuIDStr := utils.Int2Str(skuID)
|
skuIDStr := utils.Int2Str(skuID)
|
||||||
var jxSkuDetailName string
|
var jxSkuDetailName string
|
||||||
@@ -542,11 +542,11 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
|
|||||||
storeID := jxStoreInfoListValue.ID
|
storeID := jxStoreInfoListValue.ID
|
||||||
storeIDStr := utils.Int2Str(storeID)
|
storeIDStr := utils.Int2Str(storeID)
|
||||||
storeName := jxStoreInfoListValue.Name
|
storeName := jxStoreInfoListValue.Name
|
||||||
jxSkuInfoDataSingle := &StoreSkuNamesInfo{}
|
jxSkuInfoDataSingle := &dao.StoreSkuNamesInfo{}
|
||||||
jxSkuInfoDataMulti := &StoreSkuNamesInfo{}
|
jxSkuInfoDataMulti := &dao.StoreSkuNamesInfo{}
|
||||||
if jxStoreInfoListValue.StoreMaps != nil {
|
if jxStoreInfoListValue.StoreMaps != nil {
|
||||||
var filterJxSkuInfoMapSingle map[int]*StoreSkuNameExt
|
var filterJxSkuInfoMapSingle map[int]*dao.StoreSkuNameExt
|
||||||
var filterJxSkuInfoMapMulti map[int]*StoreSkuNameExt
|
var filterJxSkuInfoMapMulti map[int]*dao.StoreSkuNameExt
|
||||||
for _, vendorListValue := range jxStoreInfoListValue.StoreMaps {
|
for _, vendorListValue := range jxStoreInfoListValue.StoreMaps {
|
||||||
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
|
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
|
||||||
var flag = false
|
var flag = false
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func GetStoreSkuSalesInfo(ctx *jxcontext.Context, storeID int) (outStoreSkuSales
|
|||||||
}
|
}
|
||||||
|
|
||||||
//得到当前门店商品数据
|
//得到当前门店商品数据
|
||||||
storeSkuMapData := make(map[int]*cms.StoreSkuNameExt)
|
storeSkuMapData := make(map[int]*dao.StoreSkuNameExt)
|
||||||
storeSkuData, err := cms.GetStoreSkus(ctx, storeID, citySkuIDs, true, "", true, false, map[string]interface{}{}, 0, -1)
|
storeSkuData, err := cms.GetStoreSkus(ctx, storeID, citySkuIDs, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, value := range storeSkuData.SkuNames {
|
for _, value := range storeSkuData.SkuNames {
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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/model"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -109,10 +111,25 @@ type StoreSkuNameInfo struct {
|
|||||||
UnitPrice int64
|
UnitPrice int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type SkuAndNameExt struct {
|
// GetStoreSkus用
|
||||||
SkuID int `orm:"column(sku_id)" json:"skuID"`
|
type StoreSkuNameExt struct {
|
||||||
|
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||||
|
StoreName string `json:"storeName"`
|
||||||
|
|
||||||
model.SkuName
|
model.SkuName
|
||||||
Skus []*StoreSkuExt `orm:"-" json:"skus,omitempty"`
|
PayPercentage int `json:"-"`
|
||||||
|
UnitPrice int `json:"unitPrice"`
|
||||||
|
Skus []*StoreSkuExt `orm:"-" json:"skus,omitempty"`
|
||||||
|
SkusStr string `json:"-"`
|
||||||
|
|
||||||
|
PendingOpType int8 `json:"pendingOpType"` // 取值同 StoreOpRequest.Type
|
||||||
|
PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStoreSkus用
|
||||||
|
type StoreSkuNamesInfo struct {
|
||||||
|
TotalCount int `json:"totalCount"`
|
||||||
|
SkuNames []*StoreSkuNameExt `json:"skuNames"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoreSkuExt struct {
|
type StoreSkuExt struct {
|
||||||
@@ -896,16 +913,17 @@ func GetStoreSkusByNameIDs(db *DaoDB, storeIDs []int, nameID int) (skuList []*St
|
|||||||
return skuList, err
|
return skuList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (skuAndNameExt []*SkuAndNameExt, err error) {
|
func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (storeSkuNameExt []*StoreSkuNameExt, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t2.id sku_id,t3.*
|
SELECT t2.id sku_id,t3.*
|
||||||
FROM(
|
FROM(
|
||||||
SELECT SUM(b.count) count,c.id
|
SELECT SUM(b.count) count,c.id,a.store_id,d.name store_name
|
||||||
FROM goods_order a
|
FROM goods_order a
|
||||||
JOIN order_sku b ON a.vendor_order_id = b.vendor_order_id AND a.vendor_id = b.vendor_id
|
JOIN order_sku b ON a.vendor_order_id = b.vendor_order_id AND a.vendor_id = b.vendor_id
|
||||||
JOIN sku c ON b.sku_id = c.id AND c.deleted_at = ?
|
JOIN sku c ON b.sku_id = c.id AND c.deleted_at = ?
|
||||||
JOIN sku_name t1 ON t1.id = c.name_id AND t1.deleted_at = ?
|
JOIN sku_name t1 ON t1.id = c.name_id AND t1.deleted_at = ?
|
||||||
STRAIGHT_JOIN store_sku_bind t4 ON t4.store_id = IF(a.store_id = 0,a.jx_store_id,a.store_id) AND t4.sku_id = b.sku_id AND t4.status = ? AND t4.deleted_at = ?
|
STRAIGHT_JOIN store_sku_bind t4 ON t4.store_id = IF(a.store_id = 0,a.jx_store_id,a.store_id) AND t4.sku_id = b.sku_id AND t4.status = ? AND t4.deleted_at = ?
|
||||||
|
JOIN store d ON d.id = a.store_id
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
AND a.order_created_at BETWEEN ? and NOW()
|
AND a.order_created_at BETWEEN ? and NOW()
|
||||||
`
|
`
|
||||||
@@ -922,18 +940,21 @@ func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (skuAndNameExt []*SkuAndNam
|
|||||||
}
|
}
|
||||||
sql += `
|
sql += `
|
||||||
AND b.sale_price > ?
|
AND b.sale_price > ?
|
||||||
GROUP BY 2)t1
|
GROUP BY 2,3,4)t1
|
||||||
JOIN sku t2 ON t2.id = t1.id
|
JOIN sku t2 ON t2.id = t1.id
|
||||||
JOIN sku_name t3 ON t3.id = t2.name_id
|
JOIN sku_name t3 ON t3.id = t2.name_id
|
||||||
ORDER BY t1.count DESC
|
ORDER BY t1.count DESC
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
`
|
`
|
||||||
sqlParams = append(sqlParams, 100, 30)
|
sqlParams = append(sqlParams, 100, 30)
|
||||||
err = GetRows(db, &skuAndNameExt, sql, sqlParams...)
|
err = GetRows(db, &storeSkuNameExt, sql, sqlParams...)
|
||||||
for _, v := range skuAndNameExt {
|
var skuNamesInfo = &StoreSkuNamesInfo{
|
||||||
|
SkuNames: storeSkuNameExt,
|
||||||
|
}
|
||||||
|
for _, v := range storeSkuNameExt {
|
||||||
var skus []*StoreSkuExt
|
var skus []*StoreSkuExt
|
||||||
sql2 := `
|
sql2 := `
|
||||||
SELECT a.*,t4.created_at bind_created_at, t4.updated_at bind_updated_at, t4.last_operator bind_last_operator, t4.deleted_at bind_deleted_at,
|
SELECT a.id sku_id,a.*,t4.created_at bind_created_at, t4.updated_at bind_updated_at, t4.last_operator bind_last_operator, t4.deleted_at bind_deleted_at,
|
||||||
t4.sub_store_id, t4.price bind_price, IF(t4.unit_price IS NOT NULL, t4.unit_price, t1.price) unit_price, t4.status store_sku_status, t4.auto_sale_at,
|
t4.sub_store_id, t4.price bind_price, IF(t4.unit_price IS NOT NULL, t4.unit_price, t1.price) unit_price, t4.status store_sku_status, t4.auto_sale_at,
|
||||||
t4.ebai_id, t4.mtwm_id,
|
t4.ebai_id, t4.mtwm_id,
|
||||||
t4.ebai_sync_status, t4.mtwm_sync_status,
|
t4.ebai_sync_status, t4.mtwm_sync_status,
|
||||||
@@ -947,7 +968,7 @@ func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (skuAndNameExt []*SkuAndNam
|
|||||||
sqlParams2 := []interface{}{
|
sqlParams2 := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
v.SkuID,
|
v.Skus[0].SkuID,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
}
|
}
|
||||||
if len(storeIDs) > 0 {
|
if len(storeIDs) > 0 {
|
||||||
@@ -956,8 +977,9 @@ func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (skuAndNameExt []*SkuAndNam
|
|||||||
}
|
}
|
||||||
err = GetRows(db, &skus, sql2, sqlParams2...)
|
err = GetRows(db, &skus, sql2, sqlParams2...)
|
||||||
v.Skus = skus
|
v.Skus = skus
|
||||||
|
err = UpdateActPrice4StoreSkuNameNew(db, storeIDs, []int{v.Skus[0].SkuID}, skuNamesInfo, -1)
|
||||||
}
|
}
|
||||||
return skuAndNameExt, err
|
return storeSkuNameExt, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTopCategorysByStoreIDs(db *DaoDB, storeIDs []int) (skuCategory []*model.SkuCategory, err error) {
|
func GetTopCategorysByStoreIDs(db *DaoDB, storeIDs []int) (skuCategory []*model.SkuCategory, err error) {
|
||||||
@@ -1086,3 +1108,45 @@ func SetStoreCatMapSyncStatus(storeCatMap *model.StoreSkuCategoryMap, vendorID i
|
|||||||
storeCatMap.EbaiSyncStatus = syncStatus
|
storeCatMap.EbaiSyncStatus = syncStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skuIDs为空,会导致性能极低,所以要skuIDs必须有值
|
||||||
|
func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesInfo *StoreSkuNamesInfo, actVendorID int) (err error) {
|
||||||
|
if len(skuIDs) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var vendorIDs []int
|
||||||
|
if actVendorID >= 0 {
|
||||||
|
vendorIDs = []int{actVendorID}
|
||||||
|
}
|
||||||
|
actStoreSkuList, err := GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, storeIDs, skuIDs, time.Now(), time.Now())
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
actStoreSkuMap4Act := jxutils.NewActStoreSkuMap(actStoreSkuList, true)
|
||||||
|
actStoreSkuMap4EarningPrice := jxutils.NewActStoreSkuMap(actStoreSkuList, false)
|
||||||
|
|
||||||
|
for _, skuName := range skuNamesInfo.SkuNames {
|
||||||
|
if len(skuName.Skus) > 0 {
|
||||||
|
for _, v := range skuName.Skus {
|
||||||
|
if actStoreSku := actStoreSkuMap4Act.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
|
||||||
|
v.ActPrice = int(actStoreSku.ActualActPrice)
|
||||||
|
v.ActID = actStoreSku.ActID
|
||||||
|
v.ActType = actStoreSku.Type
|
||||||
|
}
|
||||||
|
if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
|
||||||
|
v.EarningPrice = int(actStoreSku.EarningPrice)
|
||||||
|
v.EarningActID = actStoreSku.ActID
|
||||||
|
}
|
||||||
|
|
||||||
|
v.RealEarningPrice = v.EarningPrice
|
||||||
|
if v.RealEarningPrice == 0 {
|
||||||
|
v.RealEarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
skuName.UnitPrice = skuName.Price
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user