京东商城一系列
This commit is contained in:
@@ -2555,12 +2555,14 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int, isCountry
|
|||||||
}
|
}
|
||||||
if len(priceReferList) > 0 {
|
if len(priceReferList) > 0 {
|
||||||
//TODO 高于中位价20%才刷, 2020-05-08
|
//TODO 高于中位价20%才刷, 2020-05-08
|
||||||
if storeSku.UnitPrice > priceReferList[0].MidUnitPrice/payPercentage*120 {
|
if priceReferList[0].MidUnitPrice >= 500 {
|
||||||
skuBindInfo := &StoreSkuBindInfo{
|
if storeSku.UnitPrice > priceReferList[0].MidUnitPrice/payPercentage*120 {
|
||||||
NameID: priceReferList[0].NameID,
|
skuBindInfo := &StoreSkuBindInfo{
|
||||||
UnitPrice: priceReferList[0].MidUnitPrice / payPercentage * 100,
|
NameID: priceReferList[0].NameID,
|
||||||
|
UnitPrice: priceReferList[0].MidUnitPrice / payPercentage * 120,
|
||||||
|
}
|
||||||
|
skuBindInfos = append(skuBindInfos, skuBindInfo)
|
||||||
}
|
}
|
||||||
skuBindInfos = append(skuBindInfos, skuBindInfo)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,11 +231,12 @@ func storeSkuSyncInfo2Bare(inSku *dao.StoreSkuSyncInfo) (outSku *partner.StoreSk
|
|||||||
NameID: inSku.NameID,
|
NameID: inSku.NameID,
|
||||||
VendorNameID: inSku.VendorNameID,
|
VendorNameID: inSku.VendorNameID,
|
||||||
|
|
||||||
Status: inSku.MergedStatus,
|
Status: inSku.MergedStatus,
|
||||||
VendorPrice: inSku.VendorPrice,
|
VendorPrice: inSku.VendorPrice,
|
||||||
Seq: inSku.Seq,
|
Seq: inSku.Seq,
|
||||||
JxPrice: inSku.Price,
|
JxPrice: inSku.Price,
|
||||||
JxUnitPrice: inSku.UnitPrice,
|
JxUnitPrice: inSku.UnitPrice,
|
||||||
|
VendorSkuID2: utils.Int2Str(inSku.JdsWareID),
|
||||||
}
|
}
|
||||||
if !isStoreSkuSyncNeedDelete(inSku) {
|
if !isStoreSkuSyncNeedDelete(inSku) {
|
||||||
outSku.Stock = model.MaxStoreSkuStockQty
|
outSku.Stock = model.MaxStoreSkuStockQty
|
||||||
@@ -260,6 +261,15 @@ func getSkuBoxFee(vendorID int) (boxFee int64) {
|
|||||||
return boxFee
|
return boxFee
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formalizeStoreSkuListForJds(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyncInfo {
|
||||||
|
if len(inSkuList) > 0 {
|
||||||
|
for _, skuItem := range inSkuList {
|
||||||
|
skuItem.SkuName = jxutils.ComposeSkuNameSync2(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return inSkuList
|
||||||
|
}
|
||||||
|
|
||||||
func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyncInfo {
|
func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyncInfo {
|
||||||
if len(inSkuList) > 0 {
|
if len(inSkuList) > 0 {
|
||||||
boxFee := getSkuBoxFee(inSkuList[0].VendorID)
|
boxFee := getSkuBoxFee(inSkuList[0].VendorID)
|
||||||
@@ -332,10 +342,20 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn
|
|||||||
if vendorID == model.VendorIDYB {
|
if vendorID == model.VendorIDYB {
|
||||||
err = updateYbOhterSku(db, storeSkuList)
|
err = updateYbOhterSku(db, storeSkuList)
|
||||||
}
|
}
|
||||||
|
if vendorID == model.VendorIDJDShop {
|
||||||
|
err = updateJdsWareID(db, storeSkuList)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return num, err
|
return num, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateJdsWareID(db *dao.DaoDB, storeSkuList []*dao.StoreSkuSyncInfo) (err error) {
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
err = dao.UpdateJdsWareID(db, v)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func updateYbOhterSku(db *dao.DaoDB, storeSkuList []*dao.StoreSkuSyncInfo) (err error) {
|
func updateYbOhterSku(db *dao.DaoDB, storeSkuList []*dao.StoreSkuSyncInfo) (err error) {
|
||||||
for _, v := range storeSkuList {
|
for _, v := range storeSkuList {
|
||||||
err = dao.UpdateYbOtherSku(db, v)
|
err = dao.UpdateYbOtherSku(db, v)
|
||||||
@@ -376,6 +396,11 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
skus = skus2
|
skus = skus2
|
||||||
}
|
}
|
||||||
formalizeStoreSkuList(skus)
|
formalizeStoreSkuList(skus)
|
||||||
|
//京东商城的商品名规则不同
|
||||||
|
//name,空格,comment,约xxg
|
||||||
|
if vendorID == model.VendorIDJDShop {
|
||||||
|
formalizeStoreSkuListForJds(skus)
|
||||||
|
}
|
||||||
|
|
||||||
singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||||
storeSkuHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
storeSkuHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
||||||
|
|||||||
@@ -359,6 +359,32 @@ func ComposeSkuNameOriginal(prefix, name, comment, unit string, spec_quality flo
|
|||||||
return skuName
|
return skuName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ComposeSkuNameForJds(prefix, name, comment, unit string, spec_quality float32, spec_unit string, maxLen int) (skuName string) {
|
||||||
|
strBuilder := &strings.Builder{}
|
||||||
|
if prefix != "" {
|
||||||
|
strBuilder.WriteString("[")
|
||||||
|
strBuilder.WriteString(prefix)
|
||||||
|
strBuilder.WriteString("]")
|
||||||
|
}
|
||||||
|
skuName += name
|
||||||
|
strBuilder.WriteString(name)
|
||||||
|
if comment != "" {
|
||||||
|
strBuilder.WriteString(" ")
|
||||||
|
strBuilder.WriteString(comment)
|
||||||
|
}
|
||||||
|
if unit == "份" {
|
||||||
|
strBuilder.WriteString("约")
|
||||||
|
}
|
||||||
|
if unit != "" {
|
||||||
|
strBuilder.WriteString(ComposeSkuSpec(spec_quality, spec_unit))
|
||||||
|
}
|
||||||
|
skuName = strBuilder.String()
|
||||||
|
if maxLen > 0 {
|
||||||
|
skuName = utils.LimitUTF8StringLen(skuName, maxLen)
|
||||||
|
}
|
||||||
|
return skuName
|
||||||
|
}
|
||||||
|
|
||||||
func ComposeSkuName(prefix, name, comment, unit string, spec_quality float32, spec_unit string, maxLen int, exPrefix string, exPrefixBegin, exPrefixEnd *time.Time) (skuName string) {
|
func ComposeSkuName(prefix, name, comment, unit string, spec_quality float32, spec_unit string, maxLen int, exPrefix string, exPrefixBegin, exPrefixEnd *time.Time) (skuName string) {
|
||||||
if exPrefix != "" && exPrefixBegin != nil && exPrefixEnd != nil {
|
if exPrefix != "" && exPrefixBegin != nil && exPrefixEnd != nil {
|
||||||
if utils.Time2Date(time.Now().Add(6*time.Hour)).Sub(*exPrefixBegin) >= 0 && utils.Time2Date(time.Now()).Sub(*exPrefixEnd) <= 0 {
|
if utils.Time2Date(time.Now().Add(6*time.Hour)).Sub(*exPrefixBegin) >= 0 && utils.Time2Date(time.Now()).Sub(*exPrefixEnd) <= 0 {
|
||||||
@@ -382,6 +408,19 @@ func ComposeSkuNameSync(prefix, name, comment, unit string, spec_quality float32
|
|||||||
return skuName
|
return skuName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ComposeSkuNameSync2(prefix, name, comment, unit string, spec_quality float32, spec_unit string, maxLen int, exPrefix string, exPrefixBegin, exPrefixEnd *time.Time) (skuName string) {
|
||||||
|
if exPrefix != "" && exPrefixBegin != nil && exPrefixEnd != nil {
|
||||||
|
if utils.Time2Date(time.Now().Add(6*time.Hour)).Sub(*exPrefixBegin) >= 0 && utils.Time2Date(time.Now()).Sub(*exPrefixEnd) <= 0 {
|
||||||
|
skuName = exPrefix
|
||||||
|
}
|
||||||
|
if utils.Time2Date(time.Now().Add(6*time.Hour)).Sub(*exPrefixEnd) > 0 {
|
||||||
|
skuName = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skuName += ComposeSkuNameForJds(prefix, name, comment, unit, spec_quality, spec_unit, maxLen)
|
||||||
|
return skuName
|
||||||
|
}
|
||||||
|
|
||||||
func ComposeSpuName(prefix, name string, maxLen int) (spuName string) {
|
func ComposeSpuName(prefix, name string, maxLen int) (spuName string) {
|
||||||
if prefix != "" {
|
if prefix != "" {
|
||||||
spuName = "[" + prefix + "]"
|
spuName = "[" + prefix + "]"
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ type StoreSkuSyncInfo struct {
|
|||||||
StoreSkuStatus int
|
StoreSkuStatus int
|
||||||
SkuSyncStatus int8
|
SkuSyncStatus int8
|
||||||
VendorSkuID string `orm:"column(vendor_sku_id)"`
|
VendorSkuID string `orm:"column(vendor_sku_id)"`
|
||||||
|
JdsWareID int `orm:"column(jds_ware_id)" json:"jdsWareID"`
|
||||||
BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"`
|
BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"`
|
||||||
|
|
||||||
model.Sku
|
model.Sku
|
||||||
@@ -396,7 +397,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
|||||||
t14.vendor_id, t14.vendor_org_code,
|
t14.vendor_id, t14.vendor_org_code,
|
||||||
t1.id bind_id, t1.sku_id, t1.price, t1.unit_price, t1.status store_sku_status,
|
t1.id bind_id, t1.sku_id, t1.price, t1.unit_price, t1.status store_sku_status,
|
||||||
%s vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time,
|
%s vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time,
|
||||||
t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end,
|
t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end, t1.jds_ware_id,
|
||||||
t2.*,
|
t2.*,
|
||||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.ex_prefix, t3.ex_prefix_begin, t3.ex_prefix_end, t3.category_id name_category_id, t3.yb_name_suffix,
|
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.ex_prefix, t3.ex_prefix_begin, t3.ex_prefix_end, t3.category_id name_category_id, t3.yb_name_suffix,
|
||||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||||
@@ -1511,3 +1512,21 @@ func UpdateYbOtherSku(db *DaoDB, storeSkuSyncInfo *StoreSkuSyncInfo) (err error)
|
|||||||
_, err = ExecuteSQL(db, sql, sqlParams)
|
_, err = ExecuteSQL(db, sql, sqlParams)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateJdsWareID(db *DaoDB, storeSkuSyncInfo *StoreSkuSyncInfo) (err error) {
|
||||||
|
sql := `
|
||||||
|
UPDATE store_sku_bind
|
||||||
|
SET jds_ware_id = ?
|
||||||
|
WHERE store_id = ?
|
||||||
|
AND sku_id = ?
|
||||||
|
AND deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
storeSkuSyncInfo.JdsWareID,
|
||||||
|
storeSkuSyncInfo.StoreID,
|
||||||
|
storeSkuSyncInfo.SkuID,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
_, err = ExecuteSQL(db, sql, sqlParams)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -98,10 +98,11 @@ type StoreSkuBind struct {
|
|||||||
Status int
|
Status int
|
||||||
|
|
||||||
// ElmID int64 `orm:"column(elm_id);index"`
|
// ElmID int64 `orm:"column(elm_id);index"`
|
||||||
MtwmID int64 `orm:"column(mtwm_id);index"`
|
MtwmID int64 `orm:"column(mtwm_id);index"`
|
||||||
EbaiID int64 `orm:"column(ebai_id);index"`
|
EbaiID int64 `orm:"column(ebai_id);index"`
|
||||||
YbID int64 `orm:"column(yb_id);index"`
|
YbID int64 `orm:"column(yb_id);index"`
|
||||||
JdsID int64 `orm:"column(jds_id);index"`
|
JdsID int64 `orm:"column(jds_id);index"`
|
||||||
|
JdsWareID int64 `orm:"column(jds_ware_id);index"`
|
||||||
// WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId
|
// WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId
|
||||||
// WscID2 int64 `orm:"column(wsc_id2);index"` // 表示微盟goodsId
|
// WscID2 int64 `orm:"column(wsc_id2);index"` // 表示微盟goodsId
|
||||||
|
|
||||||
|
|||||||
@@ -46,11 +46,12 @@ type StoreSkuInfo struct {
|
|||||||
|
|
||||||
Seq int `json:"seq,omitempty"`
|
Seq int `json:"seq,omitempty"`
|
||||||
|
|
||||||
ActPrice int64 `json:"actPrice,omitempty"`
|
ActPrice int64 `json:"actPrice,omitempty"`
|
||||||
VendorActID string `json:"vendorActID,omitempty"`
|
VendorActID string `json:"vendorActID,omitempty"`
|
||||||
IsSpecialty int `json:"isSpecialty,omitempty"`
|
IsSpecialty int `json:"isSpecialty,omitempty"`
|
||||||
JxPrice int64 `json:"jxPrice,omitempty"`
|
JxPrice int64 `json:"jxPrice,omitempty"`
|
||||||
JxUnitPrice int64 `json:"jxUnitPrice,omitempty"`
|
JxUnitPrice int64 `json:"jxUnitPrice,omitempty"`
|
||||||
|
VendorSkuID2 string `json:"vendorSkuID2,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoreSkuInfoWithErr struct {
|
type StoreSkuInfoWithErr struct {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,14 +32,29 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
|
|
||||||
func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
updateWareParam := &jdshopapi.UpdateWareParam{
|
||||||
|
WareID: v.JdsWareID,
|
||||||
|
Title: v.SkuName,
|
||||||
|
Weight: v.Weight,
|
||||||
|
}
|
||||||
|
err = api.JdShopAPI.UpdateWare(updateWareParam)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "更新商品基础信息")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
err = api.JdShopAPI.DeleteWare(utils.Str2Int(v.VendorSkuID2))
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "删除商品")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
@@ -50,14 +66,32 @@ func (p *PurchaseHandler) GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTas
|
|||||||
|
|
||||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
if globals.EnableJdShopWrite {
|
if globals.EnableJdShopWrite {
|
||||||
|
var stock = 0
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
if status == model.SkuStatusNormal {
|
||||||
|
stock = 9999
|
||||||
|
}
|
||||||
|
if vendorStoreID == model.JdShopMainVendorStoreID {
|
||||||
|
err = api.JdShopAPI.UpdateSkuStock(utils.Str2Int(v.VendorSkuID), stock)
|
||||||
|
} else {
|
||||||
|
err = api.JdShopAPI.UpdateSkuSiteStock(utils.Str2Int(v.VendorSkuID), stock, utils.Str2Int(vendorStoreID))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "修改商品库存")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
if globals.EnableJdShopWrite {
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
err = api.JdShopAPI.UpdateSkuJdPrice(utils.Str2Int(v.VendorSkuID), utils.Float64TwoInt(jxutils.IntPrice2Standard(v.VendorPrice)))
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "修改商品价格")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user