推荐商品
This commit is contained in:
@@ -37,27 +37,6 @@ const (
|
||||
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调用时
|
||||
type StoreSkuBindSkuInfo struct {
|
||||
SkuID int `json:"skuID"`
|
||||
@@ -169,7 +148,7 @@ var (
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -353,11 +332,11 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
||||
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)
|
||||
}
|
||||
|
||||
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) {
|
||||
return nil, fmt.Errorf("未关注按SkuName只能查询单店")
|
||||
}
|
||||
@@ -396,7 +375,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
||||
catOrderBy = "t2.seq, "
|
||||
}
|
||||
|
||||
skuNamesInfo = &StoreSkuNamesInfo{}
|
||||
skuNamesInfo = &dao.StoreSkuNamesInfo{}
|
||||
if !isBySku && sqlPageSize != model.UnlimitedPageSize {
|
||||
sql2 := `
|
||||
SELECT SQL_CALC_FOUND_ROWS
|
||||
@@ -456,12 +435,12 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
||||
}
|
||||
dao.Commit(db)
|
||||
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 {
|
||||
var storeName *StoreSkuNameExt
|
||||
var storeName *dao.StoreSkuNameExt
|
||||
index := jxutils.Combine2Int(v.StoreID, v.ID)
|
||||
if isBySku || storeNameMap[index] == nil {
|
||||
storeName = &StoreSkuNameExt{
|
||||
storeName = &dao.StoreSkuNameExt{
|
||||
StoreID: v.StoreID,
|
||||
StoreName: v.StoreName,
|
||||
SkuName: v.SkuName,
|
||||
@@ -488,7 +467,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
||||
storeIDs, skuIDs = GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
||||
}
|
||||
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))
|
||||
if !isFocus {
|
||||
err = updateUnitPrice4StoreSkuNameNew(db, skuNamesInfo)
|
||||
@@ -499,7 +478,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
||||
return skuNamesInfo, err
|
||||
}
|
||||
|
||||
func GetStoreAndSkuIDsFromInfo(skuNamesInfo *StoreSkuNamesInfo) (storeIDs, skuIDs []int) {
|
||||
func GetStoreAndSkuIDsFromInfo(skuNamesInfo *dao.StoreSkuNamesInfo) (storeIDs, skuIDs []int) {
|
||||
storeIDMap := make(map[int]int)
|
||||
skuIDMap := make(map[int]int)
|
||||
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)
|
||||
skuNameIDMap := make(map[int]int)
|
||||
for _, skuName := range skuNamesInfo.SkuNames {
|
||||
@@ -534,49 +513,7 @@ func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *StoreSkuNamesI
|
||||
return err
|
||||
}
|
||||
|
||||
// skuIDs为空,会导致性能极低,所以要skuIDs必须有值
|
||||
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) {
|
||||
func updateSaleInfo4StoreSkuName(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs, skuIDs []int, params map[string]interface{}, skuNamesInfo *dao.StoreSkuNamesInfo, offset, pageSize int) (err error) {
|
||||
var (
|
||||
saleInfoList []*SkuSaleInfo
|
||||
timeList []time.Time
|
||||
@@ -605,7 +542,7 @@ func updateSaleInfo4StoreSkuName(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
||||
for _, saleInfo := range saleInfoList {
|
||||
saleInfoMap[jxutils.Combine2Int(saleInfo.StoreID, saleInfo.SkuID)] = saleInfo
|
||||
}
|
||||
var newSkuNames []*StoreSkuNameExt
|
||||
var newSkuNames []*dao.StoreSkuNameExt
|
||||
for _, skuName := range skuNamesInfo.SkuNames {
|
||||
var newSkus []*dao.StoreSkuExt
|
||||
for _, sku := range skuName.Skus {
|
||||
@@ -2141,16 +2078,16 @@ func ReCalculateJxPrice(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
||||
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 {
|
||||
return skuAndNameExt, err
|
||||
return storeSkuNameExt, err
|
||||
}
|
||||
db := dao.GetDB()
|
||||
skuAndNameExt, err = dao.GetTopSkusByStoreIDs(db, storeIDs)
|
||||
storeSkuNameExt, err = dao.GetTopSkusByStoreIDs(db, storeIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return skuAndNameExt, err
|
||||
return storeSkuNameExt, err
|
||||
}
|
||||
|
||||
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 {
|
||||
filterJxSkuInfoMap := make(map[int]*StoreSkuNameExt)
|
||||
func GetFilterJxSkuInfoMap(jxSkuInfoList []*dao.StoreSkuNameExt) map[int]*dao.StoreSkuNameExt {
|
||||
filterJxSkuInfoMap := make(map[int]*dao.StoreSkuNameExt)
|
||||
for _, value := range jxSkuInfoList {
|
||||
for _, skuInfo := range value.Skus {
|
||||
filterJxSkuInfoMap[skuInfo.SkuID] = value
|
||||
@@ -322,7 +322,7 @@ func IsSkuCanSale(saleStatus int) bool {
|
||||
|
||||
//京西平台和其他平台商品的对比
|
||||
//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 {
|
||||
skuIDStr := utils.Int2Str(skuID)
|
||||
var jxSkuDetailName string
|
||||
@@ -542,11 +542,11 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
|
||||
storeID := jxStoreInfoListValue.ID
|
||||
storeIDStr := utils.Int2Str(storeID)
|
||||
storeName := jxStoreInfoListValue.Name
|
||||
jxSkuInfoDataSingle := &StoreSkuNamesInfo{}
|
||||
jxSkuInfoDataMulti := &StoreSkuNamesInfo{}
|
||||
jxSkuInfoDataSingle := &dao.StoreSkuNamesInfo{}
|
||||
jxSkuInfoDataMulti := &dao.StoreSkuNamesInfo{}
|
||||
if jxStoreInfoListValue.StoreMaps != nil {
|
||||
var filterJxSkuInfoMapSingle map[int]*StoreSkuNameExt
|
||||
var filterJxSkuInfoMapMulti map[int]*StoreSkuNameExt
|
||||
var filterJxSkuInfoMapSingle map[int]*dao.StoreSkuNameExt
|
||||
var filterJxSkuInfoMapMulti map[int]*dao.StoreSkuNameExt
|
||||
for _, vendorListValue := range jxStoreInfoListValue.StoreMaps {
|
||||
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
|
||||
var flag = false
|
||||
|
||||
Reference in New Issue
Block a user