增加商品额外前缀
This commit is contained in:
@@ -522,7 +522,10 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku bool, params ma
|
||||
t1.status,
|
||||
t1.is_spu,
|
||||
t1.desc_img,
|
||||
t1.upc`
|
||||
t1.upc,
|
||||
t1.ex_prefix,
|
||||
t1.ex_prefix_begin,
|
||||
t1.ex_prefix_end`
|
||||
if isBySku {
|
||||
sql += `,
|
||||
t2.id`
|
||||
@@ -551,6 +554,9 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku bool, params ma
|
||||
t1.upc,
|
||||
t1.jd_id,
|
||||
t1.jd_sync_status,
|
||||
t1.ex_prefix,
|
||||
t1.ex_prefix_begin,
|
||||
t1.ex_prefix_end,
|
||||
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"id":', t2.id, ',"comment":"', t2.comment, '","status":', t2.status,
|
||||
',"createdAt":"', CONCAT(REPLACE(t2.created_at," ","T"),"+08:00"), '","updatedAt":"', CONCAT(REPLACE(t2.updated_at," ","T"),"+08:00"),
|
||||
'","lastOperator":"', t2.last_operator, '","specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit,
|
||||
@@ -581,6 +587,15 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku bool, params ma
|
||||
|
||||
var skuIDs []int
|
||||
for _, skuName := range skuNamesInfo.SkuNames {
|
||||
if skuName.ExPrefixEnd != utils.ZeroTimeValue && skuName.ExPrefixBegin != utils.ZeroTimeValue {
|
||||
if time.Now().Before(skuName.ExPrefixEnd) && time.Now().After(skuName.ExPrefixBegin) {
|
||||
skuName.FullName = skuName.ExPrefix + jxutils.ComposeSkuName(skuName.Prefix, skuName.Name, "", "", 0, "", 0)
|
||||
} else {
|
||||
skuName.FullName = jxutils.ComposeSkuName(skuName.Prefix, skuName.Name, "", "", 0, "", 0)
|
||||
}
|
||||
} else {
|
||||
skuName.FullName = jxutils.ComposeSkuName(skuName.Prefix, skuName.Name, "", "", 0, "", 0)
|
||||
}
|
||||
if skuName.SkusStr != "" {
|
||||
if err = utils.UnmarshalUseNumber([]byte(skuName.SkusStr), &skuName.Skus); err != nil {
|
||||
dao.Rollback(db)
|
||||
@@ -852,7 +867,6 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skuList, err2 := dao.GetSkus(db, nil, []int{nameID}, nil, nil)
|
||||
if err = err2; err == nil {
|
||||
for _, v := range skuList {
|
||||
@@ -871,7 +885,6 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skuIDs, err2 := dao.GetSkuIDByNames(db, []int{nameID})
|
||||
if err = err2; err != nil {
|
||||
dao.Rollback(db)
|
||||
@@ -1331,3 +1344,35 @@ func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productIn
|
||||
}
|
||||
return productInfos, err
|
||||
}
|
||||
|
||||
func UpdateSkuNamesExPrefix(ctx *jxcontext.Context, nameIDs []int, exPrefix, fromTime, toTime string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
var (
|
||||
fromTimeP time.Time
|
||||
toTimeP time.Time
|
||||
)
|
||||
if fromTime != "" {
|
||||
fromTimeP = utils.Str2Time(fromTime)
|
||||
}
|
||||
if toTime != "" {
|
||||
toTimeP = utils.Str2Time(toTime)
|
||||
}
|
||||
task := tasksch.NewParallelTask("批量设置商品前缀", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
nameID := batchItemList[0].(int)
|
||||
payload := map[string]interface{}{
|
||||
"exPrefix": exPrefix,
|
||||
"exPrefixBegin": fromTimeP,
|
||||
"exPrefixEnd": toTimeP,
|
||||
}
|
||||
_, err = UpdateSkuName(ctx, nameID, payload)
|
||||
return retVal, err
|
||||
}, nameIDs)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if !isAsync {
|
||||
_, err = task.GetResult(0)
|
||||
hint = "1"
|
||||
} else {
|
||||
hint = task.GetID()
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
@@ -143,7 +143,17 @@ func SyncSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorIDs []int,
|
||||
if skuVendorInfo.BindID == 0 {
|
||||
return nil, fmt.Errorf("商品:%d的数据异常", skuVendorInfo.SkuID)
|
||||
}
|
||||
skuVendorInfo.SkuName = jxutils.ComposeSkuName(skuVendorInfo.Prefix, skuVendorInfo.Name, skuVendorInfo.Comment, skuVendorInfo.Unit, skuVendorInfo.SpecQuality, skuVendorInfo.SpecUnit, 0)
|
||||
skuName := ""
|
||||
if skuVendorInfo.ExPrefixEnd != utils.ZeroTimeValue && skuVendorInfo.ExPrefixBegin != utils.ZeroTimeValue {
|
||||
if time.Now().Before(skuVendorInfo.ExPrefixEnd) && time.Now().After(skuVendorInfo.ExPrefixBegin) {
|
||||
skuName = skuVendorInfo.ExPrefix + jxutils.ComposeSkuName(skuVendorInfo.Prefix, skuVendorInfo.Name, skuVendorInfo.Comment, skuVendorInfo.Unit, skuVendorInfo.SpecQuality, skuVendorInfo.SpecUnit, 0)
|
||||
} else {
|
||||
skuName = jxutils.ComposeSkuName(skuVendorInfo.Prefix, skuVendorInfo.Name, skuVendorInfo.Comment, skuVendorInfo.Unit, skuVendorInfo.SpecQuality, skuVendorInfo.SpecUnit, 0)
|
||||
}
|
||||
} else {
|
||||
skuName = jxutils.ComposeSkuName(skuVendorInfo.Prefix, skuVendorInfo.Name, skuVendorInfo.Comment, skuVendorInfo.Unit, skuVendorInfo.SpecQuality, skuVendorInfo.SpecUnit, 0)
|
||||
}
|
||||
skuVendorInfo.SkuName = skuName
|
||||
skuVendorInfo.MergedStatus = jxutils.MergeSkuStatus(skuVendorInfo.Status, skuVendorInfo.NameStatus)
|
||||
if multiStoresHandler, ok := partner.GetPurchasePlatformFromVendorID(skuVendorInfo.VendorID).(partner.IMultipleStoresHandler); ok {
|
||||
if model.IsSyncStatusDelete(skuVendorInfo.SkuSyncStatus) { //删除
|
||||
|
||||
Reference in New Issue
Block a user