Accept Merge Request #96: (yonghui -> mark)
Merge Request: 平台门店名,刷新订单状态,商品名前缀,获取平台门店商品价 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/96
This commit is contained in:
@@ -23,6 +23,9 @@ import (
|
||||
const (
|
||||
maxLastHours = 7 * 24 // 最多只能查询7天内的订单数据
|
||||
defLastHours = 2 * 24 // 缺省是两天内的订单
|
||||
|
||||
orderSubTimeImmediatelyArrive = 8
|
||||
orderSubTimeDelayArrive = 5
|
||||
)
|
||||
|
||||
type tWaybillExt struct {
|
||||
@@ -936,6 +939,7 @@ func (c *OrderManager) AmendMissingOrders(ctx *jxcontext.Context, vendorIDs []in
|
||||
}
|
||||
if len(dateVendorList) > 0 {
|
||||
var missingOrderList []*tOrderVendorPair
|
||||
var updateOrderStatusList []*model.GoodsOrder
|
||||
db := dao.GetDB()
|
||||
vendorStoreIDMap := make(map[int]string)
|
||||
if storeID > 0 {
|
||||
@@ -986,8 +990,21 @@ func (c *OrderManager) AmendMissingOrders(ctx *jxcontext.Context, vendorIDs []in
|
||||
|
||||
for _, v := range orderList {
|
||||
pair := v.(*tOrderVendorPair)
|
||||
if localOrderMap[jxutils.ComposeUniversalOrderID(pair.VendorOrderID, pair.VendorID)] == nil {
|
||||
goodsOrder := localOrderMap[jxutils.ComposeUniversalOrderID(pair.VendorOrderID, pair.VendorID)]
|
||||
if goodsOrder == nil {
|
||||
missingOrderList = append(missingOrderList, pair)
|
||||
} else {
|
||||
if !model.IsOrderFinalStatus(goodsOrder.Status) {
|
||||
if goodsOrder.BusinessType == model.BusinessTypeImmediate {
|
||||
if time.Now().Sub(goodsOrder.CreatedAt).Hours() >= orderSubTimeImmediatelyArrive {
|
||||
updateOrderStatusList = append(updateOrderStatusList, goodsOrder)
|
||||
}
|
||||
} else {
|
||||
if time.Now().Sub(goodsOrder.ExpectedDeliveredTime).Hours() >= orderSubTimeDelayArrive {
|
||||
updateOrderStatusList = append(updateOrderStatusList, goodsOrder)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
@@ -1007,9 +1024,26 @@ func (c *OrderManager) AmendMissingOrders(ctx *jxcontext.Context, vendorIDs []in
|
||||
}, missingOrderList)
|
||||
tasksch.HandleTask(task2, task, true).Run()
|
||||
result, err = task2.GetResult(0)
|
||||
case 2:
|
||||
task3 := tasksch.NewParallelTask("AmendMissingOrders UpdateOrders", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
goodsOrder := batchItemList[0].(*model.GoodsOrder)
|
||||
if handler := partner.GetPurchaseOrderHandlerFromVendorID(goodsOrder.VendorID); handler != nil {
|
||||
status, err2 := handler.GetOrderStatus(goodsOrder.VendorOrgCode, goodsOrder.VendorOrderID)
|
||||
if err = err2; err == nil {
|
||||
if model.IsOrderFinalStatus(status) {
|
||||
goodsOrder.Status = status
|
||||
_, err = dao.UpdateEntity(db, goodsOrder, "Status")
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, updateOrderStatusList)
|
||||
tasksch.HandleTask(task3, task, true).Run()
|
||||
_, err = task3.GetResult(0)
|
||||
}
|
||||
return result, err
|
||||
}, 2)
|
||||
}, 3)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if !isAsync {
|
||||
result, err2 := task.GetResult(0)
|
||||
|
||||
@@ -613,7 +613,7 @@ func GetActStoreSkuInfo(ctx *jxcontext.Context, actID int, vendorIDs []int, keyw
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range actStoreSkuList {
|
||||
v.SkuName = jxutils.ComposeSkuName(v.Prefix, v.SkuNameName, v.Comment, v.Unit, v.SpecQuality, v.SpecUnit, 0)
|
||||
v.SkuName = jxutils.ComposeSkuName(v.Prefix, v.SkuNameName, v.Comment, v.Unit, v.SpecQuality, v.SpecUnit, 0, v.ExPrefix, v.ExPrefixBegin, v.ExPrefixEnd)
|
||||
}
|
||||
if pageSize > 0 && pageSize != model.UnlimitedPageSize {
|
||||
pagedInfo := &model.PagedInfo{
|
||||
|
||||
@@ -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,7 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku bool, params ma
|
||||
|
||||
var skuIDs []int
|
||||
for _, skuName := range skuNamesInfo.SkuNames {
|
||||
skuName.FullName = jxutils.ComposeSkuName(skuName.Prefix, skuName.Name, "", "", 0, "", 0, skuName.ExPrefix, skuName.ExPrefixBegin, skuName.ExPrefixEnd)
|
||||
if skuName.SkusStr != "" {
|
||||
if err = utils.UnmarshalUseNumber([]byte(skuName.SkusStr), &skuName.Skus); err != nil {
|
||||
dao.Rollback(db)
|
||||
@@ -852,7 +859,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 +877,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 +1336,102 @@ 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
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if fromTime != "" {
|
||||
fromTimeP = utils.Time2Date(utils.Str2Time(fromTime))
|
||||
}
|
||||
if toTime != "" {
|
||||
toTimeP = utils.Time2Date(utils.Str2Time(toTime))
|
||||
}
|
||||
if toTimeP.Before(fromTimeP) {
|
||||
return "", fmt.Errorf("结束时间不可以小于开始时间!开始时间:[%v],结束时间:[%v]", fromTimeP, toTimeP)
|
||||
}
|
||||
task := tasksch.NewParallelTask("批量设置商品前缀", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
step := batchItemList[0].(int)
|
||||
now := utils.Time2Date(time.Now())
|
||||
switch step {
|
||||
case 0:
|
||||
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,
|
||||
}
|
||||
if now.Sub(toTimeP) <= 0 && now.Sub(fromTimeP) >= 0 {
|
||||
_, err = UpdateSkuName(ctx, nameID, payload)
|
||||
} else if now.Sub(fromTimeP) > 0 && now.Sub(toTimeP) > 0 {
|
||||
payload["exPrefixBegin"] = nil
|
||||
payload["exPrefixEnd"] = nil
|
||||
_, err = UpdateSkuName(ctx, nameID, payload)
|
||||
} else {
|
||||
skuName := &model.SkuName{
|
||||
ExPrefix: exPrefix,
|
||||
ExPrefixBegin: &fromTimeP,
|
||||
ExPrefixEnd: &toTimeP,
|
||||
}
|
||||
skuName.ID = nameID
|
||||
skuName.LastOperator = ctx.GetLoginID()
|
||||
skuName.UpdatedAt = time.Now()
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
_, err = dao.UpdateEntity(db, skuName, "ExPrefix", "ExPrefixBegin", "ExPrefixEnd", "LastOperator", "UpdatedAt")
|
||||
dao.Commit(db)
|
||||
}
|
||||
return retVal, err
|
||||
}, nameIDs)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
_, err = task.GetResult(0)
|
||||
case 1:
|
||||
if (now.Sub(toTimeP) <= 0 && now.Sub(fromTimeP) >= 0) || (now.Sub(fromTimeP) > 0 && now.Sub(toTimeP) > 0) {
|
||||
var skuIDs []int
|
||||
skuList, err2 := dao.GetSkus(db, nil, nameIDs, nil, nil)
|
||||
if err = err2; err == nil {
|
||||
if len(skuList) > 0 {
|
||||
for _, v := range skuList {
|
||||
skuIDs = append(skuIDs, v.ID)
|
||||
}
|
||||
CurVendorSync.SyncStoresSkus2(ctx, db, partner.GetSingleStoreVendorIDs(), nil, false, skuIDs, nil, 0, true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, []int{0, 1})
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if !isAsync {
|
||||
_, err = task.GetResult(0)
|
||||
hint = "1"
|
||||
} else {
|
||||
hint = task.GetID()
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func SetSingleStoreSkuSyncModifyStatus(db *dao.DaoDB, vendorIDs []int) (err error) {
|
||||
_, err = dao.UpdateStoreSkuBindSyncStatusForExPrefix(db, vendorIDs)
|
||||
return err
|
||||
}
|
||||
|
||||
func SetMultiStoreSkuSyncModifyStatus(db *dao.DaoDB, vendorIDs []int) (err error) {
|
||||
_, err = dao.UpdateSkuSyncStatusForExPrefix(db, vendorIDs)
|
||||
return err
|
||||
}
|
||||
|
||||
func DeleteSkuNameExPrefixOverdue(db *dao.DaoDB) (err error) {
|
||||
_, err = dao.DeleteSkuNameExPrefixOverdue(db)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/360EntSecGroup-Skylar/excelize"
|
||||
|
||||
@@ -1149,6 +1150,12 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
if valid["status"] != nil {
|
||||
syncStatus |= model.SyncFlagStoreStatus
|
||||
}
|
||||
if vendorStoreName, ok := valid["vendorStoreName"].(string); ok {
|
||||
if utf8.RuneCountInString(vendorStoreName) > jdapi.MaxStoreNameLen && vendorID == model.VendorIDJD {
|
||||
return 0, fmt.Errorf("门店名称不允许超过13位!")
|
||||
}
|
||||
syncStatus |= model.SyncFlagStoreName
|
||||
}
|
||||
for _, v := range [][]string{
|
||||
[]string{
|
||||
"pricePercentagePack",
|
||||
@@ -1189,7 +1196,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if valid["status"] != nil { // 对于store vendor map,只有Status改变才需要同步到厂商
|
||||
if valid["status"] != nil || valid["vendorStoreName"] != nil { // 对于store vendor map,只有Status改变才需要同步到厂商
|
||||
num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeMap, valid, userName, map[string]interface{}{
|
||||
model.FieldStoreID: storeID,
|
||||
model.FieldVendorID: vendorID,
|
||||
@@ -1222,7 +1229,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
}
|
||||
}
|
||||
dao.Commit(db)
|
||||
if vendorID != model.VendorIDJX && (valid["status"] != nil || valid["freightDeductionPack"] != nil) {
|
||||
if vendorID != model.VendorIDJX && (valid["status"] != nil || valid["freightDeductionPack"] != nil || valid["vendorStoreName"] != nil) {
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
|
||||
}
|
||||
}
|
||||
@@ -2603,7 +2610,7 @@ func RefreshJdLevel(ctx *jxcontext.Context) (err error) {
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
v := batchItemList[0].(*model.StoreMap)
|
||||
var (
|
||||
pageLimit = 50
|
||||
pageLimit = 5
|
||||
pageNo = 1
|
||||
level string
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
||||
"git.rosy.net.cn/jx-callback/globals/api/apimanager"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
|
||||
@@ -42,6 +43,13 @@ const (
|
||||
CopyStoreSkuModeUpdatePrice = "updatePrice" // 增量复制价格
|
||||
)
|
||||
|
||||
//通用写入Excel
|
||||
type ExcelParam struct {
|
||||
DataList interface{}
|
||||
SheetName string
|
||||
TitleList []string
|
||||
}
|
||||
|
||||
// UpdateStoreSku用,API调用时
|
||||
type StoreSkuBindSkuInfo struct {
|
||||
SkuID int `json:"skuID"`
|
||||
@@ -117,6 +125,14 @@ type SheetParam struct {
|
||||
SkuRow int
|
||||
}
|
||||
|
||||
type DataVendorStoreSkuPrice struct {
|
||||
StoreID string `json:"门店ID"`
|
||||
StoreName string `json:"门店名"`
|
||||
SkuID int `json:"商品ID"`
|
||||
SkuName string `json:"商品名"`
|
||||
VendorPrice string `json:"平台价"`
|
||||
}
|
||||
|
||||
type DataSuccess struct {
|
||||
NameID int `json:"商品NameID"`
|
||||
Name string `json:"商品名称"`
|
||||
@@ -151,7 +167,14 @@ var (
|
||||
"18180948107": 1, // 徐
|
||||
// "13684045763": 1, // 周
|
||||
}
|
||||
dataLock DataLock
|
||||
dataLock DataLock
|
||||
titleListVendorStoreSkuPrice = []string{
|
||||
"门店ID",
|
||||
"门店名",
|
||||
"商品ID",
|
||||
"商品名",
|
||||
"平台价",
|
||||
}
|
||||
titleListSuccess = []string{
|
||||
"商品NameID",
|
||||
"商品名称",
|
||||
@@ -2484,3 +2507,139 @@ func IsChineseChar(str string) bool {
|
||||
func GetStoreCategories(ctx *jxcontext.Context, storeID, parentID int) (catList []*model.SkuCategory, err error) {
|
||||
return dao.GetStoreSkuCategories(dao.GetDB(), storeID, parentID)
|
||||
}
|
||||
|
||||
func GetVendorStoreSkuPrice(ctx *jxcontext.Context, vendorIDs []int, skuID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
var (
|
||||
storeSkuListJD []DataVendorStoreSkuPrice
|
||||
storeSkuListMT []DataVendorStoreSkuPrice
|
||||
storeSkuListEB []DataVendorStoreSkuPrice
|
||||
excelParamList []ExcelParam
|
||||
)
|
||||
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
for _, v := range vendorIDs {
|
||||
vendorID := v
|
||||
handler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
||||
handlerStore := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IStoreHandler)
|
||||
for _, v := range apimanager.CurAPIManager.GetAppOrgCodeList(vendorID) {
|
||||
vendorStoreIDs, err2 := handlerStore.GetAllStoresVendorID(ctx, v)
|
||||
err = err2
|
||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
vendorStoreID := batchItemList[0].(string)
|
||||
var (
|
||||
inStoreSkuList []*partner.StoreSkuInfo
|
||||
storeDetail *dao.StoreDetail
|
||||
inStoreSku = &partner.StoreSkuInfo{}
|
||||
)
|
||||
db := dao.GetDB()
|
||||
skuNameList, err := dao.GetSkus(db, []int{skuID}, nil, nil, nil)
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
if partner.IsMultiStore(vendorID) {
|
||||
multiHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler)
|
||||
storeDetail, err = multiHandler.ReadStore(ctx, v, vendorStoreID)
|
||||
if len(skuNameList) > 0 {
|
||||
inStoreSku.VendorSkuID = utils.Int64ToStr(skuNameList[0].JdID)
|
||||
}
|
||||
} else {
|
||||
singleHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreHandler)
|
||||
storeDetail, err = singleHandler.ReadStore(ctx, v, vendorStoreID)
|
||||
inStoreSku.SkuID = skuID
|
||||
}
|
||||
inStoreSkuList = append(inStoreSkuList, inStoreSku)
|
||||
outStoreSkuList, err := handler.GetStoreSkusBareInfo(ctx, v, task, 0, vendorStoreID, inStoreSkuList)
|
||||
if storeDetail != nil {
|
||||
if len(outStoreSkuList) == 0 {
|
||||
data := DataVendorStoreSkuPrice{
|
||||
StoreID: vendorStoreID,
|
||||
StoreName: storeDetail.Name,
|
||||
SkuID: skuID,
|
||||
SkuName: skuNameList[0].Name,
|
||||
VendorPrice: "",
|
||||
}
|
||||
retVal = []DataVendorStoreSkuPrice{data}
|
||||
} else {
|
||||
data := DataVendorStoreSkuPrice{
|
||||
StoreID: vendorStoreID,
|
||||
StoreName: storeDetail.Name,
|
||||
SkuID: skuID,
|
||||
SkuName: skuNameList[0].Name,
|
||||
VendorPrice: utils.Float64ToStr(utils.Str2Float64(utils.Int64ToStr(outStoreSkuList[0].VendorPrice)) / 100),
|
||||
}
|
||||
retVal = []DataVendorStoreSkuPrice{data}
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}
|
||||
taskParallel := tasksch.NewParallelTask("获取各平台所有门店某商品价格", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, taskFunc, vendorStoreIDs)
|
||||
tasksch.HandleTask(taskParallel, task, true).Run()
|
||||
storeSkuList, _ := taskParallel.GetResult(0)
|
||||
for _, v := range storeSkuList {
|
||||
if vendorID == model.VendorIDJD {
|
||||
storeSkuListJD = append(storeSkuListJD, v.(DataVendorStoreSkuPrice))
|
||||
}
|
||||
if vendorID == model.VendorIDEBAI {
|
||||
storeSkuListEB = append(storeSkuListEB, v.(DataVendorStoreSkuPrice))
|
||||
}
|
||||
if vendorID == model.VendorIDMTWM {
|
||||
storeSkuListMT = append(storeSkuListMT, v.(DataVendorStoreSkuPrice))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
excelParam1 := ExcelParam{
|
||||
DataList: storeSkuListJD,
|
||||
TitleList: titleListVendorStoreSkuPrice,
|
||||
SheetName: "京东平台",
|
||||
}
|
||||
excelParam2 := ExcelParam{
|
||||
DataList: storeSkuListEB,
|
||||
TitleList: titleListVendorStoreSkuPrice,
|
||||
SheetName: "饿百平台",
|
||||
}
|
||||
excelParam3 := ExcelParam{
|
||||
DataList: storeSkuListMT,
|
||||
TitleList: titleListVendorStoreSkuPrice,
|
||||
SheetName: "美团平台",
|
||||
}
|
||||
excelParamList = append(excelParamList, excelParam1, excelParam2, excelParam3)
|
||||
case 1:
|
||||
WriteToExcelNormal(task, "各平台"+utils.Int2Str(skuID)+"商品所有门店价格", excelParamList)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
taskSeq := tasksch.NewSeqTask2("获取各平台所有门店某商品价格-序列任务", ctx, isContinueWhenError, taskSeqFunc, 2)
|
||||
tasksch.HandleTask(taskSeq, nil, true).Run()
|
||||
if !isAsync {
|
||||
_, err = taskSeq.GetResult(0)
|
||||
hint = "1"
|
||||
} else {
|
||||
hint = taskSeq.GetID()
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func WriteToExcelNormal(task *tasksch.SeqTask, fileName string, excelParam []ExcelParam) (err error) {
|
||||
var sheetList []*excel.Obj2ExcelSheetConfig
|
||||
for _, v := range excelParam {
|
||||
if v.DataList != nil {
|
||||
excelConf := &excel.Obj2ExcelSheetConfig{
|
||||
Title: v.SheetName,
|
||||
Data: v.DataList,
|
||||
CaptionList: v.TitleList,
|
||||
}
|
||||
sheetList = append(sheetList, excelConf)
|
||||
}
|
||||
}
|
||||
downloadURL, fileNameResult, err := jxutils.UploadExeclAndPushMsg(sheetList, fileName)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s failed error:%v", fileNameResult, err)
|
||||
} else {
|
||||
noticeMsg := fmt.Sprintf("[详情点我]path=%s \n", downloadURL)
|
||||
task.SetNoticeMsg(noticeMsg)
|
||||
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s success, downloadURL:%s", fileNameResult, downloadURL)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -340,10 +340,10 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin
|
||||
//多规格商品不用比较数量单位
|
||||
if jxSkuInfo.IsSpu == 0 {
|
||||
//jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..)
|
||||
jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus[0].Comment, jxSkuInfo.SkuName.Unit, jxSkuInfo.Skus[0].SkuSpecQuality, jxSkuInfo.Skus[0].SkuSpecUnit, 0)
|
||||
jxSkuDetailName = jxutils.ComposeSkuNameOriginal(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus[0].Comment, jxSkuInfo.SkuName.Unit, jxSkuInfo.Skus[0].SkuSpecQuality, jxSkuInfo.Skus[0].SkuSpecUnit, 0)
|
||||
} else {
|
||||
//jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..)
|
||||
jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus[0].Comment, "", jxSkuInfo.Skus[0].SkuSpecQuality, "", 0)
|
||||
jxSkuDetailName = jxutils.ComposeSkuNameOriginal(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus[0].Comment, "", jxSkuInfo.Skus[0].SkuSpecQuality, "", 0)
|
||||
}
|
||||
|
||||
//jxSkuSaleStatus : 商品状态 ,skustatus 优先级高于 StoreSkuStatus
|
||||
@@ -462,9 +462,9 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool
|
||||
var jxSkuDetailName string
|
||||
//多规格商品不用比较数量单位
|
||||
if jxSkuInfo.IsSpu == 0 {
|
||||
jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, jxSkuInfo.Unit, jxSkuInfo.SpecQuality, jxSkuInfo.SpecUnit, 0)
|
||||
jxSkuDetailName = jxutils.ComposeSkuNameOriginal(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, jxSkuInfo.Unit, jxSkuInfo.SpecQuality, jxSkuInfo.SpecUnit, 0)
|
||||
} else {
|
||||
jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, "", jxSkuInfo.SpecQuality, "", 0)
|
||||
jxSkuDetailName = jxutils.ComposeSkuNameOriginal(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, "", jxSkuInfo.SpecQuality, "", 0)
|
||||
}
|
||||
|
||||
vendorSkuInfoMap := filterVendorSkuInfoMap[skuid]
|
||||
|
||||
@@ -708,7 +708,7 @@ func (v *VendorSync) ChangeStoreSkuSaleStatus(ctx *jxcontext.Context, storeID in
|
||||
skuIDs = append(skuIDs, v.SkuID)
|
||||
}
|
||||
vendorIDs := partner.GetPurchasePlatformVendorIDs()
|
||||
dao.UpdateStoreSkuBindSyncStatus(db, vendorIDs, storeID)
|
||||
dao.UpdateStoreSkuBindSyncStatusForSaleStatus(db, vendorIDs, storeID)
|
||||
v.SyncStoresSkus(ctx, db, vendorIDs, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ 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)
|
||||
skuVendorInfo.SkuName = jxutils.ComposeSkuName(skuVendorInfo.Prefix, skuVendorInfo.Name, skuVendorInfo.Comment, skuVendorInfo.Unit, skuVendorInfo.SpecQuality, skuVendorInfo.SpecUnit, 0, skuVendorInfo.ExPrefix, skuVendorInfo.ExPrefixBegin, skuVendorInfo.ExPrefixEnd)
|
||||
skuVendorInfo.MergedStatus = jxutils.MergeSkuStatus(skuVendorInfo.Status, skuVendorInfo.NameStatus)
|
||||
if multiStoresHandler, ok := partner.GetPurchasePlatformFromVendorID(skuVendorInfo.VendorID).(partner.IMultipleStoresHandler); ok {
|
||||
if model.IsSyncStatusDelete(skuVendorInfo.SkuSyncStatus) { //删除
|
||||
|
||||
@@ -228,7 +228,7 @@ func calVendorPrice4StoreSku(inSku *dao.StoreSkuSyncInfo, pricePercentagePack mo
|
||||
func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyncInfo {
|
||||
for _, skuItem := range inSkuList {
|
||||
skuItem.MergedStatus = jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus)
|
||||
skuItem.SkuName = jxutils.ComposeSkuName(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0)
|
||||
skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd)
|
||||
}
|
||||
return inSkuList
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ func GetStoreSkuSalesInfo(ctx *jxcontext.Context, storeID int) (outStoreSkuSales
|
||||
if storeSkuInfo != nil {
|
||||
skuName := storeSkuInfo.SkuName
|
||||
skuInfo := storeSkuInfo.Skus[0]
|
||||
storeSkuSales.SkuName = jxutils.ComposeSkuName(skuName.Prefix, skuName.Name, skuInfo.Comment, skuName.Unit, skuInfo.SkuSpecQuality, skuInfo.SkuSpecUnit, 0)
|
||||
storeSkuSales.SkuName = jxutils.ComposeSkuName(skuName.Prefix, skuName.Name, skuInfo.Comment, skuName.Unit, skuInfo.SkuSpecQuality, skuInfo.SkuSpecUnit, 0,skuName.ExPrefix,skuName.ExPrefixBegin,skuName.ExPrefixEnd)
|
||||
storeSkuSales.SkuImage = storeSkuInfo.Img
|
||||
storeSkuSales.SkuPrice = jxutils.IntPrice2StandardCurrencyString(int64(storeSkuInfo.Skus[0].BindPrice))
|
||||
} else if skuAndNameInfo != nil {
|
||||
@@ -159,7 +159,7 @@ func GetStoreSkuSalesInfo(ctx *jxcontext.Context, storeID int) (outStoreSkuSales
|
||||
storeSkuSales.SkuImage = skuNameList[0].Img
|
||||
prefix = skuNameList[0].Prefix
|
||||
}
|
||||
storeSkuSales.SkuName = jxutils.ComposeSkuName(prefix, skuAndNameInfo.Name, skuAndNameInfo.Comment, skuAndNameInfo.Unit, skuAndNameInfo.SpecQuality, skuAndNameInfo.SpecUnit, 0)
|
||||
storeSkuSales.SkuName = jxutils.ComposeSkuName(prefix, skuAndNameInfo.Name, skuAndNameInfo.Comment, skuAndNameInfo.Unit, skuAndNameInfo.SpecQuality, skuAndNameInfo.SpecUnit, 0,skuAndNameInfo.ExPrefix,skuAndNameInfo.ExPrefixBegin,skuAndNameInfo.ExPrefixEnd)
|
||||
storeSkuSales.SkuPrice = "N/A"
|
||||
} else {
|
||||
storeSkuSales.SkuName = "N/A"
|
||||
|
||||
@@ -1451,7 +1451,7 @@ func BuildSkuFromEbaiStore(ctx *jxcontext.Context, baiduShopID int64, isAsync, i
|
||||
}
|
||||
price := sku.LinkID
|
||||
sku.LinkID = 0
|
||||
skuName := jxutils.ComposeSkuName(skuNameExt.Prefix, skuNameExt.Name, sku.Comment, skuNameExt.Unit, sku.SpecQuality, sku.SpecUnit, jdapi.MaxSkuNameCharCount)
|
||||
skuName := jxutils.ComposeSkuNameOriginal(skuNameExt.Prefix, skuNameExt.Name, sku.Comment, skuNameExt.Unit, sku.SpecQuality, sku.SpecUnit, jdapi.MaxSkuNameCharCount)
|
||||
fixedStatus := 1
|
||||
if sku.Status != model.SkuStatusNormal {
|
||||
fixedStatus = 2
|
||||
|
||||
@@ -327,7 +327,7 @@ func FloatWeight2Int(weight float32) int {
|
||||
return int(math.Round(float64(weight * 1000)))
|
||||
}
|
||||
|
||||
func ComposeSkuName(prefix, name, comment, unit string, spec_quality float32, spec_unit string, maxLen int) (skuName string) {
|
||||
func ComposeSkuNameOriginal(prefix, name, comment, unit string, spec_quality float32, spec_unit string, maxLen int) (skuName string) {
|
||||
if prefix != "" {
|
||||
skuName = "[" + prefix + "]"
|
||||
}
|
||||
@@ -348,6 +348,29 @@ func ComposeSkuName(prefix, name, comment, unit string, spec_quality float32, sp
|
||||
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) {
|
||||
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
|
||||
}
|
||||
}
|
||||
skuName += ComposeSkuNameOriginal(prefix, name, comment, unit, spec_quality, spec_unit, maxLen)
|
||||
return skuName
|
||||
}
|
||||
|
||||
func ComposeSkuNameSync(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 += ComposeSkuNameOriginal(prefix, name, comment, unit, spec_quality, spec_unit, maxLen)
|
||||
return skuName
|
||||
}
|
||||
|
||||
func ComposeSpuName(prefix, name string, maxLen int) (spuName string) {
|
||||
if prefix != "" {
|
||||
spuName = "[" + prefix + "]"
|
||||
|
||||
@@ -199,10 +199,13 @@ type ActStoreSku2 struct {
|
||||
|
||||
SkuName string `json:"skuName"`
|
||||
|
||||
Prefix string `json:"-"`
|
||||
SkuNameName string `orm:"column(sku_name_name)" json:"-"`
|
||||
Unit string `orm:"size(8)" json:"-"`
|
||||
SpecQuality float32 `json:"-"`
|
||||
SpecUnit string `json:"-"`
|
||||
Comment string `json:"-"`
|
||||
Prefix string `json:"-"`
|
||||
ExPrefix string
|
||||
ExPrefixBegin *time.Time
|
||||
ExPrefixEnd *time.Time
|
||||
SkuNameName string `orm:"column(sku_name_name)" json:"-"`
|
||||
Unit string `orm:"size(8)" json:"-"`
|
||||
SpecQuality float32 `json:"-"`
|
||||
SpecUnit string `json:"-"`
|
||||
Comment string `json:"-"`
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func GetActStoreSkuVendorList(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs
|
||||
END vendor_sku_id,
|
||||
t4.comment, t4.spec_quality, t4.spec_unit,
|
||||
t6.name store_name,
|
||||
t7.name sku_name_name, t7.unit, t7.prefix
|
||||
t7.name sku_name_name, t7.unit, t7.prefix, t7.ex_prefix, t7.ex_prefix_begin, t7.ex_prefix_end
|
||||
FROM act_store_sku t1
|
||||
%s JOIN act_store_sku_map t2 ON t2.act_id = ? AND t2.bind_id = t1.id AND t2.deleted_at = ?`, jdVendorIDField, leftOrEmpty)
|
||||
sqlParams := []interface{}{
|
||||
|
||||
@@ -278,7 +278,7 @@ func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, snapDate time.Tim
|
||||
err = err2
|
||||
if len(skuList) > 0 {
|
||||
skuAndName := skuList[0]
|
||||
jxSkuDetailName := jxutils.ComposeSkuName(skuAndName.Prefix, skuAndName.Name, skuAndName.Comment, skuAndName.Unit, skuAndName.SpecQuality, skuAndName.SpecUnit, 0)
|
||||
jxSkuDetailName := jxutils.ComposeSkuNameOriginal(skuAndName.Prefix, skuAndName.Name, skuAndName.Comment, skuAndName.Unit, skuAndName.SpecQuality, skuAndName.SpecUnit, 0)
|
||||
v.SkuName = jxSkuDetailName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func GetCategories(db *DaoDB, parentID, level int, catIDs []int) (cats []*model.
|
||||
|
||||
func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int) (skuList []*model.SkuAndName, err error) {
|
||||
sql := `
|
||||
SELECT t1.*, t2.name, t2.unit, t2.prefix, t2.is_spu
|
||||
SELECT t1.*, t2.name, t2.unit, t2.prefix, t2.is_spu, t2.ex_prefix, t2.ex_prefix_begin, t2.ex_prefix_end
|
||||
FROM sku t1
|
||||
JOIN sku_name t2 ON t2.id = t1.name_id AND t2.deleted_at = ?
|
||||
`
|
||||
@@ -260,7 +260,9 @@ func GetSkusWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string, nameIDs
|
||||
IF(t11.resource_type IS NULL OR t11.resource_type <> ?, t2.img, '') img,
|
||||
IF(t12.resource_type IS NULL OR t12.resource_type <> ?, t2.img2, '') img2,
|
||||
t2.desc_img,
|
||||
|
||||
t2.ex_prefix,
|
||||
t2.ex_prefix_begin,
|
||||
t2.ex_prefix_end,
|
||||
t3.jd_category_id vendor_vendor_cat_id,
|
||||
|
||||
t3m.sync_status cat_sync_status,
|
||||
@@ -307,7 +309,6 @@ func GetSkusWithVendor(db *DaoDB, vendorIDs []int, appOrgCodes []string, nameIDs
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
}
|
||||
sql += " ORDER BY t1.seq"
|
||||
|
||||
if err = GetRows(db, &skuList, sql, sqlParams...); err == nil {
|
||||
skuPlaceList, err2 := GetSkuNamePlaces(db, nameIDs, skuIDs)
|
||||
if err = err2; err == nil {
|
||||
|
||||
@@ -14,10 +14,11 @@ type StoreDetail struct {
|
||||
|
||||
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||
|
||||
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
||||
VendorStatus int `json:"vendor_status"` // 取值同Store.Status
|
||||
DeliveryFee int `json:"deliveryFee"`
|
||||
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
||||
VendorStoreName string `json:"vendorStoreName"`
|
||||
VendorStatus int `json:"vendor_status"` // 取值同Store.Status
|
||||
DeliveryFee int `json:"deliveryFee"`
|
||||
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||
|
||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||
PricePercentagePackStr string `orm:"size(4096)" json:"-"` //
|
||||
@@ -81,7 +82,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
sql := `
|
||||
SELECT t1.*,
|
||||
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status, t2.vendor_org_code,
|
||||
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
|
||||
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name,
|
||||
t3.value price_percentage_pack_str,
|
||||
t4.value freight_deduction_pack_str,
|
||||
district.name district_name,
|
||||
|
||||
@@ -56,7 +56,10 @@ type StoreSkuSyncInfo struct {
|
||||
model.Sku
|
||||
|
||||
// sku_name
|
||||
Prefix string
|
||||
Prefix string
|
||||
ExPrefix string
|
||||
ExPrefixBegin *time.Time
|
||||
ExPrefixEnd *time.Time
|
||||
// NameID int `orm:"column(name_id)"`
|
||||
VendorNameID string `orm:"column(vendor_name_id)"` // 暂时无用
|
||||
Name string
|
||||
@@ -312,7 +315,7 @@ func newGetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty
|
||||
%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,
|
||||
t2.*,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.ex_prefix, t3.ex_prefix_begin, t3.ex_prefix_end,
|
||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||
IF(t12.%s <> '', t12.%s, t3.img2) img2,
|
||||
t13.%s desc_img,
|
||||
@@ -417,7 +420,7 @@ func oldGetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty
|
||||
%s.%s_id vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price,
|
||||
t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end,
|
||||
t2.*,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc,t3.ex_prefix, t3.ex_prefix_begin, t3.ex_prefix_end,
|
||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||
IF(t12.%s <> '', t12.%s, t3.img2) img2,
|
||||
t13.%s desc_img,
|
||||
@@ -519,7 +522,7 @@ func newGetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSync
|
||||
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,
|
||||
t2.*, t2.id sku_id, t2m.vendor_thing_id vendor_sku_id,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc,
|
||||
t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.ex_prefix, t3.ex_prefix_begin, t3.ex_prefix_end,
|
||||
IF(t11.%s <> '', t11.%s, t3.img) img,
|
||||
IF(t12.%s <> '', t12.%s, t3.img2) img2,
|
||||
t13.%s desc_img,
|
||||
@@ -868,7 +871,7 @@ func GetStoresSkusInfoBySaleTime(db *DaoDB, storeID int) (storeSkuBindList []*mo
|
||||
return storeSkuBindList, err
|
||||
}
|
||||
|
||||
func UpdateStoreSkuBindSyncStatus(db *DaoDB, vendorIDs []int, storeID int) (num int64, err error) {
|
||||
func UpdateStoreSkuBindSyncStatusForSaleStatus(db *DaoDB, vendorIDs []int, storeID int) (num int64, err error) {
|
||||
sql := `
|
||||
UPDATE store_sku_bind
|
||||
SET
|
||||
@@ -900,6 +903,81 @@ func UpdateStoreSkuBindSyncStatus(db *DaoDB, vendorIDs []int, storeID int) (num
|
||||
return ExecuteSQL(db, sql, sqlParams...)
|
||||
}
|
||||
|
||||
func UpdateStoreSkuBindSyncStatusForExPrefix(db *DaoDB, vendorIDs []int) (num int64, err error) {
|
||||
sql := `
|
||||
UPDATE store_sku_bind a
|
||||
JOIN sku b ON a.sku_id = b.id AND b.deleted_at = ?
|
||||
JOIN sku_name c ON c.id = b.name_id AND c.deleted_at = ?
|
||||
SET
|
||||
`
|
||||
fmtParams := []interface{}{}
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if len(vendorIDs) > 0 {
|
||||
for _, v := range vendorIDs {
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[v])
|
||||
sql += ` %s_sync_status = %s_sync_status | ?,`
|
||||
fmtParams = append(fmtParams, fieldPrefix)
|
||||
sqlParams = append(sqlParams, model.SyncFlagModifiedMask)
|
||||
}
|
||||
} else {
|
||||
return 0, errors.New("取平台ID名有错误!partner.GetPurchasePlatformVendorIDs()")
|
||||
}
|
||||
sql = sql[0:strings.LastIndex(sql, ",")]
|
||||
sql = fmt.Sprintf(sql, fmtParams...)
|
||||
sql += ` WHERE a.deleted_at = ?
|
||||
AND c.ex_prefix != ""
|
||||
AND (c.ex_prefix_begin = DATE_FORMAT(DATE_ADD(NOW(),INTERVAL '6' HOUR),'%Y-%m-%d 00:00:00')
|
||||
OR c.ex_prefix_end = DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'))
|
||||
`
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||
return ExecuteSQL(db, sql, sqlParams...)
|
||||
}
|
||||
|
||||
func UpdateSkuSyncStatusForExPrefix(db *DaoDB, vendorIDs []int) (num int64, err error) {
|
||||
sql := `
|
||||
UPDATE sku b
|
||||
JOIN sku_name c ON c.id = b.name_id AND c.deleted_at = ?
|
||||
SET
|
||||
`
|
||||
fmtParams := []interface{}{}
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if len(vendorIDs) > 0 {
|
||||
for _, v := range vendorIDs {
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[v])
|
||||
sql += ` b.%s_sync_status = b.%s_sync_status | ?,`
|
||||
fmtParams = append(fmtParams, fieldPrefix)
|
||||
sqlParams = append(sqlParams, model.SyncFlagModifiedMask)
|
||||
}
|
||||
} else {
|
||||
return 0, errors.New("取平台ID名有错误!partner.GetPurchasePlatformVendorIDs()")
|
||||
}
|
||||
sql = sql[0:strings.LastIndex(sql, ",")]
|
||||
sql = fmt.Sprintf(sql, fmtParams...)
|
||||
sql += ` WHERE b.deleted_at = ?
|
||||
AND c.ex_prefix != ""
|
||||
AND (c.ex_prefix_begin = DATE_FORMAT(DATE_ADD(NOW(),INTERVAL '6' HOUR),'%Y-%m-%d 00:00:00')
|
||||
OR c.ex_prefix_end = DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'))
|
||||
`
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||
return ExecuteSQL(db, sql, sqlParams...)
|
||||
}
|
||||
|
||||
func DeleteSkuNameExPrefixOverdue(db *DaoDB) (num int64, err error) {
|
||||
sql := `
|
||||
UPDATE sku_name
|
||||
SET ex_prefix_begin = null,ex_prefix_end = null
|
||||
WHERE deleted_at = ?
|
||||
AND DATE_FORMAT(DATE_ADD(NOW(),INTERVAL '6' HOUR),'%Y-%m-%d 00:00:00') >= ex_prefix_end
|
||||
`
|
||||
sqlParams := []interface{}{utils.DefaultTimeValue}
|
||||
return ExecuteSQL(db, sql, sqlParams...)
|
||||
}
|
||||
|
||||
func GetStoreSkusByNameIDs(db *DaoDB, storeIDs []int, nameID int) (skuList []*StoreSkuSyncInfo, err error) {
|
||||
sql := `
|
||||
SELECT a.*,c.unit,c.name
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
SkuCategoryNormal = 0
|
||||
SkuCategorySpecial = 1
|
||||
@@ -166,8 +168,12 @@ func (*SkuCategory) TableIndex() [][]string {
|
||||
type SkuName struct {
|
||||
ModelIDCULD
|
||||
|
||||
Prefix string `orm:"size(255)" json:"prefix"`
|
||||
Name string `orm:"size(255);index" json:"name"`
|
||||
Prefix string `orm:"size(255)" json:"prefix"`
|
||||
Name string `orm:"size(255);index" json:"name"`
|
||||
ExPrefix string `orm:"size(255)" json:"exPrefix"`
|
||||
|
||||
ExPrefixBegin *time.Time `orm:"null" json:"exPrefixBegin"`
|
||||
ExPrefixEnd *time.Time `orm:"null" json:"exPrefixEnd"`
|
||||
|
||||
BrandID int `orm:"column(brand_id);default(0)" json:"brandID"` // todo,此属性暂时没有使用,且有问题,应该是不同平台都有一个brandid
|
||||
CategoryID int `orm:"column(category_id);index" json:"categoryID"` // 标准类别
|
||||
@@ -203,6 +209,12 @@ func (*SkuName) TableUnique() [][]string {
|
||||
}
|
||||
}
|
||||
|
||||
func (*SkuName) TableIndex() [][]string {
|
||||
return [][]string{
|
||||
[]string{"ExPrefix", "ExPrefixBegin", "ExPrefixEnd", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
type Sku struct {
|
||||
ModelIDCULD
|
||||
|
||||
@@ -223,10 +235,13 @@ type Sku struct {
|
||||
|
||||
type SkuAndName struct {
|
||||
Sku
|
||||
Name string
|
||||
Unit string
|
||||
Prefix string
|
||||
IsSpu int
|
||||
Name string
|
||||
Unit string
|
||||
Prefix string
|
||||
IsSpu int
|
||||
ExPrefix string
|
||||
ExPrefixBegin *time.Time
|
||||
ExPrefixEnd *time.Time
|
||||
}
|
||||
|
||||
func (*Sku) TableUnique() [][]string {
|
||||
@@ -255,9 +270,9 @@ type SkuWithVendor struct {
|
||||
|
||||
type SkuNameExt struct {
|
||||
SkuName
|
||||
Skus []*SkuWithVendor `orm:"-" json:"skus"`
|
||||
SkusStr string `json:"-"`
|
||||
|
||||
Places []int `orm:"-" json:"places"`
|
||||
PlacesStr string `json:"-"`
|
||||
Skus []*SkuWithVendor `orm:"-" json:"skus"`
|
||||
SkusStr string `json:"-"`
|
||||
FullName string `json:"fullName"`
|
||||
Places []int `orm:"-" json:"places"`
|
||||
PlacesStr string `json:"-"`
|
||||
}
|
||||
|
||||
@@ -388,9 +388,10 @@ type StoreMap struct {
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||
|
||||
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
||||
Status int `json:"status"` // 取值同Store.Status
|
||||
StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字
|
||||
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
||||
Status int `json:"status"` // 取值同Store.Status
|
||||
StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字,由平台到京西
|
||||
VendorStoreName string `orm:"size(255)" json:"vendorStoreName"` //平台门店名,由京西到平台
|
||||
|
||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||
PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` //
|
||||
|
||||
@@ -30,9 +30,10 @@ type tEbaiStoreInfo struct {
|
||||
EbaiStoreStatus int
|
||||
SyncStatus int
|
||||
|
||||
ProvinceID int `orm:"column(province_id)"`
|
||||
CityID int `orm:"column(city_id)"`
|
||||
DistrictID int `orm:"column(district_id)"`
|
||||
ProvinceID int `orm:"column(province_id)"`
|
||||
CityID int `orm:"column(city_id)"`
|
||||
DistrictID int `orm:"column(district_id)"`
|
||||
VendorStoreName string
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
|
||||
@@ -156,7 +157,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.status ebai_store_status, t2.vendor_store_id, t2.vendor_org_code,
|
||||
IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status
|
||||
IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status, t2.vendor_store_name
|
||||
FROM store t1
|
||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
|
||||
WHERE t1.id = ?
|
||||
@@ -392,8 +393,12 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
||||
if store.VendorStoreID != "" {
|
||||
params["baidu_shop_id"] = store.VendorStoreID
|
||||
}
|
||||
if store.SyncStatus&(model.SyncFlagNewMask /*|model.SyncFlagStoreName*/) != 0 {
|
||||
params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI)
|
||||
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
|
||||
if store.VendorStoreName != "" {
|
||||
params["name"] = store.VendorStoreName
|
||||
} else {
|
||||
params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI)
|
||||
}
|
||||
}
|
||||
params["address"] = store.Address
|
||||
// todo 饿百 开店审核通过后不允许修改商户信息
|
||||
|
||||
@@ -36,6 +36,7 @@ type tJdStoreInfo struct {
|
||||
VendorStoreID string `orm:"column(vendor_store_id)"`
|
||||
RealLastOperator string
|
||||
SyncStatus int
|
||||
VendorStoreName string
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -123,7 +124,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code,
|
||||
t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator,
|
||||
t2.last_operator) real_last_operator,
|
||||
t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code
|
||||
t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name
|
||||
FROM store t1
|
||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
|
||||
LEFT JOIN place city ON t1.city_code = city.code
|
||||
@@ -146,7 +147,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
storeParams.OutSystemID = store.VendorStoreID
|
||||
}
|
||||
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
|
||||
storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
|
||||
if store.VendorStoreName != "" {
|
||||
storeParams.StationName = store.VendorStoreName
|
||||
} else {
|
||||
storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
|
||||
}
|
||||
}
|
||||
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 {
|
||||
storeParams.StationAddress = store.Address
|
||||
|
||||
@@ -406,7 +406,7 @@ func generateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64
|
||||
Count: v.Count,
|
||||
SalePrice: int64(storeSkuBind.JxPrice), // todo 考虑活动价
|
||||
Weight: sku.Weight,
|
||||
Name: jxutils.ComposeSkuName(sku.Prefix, sku.Name, sku.Comment, sku.Unit, sku.SpecQuality, sku.SpecUnit, 0),
|
||||
Name: jxutils.ComposeSkuName(sku.Prefix, sku.Name, sku.Comment, sku.Unit, sku.SpecQuality, sku.SpecUnit, 0, sku.ExPrefix, sku.ExPrefixBegin, sku.ExPrefixEnd),
|
||||
}
|
||||
if storeSkuBind.ActPrice != 0 && storeSkuBind.ActPrice < storeSkuBind.JxPrice {
|
||||
jxSku.SalePrice = int64(storeSkuBind.ActPrice)
|
||||
|
||||
@@ -101,6 +101,7 @@ func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||
var name string
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -115,10 +116,16 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
return err
|
||||
}
|
||||
mergedStoreStatus := jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus)
|
||||
name = remoteStoreInfo.Name
|
||||
if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
|
||||
if storeDetail.VendorStoreName != "" {
|
||||
name = storeDetail.VendorStoreName
|
||||
}
|
||||
}
|
||||
// openLevel, isOnline := bizStatusJX2Mtwm(mergedStoreStatus)
|
||||
params := map[string]interface{}{
|
||||
"name": remoteStoreInfo.Name, //jxutils.ComposeStoreName(storeDetail.Store.Name, model.VendorIDMTWM),
|
||||
"address": storeDetail.Address, // 美团好像地址也不能改的?
|
||||
"name": name, //jxutils.ComposeStoreName(storeDetail.Store.Name, model.VendorIDMTWM),
|
||||
"address": storeDetail.Address, // 美团好像地址也不能改的?
|
||||
"longitude": jxutils.IntCoordinate2Standard(int(remoteStoreInfo.Longitude)),
|
||||
"latitude": jxutils.IntCoordinate2Standard(int(remoteStoreInfo.Latitude)),
|
||||
"phone": storeDetail.Tel1,
|
||||
|
||||
@@ -246,7 +246,7 @@ func GetRecipeDetail(ctx *jxcontext.Context, recipeID int) (recipeDetail *FoodRe
|
||||
}
|
||||
choiceMap := make(map[int8][]*dao.FoodRecipeItemChoiceExt)
|
||||
for _, v := range itemChoiceList {
|
||||
v.SkuName = jxutils.ComposeSkuName(v.Prefix, v.SkuNameName, v.Comment, v.Unit, v.SpecQuality, v.SpecUnit, 0)
|
||||
v.SkuName = jxutils.ComposeSkuNameOriginal(v.Prefix, v.SkuNameName, v.Comment, v.Unit, v.SpecQuality, v.SpecUnit, 0)
|
||||
choiceMap[v.Index] = append(choiceMap[v.Index], v)
|
||||
}
|
||||
|
||||
|
||||
@@ -191,6 +191,9 @@ func (c *SkuController) UpdateSkuName() {
|
||||
// dummySkuName := &model.SkuName{}
|
||||
payload := make(map[string]interface{})
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
||||
delete(payload, "exPrefix")
|
||||
delete(payload, "exPrefixBegin")
|
||||
delete(payload, "exPrefixEnd")
|
||||
retVal, err = cms.UpdateSkuName(params.Ctx, params.NameID, payload)
|
||||
}
|
||||
return retVal, "", err
|
||||
@@ -390,3 +393,25 @@ func (c *SkuController) GetJdUpcCodeByName() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 批量设置商品额外前缀
|
||||
// @Description 批量设置商品额外前缀
|
||||
// @Param token header string true "认证token"
|
||||
// @Param nameIDs formData string true "商品nameIDs"
|
||||
// @Param exPrefix formData string true "商品额外前缀"
|
||||
// @Param fromDate formData string true "生效开始时间,格式 2006-01-01 "
|
||||
// @Param toDate formData string true "生效结束时间,格式 2006-01-01 "
|
||||
// @Param isAsync formData bool false "是否异步"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateSkuNamesExPrefix [put]
|
||||
func (c *SkuController) UpdateSkuNamesExPrefix() {
|
||||
c.callUpdateSkuNamesExPrefix(func(params *tSkuUpdateSkuNamesExPrefixParams) (retVal interface{}, errCode string, err error) {
|
||||
var skuIDList []int
|
||||
if err = jxutils.Strings2Objs(params.NameIDs, &skuIDList); err == nil {
|
||||
retVal, err = cms.UpdateSkuNamesExPrefix(params.Ctx, skuIDList, params.ExPrefix, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -537,3 +537,23 @@ func (c *StoreSkuController) GetStoreCategories() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 获取各平台所有门店某商品的价格
|
||||
// @Description 获取各平台所有门店某商品的价格
|
||||
// @Param token header string false "认证token"
|
||||
// @Param skuID formData int true "商品ID"
|
||||
// @Param vendorIDs formData string true "厂商ID列表"
|
||||
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||
// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetVendorStoreSkuPrice [post]
|
||||
func (c *StoreSkuController) GetVendorStoreSkuPrice() {
|
||||
var vendorIDList []int
|
||||
c.callGetVendorStoreSkuPrice(func(params *tStoreSkuGetVendorStoreSkuPriceParams) (retVal interface{}, errCode string, err error) {
|
||||
if jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil {
|
||||
retVal, err = cms.GetVendorStoreSkuPrice(params.Ctx, vendorIDList, params.SkuID, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func FilterMapByStructObject(mapData map[string]interface{}, obj interface{}, ob
|
||||
valid = make(map[string]interface{})
|
||||
invalid = make(map[string]interface{})
|
||||
for k, v := range mapData {
|
||||
if m[k] != nil && excludedMap[k] == 0 && v != nil && (!isCheckValue || !IsValueEqual(m[k], v)) {
|
||||
if m[k] != nil && excludedMap[k] == 0 /*&& v != nil*/ && (!isCheckValue || !IsValueEqual(m[k], v)) {
|
||||
valid[k] = v
|
||||
m[k] = v
|
||||
} else {
|
||||
|
||||
@@ -1278,6 +1278,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "UpdateSkuNamesExPrefix",
|
||||
Router: `/UpdateSkuNamesExPrefix`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "AddStoreCourierMap",
|
||||
@@ -1656,6 +1665,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetVendorStoreSkuPrice",
|
||||
Router: `/GetVendorStoreSkuPrice`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetVendorStoreSkusInfo",
|
||||
|
||||
Reference in New Issue
Block a user