- 添加IStoreSkuSorter接口,但当前无实际平台支持

This commit is contained in:
gazebo
2019-09-04 11:42:58 +08:00
parent 4be654fc3e
commit 0bdcdde11c
6 changed files with 120 additions and 18 deletions

View File

@@ -225,6 +225,15 @@ func GetPurchasePlatformFromVendorID(vendorID int) IPurchasePlatformHandler {
return PurchasePlatformHandlers[vendorID]
}
func GetExternalPurchasePlatformVendorIDs() (vendorIDs []int) {
for k := range PurchasePlatformHandlers {
if k != model.VendorIDJX {
vendorIDs = append(vendorIDs, k)
}
}
return vendorIDs
}
func GetMultiStoreVendorIDs() (vendorIDs []int) {
for k, v := range PurchasePlatformHandlers {
if _, ok := v.(IMultipleStoresHandler); ok {

View File

@@ -2,8 +2,9 @@ package partner
import (
"math"
"time"
"regexp"
"time"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
@@ -39,6 +40,7 @@ type StoreSkuInfo struct {
Stock int `json:"stock,omitempty"`
VendorPrice int64 `json:"price,omitempty"`
Status int `json:"status,omitempty"`
Seq int `json:"seq,omitempty"`
}
type SkuInfo struct {
@@ -94,6 +96,21 @@ func (l BareStoreSkuInfoList) GetSkuIDList() (skuIDList []int) {
return skuIDList
}
func (l BareStoreSkuInfoList) Len() int {
return len(l)
}
func (l BareStoreSkuInfoList) Less(i, j int) bool {
if l[i].Seq != l[j].Seq {
return l[i].Seq < l[j].Seq
}
return l[i].VendorPrice < l[j].VendorPrice
}
func (l BareStoreSkuInfoList) Swap(i, j int) {
l[i], l[j] = l[j], l[i]
}
type BareCategoryInfo struct {
VendorCatID string `json:"vendorCatID"`
@@ -141,6 +158,10 @@ type ISingleStoreStoreSkuHandler interface {
GetSensitiveWordRegexp() *regexp.Regexp
}
type IStoreSkuSorter interface {
ReorderStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, vendorCatID string, storeSkuList []*StoreSkuInfo) (err error)
}
func BuildSkuName(skuID int, vendorSkuID string) (skuName *SkuNameInfo) {
return &SkuNameInfo{
SkuList: []*SkuInfo{

View File

@@ -209,3 +209,17 @@ func (p *PurchaseHandler) SyncStoreProducts(ctx *jxcontext.Context, parentTask t
}
return hint, err
}
// func (p *PurchaseHandler) ReorderStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, vendorCatID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
// storeSkuCount := len(storeSkuList)
// if storeSkuCount > 0 {
// if storeSkuCount > jdapi.MaxAddByStoreAndSkusCount {
// storeSkuList = storeSkuList[:jdapi.MaxAddByStoreAndSkusCount]
// }
// vendorSkuIDs := partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDIntList()
// if globals.EnableJdStoreWrite {
// err = getAPI("").AddByStoreAndSkus(utils.Str2Int64(vendorStoreID), vendorSkuIDs)
// }
// }
// return err
// }